Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse')
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/EnvironmentUI.properties42
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/EnvironmentUIMessages.java53
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/common/LabelsAndIds.java52
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/common/TimedOperation.java196
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/AntExtension.java110
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/AntExtensionCreation.java103
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/AntFileImportWizard.java310
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/AntFileImportWizardPage.java206
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/ErrorDialog.java99
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/InfoDialog.java98
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/MessageDialog.java585
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/OptionsDialog.java107
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/RuntimeStruct.java52
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/StatusDialogConstants.java51
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/WarningDialog.java103
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/eclipse/EclipseStatusHandler.java191
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/eclipse/EnvironmentUtils.java42
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/eclipse/SWTEnvironmentManager.java28
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/plugin/EnvUIPlugin.java55
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/preferences/ActionDialogsPreferencePage.java247
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/registry/WidgetRegistry.java110
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/AbstractSelectionDialog.java35
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/CanFinishRegistry.java29
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/CommandWidgetBinding.java42
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/CommandWidgetBindingList.java128
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/CurrentPageCommand.java46
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/DataObjectCommand.java45
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/DialogDataEvents.java35
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/DynamicWizard.java437
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/INamedWidgetContributor.java42
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/INamedWidgetContributorFactory.java39
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/PageInfo.java44
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/PageWizardDataEvents.java35
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SelectionCommand.java48
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleCanFinishRegistry.java34
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleCommandEngineManager.java322
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleDialog.java164
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimplePageFactory.java20
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimplePopupPageFactory.java27
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimplePopupWizardPage.java71
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleWidgetContributor.java74
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleWidgetDataContributor.java54
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleWidgetRegistry.java34
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleWizardPage.java153
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetBindingToWidgetFactoryAdapter.java74
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetContributor.java71
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetContributorFactory.java21
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetDataContributor.java20
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetDataEvents.java34
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetRegistry.java39
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WizardPageFactory.java23
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WizardPageManager.java538
-rw-r--r--core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/popup/DynamicPopupWizard.java227
53 files changed, 5845 insertions, 0 deletions
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/EnvironmentUI.properties b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/EnvironmentUI.properties
new file mode 100644
index 000000000..9395c2313
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/EnvironmentUI.properties
@@ -0,0 +1,42 @@
+###############################################################################
+# Copyright (c) 2001, 2008 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+# yyyymmdd bug Email and other contact information
+# -------- -------- -----------------------------------------------------------
+# 20060509 119296 pmoogk@ca.ibm.com - Peter Moogk
+# 20080221 146023 gilberta@ca.ibm.com - Gilbert Andrews
+# 20080326 223829 kathy@ca.ibm.com - Kathy Chan
+# 20080402 222094 kathy@ca.ibm.com - Kathy Chan, Update properties file.
+###############################################################################
+
+BUTTON_SHOW_ALL_DIALOGS=&Show All
+BUTTON_HIDE_ALL_DIALOGS=&Hide All
+CHECKBOX_DO_NOT_SHOW_DIALOG_AGAIN=Do not show me this dialog box again.
+
+TOOLTIP_PPAD_PAGE=Control to show/hide the dialogs that appear when a pop-up action is executed.
+TOOLTIP_DO_NOT_SHOW_DIALOG_AGAIN=To allow this dialog to show again, enable from preference - dialogs.
+TOOLTIP_PPAD_BUTTON_SHOW_ALL=Show all dialogs.
+TOOLTIP_PPAD_BUTTON_HIDE_ALL=Hide all dialogs and execute pop-up actions.
+TOOLTIP_PPAD_COMBO_RUNTIME=The runtime you require ant templates for.
+TOOLTIP_PPAD_COMBO_SCENARIO=The scenario you require ant templates for.
+
+WIZARD_TITLE_ANT=Create Ant Files
+WIZARD_PAGE_TITLE_ANT=Create Web Service Ant files
+WIZARD_PAGE_DESC_ANT=Select workspace folder for Ant script and properties files
+MSG_STATUS_COPYING_ANT_FILES=Copying web services Ant files
+MSG_ERR_COPYING_ANT_FILES=Error encountered copying Ant files
+MSG_ERR_ANT_FILES_NOT_FOUND=Ant file not found at {0}
+MSG_WARNING_FILE_EXISTS=The file {0} exists. Do you want to overwrite?
+DIALOG_TITLE_OVERWRITE=Confirm Overwrite
+
+MSG_ERROR_WIZARD_ID_NOT_FOUND=IWAB0013E Could not find wizard id: {0}
+MSG_ERROR_OPERATION_TIMED_OUT=Operation timed out.
+
+LABEL_RUNTIMES_LIST=Web service runtime:
+LABEL_SERVERS_LIST=Web service type:
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/EnvironmentUIMessages.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/EnvironmentUIMessages.java
new file mode 100644
index 000000000..96849bcd5
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/EnvironmentUIMessages.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * yyyymmdd bug Email and other contact information
+ * -------- -------- -----------------------------------------------------------
+ * 20060509 119296 pmoogk@ca.ibm.com - Peter Moogk
+ * 20080221 146023 gilberta@ca.ibm.com - Gilbert Andrews
+ * 20080402 222094 kathy@ca.ibm.com - Kathy Chan, Update properties file.
+ *******************************************************************************/
+package org.eclipse.wst.command.internal.env.ui;
+
+import org.eclipse.osgi.util.NLS;
+
+public final class EnvironmentUIMessages extends NLS {
+
+ private static final String BUNDLE_NAME = "org.eclipse.wst.command.internal.env.ui.EnvironmentUI";//$NON-NLS-1$
+
+ private EnvironmentUIMessages() {
+ // Do not instantiate
+ }
+
+ public static String BUTTON_SHOW_ALL_DIALOGS;
+ public static String BUTTON_HIDE_ALL_DIALOGS;
+ public static String CHECKBOX_DO_NOT_SHOW_DIALOG_AGAIN;
+ public static String TOOLTIP_PPAD_PAGE;
+ public static String TOOLTIP_DO_NOT_SHOW_DIALOG_AGAIN;
+ public static String TOOLTIP_PPAD_BUTTON_SHOW_ALL;
+ public static String TOOLTIP_PPAD_BUTTON_HIDE_ALL;
+ public static String TOOLTIP_PPAD_COMBO_RUNTIME;
+ public static String TOOLTIP_PPAD_COMBO_SCENARIO;
+ public static String MSG_ERROR_WIZARD_ID_NOT_FOUND;
+ public static String WIZARD_TITLE_ANT;
+ public static String WIZARD_PAGE_TITLE_ANT;
+ public static String WIZARD_PAGE_DESC_ANT;
+ public static String MSG_STATUS_COPYING_ANT_FILES;
+ public static String MSG_ERR_COPYING_ANT_FILES;
+ public static String MSG_ERR_ANT_FILES_NOT_FOUND;
+ public static String MSG_WARNING_FILE_EXISTS;
+ public static String DIALOG_TITLE_OVERWRITE;
+ public static String MSG_ERROR_OPERATION_TIMED_OUT;
+ public static String LABEL_RUNTIMES_LIST;
+ public static String LABEL_SERVERS_LIST;
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, EnvironmentUIMessages.class);
+ }
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/common/LabelsAndIds.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/common/LabelsAndIds.java
new file mode 100644
index 000000000..b8fb89f02
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/common/LabelsAndIds.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * yyyymmdd bug Email and other contact information
+ * -------- -------- -----------------------------------------------------------
+ * 20080221 146023 gilberta@ca.ibm.com - Gilbert Andrews
+ *******************************************************************************/
+/**
+ */
+package org.eclipse.wst.command.internal.env.ui.common;
+
+import java.util.Vector;
+
+public class LabelsAndIds
+{
+ private Vector labels_ = new Vector();
+ private Vector ids_ = new Vector();
+
+
+ public void add(String id, String label){
+ ids_.add(id);
+ labels_.add(label);
+ }
+
+ public String getId(int index){
+ return (String)ids_.get(index);
+ }
+
+ /**
+ * @return Returns the ids_.
+ */
+ public String[] getIds()
+ {
+ String[] stringArray = new String[ids_.size()];
+ ids_.copyInto(stringArray);
+ return stringArray;
+ }
+
+ public String[] getLabels()
+ {
+ String[] stringArray = new String[ids_.size()];
+ labels_.copyInto(stringArray);
+ return stringArray;
+ }
+
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/common/TimedOperation.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/common/TimedOperation.java
new file mode 100644
index 000000000..9eb37db76
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/common/TimedOperation.java
@@ -0,0 +1,196 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2015 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * yyyymmdd bug Email and other contact information
+ * -------- -------- -----------------------------------------------------------
+ * 20060504 119296 pmoogk@ca.ibm.com - Peter Moogk
+ * 20060822 154750 pmoogk@ca.ibm.com - Peter Moogk
+ * 20150113 457332 jgwest@ca.ibm.com - Jonathan West, TimedWSDLSelectionConditionCommand/TimedOperation classes blocks automated tests with confirmation dialog box
+ *******************************************************************************/
+package org.eclipse.wst.command.internal.env.ui.common;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.operations.AbstractOperation;
+import org.eclipse.core.commands.operations.IUndoContext;
+import org.eclipse.core.commands.operations.IUndoableOperation;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.command.internal.env.ui.EnvironmentUIMessages;
+
+public class TimedOperation implements IUndoableOperation
+{
+ private AbstractOperation operation;
+ private int timeout;
+ private IProgressMonitor tempMonitor;
+ private IAdaptable tempInfo;
+ private IStatus returnStatus;
+ private boolean operationComplete;
+ private String timeOutMessage;
+
+ private boolean headless = false;
+
+ public TimedOperation( AbstractOperation operation, int timeout, String timeOutMessage )
+ {
+ this.operation = operation;
+ this.timeout = timeout;
+ this.timeOutMessage = timeOutMessage;
+ }
+
+ public IStatus execute(IProgressMonitor monitor, IAdaptable info)
+ {
+ Thread executeThread = new Thread( new OperationRunnable() );
+
+ returnStatus = Status.OK_STATUS;
+ tempMonitor = monitor;
+ tempInfo = info;
+ operationComplete = false;
+ executeThread.start();
+
+ synchronized( operation )
+ {
+ while( !operationComplete )
+ {
+ try
+ {
+ operation.wait(timeout);
+ }
+ catch( InterruptedException exc )
+ {
+ String message = exc.getMessage();
+ Status errorStatus = new Status( IStatus.ERROR,"id", 0, message == null ? "" : message, exc );
+ executeThread.interrupt();
+ return errorStatus;
+ }
+
+ if( !operationComplete )
+ {
+
+ Status errorStatus = new Status( IStatus.ERROR,"id", 0, EnvironmentUIMessages.MSG_ERROR_OPERATION_TIMED_OUT, null);
+
+ boolean waitMore;
+ if(!headless)
+ {
+ // We timed out, since the execution thread hasn't set operationComplete to true.
+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ waitMore = MessageDialog.openConfirm(shell, EnvironmentUIMessages.MSG_ERROR_OPERATION_TIMED_OUT, timeOutMessage );
+ } else
+ {
+ // If we are running headless, don't pop-up a message dialog; we should just automatically stop waiting after timeout.
+ waitMore = false;
+ }
+
+ if( !waitMore )
+ {
+ executeThread.interrupt();
+ operationComplete = true;
+ return errorStatus;
+ }
+ }
+ }
+ }
+
+ // We completed successfully. Therefore return the status set in the forked
+ // thread.
+ return returnStatus;
+ }
+
+ private class OperationRunnable implements Runnable
+ {
+ public void run()
+ {
+ try
+ {
+ returnStatus = operation.execute(tempMonitor, tempInfo);
+ }
+ catch( Throwable exc )
+ {
+ String message = exc.getMessage();
+
+ returnStatus = new Status( IStatus.ERROR,"id", 0, message == null ? "" : message, exc );
+ }
+ finally
+ {
+ synchronized( operation )
+ {
+ operationComplete = true;
+ operation.notify();
+ }
+ }
+ }
+ }
+
+ public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
+ {
+ return operation.redo(monitor, info);
+ }
+
+ public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
+ {
+ return operation.undo(monitor, info);
+ }
+ public IUndoContext[] getContexts()
+ {
+ return operation.getContexts();
+ }
+
+ public boolean hasContext(IUndoContext context)
+ {
+ return operation.hasContext(context);
+ }
+
+ public void addContext(IUndoContext context)
+ {
+ operation.addContext(context);
+ }
+
+ public boolean canExecute()
+ {
+ return operation.canExecute();
+ }
+
+ public boolean canRedo()
+ {
+ return operation.canRedo();
+ }
+
+ public boolean canUndo()
+ {
+ return operation.canUndo();
+ }
+
+ public void dispose()
+ {
+ operation.dispose();
+ }
+
+ public String getLabel()
+ {
+ return operation.getLabel();
+ }
+
+ public void removeContext(IUndoContext context)
+ {
+ operation.removeContext(context);
+ }
+
+ public void setLabel(String name)
+ {
+ operation.setLabel(name);
+ }
+
+ public void setHeadless(boolean headless)
+ {
+ this.headless = headless;
+ }
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/AntExtension.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/AntExtension.java
new file mode 100644
index 000000000..7c34ea9c8
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/AntExtension.java
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * yyyymmdd bug Email and other contact information
+ * -------- -------- -----------------------------------------------------------
+ * 20080221 146023 gilberta@ca.ibm.com - Gilbert Andrews
+ *******************************************************************************/
+/**
+ */
+package org.eclipse.wst.command.internal.env.ui.dialog;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+
+public class AntExtension {
+
+ private String label_;
+ private String runtime_;
+ private String scenario_;
+ private String id_;
+ private String runtimeID_;
+ private String plugin_;
+ private String path_;
+ private String wsgenpath_;
+ private IConfigurationElement element_;
+
+ public AntExtension(IConfigurationElement element)
+ {
+ element_ = element;
+ }
+
+ public String getLabel()
+ {
+ if (label_==null)
+ {
+ label_ = element_.getAttribute("label");
+ }
+ return label_;
+ }
+
+ public String getRuntimeLabel()
+ {
+ if (runtime_==null)
+ {
+ runtime_ = element_.getAttribute("runtimelabel");
+ }
+ return runtime_;
+ }
+
+ public String getScenarioLabel()
+ {
+ if (scenario_==null)
+ {
+ scenario_ = element_.getAttribute("scenariolabel");
+ }
+ return scenario_;
+ }
+
+ public String getID()
+ {
+ if (id_==null)
+ {
+ id_ = element_.getAttribute("id");
+ }
+ return id_;
+ }
+
+ public String getRuntimeID()
+ {
+ if (runtimeID_==null)
+ {
+ runtimeID_ = element_.getAttribute("runtimeid");
+ }
+ return runtimeID_;
+ }
+
+ public String getPlugin()
+ {
+ if (plugin_==null)
+ {
+ plugin_ = element_.getAttribute("pluginlocation");
+ }
+ return plugin_;
+ }
+
+ public String getPath()
+ {
+ if (path_==null)
+ {
+ path_ = element_.getAttribute("path");
+ }
+ return path_;
+ }
+
+ public String getWSGenPath()
+ {
+ if (wsgenpath_==null)
+ {
+ wsgenpath_ = element_.getAttribute("wsgenpath");
+ }
+ return wsgenpath_;
+ }
+
+
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/AntExtensionCreation.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/AntExtensionCreation.java
new file mode 100644
index 000000000..4974f112c
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/AntExtensionCreation.java
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * yyyymmdd bug Email and other contact information
+ * -------- -------- -----------------------------------------------------------
+ * 20080221 146023 gilberta@ca.ibm.com - Gilbert Andrews
+ *******************************************************************************/
+/**
+ */
+package org.eclipse.wst.command.internal.env.ui.dialog;
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.wst.command.internal.env.ui.common.LabelsAndIds;
+
+public class AntExtensionCreation {
+
+ private Hashtable antExtentions_;
+ private static AntExtensionCreation antExtensionC_;
+ private Hashtable runtimeStructs_ = null;
+
+
+ public static AntExtensionCreation getInstance(){
+ if(antExtensionC_ == null){
+ antExtensionC_ = new AntExtensionCreation();
+ }
+ return antExtensionC_;
+ }
+
+ public void createExtensions()
+ {
+ antExtentions_ = new Hashtable();
+ IExtensionRegistry reg = Platform.getExtensionRegistry();
+ //Load by reading all extensions to org.eclipse.wst.command.env.ui.antfiles
+ IConfigurationElement[] antExts = reg.getConfigurationElementsFor("org.eclipse.wst.command.env.ui", "antfiles");
+
+ for(int idx=0; idx<antExts.length; idx++)
+ {
+ IConfigurationElement elem = antExts[idx];
+ if (elem.getName().equals("antfiles"))
+ {
+ AntExtension ae = new AntExtension(elem);
+ antExtentions_.put(elem.getAttribute("id"), ae);
+ }
+ }
+ }
+
+ public void createRuntimes(){
+ Enumeration antExtsEnum = antExtentions_.elements();
+ runtimeStructs_ = new Hashtable();
+
+ while(antExtsEnum.hasMoreElements()){
+ AntExtension antExt = (AntExtension)antExtsEnum.nextElement();
+ RuntimeStruct rs = (RuntimeStruct)runtimeStructs_.get(antExt.getRuntimeID());
+ if(rs == null){
+ rs = new RuntimeStruct(antExt.getRuntimeID());
+ rs.setRuntimeLabel(antExt.getRuntimeLabel());
+ rs.setScenario(antExt.getID(), antExt.getScenarioLabel());
+ runtimeStructs_.put(rs.getRuntimeID(), rs);
+ }
+ else{
+ rs.setScenario(antExt.getID(), antExt.getScenarioLabel());
+ }
+ }
+ }
+
+ public LabelsAndIds getRuntimeLabelsAndIds(){
+ if(antExtentions_ == null) createExtensions();
+ if(runtimeStructs_ == null)createRuntimes();
+ LabelsAndIds runtime = new LabelsAndIds();
+ Enumeration runtimeStructs = runtimeStructs_.elements();
+ while(runtimeStructs.hasMoreElements()){
+ RuntimeStruct rs = (RuntimeStruct)runtimeStructs.nextElement();
+ runtime.add(rs.getRuntimeID(),rs.getRuntimeLabel());
+ }
+ return runtime;
+ }
+
+ public LabelsAndIds getScenarioLabelsByRuntime(String runtimeId){
+ if(antExtentions_ == null) createExtensions();
+ if(runtimeStructs_ == null) createRuntimes();
+ RuntimeStruct rs = (RuntimeStruct)runtimeStructs_.get(runtimeId);
+ return rs.getScenarioLabels();
+ }
+
+
+ public AntExtension getAnrExtByScenario(String selection){
+ if(antExtentions_ == null) return null;
+ return (AntExtension)antExtentions_.get(selection);
+ }
+
+
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/AntFileImportWizard.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/AntFileImportWizard.java
new file mode 100644
index 000000000..24f7f6a6c
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/AntFileImportWizard.java
@@ -0,0 +1,310 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * yyyymmdd bug Email and other contact information
+ * -------- -------- -----------------------------------------------------------
+ * 20060315 128711 joan@ca.ibm.com - Joan Haggarty
+ * 20080221 146023 gilberta@ca.ibm.com - Gilbert Andrews
+ * 20080512 222094 makandre@ca.ibm.com - Andrew Mak, Error handling when Ant template cannot be found
+ *******************************************************************************/
+package org.eclipse.wst.command.internal.env.ui.dialog;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchPartReference;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.part.ISetSelectionTarget;
+import org.eclipse.wst.command.internal.env.common.FileResourceUtils;
+import org.eclipse.wst.command.internal.env.core.common.ProgressUtils;
+import org.eclipse.wst.command.internal.env.core.common.StatusUtils;
+import org.eclipse.wst.command.internal.env.core.context.ResourceContext;
+import org.eclipse.wst.command.internal.env.core.context.TransientResourceContext;
+import org.eclipse.wst.command.internal.env.plugin.EnvPlugin;
+import org.eclipse.wst.command.internal.env.ui.EnvironmentUIMessages;
+import org.eclipse.wst.command.internal.env.ui.plugin.EnvUIPlugin;
+import org.eclipse.wst.common.environment.IStatusHandler;
+import org.eclipse.wst.common.environment.NullStatusHandler;
+import org.osgi.framework.Bundle;
+
+public class AntFileImportWizard extends Wizard implements INewWizard {
+
+ //private IConfigurationElement fConfigElement;
+ private AntFileImportWizardPage mainPage;
+ /**
+ * The workbench.
+ */
+ private IWorkbench workbench;
+ private AntExtensionCreation antExtC_;
+
+ /**
+ * The current selection.
+ */
+ protected IStructuredSelection selection;
+
+ public AntFileImportWizard()
+ {
+ super();
+ setWindowTitle(EnvironmentUIMessages.WIZARD_TITLE_ANT);
+ }
+
+ public void setWindowTitle(String newTitle) {
+ super.setWindowTitle(newTitle);
+ }
+
+ public void addPages() {
+ super.addPages();
+ mainPage = new AntFileImportWizardPage(EnvironmentUIMessages.WIZARD_PAGE_TITLE_ANT, getSelection());
+ addPage(mainPage);
+ }
+
+ public boolean performFinish() {
+ antExtC_ = AntExtensionCreation.getInstance();
+ IPath destination = mainPage.getPath();
+ if (destination == null)
+ {
+ return false;
+ }
+ else
+ {
+ AntExtension antExt = antExtC_.getAnrExtByScenario(mainPage.getScenario());
+ Bundle wsBundle = Platform.getBundle(antExt.getPlugin());
+ IPath propertyPath = new Path(antExt.getPath());
+ URL propertyURL = FileLocator.find( wsBundle, propertyPath, null);
+
+ if (propertyURL == null) {
+ mainPage.displayErrorDialog(
+ NLS.bind(EnvironmentUIMessages.MSG_ERR_ANT_FILES_NOT_FOUND, antExt.getPath()));
+ return false;
+ }
+
+ URLConnection conn;
+ InputStream isProperty = null;
+ try{
+ conn = propertyURL.openConnection();
+ isProperty = conn.getInputStream();
+ }
+ catch (IOException ioe){}
+
+ Plugin sourcePlugin = EnvPlugin.getInstance();
+ String targetFile = antExt.getPath();
+ createIFile(sourcePlugin, isProperty, destination, targetFile, (IProgressMonitor)new NullProgressMonitor());
+
+ IPath wsgenPath = new Path(antExt.getWSGenPath());
+ URL fileURL = FileLocator.find( wsBundle, wsgenPath, null);
+
+ if (fileURL == null) {
+ mainPage.displayErrorDialog(
+ NLS.bind(EnvironmentUIMessages.MSG_ERR_ANT_FILES_NOT_FOUND, antExt.getWSGenPath()));
+ return false;
+ }
+
+ URLConnection connWSGen;
+ InputStream isWSGen = null;
+ try{
+ connWSGen = fileURL.openConnection();
+ isWSGen = connWSGen.getInputStream();
+ }
+ catch (IOException ioe){}
+
+ String targetFileWSGen = antExt.getWSGenPath();
+ createIFile(sourcePlugin, isWSGen, destination, targetFileWSGen, (IProgressMonitor)new NullProgressMonitor());
+
+
+
+ }
+ return true;
+ }
+
+
+
+ private IStatus createIFile(Plugin plugin, InputStream source, IPath targetPath, String targetFile, /*IEnvironment env,*/ IProgressMonitor monitor )
+ {
+
+ if (plugin != null)
+ {
+ IPath target = targetPath.append(new Path(targetFile));
+
+ ProgressUtils.report( monitor, EnvironmentUIMessages.MSG_STATUS_COPYING_ANT_FILES);
+ try
+ {
+ ResourceContext context = new TransientResourceContext();
+ // check to see if file exists before copy
+ IResource resource = FileResourceUtils.findResource(target);
+
+ if (resource != null)
+ {
+ MessageBox overwriteBox = new MessageBox(getShell(), SWT.ICON_QUESTION|SWT.YES|SWT.NO);
+ overwriteBox.setMessage(EnvironmentUIMessages.bind(EnvironmentUIMessages.MSG_WARNING_FILE_EXISTS, target.toString()));
+ overwriteBox.setText(EnvironmentUIMessages.DIALOG_TITLE_OVERWRITE);
+ int result = overwriteBox.open();
+ if (result != SWT.NO)
+ FileResourceUtils.createFile(context, target, source,
+ monitor, (IStatusHandler)new NullStatusHandler());
+ else
+ return Status.CANCEL_STATUS;
+ }
+ else
+ {
+ FileResourceUtils.createFile(context, target, source,
+ monitor, (IStatusHandler)new NullStatusHandler());
+ }
+ }
+ catch (Exception e) {
+ return StatusUtils.errorStatus(EnvironmentUIMessages.MSG_ERR_COPYING_ANT_FILES, e);
+ }
+ }
+ return Status.OK_STATUS;
+ }
+
+ /**
+ * Returns the selection which was passed to <code>init</code>.
+ *
+ * @return the selection
+ */
+ public IStructuredSelection getSelection() {
+ return selection;
+ }
+
+ /**
+ * Returns the workbench which was passed to <code>init</code>.
+ *
+ * @return the workbench
+ */
+ public IWorkbench getWorkbench() {
+ return workbench;
+ }
+
+ /**
+ * The <code>BasicNewResourceWizard</code> implementation of this
+ * <code>IWorkbenchWizard</code> method records the given workbench and
+ * selection, and initializes the default banner image for the pages
+ * by calling <code>initializeDefaultPageImageDescriptor</code>.
+ * Subclasses may extend.
+ */
+ public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
+ this.workbench = workbench;
+ this.selection = currentSelection;
+
+ initializeDefaultPageImageDescriptor();
+ }
+
+ /**
+ * Initializes the default page image descriptor to an appropriate banner.
+ * By calling <code>setDefaultPageImageDescriptor</code>.
+ * The default implementation of this method uses a generic new wizard image.
+ * <p>
+ * Subclasses may reimplement.
+ * </p>
+ */
+ protected void initializeDefaultPageImageDescriptor() {
+ ImageDescriptor desc = EnvUIPlugin.getImageDescriptor("icons/full/wizban/newantfiles_wiz.png");//$NON-NLS-1$
+ setDefaultPageImageDescriptor(desc);
+ }
+
+ /**
+ * Selects and reveals the newly added resource in all parts
+ * of the active workbench window's active page.
+ *
+ * @see ISetSelectionTarget
+ */
+ protected void selectAndReveal(IResource newResource) {
+ selectAndReveal(newResource, getWorkbench().getActiveWorkbenchWindow());
+ }
+
+ /**
+ * Attempts to select and reveal the specified resource in all
+ * parts within the supplied workbench window's active page.
+ * <p>
+ * Checks all parts in the active page to see if they implement <code>ISetSelectionTarget</code>,
+ * either directly or as an adapter. If so, tells the part to select and reveal the
+ * specified resource.
+ * </p>
+ *
+ * @param resource the resource to be selected and revealed
+ * @param window the workbench window to select and reveal the resource
+ *
+ * @see ISetSelectionTarget
+ */
+ public static void selectAndReveal(IResource resource,
+ IWorkbenchWindow window) {
+ // validate the input
+ if (window == null || resource == null)
+ return;
+ IWorkbenchPage page = window.getActivePage();
+ if (page == null)
+ return;
+
+ // get all the view and editor parts
+ List parts = new ArrayList();
+ IWorkbenchPartReference refs[] = page.getViewReferences();
+ for (int i = 0; i < refs.length; i++) {
+ IWorkbenchPart part = refs[i].getPart(false);
+ if (part != null)
+ parts.add(part);
+ }
+ refs = page.getEditorReferences();
+ for (int i = 0; i < refs.length; i++) {
+ if (refs[i].getPart(false) != null)
+ parts.add(refs[i].getPart(false));
+ }
+
+ final ISelection selection = new StructuredSelection(resource);
+ Iterator itr = parts.iterator();
+ while (itr.hasNext()) {
+ IWorkbenchPart part = (IWorkbenchPart) itr.next();
+
+ // get the part's ISetSelectionTarget implementation
+ ISetSelectionTarget target = null;
+ if (part instanceof ISetSelectionTarget)
+ target = (ISetSelectionTarget) part;
+ else
+ target = (ISetSelectionTarget) part
+ .getAdapter(ISetSelectionTarget.class);
+
+ if (target != null) {
+ // select and reveal resource
+ final ISetSelectionTarget finalTarget = target;
+ window.getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ finalTarget.selectReveal(selection);
+ }
+ });
+ }
+ }
+ }
+
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/AntFileImportWizardPage.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/AntFileImportWizardPage.java
new file mode 100644
index 000000000..af01cd1be
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/AntFileImportWizardPage.java
@@ -0,0 +1,206 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * yyyymmdd bug Email and other contact information
+ * -------- -------- -----------------------------------------------------------
+ * 20080221 146023 gilberta@ca.ibm.com - Gilbert Andrews
+ * 20080512 222094 makandre@ca.ibm.com - Andrew Mak, Error handling when Ant template cannot be found
+ * 20080618 237671 makandre@ca.ibm.com - Andrew Mak, Label on Ant files wizard is truncated
+ * 20080716 238059 makandre@ca.ibm.com - Andrew Mak, New ant files wizard not working
+ * 20081023 251911 ericdp@ca.ibm.com - Eric D. Peters, NPE in .log when choosing ant files to import
+ *******************************************************************************/
+package org.eclipse.wst.command.internal.env.ui.dialog;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+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.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.WizardResourceImportPage;
+import org.eclipse.wst.command.internal.env.ui.EnvironmentUIMessages;
+import org.eclipse.wst.command.internal.env.ui.common.LabelsAndIds;
+
+public class AntFileImportWizardPage extends WizardResourceImportPage{
+
+ private String pluginId_ = "org.eclipse.wst.command.internal.env.ui";
+
+ /* CONTEXT_ID SRPF0001 for server preference on the server runtime preference page */
+ private String INFOPOP_SRPF_SERVER_PREF = pluginId_ + ".SRPF0001";
+ private Combo scenario_;
+
+ /* CONTEXT_ID SRPF0002 for runtime preference on the server runtime preference page */
+ private String INFOPOP_SRPF_RUNTIME_PREF = pluginId_ + ".SRPF0002";
+ private Combo runtime_;
+
+ private AntExtensionCreation antExtC_;
+ private LabelsAndIds labelsAndIdsScenario_;
+ private LabelsAndIds labelsAndIdsRuntime_;
+// private int runtimeIdx_;
+
+ public AntFileImportWizardPage(String pageName,
+ IStructuredSelection selection) {
+ super("WSAntFilesPage1", selection);//$NON-NLS-1$
+ setTitle(pageName);
+ setDescription(EnvironmentUIMessages.WIZARD_PAGE_DESC_ANT);
+ }
+
+
+ public Combo createCombo( Composite parent, String labelName, String tooltip, String infopop, int style )
+ {
+ tooltip = tooltip == null ? labelName : tooltip;
+
+ if( labelName != null )
+ {
+ Label label = new Label( parent, SWT.NONE);
+ label.setText( labelName );
+ label.setToolTipText( tooltip );
+ }
+
+ Combo combo = new Combo( parent, style );
+ GridData griddata = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
+
+ combo.setLayoutData( griddata );
+ combo.setToolTipText( tooltip );
+
+ if( infopop != null ) PlatformUI.getWorkbench().getHelpSystem().setHelp( combo, pluginId_ + "." + infopop );
+
+ return combo;
+ }
+
+ protected ITreeContentProvider getFileProvider() {
+ return null;
+ }
+
+ public IPath getPath()
+ {
+ return getContainerFullPath();
+ }
+
+ protected void createSourceGroup(Composite parent) {
+ Composite page = new Composite(parent, SWT.NONE);
+ GridLayout gl = new GridLayout();
+ gl.numColumns = 2;
+ page.setLayout(gl);
+ GridData gd = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
+ page.setLayoutData(gd);
+
+ runtime_ = createCombo(page,EnvironmentUIMessages.LABEL_RUNTIMES_LIST,
+ EnvironmentUIMessages.TOOLTIP_PPAD_COMBO_RUNTIME,
+ INFOPOP_SRPF_RUNTIME_PREF,
+ SWT.SINGLE|SWT.BORDER|SWT.READ_ONLY);
+
+ runtime_.addSelectionListener(new SelectionListener(){
+ public void widgetDefaultSelected(SelectionEvent e) {}
+
+ public void widgetSelected(SelectionEvent e) {
+ handleRuntimeSelected();
+ }
+ });
+
+ scenario_ = createCombo(page,EnvironmentUIMessages.LABEL_SERVERS_LIST,
+ EnvironmentUIMessages.TOOLTIP_PPAD_COMBO_SCENARIO,
+ INFOPOP_SRPF_SERVER_PREF,
+ SWT.SINGLE|SWT.BORDER|SWT.READ_ONLY);
+
+ iniatialize();
+ }
+
+ protected boolean validateSourceGroup() {
+ return runtime_.getItemCount() > 0;
+ }
+
+ protected ITreeContentProvider getFolderProvider() {
+ return null;
+ }
+
+ protected void createOptionsGroup(Composite parent) {
+ //empty - don't want an options group
+ }
+
+ public void handleEvent(Event event)
+ {
+ if (scenario_ == event.widget)
+ handleScenarioSelected();
+ else if (runtime_ == event.widget)
+ handleRuntimeSelected();
+ else
+ super.handleEvent(event);
+
+ }
+
+ public void handleRuntimeSelected(){
+ labelsAndIdsScenario_ = antExtC_.getScenarioLabelsByRuntime(labelsAndIdsRuntime_.getId(runtime_.getSelectionIndex()));
+ setScenarioLabels(labelsAndIdsScenario_.getLabels());
+ }
+
+ public void handleScenarioSelected(){
+
+ }
+
+ private void iniatialize(){
+ antExtC_ = AntExtensionCreation.getInstance();
+ labelsAndIdsRuntime_ = antExtC_.getRuntimeLabelsAndIds();
+ if (labelsAndIdsRuntime_.getLabels().length > 0)
+ setRuntimeLabels(labelsAndIdsRuntime_.getLabels());
+ }
+
+ public String getScenario(){
+ return labelsAndIdsScenario_.getId(scenario_.getSelectionIndex());
+ }
+
+ private void setSelection(Combo combo, String s)
+ {
+ String[] items = combo.getItems();
+ for (int i=0; i<items.length; i++)
+ {
+ if (items[i].equals(s))
+ {
+ combo.select(i);
+ return;
+ }
+ }
+ }
+
+ private void setRuntimeLabels(String[] runtimeLabels)
+ {
+ runtime_.setItems(runtimeLabels);
+ //until the preferences are set up
+ setSelection(runtime_,runtimeLabels[0]);
+// runtimeIdx_ = 0;
+ labelsAndIdsScenario_ = antExtC_.getScenarioLabelsByRuntime(labelsAndIdsRuntime_.getId(0));
+ setScenarioLabels(labelsAndIdsScenario_.getLabels());
+ }
+
+ private void setScenarioLabels(String[] scenarioLabels)
+ {
+ scenario_.setItems(scenarioLabels);
+ //until the preferences are set up
+ setSelection(scenario_,scenarioLabels[0]);
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.dialogs.WizardDataTransferPage#displayErrorDialog(java.lang.String)
+ */
+ protected void displayErrorDialog(String message) {
+ super.displayErrorDialog(message);
+ }
+}
+
+
+
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/ErrorDialog.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/ErrorDialog.java
new file mode 100644
index 000000000..3bd1c1102
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/ErrorDialog.java
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.command.internal.env.ui.dialog;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+
+
+/**
+ * A dialog to display one or more errors to the user, as contained in an
+ * <code>Status</code> object. If an error contains additional detailed
+ * information then a Details button is automatically supplied, which shows or
+ * hides an error details viewer when pressed by the user.
+ *
+ */
+public class ErrorDialog extends MessageDialog
+{
+
+ /**
+ * Creates an error dialog. Note that the dialog will have no visual
+ * representation (no widgets) until it is told to open.
+ * <p>
+ * Normally one should use <code>openError</code> to create and open one of
+ * these. This constructor is useful only if the error object being displayed
+ * contains child items <it>and</it> you need to specify a mask which will
+ * be used to filter the displaying of these children.
+ * </p>
+ *
+ * @param parentShell
+ * the shell under which to create this dialog
+ * @param dialogTitle
+ * the title to use for this dialog, or <code>null</code> to
+ * indicate that the default title should be used
+ * @param message
+ * the message to show in this dialog, or <code>null</code> to
+ * indicate that the error's message should be shown as the
+ * primary message
+ * @param status
+ * the error to show to the user
+ * @param displayMask
+ * the mask to use to filter the displaying of child items, as per
+ * <code>Status.matches</code>
+ */
+ public ErrorDialog(
+ Shell parentShell,
+ String dialogTitle,
+ String message,
+ IStatus status,
+ int displayMask)
+ {
+ super(parentShell, dialogTitle, message, status, displayMask);
+ }
+
+ /*
+ * (non-Javadoc) This should also be overwritten Method declared on Dialog.
+ */
+ protected void createButtonsForButtonBar(Composite parent)
+ {
+ // create OK and Details buttons
+ createButton(
+ parent,
+ StatusDialogConstants.OK_ID,
+ IDialogConstants.OK_LABEL,
+ true);
+ if (status.isMultiStatus() || status.getException() != null )
+ {
+ detailsButton =
+ createButton(
+ parent,
+ StatusDialogConstants.DETAILS_ID,
+ IDialogConstants.SHOW_DETAILS_LABEL,
+ false);
+ }
+ }
+
+ /*
+ * This is one of the few methods that needs to be overwritten by the
+ * subclasses. The image names can be found in the Dialog class
+ */
+ protected Image getDialogImage()
+ {
+ // create image
+ return PlatformUI.getWorkbench().getDisplay().getSystemImage(SWT.ICON_ERROR);
+ }
+
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/InfoDialog.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/InfoDialog.java
new file mode 100644
index 000000000..7107db6e1
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/InfoDialog.java
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.command.internal.env.ui.dialog;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+
+
+/**
+ * A dialog to display one or more errors to the user, as contained in an
+ * <code>Status</code> object. If an error contains additional detailed
+ * information then a Details button is automatically supplied, which shows or
+ * hides an error details viewer when pressed by the user.
+ *
+ */
+public class InfoDialog extends MessageDialog
+{
+ /**
+ * Creates an error dialog. Note that the dialog will have no visual
+ * representation (no widgets) until it is told to open.
+ * <p>
+ * Normally one should use <code>openError</code> to create and open one of
+ * these. This constructor is useful only if the error object being displayed
+ * contains child items <it>and</it> you need to specify a mask which will
+ * be used to filter the displaying of these children.
+ * </p>
+ *
+ * @param parentShell
+ * the shell under which to create this dialog
+ * @param dialogTitle
+ * the title to use for this dialog, or <code>null</code> to
+ * indicate that the default title should be used
+ * @param message
+ * the message to show in this dialog, or <code>null</code> to
+ * indicate that the error's message should be shown as the
+ * primary message
+ * @param status
+ * the error to show to the user
+ * @param displayMask
+ * the mask to use to filter the displaying of child items, as per
+ * <code>Status.matches</code>
+ */
+ public InfoDialog(
+ Shell parentShell,
+ String dialogTitle,
+ String message,
+ IStatus status,
+ int displayMask)
+ {
+ super(parentShell, dialogTitle, message, status, displayMask);
+ }
+
+ /*
+ * (non-Javadoc) This should also be overwritten Method declared on Dialog.
+ */
+ protected void createButtonsForButtonBar(Composite parent)
+ {
+ // create OK and Details buttons
+ createButton(
+ parent,
+ StatusDialogConstants.OK_ID,
+ IDialogConstants.OK_LABEL,
+ true);
+ if (status.isMultiStatus() )
+ {
+ detailsButton =
+ createButton(
+ parent,
+ StatusDialogConstants.DETAILS_ID,
+ IDialogConstants.SHOW_DETAILS_LABEL,
+ false);
+ }
+ }
+
+ /*
+ * This is one of the few methods that needs to be overwritten by the
+ * subclasses. The image names can be found in the Dialog class
+ */
+ protected Image getDialogImage()
+ {
+ // create image
+ return PlatformUI.getWorkbench().getDisplay().getSystemImage(SWT.ICON_INFORMATION);
+ }
+
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/MessageDialog.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/MessageDialog.java
new file mode 100644
index 000000000..ddaf723b3
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/MessageDialog.java
@@ -0,0 +1,585 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * yyyymmdd bug Email and other contact information
+ * -------- -------- -----------------------------------------------------------
+ * 20060504 128984 pmoogk@ca.ibm.com - Peter Moogk
+ *******************************************************************************/
+package org.eclipse.wst.command.internal.env.ui.dialog;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+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.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.List;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.command.internal.env.common.StringUtils;
+import org.eclipse.wst.common.environment.Choice;
+
+
+/**
+ * A dialog to display one or more errors to the user, as contained in an
+ * <code>Status</code> object. If an error contains additional detailed
+ * information then a Details button is automatically supplied, which shows or
+ * hides an error details viewer when pressed by the user.
+ *
+ */
+public class MessageDialog extends Dialog
+{
+ protected Composite parent;
+
+ /**
+ * Reserve room for this many list items.
+ */
+ protected static final int LIST_ITEM_COUNT = 7;
+
+ /**
+ * The Details button.
+ */
+ protected Button detailsButton;
+
+ /**
+ * The title of the dialog.
+ */
+ protected String title;
+
+ /**
+ * The message to display.
+ */
+ protected String message;
+
+ /**
+ * The SWT list control that displays the error details.
+ */
+ protected List list;
+ protected Text details;
+
+ /**
+ * Indicates whether the error details viewer is currently created.
+ */
+ protected boolean listCreated = false;
+ protected boolean detailsCreated = false;
+
+ /**
+ * Filter mask for determining which status items to display.
+ */
+ protected int displayMask = 0xFFFF;
+
+ /**
+ * The main status object.
+ */
+ protected IStatus status;
+
+ private Point savedSize = null;
+
+ /**
+ * List of the main error object's detailed errors (element type: <code>Status</code>).
+ */
+ protected java.util.List statusList;
+ /**
+ * Creates an error dialog. Note that the dialog will have no visual
+ * representation (no widgets) until it is told to open.
+ * <p>
+ * Normally one should use <code>openError</code> to create and open one of
+ * these. This constructor is useful only if the error object being displayed
+ * contains child items <it>and</it> you need to specify a mask which will
+ * be used to filter the displaying of these children.
+ * </p>
+ *
+ * @param parentShell
+ * the shell under which to create this dialog
+ * @param dialogTitle
+ * the title to use for this dialog, or <code>null</code> to
+ * indicate that the default title should be used
+ * @param message
+ * the message to show in this dialog, or <code>null</code> to
+ * indicate that the error's message should be shown as the
+ * primary message
+ * @param status
+ * the error to show to the user
+ * @param displayMask
+ * the mask to use to filter the displaying of child items, as per
+ * <code>Status.matches</code>
+ */
+ public MessageDialog(
+ Shell parentShell,
+ String dialogTitle,
+ String message,
+ IStatus status,
+ int displayMask)
+ {
+ super(parentShell);
+ this.title = dialogTitle == null ? JFaceResources.getString("Problem_Occurred") : //$NON-NLS-1$
+ dialogTitle;
+ this.message = message == null ? status.getMessage() : JFaceResources.format("Reason", new Object[] { message, status.getMessage()}); //$NON-NLS-1$
+ this.status = status;
+ statusList = Arrays.asList(status.getChildren());
+ this.displayMask = displayMask;
+ setShellStyle(SWT.DIALOG_TRIM | SWT.RESIZE | SWT.APPLICATION_MODAL);
+ }
+ /*
+ * (non-Javadoc) Method declared on Dialog. Handles the pressing of the Ok or
+ * Details button in this dialog. If the Ok button was pressed then close
+ * this dialog. If the Details button was pressed then toggle the displaying
+ * of the error details area. Note that the Details button will only be
+ * visible if the error being displayed specifies child details.
+ */
+ protected void buttonPressed(int id)
+ {
+ if (id == StatusDialogConstants.DETAILS_ID)
+ { // was the details button pressed?
+ toggleDetailsArea();
+ }
+ else
+ {
+ super.buttonPressed(id);
+ }
+ }
+ /*
+ * (non-Javadoc) Method declared in Window.
+ */
+ protected void configureShell(Shell shell)
+ {
+ super.configureShell(shell);
+ shell.setText(title);
+ }
+ /*
+ * (non-Javadoc) This should also be overwritten Method declared on Dialog.
+ */
+ protected void createButtonsForButtonBar(Composite parent)
+ {
+ // create OK and Details buttons
+ createButton(
+ parent,
+ StatusDialogConstants.OK_ID,
+ IDialogConstants.OK_LABEL,
+ true);
+ if (status.isMultiStatus() || status.getException() != null )
+ {
+ detailsButton =
+ createButton(
+ parent,
+ StatusDialogConstants.DETAILS_ID,
+ IDialogConstants.SHOW_DETAILS_LABEL,
+ false);
+ }
+
+ parent.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ));
+ }
+
+ /*
+ * This is one of the few methods that needs to be overwritten by the
+ * subclasses. The image names can be found in the Dialog class
+ */
+ protected Image getDialogImage()
+ {
+ // create image
+ return PlatformUI.getWorkbench().getDisplay().getSystemImage(SWT.ICON_INFORMATION);
+ }
+
+ /*
+ * (non-Javadoc) Method declared on Dialog. Creates and returns the contents
+ * of the upper part of the dialog (above the button bar).
+ */
+ protected Control createDialogArea(Composite parent)
+ {
+ this.parent = parent;
+
+ // create composite
+ Composite composite = (Composite) super.createDialogArea(parent);
+ Composite imageAndLabel = new Composite(composite, SWT.NONE);
+ GridLayout gl = new GridLayout();
+ gl.numColumns = 2;
+ imageAndLabel.setLayout(gl);
+ imageAndLabel.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+ composite.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ));
+
+ // create image
+ Image image = getDialogImage();
+ if (image != null)
+ {
+ Label label = new Label(imageAndLabel, 0);
+ image.setBackground(label.getBackground());
+ label.setImage(image);
+ label.setLayoutData(
+ new GridData(
+ GridData.HORIZONTAL_ALIGN_CENTER
+ | GridData.VERTICAL_ALIGN_BEGINNING));
+ }
+
+ // create message
+ if (message != null)
+ {
+ Text text = new Text(imageAndLabel, SWT.READ_ONLY|SWT.WRAP);
+ text.setText(message);
+ GridData data =
+ new GridData(
+ GridData.GRAB_HORIZONTAL
+ | GridData.GRAB_VERTICAL
+ | GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.VERTICAL_ALIGN_CENTER);
+ data.widthHint =
+ convertHorizontalDLUsToPixels(
+ IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
+
+ text.setLayoutData(data);
+ text.setFont(parent.getFont());
+ }
+
+ return composite;
+ }
+
+ protected List createDropDownList(Composite parent)
+ {
+ // create the list
+ list = new List(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
+
+ // fill the list
+ populateList(list);
+
+ GridData data =
+ new GridData(
+ GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.GRAB_HORIZONTAL
+ | GridData.VERTICAL_ALIGN_FILL
+ | GridData.GRAB_VERTICAL);
+ data.heightHint = list.getItemHeight() * LIST_ITEM_COUNT;
+ list.setLayoutData(data);
+ listCreated = true;
+ return list;
+ }
+ protected Text createDropDownDetails(Composite parent)
+ {
+ details = new Text(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY | SWT.WRAP );
+ //details.setEditable(false);
+ Color color = parent.getShell().getDisplay().getSystemColor( SWT.COLOR_WHITE );
+ details.setBackground(color);
+ populateDetails(details, status, 0);
+ GridData data =
+ new GridData(
+ GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.GRAB_HORIZONTAL
+ | GridData.VERTICAL_ALIGN_FILL
+ | GridData.GRAB_VERTICAL);
+
+ details.setLayoutData(data);
+ details.setSelection(0);
+ detailsCreated = true;
+ return details;
+ }
+ /*
+ * (non-Javadoc) Method declared on Window.
+ */
+ /**
+ * Extends <code>Window.open()</code>. Opens an error dialog to display
+ * the error. If you specified a mask to filter the displaying of these
+ * children, the error dialog will only be displayed if there is at least one
+ * child status matching the mask.
+ */
+ public int open()
+ {
+ if (shouldDisplay(status, displayMask))
+ {
+ return super.open();
+ }
+ return 0;
+ }
+ /**
+ * This essentially does the work of a factory Opens an error dialog to
+ * display the given error. Use this method if the error object being
+ * displayed does not contain child items, or if you wish to display all such
+ * items without filtering.
+ *
+ * @param parent
+ * the parent shell of the dialog, or <code>null</code> if none
+ * @param dialogTitle
+ * the title to use for this dialog, or <code>null</code> to
+ * indicate that the default title should be used
+ * @param message
+ * the message to show in this dialog, or <code>null</code> to
+ * indicate that the error's message should be shown as the
+ * primary message
+ * @param status
+ * the error to show to the user
+ * @return the code of the button that was pressed that resulted in this
+ * dialog closing. This will be <code>Dialog.OK</code> if the OK
+ * button was pressed, or <code>Dialog.CANCEL</code> if this
+ * dialog's close window decoration or the ESC key was used.
+ */
+ public static int openMessage(
+ Shell parent,
+ String dialogTitle,
+ String message,
+ IStatus status)
+ {
+
+ switch (status.getSeverity())
+ {
+ case IStatus.INFO :
+ return openInfo(
+ parent,
+ dialogTitle,
+ message,
+ status,
+ IStatus.OK | IStatus.INFO | IStatus.WARNING | IStatus.ERROR);
+ case IStatus.WARNING :
+ return openWarning(
+ parent,
+ dialogTitle,
+ message,
+ status,
+ IStatus.OK | IStatus.INFO | IStatus.WARNING | IStatus.ERROR);
+ default :
+ return openError(
+ parent,
+ dialogTitle,
+ message,
+ status,
+ IStatus.OK | IStatus.INFO | IStatus.WARNING | IStatus.ERROR);
+ }
+
+ }
+
+ public static int openMessage(
+ Shell parent,
+ String dialogTitle,
+ String message,
+ IStatus status,
+ Choice[] options)
+ {
+
+ return openOptions(
+ parent,
+ dialogTitle,
+ message,
+ status,
+ IStatus.OK | IStatus.INFO | IStatus.WARNING | IStatus.ERROR,
+ options);
+ }
+
+ /**
+ * Opens an error dialog to display the given error. Use this method if the
+ * error object being displayed contains child items <it>and</it> you wish
+ * to specify a mask which will be used to filter the displaying of these
+ * children. The error dialog will only be displayed if there is at least one
+ * child status matching the mask.
+ *
+ * @param parentShell
+ * the parent shell of the dialog, or <code>null</code> if none
+ * @param dialogTitle
+ * the title to use for this dialog, or <code>null</code> to
+ * indicate that the default title should be used
+ * @param message
+ * the message to show in this dialog, or <code>null</code> to
+ * indicate that the error's message should be shown as the
+ * primary message
+ * @param status
+ * the error to show to the user
+ * @param displayMask
+ * the mask to use to filter the displaying of child items, as per
+ * <code>Status.matches</code>
+ * @return the code of the button that was pressed that resulted in this
+ * dialog closing. This will be <code>Dialog.OK</code> if the OK
+ * button was pressed, or <code>Dialog.CANCEL</code> if this
+ * dialog's close window decoration or the ESC key was used.
+ */
+ public static int openError(
+ Shell parentShell,
+ String title,
+ String message,
+ IStatus status,
+ int displayMask)
+ {
+ ErrorDialog dialog =
+ new ErrorDialog(parentShell, title, message, status, displayMask);
+ return dialog.open();
+ }
+
+ public static int openInfo(
+ Shell parentShell,
+ String title,
+ String message,
+ IStatus status,
+ int displayMask)
+ {
+ InfoDialog dialog =
+ new InfoDialog(parentShell, title, message, status, displayMask);
+ return dialog.open();
+ }
+
+ public static int openWarning(
+ Shell parentShell,
+ String title,
+ String message,
+ IStatus status,
+ int displayMask)
+ {
+ WarningDialog dialog =
+ new WarningDialog(parentShell, title, message, status, displayMask);
+ return dialog.open();
+ }
+
+ public static int openOptions(
+ Shell parentShell,
+ String title,
+ String message,
+ IStatus status,
+ int displayMask,
+ Choice[] options)
+ {
+ OptionsDialog dialog =
+ new OptionsDialog(
+ parentShell,
+ title,
+ message,
+ status,
+ displayMask,
+ options);
+ dialog.open();
+ return dialog.getReturnCode();
+ }
+
+ /**
+ * Populates the list using this error dialog's status object. This walks the
+ * child stati of the status object and displays them in a list. The format
+ * for each entry is status_path : status_message If the status's path was
+ * null then it (and the colon) are omitted.
+ */
+ private void populateList(List list)
+ {
+ Iterator enumeration = statusList.iterator();
+ while (enumeration.hasNext())
+ {
+ IStatus childStatus = (IStatus) enumeration.next();
+ populateList(list, childStatus, 0);
+ }
+ }
+ private void populateList(List list, IStatus status, int nesting)
+ {
+ if (!status.matches(displayMask))
+ {
+ return;
+ }
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < nesting; i++)
+ {
+ sb.append(" ");
+ }
+ sb.append(status.getMessage());
+ list.add(sb.toString());
+ IStatus[] children = status.getChildren();
+ for (int i = 0; i < children.length; i++)
+ {
+ populateList(list, children[i], nesting + 1);
+ }
+ }
+ private void populateDetails(Text text, IStatus status, int nesting)
+ {
+ if (!status.matches(displayMask))
+ {
+ return;
+ }
+
+ String tabChars = StringUtils.repeat( ' ', nesting * 2 );
+ String messageLine = tabChars + status.getMessage() + System.getProperty("line.separator");
+ Throwable except = status.getException();
+
+ text.append( messageLine );
+
+ if( except != null )
+ {
+ String[] trace = StringUtils.getStackTrace( except );
+
+ for( int index = 0; index < trace.length; index++ )
+ {
+ text.append( tabChars + " " + trace[index] + System.getProperty("line.separator") );
+ }
+ }
+
+ IStatus[] children = status.getChildren();
+ for (int i = 0; i < children.length; i++)
+ {
+ populateDetails(text, children[i], nesting + 1);
+ }
+ }
+ /**
+ * Returns whether the given status object should be displayed.
+ *
+ * @param status
+ * a status object
+ * @param mask
+ * a mask as per <code>Status.matches</code>
+ * @return <code>true</code> if the given status should be displayed, and
+ * <code>false</code> otherwise
+ */
+ protected static boolean shouldDisplay(IStatus status, int mask)
+ {
+ IStatus[] children = status.getChildren();
+ if (children == null || children.length == 0)
+ {
+ return status.matches(mask);
+ }
+ for (int i = 0; i < children.length; i++)
+ {
+ if (children[i].matches(mask))
+ return true;
+ }
+ return false;
+ }
+ /**
+ * Toggles the unfolding of the details area. This is triggered by the user
+ * pressing the details button.
+ */
+ private void toggleDetailsArea()
+ {
+ Point windowSize = getShell().getSize();
+ int newHeight = -1;
+
+ if (detailsCreated)
+ {
+ details.dispose();
+ detailsCreated = false;
+ detailsButton.setText(IDialogConstants.SHOW_DETAILS_LABEL);
+
+ // Without the following computeSize call the setSize call below throws an array out of bounds exception.
+ // Very weird.
+ getContents().computeSize(SWT.DEFAULT, SWT.DEFAULT);
+
+ newHeight = savedSize.y;
+ }
+ else
+ {
+ if( savedSize == null ) savedSize = windowSize;
+
+ details = createDropDownDetails((Composite) getContents());
+ detailsButton.setText(IDialogConstants.HIDE_DETAILS_LABEL);
+ newHeight = getContents().computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
+ newHeight = newHeight < 250 ? 250 : newHeight;
+ }
+
+ newHeight = newHeight > 400 ? 400 : newHeight;
+
+ getShell().setSize( new Point(windowSize.x, newHeight) );
+ parent.layout();
+ }
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/OptionsDialog.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/OptionsDialog.java
new file mode 100644
index 000000000..bf1179d40
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/OptionsDialog.java
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.command.internal.env.ui.dialog;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.common.environment.Choice;
+
+
+/**
+ * A dialog to display one or more errors to the user, as contained in an
+ * <code>Status</code> object. If an error contains additional detailed
+ * information then a Details button is automatically supplied, which shows or
+ * hides an error details viewer when pressed by the user.
+ *
+ */
+public class OptionsDialog extends MessageDialog
+{
+ private Choice[] choices;
+ private int returnCode_;
+
+ public OptionsDialog(
+ Shell parentShell,
+ String dialogTitle,
+ String message,
+ IStatus status,
+ int displayMask,
+ Choice[] choices)
+ {
+ super(parentShell, dialogTitle, message, status, displayMask);
+ this.choices = choices;
+ }
+
+ /*
+ * (non-Javadoc) This should also be overwritten Method declared on Dialog.
+ */
+ protected void createButtonsForButtonBar(Composite parent)
+ {
+ // create a button for each options
+ for (int i = 0; i < choices.length; i++)
+ {
+ createButton(parent, choices[i].getShortcut(), choices[i].getLabel(), true);
+ }
+ if (status.isMultiStatus() )
+ {
+ detailsButton =
+ createButton(
+ parent,
+ StatusDialogConstants.DETAILS_ID,
+ IDialogConstants.SHOW_DETAILS_LABEL,
+ false);
+ }
+ }
+
+ protected void buttonPressed(int id)
+ {
+ if (id == StatusDialogConstants.DETAILS_ID)
+ // was the Details button pressed?
+ super.buttonPressed(id);
+ else
+ {
+ setReturnCode(id);
+ close();
+ }
+ }
+
+ protected void setReturnCode(int id)
+ {
+ returnCode_ = id;
+ }
+
+ public int getReturnCode()
+ {
+ return returnCode_;
+ }
+ /*
+ * This is one of the few methods that needs to be overwritten by the
+ * subclasses. The image names can be found in the Dialog class
+ */
+ protected Image getDialogImage()
+ {
+ // create image
+ switch (status.getSeverity())
+ {
+ case IStatus.INFO :
+ return PlatformUI.getWorkbench().getDisplay().getSystemImage(SWT.ICON_INFORMATION);
+ case IStatus.WARNING :
+ return PlatformUI.getWorkbench().getDisplay().getSystemImage(SWT.ICON_WARNING);
+ default :
+ return PlatformUI.getWorkbench().getDisplay().getSystemImage(SWT.ICON_ERROR);
+ }
+ }
+
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/RuntimeStruct.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/RuntimeStruct.java
new file mode 100644
index 000000000..c5902490a
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/RuntimeStruct.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * yyyymmdd bug Email and other contact information
+ * -------- -------- -----------------------------------------------------------
+ * 20080221 146023 gilberta@ca.ibm.com - Gilbert Andrews
+ *******************************************************************************/
+/**
+ */
+package org.eclipse.wst.command.internal.env.ui.dialog;
+
+import org.eclipse.wst.command.internal.env.ui.common.LabelsAndIds;
+
+public class RuntimeStruct {
+
+ private String runtimeID_;
+ private String runtimeLabel_;
+ private LabelsAndIds scenarios_;
+
+ public RuntimeStruct(String runtimeID){
+ runtimeID_ = runtimeID;
+ }
+
+ public String getRuntimeID(){
+ return runtimeID_;
+ }
+
+ public void setRuntimeLabel(String label){
+ runtimeLabel_ = label;
+ }
+
+ public String getRuntimeLabel(){
+ return runtimeLabel_;
+ }
+
+ public void setScenario(String id, String label){
+ if(scenarios_ == null) scenarios_ = new LabelsAndIds();
+ if(id == null || label == null) return;
+ scenarios_.add(id,label);
+ }
+
+ public LabelsAndIds getScenarioLabels(){
+ return scenarios_;
+ }
+
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/StatusDialogConstants.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/StatusDialogConstants.java
new file mode 100644
index 000000000..4e56788ec
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/StatusDialogConstants.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.command.internal.env.ui.dialog;
+
+/**
+* Constants for status dialogs
+*/
+public interface StatusDialogConstants {
+
+ /*
+ * Button ID for the "Yes" button
+ */
+ public static final int YES_ID = 2;
+ /*
+ * Button ID for the "Yes to all" button
+ */
+ public static final int YES_TO_ALL_ID = 4;
+ /*
+ * Button ID for the "Cancel" button
+ */
+ public static final int CANCEL_ID = 1;
+ /*
+ * Button ID for the "OK" button
+ */
+ public static final int OK_ID = 0;
+ /*
+ * Button ID for the "Details" button
+ */
+ public static final int DETAILS_ID = 13;
+
+ /*
+ * Button label for the "Yes" button
+ */
+ // public static final String YES_LABEL = EnvironmentPlugin.getInstance().getMessage("%STATUS_DIALOG_YES_LABEL");
+ /*
+ * Button label for the "Yes to all" button
+ */
+ // public static final String YES_TO_ALL_LABEL = EnvironmentPlugin.getInstance().getMessage("%STATUS_DIALOG_YES_TO_ALL_LABEL");
+ /*
+ * Button label for the "Cancel" button
+ */
+ // public static final String CANCEL_LABEL = EnvironmentPlugin.getInstance().getMessage("%STATUS_DIALOG_CANCEL_LABEL");
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/WarningDialog.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/WarningDialog.java
new file mode 100644
index 000000000..cb5695f5b
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/WarningDialog.java
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.command.internal.env.ui.dialog;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+
+
+/**
+ * A dialog to display one or more errors to the user, as contained in an
+ * <code>Status</code> object. If an error contains additional detailed
+ * information then a Details button is automatically supplied, which shows or
+ * hides an error details viewer when pressed by the user.
+ *
+ */
+public class WarningDialog extends MessageDialog
+{
+ /**
+ * Creates an error dialog. Note that the dialog will have no visual
+ * representation (no widgets) until it is told to open.
+ * <p>
+ * Normally one should use <code>openError</code> to create and open one of
+ * these. This constructor is useful only if the error object being displayed
+ * contains child items <it>and</it> you need to specify a mask which will
+ * be used to filter the displaying of these children.
+ * </p>
+ *
+ * @param parentShell
+ * the shell under which to create this dialog
+ * @param dialogTitle
+ * the title to use for this dialog, or <code>null</code> to
+ * indicate that the default title should be used
+ * @param message
+ * the message to show in this dialog, or <code>null</code> to
+ * indicate that the error's message should be shown as the
+ * primary message
+ * @param status
+ * the error to show to the user
+ * @param displayMask
+ * the mask to use to filter the displaying of child items, as per
+ * <code>Status.matches</code>
+ */
+ public WarningDialog(
+ Shell parentShell,
+ String dialogTitle,
+ String message,
+ IStatus status,
+ int displayMask)
+ {
+ super(parentShell, dialogTitle, message, status, displayMask);
+ }
+
+ /*
+ * (non-Javadoc) This should also be overwritten Method declared on Dialog.
+ */
+ protected void createButtonsForButtonBar(Composite parent)
+ {
+ // create OK, Cancel and Details buttons
+ createButton(
+ parent,
+ StatusDialogConstants.OK_ID,
+ IDialogConstants.OK_LABEL,
+ true);
+ createButton(
+ parent,
+ StatusDialogConstants.CANCEL_ID,
+ IDialogConstants.CANCEL_LABEL,
+ false);
+ if (status.isMultiStatus())
+ {
+ detailsButton =
+ createButton(
+ parent,
+ StatusDialogConstants.DETAILS_ID,
+ IDialogConstants.SHOW_DETAILS_LABEL,
+ false);
+ }
+ }
+
+ /*
+ * This is one of the few methods that needs to be overwritten by the
+ * subclasses. The image names can be found in the Dialog class
+ */
+ protected Image getDialogImage()
+ {
+ // create image
+ return PlatformUI.getWorkbench().getDisplay().getSystemImage(SWT.ICON_WARNING);
+ }
+
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/eclipse/EclipseStatusHandler.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/eclipse/EclipseStatusHandler.java
new file mode 100644
index 000000000..39c764534
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/eclipse/EclipseStatusHandler.java
@@ -0,0 +1,191 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * yyyymmdd bug Email and other contact information
+ * -------- -------- -----------------------------------------------------------
+ * 20070314 176886 pmoogk@ca.ibm.com - Peter Moogk
+ * 20070502 162287 makandre@ca.ibm.com - Andrew Mak, Server publish cancel button unavailable
+ *******************************************************************************/
+package org.eclipse.wst.command.internal.env.ui.eclipse;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.wst.command.internal.env.core.EnvironmentCoreMessages;
+import org.eclipse.wst.command.internal.env.eclipse.BaseStatusHandler;
+import org.eclipse.wst.command.internal.env.ui.dialog.MessageDialog;
+import org.eclipse.wst.command.internal.env.ui.dialog.StatusDialogConstants;
+import org.eclipse.wst.common.environment.Choice;
+import org.eclipse.wst.common.environment.StatusException;
+
+
+/**
+ * This is the Eclipse UI version of the IStatusHandler
+ */
+public class EclipseStatusHandler extends BaseStatusHandler
+{
+ private Shell shell = null;
+
+ public EclipseStatusHandler()
+ {
+ }
+
+ public EclipseStatusHandler( Shell theShell )
+ {
+ shell = theShell;
+ }
+
+ /**
+ * @see org.eclipse.env.common.IStatusHandler#report(org.eclipse.env.common.Status, org.eclipse.env.common.Choice[])
+ */
+ public Choice report( final IStatus status, final Choice[] choices)
+ {
+ final int[] result = new int[1];
+
+ checkStatus( status );
+
+ Runnable runnable = new Runnable()
+ {
+ public void run()
+ {
+ result[0] =
+ MessageDialog.openMessage( getShell(),
+ EnvironmentCoreMessages.TITLE_WARNING, //TODO: Should be inferred from status' severity.
+ null,
+ status,
+ choices);
+ }
+ };
+
+ Display.getDefault().syncExec( runnable );
+
+ for (int i = 0; i < choices.length; i++)
+ {
+ if (choices[i].getShortcut() == result[0] )
+ return choices[i];
+ }
+
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.env.common.IStatusHandler#report(org.eclipse.env.common.Status)
+ */
+ public void report(IStatus status) throws StatusException
+ {
+ boolean userOk = false;
+
+ checkStatus( status );
+
+ switch (status.getSeverity())
+ {
+ // an error has been reported and we need to stop executing the comming
+ // commands
+ case Status.ERROR :
+ {
+ userOk = reportErrorStatus(status);
+ break;
+ }
+ case Status.WARNING :
+ {
+ userOk = reportWarning(status);
+ break;
+ }
+ case Status.INFO :
+ {
+ userOk = true;
+ reportInfo(status);
+ break;
+ }
+ }
+
+ if( !userOk ) throw new StatusException( status );
+ }
+
+ private boolean reportWarning( final IStatus status )
+ {
+ final int userResponse[] = new int[1];
+
+ Runnable runnable = new Runnable()
+ {
+ public void run()
+ {
+ userResponse[0] =
+ MessageDialog.openMessage( getShell(),
+ EnvironmentCoreMessages.TITLE_WARNING,
+ null,
+ status);
+ }
+ };
+
+ Display.getDefault().syncExec( runnable );
+
+ return (userResponse[0] == StatusDialogConstants.OK_ID);
+ }
+
+ private boolean reportErrorStatus(final IStatus status)
+ {
+ // no need to report an empty message with no exception
+ if ("".equals(status.getMessage()) && status.getException() == null)
+ return false;
+
+ Runnable runnable = new Runnable()
+ {
+ public void run()
+ {
+ MessageDialog.openMessage( getShell(),
+ EnvironmentCoreMessages.TITLE_ERROR,
+ null,
+ status);
+ }
+ };
+
+ Display.getDefault().syncExec( runnable );
+
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.wst.command.internal.env.core.common.IStatusHandler#reportError(org.eclipse.wst.command.internal.env.core.common.Status)
+ */
+ public void reportError(IStatus status)
+ {
+ checkStatus( status );
+ reportErrorStatus( status );
+ }
+
+ /**
+ * @see org.eclipse.wst.command.internal.env.core.common.IStatusHandler#reportInfo(org.eclipse.wst.command.internal.env.core.common.Status)
+ */
+ public void reportInfo(final IStatus status)
+ {
+ Runnable runnable = new Runnable()
+ {
+ public void run()
+ {
+ MessageDialog.openMessage( getShell(),
+ EnvironmentCoreMessages.TITLE_INFO,
+ null,
+ status);
+ }
+ };
+
+ Display.getDefault().syncExec( runnable );
+ }
+
+ private Shell getShell()
+ {
+ if( shell != null ) return shell;
+
+ Display display = Display.getDefault();
+
+ return display == null ? null : display.getActiveShell();
+ }
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/eclipse/EnvironmentUtils.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/eclipse/EnvironmentUtils.java
new file mode 100644
index 000000000..ea1de3783
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/eclipse/EnvironmentUtils.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.command.internal.env.ui.eclipse;
+
+import org.eclipse.wst.command.internal.env.core.context.ResourceContext;
+import org.eclipse.wst.command.internal.env.core.context.TransientResourceContext;
+import org.eclipse.wst.command.internal.env.eclipse.EclipseEnvironment;
+import org.eclipse.wst.common.environment.IEnvironment;
+
+public final class EnvironmentUtils
+{
+ /**
+ *
+ * @param env This should be an EclipseEnvironment.
+ * @return Returns a ResourceContext.
+ */
+ public static ResourceContext getResourceContext( IEnvironment env )
+ {
+ ResourceContext context = null;
+
+ if( env instanceof EclipseEnvironment )
+ {
+ context = ((EclipseEnvironment)env).getResourceContext();
+ }
+ else
+ {
+ context = new TransientResourceContext();
+ }
+
+ return context;
+ }
+
+
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/eclipse/SWTEnvironmentManager.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/eclipse/SWTEnvironmentManager.java
new file mode 100644
index 000000000..99132bcc5
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/eclipse/SWTEnvironmentManager.java
@@ -0,0 +1,28 @@
+/***************************************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others. All rights reserved. This program and the
+ * accompanying materials are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ **************************************************************************************************/
+package org.eclipse.wst.command.internal.env.ui.eclipse;
+
+import org.eclipse.wst.command.internal.env.context.PersistentResourceContext;
+import org.eclipse.wst.command.internal.env.eclipse.BaseEclipseEnvironment;
+import org.eclipse.wst.command.internal.env.eclipse.EclipseEnvironment;
+
+public class SWTEnvironmentManager
+{
+ /**
+ * Returns a new instance of an IEnvironment for the Eclipse SWT GUI.
+ */
+ public static BaseEclipseEnvironment getNewSWTEnvironment()
+ {
+ PersistentResourceContext context = PersistentResourceContext.getInstance();
+ EclipseStatusHandler handler = new EclipseStatusHandler();
+ EclipseEnvironment environment = new EclipseEnvironment( null, context, handler );
+
+ return environment;
+ }
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/plugin/EnvUIPlugin.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/plugin/EnvUIPlugin.java
new file mode 100644
index 000000000..4c15d6091
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/plugin/EnvUIPlugin.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.wst.command.internal.env.ui.plugin;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.jface.resource.ImageDescriptor;
+
+/**
+ * The main plugin class to be used in the desktop.
+ */
+public class EnvUIPlugin extends Plugin {
+
+ //The shared instance.
+ private static EnvUIPlugin instance;
+
+ /**
+ * The constructor.
+ */
+ public EnvUIPlugin() {
+ super();
+ instance = this;
+ }
+
+ /**
+ * Returns the shared instance.
+ */
+ public static EnvUIPlugin getInstance() {
+ return instance;
+ }
+ public static ImageDescriptor getImageDescriptor ( String name )
+ {
+ try
+ {
+ URL installURL = instance.getBundle().getEntry("/");
+ URL imageURL = new URL(installURL,name);
+ return ImageDescriptor.createFromURL(imageURL);
+ }
+ catch (MalformedURLException e)
+ {
+ return null;
+ }
+ }
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/preferences/ActionDialogsPreferencePage.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/preferences/ActionDialogsPreferencePage.java
new file mode 100644
index 000000000..e37e4981f
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/preferences/ActionDialogsPreferencePage.java
@@ -0,0 +1,247 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * yyyymmdd bug Email and other contact information
+ * -------- -------- -----------------------------------------------------------
+ * 20060726 151866 makandre@ca.ibm.com - Andrew Mak, Popup Dialog Selection preferences defaults incorrectly to hide all
+ *******************************************************************************/
+package org.eclipse.wst.command.internal.env.ui.preferences;
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExecutableExtension;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+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.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.command.internal.env.context.PersistentActionDialogsContext;
+import org.eclipse.wst.command.internal.env.preferences.ActionDialogPreferenceType;
+import org.eclipse.wst.command.internal.env.ui.EnvironmentUIMessages;
+
+
+/**
+ * This class can be used to create a popup actions preference page for a
+ * particular category. For example:
+ *
+ * <pre>
+ * &lt;extension
+ * point="org.eclipse.ui.preferencePages"&gt;
+ * &lt;page
+ * name="%PREFERENCE_CATEGORY_DIALOGS"
+ * category="org.eclipse.jst.ws.ui.preferences.name"
+ * class="org.eclipse.wst.command.internal.env.preferences.ActionDialogsPreferencePage"
+ * id="org.eclipse.jst.wss.popup.category"&gt;
+ * &lt;/page&gt;
+ * * </pre>
+ * This entry specifies that all popup actions that are associated with the
+ * org.eclipse.jst.wss.popup.category will be displayed on this
+ * preference page.
+ */
+public class ActionDialogsPreferencePage extends PreferencePage implements IWorkbenchPreferencePage, Listener, IExecutableExtension
+{
+ /*CONTEXT_ID PPAD0001 for the Action Dialogs Preference Page*/
+ private String INFOPOP_PPAD_PAGE = "org.eclipse.wst.command.env.ui.PPAD0001";
+ //
+ private Button showAll;
+ /*CONTEXT_ID PPAD0002 for the show all check box on the Action Dialogs Preference Page*/
+ private String INFOPOP_PPAD_BUTTON_SHOW_ALL = "org.eclipse.wst.command.env.ui.PPAD0002";
+ //
+ private Button hideAll;
+ /*CONTEXT_ID PPAD0003 for the hide all check box on the Action Dialogs Preference Page*/
+ private String INFOPOP_PPAD_BUTTON_HIDE_ALL = "org.eclipse.wst.command.env.ui.PPAD0003";
+
+ private Hashtable checkBoxes_;
+ private String categoryId_;
+
+ public void setInitializationData( IConfigurationElement config,
+ String propertyName,
+ Object data )
+ throws CoreException
+ {
+ categoryId_ = config.getAttribute( "id" );
+ }
+
+ /**
+ * Creates preference page controls on demand.
+ * @param parent the parent for the preference page
+ */
+ protected Control createContents(Composite superparent)
+ {
+
+ checkBoxes_ = new Hashtable();
+ addOptionalDialogsCheckBoxes (superparent);
+ new Label(superparent, SWT.HORIZONTAL);
+
+ Composite parent = new Composite( superparent, SWT.NONE );
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ parent.setLayout( layout );
+ parent.setToolTipText(EnvironmentUIMessages.TOOLTIP_PPAD_PAGE);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, INFOPOP_PPAD_PAGE );
+
+ showAll = new Button(parent, SWT.NONE);
+ showAll.setText(EnvironmentUIMessages.BUTTON_SHOW_ALL_DIALOGS);
+ showAll.addListener(SWT.Selection, this);
+ showAll.setToolTipText(EnvironmentUIMessages.TOOLTIP_PPAD_BUTTON_SHOW_ALL);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(showAll, INFOPOP_PPAD_BUTTON_SHOW_ALL );
+
+ hideAll = new Button(parent, SWT.NONE);
+ hideAll.setText(EnvironmentUIMessages.BUTTON_HIDE_ALL_DIALOGS);
+ hideAll.addListener ( SWT.Selection, this);
+ hideAll.setToolTipText(EnvironmentUIMessages.TOOLTIP_PPAD_BUTTON_HIDE_ALL);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(hideAll, INFOPOP_PPAD_BUTTON_HIDE_ALL );
+
+ initializeValues();
+ org.eclipse.jface.dialogs.Dialog.applyDialogFont(superparent);
+ return parent;
+ }
+
+ public void handleEvent (Event event)
+ {
+ if (showAll == event.widget)
+ handleShowAllEvent();
+
+ else if ( hideAll == event.widget)
+ handleHideAllEvent();
+ }
+
+ private void handleShowAllEvent ()
+ {
+ Enumeration e = checkBoxes_.elements();
+ for (; e.hasMoreElements();)
+ {
+ Button dialog = (Button) e.nextElement();
+ dialog.setSelection( false );
+ }
+ }
+
+ private void handleHideAllEvent ()
+ {
+ Enumeration e = checkBoxes_.elements();
+ for (; e.hasMoreElements();)
+ {
+ Button dialog = (Button) e.nextElement();
+ dialog.setSelection( true );
+ }
+ }
+
+ private void addOptionalDialogsCheckBoxes ( Composite parent)
+ {
+ PersistentActionDialogsContext context = PersistentActionDialogsContext.getInstance();
+ ActionDialogPreferenceType[] dialogs = context.getDialogs();
+
+ for (int i = 0; i < dialogs.length; i++)
+ {
+ ActionDialogPreferenceType dialog = dialogs[i];
+ String category = dialog.getCategory();
+
+ if( dialog.getShowCheckbox() && category != null && category.equals( categoryId_) )
+ {
+ Button checkBox = createCheckBox(parent, dialog.getName());
+ checkBox.setToolTipText( dialog.getTooltip() );
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(checkBox, dialog.getInfopop() );
+ checkBoxes_.put(dialog.getId(), checkBox);
+ }
+ }
+ }
+
+ private Button createCheckBox( Composite parent, String text )
+ {
+ Button button = new Button( parent, SWT.CHECK );
+ button.setText( text );
+ return button;
+ }
+
+ /**
+ * Does anything necessary because the default button has been pressed.
+ */
+ protected void performDefaults()
+ {
+ super.performDefaults();
+ initializeDefaults();
+ }
+
+ /**
+ * Do anything necessary because the OK button has been pressed.
+ * @return whether it is okay to close the preference page
+ */
+ public boolean performOk()
+ {
+ storeValues();
+ return true;
+ }
+
+ protected void performApply()
+ {
+ performOk();
+ }
+
+ /**
+ * @see IWorkbenchPreferencePage
+ */
+ public void init(IWorkbench workbench) { }
+
+ /**
+ * Initializes states of the controls using default values
+ * in the preference store.
+ */
+ private void initializeDefaults()
+ {
+ PersistentActionDialogsContext context = PersistentActionDialogsContext.getInstance();
+ Enumeration e = checkBoxes_.keys();
+ for (; e.hasMoreElements();)
+ {
+ String id = (String) e.nextElement();
+ Button dialog = (Button) checkBoxes_.get(id);
+ dialog.setSelection(context.getDefaultBoolean(id));
+ }
+ }
+
+ /**
+ * Initializes states of the controls from the preferences.
+ */
+ private void initializeValues()
+ {
+ PersistentActionDialogsContext context = PersistentActionDialogsContext.getInstance();
+ Enumeration e = checkBoxes_.keys();
+ for (; e.hasMoreElements();)
+ {
+ String id = (String) e.nextElement();
+ Button button = (Button) checkBoxes_.get(id);
+ button.setSelection(context.isActionDialogEnabled(id));
+ }
+ }
+
+ /**
+ * Stores the values of the controls back to the preference store.
+ */
+ private void storeValues()
+ {
+ PersistentActionDialogsContext context = PersistentActionDialogsContext.getInstance();
+
+ Enumeration e = checkBoxes_.keys();
+ for (; e.hasMoreElements();)
+ {
+ String id = (String) e.nextElement();
+ context.setActionDialogEnabled(id, ((Button)checkBoxes_.get(id)).getSelection());
+ }
+ }
+}
+
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/registry/WidgetRegistry.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/registry/WidgetRegistry.java
new file mode 100644
index 000000000..5ab5b3104
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/registry/WidgetRegistry.java
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.wst.command.internal.env.ui.registry;
+
+import java.util.Hashtable;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.wst.command.internal.env.ui.widgets.INamedWidgetContributorFactory;
+
+public class WidgetRegistry
+{
+ private static WidgetRegistry registry_;
+
+ private Hashtable entries_;
+
+ private WidgetRegistry()
+ {
+ }
+
+ public static WidgetRegistry instance()
+ {
+ if (registry_ == null)
+ {
+ registry_ = new WidgetRegistry();
+ registry_.load();
+ }
+
+ return registry_;
+ }
+
+ public static void initialize()
+ {
+ registry_ = null;
+ }
+
+ /**
+ *
+ * @param id the methodId that may have WidgetContributor associated with it.
+ * @return returns a INamedWidgetContributorFactory if one was defined in the registry.
+ * Otherwise null is returned.
+ */
+ public INamedWidgetContributorFactory getFactory( String id )
+ {
+ INamedWidgetContributorFactory factory = null;
+ Entry entry = (Entry)entries_.get( id );
+
+ if( entry != null )
+ {
+ try
+ {
+ if( entry.factory_ == null )
+ {
+ entry.factory_ = (INamedWidgetContributorFactory)entry.element_.createExecutableExtension( "class" );
+ }
+
+ factory = entry.factory_;
+ }
+ catch( CoreException exc )
+ {
+ exc.printStackTrace();
+ }
+ catch( Throwable exc )
+ {
+ exc.printStackTrace();
+ }
+ }
+
+ return factory;
+ }
+
+ private void load()
+ {
+ IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.wst.command.env.ui.widgetRegistry");
+
+ entries_ = new Hashtable();
+
+ for( int index = 0; index < elements.length; index++ )
+ {
+ // If this is not an element that know about we will skip it.
+ if( !elements[index].getName().equals("widgetFactory") ) continue;
+
+ Entry entry = new Entry();
+ IConfigurationElement element = elements[index];
+ String id = element.getAttribute( "id" );
+ String methodId = element.getAttribute( "insertBeforeCommandId" );
+
+ entry.element_ = element;
+ entry.id_ = id;
+
+ entries_.put( methodId, entry );
+ }
+ }
+
+ private class Entry
+ {
+ String id_;
+ IConfigurationElement element_;
+ INamedWidgetContributorFactory factory_;
+ }
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/AbstractSelectionDialog.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/AbstractSelectionDialog.java
new file mode 100644
index 000000000..0d94ecb68
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/AbstractSelectionDialog.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.command.internal.env.ui.widgets;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Shell;
+
+public abstract class AbstractSelectionDialog extends SimpleDialog {
+
+ public AbstractSelectionDialog( Shell shell, PageInfo pageInfo)
+ {
+ super(shell, pageInfo);
+ }
+
+ protected void callSetters() {
+ // extenders should override this method
+
+ }
+
+ public String getDisplayableSelectionString()
+ {
+ return "";
+ }
+
+ public abstract IStructuredSelection getObjectSelection();
+
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/CanFinishRegistry.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/CanFinishRegistry.java
new file mode 100644
index 000000000..c86640939
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/CanFinishRegistry.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.command.internal.env.ui.widgets;
+
+import org.eclipse.wst.command.internal.env.core.common.Condition;
+
+/**
+ * This is an interface for an abstract can finish registry.
+ * This registry is usually associate with an Eclipse wizard. This
+ * registry allow condition object to be added to it in order to
+ * determine if the wizard can finish or not.
+ *
+ */
+public interface CanFinishRegistry
+{
+ /**
+ * Add a condition object to the registry.
+ * @param condition the condition.
+ */
+ public void addCondition( Condition condition );
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/CommandWidgetBinding.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/CommandWidgetBinding.java
new file mode 100644
index 000000000..b1cfc3273
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/CommandWidgetBinding.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.command.internal.env.ui.widgets;
+
+import org.eclipse.wst.command.internal.env.core.data.DataMappingRegistry;
+import org.eclipse.wst.command.internal.env.core.fragment.CommandFragmentFactoryFactory;
+
+
+public interface CommandWidgetBinding extends CommandFragmentFactoryFactory
+{
+ /**
+ * This method is used by extensions to register their widgets with
+ * CommandFragments
+ *
+ * @param widgetRegistry
+ */
+ public void registerWidgetMappings( WidgetRegistry widgetRegistry );
+
+ /**
+ * This method is used by extenions to register the data mappings
+ * that their widgets use.
+ *
+ * @param dataRegistry
+ */
+ public void registerDataMappings( DataMappingRegistry dataRegistry );
+
+ /**
+ * This method is used by extensions to register condition objects
+ * that control if the wizard can finish or not.
+ *
+ * @param canFinishRegistry
+ */
+ public void registerCanFinish( CanFinishRegistry canFinishRegistry );
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/CommandWidgetBindingList.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/CommandWidgetBindingList.java
new file mode 100644
index 000000000..ec1980769
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/CommandWidgetBindingList.java
@@ -0,0 +1,128 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.command.internal.env.ui.widgets;
+
+import java.util.Vector;
+
+import org.eclipse.wst.command.internal.env.core.data.DataMappingRegistry;
+import org.eclipse.wst.command.internal.env.core.fragment.CommandFragment;
+import org.eclipse.wst.command.internal.env.core.fragment.CommandFragmentFactory;
+import org.eclipse.wst.command.internal.env.core.fragment.SequenceFragment;
+
+
+public class CommandWidgetBindingList implements CommandWidgetBinding
+{
+ private Vector bindings_;
+ private Vector fragments_;
+ private CommandFragmentFactory factory_;
+
+ /**
+ * This CommandWidgetBinding combines a list of CommandWidgetBindings.
+ * There should be the same number of entries in both the bindings
+ * parameter and the fragments parameter. Entries in either of the
+ * bindings for fragments vectors are allowed to be null.
+ *
+ * @param bindings the bindings to combine.
+ * @param fragments These fragments will be interspersed with the
+ * fragments associated with each binding. The first
+ * fragment will be put before the fragment from the
+ * first binding. Following this will be the second
+ * fragment from the fragments vector and then the
+ * second fragment from the bindings vector, etc.
+ */
+ public CommandWidgetBindingList( Vector bindings, Vector fragments )
+ {
+ bindings_ = bindings;
+ fragments_ = fragments;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.command.env.ui.widgets.CommandWidgetBinding#registerCanFinish(org.eclipse.wst.command.env.ui.widgets.CanFinishRegistry)
+ */
+ public void registerCanFinish(CanFinishRegistry canFinishRegistry)
+ {
+ int length = bindings_.size();
+
+ for( int index = 0; index < length; index++ )
+ {
+ CommandWidgetBinding binding = (CommandWidgetBinding)bindings_.elementAt( index );
+
+ if( binding != null ) binding.registerCanFinish( canFinishRegistry );
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.command.env.ui.widgets.CommandWidgetBinding#registerDataMappings(org.eclipse.wst.command.internal.env.core.data.DataMappingRegistry)
+ */
+ public void registerDataMappings(DataMappingRegistry dataRegistry)
+ {
+ int length = bindings_.size();
+
+ for( int index = 0; index < length; index++ )
+ {
+ CommandWidgetBinding binding = (CommandWidgetBinding)bindings_.elementAt( index );
+ if( binding != null ) binding.registerDataMappings( dataRegistry );
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.command.env.ui.widgets.CommandWidgetBinding#registerWidgetMappings(org.eclipse.wst.command.env.ui.widgets.WidgetRegistry)
+ */
+ public void registerWidgetMappings(WidgetRegistry widgetRegistry)
+ {
+ int length = bindings_.size();
+
+ for( int index = 0; index < length; index++ )
+ {
+ CommandWidgetBinding binding = (CommandWidgetBinding)bindings_.elementAt( index );
+ if( binding != null ) binding.registerWidgetMappings( widgetRegistry );
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.command.internal.env.core.fragment.CommandFragmentFactoryFactory#create()
+ */
+ public CommandFragmentFactory create()
+ {
+ if( factory_ == null )
+ {
+ factory_ = new CommandFragmentFactory()
+ {
+ public CommandFragment create()
+ {
+ SequenceFragment fragmentList = new SequenceFragment();
+ int length = bindings_.size();
+
+ for( int index = 0; index < length; index++ )
+ {
+ CommandFragment fragment = (CommandFragment)fragments_.elementAt( index );
+
+ if( fragment != null )
+ {
+ fragmentList.add( fragment );
+ }
+
+ CommandWidgetBinding binding = (CommandWidgetBinding)bindings_.elementAt( index );
+
+ if( binding != null )
+ {
+ fragmentList.add( binding.create().create() );
+ }
+ }
+
+ return fragmentList;
+ }
+ };
+ }
+
+ return factory_;
+ }
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/CurrentPageCommand.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/CurrentPageCommand.java
new file mode 100644
index 000000000..c3855d4de
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/CurrentPageCommand.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.wst.command.internal.env.ui.widgets;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+
+
+/**
+ * This Command can be used to get the current page.
+ * Use of this class is not recommended.
+ *
+ */
+public class CurrentPageCommand extends AbstractDataModelOperation
+{
+ private WizardPageManager pageManager_;
+
+ public CurrentPageCommand( WizardPageManager pageManager )
+ {
+ pageManager_ = pageManager;
+ }
+
+ public IWizardPage getCurrentPage()
+ {
+ return pageManager_.getCurrentPage();
+ }
+
+ public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
+ {
+ return Status.OK_STATUS;
+ }
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/DataObjectCommand.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/DataObjectCommand.java
new file mode 100644
index 000000000..0450ad308
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/DataObjectCommand.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.wst.command.internal.env.ui.widgets;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+
+
+/**
+ * This Command can be use to get the resulting data object for
+ * this wizard.
+ *
+ */
+public class DataObjectCommand extends AbstractDataModelOperation
+{
+ private Object dataObject_;
+
+ public void setDataObject( Object object )
+ {
+ dataObject_ = object;
+ }
+
+ public Object getDataObject()
+ {
+ return dataObject_;
+ }
+
+ public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
+ {
+ return Status.OK_STATUS;
+ }
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/DialogDataEvents.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/DialogDataEvents.java
new file mode 100644
index 000000000..52fd19d8c
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/DialogDataEvents.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.command.internal.env.ui.widgets;
+
+
+/**
+ * Dynamic wizard implementations that want to create different
+ * kinds of wizard pages need to implement this interface.
+ * The WizardPageFactory returns a class of this type.
+ *
+ */
+public interface DialogDataEvents
+{
+ /**
+ *
+ * @return returns the WidgetDataEvents object created by the addControls
+ * method of a WidgetContributor.
+ */
+ public WidgetDataEvents getDataEvents();
+
+ /**
+ * Validates that this wizard page is complete.
+ *
+ */
+ public void validatePageToStatus();
+}
+
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/DynamicWizard.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/DynamicWizard.java
new file mode 100644
index 000000000..db024de06
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/DynamicWizard.java
@@ -0,0 +1,437 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * yyyymmdd bug Email and other contact information
+ * -------- -------- -----------------------------------------------------------
+ * 20060223 129232 pmoogk@ca.ibm.com - Peter Moogk
+ * 20060822 154750 pmoogk@ca.ibm.com - Peter Moogk
+ * 20070529 187780 pmoogk@ca.ibm.com - Peter Moogk
+ * 20080613 236523 makandre@ca.ibm.com - Andrew Mak, Overwrite setting on Web service wizard is coupled with preference
+ *******************************************************************************/
+package org.eclipse.wst.command.internal.env.ui.widgets;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExecutableExtension;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.wst.command.internal.env.context.PersistentResourceContext;
+import org.eclipse.wst.command.internal.env.core.common.Condition;
+import org.eclipse.wst.command.internal.env.core.context.ResourceContext;
+import org.eclipse.wst.command.internal.env.core.data.DataFlowManager;
+import org.eclipse.wst.command.internal.env.core.data.DataMappingRegistryImpl;
+import org.eclipse.wst.command.internal.env.core.fragment.CommandFragment;
+import org.eclipse.wst.command.internal.env.core.fragment.SequenceFragment;
+import org.eclipse.wst.command.internal.env.core.fragment.SimpleFragment;
+import org.eclipse.wst.command.internal.env.eclipse.EclipseEnvironment;
+import org.eclipse.wst.command.internal.env.ui.EnvironmentUIMessages;
+import org.eclipse.wst.command.internal.env.ui.eclipse.EclipseStatusHandler;
+import org.eclipse.wst.command.internal.env.ui.registry.WidgetRegistry;
+import org.osgi.framework.Bundle;
+
+
+/**
+ * This class is used to add dynamic wizards into Eclipse. When adding
+ * a dynamic wizard into eclipse two entries need to be made in the plugin.xml
+ * file. This first entry tells Eclipse that a new wizard should be added
+ * and it references this class. The second entry specifies detailed information
+ * that is specific to the wizard to be added. These two plugin.xml entries
+ * are linked together via their id attributes. For example here is an
+ * entry that registers a new wizard with eclipse. Note the class attribute
+ * references this class.
+ * <pre>
+ * &lt;extension
+ * point="org.eclipse.ui.newWizards"&gt;
+ * &lt;wizard
+ * name="%PLUGIN_NEW_WIZARD_NAME_WS_CLIENT"
+ * icon="icons/full/ctool16/newclient_webserv_wiz.gif"
+ * category="org.eclipse.jst.ws.ui.new"
+ * class="org.eclipse.wst.command.env.ui.widgets.DynamicWizard"
+ * id="org.eclipse.jst.ws.consumption.ui.wizard.client.clientwizard"&gt;
+ * &lt;description&gt;
+ * %PLUGIN_NEW_WIZARD_DESC_WS_CLIENT
+ * &lt;/description&gt;
+ * &lt;selection
+ * class="org.eclipse.core.resources.IResource"&gt;
+ * &lt;/selection&gt;
+ * &lt;/wizard&gt;
+ * &lt;/extension&gt;
+ *
+ * </pre>
+ * Here is the dynamicWizard entry for this particular wizard. This id attributes
+ * link these two entries together. The class attribute must specify a class that
+ * implements the org.eclipse.wst.command.env.ui.widgets.CommandWidgetBinding interface. This
+ * interface specifies what the UI should look like and the commands the should
+ * be executed in the wizard.
+ *
+ * <pre>
+ * &lt;extension
+ * point="org.eclipse.wst.command.env.dynamicWizard"&gt;
+ * &lt;dynamicWizard
+ * iconbanner="icons/full/wizban/webservicesclient_wiz.gif"
+ * class="org.eclipse.jst.ws.consumption.ui.widgets.binding.ClientWidgetBinding"
+ * title="%WIZARD_TITLE_WSC"
+ * id="org.eclipse.jst.ws.consumption.ui.wizard.client.clientwizard"&gt;
+ * &lt;/dynamicWizard&gt;
+ * &lt;/extension&gt;
+ * </pre>
+ *
+ */
+public class DynamicWizard extends Wizard implements INewWizard, IExecutableExtension
+{
+ private String iconBannerName_;
+ private Bundle bundle_;
+ private SimpleCanFinishRegistry canFinishRegistry_;
+ private String wizardTitle_;
+ private DataObjectCommand dataObjectCommand_ = null;
+ private WizardPageManager pageManager_;
+
+ protected IConfigurationElement wizardElement_;
+ protected IConfigurationElement originalElement_;
+ protected CommandWidgetBinding commandWidgetBinding_;
+
+ public DynamicWizard()
+ {
+ setNeedsProgressMonitor(true);
+ }
+
+ /**
+ * This method is called when the Dynamic wizard is created by eclipse.
+ * We need to find a dynamicWizard extension point that matches the id
+ * for this wizard. Once the extension point is found it will contain
+ * a reference to a CommandWidgetBinding class which defines the widgets
+ * and commands for this wizard.
+ *
+ * @see org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement, java.lang.String, java.lang.Object)
+ */
+ public void setInitializationData( IConfigurationElement config,
+ String propertyName,
+ Object data )
+ throws CoreException
+ {
+ String wizardId = config.getAttribute( "id" ); //$NON-NLS-1$
+
+ setInitialData( wizardId );
+ originalElement_ = config;
+ }
+
+ /**
+ * This method should only be called if the Dynamic Wizard is being
+ * launched through some other mechanise other than the Eclipse New Wizard
+ * mechanism.
+ *
+ * @param binding the command widget binding for this wizard.
+ * @param descriptor the plugin descriptor where the icon banner is
+ * located.
+ * @param iconBannerPath the icon banner path for this wizard. The path
+ * is relative to the plugin specified by the
+ * descriptor parameter.
+ * @param wizardTitle the wizard title
+ *
+ * @deprecated Use either setInitialData(wizardId) or
+ * setInitialData(wizardId, bundle, iconBannerPath, wizardTitle )
+ */
+ public void setInitialData( CommandWidgetBinding binding,
+ Bundle bundle,
+ String iconBannerPath,
+ String wizardTitle )
+ {
+ commandWidgetBinding_ = binding;
+ bundle_ = bundle;
+ iconBannerName_ = iconBannerPath;
+ wizardTitle_ = wizardTitle;
+ }
+
+ /**
+ * Sets the initial data based on the dynamic wizard id.
+ *
+ * @param wizardId
+ */
+ public void setInitialData( String wizardId ) throws CoreException
+ {
+ setInitialData(wizardId, null, null, null );
+ }
+
+ /**
+ * Sets the initial data based on the dynamic wizard id.
+ *
+ * @param wizardId the ID of the wizard.
+ * @param bundle the bundle used to find an icon banner. Can be null if
+ * no icon banner is specified.
+ * @param iconBannerPath the path relative to the bundle specified.
+ * @param wizardTitle the title of the wizard.
+ *
+ * Note: normally the wizard associated with a wizardId will have an
+ * icon banner and a title. The parameters on this method allow the caller
+ * to override these values.
+ */
+ public void setInitialData( String wizardId, Bundle bundle, String iconBannerPath, String wizardTitle ) throws CoreException
+ {
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint point = registry.getExtensionPoint("org.eclipse.wst.command.env.dynamicWizard"); //$NON-NLS-1$
+ IExtension[] extensions = point.getExtensions();
+
+ for( int index = 0; index < extensions.length; index++)
+ {
+ IConfigurationElement[] elements = extensions[index].getConfigurationElements();
+
+ if( elements.length == 1 && elements[0].getName().equals( "dynamicWizard") ) //$NON-NLS-1$
+ {
+ String id = elements[0].getAttribute( "id" ); //$NON-NLS-1$
+
+ if( id != null && id.equals( wizardId ) )
+ {
+ wizardElement_ = elements[0];
+ break;
+ }
+ }
+ }
+
+ bundle_ = bundle;
+ iconBannerName_ = iconBannerPath;
+ wizardTitle_ = wizardTitle;
+
+ if( wizardElement_ == null )
+ {
+ Status status = new Status( Status.ERROR, "id", 0, NLS.bind(EnvironmentUIMessages.MSG_ERROR_WIZARD_ID_NOT_FOUND, new String[]{ wizardId}) , null ); //$NON-NLS-1$
+ throw new CoreException( status );
+ }
+ }
+
+ /**
+ * This method is called by the eclipse framework to initialize the
+ * wizard.
+ *
+ * Note: if this method is called programatically(ie. not by the eclipse
+ * framework.) one of the setInitalData methods needs to be called before this
+ * method is invoked.
+ *
+ * @param workbench the eclipse workbench
+ * @param selection the initial selection that the user has made within
+ * eclipse.
+ */
+ public void init ( IWorkbench workbench, IStructuredSelection selection )
+ {
+ ResourceContext context = PersistentResourceContext.getInstance().copy();
+ EclipseStatusHandler handler = new EclipseStatusHandler();
+ EclipseEnvironment environment = new EclipseEnvironment( null, context, handler );
+
+ DataMappingRegistryImpl dataRegistry_ = new DataMappingRegistryImpl();
+ SimpleWidgetRegistry widgetRegistry_ = new SimpleWidgetRegistry();
+ DataFlowManager dataManager = new DataFlowManager( dataRegistry_, environment );
+
+ try
+ {
+ if( wizardElement_ != null )
+ {
+ if( commandWidgetBinding_ == null )
+ {
+ commandWidgetBinding_ = (CommandWidgetBinding)wizardElement_.createExecutableExtension( "class" ); //$NON-NLS-1$
+ }
+
+ if( bundle_ == null )
+ {
+ bundle_ = Platform.getBundle( wizardElement_.getNamespace() );
+ }
+
+ if( iconBannerName_ == null )
+ {
+ iconBannerName_ = wizardElement_.getAttribute( "iconbanner" ); //$NON-NLS-1$
+ }
+
+ if( wizardTitle_ == null )
+ {
+ wizardTitle_ = wizardElement_.getAttribute( "title" ); //$NON-NLS-1$
+ }
+ }
+ }
+ catch( CoreException exc )
+ {
+ exc.printStackTrace();
+ }
+
+ dataObjectCommand_ = new DataObjectCommand();
+ canFinishRegistry_ = new SimpleCanFinishRegistry();
+ pageManager_ = new WizardPageManager( widgetRegistry_,
+ getWizardPageFactory(),
+ this,
+ dataManager,
+ environment );
+
+ pageManager_.setRootFragment( getRootFragment( selection, pageManager_ ) );
+
+ commandWidgetBinding_.registerWidgetMappings( widgetRegistry_ );
+ commandWidgetBinding_.registerDataMappings( dataRegistry_ );
+ commandWidgetBinding_.registerCanFinish( canFinishRegistry_ );
+
+ // If a page is not complete ensure that canFinish is false.
+ Condition canFinish = new Condition()
+ {
+ public boolean evaluate()
+ {
+ IWizardPage currentPage = pageManager_.getCurrentPage();
+
+ return currentPage != null ? currentPage.isPageComplete() : true;
+ }
+ };
+
+ canFinishRegistry_.add( canFinish );
+
+ // Set that we need a progress monitor.
+ setNeedsProgressMonitor( true );
+
+ // Ensure that the next/back buttons are enabled.
+ setForcePreviousAndNextButtons( true );
+
+ // Set the icon banner if specified.
+ if( iconBannerName_ != null && iconBannerName_.length() > 0 )
+ {
+ try
+ {
+ URL installURL = bundle_.getEntry("/"); //$NON-NLS-1$
+ URL imageURL = new URL(installURL, iconBannerName_ );
+ ImageDescriptor image = ImageDescriptor.createFromURL(imageURL);
+
+ if( image != null )
+ {
+ setDefaultPageImageDescriptor( image );
+ }
+ }
+ catch (MalformedURLException e)
+ {
+ }
+ }
+
+ if( wizardTitle_ != null && wizardTitle_.length() > 0 )
+ {
+ setWindowTitle( wizardTitle_ );
+ }
+ }
+
+ // Subclasses can override this.
+ protected WizardPageFactory getWizardPageFactory()
+ {
+ return new SimplePageFactory();
+ }
+
+ /**
+ * Returns true if all pages are complete.
+ * @return True if all pages are complete.
+ */
+ public boolean canFinish ()
+ {
+ int length = canFinishRegistry_.size();
+ boolean result = true;
+
+ for( int index = 0; index < length; index++ )
+ {
+ Condition condition = (Condition)canFinishRegistry_.elementAt( index );
+
+ result = condition.evaluate();
+
+ if( !result ) break;
+ }
+
+ return result;
+ }
+
+ /**
+ * Returns the first page for this wizard.
+ *
+ * @return the first page for this wizard.
+ **/
+ public IWizardPage getStartingPage()
+ {
+ return pageManager_.getStartingPage();
+ }
+
+ /**
+ * Returns the next page after page and
+ * runs the appropriate tasks.
+ *
+ * @return the next page after page.
+ **/
+ public IWizardPage getNextPage( IWizardPage page )
+ {
+ return pageManager_.getNextPage();
+ }
+
+ /**
+ */
+ public boolean performFinish ()
+ {
+ boolean result = pageManager_.performFinish();
+
+ if( result ) cleanup();
+
+ return result;
+ }
+
+ /**
+ * Undo fragments
+ */
+ public boolean performCancel ()
+ {
+ boolean result = pageManager_.performCancel();
+
+ if( result ) cleanup();
+
+ return result;
+ }
+
+ public Object getDataObject()
+ {
+ return dataObjectCommand_.getDataObject();
+ }
+
+ protected CommandFragment getRootFragment( IStructuredSelection selection, WizardPageManager pageManager )
+ {
+ SequenceFragment root = new SequenceFragment();
+
+ root.add( new SimpleFragment( new SelectionCommand( selection ), "" ) ); //$NON-NLS-1$
+ root.add( new SimpleFragment( new CurrentPageCommand( pageManager ), "" ) ); //$NON-NLS-1$
+ root.add( commandWidgetBinding_.create().create() );
+ root.add( new SimpleFragment( dataObjectCommand_, "" )); //$NON-NLS-1$
+
+ return root;
+ }
+
+ protected IConfigurationElement getConfigElement()
+ {
+ return wizardElement_;
+ }
+
+ /**
+ * This method frees up the memory held by this object.
+ *
+ */
+ private void cleanup()
+ {
+ iconBannerName_ = null;
+ bundle_ = null;
+ canFinishRegistry_ = null;
+ pageManager_ = null;
+ wizardTitle_ = null;
+ commandWidgetBinding_ = null;
+ WidgetRegistry.initialize();
+ }
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/INamedWidgetContributor.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/INamedWidgetContributor.java
new file mode 100644
index 000000000..a5baf32b4
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/INamedWidgetContributor.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.wst.command.internal.env.ui.widgets;
+
+
+public interface INamedWidgetContributor
+{
+ /**
+ *
+ * @return returns the WidgetContributor for this Named widget.
+ */
+ public WidgetContributorFactory getWidgetContributorFactory();
+
+ /**
+ *
+ * @return returns the name.
+ */
+ public String getName ();
+
+ /**
+ *
+ * @return returns a description that might be displayed on
+ * a wizard page.
+ */
+ public String getDescription ();
+
+ /**
+ *
+ * @return returns title that may be displayed on
+ * a wizard page.
+ */
+ public String getTitle();
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/INamedWidgetContributorFactory.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/INamedWidgetContributorFactory.java
new file mode 100644
index 000000000..f14ff0380
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/INamedWidgetContributorFactory.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.wst.command.internal.env.ui.widgets;
+
+import org.eclipse.wst.command.internal.env.core.data.DataMappingRegistry;
+
+public interface INamedWidgetContributorFactory
+{
+ /**
+ *
+ * @return returns the first named widget.
+ */
+ INamedWidgetContributor getFirstNamedWidget();
+
+ /**
+ *
+ * @param widgetContributor
+ * @return returns the next named widget after the one specified.
+ */
+ INamedWidgetContributor getNextNamedWidget( INamedWidgetContributor widgetContributor );
+
+ /**
+ * This method is used by extenions to register the data mappings
+ * that their widgets use.
+ *
+ * @param dataRegistry
+ */
+ public void registerDataMappings( DataMappingRegistry dataRegistry );
+
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/PageInfo.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/PageInfo.java
new file mode 100644
index 000000000..15843645d
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/PageInfo.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.command.internal.env.ui.widgets;
+
+
+
+public class PageInfo
+{
+ private String pageName_;
+ private String pageTitle_;
+ private WidgetContributorFactory widgetFactory_;
+
+ public PageInfo( String pageName,
+ String pageTitle,
+ WidgetContributorFactory widgetFactory )
+ {
+ pageName_ = pageName;
+ pageTitle_ = pageTitle;
+ widgetFactory_ = widgetFactory;
+ }
+
+ public String getPageName()
+ {
+ return pageName_;
+ }
+
+ public String getPageTitle()
+ {
+ return pageTitle_;
+ }
+
+ public WidgetContributorFactory getWidgetFactory()
+ {
+ return widgetFactory_;
+ }
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/PageWizardDataEvents.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/PageWizardDataEvents.java
new file mode 100644
index 000000000..5eb65f110
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/PageWizardDataEvents.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.command.internal.env.ui.widgets;
+
+import org.eclipse.jface.wizard.IWizardPage;
+
+/**
+ * Dynamic wizard implementations that want to create different
+ * kinds of wizard pages need to implement this interface.
+ * The WizardPageFactory returns a class of this type.
+ *
+ */
+public interface PageWizardDataEvents extends IWizardPage
+{
+ /**
+ *
+ * @return returns the WidgetDataEvents object created by the addControls
+ * method of a WidgetContributor.
+ */
+ public WidgetDataEvents getDataEvents();
+
+ /**
+ * Validates that this wizard page is complete.
+ *
+ */
+ public void validatePageToStatus();
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SelectionCommand.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SelectionCommand.java
new file mode 100644
index 000000000..8f13bcce3
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SelectionCommand.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.wst.command.internal.env.ui.widgets;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+
+
+/**
+ * This SelectionCommand is execute at the very beginning of the
+ * dynamic wizard. Commands executed in the wizard that need
+ * the initial selection can get it through a data mapping from
+ * this command to the command that needs it.
+ *
+ */
+public class SelectionCommand extends AbstractDataModelOperation
+{
+ private IStructuredSelection selection_;
+
+ public SelectionCommand( IStructuredSelection selection )
+ {
+ selection_ = selection;
+ }
+
+ public IStructuredSelection getInitialSelection()
+ {
+ return selection_;
+ }
+
+ public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
+ {
+ return Status.OK_STATUS;
+ }
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleCanFinishRegistry.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleCanFinishRegistry.java
new file mode 100644
index 000000000..ae99dc6ef
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleCanFinishRegistry.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.command.internal.env.ui.widgets;
+
+import java.util.Vector;
+
+import org.eclipse.wst.command.internal.env.core.common.Condition;
+
+
+
+public class SimpleCanFinishRegistry extends Vector implements CanFinishRegistry
+{
+
+ /**
+ * Comment for <code>serialVersionUID</code>
+ */
+ private static final long serialVersionUID = 3257285837870741305L;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.env.widgets.CanFinishRegistry#addCondition(org.eclipse.env.command.fragment.Condition)
+ */
+ public void addCondition(Condition condition)
+ {
+ add( condition );
+ }
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleCommandEngineManager.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleCommandEngineManager.java
new file mode 100644
index 000000000..46aaa7b80
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleCommandEngineManager.java
@@ -0,0 +1,322 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * yyyymmdd bug Email and other contact information
+ * -------- -------- -----------------------------------------------------------
+ * 20060223 129232 pmoogk@ca.ibm.com - Peter Moogk
+ * 20070314 176886 pmoogk@ca.ibm.com - Peter Moogk
+ * 20070730 197144 pmoogk@ca.ibm.com - Peter Moogk, Pass progress monitor to undo commands.
+ *******************************************************************************/
+package org.eclipse.wst.command.internal.env.ui.widgets;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.operation.IRunnableContext;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.wst.command.internal.env.core.data.DataFlowManager;
+import org.eclipse.wst.command.internal.env.core.fragment.CommandFragment;
+import org.eclipse.wst.command.internal.env.core.fragment.CommandFragmentEngine;
+import org.eclipse.wst.command.internal.env.core.fragment.FragmentListener;
+import org.eclipse.wst.command.internal.env.eclipse.BaseStatusHandler;
+import org.eclipse.wst.command.internal.env.eclipse.EclipseEnvironment;
+import org.eclipse.wst.common.environment.ILog;
+
+
+/**
+ * This class manages the execution of Commands in a flow of CommandFragments.
+ * The bulk of this work is done by the CommandFragmentEngine. The main job of
+ * this class is run the fragments in a particular transactional environment.
+ * A fragment has a method called doNotRunInTransaction which is used to determine
+ * if its commands should be run in a transaction or not. If this method returns
+ * true(ie. not in a transaction) the Commands are wrapped in a IRunnableWithProgress.
+ * If false( ie. in a transaction ) the Commands are wrapped in a WorkspaceModifyOperation.
+ *
+ */
+public class SimpleCommandEngineManager
+{
+ protected CommandFragmentEngine engine_;
+ protected DataFlowManager dataManager_;
+ protected EclipseEnvironment environment_;
+
+ private boolean foundStop_;
+ private boolean doNotRunInTransaction_;
+
+ public SimpleCommandEngineManager( EclipseEnvironment environment, DataFlowManager dataManager )
+ {
+ environment_ = environment;
+ dataManager_ = dataManager;
+ }
+
+ /**
+ * Sets the root fragment. The execution engine will start executing commands
+ * at the beginning of this root fragment.
+ *
+ * @param root the root fragment.
+ */
+ public void setRootFragment( CommandFragment root )
+ {
+ engine_ = new CommandFragmentEngine( root, dataManager_, environment_ );
+
+ environment_.setCommandManager( engine_ );
+
+ engine_.setPeekFragmentListener(
+ new FragmentListener()
+ {
+ public boolean notify( CommandFragment fragment )
+ {
+ return peekFragment( fragment );
+ }
+ } );
+
+ engine_.setNextFragmentListener(
+ new FragmentListener()
+ {
+ public boolean notify( CommandFragment fragment )
+ {
+ return nextFragment( fragment );
+ }
+ } );
+
+ engine_.setAfterExecuteFragmentListener(
+ new FragmentListener()
+ {
+ public boolean notify( CommandFragment fragment )
+ {
+ return afterExecuteNextFragment( fragment );
+ }
+ } );
+
+ engine_.setUndoFragmentListener(
+ new FragmentListener()
+ {
+ public boolean notify( CommandFragment fragment )
+ {
+ return undoFragment( fragment );
+ }
+ } );
+ }
+
+ protected boolean afterExecuteNextFragment( CommandFragment fragment )
+ {
+ boolean continueExecute = true;
+ BaseStatusHandler statusHandler = (BaseStatusHandler)environment_.getStatusHandler();
+ IStatus commandStatus = engine_.getLastStatus();
+ IStatus handlerStatus = statusHandler.getStatus();
+
+ if( commandStatus.getSeverity() == IStatus.ERROR &&
+ handlerStatus.getSeverity() != IStatus.ERROR )
+ {
+ // The command returned an error status for the engine to stop,
+ // but the status handler did not have report and error.
+ // Therefore, we will report this status returned by the command
+ // if there is a message to display.
+ String errorMessage = commandStatus.getMessage();
+
+ if( errorMessage != null && errorMessage.length() > 0 )
+ {
+ statusHandler.reportError( commandStatus );
+ }
+ }
+ else if( commandStatus.getSeverity() != IStatus.ERROR &&
+ handlerStatus.getSeverity() == IStatus.ERROR )
+ {
+ // The last command didn't return an error, but the status handler
+ // did report and error. Therefore, we should stop.
+ continueExecute = false;
+ }
+
+ return continueExecute;
+ }
+
+ /**
+ * The CommandFragmentEngine calls this method when it is peeking forward
+ * in the fragments. When peeking forward the command stack state in the
+ * engine is not changes.
+ *
+ *
+ * @param fragment the fragment that it is peeking at.
+ * @return Indicates whether peeking should stop or not.
+ */
+ protected boolean peekFragment( CommandFragment fragment )
+ {
+ return true;
+ }
+
+ /**
+ * The CommandFragmentEngine calls this method when it is moving forward
+ * in the fragments. When moving forward the command stack state is saved
+ * at each fragment is traversed.
+ *
+ * @param fragment the fragment that is being traversed.
+ * @return indicates if the forward traversal should continue.
+ */
+ protected boolean nextFragment( CommandFragment fragment )
+ {
+ if( fragment.doNotRunInTransaction() != doNotRunInTransaction_ )
+ {
+ // The fragment is requesting a different transaction environment than
+ // the one that we are in so we must stop and change environments.
+ doNotRunInTransaction_ = fragment.doNotRunInTransaction();
+ foundStop_ = false;
+ }
+
+ return foundStop_;
+ }
+
+ /**
+ * This method is called for each fragment when the command engine is unwinding
+ * its stack during an undo operation.
+ *
+ * @param fragment the fragment being undone.
+ * @return returns true if the undo process should continue.
+ */
+ protected boolean undoFragment( CommandFragment fragment )
+ {
+ return true;
+ }
+
+ /**
+ * This method undoes the commands that were executed in the runForwardToNextStop
+ * method.
+ * @param context the runnable context.
+ * @return returns if all commands have been undone or not.
+ */
+ public boolean runUndoToNextStop( IRunnableContext context )
+ {
+ final boolean result[] = new boolean[]{true};
+
+ IRunnableWithProgress undoOperation
+ = new IRunnableWithProgress()
+ {
+ public void run(IProgressMonitor monitor)
+ {
+ result[0] = engine_.undoToLastStop(monitor);
+ }
+ };
+
+ try
+ {
+ if( context == null )
+ {
+ // We don't have a container yet so just run the operation.
+ undoOperation.run( null );
+ }
+ else
+ {
+ // We have a container where this operation can run and have
+ // its progress displayed.
+ context.run( false, false, undoOperation );
+ }
+ }
+ catch( Exception exc )
+ {
+ // For now we will ignore all exceptions.
+ }
+
+ return result[0];
+ }
+
+ /**
+ * The method executes the CommandFragment commands in the context provided.
+ *
+ * @param context the context
+ * @return returns the status of executing the commands.
+ */
+ public IStatus runForwardToNextStop( IRunnableContext context )
+ {
+ IRunnableWithProgress operation = null;
+
+ doNotRunInTransaction_ = false;
+
+ do
+ {
+ // We will stop unless we are changing transaction modes.
+ foundStop_ = true;
+
+ if( doNotRunInTransaction_ )
+ {
+ operation = getNoTransactionOperation();
+ }
+ else
+ {
+ operation = getTransactionOperation();
+ }
+
+ try
+ {
+ if( context == null )
+ {
+ // We don't have a container yet so just run the operation.
+ operation.run( null );
+ }
+ else
+ {
+ // We have a container where this operation can run and have
+ // its progress displayed.
+ context.run( false, false, operation );
+ }
+ }
+ catch( InterruptedException exc )
+ {
+ //TODO should log these exceptions.
+ exc.printStackTrace();
+ }
+ catch( InvocationTargetException exc )
+ {
+ //TODO should log these exceptions.
+ exc.printStackTrace();
+ }
+ }
+ while( !foundStop_ );
+
+ return engine_.getLastStatus();
+ }
+
+ private IRunnableWithProgress getTransactionOperation()
+ {
+ IRunnableWithProgress operation = new IRunnableWithProgress()
+ {
+ public void run( IProgressMonitor monitor )
+ {
+ environment_.getLog().log(ILog.INFO, "command", 5002, this, "getTransactionOperation", "Start of transaction");
+
+ BaseStatusHandler statusHandler = (BaseStatusHandler)environment_.getStatusHandler();
+
+ statusHandler.resetStatus();
+ engine_.moveForwardToNextStop( monitor );
+
+
+ environment_.getLog().log(ILog.INFO, "command", 5003, this, "getTransactionOperation", "End of transaction");
+ }
+ };
+
+ return operation;
+ }
+
+ private IRunnableWithProgress getNoTransactionOperation()
+ {
+ IRunnableWithProgress operation = new IRunnableWithProgress()
+ {
+ public void run( IProgressMonitor monitor )
+ {
+ environment_.getLog().log(ILog.INFO, "command", 5085, this, "getNoTransactionOperation", "Start of NON transaction");
+
+ BaseStatusHandler statusHandler = (BaseStatusHandler)environment_.getStatusHandler();
+
+ statusHandler.resetStatus();
+ engine_.moveForwardToNextStop( monitor );
+ environment_.getLog().log(ILog.INFO, "command", 5086, this, "getNoTransactionOperation", "End of NON transaction");
+ }
+ };
+
+ return operation;
+ }
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleDialog.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleDialog.java
new file mode 100644
index 000000000..fe6f8f765
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleDialog.java
@@ -0,0 +1,164 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * yyyymmdd bug Email and other contact information
+ * -------- -------- -----------------------------------------------------------
+ * 20060418 136335 joan@ca.ibm.com - Joan Haggarty
+ * 20060418 136759 joan@ca.ibm.com - Joan Haggarty
+ * 20061106 142500 david.schneider@unisys.com - David Schneider
+ * 20060829 180833 ericdp@ca.ibm.com - Eric D. Peters, New Web Service wizard service settings dialog has unlabelled enabled text fields
+ *******************************************************************************/
+package org.eclipse.wst.command.internal.env.ui.widgets;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+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.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+public abstract class SimpleDialog extends Dialog implements DialogDataEvents
+{
+ private WidgetContributor widget_;
+ private WidgetDataEvents dataEvents_;
+ private Listener statusListener_;
+ protected WizardPageManager pageManager_;
+ private Text messageText_;
+ private boolean ok_;
+
+ public SimpleDialog( Shell shell, PageInfo pageInfo)
+ {
+ super(shell);
+ widget_ = pageInfo.getWidgetFactory().create();
+ statusListener_ = new StatusListener();
+ }
+
+ Composite parent_;
+ public Control createDialogArea( Composite parent )
+ {
+ parent_ = parent;
+ Composite control = (Composite) super.createDialogArea(parent);
+ dataEvents_ = widget_.addControls( control, statusListener_ );
+
+ //Text area to display validation messages
+ messageText_ = new Text(parent, SWT.WRAP | SWT.MULTI | SWT.READ_ONLY);
+ messageText_.setBackground(parent.getBackground());
+ GridData griddata = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
+ griddata.horizontalIndent = 10;
+ messageText_.setLayoutData( griddata );
+ parent_.setFocus();
+
+ //Call extenders override of the callSetters method to intialize any data in widget
+ callSetters();
+ Dialog.applyDialogFont(parent);
+ return control;
+ }
+
+ //Override of Dialog.createContents so we can affect button enablement
+ protected Control createContents(Composite parent) {
+ Control c = super.createContents(parent);
+ //enable controls for initial entry to dialog
+ validatePageToStatus();
+ return c;
+ }
+
+ // Enable or disable ok button based on state
+ private void enableOk(boolean state)
+ {
+ Button okButton = getButton(IDialogConstants.OK_ID);
+ if (okButton != null)
+ okButton.setEnabled(state);
+ }
+
+ //Implement this method to call all setters on the dialog widget after the controls are created
+ protected abstract void callSetters();
+
+ public WidgetDataEvents getDataEvents()
+ {
+ return dataEvents_;
+ }
+
+ protected WidgetContributor getWidget()
+ {
+ return widget_;
+ }
+
+ // sets message in message area above OK and Cancel buttons
+ private void setMessage(String message)
+ {
+ if (message == null)
+ messageText_.setText("");
+ else
+ messageText_.setText(message);
+ // force a resize of the parent composite and wrap of the text field if necessary
+ parent_.layout();
+ }
+
+
+
+ public void validatePageToStatus()
+ {
+ IStatus status = widget_.getStatus();
+
+ if( status != null )
+ {
+ String message = status.getMessage();
+ int severity = status.getSeverity();
+
+ // for error condition, disable ok and print message
+ if( severity == IStatus.ERROR )
+ {
+ if( message.length() == 0 )
+ {
+ setMessage( null);
+ }
+ else
+ {
+ setMessage(message);
+ }
+ ok_ = false;
+ }
+ // display warning and info messages but still enable OK
+ else if (severity == IStatus.WARNING | severity == IStatus.INFO)
+ {
+ setMessage(message);
+ ok_ = true;
+ }
+ // no message to display
+ else
+ {
+ setMessage( null);
+ ok_ = true;
+ }
+ }
+ // null status case
+ else
+ {
+ setMessage(null);
+ ok_ = true;
+ }
+
+ enableOk(ok_);
+ }
+
+ private class StatusListener implements Listener
+ {
+ public void handleEvent( Event evt )
+ {
+ validatePageToStatus();
+ }
+ }
+}
+
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimplePageFactory.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimplePageFactory.java
new file mode 100644
index 000000000..9694e7080
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimplePageFactory.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.command.internal.env.ui.widgets;
+
+
+public class SimplePageFactory implements WizardPageFactory
+{
+ public PageWizardDataEvents getPage( PageInfo pageInfo, WizardPageManager manager )
+ {
+ return new SimpleWizardPage( pageInfo, manager );
+ }
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimplePopupPageFactory.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimplePopupPageFactory.java
new file mode 100644
index 000000000..65331d32e
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimplePopupPageFactory.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.command.internal.env.ui.widgets;
+
+
+public class SimplePopupPageFactory implements WizardPageFactory
+{
+ private String id_;
+
+ public SimplePopupPageFactory( String id )
+ {
+ id_ = id;
+ }
+
+ public PageWizardDataEvents getPage( PageInfo pageInfo, WizardPageManager manager )
+ {
+ return new SimplePopupWizardPage( pageInfo, manager, id_ );
+ }
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimplePopupWizardPage.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimplePopupWizardPage.java
new file mode 100644
index 000000000..bc509ca8a
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimplePopupWizardPage.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * yyyymmdd bug Email and other contact information
+ * -------- -------- -----------------------------------------------------------
+ * 20060731 120378 makandre@ca.ibm.com - Andrew Mak, Fields not visible in Large font settings
+ * 20070522 184006 pmoogk@ca.ibm.com - Peter Moogk
+ *******************************************************************************/
+package org.eclipse.wst.command.internal.env.ui.widgets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.command.internal.env.context.PersistentActionDialogsContext;
+import org.eclipse.wst.command.internal.env.ui.EnvironmentUIMessages;
+
+
+
+public class SimplePopupWizardPage extends SimpleWizardPage
+{
+ private String id_;
+
+ public SimplePopupWizardPage( PageInfo pageInfo, WizardPageManager pageManager, String id )
+ {
+ super( pageInfo, pageManager );
+
+ id_ = id;
+ }
+
+ protected Composite internalCreateControl( Composite parent )
+ {
+ Composite composite = super.internalCreateControl(parent);
+
+ final PersistentActionDialogsContext context = PersistentActionDialogsContext.getInstance();
+
+ // If the current page is null then this must be the first page.
+ if( pageManager_.getCurrentPage() == null && context.showCheckbox(id_) )
+ {
+ final Button button = new Button( composite, SWT.CHECK );
+ String label = EnvironmentUIMessages.CHECKBOX_DO_NOT_SHOW_DIALOG_AGAIN;
+
+ /*CONTEXT_ID TWP0001 for the show/hide check box*/
+ String infopop = "org.eclipse.wst.command.env.ui.TWP0001";
+ String tooltip = EnvironmentUIMessages.TOOLTIP_DO_NOT_SHOW_DIALOG_AGAIN;
+
+ button.setText( label );
+ button.setToolTipText( tooltip );
+ button.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent evt )
+ {
+ context.setObjectActionDialogEnabled( id_, button.getSelection() );
+ }
+ });
+ button.setSelection( false );
+
+ PlatformUI.getWorkbench().getHelpSystem().setHelp( button, infopop );
+ }
+
+ return composite;
+ }
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleWidgetContributor.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleWidgetContributor.java
new file mode 100644
index 000000000..952c2f42e
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleWidgetContributor.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.wst.command.internal.env.ui.widgets;
+
+import org.eclipse.wst.command.internal.env.core.data.DataMappingRegistry;
+
+public class SimpleWidgetContributor implements INamedWidgetContributor
+{
+ private WidgetContributorFactory factory_;
+ private String name_;
+ private String description_;
+ private String title_;
+
+ public void setDescription(String description)
+ {
+ description_ = description;
+ }
+
+
+ public void setFactory(WidgetContributorFactory factory)
+ {
+ factory_ = factory;
+ }
+
+
+ public void setName(String name)
+ {
+ name_ = name;
+ }
+
+
+ public void setTitle(String title)
+ {
+ title_ = title;
+ }
+
+
+ public WidgetContributorFactory getWidgetContributorFactory()
+ {
+ return factory_;
+ }
+
+ public String getName()
+ {
+ return name_;
+ }
+
+ public String getDescription()
+ {
+ return description_;
+ }
+
+ public String getTitle()
+ {
+ return title_;
+ }
+
+ /**
+ * Subsclassers should override this method.
+ */
+ public void registerDataMappings(DataMappingRegistry dataRegistry)
+ {
+
+ }
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleWidgetDataContributor.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleWidgetDataContributor.java
new file mode 100644
index 000000000..6f806a16a
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleWidgetDataContributor.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.command.internal.env.ui.widgets;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Listener;
+
+
+/**
+ * This class provides a simple WidgetDataContributor class that concrete
+ * WidgetDataContributors can subclass.
+ *
+ */
+public class SimpleWidgetDataContributor implements WidgetDataContributor
+{
+ /**
+ * @see org.eclipse.wst.command.internal.env.ui.widgets.WidgetContributor#addControls(org.eclipse.swt.widgets.Composite, org.eclipse.swt.widgets.Listener)
+ */
+ public WidgetDataEvents addControls( Composite parent, Listener statusListener)
+ {
+ return this;
+ }
+
+ /**
+ * @see org.eclipse.wst.command.internal.env.ui.widgets.WidgetContributor#getStatus()
+ */
+ public IStatus getStatus()
+ {
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.wst.command.internal.env.ui.widgets.WidgetDataEvents#externalize()
+ */
+ public void externalize()
+ {
+ }
+
+ /**
+ * @see org.eclipse.wst.command.internal.env.ui.widgets.WidgetDataEvents#internalize()
+ */
+ public void internalize()
+ {
+ }
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleWidgetRegistry.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleWidgetRegistry.java
new file mode 100644
index 000000000..8a6fafc21
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleWidgetRegistry.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.command.internal.env.ui.widgets;
+
+import java.util.Hashtable;
+
+
+
+public class SimpleWidgetRegistry implements WidgetRegistry
+{
+ private Hashtable table_ = new Hashtable();
+
+ public void add( String fragmentId,
+ String pageName,
+ String pageTitle,
+ WidgetContributorFactory widgetFactory )
+ {
+ PageInfo entry = new PageInfo( pageName, pageTitle, widgetFactory );
+ table_.put( fragmentId, entry );
+ }
+
+ public PageInfo getPageInfo( String fragmentId )
+ {
+ return (PageInfo)table_.get( fragmentId );
+ }
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleWizardPage.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleWizardPage.java
new file mode 100644
index 000000000..2625964cc
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleWizardPage.java
@@ -0,0 +1,153 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * yyyymmdd bug Email and other contact information
+ * -------- -------- -----------------------------------------------------------
+ * 20060731 120378 makandre@ca.ibm.com - Andrew Mak, Fields not visible in Large font settings
+ *******************************************************************************/
+package org.eclipse.wst.command.internal.env.ui.widgets;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+
+
+
+public class SimpleWizardPage extends WizardPage implements PageWizardDataEvents
+{
+ private WidgetContributor widget_;
+ private WidgetDataEvents dataEvents_;
+ private Listener statusListener_;
+ protected WizardPageManager pageManager_;
+
+ public SimpleWizardPage( PageInfo pageInfo, WizardPageManager pageManager )
+ {
+ super( "" );
+
+ setTitle( pageInfo.getPageName() );
+ setDescription( pageInfo.getPageTitle());
+
+ widget_ = pageInfo.getWidgetFactory().create();
+ statusListener_ = new StatusListener();
+ pageManager_ = pageManager;
+ }
+
+ public void createControl( Composite parent )
+ {
+ ScrolledComposite control = new ScrolledComposite( parent, SWT.V_SCROLL );
+ Composite inner = internalCreateControl(control);
+
+ control.setExpandHorizontal(true);
+ control.setExpandVertical(true);
+ control.setContent(inner);
+ control.setMinSize(inner.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+
+ org.eclipse.jface.dialogs.Dialog.applyDialogFont(control);
+ setControl( control );
+ }
+
+ protected Composite internalCreateControl( Composite parent ) {
+
+ Composite control = new Composite( parent, SWT.NONE );
+ control.setLayout( new GridLayout() );
+ control.setLayoutData( new GridData( GridData.FILL_BOTH ));
+
+ dataEvents_ = widget_.addControls( control, statusListener_ );
+
+ return control;
+ }
+
+ public WidgetDataEvents getDataEvents()
+ {
+ return dataEvents_;
+ }
+
+ public void validatePageToStatus()
+ {
+ IStatus status = widget_.getStatus();
+
+ if( status != null )
+ {
+ if( status.getSeverity() == IStatus.ERROR )
+ {
+ String message = status.getMessage();
+
+ if( message.length() == 0 )
+ {
+ setErrorMessage( null );
+ setMessage( getDescription() );
+ }
+ else
+ {
+ setErrorMessage( message );
+ }
+
+ setPageComplete( false );
+ }
+ else if (status.getSeverity() == IStatus.WARNING )
+ {
+ setErrorMessage( null );
+ setMessage(status.getMessage(), IStatus.WARNING );
+ setPageComplete( true );
+ }
+ else if( status.getSeverity() == IStatus.INFO )
+ {
+ setErrorMessage( null );
+ setMessage( status.getMessage(), IStatus.INFO );
+ setPageComplete( true );
+ }
+ else
+ {
+ setErrorMessage( null );
+ setMessage( getDescription() );
+ setPageComplete( true );
+ }
+ }
+ else
+ {
+ setErrorMessage( null );
+ setMessage( getDescription() );
+ setPageComplete( true );
+ }
+
+ getContainer().updateButtons();
+ }
+
+ public boolean canFlipToNextPage()
+ {
+ return isPageComplete() && pageManager_.hasNextPage();
+ }
+
+ public IWizardPage getNextPage()
+ {
+ return pageManager_.getNextPage();
+ }
+
+ public void setVisible(boolean value)
+ {
+ pageManager_.handlePageVisible( this, value );
+
+ super.setVisible(value);
+ }
+
+ private class StatusListener implements Listener
+ {
+ public void handleEvent( Event evt )
+ {
+ validatePageToStatus();
+ }
+ }
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetBindingToWidgetFactoryAdapter.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetBindingToWidgetFactoryAdapter.java
new file mode 100644
index 000000000..152f7c8c8
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetBindingToWidgetFactoryAdapter.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.wst.command.internal.env.ui.widgets;
+
+import java.util.Hashtable;
+
+import org.eclipse.wst.command.internal.env.core.data.DataMappingRegistry;
+
+public class WidgetBindingToWidgetFactoryAdapter
+{
+ private Hashtable widgetContributor_;
+ private CommandWidgetBinding binding_;
+
+ public WidgetBindingToWidgetFactoryAdapter( CommandWidgetBinding binding )
+ {
+ widgetContributor_ = new Hashtable();
+ binding_ = binding;
+
+ binding.registerWidgetMappings( new MyWidgetRegistry() );
+ }
+
+ public INamedWidgetContributor getWidget( String id )
+ {
+ return (INamedWidgetContributor)widgetContributor_.get( id );
+ }
+
+ public void registerDataMappings( DataMappingRegistry registry )
+ {
+ binding_.registerDataMappings( registry );
+ }
+
+ private class MyWidgetRegistry implements WidgetRegistry
+ {
+ public void add(String fragmentId, String pageName, String pageTitle, WidgetContributorFactory widgetFactory)
+ {
+ SimpleWidgetContributor widget = new SimpleWidgetContributor();
+ widget.setTitle( pageName );
+ widget.setDescription( pageTitle );
+ widget.setFactory( new MyWidgetContributorFactory( widgetFactory ) );
+
+ widgetContributor_.put( fragmentId, widget );
+ }
+ }
+
+ private class MyWidgetContributorFactory implements WidgetContributorFactory
+ {
+ private WidgetContributorFactory factory_;
+ private WidgetContributor widget_;
+
+ public MyWidgetContributorFactory( WidgetContributorFactory factory )
+ {
+ factory_ = factory;
+ }
+
+ public WidgetContributor create()
+ {
+ if( widget_ == null )
+ {
+ widget_ = factory_.create();
+ }
+
+ return widget_;
+ }
+ }
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetContributor.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetContributor.java
new file mode 100644
index 000000000..9c8afc661
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetContributor.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.command.internal.env.ui.widgets;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Listener;
+
+
+/**
+ * This interface provides a way for developers to create validatable widgets
+ * that can be used in many different Eclipse UI contexts. (ie. in a Windows, Diaglogs,
+ * wizard pages, etc)
+ *
+ * The main functionality this interface has over just a regular Eclipse Composite
+ * is that it provides a mechanism for validating the Widget. When validating
+ * there are two aspects to keep in mind. The first aspect deals with WHEN validation
+ * occurs and the second aspect deals with WHAT to do for a validation event.
+ *
+ * The first aspect of triggering validation events is handled by the statusListener
+ * parameter of the addControls method. If a particular control that is contributed can
+ * affect the validity of this WidgetContributor then the statusListener object
+ * should be added to the listener list of that control. For example, if the text in
+ * a Text widget can affect the validity of this WidgetContributor then you would
+ * add the statusListener to the Text widgets Modify listener list:
+ *
+ *
+ * Text someText = new Text( parent, SWT.NONE );
+ * someText.addListener( SWT.Modify, statusListener );
+ *
+ * Note: if you want to force validation of this widget you can call
+ * the statusListener.handleEvent(null) method directly. This
+ * is not the prefered may to trigger validation, however.
+ *
+ * The second aspect of valiation is what to do when the validation event occurs.
+ * This is handled by getStatus method. Any code that ensures that this widget is
+ * valid should be put in the getStatus implementation.
+ *
+ *
+*/
+public interface WidgetContributor
+{
+ /**
+ * This method should be used to implement the UI contributions for this widget.
+ *
+ * @param parent The composite parent that sub widgets should use.
+ * @param statusListener This listener should be added to any widget that can
+ * affect the validity of this WidgetContributor.
+ * @return returns a WidgetDataEvents object. This object is used by the
+ * framework to internalize and externalize data for this widget.
+ */
+ public WidgetDataEvents addControls( Composite parent, Listener statusListener );
+
+ /**
+ * This method should implement validation code for this WidgetContributor.
+ *
+ * @return returns a status object indicating the validity of this widget.
+ * If the status severity is ERROR then this widget is considered to
+ * be invalid. For any other status severity or if the status returned
+ * is null this widget is considered to be valid.
+ */
+ public IStatus getStatus();
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetContributorFactory.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetContributorFactory.java
new file mode 100644
index 000000000..f27efc63f
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetContributorFactory.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.command.internal.env.ui.widgets;
+
+/**
+ * This interface provide a way for creating WidgetContributors
+ *
+ *
+ */
+public interface WidgetContributorFactory
+{
+ public WidgetContributor create();
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetDataContributor.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetDataContributor.java
new file mode 100644
index 000000000..a781acbbf
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetDataContributor.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.command.internal.env.ui.widgets;
+
+/**
+ * This interface is a combination of the WidgetContributor interface and
+ * the WidgetDataEvents interface.
+ *
+ */
+public interface WidgetDataContributor extends WidgetContributor, WidgetDataEvents
+{
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetDataEvents.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetDataEvents.java
new file mode 100644
index 000000000..cd1d9f8e9
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetDataEvents.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.command.internal.env.ui.widgets;
+
+/**
+ * This interface provides a way for internalizing and externalizing state
+ * data in a WidgetContributor. The internalize method will be called
+ * before the widget is displayed so that it can set the default data
+ * for that widget. The externalize method provides a way of getting data
+ * from the widget after it is displayed.
+ *
+ */
+public interface WidgetDataEvents
+{
+ /**
+ * Implementations should set widget state data here.
+ *
+ */
+ public void internalize();
+
+ /**
+ * Implemenations should get widget state data here.
+ *
+ */
+ public void externalize();
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetRegistry.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetRegistry.java
new file mode 100644
index 000000000..e51b18f53
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetRegistry.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.command.internal.env.ui.widgets;
+
+/**
+ * This interface defines how WidgetContributors are made known to the
+ * dynamic wizard framework. This widget will be displayed as a wizard page
+ * with the name and title specified in the add method. The fragmentId is
+ * used to associate this widget with a particular CommandFragment. When
+ * a CommandFragment with this fragmentId is traversed the corresponding
+ * WidgetContributor will be displayed.
+ *
+ */
+public interface WidgetRegistry
+{
+ /**
+ * Adds a WidgetContributorFactory to the framework. This factory
+ * is used to get the WidgetContributor. This WidgetContributor
+ * will be used to render the wizard page.
+ *
+ * @param fragmentId the CommandFragment id that this WidgetContributor is associated with.
+ * @param pageName the name of this wizard page.
+ * @param pageTitle the title of this wizard page.
+ * @param widgetFactory the factory which will create the WidgetContributor.
+ */
+ public void add( String fragmentId,
+ String pageName,
+ String pageTitle,
+ WidgetContributorFactory widgetFactory );
+
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WizardPageFactory.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WizardPageFactory.java
new file mode 100644
index 000000000..36b664d12
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WizardPageFactory.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.command.internal.env.ui.widgets;
+
+
+/**
+ *
+ *
+ *
+ *
+ */
+public interface WizardPageFactory
+{
+ public PageWizardDataEvents getPage( PageInfo pageInfo, WizardPageManager manager );
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WizardPageManager.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WizardPageManager.java
new file mode 100644
index 000000000..068ed7d89
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WizardPageManager.java
@@ -0,0 +1,538 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * yyyymmdd bug Email and other contact information
+ * -------- -------- -----------------------------------------------------------
+ * 20060223 129232 pmoogk@ca.ibm.com - Peter Moogk
+ * 20060313 130958 pmoogk@ca.ibm.com - Peter Moogk
+ * 20070319 175721 pmoogk@ca.ibm.com - Peter Moogk
+ * 20070328 173345 pmoogk@ca.ibm.com - Peter Moogk, Peek next page problem
+ * 20070730 197144 pmoogk@ca.ibm.com - Peter Moogk, Pass progress monitor to undo commands.
+ *******************************************************************************/
+package org.eclipse.wst.command.internal.env.ui.widgets;
+
+import java.util.Hashtable;
+import java.util.Stack;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.IWizardContainer;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.wst.command.internal.env.core.data.DataFlowManager;
+import org.eclipse.wst.command.internal.env.core.fragment.CommandFragment;
+import org.eclipse.wst.command.internal.env.eclipse.EclipseEnvironment;
+import org.eclipse.wst.command.internal.env.ui.registry.WidgetRegistry;
+import org.eclipse.wst.common.environment.ILog;
+
+
+
+public class WizardPageManager extends SimpleCommandEngineManager
+{
+ private WizardPageFactory pageFactory_;
+ private Hashtable pageTable_;
+ private IWizard wizard_;
+ protected SimpleWidgetRegistry registry_;
+
+ // These variables are used and set by our methods which is
+ // why they are not initialized in the constructor.
+ private PageWizardDataEvents currentPage_;
+ private PageWizardDataEvents nextPage_;
+ private PageWizardDataEvents nextPeekPage_;
+ private PageWizardDataEvents firstPage_;
+ private CommandFragment lastUndoFragment_;
+ private boolean firstFragment_;
+
+ private INamedWidgetContributorFactory widgetFactory_;
+ private Stack widgetStack_;
+ private Stack widgetStackStack_;
+ private Hashtable widgetTable_;
+ private WidgetRegistry widgetRegistry_;
+ private Hashtable widgetFactoryTable_;
+
+ public WizardPageManager( SimpleWidgetRegistry registry,
+ WizardPageFactory pageFactory,
+ IWizard wizard,
+ DataFlowManager dataManager,
+ EclipseEnvironment environment )
+ {
+ super( environment, dataManager );
+
+ pageFactory_ = pageFactory;
+ pageTable_ = new Hashtable();
+ registry_ = registry;
+ wizard_ = wizard;
+ widgetTable_ = new Hashtable();
+ widgetFactoryTable_ = new Hashtable();
+ widgetRegistry_ = WidgetRegistry.instance();
+ widgetStackStack_ = new Stack();
+ }
+
+ public IWizardPage getStartingPage()
+ {
+ if( firstPage_ == null )
+ {
+ firstPage_ = (PageWizardDataEvents)getNextPage();
+ }
+
+ return firstPage_;
+ }
+
+ public IStatus runForwardToNextStop()
+ {
+ firstFragment_ = true;
+ nextPage_ = null;
+
+ return super.runForwardToNextStop( getContainer() );
+ }
+
+ private IWizardContainer getContainer()
+ {
+ IWizardContainer container = wizard_.getContainer();
+
+ if( container == null || container.getCurrentPage() == null )
+ {
+ container = null;
+ }
+
+ return container;
+ }
+
+ public IWizardPage getCurrentPage()
+ {
+ return currentPage_;
+ }
+
+ public boolean hasNextPage()
+ {
+
+ nextPeekPage_ = null;
+
+ try
+ {
+ nextPeekPage_ = getNextPageInGroup( widgetFactory_, widgetStack_, false );
+
+ if( nextPeekPage_ == null )
+ {
+ // If a page is found nextPage_ will be set to its value in the method below.
+ engine_.peekForwardToNextStop();
+ }
+ }
+ catch( Throwable exc )
+ {
+ exc.printStackTrace();
+ }
+
+ return nextPeekPage_ != null;
+ }
+
+ public IWizardPage getNextPage()
+ {
+ try
+ {
+ // Need to externalize the data for the current page so that
+ // when we move forward below the data is available.
+ if( currentPage_ != null ) currentPage_.getDataEvents().externalize();
+
+ if( environment_.getLog().isEnabled() )
+ {
+ environment_.getLog().log(ILog.INFO, "ws_dt_cmd_engine", 5010, this, "Cmd stack dump:", engine_ );
+ }
+
+ nextPage_ = getNextPageInGroup( widgetFactory_, widgetStack_, true );
+
+ if( nextPage_ == null )
+ {
+ widgetFactory_ = null;
+ widgetStack_ = null;
+
+ IStatus status = runForwardToNextStop();
+
+ if( status.getSeverity() == IStatus.ERROR )
+ {
+ // An error has occured so we need undo to the previous stop point.
+ undoToLastPage();
+ }
+ }
+
+ if( nextPage_ != null ) nextPage_.setWizard( wizard_ );
+
+ return nextPage_;
+ }
+ catch( Throwable exc )
+ {
+ exc.printStackTrace();
+ }
+
+ return null;
+ }
+
+ public void handlePageVisible( PageWizardDataEvents page, boolean isPageVisible )
+ {
+ if( !isPageVisible && page == firstPage_ && page == currentPage_ )
+ {
+ // We are moving back one page from the first page. This can't happen with popup wizards
+ // since the previous button would be greyed out. But when the new wizard launches this wizard
+ // the previous button is not greyed out and brings the user back to the list wizards to select.
+ // Therefore, we must unwind the command engine and get ready for the user to invoke this wizard
+ // again. We are assuming here that the first page is never part of a widget group!
+ undoToLastPage();
+ currentPage_ = null;
+ firstPage_ = null;
+ }
+ if( currentPage_ != null && page == currentPage_.getPreviousPage() && isPageVisible )
+ {
+ // We are moving back one page.
+ // Note: we don't internalize the previous page and we do not externalize the current page.
+ // we are basically just leaving the current page without retrieving its state and
+ // moving to the previous page which already has its state set.
+
+ if( widgetFactory_ != null )
+ {
+ if( widgetStack_.size() > 0 )
+ {
+ widgetStack_.pop();
+ }
+
+ if( widgetStack_.size() == 0 )
+ {
+ widgetFactory_ = null;
+ widgetStack_ = null;
+ widgetStackStack_.pop();
+ }
+ }
+
+ if( widgetFactory_ == null )
+ {
+ undoToLastPage();
+ }
+
+ // Since we are moving backwards we need to remove the
+ // current page object from the mapping table.
+ dataManager_.unprocess( currentPage_.getDataEvents() );
+
+ currentPage_ = page;
+ }
+ else if( isPageVisible )
+ {
+ try
+ {
+ // We are moving forward one page.
+ WidgetDataEvents dataEvents = page.getDataEvents();
+
+ dataManager_.process( dataEvents ); // Push model data into the new page.
+ dataEvents.internalize();
+
+ page.validatePageToStatus();
+ }
+ catch( Throwable exc )
+ {
+ exc.printStackTrace();
+ }
+ finally
+ {
+ if( currentPage_ != null ) page.setPreviousPage( currentPage_ );
+
+ currentPage_ = page;
+ }
+ }
+ }
+
+ public boolean performFinish()
+ {
+ // We need to simulate the next button being pressed until there are no more pages.
+ // If an error occurs we will return false and reset the command stack back our original state.
+ boolean doneOk = true;
+ PageWizardDataEvents startPage = currentPage_;
+ int stackStackSize = widgetStackStack_.size();
+
+ INamedWidgetContributorFactory currentFactory = widgetFactory_;
+
+ // Externalize the current page.
+ currentPage_.getDataEvents().externalize();
+
+ // Loop through subsequent pages.
+ do
+ {
+ IStatus status = runForwardToNextStop();
+
+ if( status.getSeverity() == IStatus.ERROR )
+ {
+ // An error occured in one of the commands.
+ doneOk = false;
+ }
+ }
+ while( nextPage_ != null && doneOk);
+
+ if( !doneOk )
+ {
+ // An error occured, so we need to return the command stack to it's
+ // orginal state.
+ PageWizardDataEvents page = null;
+ boolean done = false;
+
+ do
+ {
+ done = runUndoToNextStop( getContainer() );
+ page = getPage( lastUndoFragment_ );
+
+ if( page == null &&
+ currentFactory != null &&
+ lastUndoFragment_ != null &&
+ getWidgetFactory( lastUndoFragment_.getId() ) == currentFactory )
+ {
+ // The current widget factory is associated with the last fragment that was undone.
+ // Therefore, we are back to where we started.
+ done = true;
+
+ // Restore the widgetStackStack back to the state it was in before
+ // running forward.
+ widgetStackStack_.setSize( stackStackSize );
+
+ StackEntry entry = (StackEntry)widgetStackStack_.peek();
+
+ widgetFactory_ = entry.factory_;
+ widgetStack_ = entry.stack_;
+ }
+ else if( page != null )
+ {
+ widgetFactory_ = null;
+ widgetStack_ = null;
+ }
+ }
+ while( page != startPage && !done );
+ }
+
+ return doneOk;
+ }
+
+ public boolean performCancel()
+ {
+ IWizardContainer container = getContainer();
+
+ while( !runUndoToNextStop( container ) ){}
+
+ return true;
+ }
+
+ protected boolean peekFragment( CommandFragment fragment )
+ {
+ // Check to see if this fragment is in our page table.
+ nextPeekPage_ = getPage( fragment );
+
+ if( nextPeekPage_ == null )
+ {
+ INamedWidgetContributorFactory factory = getWidgetFactory( fragment.getId() );
+
+ if( factory != null )
+ {
+ nextPeekPage_ = getNextPageInGroup( factory, null, false );
+ }
+ }
+
+ return nextPeekPage_ == null;
+ }
+
+ protected boolean nextFragment( CommandFragment fragment )
+ {
+ // If the super class nextFragment want us to stop then we will stop right away.
+ if( !super.nextFragment( fragment ) ) return false;
+
+ // The first fragment is either at the start of the wizard
+ // or it is on a wizard page. In either case we do not want
+ // to stop if a page is found.
+ if( firstFragment_ )
+ {
+ firstFragment_ = false;
+ }
+ else
+ {
+ widgetFactory_ = getWidgetFactory( fragment.getId() );
+
+ if( widgetFactory_ != null )
+ {
+ widgetStack_ = new Stack();
+
+ nextPage_ = getNextPageInGroup( widgetFactory_, widgetStack_, true );
+
+ if( nextPage_ == null )
+ {
+ // We found a widget contributor for this fragment, but no page was delivered for it.
+ // We will therefore, not put it on our stack of widget stacks.
+ widgetStack_ = null;
+ widgetFactory_ = null;
+ }
+ else
+ {
+ StackEntry entry = new StackEntry();
+
+ entry.factory_ = widgetFactory_;
+ entry.stack_ = widgetStack_;
+ widgetStackStack_.push( entry );
+ }
+ }
+ else
+ {
+ nextPage_ = getPage( fragment );
+ }
+ }
+
+ return nextPage_ == null;
+ }
+
+ protected boolean undoFragment( CommandFragment fragment )
+ {
+ lastUndoFragment_ = fragment;
+
+ return true;
+ }
+
+
+ private PageWizardDataEvents getNextPageInGroup( INamedWidgetContributorFactory factory, Stack widgetStack, boolean pushNewWidget )
+ {
+ PageWizardDataEvents page = null;
+
+ if( factory != null )
+ {
+ INamedWidgetContributor newWidget = null;
+
+ if( widgetStack == null || widgetStack.size() == 0 )
+ {
+ newWidget = factory.getFirstNamedWidget();
+ }
+ else
+ {
+ INamedWidgetContributor currentWidget = (INamedWidgetContributor)widgetStack.peek();
+ newWidget = factory.getNextNamedWidget( currentWidget );
+ }
+
+ if( newWidget != null )
+ {
+ page = getPage( newWidget );
+
+ if( pushNewWidget )
+ {
+ widgetStack.push( newWidget );
+ }
+ }
+ }
+
+ return page;
+ }
+
+ private void undoToLastPage()
+ {
+ boolean stackEmpty = false;
+ boolean doneUndoing = false;
+
+ while( !doneUndoing )
+ {
+ stackEmpty = runUndoToNextStop( getContainer() );
+
+ IWizardPage page = null;
+
+ if( lastUndoFragment_ != null )
+ {
+ page = getPage( lastUndoFragment_ );
+
+ if( page == null )
+ {
+ // Check to see if a group page fragment was found.
+ INamedWidgetContributorFactory factory = getWidgetFactory( lastUndoFragment_.getId() );
+
+ if( factory != null && !widgetStackStack_.empty() )
+ {
+ StackEntry entry = (StackEntry)widgetStackStack_.peek();
+
+ if( entry.factory_ == factory )
+ {
+ // We found the factory for the entry at the top of the stack.
+ widgetFactory_ = entry.factory_;
+ widgetStack_ = entry.stack_;
+
+ if( widgetStack_ != null && !widgetStack_.empty() )
+ {
+ INamedWidgetContributor currentWidget = (INamedWidgetContributor)widgetStack_.peek();
+
+ page = getPage( currentWidget );
+ }
+ }
+ }
+ }
+ }
+
+ doneUndoing = page != null || stackEmpty;
+ }
+ }
+
+ private PageWizardDataEvents getPage( CommandFragment fragment )
+ {
+ // Check to see if this fragment is in our page table.
+ PageWizardDataEvents page = (PageWizardDataEvents)pageTable_.get( fragment );
+ String id = fragment.getId();
+
+ if( page == null && id != null )
+ {
+ // Check to see if this fragment id is in the registry.
+ PageInfo pageInfo = registry_.getPageInfo( id );
+
+ if( pageInfo != null )
+ {
+ page = pageFactory_.getPage( pageInfo, this );
+ pageTable_.put( fragment, page );
+ }
+ }
+
+ return page;
+ }
+
+ private PageWizardDataEvents getPage( INamedWidgetContributor widget )
+ {
+ PageWizardDataEvents page = (PageWizardDataEvents)widgetTable_.get( widget );
+
+ if( page == null )
+ {
+ PageInfo pageInfo = new PageInfo(widget.getTitle(), widget.getDescription(), widget.getWidgetContributorFactory() );
+
+ page = pageFactory_.getPage( pageInfo, this );
+ widgetTable_.put( widget, page );
+ }
+
+ return page;
+ }
+
+ private INamedWidgetContributorFactory getWidgetFactory( String id )
+ {
+ INamedWidgetContributorFactory factory = (INamedWidgetContributorFactory)widgetFactoryTable_.get( id );
+
+ if( factory == null )
+ {
+ // The factory is not in our table so we will try the registry.
+ factory = widgetRegistry_.getFactory( id );
+
+ if( factory != null )
+ {
+ widgetFactoryTable_.put( id, factory );
+ factory.registerDataMappings( dataManager_.getMappingRegistry() );
+ dataManager_.process( factory );
+ }
+ }
+ else
+ {
+ dataManager_.process( factory );
+ }
+
+ return factory;
+ }
+
+ private class StackEntry
+ {
+ INamedWidgetContributorFactory factory_;
+ Stack stack_;
+ }
+}
diff --git a/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/popup/DynamicPopupWizard.java b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/popup/DynamicPopupWizard.java
new file mode 100644
index 000000000..0a1748bc8
--- /dev/null
+++ b/core/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/popup/DynamicPopupWizard.java
@@ -0,0 +1,227 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * yyyymmdd bug Email and other contact information
+ * -------- -------- -----------------------------------------------------------
+ * 20060223 129232 pmoogk@ca.ibm.com - Peter Moogk
+ * 20060417 136596 joan@ca.ibm.com - Joan Haggarty
+ * 20060731 120378 makandre@ca.ibm.com - Andrew Mak, Fields not visible in Large font settings
+ *******************************************************************************/
+package org.eclipse.wst.command.internal.env.ui.widgets.popup;
+
+import java.lang.reflect.InvocationTargetException;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableContext;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.ui.IActionDelegate;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.command.internal.env.context.PersistentActionDialogsContext;
+import org.eclipse.wst.command.internal.env.context.PersistentResourceContext;
+import org.eclipse.wst.command.internal.env.core.data.DataFlowManager;
+import org.eclipse.wst.command.internal.env.core.data.DataMappingRegistryImpl;
+import org.eclipse.wst.command.internal.env.core.fragment.CommandFragment;
+import org.eclipse.wst.command.internal.env.eclipse.EclipseEnvironment;
+import org.eclipse.wst.command.internal.env.ui.eclipse.EclipseStatusHandler;
+import org.eclipse.wst.command.internal.env.ui.widgets.CommandWidgetBinding;
+import org.eclipse.wst.command.internal.env.ui.widgets.DynamicWizard;
+import org.eclipse.wst.command.internal.env.ui.widgets.SimpleCommandEngineManager;
+import org.eclipse.wst.command.internal.env.ui.widgets.SimplePopupPageFactory;
+import org.eclipse.wst.command.internal.env.ui.widgets.WizardPageFactory;
+
+
+/**
+ * This class is used to popup dynamic wizards. The popupMenus extension is used
+ * the contribute a popup to Eclipse. The class in the action element should reference
+ * this DynamicPopupWizard class. This id attribute in the action element should contain
+ * an id that references a dynamicWizard extension point. This is how the DynamicPopupWizard
+ * class knows which wizard to display.
+ *
+ * Note: the id attribute in the objectContribution element refers to an
+ * actionDialogPreferenceType extension point. The ids in objectContribution
+ * element and the action element need not be the same as they are in the
+ * example below.
+ *
+ *<pre>
+ * &lt;extension
+ * point="org.eclipse.ui.popupMenus"&gt;
+ *&lt;!-- IFile *.wsdl popup menu --&gt;
+ * &lt;objectContribution
+ * objectClass="org.eclipse.core.resources.IFile"
+ * nameFilter="*.wsdl"
+ * id="org.eclipse.jst.ws.consumption.ui.wizard.client.clientwizard"&gt;
+ *&lt;!-- WSDL To Java Bean Proxy --&gt;
+ * &lt;action
+ * label="%ACTION_GENERATE_JAVA_PROXY"
+ * class="org.eclipse.wst.command.internal.env.ui.widgets.popup.DynamicPopupWizard"
+ * menubarPath="org.eclipse.jst.ws.atk.ui.webservice.category.popupMenu/popupActions"
+ * id="org.eclipse.jst.ws.consumption.ui.wizard.client.clientwizard"&gt;
+ * &lt;/action&gt;
+ * &lt;/objectContribution&gt;
+ * &lt;/extension&gt;
+ *
+ * &lt;extension
+ * point="org.eclipse.wst.command.env.dynamicWizard"&gt;
+ * &lt;dynamicWizard
+ * iconbanner="icons/full/wizban/webservicesclient_wiz.gif"
+ * class="org.eclipse.jst.ws.consumption.ui.widgets.binding.ClientWidgetBinding"
+ * title="%WIZARD_TITLE_WSC"
+ * id="org.eclipse.jst.ws.consumption.ui.wizard.client.clientwizard"&gt;
+ * &lt;/dynamicWizard&gt;
+ * &lt;/extension&gt;
+ *</pre>
+ *
+ */
+public class DynamicPopupWizard extends DynamicWizard implements IActionDelegate
+{
+ private ISelection selection_;
+
+ public DynamicPopupWizard()
+ {
+ super();
+ }
+
+ /**
+ *
+ * @see org.eclipse.wst.command.internal.env.ui.widgets.DynamicWizard#getWizardPageFactory()
+ */
+ protected WizardPageFactory getWizardPageFactory()
+ {
+ return new SimplePopupPageFactory( getId() );
+ }
+
+ private String getId()
+ {
+ return ((IConfigurationElement)originalElement_.getParent()).getAttribute( "id" );
+ }
+
+ /**
+ * @see IActionDelegate#run
+ */
+ public void run(IAction action)
+ {
+ PersistentActionDialogsContext context = PersistentActionDialogsContext.getInstance();
+ String id = getId();
+
+ if( context.showDialog(id) )
+ {
+ // Launch the wizard.
+ init( PlatformUI.getWorkbench(), getSelection() );
+
+ WizardDialog dialog= new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), this);
+ dialog.create();
+
+ if( getStartingPage() != null )
+ {
+ dialog.open();
+ }
+ }
+ else
+ {
+ final ProgressMonitorDialog monitor = new ProgressMonitorDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
+
+ try
+ {
+ monitor.run( false, false, new IRunnableWithProgress()
+ {
+ public void run( IProgressMonitor progressMonitor )
+ {
+ runHeadLess( getSelection(), monitor );
+ }
+ } );
+ }
+ catch( InterruptedException exc )
+ {
+ }
+ catch( InvocationTargetException exc )
+ {
+ }
+ }
+ }
+
+ /**
+ * Runs only the Commands associated with the dynamic wizard.
+ *
+ * @param selection the initial selection from the user.
+ * @param context the context that this execution should take place in. This
+ * is usually a progress context so that the user can get feedback
+ * on how execution is progressing. The context may be null.
+ */
+ public void runHeadLess( IStructuredSelection selection, IRunnableContext context )
+ {
+ PersistentResourceContext resourceContext = PersistentResourceContext.getInstance();
+ EclipseStatusHandler handler = new EclipseStatusHandler();
+ EclipseEnvironment environment = new EclipseEnvironment( null, resourceContext, handler );
+
+ DataMappingRegistryImpl dataRegistry_ = new DataMappingRegistryImpl();
+ DataFlowManager dataManager = new DataFlowManager( dataRegistry_, environment );
+ SimpleCommandEngineManager manager = new SimpleCommandEngineManager(environment, dataManager );
+
+ try
+ {
+ commandWidgetBinding_ = (CommandWidgetBinding)wizardElement_.createExecutableExtension( "class" );
+ }
+ catch( CoreException exc )
+ {
+ exc.printStackTrace();
+ }
+
+ commandWidgetBinding_.registerDataMappings( dataRegistry_ );
+
+ CommandFragment rootFragment = getRootFragment( selection, null );
+
+ manager.setRootFragment( rootFragment );
+ manager.runForwardToNextStop( context );
+ }
+
+ /**
+ * @see IActionDelegate#selectionChanged
+ */
+ public void selectionChanged(IAction action, ISelection selection)
+ {
+ selection_ = selection;
+ }
+
+ private IStructuredSelection getSelection()
+ {
+ IStructuredSelection result = new StructuredSelection();
+
+ if( selection_ != null)
+ {
+ if( selection_ instanceof IStructuredSelection )
+ {
+ result = (IStructuredSelection)selection_;
+ }
+ }
+ else
+ {
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+
+ if( window != null )
+ {
+ ISelection selection = window.getSelectionService().getSelection();
+
+ if( selection instanceof IStructuredSelection )
+ {
+ result = (IStructuredSelection)selection;
+ }
+ }
+ }
+
+ return result;
+ }
+}

Back to the top