Преглед изворни кода

Used XTextPropertyDescriptor from commons

Andreas Mülder пре 14 година
родитељ
комит
d144397532

+ 1 - 0
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/propertysheets/StatePropertySection.java

@@ -22,6 +22,7 @@ import com.google.inject.Injector;
 
 import de.itemis.gmf.runtime.commons.properties.descriptors.IFormPropertyDescriptor;
 import de.itemis.gmf.runtime.commons.properties.descriptors.TextPropertyDescriptor;
+import de.itemis.gmf.runtime.commons.properties.descriptors.XtextPropertyDescriptor;
 /**
  * Property Section for {@link StateEditPart}s. Consists of a
  * {@link TextPropertyDescriptor} for the name field and an

+ 1 - 0
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/propertysheets/StatechartPropertySection.java

@@ -23,6 +23,7 @@ import com.google.inject.Injector;
 import de.itemis.gmf.runtime.commons.properties.GenericFormBasedPropertySection;
 import de.itemis.gmf.runtime.commons.properties.descriptors.IFormPropertyDescriptor;
 import de.itemis.gmf.runtime.commons.properties.descriptors.TextPropertyDescriptor;
+import de.itemis.gmf.runtime.commons.properties.descriptors.XtextPropertyDescriptor;
 
 /**
  * Property Section for {@link StatechartTextEditPart}s. Consists of a

+ 1 - 0
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/propertysheets/TransitionPropertySection.java

@@ -22,6 +22,7 @@ import com.google.inject.Injector;
 
 import de.itemis.gmf.runtime.commons.properties.GenericFormBasedPropertySection;
 import de.itemis.gmf.runtime.commons.properties.descriptors.IFormPropertyDescriptor;
+import de.itemis.gmf.runtime.commons.properties.descriptors.XtextPropertyDescriptor;
 
 /**
  * Property Section for {@link TransitionEditPart}s. Consists of a

+ 0 - 79
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/propertysheets/XtextPropertyDescriptor.java

@@ -1,79 +0,0 @@
-/**
- * Copyright (c) 2011 committers of YAKINDU and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- * Contributors:
- * 	committers of YAKINDU - initial API and implementation
- * 
- */
-package org.yakindu.sct.ui.editor.propertysheets;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.jface.layout.GridDataFactory;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.widgets.Composite;
-
-import com.google.inject.Injector;
-
-import de.itemis.gmf.runtime.commons.properties.descriptors.AbstractPropertyDescriptor;
-import de.itemis.xtext.utils.jface.viewers.XtextCellEditor;
-
-/**
- * 
- * @author andreas muelder
- * 
- */
-public class XtextPropertyDescriptor extends AbstractPropertyDescriptor {
-
-	private final Injector injector;
-
-	public XtextPropertyDescriptor(EAttribute feature, String labelName,
-			Injector injector) {
-		super(feature, labelName);
-		this.injector = injector;
-	}
-
-	public StyledText createControl(Composite parent) {
-		XtextCellEditor editor = new XtextCellEditor(SWT.MULTI | SWT.BORDER
-				| SWT.V_SCROLL) {
-			@Override
-			protected void focusLost() {
-				// Default implementation disposes control on focus lost
-			}
-		};
-		getInjector().injectMembers(editor);
-		editor.create(parent);
-		editor.activate();
-		editor.getControl().setVisible(true);
-		GridDataFactory.fillDefaults().grab(true, true)
-				.applyTo(editor.getControl());
-		return (StyledText) editor.getControl();
-	}
-
-	public Object getControlValue() {
-		StyledText styledText = getControl();
-		return (styledText.getText() != null && styledText.getText().trim()
-				.length() != 0) ? styledText.getText().trim() : null;
-	}
-
-	public void setControlValue(Object value) {
-		if (value != null) {
-			Assert.isTrue(value instanceof String, "Illegal value " + value);
-			getControl().setText((String) value);
-		}
-	}
-
-	public Injector getInjector() {
-		return injector;
-	}
-
-	@Override
-	public StyledText getControl() {
-		return (StyledText) super.getControl();
-	}
-
-}