You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(7) |
Aug
|
Sep
(46) |
Oct
(102) |
Nov
(10) |
Dec
(21) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(1) |
Feb
(3) |
Mar
(14) |
Apr
(9) |
May
(12) |
Jun
(4) |
Jul
(40) |
Aug
(60) |
Sep
(38) |
Oct
(2) |
Nov
(1) |
Dec
(42) |
2008 |
Jan
(23) |
Feb
(29) |
Mar
(107) |
Apr
(27) |
May
(3) |
Jun
(1) |
Jul
(15) |
Aug
(7) |
Sep
(19) |
Oct
|
Nov
(2) |
Dec
|
2009 |
Jan
(36) |
Feb
(4) |
Mar
(2) |
Apr
(1) |
May
(1) |
Jun
(15) |
Jul
(30) |
Aug
(32) |
Sep
(11) |
Oct
(21) |
Nov
(12) |
Dec
(15) |
2010 |
Jan
(29) |
Feb
(9) |
Mar
(25) |
Apr
|
May
(7) |
Jun
(5) |
Jul
(21) |
Aug
(32) |
Sep
(10) |
Oct
(8) |
Nov
(29) |
Dec
(8) |
2011 |
Jan
(9) |
Feb
(35) |
Mar
(11) |
Apr
(4) |
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
(3) |
Dec
(30) |
2012 |
Jan
(5) |
Feb
(7) |
Mar
(10) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <jrb...@us...> - 2009-08-18 20:33:19
|
Revision: 927 http://cishell.svn.sourceforge.net/cishell/?rev=927&view=rev Author: jrbibers Date: 2009-08-18 20:33:00 +0000 (Tue, 18 Aug 2009) Log Message: ----------- Previous commit included what is probably a poor assumption: that the list would not include the option to default. Now defaulting never adds an option to the list; it only checks for the presence of the given default in the given options and, if found, swaps it the front of the structure (as the called code treats the first option in the structure as the default). Modified Paths: -------------- trunk/core/org.cishell.utilities/src/org/cishell/utilities/mutateParameter/DropdownMutator.java Added Paths: ----------- trunk/core/org.cishell.utilities/src/org/cishell/utilities/ArrayUtilities.java Added: trunk/core/org.cishell.utilities/src/org/cishell/utilities/ArrayUtilities.java =================================================================== --- trunk/core/org.cishell.utilities/src/org/cishell/utilities/ArrayUtilities.java (rev 0) +++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/ArrayUtilities.java 2009-08-18 20:33:00 UTC (rev 927) @@ -0,0 +1,13 @@ +package org.cishell.utilities; + +public class ArrayUtilities { + public static int indexOf(Object[] array, Object target) { + for (int ii = 0; ii < array.length; ii++) { + if (target.equals(array[ii])) { + return ii; + } + } + + return -1; + } +} Modified: trunk/core/org.cishell.utilities/src/org/cishell/utilities/mutateParameter/DropdownMutator.java =================================================================== --- trunk/core/org.cishell.utilities/src/org/cishell/utilities/mutateParameter/DropdownMutator.java 2009-08-18 19:52:44 UTC (rev 926) +++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/mutateParameter/DropdownMutator.java 2009-08-18 20:33:00 UTC (rev 927) @@ -1,9 +1,9 @@ package org.cishell.utilities.mutateParameter; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import org.cishell.utilities.ArrayUtilities; import org.osgi.service.metatype.AttributeDefinition; import org.osgi.service.metatype.ObjectClassDefinition; @@ -25,70 +25,51 @@ return ObjectClassDefinitionTransformer.transform(ocd, transforms); } - public void add(String id, Collection options, String defaultOption) { - List defaultedOptions = new ArrayList(); - defaultedOptions.add(defaultOption); - defaultedOptions.addAll(options); - - add(id, defaultedOptions); + public void add(String id, List options, String defaultOption) { + add(id, swapToFront(options, defaultOption)); } - public void add(String id, Collection options) { + public void add(String id, List options) { add(id, options, options); } - public void add(String id, Collection optionLabels, String defaultOptionLabel, Collection optionValues, String defaultOptionValue) { - List defaultedOptionLabels = new ArrayList(); - defaultedOptionLabels.add(defaultOptionLabel); - defaultedOptionLabels.addAll(optionLabels); - - List defaultedOptionValues = new ArrayList(); - defaultedOptionValues.add(defaultOptionValue); - defaultedOptionValues.addAll(optionValues); - - add(id, defaultedOptionLabels, defaultedOptionValues); + public void add(String id, + List optionLabels, + String defaultOptionLabel, + List optionValues, + String defaultOptionValue) { + add(id, + swapToFront(optionLabels, defaultOptionLabel), + swapToFront(optionValues, defaultOptionValue)); } - public void add(String id, Collection optionLabels, Collection optionValues) { - add(id, (String[]) optionLabels.toArray(new String[0]), (String[]) optionValues.toArray(new String[0])); + public void add(String id, List optionLabels, List optionValues) { + add(id, + (String[]) optionLabels.toArray(new String[0]), + (String[]) optionValues.toArray(new String[0])); } public void add(String id, String[] options, String defaultOption) { - String[] defaultedOptions = new String[options.length + 1]; - defaultedOptions[0] = defaultOption; - for (int ii = 0; ii < options.length; ii++) { - defaultedOptions[ii+1] = options[ii]; - } - - System.out.println("options = "); - for (int ii = 0; ii < defaultedOptions.length; ii++) { - System.out.println(defaultedOptions[ii]); - } - - add(id, defaultedOptions); + add(id, swapToFront(options, defaultOption)); } public void add(String id, String[] options) { add(id, options, options); } - public void add(final String id, final String[] optionLabels, String defaultOptionLabel, final String[] optionValues, String defaultOptionValue) { - String[] defaultedOptionLabels = new String[optionLabels.length + 1]; - defaultedOptionLabels[0] = defaultOptionLabel; - for (int ii = 0; ii < optionLabels.length; ii++) { - defaultedOptionLabels[ii+1] = optionLabels[ii]; - } - - String[] defaultedOptionValues = new String[optionValues.length + 1]; - defaultedOptionValues[0] = defaultOptionValue; - for (int ii = 0; ii < optionValues.length; ii++) { - defaultedOptionValues[ii+1] = optionValues[ii]; - } - - add(id, defaultedOptionLabels, defaultedOptionValues); + public void add(final String id, + final String[] optionLabels, + String defaultOptionLabel, + final String[] optionValues, + String defaultOptionValue) { + add(id, + swapToFront(optionLabels, defaultOptionLabel), + swapToFront(optionValues, defaultOptionValue)); } - public void add(final String id, final String[] optionLabels, final String[] optionValues) { + public void add(final String id, + final String[] optionLabels, + final String[] optionValues) { transforms.add( new NullDropdownTransformer() { public boolean shouldTransform(AttributeDefinition ad) { @@ -104,4 +85,27 @@ } }); } + + private static List swapToFront(List list, String item) { + if (list.contains(item)) { + int index = list.indexOf(item); + String displacedItem = (String) list.get(0); + list.set(0, item); + list.set(index, displacedItem); + } + + return list; + } + + private static String[] swapToFront(String[] array, String item) { + int index = ArrayUtilities.indexOf(array, item); + + if (index != -1) { + String displacedItem = array[0]; + array[0] = item; + array[index] = displacedItem; + } + + return array; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jrb...@us...> - 2009-08-18 19:52:55
|
Revision: 926 http://cishell.svn.sourceforge.net/cishell/?rev=926&view=rev Author: jrbibers Date: 2009-08-18 19:52:44 +0000 (Tue, 18 Aug 2009) Log Message: ----------- Added convenience methods for default options to DropdownMutator Modified Paths: -------------- trunk/core/org.cishell.utilities/src/org/cishell/utilities/mutateParameter/DropdownMutator.java Modified: trunk/core/org.cishell.utilities/src/org/cishell/utilities/mutateParameter/DropdownMutator.java =================================================================== --- trunk/core/org.cishell.utilities/src/org/cishell/utilities/mutateParameter/DropdownMutator.java 2009-08-15 20:53:04 UTC (rev 925) +++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/mutateParameter/DropdownMutator.java 2009-08-18 19:52:44 UTC (rev 926) @@ -7,6 +7,13 @@ import org.osgi.service.metatype.AttributeDefinition; import org.osgi.service.metatype.ObjectClassDefinition; +/* For aggregating and applying DropdownTransforms. + * Many convenience methods are given to support arrays vs. Lists + * and default vs. no default. + * The core functionality + * is in add(final String, final String[], final String[]) + * and mutate(ObjectClassDefinition) + */ public class DropdownMutator { private List transforms; @@ -14,18 +21,73 @@ transforms = new ArrayList(); } + public ObjectClassDefinition mutate(ObjectClassDefinition ocd) { + return ObjectClassDefinitionTransformer.transform(ocd, transforms); + } + + public void add(String id, Collection options, String defaultOption) { + List defaultedOptions = new ArrayList(); + defaultedOptions.add(defaultOption); + defaultedOptions.addAll(options); + + add(id, defaultedOptions); + } + public void add(String id, Collection options) { add(id, options, options); } + public void add(String id, Collection optionLabels, String defaultOptionLabel, Collection optionValues, String defaultOptionValue) { + List defaultedOptionLabels = new ArrayList(); + defaultedOptionLabels.add(defaultOptionLabel); + defaultedOptionLabels.addAll(optionLabels); + + List defaultedOptionValues = new ArrayList(); + defaultedOptionValues.add(defaultOptionValue); + defaultedOptionValues.addAll(optionValues); + + add(id, defaultedOptionLabels, defaultedOptionValues); + } + public void add(String id, Collection optionLabels, Collection optionValues) { add(id, (String[]) optionLabels.toArray(new String[0]), (String[]) optionValues.toArray(new String[0])); } + public void add(String id, String[] options, String defaultOption) { + String[] defaultedOptions = new String[options.length + 1]; + defaultedOptions[0] = defaultOption; + for (int ii = 0; ii < options.length; ii++) { + defaultedOptions[ii+1] = options[ii]; + } + + System.out.println("options = "); + for (int ii = 0; ii < defaultedOptions.length; ii++) { + System.out.println(defaultedOptions[ii]); + } + + add(id, defaultedOptions); + } + public void add(String id, String[] options) { add(id, options, options); } + public void add(final String id, final String[] optionLabels, String defaultOptionLabel, final String[] optionValues, String defaultOptionValue) { + String[] defaultedOptionLabels = new String[optionLabels.length + 1]; + defaultedOptionLabels[0] = defaultOptionLabel; + for (int ii = 0; ii < optionLabels.length; ii++) { + defaultedOptionLabels[ii+1] = optionLabels[ii]; + } + + String[] defaultedOptionValues = new String[optionValues.length + 1]; + defaultedOptionValues[0] = defaultOptionValue; + for (int ii = 0; ii < optionValues.length; ii++) { + defaultedOptionValues[ii+1] = optionValues[ii]; + } + + add(id, defaultedOptionLabels, defaultedOptionValues); + } + public void add(final String id, final String[] optionLabels, final String[] optionValues) { transforms.add( new NullDropdownTransformer() { @@ -42,8 +104,4 @@ } }); } - - public ObjectClassDefinition mutate(ObjectClassDefinition ocd) { - return ObjectClassDefinitionTransformer.transform(ocd, transforms); - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
From: <pat...@us...> - 2009-08-14 22:14:48
|
Revision: 924 http://cishell.svn.sourceforge.net/cishell/?rev=924&view=rev Author: pataphil Date: 2009-08-14 22:14:40 +0000 (Fri, 14 Aug 2009) Log Message: ----------- * Added necessary template files for the static executable wizard. (Oops.) Added Paths: ----------- trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/ant trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/ant.bat trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/ant.cmd trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/antRun trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/antRun.bat trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/antRun.pl trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/antenv.cmd trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/complete-ant-cmd.pl trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/envset.cmd trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/lcp.bat trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/runant.pl trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/runant.py trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/runrc.cmd Added: trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/ant =================================================================== --- trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/ant (rev 0) +++ trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/ant 2009-08-14 22:14:40 UTC (rev 924) @@ -0,0 +1,299 @@ +#! /bin/sh + +# Copyright 2001-2005 The Apache Software Foundation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Extract launch and ant arguments, (see details below). +ant_exec_args= +no_config=false +use_jikes_default=false +ant_exec_debug=false +show_help=false +for arg in "$@" ; do + if [ "$arg" = "--noconfig" ] ; then + no_config=true + elif [ "$arg" = "--usejikes" ] ; then + use_jikes_default=true + elif [ "$arg" = "--execdebug" ] ; then + ant_exec_debug=true + elif [ my"$arg" = my"--h" -o my"$arg" = my"--help" ] ; then + show_help=true + ant_exec_args="$ant_exec_args -h" + else + if [ my"$arg" = my"-h" -o my"$arg" = my"-help" ] ; then + show_help=true + fi + ant_exec_args="$ant_exec_args \"$arg\"" + fi +done + +# Source/default ant configuration +if $no_config ; then + rpm_mode=false + usejikes=$use_jikes_default +else + # load system-wide ant configuration + if [ -f "/etc/ant.conf" ] ; then + . /etc/ant.conf + fi + + # load user ant configuration + if [ -f "$HOME/.ant/ant.conf" ] ; then + . $HOME/.ant/ant.conf + fi + if [ -f "$HOME/.antrc" ] ; then + . "$HOME/.antrc" + fi + + # provide default configuration values + if [ -z "$rpm_mode" ] ; then + rpm_mode=false + fi + if [ -z "$usejikes" ] ; then + usejikes=$use_jikes_default + fi +fi + +# Setup Java environment in rpm mode +if $rpm_mode ; then + if [ -f /usr/share/java-utils/java-functions ] ; then + . /usr/share/java-utils/java-functions + set_jvm + set_javacmd + fi +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +case "`uname`" in + CYGWIN*) cygwin=true ;; + Darwin*) darwin=true + if [ -z "$JAVA_HOME" ] ; then + JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home + fi + ;; +esac + +if [ -z "$ANT_HOME" -o ! -d "$ANT_HOME" ] ; then + ## resolve links - $0 may be a link to ant's home + PRG="$0" + progname=`basename "$0"` + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi + done + + ANT_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + ANT_HOME=`cd "$ANT_HOME" && pwd` +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$ANT_HOME" ] && + ANT_HOME=`cygpath --unix "$ANT_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` +fi + +# set ANT_LIB location +ANT_LIB="${ANT_HOME}/lib" + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD=`which java 2> /dev/null ` + if [ -z "$JAVACMD" ] ; then + JAVACMD=java + fi + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." + echo " We cannot execute $JAVACMD" + exit 1 +fi + +# Build local classpath using just the launcher in non-rpm mode or +# use the Jpackage helper in rpm mode with basic and default jars +# specified in the ant.conf configuration. Because the launcher is +# used, libraries linked in ANT_HOME will also be include, but this +# is discouraged as it is not java-version safe. A user should +# request optional jars and their dependencies via the OPT_JAR_LIST +# variable +if $rpm_mode && [ -f /usr/bin/build-classpath ] ; then + LOCALCLASSPATH="$(/usr/bin/build-classpath ant ant-launcher jaxp_parser_impl xml-commons-apis)" + # If the user requested to try to add some other jars to the classpath + if [ -n "$OPT_JAR_LIST" ] ; then + _OPTCLASSPATH="$(/usr/bin/build-classpath $OPT_JAR_LIST 2> /dev/null)" + if [ -n "$_OPTCLASSPATH" ] ; then + LOCALCLASSPATH="$LOCALCLASSPATH:$_OPTCLASSPATH" + fi + fi + + # Explicitly add javac path to classpath, assume JAVA_HOME set + # properly in rpm mode + if [ -f "$JAVA_HOME/lib/tools.jar" ] ; then + LOCALCLASSPATH="$LOCALCLASSPATH:$JAVA_HOME/lib/tools.jar" + fi + if [ -f "$JAVA_HOME/lib/classes.zip" ] ; then + LOCALCLASSPATH="$LOCALCLASSPATH:$JAVA_HOME/lib/classes.zip" + fi + + # if CLASSPATH_OVERRIDE env var is set, LOCALCLASSPATH will be + # user CLASSPATH first and ant-found jars after. + # In that case, the user CLASSPATH will override ant-found jars + # + # if CLASSPATH_OVERRIDE is not set, we'll have the normal behaviour + # with ant-found jars first and user CLASSPATH after + if [ -n "$CLASSPATH" ] ; then + # merge local and specified classpath + if [ -z "$LOCALCLASSPATH" ] ; then + LOCALCLASSPATH="$CLASSPATH" + elif [ -n "$CLASSPATH_OVERRIDE" ] ; then + LOCALCLASSPATH="$CLASSPATH:$LOCALCLASSPATH" + else + LOCALCLASSPATH="$LOCALCLASSPATH:$CLASSPATH" + fi + + # remove class path from launcher -cp option + CLASSPATH="" + fi +else + # not using rpm_mode; use launcher to determine classpaths + if [ -z "$LOCALCLASSPATH" ] ; then + LOCALCLASSPATH=$ANT_LIB/ant-launcher.jar + else + LOCALCLASSPATH=$ANT_LIB/ant-launcher.jar:$LOCALCLASSPATH + fi +fi + +if [ -n "$JAVA_HOME" ] ; then + # OSX hack to make Ant work with jikes + if $darwin ; then + OSXHACK="${JAVA_HOME}/../Classes" + if [ -d "${OSXHACK}" ] ; then + for i in "${OSXHACK}"/*.jar + do + JIKESPATH="$JIKESPATH:$i" + done + fi + fi +fi + +# Allow Jikes support (off by default) +if $usejikes; then + ANT_OPTS="$ANT_OPTS -Dbuild.compiler=jikes" +fi + +# For Cygwin, switch paths to appropriate format before running java +# For PATHs convert to unix format first, then to windows format to ensure +# both formats are supported. Probably this will fail on directories with ; +# in the name in the path. Let's assume that paths containing ; are more +# rare than windows style paths on cygwin. +if $cygwin; then + if [ "$OS" = "Windows_NT" ] && cygpath -m .>/dev/null 2>/dev/null ; then + format=mixed + else + format=windows + fi + ANT_HOME=`cygpath --$format "$ANT_HOME"` + ANT_LIB=`cygpath --$format "$ANT_LIB"` + JAVA_HOME=`cygpath --$format "$JAVA_HOME"` + LCP_TEMP=`cygpath --path --unix "$LOCALCLASSPATH"` + LOCALCLASSPATH=`cygpath --path --$format "$LCP_TEMP"` + if [ -n "$CLASSPATH" ] ; then + CP_TEMP=`cygpath --path --unix "$CLASSPATH"` + CLASSPATH=`cygpath --path --$format "$CP_TEMP"` + fi + CYGHOME=`cygpath --$format "$HOME"` +fi + +# Show script help if requested +if $show_help ; then + echo $0 '[script options] [options] [target [target2 [target3] ..]]' + echo 'Script Options:' + echo ' --help, --h print this message and ant help' + echo ' --noconfig suppress sourcing of /etc/ant.conf,' + echo ' $HOME/.ant/ant.conf, and $HOME/.antrc' + echo ' configuration files' + echo ' --usejikes enable use of jikes by default, unless' + echo ' set explicitly in configuration files' + echo ' --execdebug print ant exec line generated by this' + echo ' launch script' + echo ' ' +fi +# add a second backslash to variables terminated by a backslash under cygwin +if $cygwin; then + case "$ANT_HOME" in + *\\ ) + ANT_HOME="$ANT_HOME\\" + ;; + esac + case "$CYGHOME" in + *\\ ) + CYGHOME="$CYGHOME\\" + ;; + esac + case "$JIKESPATH" in + *\\ ) + JIKESPATH="$JIKESPATH\\" + ;; + esac + case "$LOCALCLASSPATH" in + *\\ ) + LOCALCLASSPATH="$LOCALCLASSPATH\\" + ;; + esac + case "$CLASSPATH" in + *\\ ) + CLASSPATH="$CLASSPATH\\" + ;; + esac +fi +# Execute ant using eval/exec to preserve spaces in paths, +# java options, and ant args +ant_sys_opts= +if [ -n "$CYGHOME" ]; then + if [ -n "$JIKESPATH" ]; then + ant_sys_opts="-Djikes.class.path=\"$JIKESPATH\" -Dcygwin.user.home=\"$CYGHOME\"" + else + ant_sys_opts="-Dcygwin.user.home=\"$CYGHOME\"" + fi +else + if [ -n "$JIKESPATH" ]; then + ant_sys_opts="-Djikes.class.path=\"$JIKESPATH\"" + fi +fi +ant_exec_command="exec \"$JAVACMD\" $ANT_OPTS -classpath \"$LOCALCLASSPATH\" -Dant.home=\"$ANT_HOME\" -Dant.library.dir=\"$ANT_LIB\" $ant_sys_opts org.apache.tools.ant.launch.Launcher $ANT_ARGS -cp \"$CLASSPATH\" $ant_exec_args" +if $ant_exec_debug ; then + echo $ant_exec_command +fi +eval $ant_exec_command Added: trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/ant.bat =================================================================== --- trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/ant.bat (rev 0) +++ trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/ant.bat 2009-08-14 22:14:40 UTC (rev 924) @@ -0,0 +1,126 @@ +@echo off + +REM Copyright 2001,2004-2005 The Apache Software Foundation +REM +REM Licensed under the Apache License, Version 2.0 (the "License"); +REM you may not use this file except in compliance with the License. +REM You may obtain a copy of the License at +REM +REM http://www.apache.org/licenses/LICENSE-2.0 +REM +REM Unless required by applicable law or agreed to in writing, software +REM distributed under the License is distributed on an "AS IS" BASIS, +REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +REM See the License for the specific language governing permissions and +REM limitations under the License. + +if exist "%HOME%\antrc_pre.bat" call "%HOME%\antrc_pre.bat" + +if "%OS%"=="Windows_NT" @setlocal +if "%OS%"=="WINNT" @setlocal + +rem %~dp0 is expanded pathname of the current script under NT +set DEFAULT_ANT_HOME=%~dp0.. + +if "%ANT_HOME%"=="" set ANT_HOME=%DEFAULT_ANT_HOME% +set DEFAULT_ANT_HOME= + +set _USE_CLASSPATH=yes + +rem Slurp the command line arguments. This loop allows for an unlimited number +rem of arguments (up to the command line limit, anyway). +set ANT_CMD_LINE_ARGS=%1 +if ""%1""=="""" goto doneStart +shift +:setupArgs +if ""%1""=="""" goto doneStart +if ""%1""==""-noclasspath"" goto clearclasspath +set ANT_CMD_LINE_ARGS=%ANT_CMD_LINE_ARGS% %1 +shift +goto setupArgs + +rem here is there is a -noclasspath in the options +:clearclasspath +set _USE_CLASSPATH=no +shift +goto setupArgs + +rem This label provides a place for the argument list loop to break out +rem and for NT handling to skip to. + +:doneStart +rem find ANT_HOME if it does not exist due to either an invalid value passed +rem by the user or the %0 problem on Windows 9x +if exist "%ANT_HOME%\lib\ant.jar" goto checkJava + +rem check for ant in Program Files +if not exist "%ProgramFiles%\ant" goto checkSystemDrive +set ANT_HOME=%ProgramFiles%\ant +goto checkJava + +:checkSystemDrive +rem check for ant in root directory of system drive +if not exist %SystemDrive%\ant\lib\ant.jar goto checkCDrive +set ANT_HOME=%SystemDrive%\ant +goto checkJava + +:checkCDrive +rem check for ant in C:\ant for Win9X users +if not exist C:\ant\lib\ant.jar goto noAntHome +set ANT_HOME=C:\ant +goto checkJava + +:noAntHome +echo ANT_HOME is set incorrectly or ant could not be located. Please set ANT_HOME. +goto end + +:checkJava +set _JAVACMD=%JAVACMD% + +if "%JAVA_HOME%" == "" goto noJavaHome +if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome +if "%_JAVACMD%" == "" set _JAVACMD=%JAVA_HOME%\bin\java.exe +goto checkJikes + +:noJavaHome +if "%_JAVACMD%" == "" set _JAVACMD=java.exe + +:checkJikes +if not "%JIKESPATH%"=="" goto runAntWithJikes + +:runAnt +if "%_USE_CLASSPATH%"=="no" goto runAntNoClasspath +if not "%CLASSPATH%"=="" goto runAntWithClasspath +"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" "-Dant.home=%ANT_HOME%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% %ANT_CMD_LINE_ARGS% +goto end + +:runAntNoClasspath +"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" "-Dant.home=%ANT_HOME%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% %ANT_CMD_LINE_ARGS% +goto end + +:runAntWithClasspath +"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" "-Dant.home=%ANT_HOME%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% -cp "%CLASSPATH%" %ANT_CMD_LINE_ARGS% +goto end + +:runAntWithJikes +if "%_USE_CLASSPATH%"=="no" goto runAntWithJikesNoClasspath +if not "%CLASSPATH%"=="" goto runAntWithJikesAndClasspath + +:runAntWithJikesNoClasspath +"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" "-Dant.home=%ANT_HOME%" "-Djikes.class.path=%JIKESPATH%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% %ANT_CMD_LINE_ARGS% +goto end + +:runAntWithJikesAndClasspath +"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" "-Dant.home=%ANT_HOME%" "-Djikes.class.path=%JIKESPATH%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% -cp "%CLASSPATH%" %ANT_CMD_LINE_ARGS% +goto end + +:end +set _JAVACMD= +set ANT_CMD_LINE_ARGS= + +if "%OS%"=="Windows_NT" @endlocal +if "%OS%"=="WINNT" @endlocal + +:mainEnd +if exist "%HOME%\antrc_post.bat" call "%HOME%\antrc_post.bat" + Added: trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/ant.cmd =================================================================== --- trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/ant.cmd (rev 0) +++ trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/ant.cmd 2009-08-14 22:14:40 UTC (rev 924) @@ -0,0 +1,92 @@ +/* + Copyright 2003-2004 The Apache Software Foundation + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + Run ant +*/ + +'@echo off' +parse arg mode envarg '::' antarg + +if mode\='.' & mode\='..' & mode\='/' then do + envarg = mode envarg + mode = '' +end + +if antarg = '' then do + antarg = envarg + envarg = '' +end + +x = setlocal() + +env="OS2ENVIRONMENT" +antenv = _getenv_('antenv') +if _testenv_() = 0 then interpret 'call "' || antenv || '"' '"' || envarg || '"' + +if mode = '' then mode = _getenv_('ANT_MODE' '..') +if mode \= '/' then do + runrc = _getenv_('runrc') + antrc = _getenv_('antrc' 'antrc.cmd') + if mode = '..' then mode = '-r' + else mode = '' + interpret 'call "' || runrc || '"' antrc '"' || mode || '"' +end + +if _testenv_() = 0 then do + say 'Ant environment is not set properly' + x = endlocal() + exit 16 +end + +settings = '-Dant.home=' || ANT_HOME '-Djava.home=' || JAVA_HOME + +java = _getenv_('javacmd' 'java') +opts = value('ANT_OPTS',,env) +args = value('ANT_ARGS',,env) +lcp = value('LOCALCLASSPATH',,env) +cp = value('CLASSPATH',,env) +if value('ANT_USE_CP',,env) \= '' then do + if lcp \= '' & right(lcp, 1) \= ';' then lcp = lcp || ';' + lcp = lcp || cp + 'SET CLASSPATH=' +end +if lcp\='' then lcp = '-classpath' lcp + +cmd = java opts lcp '-jar' ANT_HOME ||'\lib\ant-launcher.jar' settings args antarg +launcher = stream(ANT_HOME ||'\lib\ant-launcher.jar', 'C', 'query exists') +if launcher = '' then entry = 'org.apache.tools.ant.Main' +else entry = 'org.apache.tools.ant.launch.Launcher' +java opts lcp entry settings args antarg + +x = endlocal() + +return rc + +_testenv_: procedure expose env ANT_HOME JAVA_HOME +ANT_HOME = value('ANT_HOME',,env) +if ANT_HOME = '' then return 0 +JAVA_HOME = value('JAVA_HOME',,env) +if JAVA_HOME = '' then return 0 +cp = translate(value('CLASSPATH',,env)) +if pos(translate(ANT_HOME), cp) = 0 then return 0 +if pos(translate(JAVA_HOME), cp) = 0 then return 0 +return 1 + +_getenv_: procedure expose env +parse arg envar default +if default = '' then default = envar +var = value(translate(envar),,env) +if var = '' then var = default +return var Added: trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/antRun =================================================================== --- trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/antRun (rev 0) +++ trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/antRun 2009-08-14 22:14:40 UTC (rev 924) @@ -0,0 +1,26 @@ +#!/bin/sh + +# +# Copyright 2001-2002,2004 The Apache Software Foundation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# + +# Args: DIR command +cd "$1" +CMD="$2" +shift +shift + +exec "$CMD" "$@" Added: trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/antRun.bat =================================================================== --- trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/antRun.bat (rev 0) +++ trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/antRun.bat 2009-08-14 22:14:40 UTC (rev 924) @@ -0,0 +1,47 @@ +@echo off + +REM +REM Copyright 2001-2002,2004-2005 The Apache Software Foundation +REM +REM Licensed under the Apache License, Version 2.0 (the "License"); +REM you may not use this file except in compliance with the License. +REM You may obtain a copy of the License at +REM +REM http://www.apache.org/licenses/LICENSE-2.0 +REM +REM Unless required by applicable law or agreed to in writing, software +REM distributed under the License is distributed on an "AS IS" BASIS, +REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +REM See the License for the specific language governing permissions and +REM limitations under the License. +REM +REM + +if "%OS%"=="Windows_NT" @setlocal +if "%OS%"=="WINNT" @setlocal + +if ""%1""=="""" goto runCommand + +rem Change drive and directory to %1 +if "%OS%"=="Windows_NT" cd /d ""%1"" +if not "%OS%"=="Windows_NT" cd ""%1"" +shift + +rem Slurp the command line arguments. This loop allows for an unlimited number +rem of agruments (up to the command line limit, anyway). +set ANT_RUN_CMD=%1 +if ""%1""=="""" goto runCommand +shift +:loop +if ""%1""=="""" goto runCommand +set ANT_RUN_CMD=%ANT_RUN_CMD% %1 +shift +goto loop + +:runCommand +rem echo %ANT_RUN_CMD% +%ANT_RUN_CMD% + +if "%OS%"=="Windows_NT" @endlocal +if "%OS%"=="WINNT" @endlocal + Added: trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/antRun.pl =================================================================== --- trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/antRun.pl (rev 0) +++ trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/antRun.pl 2009-08-14 22:14:40 UTC (rev 924) @@ -0,0 +1,65 @@ +#!/usr/bin/perl +# +# Copyright 2001,2003-2004 The Apache Software Foundation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +####################################################################### +# +# antRun.pl +# +# wrapper script for invoking commands on a platform with Perl installed +# this is akin to antRun.bat, and antRun the SH script +# +# created: 2001-10-18 +# author: Jeff Tulley jt...@no... +####################################################################### +#be fussy about variables +use strict; + +#turn warnings on during dev; generates a few spurious uninitialised var access warnings +#use warnings; + +#and set $debug to 1 to turn on trace info (currently unused) +my $debug=1; + +####################################################################### +# change drive and directory to "%1" +my $ANT_RUN_CMD = @ARGV[0]; + +# assign current run command to "%2" +chdir (@ARGV[0]) || die "Can't cd to $ARGV[0]: $!\n"; +if ($^O eq "NetWare") { + # There is a bug in Perl 5 on NetWare, where chdir does not + # do anything. On NetWare, the following path-prefixed form should + # always work. (afaict) + $ANT_RUN_CMD .= "/".@ARGV[1]; +} +else { + $ANT_RUN_CMD = @ARGV[1]; +} + +# dispose of the first two arguments, leaving only the command's args. +shift; +shift; + +# run the command +my $returnValue = system $ANT_RUN_CMD, @ARGV; +if ($returnValue eq 0) { + exit 0; +} +else { + # only 0 and 1 are widely recognized as exit values + # so change the exit value to 1 + exit 1; +} Added: trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/antenv.cmd =================================================================== --- trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/antenv.cmd (rev 0) +++ trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/antenv.cmd 2009-08-14 22:14:40 UTC (rev 924) @@ -0,0 +1,99 @@ +/* + Copyright 2003-2004 The Apache Software Foundation + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + Ant environment +*/ + +'@echo off' +call RxFuncAdd "SysLoadFuncs", "RexxUtil", "SysLoadFuncs" +call SysLoadFuncs + +/* Prepare the parameters for later use */ +parse arg argv +mode = '' +args = '' +opts = '' +cp = '' +lcp = '' + +do i = 1 to words(argv) + param = word(argv, i) + select + when param='-lcp' then mode = 'l' + when param='-cp' | param='-classpath' then mode = 'c' + when abbrev('-opts', param, 4) then mode = 'o' + when abbrev('-args', param, 4) then mode = 'a' + otherwise + select + when mode = 'a' then args = space(args param, 1) + when mode = 'c' then cp = space(cp param, 1) + when mode = 'l' then lcp = space(lcp param, 1) + when mode = 'o' then opts = space(opts param, 1) + otherwise + say 'Option' param 'ignored' + end + end +end + +env="OS2ENVIRONMENT" +antconf = _getenv_('antconf' 'antconf.cmd') +runrc = _getenv_('runrc') +interpret 'call "' || runrc || '"' '"' || antconf || '"' 'ETC' +ANT_HOME = value('ANT_HOME',,env) +JAVA_HOME = value('JAVA_HOME',,env) +classpath = value('CLASSPATH',,env) +classes = stream(JAVA_HOME || "\lib\classes.zip", "C", "QUERY EXISTS") +if classes \= '' then classpath = prepend(classpath classes) +classes = stream(JAVA_HOME || "\lib\tools.jar", "C", "QUERY EXISTS") +if classes \= '' then classpath = prepend(classpath classes) + +classpath = prepend(classpath ANT_HOME || '\lib\ant-launcher.jar') +'SET CLASSPATH=' || classpath + +/* Setting classpathes, options and arguments */ +envset = _getenv_('envset') +if cp\='' then interpret 'call "' || envset || '"' '"; CLASSPATH"' '"' || cp || '"' +if lcp\='' then interpret 'call "' || envset || '"' '"; LOCALCLASSPATH"' '"' || lcp || '"' +if opts\='' then interpret 'call "' || envset || '"' '"-D ANT_OPTS"' '"' || opts || '"' +if args\='' then interpret 'call "' || envset || '"' '"ANT_ARGS"' '"' || args || '"' + +exit 0 + +addpath: procedure +parse arg path elem +if elem = '' then do + if path\='' & right(path, 1)\=';' then path = path || ';' + return path +end +if substr(path, length(path)) = ';' then glue = '' +else glue = ';' +if pos(translate(elem), translate(path)) = 0 then path = path || glue || elem || ';' +return path + +prepend: procedure +parse arg path elem +if elem = '' then do + if path\='' & right(path, 1)\=';' then path = path || ';' + return path +end +if pos(translate(elem), translate(path)) = 0 then path = elem || ';' || path +return path + +_getenv_: procedure expose env +parse arg envar default +if default = '' then default = envar +var = value(translate(envar),,env) +if var = '' then var = default +return var Added: trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/complete-ant-cmd.pl =================================================================== --- trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/complete-ant-cmd.pl (rev 0) +++ trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/complete-ant-cmd.pl 2009-08-14 22:14:40 UTC (rev 924) @@ -0,0 +1,113 @@ +#!/usr/bin/perl +# +# Copyright 2001,2004 The Apache Software Foundation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# A script to allow Bash or Z-Shell to complete an Ant command-line. +# +# To install for Bash 2.0 or better, add the following to ~/.bashrc: +# +# $ complete -C complete-ant-cmd ant build.sh +# +# To install for Z-Shell 2.5 or better, add the following to ~/.zshrc: +# +# function ant_complete () { +# local args_line args +# read -l args_line +# set -A args $args_line +# set -A reply $(COMP_LINE=$args_line complete-ant-cmd ${args[1]} $1) +# } +# compctl -K ant_complete ant build.sh +# +# @author Mike Williams <mi...@co...> + +my $cmdLine = $ENV{'COMP_LINE'}; +my $antCmd = $ARGV[0]; +my $word = $ARGV[1]; + +my @completions; +if ($word =~ /^-/) { + list( restrict( $word, getArguments() )); +} elsif ($cmdLine =~ /-(f|buildfile)\s+\S*$/) { + list( getBuildFiles($word) ); +} else { + list( restrict( $word, getTargets() )); +} + +exit(0); + +sub list { + for (@_) { + print "$_\n"; + } +} + +sub restrict { + my ($word, @completions) = @_; + grep( /^\Q$word\E/, @completions ); +} + +sub getArguments { + qw(-buildfile -debug -emacs -f -find -help -listener -logfile + -logger -projecthelp -quiet -verbose -version); +} + + +sub getBuildFiles { + my ($word) = @_; + grep( /\.xml$/, glob( "$word*" )); +} + +sub getTargets { + + # Look for build-file + my $buildFile = 'build.xml'; + if ($cmdLine =~ /-(f|buildfile)\s+(\S+)/) { + $buildFile = $2; + } + return () unless (-f $buildFile); + + # Run "ant -projecthelp" to list targets. Keep a cache of results in a + # cache-file. + my $cacheFile = $buildFile; + $cacheFile =~ s|(.*/)?(.*)|${1}.ant-targets-${2}|; + if ((!-e $cacheFile) || (-M $buildFile) < (-M $cacheFile)) { + open( CACHE, '>'.$cacheFile ) || die "can\'t write $cacheFile: $!\n"; + open( HELP, "$antCmd -projecthelp -f '$buildFile'|" ) || return(); + my %targets; + while( <HELP> ) { + if (/^\s+(\S+)/) { + $targets{$1}++; + } + } + my @targets = sort keys %targets; + for (@targets) { print CACHE "$_\n"; } + return @targets; + } + + # Read the target-cache + open( CACHE, $cacheFile ) || die "can\'t read $cacheFile: $!\n"; + my @targets; + while (<CACHE>) { + chop; + s/\r$//; # for Cygwin + push( @targets, $_ ); + } + close( CACHE ); + @targets; + +} + + + Added: trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/envset.cmd =================================================================== --- trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/envset.cmd (rev 0) +++ trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/envset.cmd 2009-08-14 22:14:40 UTC (rev 924) @@ -0,0 +1,130 @@ +/* + + Copyright 2003-2004 The Apache Software Foundation + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +SET environment variables +First optional parameter: + ; parameters are considered parts of a path variable, semicolons are + appended to each element if not already present + -D parameters are properties for Java or Makefile etc., -D will be + prepended and the parameters will be separated by a space + =D the same as above but equal sign is not required + , parameters should be comma separated in the environment variable + - parameters should be separated by the next parameter + Other values mean that the first parameter is missing and the environment + variable will be set to the space separated parameters + +Second parameter: name of the environment variable + +Next parameters: values +; implies that the equal sign is considered a part of the parameter and is +not interpreted + +-D requires parameters in the form name=value. If the equal sign is not found, +the parameters are changed to name=expanded_name + +Other options have optional equal sign. If it is found, only the part after +the equal sign will be oprionally expanded. + +If the parameter is the minus sign, the next parameter will not be expanded. +If the parameter is a single dot, it will be replaced with the value of the +environment variable as it existed before envset was invoked. + +For other parameters the batch looks for the environment variable with the +same name (in uppercase). If it is found, it forms the expanded_name. If +the environment variable with such a name does not exist, the expanded_name +will hold the parameter name without case conversion. +*/ + +parse arg mode envar args + +equal = 0 +sep = ' ' + +/* Parse command line parameters */ +select + when mode='-' then do + sep = envar + parse var args envar args + end + when mode=';' then do + sep = '' + equal = -1 + end + when mode='-D' then equal = 1 + when mode='=D' then mode = '-D' + when mode=',' then sep = ',' +otherwise + args = envar args + envar = mode + mode = '' +end + +env = 'OS2ENVIRONMENT' +envar = translate(envar) +orig = value(envar,,env) +newval = '' +expand = 1 + +/* for each parameter... */ +do i = 1 to words(args) + if expand > 0 & word(args, i) = '-' then expand = 0 + else call addval word(args, i) +end + +/* Optionally enclose path variable by quotes */ +if mode = ';' & pos(' ', newval) > 0 then newval = '"' || newval || '"' + +/* Set the new value, 'SET' cannot be used since it does not allow '=' */ +x = value(envar, newval, env) +exit 0 + +addval: procedure expose sep equal orig expand newval mode env +parse arg var + +if var = '.' then expvar = orig +else do + if equal >= 0 then do + parse var var name '=' val + if val = '' then var = name + else var = val + end + if expand = 0 then expvar = var + else expvar = value(translate(var),,env) + if expvar = '' then expvar = var + if equal >= 0 then do + if val = '' then do + parse var expvar key '=' val + if val <> '' then name = key + else do + if equal > 0 then val = key + else name = key + end + end + else val = expvar + if pos(' ', val) > 0 | pos('=', val) > 0 then val = '"' || val || '"' + if val = '' then expvar = name + else expvar = name || '=' || val + end + if mode = '-D' then expvar = '-D' || expvar + if mode = ';' then do + if right(expvar, 1) <> ';' then expvar = expvar || ';' + end +end + +if newval = '' then newval = expvar +else newval = newval || sep || expvar +expand = 1 +return Added: trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/lcp.bat =================================================================== --- trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/lcp.bat (rev 0) +++ trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/lcp.bat 2009-08-14 22:14:40 UTC (rev 924) @@ -0,0 +1,30 @@ +REM +REM Copyright 2001-2004 The Apache Software Foundation +REM +REM Licensed under the Apache License, Version 2.0 (the "License"); +REM you may not use this file except in compliance with the License. +REM You may obtain a copy of the License at +REM +REM http://www.apache.org/licenses/LICENSE-2.0 +REM +REM Unless required by applicable law or agreed to in writing, software +REM distributed under the License is distributed on an "AS IS" BASIS, +REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +REM See the License for the specific language governing permissions and +REM limitations under the License. +REM +REM + +set _CLASSPATHCOMPONENT=%1 +if ""%1""=="""" goto gotAllArgs +shift + +:argCheck +if ""%1""=="""" goto gotAllArgs +set _CLASSPATHCOMPONENT=%_CLASSPATHCOMPONENT% %1 +shift +goto argCheck + +:gotAllArgs +set LOCALCLASSPATH=%_CLASSPATHCOMPONENT%;%LOCALCLASSPATH% + Added: trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/runant.pl =================================================================== --- trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/runant.pl (rev 0) +++ trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/runant.pl 2009-08-14 22:14:40 UTC (rev 924) @@ -0,0 +1,152 @@ +#!/usr/bin/perl +# +# Copyright 2000-2004 The Apache Software Foundation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +####################################################################### +# +# runant.pl +# +# wrapper script for invoking ant in a platform with Perl installed +# this may include cgi-bin invocation, which is considered somewhat daft. +# (slo: that should be a separate file which can be derived from this +# and returns the XML formatted output) +# +# the code is not totally portable due to classpath and directory splitting +# issues. oops. (NB, use File::Spec::Functions will help and the code is +# structured for the catfile() call, but because of perl version funnies +# the code is not included. +# +# created: 2000-8-24 +# author: Steve Loughran st...@so... +####################################################################### +# +# Assumptions: +# +# - the "java" executable/script is on the command path +# - ANT_HOME has been set +# - target platform uses ":" as classpath separator or perl indicates it is dos/win32 +# - target platform uses "/" as directory separator. + +#be fussy about variables +use strict; + +#platform specifics (disabled) +#use File::Spec::Functions; + +#turn warnings on during dev; generates a few spurious uninitialised var access warnings +#use warnings; + +#and set $debug to 1 to turn on trace info +my $debug=1; + +####################################################################### +# +# check to make sure environment is setup +# + +my $HOME = $ENV{ANT_HOME}; +if ($HOME eq "") + { + die "\n\nANT_HOME *MUST* be set!\n\n"; + } + +my $JAVACMD = $ENV{JAVACMD}; +$JAVACMD = "java" if $JAVACMD eq ""; + +my $onnetware = 0; +if ($^O eq "NetWare") +{ + $onnetware = 1; +} + +my $oncygwin = ($^O eq "cygwin"); + +#ISSUE: what java wants to split up classpath varies from platform to platform +#and perl is not too hot at hinting which box it is on. +#here I assume ":" 'cept on win32, dos, and netware. Add extra tests here as needed. +my $s=":"; +if(($^O eq "MSWin32") || ($^O eq "dos") || ($^O eq "cygwin") || + ($onnetware == 1)) + { + $s=";"; + } + +#build up standard classpath +my $localpath = "$HOME/lib/ant-launcher.jar"; +#set JVM options and Ant arguments, if any +my @ANT_OPTS=split(" ", $ENV{ANT_OPTS}); +my @ANT_ARGS=split(" ", $ENV{ANT_ARGS}); + +#jikes +if($ENV{JIKESPATH} ne "") + { + push @ANT_OPTS, "-Djikes.class.path=$ENV{JIKESPATH}"; + } + +#construct arguments to java +my @ARGS; +push @ARGS, @ANT_OPTS; + +my $CYGHOME = ""; + +my $classpath=$ENV{CLASSPATH}; +if ($oncygwin == 1) { + $localpath = `cygpath --path --windows $localpath`; + chomp ($localpath); + if (! $classpath eq "") + { + $classpath = `cygpath --path --windows "$classpath"`; + chomp ($classpath); + } + $HOME = `cygpath --path --windows $HOME`; + chomp ($HOME); + $CYGHOME = `cygpath --path --windows $ENV{HOME}`; + chomp ($CYGHOME); +} +push @ARGS, "-classpath", "$localpath"; +push @ARGS, "-Dant.home=$HOME"; +if ( ! $CYGHOME eq "" ) +{ + push @ARGS, "-Dcygwin.user.home=\"$CYGHOME\"" +} +push @ARGS, "org.apache.tools.ant.launch.Launcher", @ANT_ARGS; +push @ARGS, @ARGV; +if (! $classpath eq "") +{ + if ($onnetware == 1) + { + # make classpath literally $CLASSPATH + # this is to avoid pushing us over the 512 character limit + # even skip the ; - that is already in $localpath + push @ARGS, "-lib", "\$CLASSPATH"; + } + else + { + push @ARGS, "-lib", "$classpath"; + } +} +print "\n $JAVACMD @ARGS\n\n" if ($debug); + +my $returnValue = system $JAVACMD, @ARGS; +if ($returnValue eq 0) + { + exit 0; + } +else + { + # only 0 and 1 are widely recognized as exit values + # so change the exit value to 1 + exit 1; + } Added: trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/runant.py =================================================================== --- trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/runant.py (rev 0) +++ trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/runant.py 2009-08-14 22:14:40 UTC (rev 924) @@ -0,0 +1,100 @@ +#!/usr/bin/python +# Copyright 2001,2003-2004 The Apache Software Foundation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +""" + + runant.py + + This script is a translation of the runant.pl written by Steve Loughran. + It runs ant with/out arguments, it should be quite portable (thanks to + the python os library) + This script has been tested with Python2.0/Win2K + + created: 2001-04-11 + author: Pierre Dittgen pie...@cr... + + Assumptions: + + - the "java" executable/script is on the command path +""" +import os, os.path, string, sys + +# Change it to 1 to get extra debug information +debug = 0 + +####################################################################### + +# If ANT_HOME is not set default to script's parent directory +if os.environ.has_key('ANT_HOME'): + ANT_HOME = os.environ['ANT_HOME'] +else: + ANT_HOME = os.path.dirname(os.path.dirname(os.path.abspath(sys.argv[0]))) + +# set ANT_LIB location +ANT_LIB = os.path.join(ANT_HOME, 'lib') + +# set JAVACMD (check variables JAVACMD and JAVA_HOME) +JAVACMD = None +if not os.environ.has_key('JAVACMD'): + if os.environ.has_key('JAVA_HOME'): + if not os.path.exists(os.environ['JAVA_HOME']): + print "Warning: JAVA_HOME is not defined correctly." + else: + JAVACMD = os.path.join(os.environ['JAVA_HOME'], 'bin', 'java') + else: + print "Warning: JAVA_HOME not set." +else: + JAVACMD = os.environ['JAVACMD'] +if not JAVACMD: + JAVACMD = 'java' + +launcher_jar = os.path.join(ANT_LIB, 'ant-launcher.jar') +if not os.path.exists(launcher_jar): + print 'Unable to locate ant-launcher.jar. Expected to find it in %s' % \ + ANT_LIB + +# Build up standard classpath (LOCALCLASSPATH) +LOCALCLASSPATH = launcher_jar +if os.environ.has_key('LOCALCLASSPATH'): + LOCALCLASSPATH += os.pathsep + os.environ['LOCALCLASSPATH'] + +ANT_OPTS = "" +if os.environ.has_key('ANT_OPTS'): + ANT_OPTS = os.environ['ANT_OPTS'] + +OPTS = "" +if os.environ.has_key('JIKESPATH'): + OPTS = '-Djikes.class.path=\"%s\"' % os.environ['JIKESPATH'] + +ANT_ARGS = "" +if os.environ.has_key('ANT_ARGS'): + ANT_ARGS = os.environ['ANT_ARGS'] + +CLASSPATH = "" +if os.environ.has_key('CLASSPATH'): + CLASSPATH = os.environ['CLASSPATH'] + +# Builds the commandline +cmdline = ('%s %s -classpath %s -Dant.home=%s %s ' + \ + 'org.apache.tools.ant.launch.Launcher %s -lib %s %s') \ + % (JAVACMD, ANT_OPTS, LOCALCLASSPATH, ANT_HOME, OPTS, ANT_ARGS, \ + CLASSPATH, string.join(sys.argv[1:], ' ')) + +if debug: + print '\n%s\n\n' % (cmdline) + +# Run the biniou! +os.system(cmdline) Added: trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/runrc.cmd =================================================================== --- trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/runrc.cmd (rev 0) +++ trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/runrc.cmd 2009-08-14 22:14:40 UTC (rev 924) @@ -0,0 +1,59 @@ +/* + Copyright 2003-2004 The Apache Software Foundation + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + Run RC file, name is in the first arg, second arg is either PATH + ENV or -r or nothing +*/ + +parse arg name path rest + +if name = '' then do + say 'RC file name is missing' + exit 1 +end + +if rest \= '' then do + say 'Too many parameters' + exit 1 +end + +call runit name path +exit 0 + +runit: procedure +parse arg name path dir + +if path \= '' & path \= '-r' then do + dir = value(translate(path),,'OS2ENVIRONMENT') + if dir = '' then return + dir = translate(dir, '\', '/') /* change UNIX-like path to OS/2 */ +end + +if dir = '' then dir = directory() + +if path = '-r' then do /* recursive call */ + subdir = filespec('path', dir) + if subdir \= '\' then do + subdir = left(subdir, length(subdir)-1) + call runit name path filespec('drive', dir) || subdir + end +end + +/* Look for the file and run it */ +if right(dir, 1) \= '\' then dir = dir || '\' +rcfile = stream(dir || name, 'c', 'query exists') +if rcfile \= '' then interpret 'call "' || rcfile || '"' + +return This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pat...@us...> - 2009-08-14 21:52:42
|
Revision: 923 http://cishell.svn.sourceforge.net/cishell/?rev=923&view=rev Author: pataphil Date: 2009-08-14 21:52:29 +0000 (Fri, 14 Aug 2009) Log Message: ----------- * Added necessary template files for the static executable wizard. Added Paths: ----------- trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-launcher.jar trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant.jar trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/cishell_templates.jar trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/component.xml Added: trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-launcher.jar =================================================================== (Binary files differ) Property changes on: trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-launcher.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant.jar =================================================================== (Binary files differ) Property changes on: trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/cishell_templates.jar =================================================================== (Binary files differ) Property changes on: trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/cishell_templates.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/component.xml =================================================================== --- trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/component.xml (rev 0) +++ trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/component.xml 2009-08-14 21:52:29 UTC (rev 923) @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<component name="${component.id}" immediate="false"> + <implementation class="org.cishell.templates.staticexecutable.StaticExecutableAlgorithmFactory"/> + <properties entry="${service.properties}"/> + <property name="Algorithm-Directory" value="${alg.dir}"/> + <reference name="LOG" interface="org.osgi.service.log.LogService"/> + <reference name="MTS" interface="org.osgi.service.metatype.MetaTypeService"/> + + <service> + <provide interface= + "org.cishell.framework.algorithm.AlgorithmFactory"/> + </service> +</component> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pat...@us...> - 2009-08-14 21:48:41
|
Revision: 922 http://cishell.svn.sourceforge.net/cishell/?rev=922&view=rev Author: pataphil Date: 2009-08-14 21:48:28 +0000 (Fri, 14 Aug 2009) Log Message: ----------- * Added necessary template files for the static executable wizard. * For some reason SVN doesn't like it when I try to commit a brand new directory in this project, so I have to create it in the repository first. Added Paths: ----------- trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ant-bin/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pat...@us...> - 2009-08-14 21:45:44
|
Revision: 921 http://cishell.svn.sourceforge.net/cishell/?rev=921&view=rev Author: pataphil Date: 2009-08-14 21:45:32 +0000 (Fri, 14 Aug 2009) Log Message: ----------- * Fixed file copy bug. Modified Paths: -------------- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/BasicTemplate.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 Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/BasicTemplate.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/BasicTemplate.java 2009-08-14 17:41:28 UTC (rev 920) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/BasicTemplate.java 2009-08-14 21:45:32 UTC (rev 921) @@ -46,6 +46,7 @@ import org.eclipse.pde.ui.templates.OptionTemplateSection; import org.eclipse.pde.ui.templates.TemplateOption; +// TODO Could we safely reduce some of the method visibilities here? public abstract class BasicTemplate extends OptionTemplateSection { protected final String sectionID; protected Map valueMap; @@ -125,6 +126,10 @@ return value; } + public boolean shouldProcessFile(File file) { + return true; + } + public void execute(IProject project, IPluginModelBase model, IProgressMonitor monitor) throws CoreException { @@ -134,12 +139,12 @@ updateModel(monitor); } - public void generateFiles(IProgressMonitor progressMonitor) + protected void generateFiles(IProgressMonitor progressMonitor) throws CoreException { generateFiles(progressMonitor, getTemplateLocation()); } - public void generateFiles(IProgressMonitor progressMonitor, + protected void generateFiles(IProgressMonitor progressMonitor, URL locationURL) throws CoreException { progressMonitor.setTaskName( PDEUIMessages.AbstractTemplateSection_generating); @@ -167,8 +172,12 @@ return; } - generateFiles( - templateDirectory, project, true, false, progressMonitor); + generateFiles(templateDirectory, + project, + true, + false, + true, + progressMonitor); } else if ("jar".equals(resolvedLocationURLProtocol)) { int exclamationIndex = resolvedLocationURLFileName.indexOf('!'); @@ -223,17 +232,21 @@ progressMonitor.worked(1); } - private void generateFiles( + protected void generateFiles( File sourceFile, IContainer destinationContainer, boolean isFirstLevel, boolean isBinaryFile, + boolean shouldProcessAsTemplate, IProgressMonitor progressMonitor) throws CoreException { File[] sourceSubFiles = sourceFile.listFiles(); for (int ii = 0; ii < sourceSubFiles.length; ii++) { File sourceSubFile = sourceSubFiles[ii]; + boolean shouldProcessSubFileAsTemplate = + shouldProcessAsTemplate && shouldProcessFile(sourceSubFile); + if (sourceSubFile.isDirectory()) { IContainer subDestinationContainer = null; @@ -260,8 +273,15 @@ continue; } - String folderName = getProcessedString( - sourceSubFile.getName(), sourceSubFile.getName()); + String folderName; + + if (shouldProcessSubFileAsTemplate) { + folderName = getProcessedString( + sourceSubFile.getName(), sourceSubFile.getName()); + } else { + folderName = sourceSubFile.getName(); + } + subDestinationContainer = destinationContainer.getFolder(new Path(folderName)); } @@ -276,6 +296,7 @@ subDestinationContainer, false, isBinaryFile, + shouldProcessSubFileAsTemplate, progressMonitor); } else { if (isOkToCreateFile(sourceSubFile)) { @@ -291,6 +312,7 @@ inputStream, destinationContainer, isBinaryFile, + shouldProcessSubFileAsTemplate, progressMonitor); } catch (IOException ioException1) { } finally { @@ -306,7 +328,7 @@ } } - private void generateFiles( + protected void generateFiles( ZipFile zipFile, IPath filePath, IContainer destinationContainer, @@ -314,8 +336,9 @@ boolean isBinary, IProgressMonitor progressMonitor) throws CoreException { int pathLength = filePath.segmentCount(); - // Immidiate children - Map childZipEntries = new HashMap(); // "dir/" or "dir/file.java" + // Immediate children. + // "dir/" or "dir/file.java" + Map childZipEntries = new HashMap(); for (Enumeration zipEntries = zipFile.entries(); zipEntries.hasMoreElements();) { @@ -327,7 +350,7 @@ } if (!filePath.isPrefixOf(entryPath)) { - // not a descendant + // Not a descendant. continue; } @@ -404,6 +427,7 @@ inputStream, destinationContainer, isBinary, + true, progressMonitor); } catch (IOException ioException1) { } finally { @@ -457,7 +481,7 @@ return source; } - int location = -1; + int locationIndex = -1; StringBuffer buffer = new StringBuffer(); boolean shouldReplace = false; @@ -466,7 +490,7 @@ if (currentCharacter == '$') { if (shouldReplace) { - String key = source.substring(location, ii); + String key = source.substring(locationIndex, ii); String value; if (key.length() == 0) { @@ -479,7 +503,7 @@ shouldReplace = false; } else { shouldReplace = true; - location = ii + 1; + locationIndex = ii + 1; continue; } @@ -495,17 +519,30 @@ InputStream inputStream, IContainer destinationContainer, boolean isBinary, + boolean shouldProcessSubFileAsTemplate, IProgressMonitor progressMonitor) throws CoreException { - String targetFileName = getProcessedString(fileName, fileName); + String targetFileName; + + if (shouldProcessSubFileAsTemplate) { + targetFileName = getProcessedString(fileName, fileName); + } else { + targetFileName = fileName; + } progressMonitor.subTask(targetFileName); IFile destinationFile = destinationContainer.getFile(new Path(targetFileName)); try { - InputStream processedInputStream = - getProcessedStream(fileName, inputStream, isBinary); + InputStream processedInputStream; + if (shouldProcessSubFileAsTemplate) { + processedInputStream = + getProcessedStream(fileName, inputStream, isBinary); + } else { + processedInputStream = inputStream; + } + if (destinationFile.exists()) { destinationFile.setContents( processedInputStream, true, true, progressMonitor); 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 17:41:28 UTC (rev 920) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/NewStaticExecutableAlgorithmTemplate.java 2009-08-14 21:45:32 UTC (rev 921) @@ -13,6 +13,9 @@ * ***************************************************************************/ 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; @@ -182,6 +185,18 @@ { MENU_END_LABEL, MENU_END_DESCRIPTION } }; + public static final String[] IGNORED_REPLACEMENT_STRING_FILES = + new String[] { + "ant.sh", + "build.xml" + }; + + public static final String[] IGNORED_REPLACEMENT_STRING_DIRECTORIES = + new String[] { + "l10n", + "lib" + }; + private WizardNewProjectCreationPage createProjectPage; private WizardPage bundlePropertiesPage; private ChooseExecutableFilesPage chooseExecutableFilesPage; @@ -327,6 +342,32 @@ super.execute(project, model, monitor); } + + public boolean shouldProcessFile(File file) { + String fileName = file.getName(); + String filePath = file.getParent(); + + for (int ii = 0; ii < IGNORED_REPLACEMENT_STRING_FILES.length; ii++) { + if (IGNORED_REPLACEMENT_STRING_FILES[ii].equals(fileName)) { + return false; + } + } + + /* TODO What if the path happens to include an ignored string, + * like "lib", but without the meaning intended here? + * Like ".../workspace/reginald_libby/...". + */ + for (int ii = 0; + ii < IGNORED_REPLACEMENT_STRING_DIRECTORIES.length; + ii++) { + if (filePath.contains( + IGNORED_REPLACEMENT_STRING_DIRECTORIES[ii])) { + return false; + } + } + + return true; + } protected void updateModel(IProgressMonitor monitor) throws CoreException { } 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 17:41:28 UTC (rev 920) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/NewStaticExecutableAlgorithmWizard.java 2009-08-14 21:45:32 UTC (rev 921) @@ -102,7 +102,8 @@ */ public ITemplateSection[] createTemplateSections() { template = new NewStaticExecutableAlgorithmTemplate(); - return new ITemplateSection[]{template}; + + return new ITemplateSection[] { template }; } public boolean performFinish() { @@ -206,9 +207,7 @@ /** * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection) */ - public void init(IWorkbench workbench, IStructuredSelection selection) { - - } + public void init(IWorkbench workbench, IStructuredSelection selection) {} private void copyTemplateOptionFile(TemplateOption templateOption, String directoryPath, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pat...@us...> - 2009-08-14 17:41:39
|
Revision: 920 http://cishell.svn.sourceforge.net/cishell/?rev=920&view=rev Author: pataphil Date: 2009-08-14 17:41:28 +0000 (Fri, 14 Aug 2009) Log Message: ----------- * All of the template file copying/processing is now within our control. Modified Paths: -------------- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/BasicTemplate.java Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/BasicTemplate.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/BasicTemplate.java 2009-08-13 19:23:23 UTC (rev 919) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/BasicTemplate.java 2009-08-14 17:41:28 UTC (rev 920) @@ -13,14 +13,36 @@ * ***************************************************************************/ package org.cishell.templates.wizards; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.MalformedURLException; import java.net.URL; +import java.util.Enumeration; import java.util.HashMap; +import java.util.Iterator; import java.util.Map; import java.util.ResourceBundle; +import java.util.zip.ZipEntry; +import java.util.zip.ZipException; +import java.util.zip.ZipFile; +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.Path; +import org.eclipse.pde.core.plugin.IPluginModelBase; import org.eclipse.pde.core.plugin.IPluginReference; +import org.eclipse.pde.internal.ui.PDEUIMessages; +import org.eclipse.pde.internal.ui.wizards.templates.ControlStack; import org.eclipse.pde.ui.templates.OptionTemplateSection; import org.eclipse.pde.ui.templates.TemplateOption; @@ -103,6 +125,516 @@ return value; } + public void execute(IProject project, + IPluginModelBase model, + IProgressMonitor monitor) throws CoreException { + this.project = project; + this.model = model; + generateFiles(monitor); + updateModel(monitor); + } + + public void generateFiles(IProgressMonitor progressMonitor) + throws CoreException { + generateFiles(progressMonitor, getTemplateLocation()); + } + + public void generateFiles(IProgressMonitor progressMonitor, + URL locationURL) throws CoreException { + progressMonitor.setTaskName( + PDEUIMessages.AbstractTemplateSection_generating); + + if (locationURL == null) { + return; + } + + URL resolvedLocationURL; + + try { + resolvedLocationURL = FileLocator.resolve(locationURL); + resolvedLocationURL = FileLocator.toFileURL(locationURL); + } catch (IOException e) { + return; + } + + String resolvedLocationURLProtocol = resolvedLocationURL.getProtocol(); + String resolvedLocationURLFileName = resolvedLocationURL.getFile(); + + if ("file".equals(resolvedLocationURLProtocol)) { + File templateDirectory = new File(resolvedLocationURLFileName); + + if (!templateDirectory.exists()) { + return; + } + + generateFiles( + templateDirectory, project, true, false, progressMonitor); + } else if ("jar".equals(resolvedLocationURLProtocol)) { + int exclamationIndex = resolvedLocationURLFileName.indexOf('!'); + + if (exclamationIndex < 0) { + return; + } + + URL fileURL = null; + + try { + String fileNameUpToExclamationMark = + resolvedLocationURLFileName.substring(0, exclamationIndex); + fileURL = new URL(fileNameUpToExclamationMark); + } catch (MalformedURLException malformedURLException) { + return; + } + + File pluginJarFile = new File(fileURL.getFile()); + + if (!pluginJarFile.exists()) { + return; + } + + // "/some/path/" + String templateDirectoryName = + resolvedLocationURLFileName.substring(exclamationIndex + 1); + IPath templateDirectoryPath = new Path(templateDirectoryName); + ZipFile zipFile = null; + + try { + zipFile = new ZipFile(pluginJarFile); + generateFiles(zipFile, + templateDirectoryPath, + project, + true, + false, + progressMonitor); + } catch (ZipException zipException) { + } catch (IOException ioException1) { + } finally { + if (zipFile != null) { + try { + zipFile.close(); + } catch (IOException ioException2) { + } + } + } + + } + + progressMonitor.subTask(""); //$NON-NLS-1$ + progressMonitor.worked(1); + } + + private void generateFiles( + File sourceFile, + IContainer destinationContainer, + boolean isFirstLevel, + boolean isBinaryFile, + IProgressMonitor progressMonitor) throws CoreException { + File[] sourceSubFiles = sourceFile.listFiles(); + + for (int ii = 0; ii < sourceSubFiles.length; ii++) { + File sourceSubFile = sourceSubFiles[ii]; + + if (sourceSubFile.isDirectory()) { + IContainer subDestinationContainer = null; + + if (isFirstLevel) { + isBinaryFile = false; + + if (!isOkToCreateFolder(sourceSubFile)) { + continue; + } + + if (sourceSubFile.getName().equals("java")) { + IFolder sourceFolder = + getSourceFolder(progressMonitor); + subDestinationContainer = generateJavaSourceFolder( + sourceFolder, progressMonitor); + } else if (sourceSubFile.getName().equals("bin")) { + isBinaryFile = true; + subDestinationContainer = destinationContainer; + } + } + + if (subDestinationContainer == null) { + if (isOkToCreateFolder(sourceSubFile) == false) { + continue; + } + + String folderName = getProcessedString( + sourceSubFile.getName(), sourceSubFile.getName()); + subDestinationContainer = + destinationContainer.getFolder(new Path(folderName)); + } + + if (subDestinationContainer instanceof IFolder && + !subDestinationContainer.exists()) { + ((IFolder)subDestinationContainer).create( + true, true, progressMonitor); + } + + generateFiles(sourceSubFile, + subDestinationContainer, + false, + isBinaryFile, + progressMonitor); + } else { + if (isOkToCreateFile(sourceSubFile)) { + if (isFirstLevel) { + isBinaryFile = false; + } + + InputStream inputStream = null; + + try { + inputStream = new FileInputStream(sourceSubFile); + copyFile(sourceSubFile.getName(), + inputStream, + destinationContainer, + isBinaryFile, + progressMonitor); + } catch (IOException ioException1) { + } finally { + if (inputStream != null) { + try { + inputStream.close(); + } catch (IOException ioException2) { + } + } + } + } + } + } + } + + private void generateFiles( + ZipFile zipFile, + IPath filePath, + IContainer destinationContainer, + boolean isFirstLevel, + boolean isBinary, + IProgressMonitor progressMonitor) throws CoreException { + int pathLength = filePath.segmentCount(); + // Immidiate children + Map childZipEntries = new HashMap(); // "dir/" or "dir/file.java" + + for (Enumeration zipEntries = zipFile.entries(); + zipEntries.hasMoreElements();) { + ZipEntry zipEntry = (ZipEntry)zipEntries.nextElement(); + IPath entryPath = new Path(zipEntry.getName()); + if (entryPath.segmentCount() <= pathLength) { + // ancestor or current directory + continue; + } + + if (!filePath.isPrefixOf(entryPath)) { + // not a descendant + continue; + } + + if (entryPath.segmentCount() == pathLength + 1) { + childZipEntries.put(zipEntry.getName(), zipEntry); + } else { + String name = entryPath.uptoSegment(pathLength + 1). + addTrailingSeparator().toString(); + + if (!childZipEntries.containsKey(name)) { + ZipEntry dirEntry = new ZipEntry(name); + childZipEntries.put(name, dirEntry); + } + } + } + + for (Iterator childZipEntryIterator = + childZipEntries.values().iterator(); + childZipEntryIterator.hasNext();) { + ZipEntry zipEnry = (ZipEntry)childZipEntryIterator.next(); + String name = new Path(zipEnry.getName()).lastSegment().toString(); + if (zipEnry.isDirectory()) { + IContainer subDestinationContainer = null; + + if (isFirstLevel) { + isBinary = false; + + if (name.equals("java")) { + IFolder sourceFolder = + getSourceFolder(progressMonitor); + subDestinationContainer = generateJavaSourceFolder( + sourceFolder, progressMonitor); + } else if (name.equals("bin")) { + isBinary = true; + subDestinationContainer = destinationContainer; + } + } + + if (subDestinationContainer == null) { + File newFolder = new File(filePath.toFile(), name); + + if (!isOkToCreateFolder(newFolder)) { + continue; + } + + String folderName = getProcessedString(name, name); + subDestinationContainer = + destinationContainer.getFolder(new Path(folderName)); + } + + if (subDestinationContainer instanceof IFolder && + !subDestinationContainer.exists()) { + ((IFolder)subDestinationContainer).create( + true, true, progressMonitor); + } + + generateFiles(zipFile, + filePath.append(name), + subDestinationContainer, + false, + isBinary, + progressMonitor); + } else { + if (isOkToCreateFile(new File(filePath.toFile(), name))) { + if (isFirstLevel) { + isBinary = false; + } + + InputStream inputStream = null; + + try { + inputStream = zipFile.getInputStream(zipEnry); + copyFile(name, + inputStream, + destinationContainer, + isBinary, + progressMonitor); + } catch (IOException ioException1) { + } finally { + if (inputStream != null) + try { + inputStream.close(); + } catch (IOException ioException2) { + } + } + } + } + } + } + + public IFolder generateJavaSourceFolder( + IFolder sourceFolder, + IProgressMonitor monitor) throws CoreException { + Object packageValue = getValue(KEY_PACKAGE_NAME); + String packageName; + + if (packageValue != null) { + packageName = packageValue.toString(); + } else { + packageName = null; + } + + if (packageName == null) { + packageName = model.getPluginBase().getId(); + } + + IPath path = new Path(packageName.replace('.', File.separatorChar)); + + if (sourceFolder != null) { + path = sourceFolder.getProjectRelativePath().append(path); + } + + for (int ii = 1; ii <= path.segmentCount(); ii++) { + IPath subpath = path.uptoSegment(ii); + IFolder subfolder = project.getFolder(subpath); + + if (subfolder.exists() == false) { + subfolder.create(true, true, monitor); + } + } + + return project.getFolder(path); + } + + private String getProcessedString(String fileName, String source) { + if (source.indexOf('$') == -1) { + return source; + } + + int location = -1; + StringBuffer buffer = new StringBuffer(); + boolean shouldReplace = false; + + for (int ii = 0; ii < source.length(); ii++) { + char currentCharacter = source.charAt(ii); + + if (currentCharacter == '$') { + if (shouldReplace) { + String key = source.substring(location, ii); + String value; + + if (key.length() == 0) { + value = "$"; + } else { + value = getReplacementString(fileName, key); + } + + buffer.append(value); + shouldReplace = false; + } else { + shouldReplace = true; + location = ii + 1; + + continue; + } + } else if (!shouldReplace) { + buffer.append(currentCharacter); + } + } + return buffer.toString(); + } + + private void copyFile( + String fileName, + InputStream inputStream, + IContainer destinationContainer, + boolean isBinary, + IProgressMonitor progressMonitor) throws CoreException { + String targetFileName = getProcessedString(fileName, fileName); + + progressMonitor.subTask(targetFileName); + IFile destinationFile = + destinationContainer.getFile(new Path(targetFileName)); + + try { + InputStream processedInputStream = + getProcessedStream(fileName, inputStream, isBinary); + + if (destinationFile.exists()) { + destinationFile.setContents( + processedInputStream, true, true, progressMonitor); + } else { + destinationFile.create( + processedInputStream, true, progressMonitor); + } + + processedInputStream.close(); + + } catch (IOException ioException) { + } + } + + private InputStream getProcessedStream( + String fileName, + InputStream inputStream, + boolean isBinary) throws IOException, CoreException { + if (isBinary) { + return inputStream; + } + + InputStreamReader inputStreamReader = + new InputStreamReader(inputStream); + int bufferSize = 1024; + char[] characterBuffer = new char[bufferSize]; + int readCharacterCount = 0; + StringBuffer keyStringBuffer = new StringBuffer(); + StringBuffer outStringBuffer = new StringBuffer(); + StringBuffer preStringBuffer = new StringBuffer(); + boolean isOnNewLine = true; + ControlStack preControlStack = new ControlStack(); + preControlStack.setValueProvider(this); + + boolean shouldReplace = false; + boolean shouldPreProcess = false; + boolean foundEscapeCharacter = false; + while (readCharacterCount != -1) { + readCharacterCount = inputStreamReader.read(characterBuffer); + + for (int ii = 0; ii < readCharacterCount; ii++) { + char currentCharacter = characterBuffer[ii]; + + if (foundEscapeCharacter) { + StringBuffer stringBuffer; + + if (shouldPreProcess) { + stringBuffer = preStringBuffer; + } else { + stringBuffer = outStringBuffer; + } + + stringBuffer.append(currentCharacter); + foundEscapeCharacter = false; + + continue; + } + + if (isOnNewLine && currentCharacter == '%') { + // PreProcessor line. + shouldPreProcess = true; + preStringBuffer.delete(0, preStringBuffer.length()); + + continue; + } + + if (shouldPreProcess) { + if (currentCharacter == '\\') { + foundEscapeCharacter = true; + + continue; + } + + if (currentCharacter == '\n') { + // Handle line. + shouldPreProcess = false; + isOnNewLine = true; + String line = preStringBuffer.toString().trim(); + preControlStack.processLine(line); + + continue; + } + + preStringBuffer.append(currentCharacter); + + continue; + } + + if (preControlStack.getCurrentState() == false) { + continue; + } + + if (currentCharacter == '$') { + if (shouldReplace) { + shouldReplace = false; + String key = keyStringBuffer.toString(); + String value; + + if (key.length() == 0) { + value = "$"; + } else { + value = getReplacementString(fileName, key); + } + + outStringBuffer.append(value); + keyStringBuffer.delete(0, keyStringBuffer.length()); + } else { + shouldReplace = true; + } + } else { + if (shouldReplace) { + keyStringBuffer.append(currentCharacter); + } + else { + outStringBuffer.append(currentCharacter); + + if (currentCharacter == '\n') { + isOnNewLine = true; + } else + isOnNewLine = false; + } + } + } + } + + return new ByteArrayInputStream( + outStringBuffer.toString().getBytes(project.getDefaultCharset())); + } + /** * @see org.eclipse.pde.ui.templates.AbstractTemplateSection#getPluginResourceBundle() */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pat...@us...> - 2009-08-13 19:23:34
|
Revision: 919 http://cishell.svn.sourceforge.net/cishell/?rev=919&view=rev Author: pataphil Date: 2009-08-13 19:23:23 +0000 (Thu, 13 Aug 2009) Log Message: ----------- Oops. Added Paths: ----------- trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/lib/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pat...@us...> - 2009-08-13 18:42:33
|
Revision: 918 http://cishell.svn.sourceforge.net/cishell/?rev=918&view=rev Author: pataphil Date: 2009-08-13 18:42:24 +0000 (Thu, 13 Aug 2009) Log Message: ----------- * Added the choose source code files page. * Had entire code base for the wizard reviewed by Chintan. * Attempted to comment code well. Modified Paths: -------------- 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/PlatformOptionProvider.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/AddInputDataPanel.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/AddOutputDataPanel.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/SetupPlatformsPanel.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/ChooseExecutableFilesPage.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pages/ParameterListBuilderPage.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pages/SpecifyInAndOutDataPage.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/InputDataItem.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/InputDataItemEditor.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/staticexecutable/OutputDataItem.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/OutputDataItemEditor.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/StaticExecutableInputDataDelegate.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/StaticExecutableOutputDataDelegate.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 trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/widgets/PlatformSetupHeaderWidget.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/widgets/PlatformSetupWidget.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/widgets/ResizeCompositeHackWidget.java Added Paths: ----------- 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/pages/ChooseSourceCodeFilesPage.java trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/src/ Modified: 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-06 22:02:26 UTC (rev 917) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/providers/PlatformOption.java 2009-08-13 18:42:24 UTC (rev 918) @@ -1,11 +1,24 @@ package org.cishell.templates.staticexecutable.providers; import org.eclipse.pde.ui.templates.BaseOptionTemplateSection; -import org.eclipse.pde.ui.templates.StringOption; +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 StringOption { +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, @@ -14,6 +27,9 @@ String platformPath) { super(section, name, label); + this.style = DEFAULT_STYLE; + setRequired(true); + this.platformName = platformName; this.platformPath = platformPath; } @@ -25,4 +41,86 @@ 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-06 22:02:26 UTC (rev 917) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/providers/PlatformOptionProvider.java 2009-08-13 18:42:24 UTC (rev 918) @@ -1,5 +1,7 @@ package org.cishell.templates.staticexecutable.providers; +import org.eclipse.pde.ui.templates.TemplateOption; + public interface PlatformOptionProvider { public PlatformOption getExecutableFileOption(String platformName); public PlatformOption[] getExecutableFileOptions(); @@ -10,7 +12,7 @@ public PlatformOption[] getRelatedFileOptions(String platformName); public void addRelatedFileOption(PlatformOption relatedFileOption); - public void removeRelatedFileOption(PlatformOption relatedFileOption); + public void removeRelatedFileOption(TemplateOption relatedFileOption); public PlatformOption createRelatedFileOption( String platformName, String platformPath); public String formRelatedFileOptionName(String platformName); Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/AddInputDataPanel.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/AddInputDataPanel.java 2009-08-06 22:02:26 UTC (rev 917) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/AddInputDataPanel.java 2009-08-13 18:42:24 UTC (rev 918) @@ -3,7 +3,6 @@ import java.util.Map; import org.cishell.templates.guibuilder.BuilderDelegate; -import org.cishell.templates.guibuilder.EditableAttributeDefinition; import org.cishell.templates.guibuilder.ListBuilder; import org.cishell.templates.wizards.staticexecutable.InputDataItem; import org.cishell.templates.wizards.staticexecutable.StaticExecutableInputDataDelegate; @@ -19,6 +18,18 @@ import org.eclipse.swt.widgets.Layout; import org.eclipse.swt.widgets.TableItem; +/* + * This panel provides the user an interface for managing input data via + * org.cishell.templates.guibuilder.ListBuilder, an appropriate delegate + * (org.cishell.templates.wizards.staticexecutable. + * StaticExecutableInputDataDelegate), and an appropriate editor + * (org.cishell.templates.wizards.staticexecutable.InputDataItemEditor). + * The ListBuilder manages the GUI table and associated buttons. + * The delegate provides the ListBuilder and editor the appropriate columns + * that represent the data items being managed. It also stores the input data + * items. + * The editor provides an interface for the user to edit the actual data items. + */ public class AddInputDataPanel extends Composite { public static final String INPUT_DATA_LABEL_TEXT = "Input Data"; Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/AddOutputDataPanel.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/AddOutputDataPanel.java 2009-08-06 22:02:26 UTC (rev 917) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/AddOutputDataPanel.java 2009-08-13 18:42:24 UTC (rev 918) @@ -4,7 +4,6 @@ import org.cishell.templates.guibuilder.BuilderDelegate; import org.cishell.templates.guibuilder.ListBuilder; -import org.cishell.templates.wizards.staticexecutable.InputDataItem; import org.cishell.templates.wizards.staticexecutable.OutputDataItem; import org.cishell.templates.wizards.staticexecutable.StaticExecutableOutputDataDelegate; import org.eclipse.swt.SWT; @@ -19,6 +18,18 @@ import org.eclipse.swt.widgets.Layout; import org.eclipse.swt.widgets.TableItem; +/* + * This panel provides the user an interface for managing output data via + * org.cishell.templates.guibuilder.ListBuilder, an appropriate delegate + * (org.cishell.templates.wizards.staticexecutable. + * StaticExecutableOutputDataDelegate), and an appropriate editor + * (org.cishell.templates.wizards.staticexecutable.OutputDataItemEditor). + * The ListBuilder manages the GUI table and associated buttons. + * The delegate provides the ListBuilder and editor the appropriate columns + * that represent the data items being managed. It also stores the output + * data items. + * The editor provides an interface for the user to edit the actual data items. + */ public class AddOutputDataPanel extends Composite { public static final String OUTPUT_DATA_LABEL_TEXT = "Output Data"; Added: 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 (rev 0) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/ChooseSourceCodeFilesPanel.java 2009-08-13 18:42:24 UTC (rev 918) @@ -0,0 +1,37 @@ +package org.cishell.templates.wizards.pagepanels; + +import org.cishell.templates.wizards.widgets.ChooseFileWidget; +import org.eclipse.pde.ui.templates.TemplateOption; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Layout; + +/* + */ +public class ChooseSourceCodeFilesPanel extends Composite { + public ChooseSourceCodeFilesPanel( + Composite parent, + int style, + TemplateOption sourceCodeFilesLocationOption) { + super(parent, style); + + setLayout(createLayoutForThis()); + createChooseSourceCodeFilesWidget(sourceCodeFilesLocationOption); + } + + private Layout createLayoutForThis() { + GridLayout layout = new GridLayout(3, true); + layout.makeColumnsEqualWidth = false; + + return layout; + } + + private void createChooseSourceCodeFilesWidget( + TemplateOption sourceCodeFilesLocationOption) { + int parentWidth = + this.getParent().computeSize(SWT.DEFAULT, SWT.DEFAULT).x; + ChooseFileWidget fileSelector = new ChooseFileWidget( + this, SWT.NONE, false, parentWidth, sourceCodeFilesLocationOption); + } +} Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/SetupPlatformsPanel.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/SetupPlatformsPanel.java 2009-08-06 22:02:26 UTC (rev 917) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/SetupPlatformsPanel.java 2009-08-13 18:42:24 UTC (rev 918) @@ -15,12 +15,16 @@ import org.eclipse.swt.widgets.Layout; import org.eclipse.swt.widgets.Text; +/* + * This panel contains several platform setup widgets + * (org.cishell.templates.wizards.widgets.PlatformSetupWidget). There is one + * platform setup widget per (operating system) platform and a special + * platform setup widget for files common to all (operating system) platforms. + */ public class SetupPlatformsPanel extends ResizeCompositeHackWidget { public static final String SPECIFY_EXECUTABLE_NAME_LABEL = "Executable Name"; - // public static final int SPECIFY_EXECUTABLE_NAME_TEXT_WIDTH = 350; - private ArrayList platformSetupWidgets; public SetupPlatformsPanel(Composite parent, @@ -52,22 +56,6 @@ executableNameOption.createControl(this, 2); } - private void createSpecifyExecutableNameLabel() { - Label specifyExecutableNameLabel = new Label(this, SWT.NONE); - specifyExecutableNameLabel.setLayoutData( - createSpecifyExecutableNameLableLayoutData()); - specifyExecutableNameLabel.setText( - SPECIFY_EXECUTABLE_NAME_LABEL + ":"); - } - - private Text createSpecifyExecutableNameText() { - Text specifyExecutableNameText = new Text(this, SWT.BORDER); - specifyExecutableNameText.setLayoutData( - createSpecifyExecutableNameTextLayoutData()); - - return specifyExecutableNameText; - } - private ArrayList createPlatformSetupWidgets( PlatformOptionProvider platformOptionProvider) { ArrayList platformSetupWidgets = new ArrayList(); @@ -103,21 +91,6 @@ return platformSetupWidgets; } - private Object createSpecifyExecutableNameLableLayoutData() { - GridData data = new GridData(); - - return data; - } - - private Object createSpecifyExecutableNameTextLayoutData() { - GridData data = new GridData(); - data.horizontalAlignment = SWT.FILL; - data.grabExcessHorizontalSpace = true; - // data.widthHint = SPECIFY_EXECUTABLE_NAME_TEXT_WIDTH; - - return data; - } - private Object createPlatformSetupWidgetLayoutData() { GridData data = new GridData(); data.horizontalAlignment = SWT.FILL; 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-06 22:02:26 UTC (rev 917) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/SpecifyTemplateStringPanel.java 2009-08-13 18:42:24 UTC (rev 918) @@ -16,9 +16,10 @@ 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; +/* + */ public class SpecifyTemplateStringPanel extends Composite implements SelectionListener { public static final String PLACEHOLDER_LABEL = @@ -100,11 +101,13 @@ createPlaceholderTableLabelLayoutData()); placeholderTableLabel.setText(PLACEHOLDER_LABEL); - Label insertButtonLabel = new Label(this, SWT.NONE); - insertButtonLabel.setLayoutData( + // This is to keep the layout manager happy and make everything line up + // the way it should. + Label dummyLabel = new Label(this, SWT.NONE); + dummyLabel.setLayoutData( createInsertPlaceholderButtonLayoutData()); - insertButtonLabel.setText(INSERT_PLACEHOLDER_BUTTON_LABEL); - insertButtonLabel.setVisible(false); + dummyLabel.setText(INSERT_PLACEHOLDER_BUTTON_LABEL); + dummyLabel.setVisible(false); // To accomodate for the option label control. new Label(this, SWT.NONE).setLayoutData(new GridData()); Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pages/ChooseExecutableFilesPage.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pages/ChooseExecutableFilesPage.java 2009-08-06 22:02:26 UTC (rev 917) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pages/ChooseExecutableFilesPage.java 2009-08-13 18:42:24 UTC (rev 918) @@ -10,6 +10,13 @@ import org.eclipse.swt.events.ControlEvent; import org.eclipse.swt.widgets.Composite; +/* + * This page allows users to specify the name of the executable file (which + * should be the same across all platforms), the actual executable files for + * the various platforms, and the related files for the various platforms. + * The logic for this page is spread out in several locations, but for a start, + * check org.cishell.templates.wizards.pagepanels.SetupPlatformsPanel . + */ public class ChooseExecutableFilesPage extends WizardPage { private SetupPlatformsPanel setupPlatformsPanel; private TemplateOption executableNameOption; Added: 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 (rev 0) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pages/ChooseSourceCodeFilesPage.java 2009-08-13 18:42:24 UTC (rev 918) @@ -0,0 +1,31 @@ +package org.cishell.templates.wizards.pages; + +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; + +/* + * This page allows algorithm creators to choose a single file that is intended + * to be an archive file containing their algorithm source code. + */ +public class ChooseSourceCodeFilesPage extends WizardPage { + private ChooseSourceCodeFilesPanel chooseSourceCodeFilesPanel; + private TemplateOption sourceCodeFilesLocationOption; + + public ChooseSourceCodeFilesPage( + String pageName, + TemplateOption sourceCodeFilesLocationOption) { + super(pageName); + + this.sourceCodeFilesLocationOption = sourceCodeFilesLocationOption; + } + + public void createControl(Composite parent) { + this.chooseSourceCodeFilesPanel = new ChooseSourceCodeFilesPanel( + parent, SWT.NONE, this.sourceCodeFilesLocationOption); + + setControl(this.chooseSourceCodeFilesPanel); + } +} \ No newline at end of file Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pages/ParameterListBuilderPage.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pages/ParameterListBuilderPage.java 2009-08-06 22:02:26 UTC (rev 917) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pages/ParameterListBuilderPage.java 2009-08-13 18:42:24 UTC (rev 918) @@ -27,7 +27,10 @@ import org.eclipse.swt.widgets.Shell; import org.osgi.service.metatype.AttributeDefinition; - +/* + * This page provides algorithm creators with an interface for specifying the + * GUI-based input parameters that their algorithms accept. + */ public class ParameterListBuilderPage extends WizardPage implements InputParameterProvider { ParameterListBuilder builder; Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pages/SpecifyInAndOutDataPage.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pages/SpecifyInAndOutDataPage.java 2009-08-06 22:02:26 UTC (rev 917) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pages/SpecifyInAndOutDataPage.java 2009-08-13 18:42:24 UTC (rev 918) @@ -13,6 +13,13 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Layout; +/* + * This page allows users the specify input and output data. + * Input data is handled in + * org.cishell.templates.wizards.pagepanels.AddInputDataPanel, and output data + * is handled in + * org.cishell.templates.wizards.pagepanels.AddOutputDataPanel. + */ public class SpecifyInAndOutDataPage extends WizardPage implements InputDataProvider, OutputDataProvider { private AddInputDataPanel addInputDataPanel; @@ -42,19 +49,19 @@ return layout; } - private AddInputDataPanel createAndSetupInputDataPanel(Composite container, - final Composite parent) { + private AddInputDataPanel createAndSetupInputDataPanel( + Composite container, final Composite parent) { AddInputDataPanel addInputDataPanel = - new AddInputDataPanel(container, SWT.BORDER); + new AddInputDataPanel(container, SWT.NONE); addInputDataPanel.setLayoutData(createPanelLayoutData()); return addInputDataPanel; } - private AddOutputDataPanel createAndSetupOutputDataPanel(Composite container, - final Composite parent) { + private AddOutputDataPanel createAndSetupOutputDataPanel( + Composite container, final Composite parent) { AddOutputDataPanel addOutputDataPanel = - new AddOutputDataPanel(container, SWT.BORDER); + new AddOutputDataPanel(container, SWT.NONE); addOutputDataPanel.setLayoutData(createPanelLayoutData()); return addOutputDataPanel; 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-06 22:02:26 UTC (rev 917) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pages/SpecifyTemplateStringPage.java 2009-08-13 18:42:24 UTC (rev 918) @@ -8,6 +8,14 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; +/* + * This page provides algorithm creators with a list of possible "placeholders" + * that can be used in the template string. + * The template string is the string used when invoking the static executable + * on the command line. As such, it specifies all program arguments. + * The placeholders possible are the input data items and algorithm parameters + * that the algorithm creator specified. + */ public class SpecifyTemplateStringPage extends WizardPage { private SpecifyTemplateStringPanel specifyTemplateStringPanel; private InputParameterProvider inputParameterProvider; Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/InputDataItem.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/InputDataItem.java 2009-08-06 22:02:26 UTC (rev 917) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/InputDataItem.java 2009-08-13 18:42:24 UTC (rev 918) @@ -1,5 +1,11 @@ package org.cishell.templates.wizards.staticexecutable; +/* + * For static executable algorithms, input data items are always files, and + * they are always referred to by an index (as opposed to an ID). + * Thus, input data items only contain mime types and a position, and the + * position is determined by the delegate. + */ public class InputDataItem { String mimeType; Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/InputDataItemEditor.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/InputDataItemEditor.java 2009-08-06 22:02:26 UTC (rev 917) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/InputDataItemEditor.java 2009-08-13 18:42:24 UTC (rev 918) @@ -10,6 +10,10 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; +/* + * This editor provides the user with an interface to edit input data items + * (InputDataItem). + */ public class InputDataItemEditor extends Dialog { private Text mimeTypeText; private InputDataItem inputDataItem; 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-06 22:02:26 UTC (rev 917) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/NewStaticExecutableAlgorithmTemplate.java 2009-08-13 18:42:24 UTC (rev 918) @@ -13,8 +13,6 @@ * ***************************************************************************/ package org.cishell.templates.wizards.staticexecutable; -import java.io.BufferedWriter; -import java.io.FileWriter; import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -23,6 +21,7 @@ import org.cishell.templates.staticexecutable.providers.PlatformOptionProvider; import org.cishell.templates.wizards.BasicTemplate; import org.cishell.templates.wizards.pages.ChooseExecutableFilesPage; +import org.cishell.templates.wizards.pages.ChooseSourceCodeFilesPage; import org.cishell.templates.wizards.pages.ParameterListBuilderPage; import org.cishell.templates.wizards.pages.SpecifyInAndOutDataPage; import org.cishell.templates.wizards.pages.SpecifyTemplateStringPage; @@ -57,6 +56,8 @@ "specifyInAndOutDataPage"; public static final String SPECIFY_TEMPLATE_STRING_PAGE_ID = "specifyTemplateStringPage"; + public static final String CHOOSE_SOURCE_CODE_FILES_PAGE_ID = + "chooseSoureCodeFilesPage"; public static final String BUNDLE_NAME_ID = "bundleName"; public static final String BUNDLE_NAME_LABEL = "Bundle Name"; @@ -171,6 +172,10 @@ public static final String TEMPLATE_STRING_LABEL = ""; public static final String DEFAULT_TEMPLATE_STRING = ""; + public static final String CHOOSE_SOURCE_CODE_FILES_ID = "sourceCodeFiles"; + public static final String CHOOSE_SOURCE_CODE_FILES_LABEL = + "Choose an archive file that contains your source code files"; + public static final String[][] GROUP_CHOICES = new String[][] { { MENU_START_LABEL, MENU_START_DESCRIPTION }, { MENU_ADDITIONS_LABEL, MENU_ADDITIONS_DESCRIPTION }, @@ -178,19 +183,20 @@ }; private WizardNewProjectCreationPage createProjectPage; + private WizardPage bundlePropertiesPage; private ChooseExecutableFilesPage chooseExecutableFilesPage; - private WizardPage bundlePropertiesPage; private WizardPage projectPropertiesPage; private ParameterListBuilderPage projectParametersPage; private SpecifyInAndOutDataPage inputAndOutputDataPage; private SpecifyTemplateStringPage specifyTemplateStringPage; - private WizardPage sourceCodeFilesPage; + private ChooseSourceCodeFilesPage sourceCodeFilesPage; private TemplateOption executableNameOption; private Map platformExecutableOptions = new HashMap(); private MultiHashMapWithCounts relatedFileOptions = new MultiHashMapWithCounts(); private TemplateOption templateStringOption; + private TemplateOption sourceCodeFilesOption; public NewStaticExecutableAlgorithmTemplate() { super("static_executable"); @@ -207,19 +213,47 @@ setupSourceCodeFilesPage(); } + public TemplateOption getSourceCodeFilesTemplateOption() { + return this.sourceCodeFilesOption; + } + public void addPages(Wizard wizard) { - wizard.addPage(createCreateProjectPage()); - createBundlePropertiesPage(wizard); - createChooseExecutableFilesPage(wizard); - createProjectPropertiesPage(wizard); - createProjectParametersPage(wizard); - createInputAndOutputDataPage(wizard); - createTemplateStringPage(wizard); - createSourceCodeFilesPage(wizard); + this.createProjectPage = createCreateProjectPage(); + wizard.addPage(this.createProjectPage); + this.bundlePropertiesPage = createBundlePropertiesPage(); + wizard.addPage(this.bundlePropertiesPage); + + this.chooseExecutableFilesPage = createChooseExecutableFilesPage(); + wizard.addPage(this.chooseExecutableFilesPage); + + this.projectPropertiesPage = createProjectPropertiesPage(); + wizard.addPage(this.projectPropertiesPage); + + this.projectParametersPage = createProjectParametersPage(); + wizard.addPage(this.projectParametersPage); + + this.inputAndOutputDataPage = createInputAndOutputDataPage(); + wizard.addPage(this.inputAndOutputDataPage); + + this.specifyTemplateStringPage = createTemplateStringPage(); + wizard.addPage(this.specifyTemplateStringPage); + + this.sourceCodeFilesPage = createSourceCodeFilesPage(); + wizard.addPage(this.sourceCodeFilesPage); + markPagesAdded(); } + /* + * execute is basically called when the user clicks the Finish button in + * the wizard. This is where all of the template options should be + * processed and/or created. + * Template options are basically key/value string pairs. If a template + * option's key is found in the project template files (in the + * templates_3.0 directory), it is replaced with the template option's + * value. + */ public void execute(IProject project, IPluginModelBase model, IProgressMonitor monitor) throws CoreException { @@ -229,6 +263,7 @@ // Project Properties Page + // See comments on handleEmptyOption. handleEmptyOption(ON_MENU_ID, IS_ON_MENU_ID, Boolean.TRUE); handleEmptyOption(LABEL_ID, HAS_LABEL_ID, ""); handleEmptyOption(DESCRIPTION_ID, HAS_DESCRIPTION_ID, ""); @@ -264,7 +299,12 @@ this.projectParametersPage.toOutputString()); // In and Out Data Page - try{ + + /* + * These options are not tied directly to input fields on any of the + * pages. Their values are derviced from the input fields that ARE on + * the pages. + */ addOption(IN_DATA_ID, "", this.inputAndOutputDataPage. @@ -284,17 +324,7 @@ this.inputAndOutputDataPage. formConfigPropertiesOutFilesString(), SPECIFY_INPUT_AND_OUTPUT_DATA_PAGE_NUMBER); - } - catch (Exception e1) { - try { - FileWriter fstream = new FileWriter("C:/Documents and Settings/pataphil/Desktop/out.txt", true); - BufferedWriter out = new BufferedWriter(fstream); - out.write("exception: \'" + e1.toString() + "\'\n"); - out.close(); - } catch (Exception e) { - System.err.println("Error: " + e.getMessage()); - } - } + super.execute(project, model, monitor); } @@ -326,81 +356,93 @@ return createProjectPage.getProjectHandle(); } - private WizardPage createCreateProjectPage() { - this.createProjectPage = + private WizardNewProjectCreationPage createCreateProjectPage() { + WizardNewProjectCreationPage createProjectPage = new WizardNewProjectCreationPage(CREATE_PROJECT_PAGE_ID); - this.createProjectPage.setTitle( + createProjectPage.setTitle( "Create a New Static Executable Project"); - this.createProjectPage.setDescription("Enter the project name"); + createProjectPage.setDescription("Enter the project name"); return createProjectPage; } - private void createBundlePropertiesPage(Wizard wizard) { - this.bundlePropertiesPage = + private WizardPage createBundlePropertiesPage() { + WizardPage bundlePropertiesPage = createPage(PROJECT_BUNDLE_PROPERTIES_PAGE_NUMBER); - this.bundlePropertiesPage.setTitle("Bundle Properties"); - this.bundlePropertiesPage.setDescription( + bundlePropertiesPage.setTitle("Bundle Properties"); + bundlePropertiesPage.setDescription( "Enter the bundle name, and bundle version"); - wizard.addPage(this.bundlePropertiesPage); + + return bundlePropertiesPage; } - private void createChooseExecutableFilesPage(Wizard wizard) { - this.chooseExecutableFilesPage = new ChooseExecutableFilesPage( - CHOOSE_EXECUTABLE_FILES_PAGE_ID, this.executableNameOption, this); - this.chooseExecutableFilesPage.setTitle("Choose Executable Files"); - this.chooseExecutableFilesPage.setDescription( + private ChooseExecutableFilesPage createChooseExecutableFilesPage() { + ChooseExecutableFilesPage chooseExecutableFilesPage = + new ChooseExecutableFilesPage(CHOOSE_EXECUTABLE_FILES_PAGE_ID, + this.executableNameOption, + this); + chooseExecutableFilesPage.setTitle("Choose Executable Files"); + chooseExecutableFilesPage.setDescription( "Choose the executable files and any files they depend on"); - wizard.addPage(this.chooseExecutableFilesPage); + + return chooseExecutableFilesPage; } - private void createProjectPropertiesPage(Wizard wizard) { - this.projectPropertiesPage = + private WizardPage createProjectPropertiesPage() { + WizardPage projectPropertiesPage = createPage(PROJECT_PROPERTIES_PAGE_NUMBER); - this.projectPropertiesPage.setTitle("Project Properties"); - this.projectPropertiesPage.setDescription("Enter project properties"); - wizard.addPage(this.projectPropertiesPage); + projectPropertiesPage.setTitle("Project Properties"); + projectPropertiesPage.setDescription("Enter project properties"); + + return projectPropertiesPage; } - private void createProjectParametersPage(Wizard wizard) { - this.projectParametersPage = + private ParameterListBuilderPage createProjectParametersPage() { + ParameterListBuilderPage projectParametersPage = new ParameterListBuilderPage(SETUP_PARAMETERS_PAGE_ID); - this.projectParametersPage.setTitle("Project Parameters"); - this.projectParametersPage.setDescription("Enter project parameters"); - wizard.addPage(this.projectParametersPage); + projectParametersPage.setTitle("Project Parameters"); + projectParametersPage.setDescription("Enter project parameters"); + + return projectParametersPage; } - private void createInputAndOutputDataPage(Wizard wizard) { - this.inputAndOutputDataPage = + private SpecifyInAndOutDataPage createInputAndOutputDataPage() { + SpecifyInAndOutDataPage inputAndOutputDataPage = new SpecifyInAndOutDataPage(SPECIFY_IN_AND_OUT_DATA_PAGE_ID); - this.inputAndOutputDataPage.setTitle("Input and Output Data"); - this.inputAndOutputDataPage.setDescription( + inputAndOutputDataPage.setTitle("Input and Output Data"); + inputAndOutputDataPage.setDescription( "Enter the input and output data"); - wizard.addPage(this.inputAndOutputDataPage); + + return inputAndOutputDataPage; } - private void createTemplateStringPage(Wizard wizard) { - this.specifyTemplateStringPage = new SpecifyTemplateStringPage( - SPECIFY_TEMPLATE_STRING_PAGE_ID, - projectParametersPage, - inputAndOutputDataPage, - this.templateStringOption); - this.specifyTemplateStringPage.setTitle("Template String"); - this.specifyTemplateStringPage.setDescription( + private SpecifyTemplateStringPage createTemplateStringPage() { + SpecifyTemplateStringPage specifyTemplateStringPage = + new SpecifyTemplateStringPage( + SPECIFY_TEMPLATE_STRING_PAGE_ID, + projectParametersPage, + inputAndOutputDataPage, + this.templateStringOption); + specifyTemplateStringPage.setTitle("Template String"); + specifyTemplateStringPage.setDescription( "Enter the template string used to execute your program"); - wizard.addPage(this.specifyTemplateStringPage); + + return specifyTemplateStringPage; } - private void createSourceCodeFilesPage(Wizard wizard) { - this.sourceCodeFilesPage = createPage(SOURCE_CODE_FILES_PAGE_NUMBER); - this.sourceCodeFilesPage.setTitle("Source Code Files (Optional)"); - this.sourceCodeFilesPage.setDescription( + private ChooseSourceCodeFilesPage createSourceCodeFilesPage() { + ChooseSourceCodeFilesPage sourceCodeFilesPage = + new ChooseSourceCodeFilesPage( + CHOOSE_SOURCE_CODE_FILES_PAGE_ID, + this.sourceCodeFilesOption); + sourceCodeFilesPage.setTitle("Source Code Files (Optional)"); + sourceCodeFilesPage.setDescription( "Enter the source code files for your program"); - wizard.addPage(this.sourceCodeFilesPage); + + return sourceCodeFilesPage; } - private void setupCreateProjectPage() { - } + private void setupCreateProjectPage() { } private void setupBundlePropertiesPage() { addOption(BUNDLE_NAME_ID, @@ -491,11 +533,9 @@ PROJECT_PROPERTIES_PAGE_NUMBER).setRequired(true); } - private void setupProjectParametersPage() { - } + private void setupProjectParametersPage() { } - private void setupInputAndOutputDataPage() { - } + private void setupInputAndOutputDataPage() { } private void setupTemplateStringPage() { this.templateStringOption = addOption( @@ -507,8 +547,29 @@ } private void setupSourceCodeFilesPage() { + this.sourceCodeFilesOption = addOption( + CHOOSE_SOURCE_CODE_FILES_ID, + CHOOSE_SOURCE_CODE_FILES_LABEL + ":", + "", + SOURCE_CODE_FILES_PAGE_NUMBER); + this.sourceCodeFilesOption.setRequired(false); } + /* + * As far as I know, there are no conditionals in the templating langauge + * used when processing the new project templates (in the templates_3.0 + * directory). + * To avoid having empty values in the properties files, the templates must + * be setup to comment out key/value lines in case the values are empty. + * What handleEmptyOption does is check if the value of the option optionID + * is NOT equal to compareTo, and if so, it sets the "comment-out" + * template option isEmptyOptionID to have the value "#", which will + * comment out the line if it's placed accordingly in the template. + * For example, if there were the line + * $isOptionEmpty$key=$value$ + * the template option isOptionEmpty would be set to "#" if the template + * option value is empty. + */ private void handleEmptyOption( String optionID, String isEmptyOptionID, String compareTo) { if (getOption(optionID).getValue() == null || @@ -592,9 +653,15 @@ relatedFileOption.getPlatformName(), relatedFileOption); } - public void removeRelatedFileOption(PlatformOption relatedFileOption) { - this.relatedFileOptions.removeValue( - relatedFileOption.getPlatformName(), relatedFileOption); + public void removeRelatedFileOption(TemplateOption relatedFileOption) { + if (relatedFileOption instanceof PlatformOption) { + PlatformOption relatedFilePlatformOption = + (PlatformOption)relatedFileOption; + + this.relatedFileOptions.removeValue( + relatedFilePlatformOption.getPlatformName(), + relatedFilePlatformOption); + } } public PlatformOption createRelatedFileOption(String platformName, 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-06 22:02:26 UTC (rev 917) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/NewStaticExecutableAlgorithmWizard.java 2009-08-13 18:42:24 UTC (rev 918) @@ -35,6 +35,7 @@ import org.eclipse.pde.internal.core.bundle.BundlePluginModelBase; import org.eclipse.pde.ui.templates.ITemplateSection; import org.eclipse.pde.ui.templates.NewPluginTemplateWizard; +import org.eclipse.pde.ui.templates.TemplateOption; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.MessageBox; @@ -53,7 +54,6 @@ public class NewStaticExecutableAlgorithmWizard extends NewPluginTemplateWizard implements IWorkbenchWizard { - // TODO: Different label string? public static final String DEFAULT_LABEL = "Common to All"; public static final String DEFAULT_PATH = "/default/"; @@ -75,25 +75,24 @@ public static final String WIN_32_LABEL = "Windows (32 bit)"; public static final String WIN_32_PATH = "/win32/"; - // TODO: This should be improved. public static final String[] PLATFORM_LABELS = new String[] { DEFAULT_LABEL, + WIN_32_LABEL, + MAC_OSX_X86_LABEL, + MAC_OSX_PPC_LABEL, LINUX_X86_32_LABEL, LINUX_X86_64_LABEL, - MAC_OSX_PPC_LABEL, - MAC_OSX_X86_LABEL, - SOLARIS_SPARC_LABEL, - WIN_32_LABEL + SOLARIS_SPARC_LABEL }; public static final String[] PLATFORM_PATHS = new String[] { DEFAULT_PATH, + WIN_32_PATH, + MAC_OSX_X86_PATH, + MAC_OSX_PPC_PATH, LINUX_X86_32_PATH, LINUX_X86_64_PATH, - MAC_OSX_PPC_PATH, - MAC_OSX_X86_PATH, - SOLARIS_SPARC_PATH, - WIN_32_PATH + SOLARIS_SPARC_PATH }; NewStaticExecutableAlgorithmTemplate template; @@ -148,7 +147,7 @@ PlatformOption executableFileOption = template.getExecutableFileOption( PLATFORM_LABELS[ii]); - copyPlatformOptionFile( + copyTemplateOptionFile( executableFileOption, directoryPath, project); } @@ -156,11 +155,18 @@ template.getRelatedFileOptions(PLATFORM_LABELS[ii]); for (int jj = 0; jj < relatedFileOptions.length; jj++) { - copyPlatformOptionFile( + copyTemplateOptionFile( relatedFileOptions[jj], directoryPath, project); } } + String sourceCodeDirectoryPath = "src/"; + TemplateOption sourceCodeFilesTemplateOption = + template.getSourceCodeFilesTemplateOption(); + copyTemplateOptionFile(sourceCodeFilesTemplateOption, + sourceCodeDirectoryPath, + project); + monitor.done(); } }; @@ -204,11 +210,11 @@ } - private void copyPlatformOptionFile(PlatformOption platformOption, + private void copyTemplateOptionFile(TemplateOption templateOption, String directoryPath, IProject project) throws CoreException { - String sourceFilePath = platformOption.getText(); + String sourceFilePath = templateOption.getValue().toString(); if (sourceFilePath == null || "".equals(sourceFilePath)) { return; Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/OutputDataItem.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/OutputDataItem.java 2009-08-06 22:02:26 UTC (rev 917) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/OutputDataItem.java 2009-08-13 18:42:24 UTC (rev 918) @@ -1,5 +1,17 @@ package org.cishell.templates.wizards.staticexecutable; +/* + * For static executable algorithms, output data items are always files. It is + * up to the algorithm creators to make the names the output files their + * programs create and the names specified in the static executable algorithm + * match up, so CIShell can find the files. + * Labels can be specified for the output files. + * Output files for static executable algorithms also contain data types, which + * determine the icon CIShell uses for the associated data item in the Data + * Manager. + * Example data types are Network and Plot. + * Output files must also specify appropriate mime types. + */ public class OutputDataItem { private String fileName = ""; private String label = ""; Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/OutputDataItemEditor.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/OutputDataItemEditor.java 2009-08-06 22:02:26 UTC (rev 917) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/OutputDataItemEditor.java 2009-08-13 18:42:24 UTC (rev 918) @@ -11,7 +11,6 @@ import org.eclipse.swt.widgets.Text; public class OutputDataItemEditor extends Dialog { - private Text idText; private Text fileNameText; private Text labelText; private Text dataTypeText; Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/StaticExecutableInputDataDelegate.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/StaticExecutableInputDataDelegate.java 2009-08-06 22:02:26 UTC (rev 917) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/StaticExecutableInputDataDelegate.java 2009-08-13 18:42:24 UTC (rev 918) @@ -47,7 +47,7 @@ idToInputDataItemMap.put("" + this.lastID, inputDataItem); String[] item = new String[] { - "" + this.lastID, + Integer.toString(this.lastID), inputDataItem.getMimeType() }; Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/StaticExecutableOutputDataDelegate.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/StaticExecutableOutputDataDelegate.java 2009-08-06 22:02:26 UTC (rev 917) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/StaticExecutableOutputDataDelegate.java 2009-08-13 18:42:24 UTC (rev 918) @@ -53,7 +53,8 @@ boolean success = editOutputDataItem(outputDataItem); if (success) { - idToOutputDataItemMap.put("" + this.lastID, outputDataItem); + idToOutputDataItemMap.put(Integer.toString(this.lastID), + outputDataItem); String[] item = new String[] { "" + this.lastID, 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-06 22:02:26 UTC (rev 917) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/widgets/ChooseExecutableFileWidget.java 2009-08-13 18:42:24 UTC (rev 918) @@ -9,6 +9,10 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Layout; +/* + * This widget allows the user to choose one file, which is intended to be the + * executable file for the provided platform (name and path). + */ public class ChooseExecutableFileWidget extends Composite { public static final String CHOOSE_EXECUTABLE_FILE_LABEL = "Choose Executable File"; 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-06 22:02:26 UTC (rev 917) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/widgets/ChooseFileWidget.java 2009-08-13 18:42:24 UTC (rev 918) @@ -1,6 +1,6 @@ package org.cishell.templates.wizards.widgets; -import org.cishell.templates.staticexecutable.providers.PlatformOption; +import org.eclipse.pde.ui.templates.TemplateOption; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; @@ -13,6 +13,14 @@ 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. + * It ties the chosen file's path to a provided TemplateOption so the chosen + * files can be processed upon the wizard's completion. + * This widget can optionally call back upon it being filled or its Remove + * button being selected to allow its parent component handle any appropriate + * actions. + */ 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?"; @@ -24,14 +32,15 @@ private Text filePathText; private Button browseFilesButton; + // TODO: Make these listeners of an interface. private ChooseRelatedFilesWidget fileChosenListener; private ChooseRelatedFilesWidget removeElementListener; - private PlatformOption platformOption; + private TemplateOption platformOption; public ChooseFileWidget(Composite parent, int style, int parentParentWidth, - PlatformOption stringOption) { + TemplateOption stringOption) { this(parent, style, true, parentParentWidth, stringOption); } @@ -39,7 +48,7 @@ int style, boolean hasRemoveButton, int parentParentWidth, - PlatformOption platformOption) { + TemplateOption platformOption) { super(parent, style); this.platformOption = platformOption; @@ -49,24 +58,20 @@ Composite container = createContainer(hasRemoveButton, parentParentWidth); this.platformOption.createControl(container, 2); -// this.filePathText = createFilePathText(); this.browseFilesButton = createBrowseFilesButton(); createRemoveElement(hasRemoveButton); - - // fixFilePathTextWidth(widthForFilePathText); } - public PlatformOption getPlatformOption() { + public TemplateOption getPlatformOption() { return this.platformOption; } public String getFilePath() { - return this.platformOption.getText(); - // return this.filePathText.getText(); + return this.platformOption.getValue().toString(); } public void setFilePath(String filePath) { - this.platformOption.setText(filePath); + this.platformOption.setValue(filePath); } public void widgetDefaultSelected(SelectionEvent selectionEvent) { @@ -133,13 +138,6 @@ return container; } - private Text createFilePathText() { - Text filePathText = new Text(this, SWT.BORDER); - filePathText.setEditable(true); - - return filePathText; - } - private Button createBrowseFilesButton() { Button browseFilesButton = new Button(this, SWT.PUSH); browseFilesButton.setLayoutData(createBrowseFilesButtonLayoutData()); @@ -163,11 +161,6 @@ } } - private void fixFilePathTextWidth(int widthForFilePathText) { - this.filePathText.setLayoutData( - createFilePathTextLayoutData(widthForFilePathText)); - } - private void browseButtonSelected(SelectionEvent selectionEvent) { FileDialog fileDialog = new FileDialog(getShell(), SWT.NULL); fileDialog.setFileName(getFilePath()); 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-06 22:02:26 UTC (rev 917) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/widgets/ChooseRelatedFilesWidget.java 2009-08-13 18:42:24 UTC (rev 918) @@ -11,6 +11,15 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Layout; +/* + * This widget the user to choose and remove one or more files related to the + * executable file for the provided platform (name and path). + * As soon as the last file selector is filled with a file path, this widget + * provides an additional file selector for the user to continue providing + * additional related files. + * All related file selectors besides the first one can be removed in this + * widget. + */ public class ChooseRelatedFilesWidget extends ResizeCompositeHackWidget { public static final String CHOOSE_RELATED_FILES_LABEL_TEXT = "Choose Related Files"; @@ -45,7 +54,6 @@ this.firstFileSelector = createAndSetupFileSelector(false); } - // TODO: How to get the file paths out? public ChooseFileWidget getFirstFileSelector() { return this.firstFileSelector; } Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/widgets/PlatformSetupHeaderWidget.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/widgets/PlatformSetupHeaderWidget.java 2009-08-06 22:02:26 UTC (rev 917) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/widgets/PlatformSetupHeaderWidget.java 2009-08-13 18:42:24 UTC (rev 918) @@ -9,6 +9,10 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; +/* + * This widget contains any appropriate header widgets for a + * PlatformSetupWidget. + */ public class PlatformSetupHeaderWidget extends Composite { public static final String PLATFORM_LABEL = "Platform"; Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/widgets/PlatformSetupWidget.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/widgets/PlatformSetupWidget.java 2009-08-06 22:02:26 UTC (rev 917) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/widgets/PlatformSetupWidget.java 2009-08-13 18:42:24 UTC (rev 918) @@ -7,6 +7,15 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Layout; +/* + * This widget contains a header, which is a PlatformSetupHeaderWidget object, + * and it is associated with an operating system platform via its platformName + * and platformPath member variables. + * There is also optionally a widget for choosing an executable file for the + * associated platform, which is of type ChooseExecutableFileWidget. + * There is always a widget for choosing and removing one or more related + * files, which is of the type ChooseRelatedFilesWidget. + */ public class PlatformSetupWidget extends ResizeCompositeHackWidget { public static final int WIDGET_WIDTH = 454; public static final int WIDGET_HEIGHT = 317; @@ -101,8 +110,6 @@ GridData data = new GridData(); data.horizontalSpan = 2; data.grabExcessHorizontalSpace = true; -// data.horizontalAlignment = SWT.CENTER; -// data.verticalAlignment = SWT.CENTER; return data; } @@ -125,13 +132,11 @@ data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.FILL; - // data.widthHint = WIDGET_WIDTH; data.grabExcessHorizontalSpace = true; data.grabExcessVerticalSpace = true; if (!shouldSpanEntireWidth) { data.horizontalAlignment = GridData.FILL; - // data.widthHint = WIDGET_WIDTH; data.grabExcessHorizontalSpace = true; data.horizontalSpan = 2; } else { Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/widgets/ResizeCompositeHackWidget.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/widgets/ResizeCompositeHackWidget.java 2009-08-06 22:02:26 UTC (rev 917) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/widgets/ResizeCompositeHackWidget.java 2009-08-13 18:42:24 UTC (rev 918) @@ -5,6 +5,12 @@ import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Composite; +/* + * This "widget" ensures that both it and its parent component get resized + * appropriate when its size is set. + * It handles the case where its parent component is a ScrolledComposite, so + * scrolling happens properly. + */ public class ResizeCompositeHackWidget extends Composite { public ResizeCompositeHackWidget(Composite parent, int style) { super(parent, style); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jrb...@us...> - 2009-08-06 22:02:38
|
Revision: 917 http://cishell.svn.sourceforge.net/cishell/?rev=917&view=rev Author: jrbibers Date: 2009-08-06 22:02:26 +0000 (Thu, 06 Aug 2009) Log Message: ----------- Added CollectionUtilities to CIShell utilities. Initial commit includes only a method which filters a Collection according to a Dictionary into Boolean values. Added Paths: ----------- trunk/core/org.cishell.utilities/src/org/cishell/utilities/CollectionUtilities.java Added: trunk/core/org.cishell.utilities/src/org/cishell/utilities/CollectionUtilities.java =================================================================== --- trunk/core/org.cishell.utilities/src/org/cishell/utilities/CollectionUtilities.java (rev 0) +++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/CollectionUtilities.java 2009-08-06 22:02:26 UTC (rev 917) @@ -0,0 +1,31 @@ +package org.cishell.utilities; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Dictionary; +import java.util.Iterator; + +public class CollectionUtilities { + + /* Return only elements of the Collection which are mapped to true in the + * Dictionary + */ + public static Collection grabSelectedValues( + Collection elements, Dictionary selectionDictionary) { + Collection selectedElements = new ArrayList(); + + for (Iterator elementsIt = elements.iterator(); elementsIt.hasNext();) { + String element = (String) elementsIt.next(); + Object isSelected = selectionDictionary.get(element); + + if ((isSelected != null) && (isSelected instanceof Boolean)) { + if (((Boolean) isSelected).booleanValue()) { + selectedElements.add(element); + } + } + } + + return selectedElements; + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pat...@us...> - 2009-08-06 16:27:00
|
Revision: 916 http://cishell.svn.sourceforge.net/cishell/?rev=916&view=rev Author: pataphil Date: 2009-08-06 16:26:46 +0000 (Thu, 06 Aug 2009) Log Message: ----------- * Fixed some bugs. * STILL NOT REVIEWED. Modified Paths: -------------- 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/staticexecutable/NewStaticExecutableAlgorithmTemplate.java trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/ALGORITHM/service.properties trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/build.xml trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/gui.xml 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-06 15:12:31 UTC (rev 915) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/SpecifyTemplateStringPanel.java 2009-08-06 16:26:46 UTC (rev 916) @@ -65,7 +65,7 @@ " (" + inputParameters[ii].getDescription() + ")"; - String value = "\"${" + inputParameters[ii].getName() + "}\""; + String value = "\"${" + inputParameters[ii].getID() + "}\""; addTableItem(label, value); } 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-06 15:12:31 UTC (rev 915) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/NewStaticExecutableAlgorithmTemplate.java 2009-08-06 16:26:46 UTC (rev 916) @@ -85,6 +85,7 @@ public static final String MENU_PATH_ID = "menuPath"; public static final String MENU_PATH_LABEL = "Menu Path (Optional)"; public static final String DEFAULT_MENU_PATH = "menu_path"; + public static final String FULL_MENU_PATH = "fullMenuPath"; public static final String MENU_GROUP_ID = "menuGroup"; public static final String MENU_GROUP_LABEL = "Menu Item Placement"; @@ -142,6 +143,9 @@ public static final String IN_DATA_ID = "inData"; public static final String HAS_IN_DATA_ID = "hasInData"; + public static final String ATTRIBUTE_DEFINITIONS_ID = + "attributeDefinitions"; + public static final String OUT_DATA_ID = "outData"; public static final String HAS_OUT_DATA_ID = "hasOutData"; public static final String OUT_FILES_ID = "outFiles"; @@ -235,9 +239,28 @@ handleEmptyOption(DOCUMENTATION_URL_ID, HAS_DOCUMENTATION_URL_ID, ""); handleEmptyOption(WRITTEN_IN_ID, HAS_WRITTEN_IN_ID, ""); + String menuPath = (String)getValue(MENU_PATH_ID); + if (!menuPath.endsWith("/")) { + menuPath += "/"; + } + + String choice = (String)getOption(MENU_GROUP_ID).getValue(); + + for (int ii = 0; ii < GROUP_CHOICES.length; ii++) { + if (GROUP_CHOICES[ii][1].equals(choice) || + GROUP_CHOICES[ii][0].equals(choice)) { + menuPath += GROUP_CHOICES[ii][0]; + + break; + } + + } + + setValue(FULL_MENU_PATH, menuPath); + // Project Parameters Page - setValue("attributeDefinitions", + setValue(ATTRIBUTE_DEFINITIONS_ID, this.projectParametersPage.toOutputString()); // In and Out Data Page Modified: trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/ALGORITHM/service.properties =================================================================== --- trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/ALGORITHM/service.properties 2009-08-06 15:12:31 UTC (rev 915) +++ trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/ALGORITHM/service.properties 2009-08-06 16:26:46 UTC (rev 916) @@ -1,7 +1,7 @@ service.pid=$bundleSymbolicName$ $hasInData$in_data=$inData$ $hasOutData$out_data=$outData$ -$isOnMenu$menu_path=$menuPath$ +$isOnMenu$menu_path=$fullMenuPath$ $hasLabel$label=$label$ $hasDescription$description=$description$ $hasImplementers$implementers=$implementers$ Modified: trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/build.xml =================================================================== --- trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/build.xml 2009-08-06 15:12:31 UTC (rev 915) +++ trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/build.xml 2009-08-06 16:26:46 UTC (rev 916) @@ -1,56 +1,55 @@ -<!-- This file in almost all cases will not need edited --> -<project name="Static Executable Integration Template" basedir="." default="compile"> - <property file="manifest.properties"/> - - <property name="repository.dir" value="${basedir}"/> - <property name="build.dir" value="${repository.dir}/build"/> - <property name="lib.dir" value="${repository.dir}/lib"/> - <property name="out.dir" value="${build.dir}/out"/> - <property name="global.properties" value="${repository.dir}/manifest.properties"/> - <property name="gui.file" value="${repository.dir}/gui.xml"/> - <property name="dest.gui.file" value="${out.dir}/OSGI-INF/metatype/METADATA.XML"/> - <property name="l10n.dir" value="${repository.dir}/l10n" /> - <property name="dest.l10n.dir" value="${out.dir}/OSGI-INF/l10n"/> - <property name="template.file" value="${lib.dir}/component.xml"/> - - <target name="compile" depends="copy.files" - description="Compile an OSGi Bundle of the Static Executable"> - - <createManifest basedir="${out.dir}" - baseproperties="${global.properties}" - template="${template.file}"/> - - <copy file="${gui.file}" tofile="${dest.gui.file}" failonerror="false"/> - - <copy todir="${dest.l10n.dir}"> - <fileset dir="${l10n.dir}"/> - </copy> - - <jar destfile="${build.dir}/${Bundle-SymbolicName}_${Bundle-Version}.jar" - basedir="${out.dir}" manifest="${out.dir}/META-INF/MANIFEST.MF"/> - </target> - - <target name="copy.files" description="Copying files" depends="tasks.init"> - <copy todir="${out.dir}"> - <fileset dir="${repository.dir}"> - <include name="**/*"/> - <exclude name="${lib.dir},${build.dir},${l10n.dir}"/> - <exclude name="l10n/**/*"/> - <exclude name="build/**/*"/> - <exclude name="lib/**/*"/> - <exclude name="src/**/*"/> - <exclude name="*"/> - </fileset> - </copy> - </target> - - <target name="tasks.init" description="Initialize TaskDefinitions"> - <taskdef name="createManifest" - classname="org.cishell.templates.staticexecutable.StaticExecutableIntegrationTask" - classpath="${lib.dir}/cishell_templates.jar"/> - </target> - - <target name="clean" description="Clean build directory"> - <delete dir="${build.dir}"/> - </target> +<!-- This file in almost all cases will not need edited --> +<project name="Static Executable Integration Template" basedir="." default="compile"> + <property file="manifest.properties"/> + + <property name="repository.dir" value="${basedir}"/> + <property name="build.dir" value="${repository.dir}/build"/> + <property name="lib.dir" value="${repository.dir}/lib"/> + <property name="out.dir" value="${build.dir}/out"/> + <property name="global.properties" value="${repository.dir}/manifest.properties"/> + <property name="gui.file" value="${repository.dir}/gui.xml"/> + <property name="dest.gui.file" value="${out.dir}/OSGI-INF/metatype/METADATA.XML"/> + <property name="l10n.dir" value="${repository.dir}/l10n" /> + <property name="dest.l10n.dir" value="${out.dir}/OSGI-INF/l10n"/> + <property name="template.file" value="${lib.dir}/component.xml"/> + + <target name="compile" depends="copy.files" + description="Compile an OSGi Bundle of the Static Executable"> + + <createManifest basedir="${out.dir}" + baseproperties="${global.properties}" + template="${template.file}"/> + + <copy file="${gui.file}" tofile="${dest.gui.file}" failonerror="false"/> + + <copy todir="${dest.l10n.dir}"> + <fileset dir="${l10n.dir}"/> + </copy> + + <jar destfile="${build.dir}/${Bundle-SymbolicName}_${Bundle-Version}.jar" + basedir="${out.dir}" manifest="${out.dir}/META-INF/MANIFEST.MF"/> + </target> + + <target name="copy.files" description="Copying files" depends="tasks.init"> + <copy todir="${out.dir}"> + <fileset dir="${repository.dir}"> + <include name="**/*"/> + <exclude name="${lib.dir},${build.dir},${l10n.dir}"/> + <exclude name="l10n/**/*"/> + <exclude name="build/**/*"/> + <exclude name="lib/**/*"/> + <exclude name="*"/> + </fileset> + </copy> + </target> + + <target name="tasks.init" description="Initialize TaskDefinitions"> + <taskdef name="createManifest" + classname="org.cishell.templates.staticexecutable.StaticExecutableIntegrationTask" + classpath="${lib.dir}/cishell_templates.jar"/> + </target> + + <target name="clean" description="Clean build directory"> + <delete dir="${build.dir}"/> + </target> </project> \ No newline at end of file Modified: trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/gui.xml =================================================================== --- trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/gui.xml 2009-08-06 15:12:31 UTC (rev 915) +++ trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/gui.xml 2009-08-06 16:26:46 UTC (rev 916) @@ -1,12 +1,10 @@ <?xml version="1.0" encoding="UTF-8"?> <metatype:MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.0.0"> -<!-- SAMPLE - <OCD name="$bundleName$" id="$bundleSymbolicName$.OCD" + <OCD name="$bundleName$" id="$bundleSymbolicName$.gui" description="$description$"> $attributeDefinitions$ </OCD> <Designate pid="$bundleSymbolicName$"> <Object ocdref="$bundleSymbolicName$.gui" /> </Designate> - --> </metatype:MetaData> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pat...@us...> - 2009-08-06 15:12:40
|
Revision: 915 http://cishell.svn.sourceforge.net/cishell/?rev=915&view=rev Author: pataphil Date: 2009-08-06 15:12:31 +0000 (Thu, 06 Aug 2009) Log Message: ----------- * Now outputs all necessary data in the newly-created projects. * Fixed a couple of bugs with the way input/output data was being retrieved. * STILL NOT REVIEWED. Modified Paths: -------------- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/providers/InputDataProvider.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/AddInputDataPanel.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/AddOutputDataPanel.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pages/SpecifyInAndOutDataPage.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/StaticExecutableOutputDataDelegate.java trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/ALGORITHM/config.properties Added Paths: ----------- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/providers/OutputDataProvider.java Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/providers/InputDataProvider.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/providers/InputDataProvider.java 2009-08-06 14:02:35 UTC (rev 914) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/providers/InputDataProvider.java 2009-08-06 15:12:31 UTC (rev 915) @@ -4,4 +4,6 @@ public interface InputDataProvider { public InputDataItem[] getInputDataItems(); + + public String formServicePropertiesInputDataString(); } \ No newline at end of file Added: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/providers/OutputDataProvider.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/providers/OutputDataProvider.java (rev 0) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/providers/OutputDataProvider.java 2009-08-06 15:12:31 UTC (rev 915) @@ -0,0 +1,10 @@ +package org.cishell.templates.staticexecutable.providers; + +import org.cishell.templates.wizards.staticexecutable.OutputDataItem; + +public interface OutputDataProvider { + public OutputDataItem[] getOutputDataItems(); + + public String formServicePropertiesOutputDataString(); + public String formConfigPropertiesOutFilesString(); +} \ No newline at end of file Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/AddInputDataPanel.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/AddInputDataPanel.java 2009-08-06 14:02:35 UTC (rev 914) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/AddInputDataPanel.java 2009-08-06 15:12:31 UTC (rev 915) @@ -3,6 +3,7 @@ import java.util.Map; import org.cishell.templates.guibuilder.BuilderDelegate; +import org.cishell.templates.guibuilder.EditableAttributeDefinition; import org.cishell.templates.guibuilder.ListBuilder; import org.cishell.templates.wizards.staticexecutable.InputDataItem; import org.cishell.templates.wizards.staticexecutable.StaticExecutableInputDataDelegate; @@ -13,6 +14,7 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Layout; import org.eclipse.swt.widgets.TableItem; @@ -44,16 +46,16 @@ } public InputDataItem[] getInputDataItems() { - TableItem[] tableItems = this.listBuilder.getTable().getItems(); - InputDataItem[] inputDataItems = new InputDataItem[tableItems.length]; - Map idToInputDataItemMap = this.delegate.getIDToInputDataItemMap(); - - for (int ii = 0; ii < tableItems.length; ii++) { - inputDataItems[ii] = (InputDataItem) - idToInputDataItemMap.get(tableItems[ii].getText(0)); - } - - return inputDataItems; + Display display = Display.getDefault(); + + if (display != null) { + GetInputDataAction action = new GetInputDataAction(); + display.syncExec(action); + + return action.inputDataItems; + } else { + return new InputDataItem[0]; + } } private Layout createLayoutForThis() { @@ -94,4 +96,19 @@ return new Font(device, newFontData); } + + private class GetInputDataAction implements Runnable { + InputDataItem[] inputDataItems; + + public void run() { + TableItem[] tableItems = listBuilder.getTable().getItems(); + inputDataItems = new InputDataItem[tableItems.length]; + Map idToInputDataItemMap = delegate.getIDToInputDataItemMap(); + + for (int ii = 0; ii < tableItems.length; ii++) { + inputDataItems[ii] = (InputDataItem) + idToInputDataItemMap.get(tableItems[ii].getText(0)); + } + } + } } \ No newline at end of file Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/AddOutputDataPanel.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/AddOutputDataPanel.java 2009-08-06 14:02:35 UTC (rev 914) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/AddOutputDataPanel.java 2009-08-06 15:12:31 UTC (rev 915) @@ -1,7 +1,11 @@ package org.cishell.templates.wizards.pagepanels; +import java.util.Map; + import org.cishell.templates.guibuilder.BuilderDelegate; import org.cishell.templates.guibuilder.ListBuilder; +import org.cishell.templates.wizards.staticexecutable.InputDataItem; +import org.cishell.templates.wizards.staticexecutable.OutputDataItem; import org.cishell.templates.wizards.staticexecutable.StaticExecutableOutputDataDelegate; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Device; @@ -10,14 +14,16 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Layout; +import org.eclipse.swt.widgets.TableItem; public class AddOutputDataPanel extends Composite { public static final String OUTPUT_DATA_LABEL_TEXT = "Output Data"; private ListBuilder listBuilder; - private BuilderDelegate delegate; + private StaticExecutableOutputDataDelegate delegate; public AddOutputDataPanel(Composite parent, int style) { super(parent, style); @@ -40,6 +46,19 @@ return this.delegate; } + public OutputDataItem[] getOutputDataItems() { + Display display = Display.getDefault(); + + if (display != null) { + GetOutputDataAction action = new GetOutputDataAction(); + display.syncExec(action); + + return action.inputDataItems; + } else { + return new OutputDataItem[0]; + } + } + private Layout createLayoutForThis() { GridLayout layout = new GridLayout(6, true); @@ -76,4 +95,19 @@ return new Font(device, newFontData); } + + private class GetOutputDataAction implements Runnable { + OutputDataItem[] inputDataItems; + + public void run() { + TableItem[] tableItems = listBuilder.getTable().getItems(); + inputDataItems = new OutputDataItem[tableItems.length]; + Map idToInputDataItemMap = delegate.getIDToOutputDataItemMap(); + + for (int ii = 0; ii < tableItems.length; ii++) { + inputDataItems[ii] = (OutputDataItem) + idToInputDataItemMap.get(tableItems[ii].getText(0)); + } + } + } } \ No newline at end of file Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pages/SpecifyInAndOutDataPage.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pages/SpecifyInAndOutDataPage.java 2009-08-06 14:02:35 UTC (rev 914) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pages/SpecifyInAndOutDataPage.java 2009-08-06 15:12:31 UTC (rev 915) @@ -1,9 +1,11 @@ package org.cishell.templates.wizards.pages; import org.cishell.templates.staticexecutable.providers.InputDataProvider; +import org.cishell.templates.staticexecutable.providers.OutputDataProvider; import org.cishell.templates.wizards.pagepanels.AddInputDataPanel; import org.cishell.templates.wizards.pagepanels.AddOutputDataPanel; import org.cishell.templates.wizards.staticexecutable.InputDataItem; +import org.cishell.templates.wizards.staticexecutable.OutputDataItem; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; @@ -12,7 +14,7 @@ import org.eclipse.swt.widgets.Layout; public class SpecifyInAndOutDataPage extends WizardPage - implements InputDataProvider { + implements InputDataProvider, OutputDataProvider { private AddInputDataPanel addInputDataPanel; private AddOutputDataPanel addOutputDataPanel; @@ -69,4 +71,72 @@ public InputDataItem[] getInputDataItems() { return this.addInputDataPanel.getInputDataItems(); } + + public String formServicePropertiesInputDataString() { + InputDataItem[] inputDataItems = getInputDataItems(); + + StringBuffer inputDataStringInProgress = new StringBuffer(); + + if (inputDataItems.length != 0) { + inputDataStringInProgress.append( + "file:" + inputDataItems[0].getMimeType()); + + for (int ii = 1; ii < inputDataItems.length; ii++) { + inputDataStringInProgress.append( + ",file:" + inputDataItems[0].getMimeType()); + } + } + + String inputDataString = inputDataStringInProgress.toString(); + + return inputDataString; + } + + public OutputDataItem[] getOutputDataItems() { + return this.addOutputDataPanel.getOutputDataItems(); + } + + public String formServicePropertiesOutputDataString() { + OutputDataItem[] outputDataItems = getOutputDataItems(); + + StringBuffer outputDataStringInProgress = new StringBuffer(); + + if (outputDataItems.length != 0) { + outputDataStringInProgress.append( + "file:" + outputDataItems[0].getMimeType()); + + for (int ii = 1; ii < outputDataItems.length; ii++) { + outputDataStringInProgress.append( + ",file:" + outputDataItems[0].getMimeType()); + } + } + + String outputDataString = outputDataStringInProgress.toString(); + + return outputDataString; + } + + public String formConfigPropertiesOutFilesString() { + OutputDataItem[] outputDataItems = getOutputDataItems(); + + StringBuffer outputFilesStringInProgress = new StringBuffer(); + + for (int ii = 0; ii < outputDataItems.length; ii++) { + String outFileBase = "outFile[" + ii + "]"; + outputFilesStringInProgress.append( + outFileBase + "=" + outputDataItems[ii].getFileName() + "\n"); + outputFilesStringInProgress.append( + outFileBase + ".label=" + + outputDataItems[ii].getLabel() + + "\n"); + outputFilesStringInProgress.append( + outFileBase + ".type=" + + outputDataItems[ii].getDataType() + + "\n"); + } + + String outputDataString = outputFilesStringInProgress.toString(); + + return outputDataString; + } } \ No newline at end of file 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-06 14:02:35 UTC (rev 914) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/NewStaticExecutableAlgorithmTemplate.java 2009-08-06 15:12:31 UTC (rev 915) @@ -13,6 +13,8 @@ * ***************************************************************************/ package org.cishell.templates.wizards.staticexecutable; +import java.io.BufferedWriter; +import java.io.FileWriter; import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -137,6 +139,15 @@ public static final String REMOTABLE_LABEL = "Remotable?"; public static final boolean DEFAULT_REMOTABLE_VALUE = true; + public static final String IN_DATA_ID = "inData"; + public static final String HAS_IN_DATA_ID = "hasInData"; + + public static final String OUT_DATA_ID = "outData"; + public static final String HAS_OUT_DATA_ID = "hasOutData"; + public static final String OUT_FILES_ID = "outFiles"; + public static final String OUT_FILE_LABELS_ID = "outFileLabels"; + public static final String OUT_FILE_TYPES_ID = "outFileTypes"; + public static final String BASE_EXECUTABLE_FILE_OPTION_NAME = "executableFileOption"; public static final String BASE_RELATED_FILE_OPTION_NAME = @@ -223,7 +234,44 @@ handleEmptyOption(REFERENCE_URL_ID, HAS_REFERENCE_URL_ID, ""); handleEmptyOption(DOCUMENTATION_URL_ID, HAS_DOCUMENTATION_URL_ID, ""); handleEmptyOption(WRITTEN_IN_ID, HAS_WRITTEN_IN_ID, ""); - + + // Project Parameters Page + + setValue("attributeDefinitions", + this.projectParametersPage.toOutputString()); + + // In and Out Data Page + try{ + addOption(IN_DATA_ID, + "", + this.inputAndOutputDataPage. + formServicePropertiesInputDataString(), + SPECIFY_INPUT_AND_OUTPUT_DATA_PAGE_NUMBER); + handleEmptyOption(IN_DATA_ID, HAS_IN_DATA_ID, ""); + + addOption(OUT_DATA_ID, + "", + this.inputAndOutputDataPage. + formServicePropertiesOutputDataString(), + SPECIFY_INPUT_AND_OUTPUT_DATA_PAGE_NUMBER); + handleEmptyOption(OUT_DATA_ID, HAS_OUT_DATA_ID, ""); + + addOption(OUT_FILES_ID, + "", + this.inputAndOutputDataPage. + formConfigPropertiesOutFilesString(), + SPECIFY_INPUT_AND_OUTPUT_DATA_PAGE_NUMBER); + } + catch (Exception e1) { + try { + FileWriter fstream = new FileWriter("C:/Documents and Settings/pataphil/Desktop/out.txt", true); + BufferedWriter out = new BufferedWriter(fstream); + out.write("exception: \'" + e1.toString() + "\'\n"); + out.close(); + } catch (Exception e) { + System.err.println("Error: " + e.getMessage()); + } + } super.execute(project, model, monitor); } @@ -440,7 +488,8 @@ private void handleEmptyOption( String optionID, String isEmptyOptionID, String compareTo) { - if (getOption(optionID).getValue().toString().equals(compareTo)) { + if (getOption(optionID).getValue() == null || + getOption(optionID).getValue().toString().equals(compareTo)) { setValue(isEmptyOptionID, "#"); } else { setValue(isEmptyOptionID, ""); Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/StaticExecutableOutputDataDelegate.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/StaticExecutableOutputDataDelegate.java 2009-08-06 14:02:35 UTC (rev 914) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/StaticExecutableOutputDataDelegate.java 2009-08-06 15:12:31 UTC (rev 915) @@ -38,6 +38,10 @@ public Composite getParent() { return this.parent; } + + public Map getIDToOutputDataItemMap() { + return this.idToOutputDataItemMap; + } public String[] createItem() { OutputDataItem outputDataItem = new OutputDataItem(); Modified: trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/ALGORITHM/config.properties =================================================================== --- trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/ALGORITHM/config.properties 2009-08-06 14:02:35 UTC (rev 914) +++ trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/ALGORITHM/config.properties 2009-08-06 15:12:31 UTC (rev 915) @@ -1,5 +1,3 @@ executable=$executableName$ template=$${executable} $templateString$ $outFiles$ -$outFileLabels$ -$outFileTypes$ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pat...@us...> - 2009-08-06 14:02:48
|
Revision: 914 http://cishell.svn.sourceforge.net/cishell/?rev=914&view=rev Author: pataphil Date: 2009-08-06 14:02:35 +0000 (Thu, 06 Aug 2009) Log Message: ----------- * Overhauled Static Executable Wizard. * There are still a few minor things to touch up on it. * NOT REVIEWED. Modified Paths: -------------- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/guibuilder/AttributeDefinitionEditor.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/guibuilder/ListBuilder.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/guibuilder/ParameterBuilderDelegate.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/guibuilder/ParameterListBuilder.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/BasicTemplate.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/dataset/NewDatasetTemplate.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/java/NewJavaAlgorithmTemplate.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/java/NewJavaAlgorithmWizard.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/jython/NewJythonAlgorithmTemplate.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pages/ParameterListBuilderPage.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/templates_3.0/java_algorithm/java/$algClass$.java trunk/templates/org.cishell.templates.wizards/templates_3.0/java_algorithm/java/$algClass$Factory.java trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/ALGORITHM/config.properties trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/ALGORITHM/service.properties trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/gui.xml trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/manifest.properties Added Paths: ----------- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/providers/ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/providers/InputDataProvider.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/providers/InputParameterProvider.java 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/PlatformOptionProvider.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/AddInputDataPanel.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/AddOutputDataPanel.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/SetupPlatformsPanel.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/ChooseExecutableFilesPage.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pages/SpecifyInAndOutDataPage.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/InputDataItem.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/InputDataItemEditor.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/OutputDataItem.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/OutputDataItemEditor.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/StaticExecutableInputDataDelegate.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/StaticExecutableOutputDataDelegate.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/utilities/ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/utilities/MultiHashMapWithCounts.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/widgets/ 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 trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/widgets/PlatformSetupHeaderWidget.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/widgets/PlatformSetupWidget.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/widgets/ResizeCompositeHackWidget.java trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/ALGORITHM/linux.x86_64/ trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/ALGORITHM/macosx.ppc/ trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/ALGORITHM/macosx.x86/ trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/ALGORITHM/solaris.sparc/ trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/ALGORITHM/win32/ Removed Paths: ------------- trunk/templates/org.cishell.templates.wizards/templates_3.0/static_executable/ALGORITHM/linux.x86/SampleAlg Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/guibuilder/AttributeDefinitionEditor.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/guibuilder/AttributeDefinitionEditor.java 2009-08-03 16:41:30 UTC (rev 913) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/guibuilder/AttributeDefinitionEditor.java 2009-08-06 14:02:35 UTC (rev 914) @@ -1,16 +1,3 @@ -/* **************************************************************************** - * CIShell: Cyberinfrastructure Shell, An Algorithm Integration Framework. - * - * All rights reserved. This program and the accompanying materials are made - * available under the terms of the Apache License v2.0 which accompanies - * this distribution, and is available at: - * http://www.apache.org/licenses/LICENSE-2.0.html - * - * Created on Aug 16, 2006 at Indiana University. - * - * Contributors: - * Indiana University - - * ***************************************************************************/ package org.cishell.templates.guibuilder; import org.eclipse.jface.dialogs.Dialog; @@ -26,12 +13,7 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; -/** - * - * @author Bruce Herr (bh...@bh...) - */ public class AttributeDefinitionEditor extends Dialog { - protected EditableAttributeDefinition attr; public static final String[] TYPE_LABELS = new String[]{ "String","Integer","Long","Short","Double","Float","Boolean", "Char", "Byte", "File", "Directory" @@ -40,40 +22,41 @@ 1,3,2,4,7,8,11,5,6,1,1 }; - protected Text id; - protected Text name; - protected Text description; - protected Text defaultValue; - protected Combo type; + private EditableAttributeDefinition attribute; + private Text id; + private Text name; + private Text description; + private Text defaultValue; + private Combo type; - protected AttributeDefinitionEditor(Composite parent, EditableAttributeDefinition attr) { + public AttributeDefinitionEditor(Composite parent, EditableAttributeDefinition attr) { this(parent.getShell(), attr); } - protected AttributeDefinitionEditor(Shell parentShell, EditableAttributeDefinition attr) { + private AttributeDefinitionEditor(Shell parentShell, EditableAttributeDefinition attr) { super(parentShell); - this.attr = attr; + this.attribute = attr; } protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); Composite panel = new Composite(composite, SWT.NONE); - GridLayout gridLayout = new GridLayout(2,false); + GridLayout gridLayout = new GridLayout(2, false); panel.setLayout(gridLayout); - id = newTextInput(panel,"Unique ID"); - id.setText(attr.getID()); + id = newTextInput(panel, "Unique ID"); + id.setText(attribute.getID()); - name = newTextInput(panel,"Name"); - name.setText(attr.getName()); + name = newTextInput(panel, "Name"); + name.setText(attribute.getName()); - description = newTextInput(panel,"Description"); - description.setText(attr.getDescription()); + description = newTextInput(panel, "Description"); + description.setText(attribute.getDescription()); defaultValue = newTextInput(panel, "Default Value"); - defaultValue.setText(attr.getDefaultValue()[0]); + defaultValue.setText(attribute.getDefaultValue()[0]); type = newListInput(panel, "Input Type"); type.setItems(TYPE_LABELS); @@ -95,7 +78,7 @@ }}); for (int i=0; i < TYPE_VALUES.length; i++) { - if (TYPE_VALUES[i] == attr.getType()) { + if (TYPE_VALUES[i] == attribute.getType()) { type.select(i); break; } @@ -106,7 +89,7 @@ return composite; } - protected Text newTextInput(Composite panel, String text) { + private Text newTextInput(Composite panel, String text) { Label label = new Label(panel, SWT.NONE); label.setText(text); GridData data = new GridData(SWT.LEFT, SWT.BEGINNING, false, false); @@ -119,7 +102,7 @@ return input; } - protected Combo newListInput(Composite panel, String text) { + private Combo newListInput(Composite panel, String text) { Label label = new Label(panel, SWT.NONE); label.setText(text); GridData data = new GridData(SWT.LEFT, SWT.BEGINNING, false, false); @@ -131,20 +114,20 @@ } protected void okPressed() { - attr.setID(cleanText(id.getText())); - attr.setName(cleanText(name.getText())); + attribute.setID(cleanText(id.getText())); + attribute.setName(cleanText(name.getText())); String desc = cleanText(description.getText()); if (desc.length() == 0) { desc = " "; } - attr.setDescription(desc); - attr.setDefaultValue(new String[]{cleanText(defaultValue.getText())}); - attr.setType(TYPE_VALUES[type.getSelectionIndex()]); + attribute.setDescription(desc); + attribute.setDefaultValue(new String[]{cleanText(defaultValue.getText())}); + attribute.setType(TYPE_VALUES[type.getSelectionIndex()]); super.okPressed(); } - protected String cleanText(String text) { + private String cleanText(String text) { text = text.replaceAll("<", "<"); text = text.replaceAll(">", ">"); Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/guibuilder/ListBuilder.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/guibuilder/ListBuilder.java 2009-08-03 16:41:30 UTC (rev 913) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/guibuilder/ListBuilder.java 2009-08-06 14:02:35 UTC (rev 914) @@ -31,9 +31,9 @@ import org.eclipse.swt.widgets.TableItem; public class ListBuilder { - protected BuilderDelegate delegate; - protected Table table; - protected Composite panel; + private BuilderDelegate delegate; + private Table table; + private Composite panel; public ListBuilder(Composite parent, BuilderDelegate delegate) { this(parent, SWT.NONE, delegate); @@ -41,91 +41,104 @@ public ListBuilder(Composite parent, int style, BuilderDelegate delegate) { this.delegate = delegate; + createGUI(parent, style); } private void createGUI(Composite parent, int style) { panel = new Composite(parent, style); - GridLayout gridLayout = new GridLayout(2, false); - panel.setLayout(gridLayout); + GridLayout panelLayout = new GridLayout(2, false); + panel.setLayout(panelLayout); - GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, true); - gridData.verticalSpan = 10; + GridData tableData = + new GridData(GridData.FILL, GridData.FILL, true, true); + tableData.verticalSpan = 10; table = createTable(panel); - table.setLayoutData(gridData); + table.setLayoutData(tableData); setupTableDoubleClicking(); setupTableDeleteKey(); - gridData = new GridData(GridData.FILL, GridData.BEGINNING, false, false); - Button add = createAddButton(panel); - add.setLayoutData(gridData); + GridData addButtonLayoutData = + new GridData(GridData.FILL, GridData.BEGINNING, false, false); + Button addButton = createAddButton(panel); + addButton.setLayoutData(addButtonLayoutData); - gridData = new GridData(GridData.FILL, GridData.BEGINNING, false, false); - Button edit = createEditButton(panel); - edit.setLayoutData(gridData); + GridData editButtonLayoutData = + new GridData(GridData.FILL, GridData.BEGINNING, false, false); + Button editButton = createEditButton(panel); + editButton.setLayoutData(editButtonLayoutData); - gridData = new GridData(GridData.FILL, GridData.BEGINNING, false, false); - Button remove = createRemoveButton(panel); - remove.setLayoutData(gridData); + GridData removeButtonLayoutData = + new GridData(GridData.FILL, GridData.BEGINNING, false, false); + Button removeButton = createRemoveButton(panel); + removeButton.setLayoutData(removeButtonLayoutData); - new Label(panel, SWT.NONE); //filler label + // This is a filler label. + new Label(panel, SWT.NONE); - gridData = new GridData(GridData.FILL, GridData.BEGINNING, false, false); - Button up = createUpButton(panel); - up.setLayoutData(gridData); + GridData moveUpButtonLayoutData = + new GridData(GridData.FILL, GridData.BEGINNING, false, false); + Button moveUpButton = createMoveUpButton(panel); + moveUpButton.setLayoutData(moveUpButtonLayoutData); - gridData = new GridData(GridData.FILL, GridData.BEGINNING, false, false); - Button down = createDownButton(panel); - down.setLayoutData(gridData); + GridData moveDownButtonLayoutData = + new GridData(GridData.FILL, GridData.BEGINNING, false, false); + Button moveDownButton = createMoveDownButton(panel); + moveDownButton.setLayoutData(moveDownButtonLayoutData); } private Button createAddButton(Composite parent) { - Button button = new Button(parent, SWT.FLAT); - button.setText("Add..."); - button.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) { - widgetSelected(e); + Button addButton = new Button(parent, SWT.PUSH); + addButton.setText("Add..."); + + addButton.addSelectionListener(new SelectionListener() { + public void widgetDefaultSelected(SelectionEvent selectionEvent) { + widgetSelected(selectionEvent); } - public void widgetSelected(SelectionEvent e) { + public void widgetSelected(SelectionEvent selectionEvent) { String[] item = delegate.createItem(); - if (item != null) add(item); + if (item != null) { + addItem(item); + } }}); - return button; + return addButton; } private Button createEditButton(Composite parent) { - Button button = new Button(parent, SWT.FLAT); - button.setText("Edit..."); - button.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) { - widgetSelected(e); + Button editButton = new Button(parent, SWT.PUSH); + editButton.setText("Edit..."); + + editButton.addSelectionListener(new SelectionListener() { + public void widgetDefaultSelected(SelectionEvent selectionEvent) { + widgetSelected(selectionEvent); } - public void widgetSelected(SelectionEvent e) { - TableItem[] items = table.getSelection(); + public void widgetSelected(SelectionEvent selectionEvent) { + TableItem[] tableItems = table.getSelection(); - if (items.length > 0) { - delegate.edit(items[0]); + if (tableItems.length > 0) { + delegate.edit(tableItems[0]); } }}); - return button; + return editButton; } private Button createRemoveButton(Composite parent) { - Button button = new Button(parent, SWT.FLAT); - button.setText("Remove"); - button.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) { - widgetSelected(e); + Button removeButton = new Button(parent, SWT.PUSH); + removeButton.setText("Remove"); + + removeButton.addSelectionListener(new SelectionListener() { + public void widgetDefaultSelected(SelectionEvent selectionEvent) { + widgetSelected(selectionEvent); } - public void widgetSelected(SelectionEvent e) { + public void widgetSelected(SelectionEvent selectionEvent) { int index = table.getSelectionIndex(); if (index != -1) { @@ -133,11 +146,11 @@ } }}); - return button; + return removeButton; } - private Button createUpButton(Composite parent) { - Button button = new Button(parent, SWT.FLAT); + private Button createMoveUpButton(Composite parent) { + Button button = new Button(parent, SWT.PUSH); button.setText("Up"); button.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { @@ -161,8 +174,8 @@ return button; } - private Button createDownButton(Composite parent) { - Button button = new Button(parent, SWT.FLAT); + private Button createMoveDownButton(Composite parent) { + Button button = new Button(parent, SWT.PUSH); button.setText("Down"); button.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { @@ -204,7 +217,7 @@ return table; } - private void add(String[] item) { + private void addItem(String[] item) { int index = table.getSelectionIndex(); TableItem row; if (index == -1) { Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/guibuilder/ParameterBuilderDelegate.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/guibuilder/ParameterBuilderDelegate.java 2009-08-03 16:41:30 UTC (rev 913) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/guibuilder/ParameterBuilderDelegate.java 2009-08-06 14:02:35 UTC (rev 914) @@ -1,16 +1,3 @@ -/* **************************************************************************** - * CIShell: Cyberinfrastructure Shell, An Algorithm Integration Framework. - * - * All rights reserved. This program and the accompanying materials are made - * available under the terms of the Apache License v2.0 which accompanies - * this distribution, and is available at: - * http://www.apache.org/licenses/LICENSE-2.0.html - * - * Created on Aug 16, 2006 at Indiana University. - * - * Contributors: - * Indiana University - - * ***************************************************************************/ package org.cishell.templates.guibuilder; import java.util.HashMap; @@ -21,97 +8,91 @@ import org.eclipse.swt.widgets.TableItem; import org.osgi.service.metatype.AttributeDefinition; -/** - * - * @author Bruce Herr (bh...@bh...) - */ public class ParameterBuilderDelegate implements BuilderDelegate { - protected static final String[] COLUMN_LABELS = new String[]{"id","Type","Label"}; - protected Map idToAttrMap; - protected int lastID; - protected Composite parent; + public static final String[] COLUMN_LABELS = new String[] { + "id", "Type", "Label" + }; + private Map idToAttributeMap; + private int lastID; + private Composite parent; + public ParameterBuilderDelegate(Composite parent) { this.parent = parent; - idToAttrMap = new HashMap(); + idToAttributeMap = new HashMap(); lastID = 0; } - /** - * @see org.cishell.templates.guibuilder.BuilderDelegate#createItem() - */ public String[] createItem() { - EditableAttributeDefinition attr = new EditableAttributeDefinition(); + EditableAttributeDefinition attribute = new EditableAttributeDefinition(); lastID++; - attr.setID(""+lastID); - attr.setName("Parameter Label"); - attr.setDescription("Parameter Description"); - attr.setDefaultValue(new String[]{"Default value"}); - attr.setType(AttributeDefinition.STRING); + attribute.setID("" + lastID); + attribute.setName("Parameter Label"); + attribute.setDescription("Parameter Description"); + attribute.setDefaultValue(new String[] { "Default value" }); + attribute.setType(AttributeDefinition.STRING); - boolean success = edit(attr); + boolean success = edit(attribute); if (success) { - idToAttrMap.put(attr.getID(), attr); + idToAttributeMap.put(attribute.getID(), attribute); String[] item = new String[]{ - attr.getID(), - getTypeString(attr.getType()), - attr.getName() + attribute.getID(), + getTypeString(attribute.getType()), + attribute.getName() }; + return item; } else { return null; } } - /** - * @see org.cishell.templates.guibuilder.BuilderDelegate#edit(org.eclipse.swt.widgets.TableItem) - */ public void edit(TableItem item) { - String id = item.getText(0); + String itemID = item.getText(0); - EditableAttributeDefinition attr = - (EditableAttributeDefinition) idToAttrMap.get(id); + EditableAttributeDefinition attribute = + (EditableAttributeDefinition)idToAttributeMap.get(itemID); - edit(attr); + edit(attribute); - item.setText(0, attr.getID()); - item.setText(1, getTypeString(attr.getType())); - item.setText(2, attr.getName()); + item.setText(0, attribute.getID()); + item.setText(1, getTypeString(attribute.getType())); + item.setText(2, attribute.getName()); } - protected boolean edit(EditableAttributeDefinition attr) { - AttributeDefinitionEditor editor = new AttributeDefinitionEditor(parent, attr); - int returnCode = editor.open(); + protected boolean edit(EditableAttributeDefinition attribute) { + AttributeDefinitionEditor attributeDefinitionEditor = + new AttributeDefinitionEditor(parent, attribute); + int returnCode = attributeDefinitionEditor.open(); if (returnCode == Dialog.OK) { - idToAttrMap.put(attr.getID(), attr); + idToAttributeMap.put(attribute.getID(), attribute); } return returnCode == Dialog.OK; } protected String getTypeString(int type) { - String str = "Unknown"; + String typeString = "Unknown"; - for (int i=0; i < AttributeDefinitionEditor.TYPE_VALUES.length; i++) { - if (AttributeDefinitionEditor.TYPE_VALUES[i] == type) { - str = AttributeDefinitionEditor.TYPE_LABELS[i]; + for (int ii = 0; + ii < AttributeDefinitionEditor.TYPE_VALUES.length; + ii++) { + if (AttributeDefinitionEditor.TYPE_VALUES[ii] == type) { + typeString = AttributeDefinitionEditor.TYPE_LABELS[ii]; break; } } - return str; + return typeString; } public EditableAttributeDefinition getAttributeDefinition(String id) { - return (EditableAttributeDefinition) idToAttrMap.get(id); + return (EditableAttributeDefinition)idToAttributeMap.get(id); } - - /** - * @see org.cishell.templates.guibuilder.BuilderDelegate#getColumns() - */ + public String[] getColumns() { return COLUMN_LABELS; } Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/guibuilder/ParameterListBuilder.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/guibuilder/ParameterListBuilder.java 2009-08-03 16:41:30 UTC (rev 913) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/guibuilder/ParameterListBuilder.java 2009-08-06 14:02:35 UTC (rev 914) @@ -1,16 +1,3 @@ -/* **************************************************************************** - * CIShell: Cyberinfrastructure Shell, An Algorithm Integration Framework. - * - * All rights reserved. This program and the accompanying materials are made - * available under the terms of the Apache License v2.0 which accompanies - * this distribution, and is available at: - * http://www.apache.org/licenses/LICENSE-2.0.html - * - * Created on Aug 16, 2006 at Indiana University. - * - * Contributors: - * Indiana University - - * ***************************************************************************/ package org.cishell.templates.guibuilder; import org.eclipse.swt.SWT; @@ -19,8 +6,8 @@ import org.eclipse.swt.widgets.TableItem; public class ParameterListBuilder { - protected ListBuilder builder; - protected ParameterBuilderDelegate delegate; + private ListBuilder builder; + private ParameterBuilderDelegate delegate; public ParameterListBuilder(Composite parent) { this(parent, SWT.NONE); @@ -37,24 +24,28 @@ public EditableAttributeDefinition[] getCreatedAttributes() { Display display = Display.getDefault(); + if (display != null) { - GetAttributeDefinitionsAction action = new GetAttributeDefinitionsAction(); + GetAttributeDefinitionsAction action = + new GetAttributeDefinitionsAction(); display.syncExec(action); - return action.attrs; + + return action.attributes; } else { return new EditableAttributeDefinition[0]; } } private class GetAttributeDefinitionsAction implements Runnable { - EditableAttributeDefinition[] attrs; + EditableAttributeDefinition[] attributes; public void run() { TableItem[] items = builder.getTable().getItems(); - attrs = new EditableAttributeDefinition[items.length]; + attributes = new EditableAttributeDefinition[items.length]; - for (int i=0; i < items.length; i++) { - attrs[i] = delegate.getAttributeDefinition(items[i].getText(0)); + for (int ii = 0; ii < items.length; ii++) { + attributes[ii] = + delegate.getAttributeDefinition(items[ii].getText(0)); } } } Added: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/providers/InputDataProvider.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/providers/InputDataProvider.java (rev 0) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/providers/InputDataProvider.java 2009-08-06 14:02:35 UTC (rev 914) @@ -0,0 +1,7 @@ +package org.cishell.templates.staticexecutable.providers; + +import org.cishell.templates.wizards.staticexecutable.InputDataItem; + +public interface InputDataProvider { + public InputDataItem[] getInputDataItems(); +} \ No newline at end of file Added: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/providers/InputParameterProvider.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/providers/InputParameterProvider.java (rev 0) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/providers/InputParameterProvider.java 2009-08-06 14:02:35 UTC (rev 914) @@ -0,0 +1,7 @@ +package org.cishell.templates.staticexecutable.providers; + +import org.osgi.service.metatype.AttributeDefinition; + +public interface InputParameterProvider { + public AttributeDefinition[] getInputParameters(); +} \ No newline at end of file Added: 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 (rev 0) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/providers/PlatformOption.java 2009-08-06 14:02:35 UTC (rev 914) @@ -0,0 +1,28 @@ +package org.cishell.templates.staticexecutable.providers; + +import org.eclipse.pde.ui.templates.BaseOptionTemplateSection; +import org.eclipse.pde.ui.templates.StringOption; + +public class PlatformOption extends StringOption { + 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 Added: 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 (rev 0) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/staticexecutable/providers/PlatformOptionProvider.java 2009-08-06 14:02:35 UTC (rev 914) @@ -0,0 +1,17 @@ +package org.cishell.templates.staticexecutable.providers; + +public interface PlatformOptionProvider { + public PlatformOption getExecutableFileOption(String platformName); + public PlatformOption[] getExecutableFileOptions(); + public void addExecutableFileOption(PlatformOption executableFileOption); + public PlatformOption createExecutableFileOption( + String platformName, String platformPath); + public String formExecutableFileOptionName(String platformName); + + public PlatformOption[] getRelatedFileOptions(String platformName); + public void addRelatedFileOption(PlatformOption relatedFileOption); + public void removeRelatedFileOption(PlatformOption relatedFileOption); + public PlatformOption createRelatedFileOption( + String platformName, String platformPath); + public String formRelatedFileOptionName(String platformName); +} \ No newline at end of file Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/BasicTemplate.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/BasicTemplate.java 2009-08-03 16:41:30 UTC (rev 913) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/BasicTemplate.java 2009-08-06 14:02:35 UTC (rev 914) @@ -24,10 +24,6 @@ import org.eclipse.pde.ui.templates.OptionTemplateSection; import org.eclipse.pde.ui.templates.TemplateOption; -/** - * - * @author Bruce Herr (bh...@bh...) - */ public abstract class BasicTemplate extends OptionTemplateSection { protected final String sectionID; protected Map valueMap; Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/dataset/NewDatasetTemplate.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/dataset/NewDatasetTemplate.java 2009-08-03 16:41:30 UTC (rev 913) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/dataset/NewDatasetTemplate.java 2009-08-06 14:02:35 UTC (rev 914) @@ -36,7 +36,7 @@ } public void addPages(Wizard wizard) { - WizardPage page = new WizardNewProjectCreationPage("projectPage"); + WizardPage page = new WizardNewProjectCreationPage("createProjectPage"); page.setTitle("Project Properties"); page.setDescription("Enter the project name and location"); wizard.addPage(page); Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/java/NewJavaAlgorithmTemplate.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/java/NewJavaAlgorithmTemplate.java 2009-08-03 16:41:30 UTC (rev 913) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/java/NewJavaAlgorithmTemplate.java 2009-08-06 14:02:35 UTC (rev 914) @@ -59,7 +59,7 @@ } public void addPages(Wizard wizard) { - projectPage = new WizardNewProjectCreationPage("projectPage"); + projectPage = new WizardNewProjectCreationPage("createProjectPage"); WizardPage page = projectPage; page.setTitle("Project Properties"); page.setDescription("Enter the project name and location"); Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/java/NewJavaAlgorithmWizard.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/java/NewJavaAlgorithmWizard.java 2009-08-03 16:41:30 UTC (rev 913) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/java/NewJavaAlgorithmWizard.java 2009-08-06 14:02:35 UTC (rev 914) @@ -48,10 +48,6 @@ import org.eclipse.ui.ide.IDE; import org.eclipse.ui.part.ISetSelectionTarget; -/** - * - * @author Bruce Herr (bh...@bh...) - */ public class NewJavaAlgorithmWizard extends NewPluginTemplateWizard implements IWorkbenchWizard { NewJavaAlgorithmTemplate template; Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/jython/NewJythonAlgorithmTemplate.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/jython/NewJythonAlgorithmTemplate.java 2009-08-03 16:41:30 UTC (rev 913) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/jython/NewJythonAlgorithmTemplate.java 2009-08-06 14:02:35 UTC (rev 914) @@ -36,7 +36,7 @@ } public void addPages(Wizard wizard) { - WizardPage page = new WizardNewProjectCreationPage("projectPage"); + WizardPage page = new WizardNewProjectCreationPage("createProjectPage"); page.setTitle("Project Properties"); page.setDescription("Enter the project name and location"); wizard.addPage(page); Added: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/AddInputDataPanel.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/AddInputDataPanel.java (rev 0) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/AddInputDataPanel.java 2009-08-06 14:02:35 UTC (rev 914) @@ -0,0 +1,97 @@ +package org.cishell.templates.wizards.pagepanels; + +import java.util.Map; + +import org.cishell.templates.guibuilder.BuilderDelegate; +import org.cishell.templates.guibuilder.ListBuilder; +import org.cishell.templates.wizards.staticexecutable.InputDataItem; +import org.cishell.templates.wizards.staticexecutable.StaticExecutableInputDataDelegate; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Device; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Layout; +import org.eclipse.swt.widgets.TableItem; + +public class AddInputDataPanel extends Composite { + public static final String INPUT_DATA_LABEL_TEXT = "Input Data"; + + private ListBuilder listBuilder; + private StaticExecutableInputDataDelegate delegate; + + public AddInputDataPanel(Composite parent, int style) { + super(parent, style); + setLayout(createLayoutForThis()); + + createHeader(); + this.delegate = new StaticExecutableInputDataDelegate(parent); + this.listBuilder = new ListBuilder(parent, SWT.NONE, delegate); + + GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); + this.listBuilder.getPanel().setLayoutData(gridData); + } + + public ListBuilder getListBuilder() { + return this.listBuilder; + } + + public BuilderDelegate getDelegate() { + return this.delegate; + } + + public InputDataItem[] getInputDataItems() { + TableItem[] tableItems = this.listBuilder.getTable().getItems(); + InputDataItem[] inputDataItems = new InputDataItem[tableItems.length]; + Map idToInputDataItemMap = this.delegate.getIDToInputDataItemMap(); + + for (int ii = 0; ii < tableItems.length; ii++) { + inputDataItems[ii] = (InputDataItem) + idToInputDataItemMap.get(tableItems[ii].getText(0)); + } + + return inputDataItems; + } + + private Layout createLayoutForThis() { + GridLayout layout = new GridLayout(1, true); + layout.marginHeight = 0; + layout.marginBottom = 0; + layout.marginTop = 0; + + return layout; + } + + private void createHeader() { + Label inputDataLabel = new Label(this, SWT.NONE); + inputDataLabel.setLayoutData(createInputDataLabelLayoutData()); + inputDataLabel.setText(INPUT_DATA_LABEL_TEXT); + inputDataLabel.setFont( + createInputDataLabelFont(inputDataLabel.getDisplay(), + inputDataLabel.getFont().getFontData())); + } + + private Object createInputDataLabelLayoutData() { + GridData data = new GridData(); + data.horizontalAlignment = SWT.BEGINNING; + + return data; + } + + private Font createInputDataLabelFont(Device device, + FontData[] oldFontData) { + FontData[] newFontData = new FontData[oldFontData.length]; + + for (int ii = 0; ii < oldFontData.length; ii++) { + newFontData[ii] = new FontData( + oldFontData[ii].getName(), + oldFontData[ii].getHeight() + 2, + oldFontData[ii].getStyle() | SWT.BOLD); + } + + return new Font(device, newFontData); + } +} \ No newline at end of file Added: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/AddOutputDataPanel.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/AddOutputDataPanel.java (rev 0) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/AddOutputDataPanel.java 2009-08-06 14:02:35 UTC (rev 914) @@ -0,0 +1,79 @@ +package org.cishell.templates.wizards.pagepanels; + +import org.cishell.templates.guibuilder.BuilderDelegate; +import org.cishell.templates.guibuilder.ListBuilder; +import org.cishell.templates.wizards.staticexecutable.StaticExecutableOutputDataDelegate; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Device; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Layout; + +public class AddOutputDataPanel extends Composite { + public static final String OUTPUT_DATA_LABEL_TEXT = "Output Data"; + + private ListBuilder listBuilder; + private BuilderDelegate delegate; + + public AddOutputDataPanel(Composite parent, int style) { + super(parent, style); + + setLayout(createLayoutForThis()); + + createHeader(); + delegate = new StaticExecutableOutputDataDelegate(parent); + listBuilder = new ListBuilder(parent, SWT.NONE, delegate); + + GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); + this.listBuilder.getPanel().setLayoutData(gridData); + } + + public ListBuilder getListBuilder() { + return this.listBuilder; + } + + public BuilderDelegate getDelegate() { + return this.delegate; + } + + private Layout createLayoutForThis() { + GridLayout layout = new GridLayout(6, true); + + return layout; + } + + private void createHeader() { + Label outputDataLabel = new Label(this, SWT.NONE); + outputDataLabel.setLayoutData(createOutputDataLabelLayoutData()); + outputDataLabel.setText(OUTPUT_DATA_LABEL_TEXT); + outputDataLabel.setFont(createOutputDataLabelFont( + outputDataLabel.getDisplay(), + outputDataLabel.getFont().getFontData())); + } + + private Object createOutputDataLabelLayoutData() { + GridData data = new GridData(); + data.horizontalAlignment = SWT.CENTER; + data.horizontalSpan = 6; + + return data; + } + + private Font createOutputDataLabelFont(Device device, + FontData[] oldFontData) { + FontData[] newFontData = new FontData[oldFontData.length]; + + for (int ii = 0; ii < oldFontData.length; ii++) { + newFontData[ii] = new FontData( + oldFontData[ii].getName(), + oldFontData[ii].getHeight() + 2, + oldFontData[ii].getStyle() | SWT.BOLD); + } + + return new Font(device, newFontData); + } +} \ No newline at end of file Added: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/SetupPlatformsPanel.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/SetupPlatformsPanel.java (rev 0) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/SetupPlatformsPanel.java 2009-08-06 14:02:35 UTC (rev 914) @@ -0,0 +1,129 @@ +package org.cishell.templates.wizards.pagepanels; + +import java.util.ArrayList; + +import org.cishell.templates.staticexecutable.providers.PlatformOptionProvider; +import org.cishell.templates.wizards.staticexecutable.NewStaticExecutableAlgorithmWizard; +import org.cishell.templates.wizards.widgets.PlatformSetupWidget; +import org.cishell.templates.wizards.widgets.ResizeCompositeHackWidget; +import org.eclipse.pde.ui.templates.TemplateOption; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Layout; +import org.eclipse.swt.widgets.Text; + +public class SetupPlatformsPanel extends ResizeCompositeHackWidget { + public static final String SPECIFY_EXECUTABLE_NAME_LABEL = + "Executable Name"; + + // public static final int SPECIFY_EXECUTABLE_NAME_TEXT_WIDTH = 350; + + private ArrayList platformSetupWidgets; + + public SetupPlatformsPanel(Composite parent, + int style, + TemplateOption executableNameOption, + PlatformOptionProvider platformOptionProvider) { + super(parent, style); + + setLayout(createLayoutForThis()); + createExecutableNameOptionWidget(executableNameOption); + + this.platformSetupWidgets = + createPlatformSetupWidgets(platformOptionProvider); + } + + public ArrayList getPlatformSetupWidgets() { + return this.platformSetupWidgets; + } + + private Layout createLayoutForThis() { + GridLayout layout = new GridLayout(2, true); + layout.makeColumnsEqualWidth = false; + + return layout; + } + + private void createExecutableNameOptionWidget( + TemplateOption executableNameOption) { + executableNameOption.createControl(this, 2); + } + + private void createSpecifyExecutableNameLabel() { + Label specifyExecutableNameLabel = new Label(this, SWT.NONE); + specifyExecutableNameLabel.setLayoutData( + createSpecifyExecutableNameLableLayoutData()); + specifyExecutableNameLabel.setText( + SPECIFY_EXECUTABLE_NAME_LABEL + ":"); + } + + private Text createSpecifyExecutableNameText() { + Text specifyExecutableNameText = new Text(this, SWT.BORDER); + specifyExecutableNameText.setLayoutData( + createSpecifyExecutableNameTextLayoutData()); + + return specifyExecutableNameText; + } + + private ArrayList createPlatformSetupWidgets( + PlatformOptionProvider platformOptionProvider) { + ArrayList platformSetupWidgets = new ArrayList(); + + PlatformSetupWidget defaultPlatformSetupWidget = + new PlatformSetupWidget( + this, + SWT.NONE, + NewStaticExecutableAlgorithmWizard.DEFAULT_LABEL, + NewStaticExecutableAlgorithmWizard.DEFAULT_PATH, + false, + platformOptionProvider); + defaultPlatformSetupWidget.setLayoutData( + createPlatformSetupWidgetLayoutData()); + platformSetupWidgets.add(defaultPlatformSetupWidget); + + for (int ii = 1; + ii < NewStaticExecutableAlgorithmWizard.PLATFORM_LABELS.length; + ii++) { + PlatformSetupWidget platformSetupWidget = + new PlatformSetupWidget( + this, + SWT.NONE, + NewStaticExecutableAlgorithmWizard.PLATFORM_LABELS[ii], + NewStaticExecutableAlgorithmWizard.PLATFORM_PATHS[ii], + true, + platformOptionProvider); + platformSetupWidget.setLayoutData( + createPlatformSetupWidgetLayoutData()); + platformSetupWidgets.add(platformSetupWidget); + } + + return platformSetupWidgets; + } + + private Object createSpecifyExecutableNameLableLayoutData() { + GridData data = new GridData(); + + return data; + } + + private Object createSpecifyExecutableNameTextLayoutData() { + GridData data = new GridData(); + data.horizontalAlignment = SWT.FILL; + data.grabExcessHorizontalSpace = true; + // data.widthHint = SPECIFY_EXECUTABLE_NAME_TEXT_WIDTH; + + return data; + } + + private Object createPlatformSetupWidgetLayoutData() { + GridData data = new GridData(); + data.horizontalAlignment = SWT.FILL; + data.grabExcessHorizontalSpace = true; + data.horizontalSpan = 2; + + return data; + } +} \ No newline at end of file Added: 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 (rev 0) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/SpecifyTemplateStringPanel.java 2009-08-06 14:02:35 UTC (rev 914) @@ -0,0 +1,239 @@ +package org.cishell.templates.wizards.pagepanels; + +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.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Layout; +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; + +public class SpecifyTemplateStringPanel extends Composite + implements SelectionListener { + public static final String PLACEHOLDER_LABEL = + "Template String Placeholders"; + public static final String TEMPLATE_STRING_LABEL = "Template String"; + public static final String INSERT_PLACEHOLDER_BUTTON_LABEL = "Insert"; + + public static final String PLACEHOLDER_LABEL_COLUMN_LABEL = "Item"; + public static final String PLACEHOLDER_COLUMN_LABEL = + "Placeholder String for Item"; + + public static final int COLUMN_WIDTH = 85; + public static final int TABLE_HEIGHT = 300; + + private Table placeholderTable; + private Button insertPlaceholderButton; + private TemplateOption templateStringOption; + + public SpecifyTemplateStringPanel(Composite parent, + int style, + TemplateOption templateStringOption) { + super(parent, style); + + this.templateStringOption = templateStringOption; + + setLayout(createLayoutForThis()); + + createHeader(); + this.placeholderTable = createPlaceholderTable(); + this.insertPlaceholderButton = createInsertPlaceholderButton(); + createTemplateStringText(); + } + + public void updateControls(InputParameterProvider inputParameterProvider, + InputDataProvider inputDataProvider) { + this.placeholderTable.deselectAll(); + this.placeholderTable.removeAll(); + + AttributeDefinition[] inputParameters = + inputParameterProvider.getInputParameters(); + + for (int ii = 0; ii < inputParameters.length; ii++) { + String label = inputParameters[ii].getName() + + " (" + + inputParameters[ii].getDescription() + + ")"; + String value = "\"${" + inputParameters[ii].getName() + "}\""; + addTableItem(label, value); + } + + InputDataItem[] inputDataItems = + inputDataProvider.getInputDataItems(); + + for (int ii = 0; ii < inputDataItems.length; ii++) { + String label = inputDataItems[ii].getMimeType() + " File"; + String value = "\"${inFile[" + ii + "]}\""; + addTableItem(label, value); + } + } + + public void widgetDefaultSelected(SelectionEvent selectionEvent) { + insertButtonSelected(selectionEvent); + } + + public void widgetSelected(SelectionEvent selectionEvent) { + insertButtonSelected(selectionEvent); + } + + private Layout createLayoutForThis() { + GridLayout layout = new GridLayout(4, true); + layout.makeColumnsEqualWidth = false; + + return layout; + } + + private void createHeader() { + Label placeholderTableLabel = new Label(this, SWT.NONE); + placeholderTableLabel.setLayoutData( + createPlaceholderTableLabelLayoutData()); + placeholderTableLabel.setText(PLACEHOLDER_LABEL); + + Label insertButtonLabel = new Label(this, SWT.NONE); + insertButtonLabel.setLayoutData( + createInsertPlaceholderButtonLayoutData()); + insertButtonLabel.setText(INSERT_PLACEHOLDER_BUTTON_LABEL); + insertButtonLabel.setVisible(false); + + // To accomodate for the option label control. + new Label(this, SWT.NONE).setLayoutData(new GridData()); + + Label templateStringLabel = new Label(this, SWT.NONE); + templateStringLabel.setLayoutData( + createTemplateStringTextLayoutData()); + templateStringLabel.setText(TEMPLATE_STRING_LABEL); + } + + private Table createPlaceholderTable() { + Table placeholderTable = new Table( + this, SWT.BORDER | SWT.FULL_SELECTION | SWT.HIDE_SELECTION); + placeholderTable.setLayoutData(createPlaceholderTableLayoutData()); + placeholderTable.setLinesVisible(true); + placeholderTable.setHeaderVisible(true); + + TableColumn placeholderLabelColumn = + new TableColumn(placeholderTable, SWT.NONE); + placeholderLabelColumn.pack(); + placeholderLabelColumn.setWidth(COLUMN_WIDTH); + placeholderLabelColumn.setText(PLACEHOLDER_LABEL_COLUMN_LABEL); + + TableColumn placeholderColumn = + new TableColumn(placeholderTable, SWT.NONE); + placeholderColumn.pack(); + placeholderColumn.setWidth(COLUMN_WIDTH); + placeholderColumn.setText(PLACEHOLDER_COLUMN_LABEL); + + return placeholderTable; + } + + private Button 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() { + this.templateStringOption.createControl(this, 2); + } + + private Object createPlaceholderTableLabelLayoutData() { + GridData data = new GridData(); + data.horizontalAlignment = SWT.CENTER; + + return data; + } + + private Object createPlaceholderTableLayoutData() { + GridData data = new GridData(); + data.horizontalAlignment = SWT.CENTER; + data.heightHint = TABLE_HEIGHT; + + return data; + } + + private Object createInsertPlaceholderButtonLayoutData() { + GridData data = new GridData(); + + return data; + } + + private Object createTemplateStringTextLayoutData() { + GridData data = new GridData(); + data.horizontalAlignment = SWT.FILL; + data.grabExcessHorizontalSpace = true; + + return data; + } + + private void addTableItem(String label, String value) { + String[] tableItemText = new String[] { label, value }; + TableItem tableItem = new TableItem(this.placeholderTable, SWT.NONE); + tableItem.setText(tableItemText); + } + + private void insertButtonSelected(SelectionEvent selectionEvent) { + int selectedTableItemIndex = this.placeholderTable.getSelectionIndex(); + + if (selectedTableItemIndex != -1) { + TableItem selectedTableItem = + this.placeholderTable.getItem(selectedTableItemIndex); + String placeholder = selectedTableItem.getText(1); + + insertPlaceholder(placeholder); + } + } + + 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); + } 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); + } + + /*private int fixCaretPosition(int caretPosition) { + int fixedCaretPosition = caretPosition; + String templateStringText = this.templateStringText.getText(); + + if (fixedCaretPosition == 0 || templateStringText.length() == 0) { + return fixedCaretPosition; + } else { + char currentCharacter = templateStringText.charAt(fixedCaretPosition); + + while (!Character.isWhitespace(currentCharacter) && + fixedCaretPosition < templateStringText.length()) { + fixedCaretPosition++; + currentCharacter = + templateStringText.charAt(fixedCaretPosition); + } + } + + return fixedCaretPosition; + }*/ +} \ No newline at end of file Added: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pages/ChooseExecutableFilesPage.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pages/ChooseExecutableFilesPage.java (rev 0) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pages/ChooseExecutableFilesPage.java 2009-08-06 14:02:35 UTC (rev 914) @@ -0,0 +1,56 @@ +package org.cishell.templates.wizards.pages; + +import org.cishell.templates.staticexecutable.providers.PlatformOptionProvider; +import org.cishell.templates.wizards.pagepanels.SetupPlatformsPanel; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.pde.ui.templates.TemplateOption; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.ScrolledComposite; +import org.eclipse.swt.events.ControlAdapter; +import org.eclipse.swt.events.ControlEvent; +import org.eclipse.swt.widgets.Composite; + +public class ChooseExecutableFilesPage extends WizardPage { + private SetupPlatformsPanel setupPlatformsPanel; + private TemplateOption executableNameOption; + private PlatformOptionProvider platformOptionProvider; + + public ChooseExecutableFilesPage( + String pageName, + TemplateOption executableNameOption, + PlatformOptionProvider platformOptionProvider) { + super(pageName); + + this.executableNameOption = executableNameOption; + this.platformOptionProvider = platformOptionProvider; + } + + public void createControl(Composite parent) { + final ScrolledComposite scrollingContainer = + new ScrolledComposite(parent, SWT.V_SCROLL); + final SetupPlatformsPanel setupPlatformsPanel = + new SetupPlatformsPanel(scrollingContainer, + SWT.NONE, + this.executableNameOption, + this.platformOptionProvider); + this.setupPlatformsPanel = setupPlatformsPanel; + + // TODO: This control listener should maybe be on setupPlatformsPanel? + scrollingContainer.addControlListener(new ControlAdapter() { + public void controlResized(ControlEvent controlEvent) { + scrollingContainer.setMinSize( + setupPlatformsPanel.computeSize(SWT.DEFAULT, SWT.DEFAULT)); + } + }); + + scrollingContainer.setContent(setupPlatformsPanel); + scrollingContainer.setExpandHorizontal(true); + scrollingContainer.setExpandVertical(true); + + setControl(scrollingContainer); + } + + public SetupPlatformsPanel getSetupPlatforms... [truncated message content] |
From: <jrb...@us...> - 2009-08-03 16:41:46
|
Revision: 913 http://cishell.svn.sourceforge.net/cishell/?rev=913&view=rev Author: jrbibers Date: 2009-08-03 16:41:30 +0000 (Mon, 03 Aug 2009) Log Message: ----------- Added DropdownMutator. Use this class in the mutateParameters method of a ParameterMutator when you wish to replace some AttributeDefinition in an ObjectClassDefinition with a dropdown list of options, whose labels and values you supply. For an example usage, see edu.iu.scipolicy.visualization.geomaps.GeoMapsCirclesFactory.mutateParameters(Data[], ObjectClassDefinition). Modified Paths: -------------- trunk/core/org.cishell.utilities/META-INF/MANIFEST.MF trunk/core/org.cishell.utilities/src/org/cishell/utilities/AlgorithmUtilities.java trunk/core/org.cishell.utilities/src/org/cishell/utilities/DefaultDictionary.java trunk/core/org.cishell.utilities/src/org/cishell/utilities/FileUtilities.java trunk/core/org.cishell.utilities/src/org/cishell/utilities/MutateParameterUtilities.java trunk/core/org.cishell.utilities/src/org/cishell/utilities/mutateParameter/NullDropdownTransformer.java trunk/core/org.cishell.utilities/src/org/cishell/utilities/mutateParameter/ObjectClassDefinitionTransformer.java Added Paths: ----------- trunk/core/org.cishell.utilities/src/org/cishell/utilities/mutateParameter/DropdownMutator.java Modified: trunk/core/org.cishell.utilities/META-INF/MANIFEST.MF =================================================================== --- trunk/core/org.cishell.utilities/META-INF/MANIFEST.MF 2009-08-03 16:33:43 UTC (rev 912) +++ trunk/core/org.cishell.utilities/META-INF/MANIFEST.MF 2009-08-03 16:41:30 UTC (rev 913) @@ -4,7 +4,9 @@ Bundle-SymbolicName: org.cishell.utilities Bundle-Version: 1.0.0 Bundle-RequiredExecutionEnvironment: J2SE-1.5 -Import-Package: org.cishell.framework.algorithm;version="1.0.0", +Import-Package: org.cishell.framework;version="1.0.0", + org.cishell.framework.algorithm;version="1.0.0", + org.cishell.framework.data, org.cishell.reference.service.metatype, org.osgi.framework;version="1.4.0", org.osgi.service.metatype;version="1.1.0", Modified: trunk/core/org.cishell.utilities/src/org/cishell/utilities/AlgorithmUtilities.java =================================================================== --- trunk/core/org.cishell.utilities/src/org/cishell/utilities/AlgorithmUtilities.java 2009-08-03 16:33:43 UTC (rev 912) +++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/AlgorithmUtilities.java 2009-08-03 16:41:30 UTC (rev 913) @@ -1,6 +1,8 @@ package org.cishell.utilities; import org.cishell.framework.algorithm.AlgorithmFactory; +import org.cishell.framework.data.BasicData; +import org.cishell.framework.data.Data; import org.osgi.framework.BundleContext; import org.osgi.framework.InvalidSyntaxException; import org.osgi.framework.ServiceReference; @@ -45,4 +47,10 @@ return getAlgorithmFactoryByFilter(filter, bundleContext); } + + public static Data[] cloneSingletonData(Data[] data) { + return new Data[]{ new BasicData(data[0].getMetadata(), + data[0].getData(), + data[0].getFormat()) }; + } } \ No newline at end of file Modified: trunk/core/org.cishell.utilities/src/org/cishell/utilities/DefaultDictionary.java =================================================================== --- trunk/core/org.cishell.utilities/src/org/cishell/utilities/DefaultDictionary.java 2009-08-03 16:33:43 UTC (rev 912) +++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/DefaultDictionary.java 2009-08-03 16:41:30 UTC (rev 913) @@ -8,9 +8,8 @@ Object defaultValue; Dictionary wrappedDictionary; - public DefaultDictionary - (Object defaultValue, Dictionary wrappedDictionary) - { + public DefaultDictionary( + Object defaultValue, Dictionary wrappedDictionary) { this.defaultValue = defaultValue; this.wrappedDictionary = wrappedDictionary; } Modified: trunk/core/org.cishell.utilities/src/org/cishell/utilities/FileUtilities.java =================================================================== --- trunk/core/org.cishell.utilities/src/org/cishell/utilities/FileUtilities.java 2009-08-03 16:33:43 UTC (rev 912) +++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/FileUtilities.java 2009-08-03 16:41:30 UTC (rev 913) @@ -74,8 +74,8 @@ // If the creation of the temporary file failed, throw an exception. if (temporaryFile == null) { - throw new IOException - ("Failed to generate a file in the temporary directory."); + throw new IOException( + "Failed to generate a file in the temporary directory."); } return temporaryFile; Modified: trunk/core/org.cishell.utilities/src/org/cishell/utilities/MutateParameterUtilities.java =================================================================== --- trunk/core/org.cishell.utilities/src/org/cishell/utilities/MutateParameterUtilities.java 2009-08-03 16:33:43 UTC (rev 912) +++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/MutateParameterUtilities.java 2009-08-03 16:41:30 UTC (rev 913) @@ -1,6 +1,7 @@ package org.cishell.utilities; import java.io.IOException; +import java.util.Collection; import java.util.LinkedHashMap; import org.cishell.reference.service.metatype.BasicObjectClassDefinition; @@ -116,6 +117,17 @@ return transformer.transform(oldAD); } + public static BasicObjectClassDefinition mutateToDropdown( + ObjectClassDefinition oldOCD, + final String parameterID, + Collection optionLabels, + Collection optionValues) { + return mutateToDropdown(oldOCD, + parameterID, + (String[]) optionLabels.toArray(new String[0]), + (String[]) optionValues.toArray(new String[0])); + } + /* Convenience method for a common mutation: * Replacing a parameter (identified by its ID) with a dropdown list of * options. Added: trunk/core/org.cishell.utilities/src/org/cishell/utilities/mutateParameter/DropdownMutator.java =================================================================== --- trunk/core/org.cishell.utilities/src/org/cishell/utilities/mutateParameter/DropdownMutator.java (rev 0) +++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/mutateParameter/DropdownMutator.java 2009-08-03 16:41:30 UTC (rev 913) @@ -0,0 +1,49 @@ +package org.cishell.utilities.mutateParameter; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.osgi.service.metatype.AttributeDefinition; +import org.osgi.service.metatype.ObjectClassDefinition; + +public class DropdownMutator { + private List transforms; + + public DropdownMutator() { + transforms = new ArrayList(); + } + + public void add(String id, Collection options) { + add(id, options, options); + } + + public void add(String id, Collection optionLabels, Collection optionValues) { + add(id, (String[]) optionLabels.toArray(new String[0]), (String[]) optionValues.toArray(new String[0])); + } + + public void add(String id, String[] options) { + add(id, options, options); + } + + public void add(final String id, final String[] optionLabels, final String[] optionValues) { + transforms.add( + new NullDropdownTransformer() { + public boolean shouldTransform(AttributeDefinition ad) { + return id.equals(ad.getID()); + } + + public String[] transformOptionLabels(String[] oldOptionLabels) { + return optionLabels; + } + + public String[] transformOptionValues(String[] oldOptionValues) { + return optionValues; + } + }); + } + + public ObjectClassDefinition mutate(ObjectClassDefinition ocd) { + return ObjectClassDefinitionTransformer.transform(ocd, transforms); + } +} Modified: trunk/core/org.cishell.utilities/src/org/cishell/utilities/mutateParameter/NullDropdownTransformer.java =================================================================== --- trunk/core/org.cishell.utilities/src/org/cishell/utilities/mutateParameter/NullDropdownTransformer.java 2009-08-03 16:33:43 UTC (rev 912) +++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/mutateParameter/NullDropdownTransformer.java 2009-08-03 16:41:30 UTC (rev 913) @@ -10,9 +10,7 @@ * transformOptionLabels, and transformOptionValues. */ public abstract class NullDropdownTransformer extends DropdownTransformer { - public boolean shouldTransform(AttributeDefinition ad) { - return false; - } + public abstract boolean shouldTransform(AttributeDefinition ad); public String transformID(String oldID) { return oldID; Modified: trunk/core/org.cishell.utilities/src/org/cishell/utilities/mutateParameter/ObjectClassDefinitionTransformer.java =================================================================== --- trunk/core/org.cishell.utilities/src/org/cishell/utilities/mutateParameter/ObjectClassDefinitionTransformer.java 2009-08-03 16:33:43 UTC (rev 912) +++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/mutateParameter/ObjectClassDefinitionTransformer.java 2009-08-03 16:41:30 UTC (rev 913) @@ -36,9 +36,9 @@ /* Convenience method for batching transformations. * TODO Untested */ - public static BasicObjectClassDefinition transform( - BasicObjectClassDefinition oldOCD, List transformers) { - BasicObjectClassDefinition newOCD = oldOCD; + public static ObjectClassDefinition transform( + ObjectClassDefinition ocd, List transformers) { + ObjectClassDefinition newOCD = ocd; for ( Iterator it = transformers.iterator(); it.hasNext(); ) { AttributeDefinitionTransformer transformer = This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jrb...@us...> - 2009-08-03 16:33:53
|
Revision: 912 http://cishell.svn.sourceforge.net/cishell/?rev=912&view=rev Author: jrbibers Date: 2009-08-03 16:33:43 +0000 (Mon, 03 Aug 2009) Log Message: ----------- For conversion exception handling task, NWB sprint, July 2009. Stepped through each converter algorithm and tried to clean up the exception handling in each to provide useful error messages. While at it, also updated the style of unpacking the input Data[]. I've been told we're now trying to unpack this data in the constructor rather than the execute method. Finally, updated central conversion exception handling in CIShell. I've attempted to maintain this desired behavior: When an exception occurs during a conversion, if the first and only exception occurred in the final step (of a potentially multi-stepped conversion chain), and that final converter was specifically a file handler (in the "validator, reader, writer, handler" sense: it takes data from MIME type "foo" to file extension "foo"), do not throw an error, but rather log a warning and use the "unhandled" data. Conversion should work this way whether it is for saving, for viewing, or (implicitly) for use by another algorithm. As a pleasant side effect, since adding these changes, I haven't gotten any of the ugly dialogs filled with raw/junky-looking text that would sometimes pop up when saving or viewing a file in a relatively buggy format (like Pajek .net). Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.persistence/.classpath trunk/clients/gui/org.cishell.reference.gui.persistence/META-INF/MANIFEST.MF trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/FileUtil.java trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/FileSaver.java trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/Save.java trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveDataChooser.java trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/FileView.java trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/ViewDataChooser.java trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/viewwith/FileViewWith.java trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/viewwith/ViewWithDataChooser.java trunk/core/org.cishell.reference/.classpath trunk/core/org.cishell.reference/src/org/cishell/reference/service/conversion/ConverterImpl.java trunk/core/org.cishell.reference/src/org/cishell/reference/service/conversion/DataConversionServiceImpl.java Added Paths: ----------- trunk/clients/gui/org.cishell.reference.gui.persistence/.settings/org.eclipse.jdt.core.prefs trunk/core/org.cishell.reference/.settings/org.eclipse.jdt.core.prefs Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/.classpath =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/.classpath 2009-07-31 20:40:05 UTC (rev 911) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/.classpath 2009-08-03 16:33:43 UTC (rev 912) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/j2sdk1.4.2_19"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="output" path="bin"/> </classpath> Added: trunk/clients/gui/org.cishell.reference.gui.persistence/.settings/org.eclipse.jdt.core.prefs =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/.settings/org.eclipse.jdt.core.prefs (rev 0) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/.settings/org.eclipse.jdt.core.prefs 2009-08-03 16:33:43 UTC (rev 912) @@ -0,0 +1,12 @@ +#Tue Jul 28 13:21:05 EDT 2009 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.4 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning +org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning +org.eclipse.jdt.core.compiler.source=1.3 Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/META-INF/MANIFEST.MF =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/META-INF/MANIFEST.MF 2009-07-31 20:40:05 UTC (rev 911) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/META-INF/MANIFEST.MF 2009-08-03 16:33:43 UTC (rev 912) @@ -9,6 +9,7 @@ org.cishell.framework.algorithm;version="1.0.0", org.cishell.framework.data;version="1.0.0", org.cishell.reference.gui.common, + org.cishell.reference.service.conversion, org.cishell.reference.service.metatype, org.cishell.service.conversion;version="1.0.0", org.cishell.service.guibuilder;version="1.0.0", Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/FileUtil.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/FileUtil.java 2009-07-31 20:40:05 UTC (rev 911) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/FileUtil.java 2009-08-03 16:33:43 UTC (rev 912) @@ -51,8 +51,10 @@ public static String extractExtension(String format) { String extension = ""; - //TODO: We should really have explicit piece of metadata that says what the extension is, - //TODO: as this method is not guaranteed to yield the correct extension + /* TODO: We should really have explicit piece of metadata that says what + * the extension is, as this method is not guaranteed to yield the + * correct extension. + */ if (format.startsWith("file:text/")) { extension = "." + format.substring("file:text/".length()); } else if (format.startsWith("file-ext:")) { Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/FileSaver.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/FileSaver.java 2009-07-31 20:40:05 UTC (rev 911) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/FileSaver.java 2009-08-03 16:33:43 UTC (rev 912) @@ -28,8 +28,10 @@ * @author Team */ public class FileSaver { - private static File currentDir; + public static final String FILE_EXTENSION_PREFIX = "file-ext:"; + private static File currentDir; + private Shell parent; private GUIBuilderService guiBuilder; @@ -87,25 +89,28 @@ * @return Whether or not the save was successful */ public boolean save(Converter converter, Data data) { - String outDataStr = (String)converter.getProperties().get(AlgorithmProperty.OUT_DATA); + String outDataStr = + (String) converter.getProperties().get(AlgorithmProperty.OUT_DATA); String ext = ""; - if (outDataStr.startsWith("file-ext:")) { - ext = outDataStr.substring(outDataStr.indexOf(':')+1); + if (outDataStr.startsWith(FILE_EXTENSION_PREFIX)) { + ext = outDataStr.substring(FILE_EXTENSION_PREFIX.length()); } - if ((""+ext).startsWith(".")) { + // Skip any initial "." if present. + if (ext.startsWith(".")) { ext = ext.substring(1); } FileDialog dialog = new FileDialog(parent, SWT.SAVE); if (currentDir == null) { - currentDir = new File(System.getProperty("user.home") + File.separator + "anything"); + currentDir = new File(System.getProperty("user.home") + File.separator + + "anything"); } dialog.setFilterPath(currentDir.getPath()); - + if (ext != null && !ext.equals("*")) { dialog.setFilterExtensions(new String[]{"*." + ext}); } @@ -128,38 +133,46 @@ String fileName = dialog.open(); if (fileName != null) { File selectedFile = new File(fileName); - if (!isSaveFileValid(selectedFile)) + if (!isSaveFileValid(selectedFile)) { continue; - if (ext != null && ext.length() != 0) - if (!selectedFile.getPath().endsWith(ext) && !ext.equals("*")) + } + + if (ext != null && ext.length() != 0) { + if (!selectedFile.getPath().endsWith(ext) && !ext.equals("*")) { selectedFile = new File(selectedFile.getPath()+'.'+ ext); + } + } + try { - Data newData = converter.convert(data); - - - copy((File)newData.getData(), selectedFile); - - if (selectedFile.isDirectory()) { - currentDir = new File(selectedFile + File.separator + "anything"); - } else { - currentDir = new File(selectedFile.getParent() + File.separator + "anything"); + Data newData = converter.convert(data); + + copy((File) newData.getData(), selectedFile); + + if (selectedFile.isDirectory()) { + currentDir = new File(selectedFile + File.separator + "anything"); + } else { + currentDir = new File(selectedFile.getParent() + File.separator + "anything"); + } + + done = true; } - - done = true; - } catch (ConversionException e1) { - this.log.log(LogService.LOG_ERROR, "Error occurred while converting data to saved format.", e1); + catch (ConversionException e) { + log.log(LogService.LOG_ERROR, "Error occurred while converting data to saved format:\n " + e.getMessage(), e); return false; } + log.log(LogService.LOG_INFO, "Saved: " + selectedFile.getPath()); } else { done = true; return false; - } + } } return true; } - - /** + + + + /** * Converter puts it into a temporary directory, this copies it over * * @param in The temp file to copy Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/Save.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/Save.java 2009-07-31 20:40:05 UTC (rev 911) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/Save.java 2009-08-03 16:33:43 UTC (rev 912) @@ -24,14 +24,13 @@ * @author bmarkine */ public class Save implements Algorithm { - Data[] data; - Dictionary parameters; - CIShellContext context; - Shell parentShell; + public static final String ANY_FILE_EXTENSION = "file-ext:*"; + public static final String SAVE_DIALOG_TITLE = "Save"; + private Data[] data; + private CIShellContext context; + private Shell parentShell; - private GUIBuilderService guiBuilder; private DataConversionService conversionManager; - private LogService log; /** * Sets up default services for the algorithm @@ -42,102 +41,66 @@ */ public Save(Data[] data, Dictionary parameters, CIShellContext context) { this.data = data; - this.parameters = parameters; this.context = context; - this.conversionManager = (DataConversionService) context.getService( - DataConversionService.class.getName()); - - this.log = (LogService) context.getService(LogService.class.getName()); - this.guiBuilder = (GUIBuilderService)context.getService(GUIBuilderService.class.getName()); + this.conversionManager = (DataConversionService) + context.getService(DataConversionService.class.getName()); } /** - * Executes the algorithm - * - * @return Null for this algorithm + * @return Null when successful */ public Data[] execute() throws AlgorithmExecutionException { - //NOTE: A "converter" here is actually a converter path - //starting with the format for the data we want to save - //and ending in a output format - Data dataToSave = data[0]; + Data outData = data[0]; + + tryToSave(outData, ANY_FILE_EXTENSION); - //first, try to save the normal way, which is using validators to validate the output. - String saveThroughValidators = "file-ext:*"; - Object firstAttemptResult = tryToSave(dataToSave, saveThroughValidators); - if (firstAttemptResult instanceof Boolean) { - boolean succeeded = ((Boolean) firstAttemptResult).booleanValue(); - if (succeeded) { - System.out.println("Success"); - return null; //FILE SAVED SUCCESSFULLY. DONE. - } else { - System.out.println("No converter"); - this.log.log(LogService.LOG_WARNING, "No converters found that can save file through a validator." + - " Attempting to save without validating."); - } - } else { //result instanceof Exception - Exception reasonForFailure = (Exception) firstAttemptResult; - this.log.log(LogService.LOG_WARNING, "Exception occurred while attempting to save" + - " file using a validator. Attempting to save without validating.", reasonForFailure); - System.out.println("Exception"); - } - - System.out.println("Trying without validators"); - - //if saving with validators didn't work, try to save it without using validators - String saveWithoutValidators = "file:*"; - Object secondAttemptResult = tryToSave(dataToSave, saveWithoutValidators); - if (secondAttemptResult instanceof Boolean) { - boolean succeeded = ((Boolean) secondAttemptResult).booleanValue(); - if (succeeded) { - return null; //FILE SAVED SUCCESSFULLY. DONE. - } else { - throw new AlgorithmExecutionException("No converters found that could save file. Save failed"); - } - } else { //result instanceof Exception - Exception reasonForFailure2 = (Exception) secondAttemptResult; - throw new AlgorithmExecutionException("Exception occurred while attempting to save", reasonForFailure2); - } + return null; } - //returns True if save was successful - //return False if there are no converter chains available to save to the given format - //return an Exception if an exception occurred while attempting to save - private Object tryToSave(final Data dataToSave, String formatToSaveTo) { - final Converter[] converters = conversionManager.findConverters(dataToSave, formatToSaveTo); - if (converters.length == 0) {return new Boolean(false);}; + private void tryToSave(final Data outData, String outFormat) + throws AlgorithmExecutionException { + final Converter[] converters = + conversionManager.findConverters(outData, outFormat); + if (converters.length == 0) { + throw new AlgorithmExecutionException( + "Error: Calculated an empty converter chain."); + } - parentShell = PlatformUI.getWorkbench().getWorkbenchWindows()[0].getShell(); - if (parentShell.isDisposed()) {return makeParentShellDisposedException();}; + parentShell = + PlatformUI.getWorkbench().getWorkbenchWindows()[0].getShell(); + if (parentShell.isDisposed()) { + throw new AlgorithmExecutionException( + "Attempted to use disposed parent shell."); + } try { - guiRun(new Runnable() { - public void run() { - if (converters.length == 1){ - //only one possible choice in how to save data. Just do it. - Converter onlyConverter = converters[0]; - final FileSaver saver = new FileSaver(parentShell, context); - saver.save(onlyConverter, dataToSave); - } else { //converters.length > 1 - //multiple ways to save the data. Let user choose. - SaveDataChooser saveChooser = new SaveDataChooser(dataToSave, - parentShell, converters, "Save", context); - saveChooser.createContent(new Shell(parentShell)); - saveChooser.open(); - } - }}); + guiRun(new Runnable() { + public void run() { + if (converters.length == 1) { + // Only one possible choice in how to save data. Do it. + Converter onlyConverter = converters[0]; + final FileSaver saver = + new FileSaver(parentShell, context); + saver.save(onlyConverter, outData); + } else { + // Multiple ways to save the data. Let user choose. + SaveDataChooser saveChooser = + new SaveDataChooser(outData, + parentShell, + converters, + SAVE_DIALOG_TITLE, + context); + saveChooser.createContent(new Shell(parentShell)); + saveChooser.open(); + } + } + }); } catch (Exception e) { - return e; + throw new AlgorithmExecutionException(e.getMessage(), e); } - - return new Boolean(true); } - private AlgorithmExecutionException makeParentShellDisposedException() { - return new AlgorithmExecutionException("Attempted to use disposed parent shell"); - } - private void guiRun(Runnable run) { if (Thread.currentThread() == Display.getDefault().getThread()) { run.run(); @@ -145,29 +108,4 @@ parentShell.getDisplay().syncExec(run); } } - - private class NoConversionConverter implements Converter { - Dictionary props = new Hashtable(); - - public Data convert(Data data) { - return data; - } - - public AlgorithmFactory getAlgorithmFactory() { - return null; - } - - public ServiceReference[] getConverterChain() { - return null; - } - - public Dictionary getProperties() { - props.put(AlgorithmProperty.OUT_DATA, "file:*"); - return props; - } - } - - private Data removeExtension(Data data) { - return new BasicData(data.getMetadata(), data, ""); - } } \ No newline at end of file Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveDataChooser.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveDataChooser.java 2009-07-31 20:40:05 UTC (rev 911) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveDataChooser.java 2009-08-03 16:33:43 UTC (rev 912) @@ -308,12 +308,12 @@ * of opening the FileSaver and saving the model. * @param selectedIndex The chosen converter */ - protected void selectionMade(int selectedIndex){ + protected void selectionMade(int selectedIndex) { try { - getShell().setVisible(false); - final Converter converter = converterArray[selectedIndex]; - final FileSaver saver = new FileSaver(getShell(), context); - close(saver.save(converter, data)); + getShell().setVisible(false); + final Converter converter = converterArray[selectedIndex]; + final FileSaver saver = new FileSaver(getShell(), context); + close(saver.save(converter, data)); } catch (Exception e) { throw new RuntimeException(e); } @@ -328,34 +328,38 @@ public void createDialogButtons(Composite parent) { Button select = new Button(parent, SWT.PUSH); select.setText("Select"); - select.addSelectionListener(new SelectionAdapter() { + select.addSelectionListener( + new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { int index = converterList.getSelectionIndex(); - + if (index != -1) { selectionMade(index); } } - }); + } + ); Button cancel = new Button(parent, SWT.NONE); cancel.setText("Cancel"); - cancel.addSelectionListener(new SelectionAdapter() { + cancel.addSelectionListener( + new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { close(false); } - }); + } + ); } /** * Checks for the number of file savers. If there is one - * converter then it will save directly, otherwise intialize the chooser. + * converter then it will save directly, otherwise initialize the chooser. * * @param parent The parent GUI for new dialog windows. */ public Composite createContent(Composite parent) { if (converterArray.length == 1) { - final FileSaver saver = new FileSaver((Shell)parent, context); + final FileSaver saver = new FileSaver((Shell) parent, context); close(saver.save(converterArray[0], data)); return parent; } @@ -365,31 +369,30 @@ } private class CompareAlphabetically implements Comparator { - public int compare(Object o1, Object o2) { - if (o1 instanceof Converter && o2 instanceof Converter) { - Converter c1 = (Converter) o1; - String c1Label = getLabel(c1); - - Converter c2 = (Converter) o2; - String c2Label = getLabel(c2); - - if (c1Label != null && c2Label != null) { - return c1Label.compareTo(c2Label); - } else if (c1Label == null) { - //c1 > c2 - return 1; - } else if (c2Label == null) { - //c1 < c2 - return -1; - } else { - //c1 == c2 - return 0; - } - } else { - throw new IllegalArgumentException("Can only " + - "compare Converters"); - } + if (o1 instanceof Converter && o2 instanceof Converter) { + Converter c1 = (Converter) o1; + String c1Label = getLabel(c1); + + Converter c2 = (Converter) o2; + String c2Label = getLabel(c2); + + if (c1Label != null && c2Label != null) { + return c1Label.compareTo(c2Label); + } else if (c1Label == null) { + //c1 > c2 + return 1; + } else if (c2Label == null) { + //c1 < c2 + return -1; + } else { + //c1 == c2 + return 0; + } + } else { + throw new IllegalArgumentException("Can only " + + "compare Converters"); + } } private String getLabel(Converter c) { Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/FileView.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/FileView.java 2009-07-31 20:40:05 UTC (rev 911) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/FileView.java 2009-08-03 16:33:43 UTC (rev 912) @@ -27,266 +27,269 @@ * @author Weixia(Bonnie) Huang (hu...@in...) */ public class FileView implements Algorithm { - Data[] data; - Dictionary parameters; - CIShellContext context; - DataConversionService conversionManager; - LogService logger; - Program program; - // Program programTwo; - File tempFile; - - public FileView(Data[] data, Dictionary parameters, CIShellContext context) { - this.data = data; - this.parameters = parameters; - this.context = context; - - conversionManager = (DataConversionService) context.getService( - DataConversionService.class.getName()); - - logger = (LogService)context.getService(LogService.class.getName()); - } + public static final String ANY_FILE_EXTENSION_FILTER = "file-ext:*"; + private static final String CSV_FILE_EXT = "file-ext:csv"; + private static final String CSV_MIME_TYPE = "file:text/csv"; + public static final String FILE_EXTENSION_PREFIX = "file-ext:"; + public static final String ANY_TEXT_MIME_TYPE = "file:text/"; + private Data[] data; + private CIShellContext context; + private DataConversionService conversionManager; + private LogService logger; + private Program program; + private File tempFile; + - //show the contents of a file to the user - public Data[] execute() throws AlgorithmExecutionException { - try { - boolean lastSaveSuccessful = false; - boolean isCSVFile = false; - String format; - - //tempFile = getTempFile(); TC181 - - - //for each data item we want to view... - for (int i = 0; i < data.length; i++){ - Object theData = data[i].getData(); - format = data[i].getFormat(); - String label = (String) data[i].getMetadata().get(DataProperty.LABEL); - - //if it is a text file... - if (theData instanceof File || - format.startsWith("file:text/") || - format.startsWith("file-ext:")){ - - //if it is a csv text file... - if (format.startsWith("file:text/csv") || format.startsWith("file-ext:csv")) - { - //prepare to open it like a csv file - tempFile = getTempFileCSV(); - isCSVFile = true; - - } - else //it is just a regular text file - { - //prepare to open it like a normal text file - String fileName = FileUtil.extractFileName(label); - String extension = FileUtil.extractExtension(format); - tempFile = FileUtil.getTempFile(fileName, extension, logger); - } - - //copy out data into the temp file we just created. - copy((File)data[i].getData(), tempFile); - lastSaveSuccessful = true; - - - - }else {//the data item is in an in-memory format, and must be converted to a file format before the user can see it - - final Converter[] convertersCSV = conversionManager.findConverters(data[i], "file-ext:csv"); - - //if the data item can be converted to a csv file ... do it. - if (convertersCSV.length == 1) - { - Data newDataCSV = convertersCSV[0].convert(data[i]); - tempFile = getTempFileCSV(); - isCSVFile = true; - copy((File)newDataCSV.getData(), tempFile); - lastSaveSuccessful = true; - - } - else if (convertersCSV.length > 1) - { - Data newDataCSV = convertersCSV[0].convert(data[i]); - for (int j = 1; j < convertersCSV.length; j++ ) - { - newDataCSV = convertersCSV[j].convert(newDataCSV); - } - tempFile = getTempFileCSV(); - isCSVFile = true; - copy((File)newDataCSV.getData(), tempFile); - lastSaveSuccessful = true; - } else { //it cannot be converted to a .csv - - //try to convert it to any other file format - - final Converter[] converters = conversionManager.findConverters(data[i], "file-ext:*"); - - //if it can't be converted to any file format... - if (converters.length < 1) { - //throw an error - throw new AlgorithmExecutionException("No valid converters for data type: " + - data[i].getData().getClass().getName() + - ". Please install a plugin that will save the data type to a file"); - } - else if (converters.length == 1){ //if there is only file format it can be converted to - //go ahead and convert the data item to that format - Data newData = converters[0].convert(data[i]); - - String fileName = FileUtil.extractFileName(label); - String extension = FileUtil.extractExtension(newData.getFormat()); - tempFile = FileUtil.getTempFile(fileName, extension, logger); - copy((File)newData.getData(), tempFile); - lastSaveSuccessful = true; - } - else { //there is more than one format that the data item could be converted to - - //let the user choose - - //(get some eclipse UI stuff that we need to open the data viewer) - - Display display; - IWorkbenchWindow[] windows; - final Shell parentShell; - - windows = PlatformUI.getWorkbench().getWorkbenchWindows(); - if (windows.length == 0){ - throw new AlgorithmExecutionException("Cannot get workbench window."); - } - parentShell = windows[0].getShell(); - display = PlatformUI.getWorkbench().getDisplay(); - - //(open the data viewer, which lets the user choose which format they want to see the data item in.) - - if (!parentShell.isDisposed()) { - DataViewer dataViewer = new DataViewer(parentShell, data[i], converters); - display.syncExec(dataViewer); - lastSaveSuccessful = dataViewer.isSaved; - tempFile = dataViewer.outputFile; - } - } - } - } - - //if it's a CSV file - if (isCSVFile){//TC181 - //prepare to open the file with the default csv program - Display.getDefault().syncExec(new Runnable() { - public void run() { - program = Program.findProgram("csv"); - }}); - - }else - {//it's any other file - //prepare to open it with the standard text editor. - Display.getDefault().syncExec(new Runnable() { - public void run() { - program = Program.findProgram("txt"); - }}); - - } - - /* - Display.getDefault().syncExec(new Runnable() { - public void run() { - programTwo = Program.findProgram("doc"); - }}); - - if (programTwo == null) { - System.out.println("***\nYO!\nNo doc viewer\n"); - } else { - System.out.println("!!!\nHEY!\nDoc viewer found\n"); - - } - */ - - //if we can't find any program to open the file... - if (program == null) { - //throw an error - throw new AlgorithmExecutionException( - "No valid text viewer for the .txt file. " + - "The file is located at: "+tempFile.getAbsolutePath() + - ". Unable to open default text viewer. File is located at: "+ - tempFile.getAbsolutePath()); - } - else {//we found a program to open the file - //open it, for real. - if (lastSaveSuccessful == true) { - Display.getDefault().syncExec(new Runnable() { - public void run() { - program.execute(tempFile.getAbsolutePath()); - }}); - } - } - } - return null; - } catch (ConversionException e1) { - throw new AlgorithmExecutionException("Error converting data to target view format.", e1); - } catch (Throwable e2){ - throw new AlgorithmExecutionException(e2); - } - } - - public File getTempFileCSV(){ //TC181 - File tempFile; - - String tempPath = System.getProperty("java.io.tmpdir"); - File tempDir = new File(tempPath+File.separator+"temp"); - if(!tempDir.exists()) - tempDir.mkdir(); - try{ - tempFile = File.createTempFile("xxx-Session-", ".csv", tempDir); - - }catch (IOException e){ - logger.log(LogService.LOG_ERROR, e.toString(), e); - tempFile = new File (tempPath+File.separator+"temp"+File.separator+"temp.csv"); + public FileView(Data[] data, Dictionary parameters, CIShellContext context) { + this.data = data; + this.context = context; - } - return tempFile; - } - - public static boolean copy(File in, File out) throws AlgorithmExecutionException{ - try { - FileInputStream fis = new FileInputStream(in); - FileOutputStream fos = new FileOutputStream(out); - - FileChannel readableChannel = fis.getChannel(); - FileChannel writableChannel = fos.getChannel(); - - writableChannel.truncate(0); - writableChannel.transferFrom(readableChannel, 0, readableChannel.size()); - fis.close(); - fos.close(); - return true; - } - catch (IOException ioe) { - throw new AlgorithmExecutionException("IOException during copy", ioe); - } - } - - final class DataViewer implements Runnable { - Shell shell; - boolean isSaved; - File outputFile; - Data theData; - Converter[] theConverters; + this.conversionManager = (DataConversionService) context + .getService(DataConversionService.class.getName()); + + this.logger = (LogService) context.getService(LogService.class.getName()); + } + + + // Show the contents of a file to the user + public Data[] execute() throws AlgorithmExecutionException { + try { + boolean lastSaveSuccessful = false; + boolean isCSVFile = false; + String format; + + // For each data item we want to view... + for (int i = 0; i < data.length; i++) { + Object theData = data[i].getData(); + format = data[i].getFormat(); + String label = (String) data[i].getMetadata().get( + DataProperty.LABEL); + + // If it is a text file... + if (theData instanceof File + || format.startsWith(ANY_TEXT_MIME_TYPE) + || format.startsWith(FILE_EXTENSION_PREFIX)) { + + // If it is a CSV text file... + if (format.startsWith(CSV_MIME_TYPE) + || format.startsWith(CSV_FILE_EXT)) { + // Prepare to open it like a CSV file + tempFile = getTempFileCSV(); + isCSVFile = true; + } else { + // Prepare to open it like a normal text file + String fileName = FileUtil.extractFileName(label); + String extension = FileUtil.extractExtension(format); + tempFile = FileUtil.getTempFile(fileName, extension, + logger); + } + + // Copy out data into the temp file we just created. + copy((File) data[i].getData(), tempFile); + lastSaveSuccessful = true; + + } else { + /* The data item is in an in-memory format, and must be + * converted to a file format before the user can see it. + */ + final Converter[] convertersCSV = + conversionManager.findConverters(data[i], CSV_FILE_EXT); + + // If the data item can be converted to a CSV file, do so. + if (convertersCSV.length == 1) { + Data newDataCSV = convertersCSV[0].convert(data[i]); + tempFile = getTempFileCSV(); + isCSVFile = true; + copy((File) newDataCSV.getData(), tempFile); + lastSaveSuccessful = true; + + } else if (convertersCSV.length > 1) { + Data newDataCSV = convertersCSV[0].convert(data[i]); + for (int j = 1; j < convertersCSV.length; j++) { + newDataCSV = convertersCSV[j].convert(newDataCSV); + } + tempFile = getTempFileCSV(); + isCSVFile = true; + copy((File) newDataCSV.getData(), tempFile); + lastSaveSuccessful = true; + } else { // it cannot be converted to a .csv + + // try to convert it to any other file format + + final Converter[] converters = + conversionManager.findConverters( + data[i], ANY_FILE_EXTENSION_FILTER); + + // if it can't be converted to any file format... + if (converters.length < 1) { + // throw an error + throw new AlgorithmExecutionException( + "No valid converters for data type: " + + data[i].getData().getClass() + .getName() + + ". Please install a plugin that will save the data type to a file"); + } else if (converters.length == 1) { // if there is only + // file format + // it can be + // converted to + // go ahead and convert the data item to that format + Data newData = converters[0].convert(data[i]); + + String fileName = FileUtil.extractFileName(label); + String extension = FileUtil + .extractExtension(newData.getFormat()); + tempFile = FileUtil.getTempFile(fileName, + extension, logger); + copy((File) newData.getData(), tempFile); + lastSaveSuccessful = true; + } else { + // there is more than one format that the data + // item could be converted to + // let the user choose + // (get some eclipse UI stuff that we need to open + // the data viewer) + + Display display; + IWorkbenchWindow[] windows; + final Shell parentShell; + + windows = PlatformUI.getWorkbench() + .getWorkbenchWindows(); + if (windows.length == 0) { + throw new AlgorithmExecutionException( + "Cannot get workbench window."); + } + parentShell = windows[0].getShell(); + display = PlatformUI.getWorkbench().getDisplay(); + + // (open the data viewer, which lets the user choose + // which format they want to see the data item in.) + + if (!parentShell.isDisposed()) { + DataViewer dataViewer = new DataViewer( + parentShell, data[i], converters); + display.syncExec(dataViewer); + lastSaveSuccessful = dataViewer.isSaved; + tempFile = dataViewer.outputFile; + } + } + } + } + + // If it's a CSV file + if (isCSVFile) {// TC181 + // prepare to open the file with the default csv program + Display.getDefault().syncExec(new Runnable() { + public void run() { + program = Program.findProgram("csv"); + } + }); + } else { + // Prepare to open it with the standard text editor. + Display.getDefault().syncExec( + new Runnable() { + public void run() { + program = Program.findProgram("txt"); + } + } + ); + } + + // If we can't find any program to open the file... + if (program == null) { + throw new AlgorithmExecutionException( + "No valid text viewer for the .txt file. " + + "The file is located at: " + + tempFile.getAbsolutePath() + + ". Unable to open default text viewer. " + + "File is located at: " + + tempFile.getAbsolutePath()); + } else { + // We found a program to open the file. Open it. + if (lastSaveSuccessful == true) { + Display.getDefault().syncExec( + new Runnable() { + public void run() { + program.execute(tempFile.getAbsolutePath()); + } + } + ); + } + } + } - DataViewer (Shell parentShell, Data data, Converter[] converters){ + return null; + } catch (ConversionException e) { + throw new AlgorithmExecutionException( + "Error: Unable to view data:\n " + e.getMessage(), e); + } catch (Throwable e) { + throw new AlgorithmExecutionException(e); + } + } + + public File getTempFileCSV() { + File tempFile; + + String tempPath = System.getProperty("java.io.tmpdir"); + File tempDir = new File(tempPath + File.separator + "temp"); + if (!tempDir.exists()) + tempDir.mkdir(); + try { + tempFile = File.createTempFile("xxx-Session-", ".csv", tempDir); + + } catch (IOException e) { + logger.log(LogService.LOG_ERROR, e.toString(), e); + tempFile = new File(tempPath + File.separator + "temp" + + File.separator + "temp.csv"); + + } + return tempFile; + } + + public static boolean copy(File in, File out) + throws AlgorithmExecutionException { + try { + FileInputStream fis = new FileInputStream(in); + FileOutputStream fos = new FileOutputStream(out); + + FileChannel readableChannel = fis.getChannel(); + FileChannel writableChannel = fos.getChannel(); + + writableChannel.truncate(0); + writableChannel.transferFrom(readableChannel, 0, readableChannel + .size()); + fis.close(); + fos.close(); + return true; + } catch (IOException ioe) { + throw new AlgorithmExecutionException("IOException during copy", + ioe); + } + } + + final class DataViewer implements Runnable { + public static final String VIEW_DIALOG_TITLE = "View"; + private Shell shell; + private boolean isSaved; + private File outputFile; + private Data data; + private Converter[] converters; + + + DataViewer(Shell parentShell, Data data, Converter[] converters) { this.shell = parentShell; - this.theData = data; - this.theConverters = converters; + this.data = data; + this.converters = converters; } + public void run() { - // lots of persisters found, return the chooser - ViewDataChooser vdc = new ViewDataChooser("View", shell, - theData, theConverters, context, logger); + // Lots of persisters found, return the chooser + ViewDataChooser vdc = new ViewDataChooser( + VIEW_DIALOG_TITLE, shell, data, converters, context, logger); vdc.open(); isSaved = vdc.isSaved(); outputFile = vdc.outputFile; } } - - - - } \ No newline at end of file Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/ViewDataChooser.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/ViewDataChooser.java 2009-07-31 20:40:05 UTC (rev 911) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/view/ViewDataChooser.java 2009-08-03 16:33:43 UTC (rev 912) @@ -3,10 +3,12 @@ import java.io.File; import org.cishell.framework.CIShellContext; +import org.cishell.framework.algorithm.AlgorithmExecutionException; import org.cishell.framework.data.Data; import org.cishell.framework.data.DataProperty; import org.cishell.reference.gui.persistence.FileUtil; import org.cishell.reference.gui.persistence.save.SaveDataChooser; +import org.cishell.service.conversion.ConversionException; import org.cishell.service.conversion.Converter; import org.eclipse.swt.widgets.Shell; import org.osgi.service.log.LogService; @@ -29,20 +31,29 @@ this.logger = logger; } - protected void selectionMade(int selectedIndex){ - try { + protected void selectionMade(int selectedIndex) { getShell().setVisible(false); final Converter converter = converterArray[selectedIndex]; - Data newData = converter.convert(theData); - String label = (String) newData.getMetadata().get(DataProperty.LABEL); - String fileName = FileUtil.extractFileName(label); - String extension = FileUtil.extractExtension(newData.getFormat()); - File tempFile = FileUtil.getTempFile(fileName, extension, logger); - isSaved = FileView.copy((File)newData.getData(), tempFile); - outputFile = tempFile; - close(true); - } catch (Exception e) { - throw new RuntimeException(e); + + try { + Data newData = converter.convert(theData); + String label = (String) newData.getMetadata().get(DataProperty.LABEL); + String fileName = FileUtil.extractFileName(label); + String extension = FileUtil.extractExtension(newData.getFormat()); + File tempFile = FileUtil.getTempFile(fileName, extension, logger); + + try { + isSaved = FileView.copy((File)newData.getData(), tempFile); + } catch (AlgorithmExecutionException e) { + logger.log(LogService.LOG_ERROR, "Error copying view for view:\n " + e.getMessage(), e); + return; + } + + outputFile = tempFile; + close(true); + } catch (ConversionException e) { + logger.log(LogService.LOG_ERROR, "Error: Unable to view data:\n " + e.getMessage(), e); + return; } } Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/viewwith/FileViewWith.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/viewwith/FileViewWith.java 2009-07-31 20:40:05 UTC (rev 911) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/viewwith/FileViewWith.java 2009-08-03 16:33:43 UTC (rev 912) @@ -107,11 +107,11 @@ //If length=1, use the unique path to save it directly //and bring the text editor. try { - Data newData = converters[0].convert(data[i]); - copy((File)newData.getData(), tempFile); - lastSaveSuccessful = true; + Data newData = converters[0].convert(data[i]); + copy((File)newData.getData(), tempFile); + lastSaveSuccessful = true; } catch (ConversionException e) { - this.logger.log(LogService.LOG_WARNING, "Error while converting to target save format. Will attempt to use other available converters.", e); + this.logger.log(LogService.LOG_WARNING, "Warning: Unable to convert to target save format (" + e.getMessage() + "). Will attempt to use other available converters.", e); } } else { Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/viewwith/ViewWithDataChooser.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/viewwith/ViewWithDataChooser.java 2009-07-31 20:40:05 UTC (rev 911) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/viewwith/ViewWithDataChooser.java 2009-08-03 16:33:43 UTC (rev 912) @@ -28,11 +28,13 @@ protected void selectionMade(int selectedIndex){ try { - getShell().setVisible(false); - final Converter converter = converterArray[selectedIndex]; - Data newData = converter.convert(theData); - isSaved = FileViewWith.copy((File)newData.getData(), tempFile); - close(true); + getShell().setVisible(false); + final Converter converter = converterArray[selectedIndex]; + Data newData = converter.convert(theData); + isSaved = FileViewWith.copy((File)newData.getData(), tempFile); + close(true); + } catch (ConversionException e) { + throw new RuntimeException("Error: Unable to view data:\n " + e.getMessage(), e); } catch (Exception e) { throw new RuntimeException(e); } Modified: trunk/core/org.cishell.reference/.classpath =================================================================== --- trunk/core/org.cishell.reference/.classpath 2009-07-31 20:40:05 UTC (rev 911) +++ trunk/core/org.cishell.reference/.classpath 2009-08-03 16:33:43 UTC (rev 912) @@ -1,7 +1,7 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" path="src"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry kind="output" path="bin"/> -</classpath> +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/j2sdk1.4.2_19"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="output" path="bin"/> +</classpath> Added: trunk/core/org.cishell.reference/.settings/org.eclipse.jdt.core.prefs =================================================================== --- trunk/core/org.cishell.reference/.settings/org.eclipse.jdt.core.prefs (rev 0) +++ trunk/core/org.cishell.reference/.settings/org.eclipse.jdt.core.prefs 2009-08-03 16:33:43 UTC (rev 912) @@ -0,0 +1,12 @@ +#Mon Jul 27 15:45:33 EDT 2009 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.4 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning +org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning +org.eclipse.jdt.core.compiler.source=1.3 Modified: trunk/core/org.cishell.reference/src/org/cishell/reference/service/conversion/ConverterImpl.java =================================================================== --- trunk/core/org.cishell.reference/src/org/cishell/reference/service/conversion/ConverterImpl.java 2009-07-31 20:40:05 UTC (rev 911) +++ trunk/core/org.cishell.reference/src/org/cishell/reference/service/conversion/ConverterImpl.java 2009-08-03 16:33:43 UTC (rev 912) @@ -29,73 +29,69 @@ import org.osgi.framework.BundleContext; import org.osgi.framework.Constants; import org.osgi.framework.ServiceReference; +import org.osgi.service.log.LogService; import org.osgi.service.metatype.MetaTypeProvider; -/** - * - * @author Bruce Herr (bh...@bh...) - */ public class ConverterImpl implements Converter, AlgorithmFactory, AlgorithmProperty { private ServiceReference[] refs; private BundleContext bContext; - private Dictionary props; + private Dictionary properties; private CIShellContext ciContext; + public ConverterImpl(BundleContext bContext, CIShellContext ciContext, ServiceReference[] refs) { this.bContext = bContext; this.ciContext = ciContext; this.refs = refs; - props = new Hashtable(); - props.put(IN_DATA, refs[0].getProperty(IN_DATA)); - props.put(OUT_DATA, refs[refs.length-1].getProperty(OUT_DATA)); - props.put(LABEL, props.get(IN_DATA) + " -> " + props.get(OUT_DATA)); + properties = new Hashtable(); + properties.put(IN_DATA, refs[0].getProperty(IN_DATA)); + properties.put(OUT_DATA, refs[refs.length-1].getProperty(OUT_DATA)); + properties.put(LABEL, properties.get(IN_DATA) + " -> " + properties.get(OUT_DATA)); + // TODO: Do the same thing for complexity String lossiness = calculateLossiness(refs); - props.put(CONVERSION, lossiness); + properties.put(CONVERSION, lossiness); } /** * @see org.cishell.service.conversion.Converter#convert(org.cishell.framework.data.Data) */ - public Data convert(Data inDM) throws ConversionException { - Data[] dm = new Data[]{inDM}; + public Data convert(Data inData) throws ConversionException { + Data[] data = new Data[]{inData}; AlgorithmFactory factory = getAlgorithmFactory(); - Algorithm alg = factory.createAlgorithm(dm, new Hashtable(), ciContext); + Algorithm algorithm = factory.createAlgorithm(data, new Hashtable(), ciContext); try { - dm = alg.execute(); - } catch (AlgorithmExecutionException aee) { - throw new ConversionException( - "Problem converting data: " + aee.getMessage(), - aee); + data = algorithm.execute(); + } catch (AlgorithmExecutionException e) { + throw new ConversionException(e.getMessage(), e); } catch (Exception e) { throw new ConversionException( - "Problem converting data: " + e.getMessage(), - e); + "Unexpected error: " + e.getMessage(), e); } Object outData = null; - if (dm != null && dm.length > 0) { - outData = dm[0].getData(); + if (data != null && data.length > 0) { + outData = data[0].getData(); } if (outData != null) { - Dictionary props = inDM.getMetadata(); - Dictionary newProps = new Hashtable(); + Dictionary properties = inData.getMetadata(); + Dictionary newProperties = new Hashtable(); - for (Enumeration e = props.keys(); e.hasMoreElements();) { - Object key = e.nextElement(); - newProps.put(key, props.get(key)); + for (Enumeration propertyKeys = properties.keys(); propertyKeys.hasMoreElements();) { + Object key = propertyKeys.nextElement(); + newProperties.put(key, properties.get(key)); } String outFormat = (String) getProperties().get(AlgorithmProperty.OUT_DATA); - return new BasicData(newProps, outData, outFormat); + return new BasicData(newProperties, outData, outFormat); } else { return null; } @@ -120,7 +116,7 @@ * @see org.cishell.service.conversion.Converter#getProperties() */ public Dictionary getProperties() { - return props; + return properties; } public Algorithm createAlgorithm(Data[] dm, @@ -186,37 +182,141 @@ } private class ConverterAlgorithm implements Algorithm { - Data[] inDM; - CIShellContext context; - Dictionary parameters; + public static final String FILE_EXTENSION_PREFIX = "file-ext:"; + public static final String MIME_TYPE_PREFIX = "file:"; + + private Data[] inData; + private Dictionary parameters; + private CIShellContext context; + private LogService log; - public ConverterAlgorithm(Data[] dm, + + public ConverterAlgorithm(Data[] inData, Dictionary parameters, CIShellContext context) { - this.inDM = dm; + this.inData = inData; this.parameters = parameters; this.context = context; + this.log = + (LogService) context.getService(LogService.class.getName()); } + public Data[] execute() throws AlgorithmExecutionException { - Data[] dm = inDM; - for (int i = 0; i < refs.length; i++) { + Data[] convertedData = inData; + + // For each converter in the converter chain (refs) + for (int ii = 0; ii < refs.length; ii++) { AlgorithmFactory factory = - (AlgorithmFactory) bContext.getService(refs[i]); + (AlgorithmFactory) bContext.getService(refs[ii]); if (factory != null) { Algorithm alg = - factory.createAlgorithm(dm, parameters, context); + factory.createAlgorithm(convertedData, parameters, context); - dm = alg.execute(); + try { + convertedData = alg.execute(); + } catch(AlgorithmExecutionException e) { + boolean isLastStep = (ii == refs.length - 1); + if (isLastStep && isHandler(refs[ii])) { + /* If the last step of the converter chain is a + * handler and it is the first (and so only) step + * to fail, just log a warning and return the + * un-handled data. + */ + String warningMessage = + "Warning: Attempting to convert data without " + + "validating the output since the validator failed " + + "with this problem:\n " + + createErrorMessage(refs[ii], e); + + log.log(LogService.LOG_WARNING, warningMessage, e); + + return convertedData; + } else { + throw new AlgorithmExecutionException( + createErrorMessage(refs[ii], e), e); + } + } } else { throw new AlgorithmExecutionException( - "Missing subconverter: " - + refs[i].getProperty(Constants.SERVICE_PID)); + "Missing subconverter: " + + refs[ii].getProperty(Constants.SERVICE_PID)); } } - return dm; + return convertedData; } + + private boolean isHandler(ServiceReference ref) { + /* For some reason, handlers are often referred to as validators, + * though strictly speaking, validators are for reading in data and + * handlers are for writing out data. + */ + String algorithmType = + (String) ref.getProperty(AlgorithmProperty.ALGORITHM_TYPE); + boolean algorithmTypeIsValidator = + AlgorithmProperty.TYPE_VALIDATOR.equals(algorithmType); + + String inDataType = + (String) ref.getProperty(AlgorithmProperty.IN_DATA); + boolean inDataTypeIsFile = inDataType.startsWith(MIME_TYPE_PREFIX); + + String outDataType = + (String) ref.getProperty(AlgorithmProperty.OUT_DATA); + boolean outDataTypeIsFileExt = + outDataType.startsWith(FILE_EXTENSION_PREFIX); + + return (algorithmTypeIsValidator + && inDataTypeIsFile + && outDataTypeIsFileExt); + } + + private String createErrorMessage(ServiceReference ref, Throwable e) { + String inType = (String) properties.get(IN_DATA); + String preProblemType = (String) ref.getProperty(IN_DATA); + String postProblemType = (String) ref.getProperty(OUT_DATA); + String outType = (String) properties.get(OUT_DATA); + + /* Only report the intermediate conversion if it is different + * from the overall conversion. + */ + if (inType.equals(preProblemType) + && outType.equals(postProblemType)) { + return "Problem converting data from " + + prettifyDataType(inType) + + " to " + prettifyDataType(outType) + + " (See the log file for more details).:\n ... [truncated message content] |
From: <tan...@us...> - 2009-07-31 20:40:19
|
Revision: 911 http://cishell.svn.sourceforge.net/cishell/?rev=911&view=rev Author: tankchintan Date: 2009-07-31 20:40:05 +0000 (Fri, 31 Jul 2009) Log Message: ----------- Developed the functionality where description of any parameters in the dialog box pops out whenever a icon is clicked. Featured developed by Chintan. Code reviewed & refactored by Micah. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/.project trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/META-INF/MANIFEST.MF trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/LabelingComponent.java Modified: trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/.project =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/.project 2009-07-31 18:53:20 UTC (rev 910) +++ trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/.project 2009-07-31 20:40:05 UTC (rev 911) @@ -1,28 +1,28 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>org.cishell.reference.gui.guibuilder.swt</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.ManifestBuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.SchemaBuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.pde.PluginNature</nature> - <nature>org.eclipse.jdt.core.javanature</nature> - </natures> -</projectDescription> +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.cishell.reference.gui.guibuilder.swt</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> Modified: trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/META-INF/MANIFEST.MF =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/META-INF/MANIFEST.MF 2009-07-31 18:53:20 UTC (rev 910) +++ trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/META-INF/MANIFEST.MF 2009-07-31 20:40:05 UTC (rev 911) @@ -6,6 +6,7 @@ Bundle-Localization: plugin Import-Package: org.cishell.framework, org.cishell.service.guibuilder, + org.eclipse.ui, org.osgi.framework;version="1.3.0", org.osgi.service.metatype;version="1.1.0" Require-Bundle: org.eclipse.swt 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-07-31 18:53:20 UTC (rev 910) +++ trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/LabelingComponent.java 2009-07-31 20:40:05 UTC (rev 911) @@ -18,105 +18,285 @@ import org.cishell.reference.gui.guibuilder.swt.builder.StringConverter; import org.cishell.reference.gui.guibuilder.swt.builder.UpdateListener; import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; public class LabelingComponent extends AbstractComponent implements UpdateListener { - private GUIComponent childComponent; - private Label label; - private Label description; + private static final String DEFAULT_DESCRIPTION_TEXT = "No help text available."; + private static final Color DESCRIPTION_BGCOLOR = new Color(null, 250, 250, 210); + private static final int DESCRIPTION_SHELL_LEFT_MARGIN = 12; + private static final Point DESCRIPTION_SHELL_DIMENSIONS = new Point(250, 30); - public LabelingComponent(GUIComponent childComponent) { - super(true, childComponent.getColumns()); - this.childComponent = childComponent; - setAttributeDefinition(childComponent.getAttributeDefinition()); + private GUIComponent childComponent; + private Label label; - if (!childComponent.drawsLabel()) { - numColumns++; - } - - String description = attr.getDescription(); - if (description != null && description.length() > 0) { - numColumns++; - } - childComponent.addUpdateListener(this); - } + public LabelingComponent(GUIComponent childComponent) { + super(true, childComponent.getColumns()); + this.childComponent = childComponent; + setAttributeDefinition(childComponent.getAttributeDefinition()); - public Control createGUI(Composite parent, int style) { - if (drawsLabel && !childComponent.drawsLabel()) { - String labelText = attr.getName(); - - label = new Label(parent, SWT.NONE); - if (labelText == null) labelText = ""; - label.setText(labelText); - } + if (!childComponent.drawsLabel()) { + numColumns++; + } - Control control = childComponent.createGUI(parent, style); - setDefaultValue(); - - description = new Label(parent, SWT.NONE); - GridData gd = new GridData(SWT.END,SWT.CENTER,false,false); - description.setLayoutData(gd); - - //add a description tooltip and add to the gui - String descText = attr.getDescription(); - if (descText != null && descText.length() > 0) { - if (label != null) { - label.setToolTipText(descText); - } else { - control.setToolTipText(descText); - } - - Image image = parent.getDisplay().getSystemImage(SWT.ICON_QUESTION); - - Rectangle r = image.getBounds(); - - image = new Image(null, image.getImageData().scaledTo(r.width/2, r.height/2)); - - description.setToolTipText(descText); - description.setImage(image); - } - - return control; - } - - protected void setDefaultValue() { - String[] defaults = attr.getDefaultValue(); - - if (defaults != null && defaults.length > 0) { - - Object value = StringConverter.getInstance().stringToObject(attr, defaults[0]); - setValue(value); - } - } + String description = attr.getDescription(); + if (description != null && description.length() > 0) { + numColumns++; + } + childComponent.addUpdateListener(this); + } - public Object getValue() { - return childComponent.getValue(); - } + public Control createGUI(Composite parent, int style) { + if (drawsLabel && !childComponent.drawsLabel()) { - public void setValue(Object value) { - childComponent.setValue(value); - } + String labelText = attr.getName(); + if (labelText == null) { + labelText = ""; + } - public String validate() { - return childComponent.validate(); - } + label = new Label(parent, SWT.NONE); + label.setText(labelText); + } - 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(); - } + Control control = childComponent.createGUI(parent, style); + setDefaultValue(); + + createAndAddDescriptionButton(control, parent); + + return control; + } + + private void createAndAddDescriptionButton(Control control, Composite parent) { + + /* + * Create the description button, and add it to the parent. + * */ + Button descriptionButton = new Button(parent, SWT.TOGGLE); + + /* + * set the button's layout. + * */ + GridData grid = new GridData(SWT.END, SWT.CENTER, false, false); + descriptionButton.setLayoutData(grid); + + /* + * Give the button an image. + * */ + Image image = parent.getDisplay().getSystemImage(SWT.ICON_QUESTION); + Rectangle r = image.getBounds(); + image = new Image(null, image.getImageData().scaledTo(r.width / 2, + r.height / 2)); + descriptionButton.setImage(image); + + /* + * Handle displaying the description associated with the button. + * */ + String descriptionText = getDescriptionText(); + if (label != null) { + label.setToolTipText(descriptionText); + } else { + control.setToolTipText(descriptionText); + } + descriptionButton.setToolTipText(descriptionText); + DescriptionButtonListener listener = new DescriptionButtonListener(descriptionText); + descriptionButton.addSelectionListener(listener); + } + + /* + * 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; + + DescriptionButtonListener(String descText) { + this.descText = descText; + } + + public void widgetDefaultSelected(SelectionEvent arg0) { } + + public void widgetSelected(SelectionEvent arg0) { + Button descriptionButton = (Button) arg0.widget; + /* + * When the description button is selected, the toggle state on the + * button gets activated. On this create the hover containing the + * description information. + */ + if (descriptionButton.getSelection()) { + + /* + * To handle the event if the description is opened then closed + * & then user wants to open it again. In such a case we have to + * make sure that there is an object (Description Shell) to + * open. + */ + if (this.descriptionShell == null + || this.descriptionShell.isDisposed()) { + this.descriptionShell = new Shell(descriptionButton + .getShell(), SWT.NONE); + } + + /* + * Creation of a new description shell, which is a hover containing the + * description text. + */ + this.descriptionShell = createDescriptionShell(descText, descriptionButton); + + /* + * To get the absolute position of the opened dialog box. This will decide + * the position of the hover. + */ + Point absoluteShellPosition = descriptionButton.toDisplay( + descriptionButton.getBounds().width, 0); + setHoverLocation(descriptionShell, absoluteShellPosition); + + descriptionShell.open(); + } else { + + /* + * When the description button is pressed, the hover description + * needs to be removed. + */ + if (!descriptionShell.isDisposed()) { + descriptionShell.close(); + } + } + } + + + private Shell createDescriptionShell(final String descText, + Button descriptionButton) { + Shell descriptionShell = new Shell(descriptionButton.getShell(), SWT.NONE); + + descriptionShell.setLayout(new FillLayout()); + descriptionShell.setSize(DESCRIPTION_SHELL_DIMENSIONS); + + Text description = new Text(descriptionShell, SWT.MULTI + | SWT.V_SCROLL | SWT.WRAP | SWT.READ_ONLY); + + description.setText(descText); + + description.setBackground(DESCRIPTION_BGCOLOR); + + /* + * In order to enable the users to close the description by just + * pressing the ESC key. + */ + descriptionShell.addListener(SWT.Traverse, + new DescriptionShellListener(descriptionButton)); + return descriptionShell; + } + } + + /* + * Listener for Description Shell so that when ESC key is pressed it is closed. + * It does so by setting the state of the Button as false, which in turn + * triggers De-selection event of Button. + * */ + class DescriptionShellListener implements Listener { + + private Button descriptionButton; + + public DescriptionShellListener(Button descriptionButton) { + this.descriptionButton = descriptionButton; + } + + public void handleEvent(Event event) { + switch (event.detail) { + case SWT.TRAVERSE_ESCAPE: + + /* + * In order to reset the state of the Description button. + */ + descriptionButton.setSelection(false); + break; + default: + break; + } + } + } + + /** + * 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; + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fu...@us...> - 2009-07-31 18:53:45
|
Revision: 910 http://cishell.svn.sourceforge.net/cishell/?rev=910&view=rev Author: fugu13 Date: 2009-07-31 18:53:20 +0000 (Fri, 31 Jul 2009) Log Message: ----------- Add scrolling to parameter dialogue boxes. Reviewed by Micah. 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/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 2009-07-31 15:24:24 UTC (rev 909) +++ trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/SWTGui.java 2009-07-31 18:53:20 UTC (rev 910) @@ -25,6 +25,7 @@ import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; @@ -41,6 +42,8 @@ * @author Bruce Herr (bh...@bh...) */ public class SWTGui implements GUI, UpdateListener { + private static final int MAXIMUM_INITIAL_DIALOGUE_HEIGHT = 400; + public static final int TEXT_WRAP_LENGTH = 350; private Shell shell; @@ -60,7 +63,9 @@ ObjectClassDefinition ocd = provider.getObjectClassDefinition(id, null); shell.setText(ocd.getName()); - + + + GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 1; shell.setLayout(gridLayout); @@ -76,9 +81,7 @@ GridData labelData = new GridData(); labelData.horizontalAlignment = GridData.CENTER; labelData.grabExcessHorizontalSpace = true; - System.out.println(msg.getSize().x); if (msg.getSize().x > TEXT_WRAP_LENGTH) { - System.out.println(msg.getSize().x); labelData.widthHint = TEXT_WRAP_LENGTH; } msg.setLayoutData(labelData); @@ -163,8 +166,18 @@ shell.getDisplay().syncExec(new Runnable() { public void run() { shell.pack(); + resizeShell(shell); shell.open(); - }}); + } + + private void resizeShell(Shell shell) { + Point shellSize = shell.getSize(); + shell.setSize(shellSize.x, calculateNewDialogHeight(shellSize.y)); + } + + private int calculateNewDialogHeight(int proposedHeight) { + return Math.min(MAXIMUM_INITIAL_DIALOGUE_HEIGHT, proposedHeight); + }}); } /** 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 2009-07-31 15:24:24 UTC (rev 909) +++ trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/SWTGuiComposite.java 2009-07-31 18:53:20 UTC (rev 910) @@ -26,6 +26,7 @@ import org.eclipse.swt.custom.ScrolledComposite; import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; @@ -45,8 +46,8 @@ protected Set listeners; private Composite parent; - private Composite userArea; - private ScrolledComposite userScroll; + private Composite parameterArea; + private ScrolledComposite scroll; private int style; public SWTGuiComposite(Composite parent, int style, @@ -69,7 +70,7 @@ GUIComponent component = ComponentProvider.getInstance().createComponent(attrs[i]); component.setAttributeDefinition(attrs[i]); - component.createGUI(userArea, style); + component.createGUI(parameterArea, style); idToComponentMap.put(attrs[i].getID(), component); component.addUpdateListener(this); @@ -81,24 +82,32 @@ } } - userArea.addDisposeListener(new DisposeListener() { + setScrollDimensions(scroll, parameterArea); + + parameterArea.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { enteredResponses = getEnteredResponses(); }}); } + + private void setScrollDimensions(ScrolledComposite scroll, Composite innards) { + Point parameterAreaSize = innards.computeSize(SWT.DEFAULT, SWT.DEFAULT); + scroll.setMinWidth(parameterAreaSize.x); + scroll.setMinHeight(parameterAreaSize.y); + } private void setupGUI() { - userScroll = new ScrolledComposite(parent, style); - userScroll.setLayout(new GridLayout(1, true)); - userScroll.setExpandHorizontal(true); - userScroll.setExpandVertical(true); - userScroll.setAlwaysShowScrollBars(false); + 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); - userArea = new Composite(userScroll, SWT.NONE); - userArea.setLayout(new GridLayout(GUIComponent.MAX_SPAN+1,false)); + parameterArea = new Composite(scroll, SWT.NONE); + parameterArea.setLayout(new GridLayout(GUIComponent.MAX_SPAN+1,false)); GridData gd = new GridData(SWT.FILL,SWT.FILL,true,true); - userArea.setLayoutData(gd); + parameterArea.setLayoutData(gd); GridData userData = new GridData(); userData.grabExcessVerticalSpace = true; @@ -106,8 +115,8 @@ userData.verticalAlignment = SWT.FILL; userData.horizontalAlignment = SWT.FILL; - userScroll.setLayoutData(userData); - userScroll.setContent(userArea); + scroll.setLayoutData(userData); + scroll.setContent(parameterArea); } @@ -138,11 +147,11 @@ * @return the composite */ public Composite getUserArea() { - return userArea; + return parameterArea; } public Composite getComposite() { - return userScroll; + return scroll; } public String validate() { 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-07-31 15:24:24 UTC (rev 909) +++ trunk/clients/gui/org.cishell.reference.gui.guibuilder.swt/src/org/cishell/reference/gui/guibuilder/swt/builder/components/StringComponent.java 2009-07-31 18:53:20 UTC (rev 910) @@ -13,8 +13,6 @@ * ***************************************************************************/ package org.cishell.reference.gui.guibuilder.swt.builder.components; -import java.util.Arrays; - import org.cishell.reference.gui.guibuilder.swt.builder.AbstractComponent; import org.cishell.reference.gui.guibuilder.swt.builder.StringConverter; import org.eclipse.swt.SWT; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2009-07-31 15:24:34
|
Revision: 909 http://cishell.svn.sourceforge.net/cishell/?rev=909&view=rev Author: mwlinnem Date: 2009-07-31 15:24:24 +0000 (Fri, 31 Jul 2009) Log Message: ----------- Removing 'id' attribute (this was causing some confusion, as there was already an auto-generated id on the Jung graph). Modified Paths: -------------- trunk/core/org.cishell.algorithm.convertergraph/src/org/cishell/algorithm/convertergraph/ConverterGraphComputation.java Modified: trunk/core/org.cishell.algorithm.convertergraph/src/org/cishell/algorithm/convertergraph/ConverterGraphComputation.java =================================================================== --- trunk/core/org.cishell.algorithm.convertergraph/src/org/cishell/algorithm/convertergraph/ConverterGraphComputation.java 2009-07-30 21:35:14 UTC (rev 908) +++ trunk/core/org.cishell.algorithm.convertergraph/src/org/cishell/algorithm/convertergraph/ConverterGraphComputation.java 2009-07-31 15:24:24 UTC (rev 909) @@ -134,8 +134,7 @@ nodeCount++; Vertex node = new DirectedSparseVertex(); - - node.addUserDatum("id", nodeCount, new UserDataContainer.CopyAction.Shared()); + node.addUserDatum("strength", 1, new UserDataContainer.CopyAction.Shared()); node.addUserDatum("label", nodeKey, new UserDataContainer.CopyAction.Shared()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jrb...@us...> - 2009-07-30 21:35:37
|
Revision: 908 http://cishell.svn.sourceforge.net/cishell/?rev=908&view=rev Author: jrbibers Date: 2009-07-30 21:35:14 +0000 (Thu, 30 Jul 2009) Log Message: ----------- Moved apparently faulty Pajek NET test (TestFile9.net) to NotUsed folder. It didn't specify the number of vertices in the vertex section header and it is id'ed in a format that the Jung Pajek NET validator doesn't find agreeable (the maximum id exceeds the number of vertices). This change should probably be reflected in the deployed folder nwb/converter_test_files. Modified Paths: -------------- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/Full Converter.nwb Added Paths: ----------- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/Pajek NET Files/NotUsed/AHO3.NET trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/Pajek NET Files/NotUsed/LINKS.NET trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/Pajek NET Files/NotUsed/TestFile9.net Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/Full Converter.nwb =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/Full Converter.nwb 2009-07-30 16:57:02 UTC (rev 907) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/Full Converter.nwb 2009-07-30 21:35:14 UTC (rev 908) @@ -1,5 +1,8 @@ *Nodes id*int label*string +# TODO Shouldn't the file:application/pajek MIME type be deprecated? +# If so, regenerate this graph with only pajeknet and pajekmat +# MIME types floating around. 1 "file:application/pajek" 2 "file:text/nwb" 3 "file:text/edge" Added: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/Pajek NET Files/NotUsed/AHO3.NET =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/Pajek NET Files/NotUsed/AHO3.NET (rev 0) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/Pajek NET Files/NotUsed/AHO3.NET 2009-07-30 21:35:14 UTC (rev 908) @@ -0,0 +1,15 @@ +*Network aho3 +*Vertices 10 +*Edges +1 2 +1 3 +2 3 +2 4 +4 5 +5 6 +6 7 +5 7 +7 8 +8 9 +9 10 +8 10 \ No newline at end of file Added: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/Pajek NET Files/NotUsed/LINKS.NET =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/Pajek NET Files/NotUsed/LINKS.NET (rev 0) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/Pajek NET Files/NotUsed/LINKS.NET 2009-07-30 21:35:14 UTC (rev 908) @@ -0,0 +1,15 @@ +*Network TRALALA +*vertices 4 + 1 "1" 0.0938 0.0896 ellipse x_fact 1 y_fact 1 + 2 "2" 0.8188 0.2458 ellipse x_fact 1 y_fact 1 + 3 "3" 0.3688 0.7792 ellipse x_fact 1 + 4 "4" 0.9583 0.8563 ellipse x_fact 1 +*arcs +1 1 1 h2 0 w 3 c Blue s 3 a1 -130 k1 0.6 a2 -130 k2 0.6 ap 0.5 l "Bezier loop" lc BlueViolet fos 20 lr 58 lp 0.3 la 360 +2 1 1 h2 0 a1 120 k1 1.3 a2 -120 k2 0.3 ap 25 l "Bezier arc" lphi 270 la 180 lr 19 lp 0.5 +1 2 1 h2 0 a1 40 k1 2.8 a2 30 k2 0.8 ap 25 l "Bezier arc" lphi 90 la 0 lp 0.65 +4 2 -1 h2 0 w 1 k1 -2 k2 250 ap 25 l "Circular arc" c Red lc OrangeRed +3 4 1 p Dashed h2 0 w 2 c OliveGreen ap 25 l "Straight arc" lc PineGreen +1 3 1 p Dashed h2 0 w 5 k1 -1 k2 -20 ap 25 l "Oval arc" c Brown lc Black +3 3 -1 h1 6 w 1 h2 12 k1 -2 k2 -15 ap 0.5 l "Circular loop" c Red lc OrangeRed lphi 270 la 180 + Copied: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/Pajek NET Files/NotUsed/TestFile9.net (from rev 905, trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/Pajek NET Files/TestFile9.net) =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/Pajek NET Files/NotUsed/TestFile9.net (rev 0) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/test_files/Pajek NET Files/NotUsed/TestFile9.net 2009-07-30 21:35:14 UTC (rev 908) @@ -0,0 +1,196 @@ +*Vertices 600 +541 "SLP" +542 "wg" +543 "WG" +544 "en" +545 "EN" +546 "hh" +547 "HH" 0.987 0.5 0.5 box r 3.5 x_fact 7 s_size 1 lc red lphi 5 lr 3 +549 "PTC" +550 "ph" +551 "SMO" +552 "ci" +553 "CI" +554 "CIA" +555 "CIR" +556 "SLP" +557 "wg" +558 "WG" +559 "en" +560 "EN" +561 "hh" +562 "HH" +563 "ptc" +564 "PTC" box +565 "ph" +566 "SMO" +567 "ci" +568 "CI" +569 "CIA" +570 "CIR" +571 "SLP" +572 "wg" +573 "WG" +574 "en" +575 "EN" +576 "hh" +578 "ptc" +579 "PTC" +580 "ph" +581 "SMO" +582 "ci" +583 "CI" +584 "CIA" +585 "CIR" +586 "SLP" +587 "wg" +588 "WG" +589 "en" +590 "EN" +591 "hh" +592 "HH" +593 "ptc" +594 "PTC" +595 "ph" +596 "SMO" +597 "ci" +598 "CI" +599 "CIA" +600 "CIR" +*Edges +541 544 +541 557 +541 562 +541 563 +541 574 +541 579 +542 548 +542 550 +542 577 +543 550 +543 553 +543 554 +543 570 +544 555 +545 547 +545 563 +545 600 +546 554 +546 559 +546 562 +546 573 +549 544 +549 547 +549 565 +549 573 +549 583 +550 563 +550 575 +550 583 +551 565 +553 560 +553 600 +554 544 +554 545 +554 555 +555 564 +557 592 +558 548 +558 550 +558 571 +559 593 +560 592 +560 595 +562 584 +562 591 +563 544 +563 565 +563 591 +564 547 +564 560 +564 573 +564 575 +565 548 +565 549 +565 557 +565 565 +565 569 +565 571 +565 588 +565 595 +565 597 +565 599 +566 548 +566 556 +566 570 +569 547 +569 555 +569 560 +569 562 +569 564 +569 565 +569 567 +569 578 +569 585 +569 591 +571 585 +571 591 +572 548 +572 559 +572 562 +572 567 +572 574 +572 578 +572 588 +572 593 +572 598 +574 541 +574 543 +574 569 +574 589 +575 587 +576 550 +577 588 +578 566 +578 580 +578 581 +578 598 +580 547 +580 575 +581 544 +581 561 +581 562 +581 572 +581 588 +585 551 +585 558 +586 564 +586 583 +587 570 +587 584 +589 542 +589 553 +589 566 +589 589 +589 591 +589 597 +591 549 +591 551 +591 574 +591 589 +595 546 +595 553 +595 566 +595 576 +595 583 +595 595 +596 565 +598 594 +599 553 +599 557 +599 571 +599 575 +599 576 +599 583 +599 587 +599 598 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tan...@us...> - 2009-07-30 16:57:13
|
Revision: 907 http://cishell.svn.sourceforge.net/cishell/?rev=907&view=rev Author: tankchintan Date: 2009-07-30 16:57:02 +0000 (Thu, 30 Jul 2009) Log Message: ----------- Converted the plugin to use jung/graph instead of nwb to resolve the dependency issue, since converter graph is inside the org.cishell package. Modified Paths: -------------- trunk/core/org.cishell.algorithm.convertergraph/META-INF/MANIFEST.MF trunk/core/org.cishell.algorithm.convertergraph/OSGI-INF/algorithm.properties trunk/core/org.cishell.algorithm.convertergraph/src/org/cishell/algorithm/convertergraph/ConverterGraphAlgorithm.java trunk/core/org.cishell.algorithm.convertergraph/src/org/cishell/algorithm/convertergraph/ConverterGraphComputation.java Removed Paths: ------------- trunk/core/org.cishell.algorithm.convertergraph/src/org/cishell/algorithm/convertergraph/ConverterGraphOutputGenerator.java trunk/core/org.cishell.algorithm.convertergraph/src/org/cishell/algorithm/convertergraph/Edge.java trunk/core/org.cishell.algorithm.convertergraph/src/org/cishell/algorithm/convertergraph/Node.java Modified: trunk/core/org.cishell.algorithm.convertergraph/META-INF/MANIFEST.MF =================================================================== --- trunk/core/org.cishell.algorithm.convertergraph/META-INF/MANIFEST.MF 2009-07-30 14:48:59 UTC (rev 906) +++ trunk/core/org.cishell.algorithm.convertergraph/META-INF/MANIFEST.MF 2009-07-30 16:57:02 UTC (rev 907) @@ -5,8 +5,14 @@ Bundle-Version: 1.0.0 Bundle-ClassPath: . Bundle-Localization: plugin -Import-Package: edu.iu.nwb.converter.nwb.common, - edu.iu.nwb.util.nwbfile, +Import-Package: edu.uci.ics.jung.graph, + edu.uci.ics.jung.graph.decorators, + edu.uci.ics.jung.graph.event, + edu.uci.ics.jung.graph.filters, + edu.uci.ics.jung.graph.filters.impl, + edu.uci.ics.jung.graph.impl, + edu.uci.ics.jung.graph.predicates, + edu.uci.ics.jung.utils, org.cishell.framework, org.cishell.framework.algorithm, org.cishell.framework.data, Modified: trunk/core/org.cishell.algorithm.convertergraph/OSGI-INF/algorithm.properties =================================================================== --- trunk/core/org.cishell.algorithm.convertergraph/OSGI-INF/algorithm.properties 2009-07-30 14:48:59 UTC (rev 906) +++ trunk/core/org.cishell.algorithm.convertergraph/OSGI-INF/algorithm.properties 2009-07-30 16:57:02 UTC (rev 907) @@ -2,7 +2,7 @@ label=Converter Graph description=Provides graph of all the converters in the tool. in_data=null -out_data=file:text/nwb +out_data=edu.uci.ics.jung.graph.Graph service.pid=org.cishell.algorithm.convertergraph.ConverterGraphAlgorithm remoteable=true written_in=Java Modified: trunk/core/org.cishell.algorithm.convertergraph/src/org/cishell/algorithm/convertergraph/ConverterGraphAlgorithm.java =================================================================== --- trunk/core/org.cishell.algorithm.convertergraph/src/org/cishell/algorithm/convertergraph/ConverterGraphAlgorithm.java 2009-07-30 14:48:59 UTC (rev 906) +++ trunk/core/org.cishell.algorithm.convertergraph/src/org/cishell/algorithm/convertergraph/ConverterGraphAlgorithm.java 2009-07-30 16:57:02 UTC (rev 907) @@ -1,13 +1,6 @@ package org.cishell.algorithm.convertergraph; -import java.io.File; -import java.io.IOException; import java.util.Dictionary; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; import org.cishell.framework.CIShellContext; import org.cishell.framework.algorithm.Algorithm; @@ -21,9 +14,11 @@ import org.osgi.framework.ServiceReference; import org.osgi.service.log.LogService; +import edu.uci.ics.jung.graph.Graph; + /** * This plugin collects information about all the active converters in the tool and - * outputs a NWB file having this Directed network. Also nodes corresponding to each + * outputs a JUNG Graph having this Directed network. Also nodes corresponding to each * MIME/TYPE are weighted depending upon how many times they participate in a converter * relationship. * @@ -35,7 +30,9 @@ private LogService logger; private BundleContext bundleContext; - private int nodeCount, edgeCount; + private Graph outputGraph; + + private int nodeCount = 0, edgeCount = 0; /** * Construct with the appropriate parameters. @@ -51,123 +48,25 @@ public Data[] execute() throws AlgorithmExecutionException { - try { - - /* - * Get all the converter service references currently in service. - * */ - ServiceReference[] allConverterServices = getAllConverters(); - - /* - * Process the references to create a network of weighted nodes & directed edges. - * */ - ConverterGraphComputation converterGraphComputation = - new ConverterGraphComputation(allConverterServices, logger); - - /* - * Used to generate the output file containing the network. - * */ - File outputNWBFile = createOutputGraphFile(converterGraphComputation); - - return prepareOutputMetadata(new BasicData(outputNWBFile, "file:text/nwb")); + /* + * Get all the converter service references currently in service. + * */ + ServiceReference[] allConverterServices = getAllConverters(); - } catch (IOException e) { - throw new AlgorithmExecutionException(e); - } - } - - /** - * Call all the NWB File Handler processes in order to create a NWB file. - * @param converterGraphComputation - * @return - * @throws IOException - */ - private File createOutputGraphFile( - ConverterGraphComputation converterGraphComputation) - throws IOException { - - File outputNWBFile = File.createTempFile("nwb-", ".nwb"); - - ConverterGraphOutputGenerator outputGenerator = new ConverterGraphOutputGenerator( - converterGraphComputation, outputNWBFile); - - outputGenerator.addComment("Graph of all Converters in the Tool."); - - nodeCount = converterGraphComputation.nodes.size(); - outputGenerator.setNodeCount(nodeCount); - - outputGenerator.setNodeSchema(converterGraphComputation.nodeSchema); - - /* - * Print all the node rows to the output file. - * */ - setNodeTuples(converterGraphComputation, outputGenerator); - - edgeCount = converterGraphComputation.edges.size(); - outputGenerator.setDirectedEdgeCount(edgeCount); - - outputGenerator.setDirectedEdgeSchema(converterGraphComputation.edgeSchema); - - /* - * Print all the edge rows to the output file. - * */ - setDirectedEdgeTuples(converterGraphComputation, outputGenerator); - - outputGenerator.finishedParsing(); - outputGenerator.haltParsingNow(); - return outputNWBFile; - } - - /** - * Iterate through the nodes and print it into the output file. - * @param converterGraphComputation - * @param outputGenerator - */ - private void setDirectedEdgeTuples( - ConverterGraphComputation converterGraphComputation, - ConverterGraphOutputGenerator outputGenerator) { - - for (Iterator edgeIterator = converterGraphComputation.edges.iterator(); - edgeIterator.hasNext();) { + /* + * Process the references to create a network of weighted nodes & directed edges. + * */ + ConverterGraphComputation converterGraphComputation = + new ConverterGraphComputation(allConverterServices, logger); - Edge edge = (Edge) edgeIterator.next(); - int sourceNode = edge.source; - int targetNode = edge.target; - final String converterName = edge.serviceShortPID; - final String servicePID = edge.serviceCompletePID; - - outputGenerator.addDirectedEdge(sourceNode, targetNode, new HashMap() {{ - put("converter_name", converterName); - put("service_pid", servicePID); - }}); - } + /* + * Used to generate the output reference for graph containing the network. + * */ + return prepareOutputMetadata(new BasicData(converterGraphComputation.getOutputGraph(), + Graph.class.getName())); } /** - * @param converterGraphComputation - * @param outputGenerator - */ - private void setNodeTuples( - ConverterGraphComputation converterGraphComputation, - ConverterGraphOutputGenerator outputGenerator) { - - for (Iterator nodeIterator = converterGraphComputation.nodes.entrySet().iterator(); - nodeIterator.hasNext();) { - - Map.Entry node = (Entry) nodeIterator.next(); - - int nodeID = ((Node) node.getValue()).id; - final int strength = ((Node) node.getValue()).strength; - String label = node.getKey().toString(); - - outputGenerator.addNode(nodeID, label, new HashMap() {{ - put("strength", strength); - }}); - } - } - - - /** * Gets all the converter service references based on the LDAP query. * @return */ @@ -199,8 +98,10 @@ * @param outNWBData */ private Data[] prepareOutputMetadata(Data outNWBData) { + outNWBData.getMetadata().put(DataProperty.LABEL, "Converter Graph having " - + nodeCount + " nodes & " + edgeCount + " edges."); + + ((Graph) outNWBData.getData()).numVertices() + " nodes & " + + ((Graph) outNWBData.getData()).numEdges() + " edges."); outNWBData.getMetadata().put(DataProperty.TYPE, DataProperty.NETWORK_TYPE); return new Data[]{outNWBData}; } Modified: trunk/core/org.cishell.algorithm.convertergraph/src/org/cishell/algorithm/convertergraph/ConverterGraphComputation.java =================================================================== --- trunk/core/org.cishell.algorithm.convertergraph/src/org/cishell/algorithm/convertergraph/ConverterGraphComputation.java 2009-07-30 14:48:59 UTC (rev 906) +++ trunk/core/org.cishell.algorithm.convertergraph/src/org/cishell/algorithm/convertergraph/ConverterGraphComputation.java 2009-07-30 16:57:02 UTC (rev 907) @@ -3,41 +3,44 @@ */ package org.cishell.algorithm.convertergraph; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; import org.osgi.framework.ServiceReference; import org.osgi.service.log.LogService; -import edu.iu.nwb.util.nwbfile.NWBFileProperty; +import edu.uci.ics.jung.graph.Edge; +import edu.uci.ics.jung.graph.Graph; +import edu.uci.ics.jung.graph.Vertex; +import edu.uci.ics.jung.graph.impl.DirectedSparseEdge; +import edu.uci.ics.jung.graph.impl.DirectedSparseGraph; +import edu.uci.ics.jung.graph.impl.DirectedSparseVertex; +import edu.uci.ics.jung.utils.UserDataContainer; /** * The algorithm is used for getting information about current converters is, * 1. Get all the service references for converters in the system. - * 2. Create Node Schema to be used when constructing the NWB file. In this case - * it will be, + * 2. Node Schema to be used is, * id*int, label*string, strength*int - * 3. Create Edge Schema to be used when constructing the NWB file. In this case - * it will be, + * 3. Edge Schema to be used is, * source*int, target*int, converter_name*string, service_pid*string * 4. Iterate over all the converter service reference one at a time. * 5. For collecting information for Nodes do, * (a). Get node label using service properties in_data & out_data. - * (b). Check to see if this node is already present in the nodes map. + * (b). Check to see if this node is already present in the nodeLabels set. * (c). If it is present then just update the strength of node by incrementing * that node's strength by 1. * (d). Else create a new node. Provide it a default strength of 1 and update - * the node count. + * the node count. Also create an entry in the nodeLabels for future + * reference. * 6. For collecting information about Edges do, - * (a). Get the respective source & target node ids from the recently updates - * respective nodes. + * (a). Get the respective source & target node references from the recently updated + * nodes. * (b). Get the service_pid by using service property service.pid. * (c). Get the converter_name by extracting the last block from service_pid. - * 7. These information is then passed on to {@link ConverterGraphOutputGenerator} - * for printing it into a NWB file. + * 7. Since the graph is being created during the processing of each node & edge + * it just needs to be referenced on the UI. This is done by outputting the metadata. * * @author cdtank * @@ -47,12 +50,17 @@ private LogService logger; private ServiceReference[] allConverterServices; - public Map nodes = new HashMap(); - public LinkedHashMap nodeSchema = new LinkedHashMap(); + private Set nodeLabels = new HashSet(); - public List edges = new ArrayList(); - public LinkedHashMap edgeSchema = new LinkedHashMap(); + private Graph outputGraph; + /** + * @return the outputGraph + */ + public Graph getOutputGraph() { + return outputGraph; + } + private int nodeCount; public ConverterGraphComputation(ServiceReference[] allConverterServices, @@ -61,38 +69,14 @@ this.nodeCount = 0; this.logger = logger; this.allConverterServices = allConverterServices; + this.outputGraph = new DirectedSparseGraph(); /* - * Side affects nodeSchema - * */ - createNodeSchema(); - - /* - * Side affects edgeSchema - * */ - createEdgeSchema(); - - /* * Side affects nodes & edges * */ processServiceReferences(); } - private void createNodeSchema() { - nodeSchema.put("id", NWBFileProperty.TYPE_INT); - nodeSchema.put("label", NWBFileProperty.TYPE_STRING); - nodeSchema.put("strength", NWBFileProperty.TYPE_INT); - } - - private void createEdgeSchema() { - edgeSchema.put("source", NWBFileProperty.TYPE_INT); - edgeSchema.put("target", NWBFileProperty.TYPE_INT); - edgeSchema.put("converter_name", NWBFileProperty.TYPE_STRING); - edgeSchema.put("service_pid", NWBFileProperty.TYPE_STRING); - } - - - /* * Iterate over all the converter service references and process the * information to get nodes & edges. @@ -103,7 +87,7 @@ converterCount < allConverterServices.length; converterCount++) { - int sourceNodeID, targetNodeID; + Vertex sourceNode, targetNode; ServiceReference currentConverterServiceReference = allConverterServices[converterCount]; @@ -113,47 +97,61 @@ String targetNodeKey = (String) currentConverterServiceReference.getProperty("out_data"); - if (nodes.containsKey(sourceNodeKey)) { - sourceNodeID = updateNode(sourceNodeKey); + if (nodeLabels.contains(sourceNodeKey)) { + sourceNode = updateNode(sourceNodeKey); } else { - sourceNodeID = createNode(sourceNodeKey); + sourceNode = createNode(sourceNodeKey); } - if (nodes.containsKey(targetNodeKey)) { - targetNodeID = updateNode(targetNodeKey); + if (nodeLabels.contains(targetNodeKey)) { + targetNode = updateNode(targetNodeKey); } else { - targetNodeID = createNode(targetNodeKey); + targetNode = createNode(targetNodeKey); } - createEdge(sourceNodeID, targetNodeID, currentConverterServiceReference); + createEdge(sourceNode, targetNode, currentConverterServiceReference); } } - private int updateNode(String currentNodeKey) { - int sourceNodeID; - Node sourceNodeValue = (Node) nodes.get(currentNodeKey); - sourceNodeID = sourceNodeValue.id; - sourceNodeValue.strength += 1; - return sourceNodeID; + private Vertex updateNode(String currentNodeKey) { + + for (Iterator nodeIterator = outputGraph.getVertices().iterator(); + nodeIterator.hasNext();) { + Vertex currentVertex = (Vertex) nodeIterator.next(); + if (currentVertex.getUserDatum("label").toString() + .equalsIgnoreCase(currentNodeKey)) { + int currentVertexStrength = + ((Integer) currentVertex.getUserDatum("strength")).intValue(); + currentVertex.setUserDatum("strength", ++currentVertexStrength, + new UserDataContainer.CopyAction.Shared()); + return currentVertex; + } + } + return new DirectedSparseVertex(); } - private int createNode(String nodeKey) { + private Vertex createNode(String nodeKey) { nodeCount++; - Node nodeValue = new Node(); - nodeValue.id = nodeCount; - nodeValue.strength = 1; - nodes.put(nodeKey, nodeValue); - return nodeCount; + Vertex node = new DirectedSparseVertex(); + + node.addUserDatum("id", nodeCount, new UserDataContainer.CopyAction.Shared()); + node.addUserDatum("strength", 1, new UserDataContainer.CopyAction.Shared()); + node.addUserDatum("label", nodeKey, new UserDataContainer.CopyAction.Shared()); + + outputGraph.addVertex(node); + nodeLabels.add(nodeKey); + + return node; } /** * Create an edge based on source id, target id & other information. - * @param sourceNodeID - * @param targetNodeID + * @param sourceNode + * @param targetNode * @param currentConverterServiceReference */ - private void createEdge(int sourceNodeID, int targetNodeID, + private void createEdge(Vertex sourceNode, Vertex targetNode, ServiceReference currentConverterServiceReference) { String serviceCompletePID = (String) currentConverterServiceReference.getProperty("service.pid"); @@ -166,15 +164,16 @@ String serviceShortPID = serviceCompletePID.substring(startIndexForConverterName); /* - * Build the actual edge tuple. + * Build the actual edge & attach it to the graph. * */ - Edge edge = new Edge(); - edge.source = sourceNodeID; - edge.target = targetNodeID; - edge.serviceShortPID = serviceShortPID; - edge.serviceCompletePID = serviceCompletePID; + Edge edge = new DirectedSparseEdge(sourceNode, targetNode); - edges.add(edge); + edge.addUserDatum("converter_name", serviceShortPID, + new UserDataContainer.CopyAction.Shared()); + edge.addUserDatum("service_pid", serviceCompletePID, + new UserDataContainer.CopyAction.Shared()); + + outputGraph.addEdge(edge); } } Deleted: trunk/core/org.cishell.algorithm.convertergraph/src/org/cishell/algorithm/convertergraph/ConverterGraphOutputGenerator.java =================================================================== --- trunk/core/org.cishell.algorithm.convertergraph/src/org/cishell/algorithm/convertergraph/ConverterGraphOutputGenerator.java 2009-07-30 14:48:59 UTC (rev 906) +++ trunk/core/org.cishell.algorithm.convertergraph/src/org/cishell/algorithm/convertergraph/ConverterGraphOutputGenerator.java 2009-07-30 16:57:02 UTC (rev 907) @@ -1,62 +0,0 @@ -package org.cishell.algorithm.convertergraph; - -import java.io.File; -import java.io.IOException; -import java.util.LinkedHashMap; -import java.util.Map; - -import edu.iu.nwb.util.nwbfile.NWBFileParserHandler; -import edu.iu.nwb.util.nwbfile.NWBFileWriter; - -public class ConverterGraphOutputGenerator implements NWBFileParserHandler { - - private NWBFileWriter output; - - public ConverterGraphOutputGenerator(ConverterGraphComputation converterGraphComputation, - File outputNWBFile) throws IOException { - output = new NWBFileWriter(outputNWBFile); - } - - public void setNodeCount(int numberOfNodes) { - output.setNodeCount(numberOfNodes); - } - - public void setNodeSchema(LinkedHashMap schema) { - output.setNodeSchema(schema); - } - - public void addNode(int id, String label, Map attributes) { - output.addNode(id, label, attributes); - } - - public void addDirectedEdge(int sourceNode, int targetNode, Map attributes) { - output.addDirectedEdge(sourceNode, targetNode, attributes); - } - public void addUndirectedEdge(int node1, int node2, Map attributes) { - output.addUndirectedEdge(node1, node2, attributes); - } - public void setDirectedEdgeCount(int numberOfEdges) { - output.setDirectedEdgeCount(numberOfEdges); - } - public void setDirectedEdgeSchema(LinkedHashMap schema) { - output.setDirectedEdgeSchema(schema); - } - public void setUndirectedEdgeCount(int numberOfEdges) { - output.setUndirectedEdgeCount(numberOfEdges); - } - public void setUndirectedEdgeSchema(LinkedHashMap schema) { - output.setUndirectedEdgeSchema(schema); - } - - public void addComment(String comment) { - output.addComment(comment); - } - - public void finishedParsing() { - output.finishedParsing(); - } - - public boolean haltParsingNow() { - return false; - } -} Deleted: trunk/core/org.cishell.algorithm.convertergraph/src/org/cishell/algorithm/convertergraph/Edge.java =================================================================== --- trunk/core/org.cishell.algorithm.convertergraph/src/org/cishell/algorithm/convertergraph/Edge.java 2009-07-30 14:48:59 UTC (rev 906) +++ trunk/core/org.cishell.algorithm.convertergraph/src/org/cishell/algorithm/convertergraph/Edge.java 2009-07-30 16:57:02 UTC (rev 907) @@ -1,8 +0,0 @@ -package org.cishell.algorithm.convertergraph; - -public class Edge { - public int source; - public int target; - public String serviceShortPID; - public String serviceCompletePID; -} \ No newline at end of file Deleted: trunk/core/org.cishell.algorithm.convertergraph/src/org/cishell/algorithm/convertergraph/Node.java =================================================================== --- trunk/core/org.cishell.algorithm.convertergraph/src/org/cishell/algorithm/convertergraph/Node.java 2009-07-30 14:48:59 UTC (rev 906) +++ trunk/core/org.cishell.algorithm.convertergraph/src/org/cishell/algorithm/convertergraph/Node.java 2009-07-30 16:57:02 UTC (rev 907) @@ -1,13 +0,0 @@ -/** - * - */ -package org.cishell.algorithm.convertergraph; - -/** - * @author cdtank - * - */ -public class Node { - public int id; - public int strength; -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2009-07-30 14:49:08
|
Revision: 906 http://cishell.svn.sourceforge.net/cishell/?rev=906&view=rev Author: mwlinnem Date: 2009-07-30 14:48:59 +0000 (Thu, 30 Jul 2009) Log Message: ----------- Changing the default bundle name to agree with the default symbolic name (I believe this is our convention, for bundles with only one algorithm). Modified Paths: -------------- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/java/NewJavaAlgorithmTemplate.java Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/java/NewJavaAlgorithmTemplate.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/java/NewJavaAlgorithmTemplate.java 2009-07-29 21:33:47 UTC (rev 905) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/java/NewJavaAlgorithmTemplate.java 2009-07-30 14:48:59 UTC (rev 906) @@ -42,7 +42,7 @@ setPageCount(5); //this should go on page 0 addOption("bundleName", "Bundle Name", "My Algorithm Bundle", 1).setRequired(true); - addOption("bundleSymbolicName","Bundle Symbolic Name", "org.my.bundle.name", 1).setRequired(true); + addOption("bundleSymbolicName","Bundle Symbolic Name", "org.my.algorithm", 1).setRequired(true); addOption("bundleVersion", "Bundle Version", "0.0.1", 1).setRequired(true); addOption("algName", "Algorithm Name", "My Algorithm", 2).setRequired(true); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
Revision: 905 http://cishell.svn.sourceforge.net/cishell/?rev=905&view=rev Author: mwlinnem Date: 2009-07-29 21:33:47 +0000 (Wed, 29 Jul 2009) Log Message: ----------- Updated converter tester to conform to CIShell 1.0 changes (finally). Modified Paths: -------------- trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithmUtil.java Modified: trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithmUtil.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithmUtil.java 2009-07-29 15:20:15 UTC (rev 904) +++ trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithmUtil.java 2009-07-29 21:33:47 UTC (rev 905) @@ -8,21 +8,25 @@ import org.osgi.service.log.LogService; public class ConverterTesterAlgorithmUtil implements AlgorithmProperty { - public static ServiceReference[] getConverterReferences( - BundleContext bContext) { - String filter = "(&("+ALGORITHM_TYPE+"="+TYPE_CONVERTER+"))"; + /* + * Technically, this returns both converters AND validators. + * However, when it was written validators were converters! + */ + public static ServiceReference[] getConverterReferences(BundleContext bContext) { + String filter = "(|(" + ALGORITHM_TYPE + "=" + TYPE_CONVERTER + ")(" + ALGORITHM_TYPE + "=" + + TYPE_VALIDATOR + "))"; - try { - ServiceReference[] refs = bContext.getServiceReferences( - AlgorithmFactory.class.getName(), filter); - - return refs; - } catch (InvalidSyntaxException e) { - System.err.println("Invalid syntax '" + filter + - "' for filtering service references. Attempted to " + - "obtain all converter references."); - e.printStackTrace(); - return null; - } + try { + ServiceReference[] refs = bContext.getServiceReferences(AlgorithmFactory.class + .getName(), filter); + + return refs; + } catch (InvalidSyntaxException e) { + System.err.println("Invalid syntax '" + filter + + "' for filtering service references. Attempted to " + + "obtain all converter references."); + e.printStackTrace(); + return null; + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2009-07-29 15:20:27
|
Revision: 904 http://cishell.svn.sourceforge.net/cishell/?rev=904&view=rev Author: mwlinnem Date: 2009-07-29 15:20:15 +0000 (Wed, 29 Jul 2009) Log Message: ----------- Adding converter graph plugin to CIShell build. Modified Paths: -------------- trunk/deployment/org.cishell.reference.feature/feature.xml Modified: trunk/deployment/org.cishell.reference.feature/feature.xml =================================================================== --- trunk/deployment/org.cishell.reference.feature/feature.xml 2009-07-28 20:27:43 UTC (rev 903) +++ trunk/deployment/org.cishell.reference.feature/feature.xml 2009-07-29 15:20:15 UTC (rev 904) @@ -114,4 +114,11 @@ version="0.0.0" unpack="false"/> + <plugin + id="org.cishell.algorithm.convertergraph" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + </feature> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jrb...@us...> - 2009-07-28 20:27:56
|
Revision: 903 http://cishell.svn.sourceforge.net/cishell/?rev=903&view=rev Author: jrbibers Date: 2009-07-28 20:27:43 +0000 (Tue, 28 Jul 2009) Log Message: ----------- Wrapped to 80 characters while reading. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java Modified: trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java 2009-07-27 16:07:28 UTC (rev 902) +++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java 2009-07-28 20:27:43 UTC (rev 903) @@ -52,7 +52,8 @@ import org.osgi.service.metatype.MetaTypeService; import org.osgi.service.metatype.ObjectClassDefinition; -public class AlgorithmWrapper implements Algorithm, AlgorithmProperty, ProgressTrackable { +public class AlgorithmWrapper + implements Algorithm, AlgorithmProperty, ProgressTrackable { protected ServiceReference ref; protected BundleContext bContext; protected CIShellContext ciContext; @@ -62,8 +63,12 @@ protected ProgressMonitor progressMonitor; protected Algorithm algorithm; - public AlgorithmWrapper(ServiceReference ref, BundleContext bContext, CIShellContext ciContext, - Data[] originalData, Data[] data, Converter[][] converters) { + public AlgorithmWrapper(ServiceReference ref, + BundleContext bContext, + CIShellContext ciContext, + Data[] originalData, + Data[] data, + Converter[][] converters) { this.ref = ref; this.bContext = bContext; this.ciContext = ciContext; @@ -80,8 +85,9 @@ try { AlgorithmFactory factory = getAlgorithmFactory(bContext, ref); - if (factory == null) + if (factory == null) { return null; + } String pid = (String)ref.getProperty(Constants.SERVICE_PID); @@ -89,8 +95,9 @@ boolean conversionSuccessful = tryConvertingDataToRequiredFormat(data, converters); - if (!conversionSuccessful) + if (!conversionSuccessful) { return null; + } boolean inputIsValid = testDataValidityIfPossible(factory, data); @@ -107,16 +114,18 @@ getUserEnteredParameters(metatype_pid, provider); // Check to see if the user cancelled the operation. - if (parameters == null) + if (parameters == null) { return null; + } printParameters(metatype_pid, provider, parameters); // Create the algorithm. algorithm = createAlgorithm(factory, data, parameters, ciContext); - if (algorithm == null) + if (algorithm == null) { return null; + } trackAlgorithmIfPossible(algorithm); @@ -137,8 +146,9 @@ GUIBuilderService builder = (GUIBuilderService)ciContext.getService (GUIBuilderService.class.getName()); - String errorMessage = "An error occurred while preparing to run the " + - "algorithm \"" + ref.getProperty(AlgorithmProperty.LABEL) + ".\""; + String errorMessage = "An error occurred while preparing to run " + + "the algorithm \"" + ref.getProperty(AlgorithmProperty.LABEL) + + ".\""; builder.showError("Error!", errorMessage, e); log(LogService.LOG_ERROR, errorMessage, e); @@ -147,14 +157,19 @@ return null; } - protected AlgorithmFactory getAlgorithmFactory(BundleContext bContext, ServiceReference ref) { - AlgorithmFactory algorithmFactory = (AlgorithmFactory) bContext.getService(ref); + protected AlgorithmFactory getAlgorithmFactory(BundleContext bContext, + ServiceReference ref) { + AlgorithmFactory algorithmFactory = + (AlgorithmFactory) bContext.getService(ref); if (algorithmFactory == null) { - String errorMessage = "Could not create AlgorithmFactory for the algorithm " + "\"" - + ref.getProperty(AlgorithmProperty.LABEL) + "\"."; - String details = "The algorithm's pid was \"" + ref.getProperty(Constants.SERVICE_PID) + - "\" (potentially useful for debugging purposes)."; - GUIBuilderService builder = (GUIBuilderService) ciContext.getService(GUIBuilderService.class.getName()); + String errorMessage = + "Could not create AlgorithmFactory for the algorithm " + + "\"" + ref.getProperty(AlgorithmProperty.LABEL) + "\"."; + String details = "The algorithm's pid was \"" + + ref.getProperty(Constants.SERVICE_PID) + + "\" (potentially useful for debugging purposes)."; + GUIBuilderService builder = (GUIBuilderService) + ciContext.getService(GUIBuilderService.class.getName()); builder.showError("Error!", errorMessage, details); log(LogService.LOG_ERROR, errorMessage); } @@ -162,14 +177,18 @@ return algorithmFactory; } - protected Algorithm createAlgorithm(AlgorithmFactory factory, Data[] data, Dictionary parameters, - CIShellContext ciContext) { + protected Algorithm createAlgorithm(AlgorithmFactory factory, + Data[] data, + Dictionary parameters, + CIShellContext ciContext) { try { return factory.createAlgorithm(data, parameters, ciContext); } catch (Exception e) { - String errorMessage = "Unexpected error occurred while creating algorithm " + " \"" + String errorMessage = + "Unexpected error occurred while creating algorithm " + " \"" + ref.getProperty(AlgorithmProperty.LABEL) + ".\""; - GUIBuilderService builder = (GUIBuilderService) ciContext.getService(GUIBuilderService.class.getName()); + GUIBuilderService builder = (GUIBuilderService) + ciContext.getService(GUIBuilderService.class.getName()); builder.showError("Error!", errorMessage, e); log(LogService.LOG_ERROR, errorMessage, e); return null; @@ -193,8 +212,10 @@ protected void addDataToDataManager(Data[] outData) { if (outData != null) { - DataManagerService dataManager = (DataManagerService) bContext.getService(bContext - .getServiceReference(DataManagerService.class.getName())); + DataManagerService dataManager = (DataManagerService) + bContext.getService( + bContext.getServiceReference( + DataManagerService.class.getName())); if (outData.length != 0) { for (int ii = 0; ii < outData.length; ii++) { @@ -212,33 +233,40 @@ try { outData = algorithm.execute(); } catch (AlgorithmExecutionException e) { - log(LogService.LOG_ERROR, "The Algorithm: \"" + ref.getProperty(AlgorithmProperty.LABEL) + log(LogService.LOG_ERROR, "The Algorithm: \"" + + ref.getProperty(AlgorithmProperty.LABEL) + "\" had an error while executing: " + e.getMessage(), e); } catch (RuntimeException e) { - GUIBuilderService builder = (GUIBuilderService) ciContext.getService(GUIBuilderService.class.getName()); + GUIBuilderService builder = (GUIBuilderService) + ciContext.getService(GUIBuilderService.class.getName()); - builder.showError("Error!", "An unexpected exception occurred while " + "executing \"" + builder.showError("Error!", + "An unexpected exception occurred while " + "executing \"" + ref.getProperty(AlgorithmProperty.LABEL) + ".\"", e); } return outData; } - protected boolean tryConvertingDataToRequiredFormat(Data[] data, Converter[][] converters) { + protected boolean tryConvertingDataToRequiredFormat( + Data[] data, Converter[][] converters) { for (int i = 0; i < data.length; i++) { if (converters[i] != null) { try { data[i] = converters[i][0].convert(data[i]); } catch (ConversionException e) { - log(LogService.LOG_ERROR, "The conversion of data to give" - + " the algorithm failed for this reason: " + e.getMessage(), e); + log(LogService.LOG_ERROR, + "Error: Unable to convert data for use by the " + + "algorithm:\n " + e.getMessage(), e); return false; } if (data[i] == null && i < (data.length - 1)) { - log(LogService.LOG_ERROR, "The converter: " + converters[i].getClass().getName() - + " returned a null result where data was expected when" - + " converting the data to give the algorithm."); + log(LogService.LOG_ERROR, "The converter: " + + converters[i].getClass().getName() + + " returned a null result where data was " + + "expected when converting the data to give " + + "the algorithm."); return false; } converters[i] = null; @@ -248,7 +276,8 @@ return true; } - protected boolean testDataValidityIfPossible(AlgorithmFactory factory, Data[] data) { + protected boolean testDataValidityIfPossible(AlgorithmFactory factory, + Data[] data) { if (factory instanceof DataValidator) { String validation = ((DataValidator) factory).validate(data); @@ -258,7 +287,8 @@ label = "Algorithm"; } - log(LogService.LOG_ERROR, "INVALID DATA: The data given to \"" + label + log(LogService.LOG_ERROR, + "INVALID DATA: The data given to \"" + label + "\" is incompatible for this reason: " + validation); return false; } @@ -278,24 +308,27 @@ return metatype_pid; } - protected MetaTypeProvider getPossiblyMutatedMetaTypeProvider(String metatypePID, String pid, - AlgorithmFactory factory) { + protected MetaTypeProvider getPossiblyMutatedMetaTypeProvider( + String metatypePID, String pid, AlgorithmFactory factory) { MetaTypeProvider provider = null; - MetaTypeService metaTypeService = (MetaTypeService) Activator.getService(MetaTypeService.class.getName()); + MetaTypeService metaTypeService = (MetaTypeService) + Activator.getService(MetaTypeService.class.getName()); if (metaTypeService != null) { provider = metaTypeService.getMetaTypeInformation(ref.getBundle()); } if (factory instanceof ParameterMutator && provider != null) { try { - ObjectClassDefinition ocd = provider.getObjectClassDefinition(metatypePID, null); + ObjectClassDefinition ocd = + provider.getObjectClassDefinition(metatypePID, null); if (ocd == null) logNullOCDWarning(pid, metatypePID); ocd = ((ParameterMutator) factory).mutateParameters(data, ocd); if (ocd != null) { provider = new BasicMetaTypeProvider(ocd); } } catch (IllegalArgumentException e) { - log(LogService.LOG_DEBUG, pid + " has an invalid metatype id: " + metatypePID, e); + log(LogService.LOG_DEBUG, pid + " has an invalid metatype id: " + + metatypePID, e); } } @@ -312,10 +345,12 @@ } } - protected Dictionary getUserEnteredParameters(String metatype_pid, MetaTypeProvider provider) { + protected Dictionary getUserEnteredParameters(String metatype_pid, + MetaTypeProvider provider) { Dictionary parameters = new Hashtable(); if (provider != null) { - GUIBuilderService builder = (GUIBuilderService) ciContext.getService(GUIBuilderService.class.getName()); + GUIBuilderService builder = (GUIBuilderService) + ciContext.getService(GUIBuilderService.class.getName()); parameters = builder.createGUIandWait(metatype_pid, provider); } @@ -323,19 +358,26 @@ return parameters; } - // wrap the provider to provide special functionality, such as overriding default values of attributes through - // preferences. - protected MetaTypeProvider wrapProvider(ServiceReference algRef, MetaTypeProvider unwrappedProvider) { + /* Wrap the provider to provide special functionality, such as overriding + * default values of attributes through preferences. + */ + protected MetaTypeProvider wrapProvider( + ServiceReference algRef, MetaTypeProvider unwrappedProvider) { ConfigurationAdmin ca = getConfigurationAdmin(); if (ca != null && hasParamDefaultPreferences(algRef)) { - String standardServicePID = (String) algRef.getProperty(Constants.SERVICE_PID); - String paramOverrideConfPID = standardServicePID + UserPrefsProperty.PARAM_PREFS_CONF_SUFFIX; + String standardServicePID = + (String) algRef.getProperty(Constants.SERVICE_PID); + String paramOverrideConfPID = + standardServicePID + UserPrefsProperty.PARAM_PREFS_CONF_SUFFIX; try { - Configuration defaultParamValueOverrider = ca.getConfiguration(paramOverrideConfPID, null); - Dictionary defaultParamOverriderDict = defaultParamValueOverrider.getProperties(); - MetaTypeProvider wrappedProvider = new ParamMetaTypeProvider(unwrappedProvider, - defaultParamOverriderDict); + Configuration defaultParamValueOverrider = + ca.getConfiguration(paramOverrideConfPID, null); + Dictionary defaultParamOverriderDict = + defaultParamValueOverrider.getProperties(); + MetaTypeProvider wrappedProvider = + new ParamMetaTypeProvider(unwrappedProvider, + defaultParamOverriderDict); return wrappedProvider; } catch (IOException e) { return unwrappedProvider; @@ -347,16 +389,19 @@ } protected boolean hasParamDefaultPreferences(ServiceReference algRef) { - String prefsToPublish = (String) algRef.getProperty(UserPrefsProperty.PREFS_PUBLISHED_KEY); + String prefsToPublish = + (String) algRef.getProperty(UserPrefsProperty.PREFS_PUBLISHED_KEY); if (prefsToPublish == null) { return false; } - return prefsToPublish.contains(UserPrefsProperty.PUBLISH_PARAM_DEFAULT_PREFS_VALUE); + return prefsToPublish.contains( + UserPrefsProperty.PUBLISH_PARAM_DEFAULT_PREFS_VALUE); } protected void log(int logLevel, String message) { - LogService log = (LogService) ciContext.getService(LogService.class.getName()); + LogService log = + (LogService) ciContext.getService(LogService.class.getName()); if (log != null) { log.log(logLevel, message); } else { @@ -365,7 +410,8 @@ } protected void log(int logLevel, String message, Throwable exception) { - LogService log = (LogService) ciContext.getService(LogService.class.getName()); + LogService log = + (LogService) ciContext.getService(LogService.class.getName()); if (log != null) { log.log(logLevel, message, exception); } else { @@ -374,13 +420,16 @@ } } - protected void printParameters(String metatype_pid, MetaTypeProvider provider, Dictionary parameters) { + protected void printParameters(String metatype_pid, + MetaTypeProvider provider, + Dictionary parameters) { LogService logger = getLogService(); Map idToLabelMap = setupIdToLabelMap(metatype_pid, provider); if (logger != null && !parameters.isEmpty()) { // adjust to log all input parameters in one block - StringBuffer inputParams = new StringBuffer("\n" + "Input Parameters:"); + StringBuffer inputParams = + new StringBuffer("\n" + "Input Parameters:"); for (Enumeration e = parameters.keys(); e.hasMoreElements();) { String key = (String) e.nextElement(); @@ -394,7 +443,8 @@ } } - protected Map setupIdToLabelMap(String metatype_pid, MetaTypeProvider provider) { + protected Map setupIdToLabelMap(String metatype_pid, + MetaTypeProvider provider) { Map idToLabelMap = new HashMap(); if (provider != null) { ObjectClassDefinition ocd = null; @@ -402,7 +452,8 @@ ocd = provider.getObjectClassDefinition(metatype_pid, null); if (ocd != null) { - AttributeDefinition[] attr = ocd.getAttributeDefinitions(ObjectClassDefinition.ALL); + AttributeDefinition[] attr = + ocd.getAttributeDefinitions(ObjectClassDefinition.ALL); for (int i = 0; i < attr.length; i++) { String id = attr[i].getID(); @@ -422,15 +473,20 @@ protected void doParentage(Data[] outData) { // make sure the parent set is the original Data and not the // converted data... - if (outData != null && data != null && originalData != null && originalData.length == data.length) { + if (outData != null + && data != null + && originalData != null + && originalData.length == data.length) { for (int i = 0; i < outData.length; i++) { if (outData[i] != null) { - Object parent = outData[i].getMetadata().get(DataProperty.PARENT); + Object parent = + outData[i].getMetadata().get(DataProperty.PARENT); if (parent != null) { for (int j = 0; j < data.length; j++) { if (parent == data[j]) { - outData[i].getMetadata().put(DataProperty.PARENT, originalData[j]); + outData[i].getMetadata().put( + DataProperty.PARENT, originalData[j]); break; } } @@ -439,17 +495,21 @@ } } - // check and act on parentage settings + // Check and act on parentage settings String parentage = (String) ref.getProperty("parentage"); if (parentage != null) { parentage = parentage.trim(); if (parentage.equalsIgnoreCase("default")) { - if (originalData != null && originalData.length > 0 && originalData[0] != null) { + if (originalData != null + && originalData.length > 0 + && originalData[0] != null) { for (int i = 0; i < outData.length; i++) { - // if they don't have a parent set already then we set one - if (outData[i] != null && outData[i].getMetadata().get(DataProperty.PARENT) == null) { - outData[i].getMetadata().put(DataProperty.PARENT, originalData[0]); + // If they don't have a parent set already then we set one + if (outData[i] != null + && outData[i].getMetadata().get(DataProperty.PARENT) == null) { + outData[i].getMetadata().put( + DataProperty.PARENT, originalData[0]); } } } @@ -458,31 +518,36 @@ } private LogService getLogService() { - ServiceReference serviceReference = bContext.getServiceReference(DataManagerService.class.getName()); + ServiceReference serviceReference = + bContext.getServiceReference(DataManagerService.class.getName()); LogService log = null; if (serviceReference != null) { - log = (LogService) bContext.getService(bContext.getServiceReference(LogService.class.getName())); + log = (LogService) bContext.getService( + bContext.getServiceReference(LogService.class.getName())); } return log; } private ConfigurationAdmin getConfigurationAdmin() { - ServiceReference serviceReference = bContext.getServiceReference(ConfigurationAdmin.class.getName()); + ServiceReference serviceReference = + bContext.getServiceReference(ConfigurationAdmin.class.getName()); ConfigurationAdmin ca = null; if (serviceReference != null) { - ca = (ConfigurationAdmin) bContext.getService(bContext.getServiceReference(ConfigurationAdmin.class - .getName())); + ca = (ConfigurationAdmin) bContext.getService( + bContext.getServiceReference( + ConfigurationAdmin.class.getName())); } return ca; } private void logNullOCDWarning(String pid, String metatype_pid) { - this.log(LogService.LOG_WARNING, "Warning: could not get object class definition '" + metatype_pid - + "' from the algorithm '" + pid + "'"); + this.log(LogService.LOG_WARNING, + "Warning: could not get object class definition '" + metatype_pid + + "' from the algorithm '" + pid + "'"); } public ProgressMonitor getProgressMonitor() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |