From: <pat...@us...> - 2010-11-12 16:51:06
|
Revision: 1152 http://cishell.svn.sourceforge.net/cishell/?rev=1152&view=rev Author: pataphil Date: 2010-11-12 16:50:55 +0000 (Fri, 12 Nov 2010) Log Message: ----------- * Made more Java 1.5 and cleaned up a bit. * Fixed bug in validation relating to multiple fields validating depending on each other. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/SWTGui.java trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/SWTGuiComposite.java trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/AbstractComponent.java trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/BooleanComponent.java trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/LabelingComponent.java trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/MultiValuedComponent.java trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/StringComponent.java Modified: trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/SWTGui.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/SWTGui.java 2010-11-12 16:47:14 UTC (rev 1151) +++ trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/SWTGui.java 2010-11-12 16:50:55 UTC (rev 1152) @@ -37,10 +37,6 @@ import org.osgi.service.metatype.MetaTypeProvider; import org.osgi.service.metatype.ObjectClassDefinition; -/** - * - * @author Bruce Herr (bh...@bh...) - */ public class SWTGui implements GUI, UpdateListener { private static final int MAXIMUM_INITIAL_DIALOGUE_HEIGHT = 500; @@ -53,8 +49,7 @@ private Button okButton; - public SWTGui(final Shell shell, int style, - String id, MetaTypeProvider provider) { + public SWTGui(final Shell shell, int style, String id, MetaTypeProvider provider) { this.shell = shell; if (provider == null) { @@ -62,20 +57,18 @@ } ObjectClassDefinition ocd = provider.getObjectClassDefinition(id, null); - shell.setText(ocd.getName()); - - - + this.shell.setText(ocd.getName()); + GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 1; - shell.setLayout(gridLayout); + this.shell.setLayout(gridLayout); - Font defaultFont = new Font(shell.getDisplay(), "SanSerif", 8, SWT.NONE); + Font defaultFont = new Font(this.shell.getDisplay(), "SanSerif", 8, SWT.NONE); //stuff to display a message String message = ocd.getDescription(); if(message != null && !message.equals("")){ - Label msg = new Label(shell, SWT.WRAP); + Label msg = new Label(this.shell, SWT.WRAP); msg.setText(message); msg.pack(true); GridData labelData = new GridData(); @@ -88,11 +81,11 @@ } //set up the user area where the main GUI will be set up using Parameters - composite = new SWTGuiComposite(shell, style, id, provider); + composite = new SWTGuiComposite(this.shell, style, id, provider); composite.addUpdateListener(this); //the group w/ ok and cancel - Composite buttonsGroup = new Composite(shell, SWT.NONE); + Composite buttonsGroup = new Composite(this.shell, SWT.NONE); FillLayout rowLayout = new FillLayout(); rowLayout.spacing = 5; buttonsGroup.setLayout(rowLayout); @@ -103,11 +96,11 @@ gridData.grabExcessHorizontalSpace = false; buttonsGroup.setLayoutData(gridData); - okButton = new Button(buttonsGroup, SWT.PUSH); - okButton.setText("OK"); - okButton.setSize(40, 20); - okButton.setFont(defaultFont); - okButton.addSelectionListener(new SelectionAdapter() { + this.okButton = new Button(buttonsGroup, SWT.PUSH); + this.okButton.setText("OK"); + this.okButton.setSize(40, 20); + this.okButton.setFont(defaultFont); + this.okButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { hitOk = true; close(); @@ -129,14 +122,14 @@ }); - shell.addDisposeListener(new DisposeListener() { + this.shell.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { if (!hitOk && listener != null) { listener.cancelled(); } }}); - shell.setDefaultButton(okButton); + this.shell.setDefaultButton(this.okButton); validate(); } @@ -145,10 +138,10 @@ * @see org.cishell.service.guibuilder.GUI#close() */ public void close() { - shell.getDisplay().syncExec(new Runnable() { + this.shell.getDisplay().syncExec(new Runnable() { public void run() { - shell.close(); - shell.dispose(); + SWTGui.this.shell.close(); + SWTGui.this.shell.dispose(); }}); } @@ -156,18 +149,18 @@ * @see org.cishell.service.guibuilder.GUI#isClosed() */ public boolean isClosed() { - return shell.isDisposed(); + return this.shell.isDisposed(); } /** * @see org.cishell.service.guibuilder.GUI#open() */ public void open() { - shell.getDisplay().syncExec(new Runnable() { + this.shell.getDisplay().syncExec(new Runnable() { public void run() { - shell.pack(); - resizeShell(shell); - shell.open(); + SWTGui.this.shell.pack(); + resizeShell(SWTGui.this.shell); + SWTGui.this.shell.open(); } private void resizeShell(Shell shell) { @@ -183,7 +176,7 @@ /** * @see org.cishell.service.guibuilder.GUI#openAndWait() */ - public Dictionary openAndWait() { + public Dictionary<String, Object> openAndWait() { open(); final Display display = shell.getDisplay(); @@ -201,11 +194,11 @@ } private static class OpenAndWaitListener implements SelectionListener { - Dictionary valuesEntered = null; + Dictionary<String, Object> valuesEntered = null; public void cancelled() {} - public void hitOk(Dictionary valuesEntered) { + public void hitOk(Dictionary<String, Object> valuesEntered) { this.valuesEntered = valuesEntered; } } @@ -220,11 +213,11 @@ public String validate() { String valid = composite.validate(); - //if valid is a string then the string is the error message - if (valid != null && valid.length() > 0) { - okButton.setEnabled(false); + // If valid is a string then the string is the error message. + if ((valid != null) && (valid.length() > 0)) { + this.okButton.setEnabled(false); } else { - okButton.setEnabled(true); + this.okButton.setEnabled(true); } return valid; Modified: trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/SWTGuiComposite.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/SWTGuiComposite.java 2010-11-12 16:47:14 UTC (rev 1151) +++ trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/SWTGuiComposite.java 2010-11-12 16:50:55 UTC (rev 1152) @@ -16,7 +16,6 @@ import java.util.Dictionary; import java.util.HashSet; import java.util.Hashtable; -import java.util.Iterator; import java.util.Set; import org.cishell.reference.gui.guibuilder.swt.builder.ComponentProvider; @@ -40,53 +39,50 @@ * @author Bruce Herr (bh...@bh...) */ public class SWTGuiComposite implements UpdateListener { - private ObjectClassDefinition ocd; - private Dictionary idToComponentMap; - private Dictionary enteredResponses; - protected Set listeners; + private ObjectClassDefinition objectClassDefinition; + private Dictionary<String, GUIComponent> idToComponentMap; + private Dictionary<String, Object> enteredResponses; + protected Set<UpdateListener> updateListeners; private Composite parent; private Composite parameterArea; - private ScrolledComposite scroll; - private int style; + private ScrolledComposite scrollingArea; - public SWTGuiComposite(Composite parent, int style, - String id, MetaTypeProvider provider) { + public SWTGuiComposite(Composite parent, int style, String id, MetaTypeProvider provider) { if (provider == null) { throw new IllegalArgumentException("Null MetaTypeProvider given"); } - this.idToComponentMap = new Hashtable(); - this.ocd = provider.getObjectClassDefinition(id, null); + this.idToComponentMap = new Hashtable<String, GUIComponent>(); + this.objectClassDefinition = provider.getObjectClassDefinition(id, null); this.parent = parent; - this.style = style; - this.listeners = new HashSet(); - this.enteredResponses = new Hashtable(); + this.updateListeners = new HashSet<UpdateListener>(); + this.enteredResponses = new Hashtable<String, Object>(); setupGUI(); - - AttributeDefinition[] attrs = ocd.getAttributeDefinitions(ObjectClassDefinition.ALL); - for (int i=0; i < attrs.length; i++) { - GUIComponent component = ComponentProvider.getInstance().createComponent(attrs[i]); - - component.setAttributeDefinition(attrs[i]); - component.createGUI(parameterArea, style); - idToComponentMap.put(attrs[i].getID(), component); + + for (AttributeDefinition attribute : + this.objectClassDefinition.getAttributeDefinitions(ObjectClassDefinition.ALL)) { + GUIComponent component = ComponentProvider.getInstance().createComponent(attribute); + + component.setAttributeDefinition(attribute); + component.createGUI(this.parameterArea, style); + this.idToComponentMap.put(attribute.getID(), component); component.addUpdateListener(this); Object value = component.getValue(); String valid = component.validate(); - if (value != null && (valid == null || valid.length() == 0)) { - enteredResponses.put(component.getAttributeDefinition().getID(), value); + if ((value != null) && ((valid == null) || (valid.length() == 0))) { + this.enteredResponses.put(component.getAttributeDefinition().getID(), value); } } - setScrollDimensions(scroll, parameterArea); + setScrollDimensions(this.scrollingArea, this.parameterArea); - parameterArea.addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - enteredResponses = getEnteredResponses(); + this.parameterArea.addDisposeListener(new DisposeListener() { + public void widgetDisposed(DisposeEvent event) { + SWTGuiComposite.this.enteredResponses = getEnteredResponses(); }}); } @@ -97,17 +93,17 @@ } private void setupGUI() { - scroll = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL); - scroll.setLayout(new GridLayout(1, true)); - scroll.setExpandHorizontal(true); - scroll.setExpandVertical(true); - scroll.setAlwaysShowScrollBars(false); + this.scrollingArea = new ScrolledComposite(this.parent, SWT.H_SCROLL | SWT.V_SCROLL); + this.scrollingArea.setLayout(new GridLayout(1, true)); + this.scrollingArea.setExpandHorizontal(true); + this.scrollingArea.setExpandVertical(true); + this.scrollingArea.setAlwaysShowScrollBars(false); - parameterArea = new Composite(scroll, SWT.NONE); - parameterArea.setLayout(new GridLayout(GUIComponent.MAX_SPAN+1,false)); + this.parameterArea = new Composite(scrollingArea, SWT.NONE); + this.parameterArea.setLayout(new GridLayout(GUIComponent.MAX_SPAN + 1, false)); - GridData gd = new GridData(SWT.FILL,SWT.FILL,true,true); - parameterArea.setLayoutData(gd); + GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); + this.parameterArea.setLayoutData(gridData); GridData userData = new GridData(); userData.grabExcessVerticalSpace = true; @@ -115,23 +111,28 @@ userData.verticalAlignment = SWT.FILL; userData.horizontalAlignment = SWT.FILL; - scroll.setLayoutData(userData); - scroll.setContent(parameterArea); + this.scrollingArea.setLayoutData(userData); + this.scrollingArea.setContent(this.parameterArea); } public ObjectClassDefinition getObjectClassDefinition() { - return ocd; + return this.objectClassDefinition; } public Object getResponse(String id) { - GUIComponent component = (GUIComponent) idToComponentMap.get(id); - - return component == null ? null : component.getValue(); + GUIComponent component = this.idToComponentMap.get(id); + + if (component != null) { + return component.getValue(); + } else { + return null; + } +// return component == null ? null : component.getValue(); } - public Dictionary getEnteredResponses() { - return enteredResponses; + public Dictionary<String, Object> getEnteredResponses() { + return this.enteredResponses; } /** @@ -139,7 +140,7 @@ * @return the shell */ public Shell getShell() { - return parent.getShell(); + return this.parent.getShell(); } /** @@ -147,22 +148,22 @@ * @return the composite */ public Composite getUserArea() { - return parameterArea; + return this.parameterArea; } public Composite getComposite() { - return scroll; + return this.scrollingArea; } public String validate() { String totalValid = ""; - - AttributeDefinition[] attrs = ocd.getAttributeDefinitions(ObjectClassDefinition.REQUIRED); - - for (int i=0; i < attrs.length; i++) { - GUIComponent component = (GUIComponent) idToComponentMap.get(attrs[i].getID()); + + for (AttributeDefinition attribute : this.objectClassDefinition.getAttributeDefinitions( + ObjectClassDefinition.REQUIRED)) { + GUIComponent component = this.idToComponentMap.get(attribute.getID()); String valid = component.validate(); - if (valid != null && valid.length() > 0) { + + if ((valid != null) && (valid.length() > 0)) { totalValid += "\"" + valid + "\"; "; } } @@ -174,22 +175,22 @@ Object value = component.getValue(); String valid = component.validate(); - if (value != null && (valid == null || valid.length() == 0)) { - enteredResponses.put(component.getAttributeDefinition().getID(), value); + if ((value != null) && ((valid == null) || (valid.length() == 0))) { + this.enteredResponses.put(component.getAttributeDefinition().getID(), value); } else { - enteredResponses.remove(component.getAttributeDefinition().getID()); + this.enteredResponses.remove(component.getAttributeDefinition().getID()); } - - for (Iterator i=listeners.iterator(); i.hasNext(); ) { - ((UpdateListener) i.next()).componentUpdated(component); + + for (UpdateListener listener : this.updateListeners) { + listener.componentUpdated(component); } } public void addUpdateListener(UpdateListener listener) { - listeners.add(listener); + this.updateListeners.add(listener); } public void removeUpdateListener(UpdateListener listener) { - listeners.remove(listener); + this.updateListeners.remove(listener); } } Modified: trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/AbstractComponent.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/AbstractComponent.java 2010-11-12 16:47:14 UTC (rev 1151) +++ trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/AbstractComponent.java 2010-11-12 16:50:55 UTC (rev 1152) @@ -14,7 +14,6 @@ package org.cishell.reference.gui.guibuilder.swt.builder; import java.util.HashSet; -import java.util.Iterator; import java.util.Set; import org.eclipse.swt.widgets.Composite; @@ -26,51 +25,53 @@ * @author Bruce Herr (bh...@bh...) */ public abstract class AbstractComponent implements GUIComponent { - protected AttributeDefinition attr; + protected AttributeDefinition attribute; protected boolean drawsLabel; - protected int numColumns; - protected Set listeners; + protected int columnCount; + protected Set<UpdateListener> listeners; public abstract void setValue(Object value); public abstract Object getValue(); public abstract String validate(); public abstract Control createGUI(Composite parent, int style); - public AbstractComponent(boolean drawsLabel, int numColumns) { + public AbstractComponent(boolean drawsLabel, int columnCount) { this.drawsLabel = drawsLabel; - this.numColumns = numColumns; - this.listeners = new HashSet(); + this.columnCount = columnCount; + this.listeners = new HashSet<UpdateListener>(); } public AttributeDefinition getAttributeDefinition() { - if (attr == null) { + if (this.attribute == null) { throw new IllegalStateException("AttributeDefinition has not been set"); } - return attr; + return this.attribute; } - public void setAttributeDefinition(AttributeDefinition attr) { - this.attr = attr; + public void setAttributeDefinition(AttributeDefinition attribute) { + this.attribute = attribute; } + public boolean drawsLabel() { - return drawsLabel; + return this.drawsLabel; } + public int getColumns() { - return numColumns; + return this.columnCount; } protected void update() { - for (Iterator i=listeners.iterator(); i.hasNext(); ) { - ((UpdateListener) i.next()).componentUpdated(this); + for (UpdateListener listener : this.listeners) { + listener.componentUpdated(this); } } public void addUpdateListener(UpdateListener listener) { - listeners.add(listener); + this.listeners.add(listener); } public void removeUpdateListener(UpdateListener listener) { - listeners.remove(listener); + this.listeners.remove(listener); } } Modified: trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/BooleanComponent.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/BooleanComponent.java 2010-11-12 16:47:14 UTC (rev 1151) +++ trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/BooleanComponent.java 2010-11-12 16:50:55 UTC (rev 1152) @@ -32,18 +32,18 @@ public Control createGUI(Composite parent, int style) { checkbox = new Button(parent, SWT.CHECK); - GridData gridData = new GridData(SWT.LEFT,SWT.CENTER,false,false); + GridData gridData = new GridData(SWT.LEFT, SWT.CENTER, false, false); gridData.horizontalSpan = MAX_SPAN; checkbox.setLayoutData(gridData); - String label = attr.getName(); + String label = attribute.getName(); if(label != null) checkbox.setText(label); else checkbox.setText(""); checkbox.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { + public void widgetSelected(SelectionEvent event) { update(); }}); @@ -51,11 +51,11 @@ } public Object getValue() { - return checkbox.getSelection() ? Boolean.TRUE : Boolean.FALSE; + return Boolean.valueOf(this.checkbox.getSelection()); } public void setValue(Object value) { - if (value instanceof Boolean && value != null) { + if ((value instanceof Boolean) && (value != null)) { checkbox.setSelection(((Boolean) value).booleanValue()); } else { checkbox.setSelection(false); @@ -63,6 +63,6 @@ } public String validate() { - return attr.validate(""+checkbox.getSelection()); + return attribute.validate("" + checkbox.getSelection()); } } Modified: trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/LabelingComponent.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/LabelingComponent.java 2010-11-12 16:47:14 UTC (rev 1151) +++ trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/LabelingComponent.java 2010-11-12 16:50:55 UTC (rev 1152) @@ -50,20 +50,22 @@ setAttributeDefinition(childComponent.getAttributeDefinition()); if (!childComponent.drawsLabel()) { - numColumns++; + columnCount++; } - String description = attr.getDescription(); - if (description != null && description.length() > 0) { - numColumns++; + String description = attribute.getDescription(); + + if ((description != null) && (description.length() > 0)) { + columnCount++; } + childComponent.addUpdateListener(this); } public Control createGUI(Composite parent, int style) { if (drawsLabel && !childComponent.drawsLabel()) { - String labelText = attr.getName(); + String labelText = attribute.getName(); if (labelText == null) { labelText = ""; } @@ -81,7 +83,6 @@ } private void createAndAddDescriptionButton(Control control, Composite parent) { - /* * Create the description button, and add it to the parent. * */ @@ -116,13 +117,80 @@ descriptionButton.addSelectionListener(listener); } + + /** + * Sets the location for a hovering shell. + * + * @param descriptionShell + * the object that is to hover + * @param position + * the position of a widget to hover over + */ + private void setHoverLocation(Shell descriptionShell, Point position) { + Rectangle displayBounds = descriptionShell.getDisplay().getBounds(); + Rectangle shellBounds = descriptionShell.getBounds(); + shellBounds.x = Math.max(Math.min(position.x + + DESCRIPTION_SHELL_LEFT_MARGIN, displayBounds.width + - shellBounds.width), 0); + + shellBounds.y = Math.max(Math.min(position.y, displayBounds.height + - shellBounds.height), 0); + descriptionShell.setBounds(shellBounds); + } + + protected void setDefaultValue() { + String[] defaults = attribute.getDefaultValue(); + + if ((defaults != null) && (defaults.length > 0)) { + Object value = StringConverter.getInstance().stringToObject(attribute, defaults[0]); + setValue(value); + } + } + + public Object getValue() { + return childComponent.getValue(); + } + + public void setValue(Object value) { + childComponent.setValue(value); + } + + public String validate() { + String valid = childComponent.validate(); + + // If valid is a string then the string is the error message. + if ((valid != null) && (valid.length() > 0)) { + label.setForeground(ERROR_COLOR); + } else { + label.setForeground(null); + } + + return valid; + } + + public void componentUpdated(GUIComponent component) { + if (!childComponent.drawsLabel()) { + validate(); + } + + update(); + } + + private String getDescriptionText() { + String descriptionText = attribute.getDescription(); + if (descriptionText == null || descriptionText.length() == 0) { + descriptionText = DEFAULT_DESCRIPTION_TEXT; + } + + return descriptionText; + } + /* * Adds selection listener to the button. Whenever a button is pressed it triggers * the button selected event, which causes the creation of a new Description hover. * Once a button is unselected it deletes the Description hover. * */ class DescriptionButtonListener implements SelectionListener { - private Shell descriptionShell = null; private String descText; @@ -180,7 +248,6 @@ } } - private Shell createDescriptionShell(final String descText, Button descriptionButton) { Shell descriptionShell = new Shell(descriptionButton.getShell(), SWT.NONE); @@ -232,71 +299,4 @@ } } } - - /** - * Sets the location for a hovering shell. - * - * @param descriptionShell - * the object that is to hover - * @param position - * the position of a widget to hover over - */ - private void setHoverLocation(Shell descriptionShell, Point position) { - Rectangle displayBounds = descriptionShell.getDisplay().getBounds(); - Rectangle shellBounds = descriptionShell.getBounds(); - shellBounds.x = Math.max(Math.min(position.x - + DESCRIPTION_SHELL_LEFT_MARGIN, displayBounds.width - - shellBounds.width), 0); - - shellBounds.y = Math.max(Math.min(position.y, displayBounds.height - - shellBounds.height), 0); - descriptionShell.setBounds(shellBounds); - } - - protected void setDefaultValue() { - String[] defaults = attr.getDefaultValue(); - - if (defaults != null && defaults.length > 0) { - - Object value = StringConverter.getInstance().stringToObject(attr, - defaults[0]); - setValue(value); - } - } - - public Object getValue() { - return childComponent.getValue(); - } - - public void setValue(Object value) { - childComponent.setValue(value); - } - - public String validate() { - return childComponent.validate(); - } - - public void componentUpdated(GUIComponent component) { - if (!childComponent.drawsLabel()) { - String valid = validate(); - - // if valid is a string then the string is the error message - if (valid != null && valid.length() > 0) { - label.setForeground(ERROR_COLOR); - } else { - label.setForeground(null); - } - } - update(); - } - - private String getDescriptionText() { - String descriptionText = attr.getDescription(); - if (descriptionText == null || descriptionText.length() == 0) { - descriptionText = DEFAULT_DESCRIPTION_TEXT; - } - - return descriptionText; - } - } Modified: trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/MultiValuedComponent.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/MultiValuedComponent.java 2010-11-12 16:47:14 UTC (rev 1151) +++ trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/MultiValuedComponent.java 2010-11-12 16:50:55 UTC (rev 1152) @@ -54,7 +54,7 @@ } protected synchronized void addComponent(int position) { - GUIComponent component = ComponentProvider.getInstance().createBasicComponent(attr); + GUIComponent component = ComponentProvider.getInstance().createBasicComponent(attribute); Control control = component.createGUI(panel, style); Modified: trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/StringComponent.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/StringComponent.java 2010-11-12 16:47:14 UTC (rev 1151) +++ trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/StringComponent.java 2010-11-12 16:50:55 UTC (rev 1152) @@ -50,15 +50,14 @@ } public Control createGUI(Composite parent, int style) { - GridData gd = new GridData(SWT.FILL,SWT.CENTER,true,true); gd.horizontalSpan = MAX_SPAN-1; gd.minimumWidth = 100; - optionValues = attr.getOptionValues(); + optionValues = attribute.getOptionValues(); if(optionValues != null) { combo = new Combo(parent, style | SWT.DROP_DOWN | SWT.READ_ONLY); - String[] optionLabels = attr.getOptionLabels(); + String[] optionLabels = attribute.getOptionLabels(); if(optionLabels == null) { combo.setItems(optionValues); } else { @@ -78,18 +77,20 @@ return combo; } else { int flags; - if(multiline) { + + if (multiline) { flags = style | SWT.BORDER | SWT.MULTI | SWT.V_SCROLL; gd.minimumHeight = 100; gd.minimumWidth = 250; } else { flags = style | SWT.BORDER; } + textField = new Text(parent, flags); textField.setLayoutData(gd); textField.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { + public void modifyText(ModifyEvent event) { update(); } }); @@ -101,9 +102,9 @@ public Object getValue() { Object value; if(combo == null) { - value = StringConverter.getInstance().stringToObject(attr, textField.getText()); + value = StringConverter.getInstance().stringToObject(attribute, textField.getText()); } else { - value = StringConverter.getInstance().stringToObject(attr, getListValue()); + value = StringConverter.getInstance().stringToObject(attribute, getListValue()); } return value; @@ -122,9 +123,9 @@ return "Invalid basic value"; } if(combo == null) { - return attr.validate(textField.getText()); + return attribute.validate(textField.getText()); } else { - return attr.validate(getListValue()); + return attribute.validate(getListValue()); } } @@ -151,10 +152,10 @@ /* TODO: Log this (or do something with it besides printint it to a place most * users won't see it)? */ - String warningMessage = + /*String warningMessage = "Attempted to set combo box to a value that didn't exist inside the " + "combo box."; - System.err.println(warningMessage); + System.err.println(warningMessage);*/ } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |