From: <pat...@us...> - 2009-08-25 19:45:35
|
Revision: 938 http://cishell.svn.sourceforge.net/cishell/?rev=938&view=rev Author: pataphil Date: 2009-08-25 19:45:26 +0000 (Tue, 25 Aug 2009) Log Message: ----------- * Fixed a minor file path issue (changed back slashes to forward slashes). Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/AbstractDialog.java trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/DirectoryComponent.java trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/FileComponent.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/StringComponent.java Modified: trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/AbstractDialog.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/AbstractDialog.java 2009-08-25 18:31:48 UTC (rev 937) +++ trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/AbstractDialog.java 2009-08-25 19:45:26 UTC (rev 938) @@ -196,7 +196,7 @@ } /** - * Sets the Description of this AbstractDialog. This is the text that is displayed in the + * Sets the Description of this AbstractDialog. This is the textField that is displayed in the * top section of the Dialog window, giving information about the question that is being * asked or the information that is being given. * @@ -207,7 +207,7 @@ } /** - * Sets the details text of this AbstractDialog. This is the text that is displayed in the lower + * Sets the details textField of this AbstractDialog. This is the textField that is displayed in the lower * section of the Dialog window when the user presses the "Details >>" button. If this String * is null or the empty string, the details button will be disabled. * @@ -338,7 +338,7 @@ } /* - * creates the details text box when the "Details >>" button is toggled + * creates the details textField box when the "Details >>" button is toggled */ private void setupDetails() { detailsText = new Text(shell, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL); @@ -357,9 +357,9 @@ * Open a standard error dialog with OK button * * @param parent the parent Shell of this dialog - * @param title the text to display in the title bar of this dialog + * @param title the textField to display in the title bar of this dialog * @param message the message to give in the dialog's body - * @param details the text to put in the details pane to be visible when the + * @param details the textField to put in the details pane to be visible when the * "Details >>" button is pressed (can be null or empty, resulting * in the "Details >>" button not being enabled) * @return true if the dialog was exited by pressing the OK button, false @@ -373,9 +373,9 @@ * Open a standard information dialog with OK button * * @param parent the parent Shell of this dialog - * @param title the text to display in the title bar of this dialog + * @param title the textField to display in the title bar of this dialog * @param message the message to give in the dialog's body - * @param details the text to put in the details pane to be visible when the + * @param details the textField to put in the details pane to be visible when the * "Details >>" button is pressed (can be null or empty, resulting * in the "Details >>" button not being enabled) * @return true if the dialog was exited by pressing the OK button, false * if it was cancelled by pressing the 'x' in the title bar @@ -388,9 +388,9 @@ * Open a standard warning dialog with OK button * * @param parent the parent Shell of this dialog - * @param title the text to display in the title bar of this dialog + * @param title the textField to display in the title bar of this dialog * @param message the message to give in the dialog's body - * @param details the text to put in the details pane to be visible when the + * @param details the textField to put in the details pane to be visible when the * "Details >>" button is pressed (can be null or empty, resulting * in the "Details >>" button not being enabled) * @return true if the dialog was exited by pressing the OK button, false * if it was cancelled by pressing the 'x' in the title bar @@ -403,9 +403,9 @@ * Open a standard question dialog with Yes/No buttons * * @param parent the parent Shell of this dialog - * @param title the text to display in the title bar of this dialog + * @param title the textField to display in the title bar of this dialog * @param message the message to give in the dialog's body - * @param details the text to put in the details pane to be visible when the + * @param details the textField to put in the details pane to be visible when the * "Details >>" button is pressed (can be null or empty, resulting * in the "Details >>" button not being enabled) * @return true if the dialog was exited by pressing the OK button, false * if it was cancelled by pressing the 'x' in the title bar or pressing the @@ -419,9 +419,9 @@ * Open a standard confirmation dialog with OK/Cancel buttons * * @param parent the parent Shell of this dialog - * @param title the text to display in the title bar of this dialog + * @param title the textField to display in the title bar of this dialog * @param message the message to give in the dialog's body - * @param details the text to put in the details pane to be visible when the + * @param details the textField to put in the details pane to be visible when the * "Details >>" button is pressed (can be null or empty, resulting * in the "Details >>" button not being enabled) * @return true if the dialog was exited by pressing the OK button, false * if it was cancelled by pressing the 'x' in the title bar or pressing Modified: trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/DirectoryComponent.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/DirectoryComponent.java 2009-08-25 18:31:48 UTC (rev 937) +++ trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/DirectoryComponent.java 2009-08-25 19:45:26 UTC (rev 938) @@ -21,11 +21,13 @@ public class DirectoryComponent extends FileComponent { protected String getFile(String defaultPath) { - DirectoryDialog dialog = new DirectoryDialog(text.getShell(), SWT.OPEN); - dialog.setText("Select a Directory"); - dialog.setFilterPath(defaultPath); - - return dialog.open(); + DirectoryDialog directorySelectorDialog = + new DirectoryDialog(textField.getShell(), SWT.OPEN); + directorySelectorDialog.setText("Select a Directory"); + directorySelectorDialog.setFilterPath(defaultPath); + String chosenDirectoryPath = directorySelectorDialog.open(); + + return fixPath(chosenDirectoryPath); } protected String validate(File file) { Modified: trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/FileComponent.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/FileComponent.java 2009-08-25 18:31:48 UTC (rev 937) +++ trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/FileComponent.java 2009-08-25 19:45:26 UTC (rev 938) @@ -16,6 +16,8 @@ import java.io.File; import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; @@ -25,7 +27,7 @@ import org.eclipse.swt.widgets.FileDialog; public class FileComponent extends StringComponent { - protected Button browse; + protected Button browseButton; private static Object currentValue; public FileComponent() { @@ -37,29 +39,34 @@ } public Control createGUI(Composite parent, int style) { - super.createGUI(parent, style); //creates the text component + // Creates the textField component. + super.createGUI(parent, style); - Object data = text.getLayoutData(); - if (data != null && data instanceof GridData) { - GridData gd = (GridData) data; - gd.horizontalSpan--; //make room for the browse button + Object layoutData = this.textField.getLayoutData(); + + if (layoutData != null && layoutData instanceof GridData) { + GridData gridData = (GridData)layoutData; + gridData.horizontalSpan--;//make room for the browseButton button } - browse = new Button(parent, SWT.PUSH); - browse.setText("Browse"); - //when click "Browse", here is the listener - browse.addSelectionListener(new SelectionAdapter() { + this.browseButton = new Button(parent, SWT.PUSH); + this.browseButton.setText("Browse"); + + // When click "Browse", here is the listener. + browseButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { - String fileName = getFile(text.getText()); - //remember this new file/directory selection - currentValue = fileName; + String fileName = getFile(textField.getText()); + + // Remember this new file/directory selection. + currentValue = fixPath(fileName); + if (fileName != null) { - text.setText(fileName); + textField.setText(fileName); update(); } }}); - return text; + return this.textField; } /** @@ -68,11 +75,13 @@ * @return the file they chose */ protected String getFile(String defaultPath) { - FileDialog dialog = new FileDialog(text.getShell(), SWT.OPEN); - dialog.setText("Select a File"); - dialog.setFilterPath(defaultPath); - - return dialog.open(); + FileDialog fileSelectorDialog = + new FileDialog(textField.getShell(), SWT.OPEN); + fileSelectorDialog.setText("Select a File"); + fileSelectorDialog.setFilterPath(defaultPath); + String chosenFilePath = fileSelectorDialog.open(); + + return fixPath(chosenFilePath); } protected String validate(File file) { @@ -84,7 +93,7 @@ } public String validate() { - File file = new File(text.getText()); + File file = new File(textField.getText()); String valid = validate(file); if (valid.length() > 0) { //length > 0 means an error @@ -98,6 +107,10 @@ return "file:"; } + public Object getValue() { + return fixPath(super.getValue().toString()); + } + public void setValue(Object value) { if (value != null && value.toString().equals(getKeyword())) { @@ -114,6 +127,16 @@ } - super.setValue(value); + super.setValue(fixPath(value.toString())); } + + public static String fixPath(String path) { + if (path != null) { + String fixedPath = path.replace('\\', '/'); + + return fixedPath; + } else { + return null; + } + } } 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 2009-08-25 18:31:48 UTC (rev 937) +++ trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/LabelingComponent.java 2009-08-25 19:45:26 UTC (rev 938) @@ -155,7 +155,7 @@ /* * Creation of a new description shell, which is a hover containing the - * description text. + * description textField. */ this.descriptionShell = createDescriptionShell(descText, descriptionButton); 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 2009-08-25 18:31:48 UTC (rev 937) +++ trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/StringComponent.java 2009-08-25 19:45:26 UTC (rev 938) @@ -31,7 +31,7 @@ * @author Bruce Herr (bh...@bh...) */ public class StringComponent extends AbstractComponent { - protected Text text; + protected Text textField; protected Combo combo; protected String[] optionValues; @@ -48,7 +48,6 @@ GridData gd = new GridData(SWT.FILL,SWT.CENTER,true,false); gd.horizontalSpan = MAX_SPAN-1; gd.minimumWidth = 100; - optionValues = attr.getOptionValues(); if(optionValues != null) { combo = new Combo(parent, style | SWT.DROP_DOWN | SWT.READ_ONLY); @@ -72,23 +71,23 @@ return combo; } else { - text = new Text(parent, style | SWT.BORDER); - text.setLayoutData(gd); + textField = new Text(parent, style | SWT.BORDER); + textField.setLayoutData(gd); - text.addModifyListener(new ModifyListener() { + textField.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { update(); } }); - return text; + return textField; } } public Object getValue() { Object value; if(combo == null) { - value = StringConverter.getInstance().stringToObject(attr, text.getText()); + value = StringConverter.getInstance().stringToObject(attr, textField.getText()); } else { value = StringConverter.getInstance().stringToObject(attr, getListValue()); } @@ -109,15 +108,15 @@ return "Invalid basic value"; } if(combo == null) { - return attr.validate(text.getText()); + return attr.validate(textField.getText()); } else { return attr.validate(getListValue()); } } public void setValue(Object value) { - if (text != null) { - text.setText(value == null ? "" : value.toString()); + if (textField != null) { + textField.setText(value == null ? "" : value.toString()); } else if (combo != null) { int setComboToIndex = -1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |