Skip to content
Snippets Groups Projects
Commit 14d429f0 authored by Stefanie Gareis's avatar Stefanie Gareis
Browse files

resolving this feature:UI property section for setting ports bounds

refs 1067
parent 8615edd9
No related branches found
No related tags found
No related merge requests found
......@@ -18,8 +18,12 @@ $Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
package org.fortiss.tooling.base.ui.utils;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.FontMetrics;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Spinner;
import org.eclipse.swt.widgets.Text;
/**
* Factory class for easier creation of different widgets.
......@@ -27,7 +31,7 @@ import org.eclipse.swt.widgets.Spinner;
* @author ratiu
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating GREEN Hash: 15511F7D05406B4F9F823388E07DFF40
* @ConQAT.Rating YELLOW Hash: 5EAA89263AB31479A5547CEF1165F352
*/
public class WidgetsFactory {
......@@ -52,4 +56,31 @@ public class WidgetsFactory {
spinner.setSelection(selection);
return spinner;
}
/**
* Creates a new text field with a given size in characters. The text must be in a container
* with GridLayout.
*
* @param parent
* - the parent component
* @param style
* - the style
* @param initialText
* - the initial value
* @param charsNumber
* - maximum number of characters of this text
* @return the text field
*/
public static Text createText(Composite parent, int style, String initialText, int charsNumber) {
Text text = new Text(parent, style);
text.setText(initialText);
GC gc = new GC(text);
FontMetrics fm = gc.getFontMetrics();
int width = charsNumber * fm.getAverageCharWidth();
int height = fm.getHeight();
gc.dispose();
text.setLayoutData(new GridData(width, height));
parent.pack();
return text;
}
}
......@@ -56,7 +56,7 @@ import org.fortiss.tooling.kernel.service.ILibraryService;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: F463D51EE5F523EE8929648DB7D105C7
* @ConQAT.Rating YELLOW Hash: 7FD1F920BC8FC05E5ACF93DDE0A87F61
*/
public abstract class PropertySectionBase extends AbstractPropertySection {
......@@ -109,13 +109,25 @@ public abstract class PropertySectionBase extends AbstractPropertySection {
EObject eobj = (EObject)object;
if(ILibraryService.INSTANCE.isShadowElement(eobj)) {
for(Control c : composite.getChildren()) {
c.setEnabled(false);
}
disableControls();
}
}
}
/** Disables all children controls. */
protected void disableControls() {
for(Control c : composite.getChildren()) {
c.setEnabled(false);
}
}
/** Enables all children controls. */
protected void enableControls() {
for(Control c : composite.getChildren()) {
c.setEnabled(true);
}
}
/** This is used to set the single section input. The parameter may be null! */
protected abstract void setSectionInput(Object input);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment