From: <pat...@us...> - 2009-08-15 20:53:16
|
Revision: 925 http://cishell.svn.sourceforge.net/cishell/?rev=925&view=rev Author: pataphil Date: 2009-08-15 20:53:04 +0000 (Sat, 15 Aug 2009) Log Message: ----------- * Fixed some GUI layout issues. * Added clear button for the first related file selector field, the executable file selector field, and the source code files selector field. * Fixed template string insert-placeholder functionality. Modified Paths: -------------- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/providers/PlatformOptionProvider.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/ChooseSourceCodeFilesPanel.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/SpecifyTemplateStringPanel.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pages/ChooseSourceCodeFilesPage.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pages/SpecifyTemplateStringPage.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/NewStaticExecutableAlgorithmTemplate.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/NewStaticExecutableAlgorithmWizard.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/widgets/ChooseExecutableFileWidget.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/widgets/ChooseFileWidget.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/widgets/ChooseRelatedFilesWidget.java Added Paths: ----------- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/optiontypes/ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/optiontypes/CustomStringOption.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/optiontypes/PlatformOption.java Removed Paths: ------------- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/providers/PlatformOption.java Added: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/optiontypes/CustomStringOption.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/optiontypes/CustomStringOption.java (rev 0) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/optiontypes/CustomStringOption.java 2009-08-15 20:53:04 UTC (rev 925) @@ -0,0 +1,127 @@ +package org.cishell.templates.staticexecutable.optiontypes; + +import org.eclipse.pde.ui.templates.BaseOptionTemplateSection; +import org.eclipse.pde.ui.templates.TemplateOption; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +public class CustomStringOption extends TemplateOption { + public final static int DEFAULT_STYLE = SWT.SINGLE | SWT.BORDER; + + protected Text textWidget; + protected Label labelWidget; + protected boolean shouldIgnoreListener; + protected int style; + + public CustomStringOption( + BaseOptionTemplateSection section, String name, String label) { + super(section, name, label); + + this.style = DEFAULT_STYLE; + setRequired(true); + } + + public Text getTextWidget() { + return this.textWidget; + } + + public Label getLabelWidget() { + return this.labelWidget; + } + + public void setReadOnly(boolean readOnly) { + if (readOnly) { + this.style = DEFAULT_STYLE | SWT.READ_ONLY; + } else { + this.style = DEFAULT_STYLE; + } + } + + public String getText() { + if (getValue() != null) { + return getValue().toString(); + } else { + return null; + } + } + + public void setText(String newText) { + setValue(newText); + } + + public void setValue(Object value) { + super.setValue(value); + + if (this.textWidget != null) { + this.shouldIgnoreListener = true; + String textValue = getText(); + + if (textValue != null) { + this.textWidget.setText(textValue); + } else { + this.textWidget.setText(""); + } + + this.shouldIgnoreListener = false; + } + } + + public void createControl(Composite parent, int span) { + int textWidgetHorizontalSpan; + + if (span >= 0) { + this.labelWidget = createLabel(parent, 1); + this.labelWidget.setEnabled(isEnabled()); + + textWidgetHorizontalSpan = span - 1; + } else { + textWidgetHorizontalSpan = -span; + } + + this.textWidget = new Text(parent, style); + + if (getValue() != null) { + this.textWidget.setText(getValue().toString()); + } + + GridData gridData = new GridData(GridData.FILL_HORIZONTAL); + gridData.horizontalSpan = textWidgetHorizontalSpan; + this.textWidget.setLayoutData(gridData); + this.textWidget.setEnabled(isEnabled()); + + this.textWidget.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent modifyEvent) { + if (CustomStringOption.this.shouldIgnoreListener) { + return; + } + + CustomStringOption.super.setValue( + CustomStringOption.this.textWidget.getText()); + getSection().validateOptions(CustomStringOption.this); + } + }); + } + + public boolean isEmpty() { + if (getValue() == null || + getValue().toString().length() == 0) { + return false; + } else { + return true; + } + } + + public void setEnabled(boolean enabled) { + super.setEnabled(enabled); + + if (this.labelWidget != null) { + this.labelWidget.setEnabled(enabled); + this.textWidget.setEnabled(enabled); + } + } +} \ No newline at end of file Copied: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/optiontypes/PlatformOption.java (from rev 922, trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/providers/PlatformOption.java) =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/optiontypes/PlatformOption.java (rev 0) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/optiontypes/PlatformOption.java 2009-08-15 20:53:04 UTC (rev 925) @@ -0,0 +1,27 @@ +package org.cishell.templates.staticexecutable.optiontypes; + +import org.eclipse.pde.ui.templates.BaseOptionTemplateSection; + +public class PlatformOption extends CustomStringOption { + private String platformName; + private String platformPath; + + public PlatformOption(BaseOptionTemplateSection section, + String name, + String label, + String platformName, + String platformPath) { + super(section, name, label); + + this.platformName = platformName; + this.platformPath = platformPath; + } + + public String getPlatformName() { + return this.platformName; + } + + public String getPlatformPath() { + return this.platformPath; + } +} \ No newline at end of file Property changes on: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/optiontypes/PlatformOption.java ___________________________________________________________________ Added: svn:mergeinfo + Deleted: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/providers/PlatformOption.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/providers/PlatformOption.java 2009-08-14 22:14:40 UTC (rev 924) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/providers/PlatformOption.java 2009-08-15 20:53:04 UTC (rev 925) @@ -1,126 +0,0 @@ -package org.cishell.templates.staticexecutable.providers; - -import org.eclipse.pde.ui.templates.BaseOptionTemplateSection; -import org.eclipse.pde.ui.templates.TemplateOption; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; - -public class PlatformOption extends TemplateOption { - public final static int DEFAULT_STYLE = SWT.SINGLE | SWT.BORDER; - - private String platformName; - private String platformPath; - private Text textWidget; - private Label labelWidget; - private boolean shouldIgnoreListener; - private int style; - - public PlatformOption(BaseOptionTemplateSection section, - String name, - String label, - String platformName, - String platformPath) { - super(section, name, label); - - this.style = DEFAULT_STYLE; - setRequired(true); - - this.platformName = platformName; - this.platformPath = platformPath; - } - - public String getPlatformName() { - return this.platformName; - } - - public String getPlatformPath() { - return this.platformPath; - } - - public void setReadOnly(boolean readOnly) { - if (readOnly) { - this.style = DEFAULT_STYLE | SWT.READ_ONLY; - } else { - this.style = DEFAULT_STYLE; - } - } - - public String getText() { - if (getValue() != null) { - return getValue().toString(); - } else { - return null; - } - } - - public void setText(String newText) { - setValue(newText); - } - - public void setValue(Object value) { - super.setValue(value); - - if (this.textWidget != null) { - this.shouldIgnoreListener = true; - String textValue = getText(); - - if (textValue != null) { - this.textWidget.setText(textValue); - } else { - this.textWidget.setText(""); - } - - this.shouldIgnoreListener = false; - } - } - - public void createControl(Composite parent, int span) { - this.labelWidget = createLabel(parent, 1); - this.labelWidget.setEnabled(isEnabled()); - this.textWidget = new Text(parent, style); - - if (getValue() != null) { - this.textWidget.setText(getValue().toString()); - } - - GridData gridData = new GridData(GridData.FILL_HORIZONTAL); - gridData.horizontalSpan = span - 1; - this.textWidget.setLayoutData(gridData); - this.textWidget.setEnabled(isEnabled()); - - this.textWidget.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent modifyEvent) { - if (PlatformOption.this.shouldIgnoreListener) { - return; - } - - PlatformOption.super.setValue( - PlatformOption.this.textWidget.getText()); - getSection().validateOptions(PlatformOption.this); - } - }); - } - - public boolean isEmpty() { - if (getValue() == null || - getValue().toString().length() == 0) { - return false; - } else { - return true; - } - } - - public void setEnabled(boolean enabled) { - super.setEnabled(enabled); - - if (this.labelWidget != null) { - this.labelWidget.setEnabled(enabled); - this.textWidget.setEnabled(enabled); - } - } -} \ No newline at end of file Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/providers/PlatformOptionProvider.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/providers/PlatformOptionProvider.java 2009-08-14 22:14:40 UTC (rev 924) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/providers/PlatformOptionProvider.java 2009-08-15 20:53:04 UTC (rev 925) @@ -1,5 +1,6 @@ package org.cishell.templates.staticexecutable.providers; +import org.cishell.templates.staticexecutable.optiontypes.PlatformOption; import org.eclipse.pde.ui.templates.TemplateOption; public interface PlatformOptionProvider { Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/ChooseSourceCodeFilesPanel.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/ChooseSourceCodeFilesPanel.java 2009-08-14 22:14:40 UTC (rev 924) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/ChooseSourceCodeFilesPanel.java 2009-08-15 20:53:04 UTC (rev 925) @@ -1,5 +1,6 @@ package org.cishell.templates.wizards.pagepanels; +import org.cishell.templates.staticexecutable.optiontypes.CustomStringOption; import org.cishell.templates.wizards.widgets.ChooseFileWidget; import org.eclipse.pde.ui.templates.TemplateOption; import org.eclipse.swt.SWT; @@ -13,7 +14,7 @@ public ChooseSourceCodeFilesPanel( Composite parent, int style, - TemplateOption sourceCodeFilesLocationOption) { + CustomStringOption sourceCodeFilesLocationOption) { super(parent, style); setLayout(createLayoutForThis()); @@ -28,7 +29,7 @@ } private void createChooseSourceCodeFilesWidget( - TemplateOption sourceCodeFilesLocationOption) { + CustomStringOption sourceCodeFilesLocationOption) { int parentWidth = this.getParent().computeSize(SWT.DEFAULT, SWT.DEFAULT).x; ChooseFileWidget fileSelector = new ChooseFileWidget( Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/SpecifyTemplateStringPanel.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/SpecifyTemplateStringPanel.java 2009-08-14 22:14:40 UTC (rev 924) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/SpecifyTemplateStringPanel.java 2009-08-15 20:53:04 UTC (rev 925) @@ -1,12 +1,13 @@ package org.cishell.templates.wizards.pagepanels; +import org.cishell.templates.staticexecutable.optiontypes.CustomStringOption; import org.cishell.templates.staticexecutable.providers.InputDataProvider; import org.cishell.templates.staticexecutable.providers.InputParameterProvider; import org.cishell.templates.wizards.staticexecutable.InputDataItem; -import org.eclipse.pde.ui.templates.TemplateOption; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; @@ -16,6 +17,7 @@ import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.TableItem; +import org.eclipse.swt.widgets.Text; import org.osgi.service.metatype.AttributeDefinition; /* @@ -35,12 +37,11 @@ public static final int TABLE_HEIGHT = 300; private Table placeholderTable; - private Button insertPlaceholderButton; - private TemplateOption templateStringOption; + private CustomStringOption templateStringOption; public SpecifyTemplateStringPanel(Composite parent, int style, - TemplateOption templateStringOption) { + CustomStringOption templateStringOption) { super(parent, style); this.templateStringOption = templateStringOption; @@ -49,7 +50,7 @@ createHeader(); this.placeholderTable = createPlaceholderTable(); - this.insertPlaceholderButton = createInsertPlaceholderButton(); + createInsertPlaceholderButton(); createTemplateStringText(); } @@ -140,14 +141,12 @@ return placeholderTable; } - private Button createInsertPlaceholderButton() { + private void createInsertPlaceholderButton() { Button insertPlaceholderButton = new Button(this, SWT.PUSH); insertPlaceholderButton.setLayoutData( createInsertPlaceholderButtonLayoutData()); insertPlaceholderButton.setText(INSERT_PLACEHOLDER_BUTTON_LABEL); insertPlaceholderButton.addSelectionListener(this); - - return insertPlaceholderButton; } private void createTemplateStringText() { @@ -202,32 +201,66 @@ } private void insertPlaceholder(String placeholder) { - /*if (!this.templateStringOption.getSelectionText().equals("")) { - // If there is a selection, replace the selection with the - // placeholder. - this.templateStringText.insert(placeholder); + Text textWidget = this.templateStringOption.getTextWidget(); + Point textWidgetSelection = textWidget.getSelection(); + String templateStringOptionText = + this.templateStringOption.getText(); + + if (templateStringOptionText.equals("")) { + // There's nothing in the widget yet. + + this.templateStringOption.setText(placeholder); + int placeholderLength = placeholder.length(); + textWidget.setSelection(placeholderLength, placeholderLength); + } else if (textWidgetSelection.x != textWidgetSelection.y) { + // There's a selection, so just replace it. + + textWidget.insert(placeholder); + this.templateStringOption.setText(textWidget.getText()); } else { - // Otherwise, insert the placeholder at the fixedCaretPosition. - int caretPosition = this.templateStringText.getCaretPosition(); - int fixedCaretPosition = fixCaretPosition(caretPosition); - this.templateStringText.setSelection(fixedCaretPosition); - this.templateStringText.insert(" " + placeholder + " "); - }*/ - - this.templateStringOption.setValue( - this.templateStringOption.getValue().toString() + - " " + - placeholder); + /* + * We have to fix the caret position so we insert the new + * placeholder after the current word the caret is in, if it's + * in one. + */ + int caretPosition = textWidget.getCaretPosition(); + int fixedCaretPosition = fixCaretPosition( + caretPosition, this.templateStringOption.getText()); + + String preCaretString = + templateStringOptionText.substring(0, fixedCaretPosition); + String postCaretString; + + if (fixedCaretPosition < templateStringOptionText.length()) { + postCaretString = templateStringOptionText.substring( + fixedCaretPosition + 1); + } else { + postCaretString = ""; + } + + String preCaretWithPlaceholderString = + preCaretString + " " + placeholder + " "; + String newText = preCaretWithPlaceholderString + postCaretString; + this.templateStringOption.setText(newText); + + int newCaretPosition = preCaretWithPlaceholderString.length(); + textWidget.setSelection(newCaretPosition, newCaretPosition); + } } - /*private int fixCaretPosition(int caretPosition) { - int fixedCaretPosition = caretPosition; - String templateStringText = this.templateStringText.getText(); + private int fixCaretPosition( + int caretPosition, String templateStringText) { + int templateStringTextLength = templateStringText.length(); - if (fixedCaretPosition == 0 || templateStringText.length() == 0) { - return fixedCaretPosition; + if (templateStringTextLength == 0) { + return 0; + } else if ((caretPosition < 0) || + (caretPosition >= templateStringTextLength)) { + return templateStringText.length(); } else { - char currentCharacter = templateStringText.charAt(fixedCaretPosition); + int fixedCaretPosition = caretPosition; + char currentCharacter = + templateStringText.charAt(fixedCaretPosition); while (!Character.isWhitespace(currentCharacter) && fixedCaretPosition < templateStringText.length()) { @@ -235,8 +268,8 @@ currentCharacter = templateStringText.charAt(fixedCaretPosition); } + + return fixedCaretPosition; } - - return fixedCaretPosition; - }*/ + } } \ No newline at end of file Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pages/ChooseSourceCodeFilesPage.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pages/ChooseSourceCodeFilesPage.java 2009-08-14 22:14:40 UTC (rev 924) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pages/ChooseSourceCodeFilesPage.java 2009-08-15 20:53:04 UTC (rev 925) @@ -1,8 +1,8 @@ package org.cishell.templates.wizards.pages; +import org.cishell.templates.staticexecutable.optiontypes.CustomStringOption; import org.cishell.templates.wizards.pagepanels.ChooseSourceCodeFilesPanel; import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.pde.ui.templates.TemplateOption; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; @@ -12,11 +12,11 @@ */ public class ChooseSourceCodeFilesPage extends WizardPage { private ChooseSourceCodeFilesPanel chooseSourceCodeFilesPanel; - private TemplateOption sourceCodeFilesLocationOption; + private CustomStringOption sourceCodeFilesLocationOption; public ChooseSourceCodeFilesPage( String pageName, - TemplateOption sourceCodeFilesLocationOption) { + CustomStringOption sourceCodeFilesLocationOption) { super(pageName); this.sourceCodeFilesLocationOption = sourceCodeFilesLocationOption; Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pages/SpecifyTemplateStringPage.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pages/SpecifyTemplateStringPage.java 2009-08-14 22:14:40 UTC (rev 924) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pages/SpecifyTemplateStringPage.java 2009-08-15 20:53:04 UTC (rev 925) @@ -1,10 +1,10 @@ package org.cishell.templates.wizards.pages; +import org.cishell.templates.staticexecutable.optiontypes.CustomStringOption; import org.cishell.templates.staticexecutable.providers.InputDataProvider; import org.cishell.templates.staticexecutable.providers.InputParameterProvider; import org.cishell.templates.wizards.pagepanels.SpecifyTemplateStringPanel; import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.pde.ui.templates.TemplateOption; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; @@ -20,13 +20,13 @@ private SpecifyTemplateStringPanel specifyTemplateStringPanel; private InputParameterProvider inputParameterProvider; private InputDataProvider inputDataProvider; - private TemplateOption templateStringOption; + private CustomStringOption templateStringOption; public SpecifyTemplateStringPage( String pageName, InputParameterProvider inputParameterProvider, InputDataProvider inputDataProvider, - TemplateOption templateStringOption) { + CustomStringOption templateStringOption) { super(pageName); this.inputParameterProvider = inputParameterProvider; Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/NewStaticExecutableAlgorithmTemplate.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/NewStaticExecutableAlgorithmTemplate.java 2009-08-14 22:14:40 UTC (rev 924) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/NewStaticExecutableAlgorithmTemplate.java 2009-08-15 20:53:04 UTC (rev 925) @@ -13,14 +13,13 @@ * ***************************************************************************/ package org.cishell.templates.wizards.staticexecutable; -import java.io.BufferedWriter; import java.io.File; -import java.io.FileWriter; import java.util.HashMap; import java.util.Map; import java.util.Set; -import org.cishell.templates.staticexecutable.providers.PlatformOption; +import org.cishell.templates.staticexecutable.optiontypes.CustomStringOption; +import org.cishell.templates.staticexecutable.optiontypes.PlatformOption; import org.cishell.templates.staticexecutable.providers.PlatformOptionProvider; import org.cishell.templates.wizards.BasicTemplate; import org.cishell.templates.wizards.pages.ChooseExecutableFilesPage; @@ -210,8 +209,8 @@ private Map platformExecutableOptions = new HashMap(); private MultiHashMapWithCounts relatedFileOptions = new MultiHashMapWithCounts(); - private TemplateOption templateStringOption; - private TemplateOption sourceCodeFilesOption; + private CustomStringOption templateStringOption; + private CustomStringOption sourceCodeFilesOption; public NewStaticExecutableAlgorithmTemplate() { super("static_executable"); @@ -579,20 +578,22 @@ private void setupInputAndOutputDataPage() { } private void setupTemplateStringPage() { - this.templateStringOption = addOption( + this.templateStringOption = new CustomStringOption( + this, TEMPLATE_STRING_ID, - TEMPLATE_STRING_LABEL, + TEMPLATE_STRING_LABEL); + registerOption( + this.templateStringOption, DEFAULT_TEMPLATE_STRING, SPECIFY_TEMPLATE_STRING_PAGE_NUMBER); this.templateStringOption.setRequired(true); } private void setupSourceCodeFilesPage() { - this.sourceCodeFilesOption = addOption( - CHOOSE_SOURCE_CODE_FILES_ID, - CHOOSE_SOURCE_CODE_FILES_LABEL + ":", - "", - SOURCE_CODE_FILES_PAGE_NUMBER); + this.sourceCodeFilesOption = new CustomStringOption( + this, CHOOSE_SOURCE_CODE_FILES_ID, CHOOSE_SOURCE_CODE_FILES_LABEL); + registerOption( + this.sourceCodeFilesOption, "", SOURCE_CODE_FILES_PAGE_NUMBER); this.sourceCodeFilesOption.setRequired(false); } Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/NewStaticExecutableAlgorithmWizard.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/NewStaticExecutableAlgorithmWizard.java 2009-08-14 22:14:40 UTC (rev 924) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/NewStaticExecutableAlgorithmWizard.java 2009-08-15 20:53:04 UTC (rev 925) @@ -18,7 +18,7 @@ import java.io.FileOutputStream; import java.lang.reflect.InvocationTargetException; -import org.cishell.templates.staticexecutable.providers.PlatformOption; +import org.cishell.templates.staticexecutable.optiontypes.PlatformOption; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProjectDescription; Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/widgets/ChooseExecutableFileWidget.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/widgets/ChooseExecutableFileWidget.java 2009-08-14 22:14:40 UTC (rev 924) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/widgets/ChooseExecutableFileWidget.java 2009-08-15 20:53:04 UTC (rev 925) @@ -1,6 +1,6 @@ package org.cishell.templates.wizards.widgets; -import org.cishell.templates.staticexecutable.providers.PlatformOption; +import org.cishell.templates.staticexecutable.optiontypes.PlatformOption; import org.cishell.templates.staticexecutable.providers.PlatformOptionProvider; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/widgets/ChooseFileWidget.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/widgets/ChooseFileWidget.java 2009-08-14 22:14:40 UTC (rev 924) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/widgets/ChooseFileWidget.java 2009-08-15 20:53:04 UTC (rev 925) @@ -1,5 +1,6 @@ package org.cishell.templates.wizards.widgets; +import org.cishell.templates.staticexecutable.optiontypes.CustomStringOption; import org.eclipse.pde.ui.templates.TemplateOption; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent; @@ -9,9 +10,7 @@ import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Layout; -import org.eclipse.swt.widgets.Text; /* * This widget allows the user the choose a file off of his/her hard drive. @@ -24,23 +23,24 @@ public class ChooseFileWidget extends Composite implements SelectionListener { public static final String BROWSE_FILES_BUTTON_LABEL = "Browse"; public static final String REMOVE_FILE_LABEL_TEXT = "Remove?"; + public static final String CLEAR_FILE_LABEL_TEXT = "Clear?"; public static final int PADDING_FOR_FILE_PATH_TEXT_WITHOUT_REMOVE_BUTTON = - 75; + 5; public static final int PADDING_FOR_FILE_PATH_TEXT_WITH_REMOVE_BUTTON = - 135; + 5; - private Text filePathText; private Button browseFilesButton; // TODO: Make these listeners of an interface. private ChooseRelatedFilesWidget fileChosenListener; private ChooseRelatedFilesWidget removeElementListener; - private TemplateOption platformOption; + private CustomStringOption platformOption; + private boolean canBeRemoved; public ChooseFileWidget(Composite parent, int style, int parentParentWidth, - TemplateOption stringOption) { + CustomStringOption stringOption) { this(parent, style, true, parentParentWidth, stringOption); } @@ -48,16 +48,15 @@ int style, boolean hasRemoveButton, int parentParentWidth, - TemplateOption platformOption) { + CustomStringOption platformOption) { super(parent, style); this.platformOption = platformOption; + this.canBeRemoved = hasRemoveButton; setLayout(createLayoutForThis()); - - Composite container = - createContainer(hasRemoveButton, parentParentWidth); - this.platformOption.createControl(container, 2); + + createControlForTextWidget(hasRemoveButton, parentParentWidth); this.browseFilesButton = createBrowseFilesButton(); createRemoveElement(hasRemoveButton); } @@ -114,8 +113,8 @@ return layout; } - private Composite createContainer(boolean hasRemoveButton, - int parentParentWidth) { + private void createControlForTextWidget(boolean hasRemoveButton, + int parentParentWidth) { int widthForFilePathText; if (hasRemoveButton) { @@ -125,17 +124,14 @@ widthForFilePathText = parentParentWidth - PADDING_FOR_FILE_PATH_TEXT_WITHOUT_REMOVE_BUTTON; } - - // TODO: Fix the layout so the buttons aren't vertically offset - // above this! - Composite container = new Composite(this, SWT.NONE); - container.setLayoutData(createFilePathTextLayoutData(widthForFilePathText)); - GridLayout layout = new GridLayout(); - layout.marginWidth = 0; - layout.marginHeight = 0; - container.setLayout(layout); - - return container; + + if (hasRemoveButton) { + this.platformOption.createControl(this, -1); + } else { + this.platformOption.createControl(this, -1); + } + this.platformOption.getTextWidget().setLayoutData( + createFilePathTextLayoutData(widthForFilePathText)); } private Button createBrowseFilesButton() { @@ -148,16 +144,15 @@ } private void createRemoveElement(boolean hasRemoveButton) { + // TODO: Make the first one say Clear.; + Button removeButton = new Button(this, SWT.PUSH); + removeButton.setLayoutData(createRemoveElementLayoutData()); + removeButton.addSelectionListener(this); + if (hasRemoveButton) { - Button removeButton = new Button(this, SWT.PUSH); - removeButton.setLayoutData(createRemoveElementLayoutData()); removeButton.setText(REMOVE_FILE_LABEL_TEXT); - removeButton.addSelectionListener(this); } else { - Label removeLabel = new Label(this, SWT.NONE); - removeLabel.setLayoutData(createRemoveElementLayoutData()); - removeLabel.setText(REMOVE_FILE_LABEL_TEXT); - removeLabel.setVisible(false); + removeButton.setText(CLEAR_FILE_LABEL_TEXT); } } @@ -168,7 +163,6 @@ if (filePath != null) { setFilePath(filePath); - // this.filePathText.setText(filePath); if (this.fileChosenListener != null) { this.fileChosenListener.fileWasChosen(this, filePath); @@ -177,8 +171,12 @@ } private void removeButtonSelected(SelectionEvent selectionEvent) { - if (this.removeElementListener != null) { - this.removeElementListener.removeButtonWasSelected(this); + if (this.canBeRemoved) { + if (this.removeElementListener != null) { + this.removeElementListener.removeButtonWasSelected(this); + } + } else { + setFilePath(""); } } @@ -199,6 +197,7 @@ private GridData createRemoveElementLayoutData() { GridData data = new GridData(); + data.widthHint = 56; return data; } Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/widgets/ChooseRelatedFilesWidget.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/widgets/ChooseRelatedFilesWidget.java 2009-08-14 22:14:40 UTC (rev 924) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/widgets/ChooseRelatedFilesWidget.java 2009-08-15 20:53:04 UTC (rev 925) @@ -2,7 +2,7 @@ import java.util.ArrayList; -import org.cishell.templates.staticexecutable.providers.PlatformOption; +import org.cishell.templates.staticexecutable.optiontypes.PlatformOption; import org.cishell.templates.staticexecutable.providers.PlatformOptionProvider; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |