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] |