[nobug] JS drop patch for 112367 for peter
diff --git a/plugins/org.eclipse.wst.common.environment/src/org/eclipse/wst/common/internal/environment/eclipse/EclipseLog.java b/plugins/org.eclipse.wst.common.environment/src/org/eclipse/wst/common/internal/environment/eclipse/EclipseLog.java
index fd8a316..b5a3111 100644
--- a/plugins/org.eclipse.wst.common.environment/src/org/eclipse/wst/common/internal/environment/eclipse/EclipseLog.java
+++ b/plugins/org.eclipse.wst.common.environment/src/org/eclipse/wst/common/internal/environment/eclipse/EclipseLog.java
@@ -37,7 +37,7 @@
* @see org.eclipse.wst.command.internal.provisional.env.core.common.Log#isEnabled(java.lang.String)
*/
public boolean isEnabled(String option) {
- return "true".equals(Platform.getDebugOption("org.eclipse.wst.command.env/trace/"
+ return "true".equals(Platform.getDebugOption("org.eclipse.wst.common.environment/trace/"
+ option));
}
@@ -98,7 +98,9 @@
public void log(int severity, int messageNum, Object caller,
String method, Throwable throwable) {
log( severity, messageNum, caller, method, (Object)null );
- throwable.printStackTrace();
+
+ if( throwable != null ) throwable.printStackTrace();
+
/*
if (isEnabled()) {
switch (severity) {
diff --git a/plugins/org.eclipse.wst.common.frameworks.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.wst.common.frameworks.ui/META-INF/MANIFEST.MF
index adb6ffb..01c9f58 100644
--- a/plugins/org.eclipse.wst.common.frameworks.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.wst.common.frameworks.ui/META-INF/MANIFEST.MF
@@ -15,5 +15,6 @@
org.eclipse.ui,
org.eclipse.wst.common.frameworks;visibility:=reexport,
org.eclipse.core.runtime,
- org.eclipse.jem.util
+ org.eclipse.jem.util,
+ org.eclipse.wst.common.environment
Eclipse-AutoStart: true
diff --git a/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/datamodel/ui/DataModelWizard.java b/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/datamodel/ui/DataModelWizard.java
index 5a57123..9e73fad 100644
--- a/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/datamodel/ui/DataModelWizard.java
+++ b/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/datamodel/ui/DataModelWizard.java
@@ -9,7 +9,6 @@
package org.eclipse.wst.common.frameworks.internal.datamodel.ui;
import java.lang.reflect.InvocationTargetException;
-
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -17,12 +16,14 @@
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.wst.common.environment.Environment;
import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation;
import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider;
import org.eclipse.wst.common.frameworks.internal.DataModelManager;
import org.eclipse.wst.common.frameworks.internal.OperationManager;
+import org.eclipse.wst.common.frameworks.internal.eclipse.ui.EclipseEnvironment;
import org.eclipse.wst.common.frameworks.internal.ui.ErrorDialog;
import org.eclipse.wst.common.frameworks.internal.ui.PageGroupManager;
import org.eclipse.wst.common.frameworks.internal.ui.WTPCommonUIResourceHandler;
@@ -247,6 +248,15 @@
return new SimplePageGroup(id, id);
}
+ /**
+ * Creates the default environment for this wizard.
+ * @return
+ */
+ protected Environment createEnvironment()
+ {
+ return new EclipseEnvironment();
+ }
+
public void addPage(IWizardPage page) {
rootPageGroup.addPage((DataModelWizardPage) page);
}
@@ -260,7 +270,7 @@
private class WizardOperationManager extends OperationManager {
public WizardOperationManager(DataModelManager dataModelManager, IDataModelOperation rootOperation) {
- super(dataModelManager, rootOperation);
+ super(dataModelManager, rootOperation, createEnvironment() );
}
public IStatus runOperations() {
diff --git a/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/datamodel/ui/IDMPageGroup.java b/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/datamodel/ui/IDMPageGroup.java
index 2e97479..e37b33b 100644
--- a/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/datamodel/ui/IDMPageGroup.java
+++ b/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/datamodel/ui/IDMPageGroup.java
@@ -8,6 +8,7 @@
**************************************************************************************************/
package org.eclipse.wst.common.frameworks.internal.datamodel.ui;
+import java.util.Set;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
public interface IDMPageGroup
@@ -22,7 +23,7 @@
public String getRequiredDataOperationToRun();
- public String getDataModelID();
+ public Set getDataModelIDs();
public DataModelWizardPage[] getExtendedPages( IDataModel dataModel );
diff --git a/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/datamodel/ui/SimplePageGroup.java b/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/datamodel/ui/SimplePageGroup.java
index b643014..de53a55 100644
--- a/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/datamodel/ui/SimplePageGroup.java
+++ b/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/datamodel/ui/SimplePageGroup.java
@@ -8,6 +8,7 @@
**************************************************************************************************/
package org.eclipse.wst.common.frameworks.internal.datamodel.ui;
+import java.util.Set;
import java.util.Vector;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
@@ -16,7 +17,7 @@
private String wizardID;
private boolean allowExtendedPages;
private String requiredDataOperation;
- private String dataModelID;
+ private Set dataModelIDs;
private IDMPageHandler pageHandler;
private IDMPageGroupHandler pageGroupHandler;
@@ -84,11 +85,11 @@
return wizardID;
}
- public String getDataModelID() {
- return dataModelID;
+ public Set getDataModelIDs() {
+ return dataModelIDs;
}
- public void setDataModelID(String dataModelID) {
- this.dataModelID = dataModelID;
+ public void setDataModelIDs(Set dataModelIDs) {
+ this.dataModelIDs = dataModelIDs;
}
}
diff --git a/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/dialog/ui/ErrorDialog.java b/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/dialog/ui/ErrorDialog.java
new file mode 100644
index 0000000..2e85778
--- /dev/null
+++ b/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/dialog/ui/ErrorDialog.java
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * 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.common.frameworks.internal.dialog.ui;
+
+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/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/dialog/ui/InfoDialog.java b/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/dialog/ui/InfoDialog.java
new file mode 100644
index 0000000..72006b1
--- /dev/null
+++ b/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/dialog/ui/InfoDialog.java
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * 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.common.frameworks.internal.dialog.ui;
+
+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/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/dialog/ui/MessageDialog.java b/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/dialog/ui/MessageDialog.java
new file mode 100644
index 0000000..cb9eebb
--- /dev/null
+++ b/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/dialog/ui/MessageDialog.java
@@ -0,0 +1,636 @@
+/*******************************************************************************
+ * 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.common.frameworks.internal.dialog.ui;
+
+import java.io.BufferedReader;
+import java.io.PrintWriter;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.Vector;
+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.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);
+ 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);
+ //details.setEditable(false);
+ Color color = new Color(parent.getShell().getDisplay(), 255, 255, 255);
+ 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 = repeat( ' ', nesting * 2 );
+ String messageLine = tabChars + status.getMessage() + System.getProperty("line.separator");
+ Throwable except = status.getException();
+
+ text.append( messageLine );
+
+ if( except != null )
+ {
+ String[] trace = 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 > 400 ? 400 : newHeight;
+
+ getShell().setSize( new Point(windowSize.x, newHeight) );
+ }
+
+ private String[] getStackTrace( Throwable exc )
+ {
+ Vector lines = new Vector();
+ StringWriter stringWriter = new StringWriter();
+ PrintWriter printWriter = new PrintWriter( stringWriter );
+
+ exc.printStackTrace( printWriter );
+
+ try
+ {
+ printWriter.close();
+ stringWriter.close();
+ }
+ catch( Exception nestedExc )
+ {
+ return new String[0];
+ }
+
+ StringReader stringReader = new StringReader( stringWriter.toString() );
+ BufferedReader reader = new BufferedReader( stringReader );
+ String line = null;
+
+ try
+ {
+ line = reader.readLine();
+
+ while( line != null )
+ {
+ lines.add( line.trim() );
+ line = reader.readLine();
+ }
+ }
+ catch( Exception nestedExc )
+ {
+ return new String[0];
+ }
+
+ return (String[])lines.toArray( new String[0] );
+ }
+
+ private String repeat( char the_char, int count )
+ {
+ StringBuffer buf = new StringBuffer( count );
+
+ for( int index = 0; index < count; index++ )
+ {
+ buf.append( the_char );
+ }
+
+ return buf.toString();
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/dialog/ui/OptionsDialog.java b/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/dialog/ui/OptionsDialog.java
new file mode 100644
index 0000000..c5cb9ce
--- /dev/null
+++ b/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/dialog/ui/OptionsDialog.java
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * 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.common.frameworks.internal.dialog.ui;
+
+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/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/dialog/ui/StatusDialogConstants.java b/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/dialog/ui/StatusDialogConstants.java
new file mode 100644
index 0000000..f88bcba
--- /dev/null
+++ b/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/dialog/ui/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.common.frameworks.internal.dialog.ui;
+
+/**
+* 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/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/dialog/ui/WarningDialog.java b/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/dialog/ui/WarningDialog.java
new file mode 100644
index 0000000..34ba039
--- /dev/null
+++ b/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/dialog/ui/WarningDialog.java
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * 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.common.frameworks.internal.dialog.ui;
+
+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/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/eclipse/ui/EclipseEnvironment.java b/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/eclipse/ui/EclipseEnvironment.java
new file mode 100644
index 0000000..ae6298a
--- /dev/null
+++ b/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/eclipse/ui/EclipseEnvironment.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 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.common.frameworks.internal.eclipse.ui;
+
+import org.eclipse.wst.common.environment.Environment;
+import org.eclipse.wst.common.environment.EnvironmentService;
+import org.eclipse.wst.common.environment.Log;
+import org.eclipse.wst.common.environment.StatusHandler;
+import org.eclipse.wst.common.environment.uri.SimpleURIFactory;
+import org.eclipse.wst.common.environment.uri.URIFactory;
+import org.eclipse.wst.common.environment.uri.URIScheme;
+
+
+/**
+ * This class implements an Environment class for the Eclipse Environment.
+ * This Environment currently supports the "platform" protocol and the "file"
+ * protocol.
+ *
+ */
+public class EclipseEnvironment implements Environment
+{
+ private SimpleURIFactory uriFactory_ = null;
+ private StatusHandler statusHandler_ = null;
+ private Log logger_ = null;
+
+ public EclipseEnvironment()
+ {
+ this( new EclipseStatusHandler() );
+ }
+
+ public EclipseEnvironment( StatusHandler statusHandler )
+ {
+ URIScheme eclipseScheme = EnvironmentService.getEclipseScheme( this );
+ URIScheme fileScheme = EnvironmentService.getFileScheme();
+
+ uriFactory_ = new SimpleURIFactory();
+ statusHandler_ = statusHandler;
+
+ uriFactory_.registerScheme( "platform", eclipseScheme );
+ uriFactory_.registerScheme( "file", fileScheme );
+ }
+
+ /**
+ * @see org.eclipse.wst.command.internal.provisional.env.core.common.Environment#getLog()
+ */
+ public Log getLog()
+ {
+ if( logger_ == null )
+ {
+ logger_ = EnvironmentService.getEclipseLog();
+ };
+
+ return logger_;
+ }
+
+ /**
+ * @see org.eclipse.wst.command.internal.provisional.env.core.common.Environment#getStatusHandler()
+ */
+ public StatusHandler getStatusHandler()
+ {
+ return statusHandler_;
+ }
+
+ /** (non-Javadoc)
+ * @see org.eclipse.wst.command.internal.provisional.env.core.common.Environment#getURIFactory()
+ */
+ public URIFactory getURIFactory()
+ {
+ return uriFactory_;
+ }
+}
diff --git a/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/eclipse/ui/EclipseStatusHandler.java b/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/eclipse/ui/EclipseStatusHandler.java
new file mode 100644
index 0000000..9481c52
--- /dev/null
+++ b/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/eclipse/ui/EclipseStatusHandler.java
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * 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.common.frameworks.internal.eclipse.ui;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.wst.common.environment.Choice;
+import org.eclipse.wst.common.environment.StatusException;
+import org.eclipse.wst.common.environment.StatusHandler;
+import org.eclipse.wst.common.frameworks.internal.dialog.ui.MessageDialog;
+import org.eclipse.wst.common.frameworks.internal.dialog.ui.StatusDialogConstants;
+
+
+/**
+ * This is the Eclipse UI version of the StatusHandler
+ */
+public class EclipseStatusHandler implements StatusHandler
+{
+ private Shell shell_;
+
+ public EclipseStatusHandler()
+ {
+ this( new Shell() );
+ }
+
+ public EclipseStatusHandler(Shell shell)
+ {
+ shell_ = shell;
+ }
+
+ /**
+ * @see org.eclipse.env.common.StatusHandler#report(org.eclipse.env.common.Status, org.eclipse.env.common.Choice[])
+ */
+ public Choice report(IStatus status, Choice[] choices)
+ {
+ int result =
+ MessageDialog.openMessage(
+ shell_,
+ Messages.TITLE_WARNING,
+ null,
+ status,
+ choices);
+ for (int i = 0; i < choices.length; i++)
+ {
+ if (choices[i].getShortcut() == result)
+ return choices[i];
+ }
+
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.env.common.StatusHandler#report(org.eclipse.env.common.Status)
+ */
+ public void report(IStatus status) throws StatusException
+ {
+ boolean userOk = false;
+
+ 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(IStatus status)
+ {
+ int userResponse =
+ MessageDialog.openMessage(
+ shell_,
+ Messages.TITLE_WARNING,
+ null,
+ status);
+ return (userResponse == StatusDialogConstants.OK_ID);
+ }
+
+ private boolean reportErrorStatus(IStatus status)
+ {
+ MessageDialog.openMessage(
+ shell_,
+ Messages.TITLE_ERROR,
+ null,
+ status);
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.wst.command.internal.provisional.env.core.common.StatusHandler#reportError(org.eclipse.wst.command.internal.provisional.env.core.common.Status)
+ */
+ public void reportError(IStatus status)
+ {
+ reportErrorStatus( status );
+ }
+
+ /**
+ * @see org.eclipse.wst.command.internal.provisional.env.core.common.StatusHandler#reportInfo(org.eclipse.wst.command.internal.provisional.env.core.common.Status)
+ */
+ public void reportInfo(IStatus status)
+ {
+ MessageDialog.openMessage(
+ shell_,
+ Messages.TITLE_INFO,
+ null,
+ status);
+ }
+}
diff --git a/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/eclipse/ui/Messages.java b/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/eclipse/ui/Messages.java
new file mode 100644
index 0000000..09b2188
--- /dev/null
+++ b/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/eclipse/ui/Messages.java
@@ -0,0 +1,25 @@
+/***************************************************************************************************
+ * Copyright (c) 2003, 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.common.frameworks.internal.eclipse.ui;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS
+{
+ private static final String BUNDLE_NAME = "org.eclipse.wst.common.frameworks.internal.eclipse.ui.environment";
+
+ public static String TITLE_WARNING;
+ public static String TITLE_ERROR;
+ public static String TITLE_INFO;
+
+ static
+ {
+ NLS.initializeMessages( BUNDLE_NAME, Messages.class );
+ }
+}
diff --git a/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/eclipse/ui/environment.properties b/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/eclipse/ui/environment.properties
new file mode 100644
index 0000000..4ae4c85
--- /dev/null
+++ b/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/eclipse/ui/environment.properties
@@ -0,0 +1,17 @@
+###############################################################################
+# 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
+###############################################################################
+
+TITLE_WARNING=Warning:
+TITLE_ERROR=Error:
+TITLE_INFO=Info:
+
+
+
diff --git a/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/operation/extensionui/DMWizardPageElement.java b/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/operation/extensionui/DMWizardPageElement.java
index f75c189..1e9c8a1 100644
--- a/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/operation/extensionui/DMWizardPageElement.java
+++ b/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/operation/extensionui/DMWizardPageElement.java
@@ -8,6 +8,8 @@
**************************************************************************************************/
package org.eclipse.wst.common.frameworks.internal.operation.extensionui;
+import java.util.HashSet;
+import java.util.Set;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.jem.util.logger.proxy.Logger;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
@@ -22,7 +24,7 @@
static final String ATT_PAGE_ID = "pageGroupID"; //$NON-NLS-1$
static final String ATT_WIZARD_ID = "wizardID"; //$NON-NLS-1$
static final String ATT_REQUIRES_DATA_OPERATION_ID = "requiresDataOperationId"; //$NON-NLS-1$
- static final String ATT_DATA_MODEL_ID = "dataModelId"; //$NON-NLS-1$
+ static final String ATT_DATA_MODEL_IDS = "dataModelIds"; //$NON-NLS-1$
static final String ATT_ALLOWS_EXTENDED_PAGES_AFTER = "allowsExtendedPagesAfter"; //$NON-NLS-1$
static final String ATT_PAGE_INSERTION_ID = "pageGroupInsertionID"; //$NON-NLS-1$
static final String ELEMENT_FACTORY = "factory"; //$NON-NLS-1$
@@ -34,7 +36,7 @@
protected String wizardFactoryElement;
protected boolean allowsExtendedPagesAfter;
protected String requiresDataOperationId;
- protected String dataModelID;
+ protected Set dataModelIDs;
protected String pageInsertionID;
private int loadOrder;
private static int loadOrderCounter;
@@ -48,7 +50,7 @@
wizardID = element1.getAttribute(ATT_WIZARD_ID);
pageGroupID = element1.getAttribute(ATT_PAGE_ID);
requiresDataOperationId = element1.getAttribute(ATT_REQUIRES_DATA_OPERATION_ID);
- dataModelID = element1.getAttribute(ATT_DATA_MODEL_ID);
+ dataModelIDs = getDataModelIds( element1 );
readAllowsExtendedPageAfter(element1);
pageInsertionID = element1.getAttribute(ATT_PAGE_INSERTION_ID);
readFactory(element1);
@@ -56,6 +58,24 @@
loadOrder = loadOrderCounter++;
}
+ private Set getDataModelIds(IConfigurationElement element )
+ {
+ HashSet ids = new HashSet();
+ String idList = element.getAttribute(ATT_DATA_MODEL_IDS);
+
+ if( idList != null )
+ {
+ String[] dataModelIDs = idList.split( " *");
+
+ for( int index = 0; index < dataModelIDs.length; index++ )
+ {
+ ids.add( dataModelIDs[index] );
+ }
+ }
+
+ return ids;
+ }
+
private void validateSettings() {
if (wizardID == null || wizardPageFactoryElement == null) {
Logger.getLogger().logError("Incomplete page extension specification."); //$NON-NLS-1$
@@ -174,12 +194,12 @@
requiresDataOperationId = dataOperationId;
}
- public String getDataModelID() {
- return dataModelID;
+ public Set getDataModelIDs() {
+ return dataModelIDs;
}
- public void setDataModelID(String newDataModelID) {
- dataModelID = newDataModelID;
+ public void setDataModelID(Set newDataModelIDs) {
+ dataModelIDs = newDataModelIDs;
}
/**
diff --git a/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/ui/DMPageGroupElementImpl.java b/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/ui/DMPageGroupElementImpl.java
index 6dd7202..073470d 100644
--- a/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/ui/DMPageGroupElementImpl.java
+++ b/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/ui/DMPageGroupElementImpl.java
@@ -1,5 +1,6 @@
package org.eclipse.wst.common.frameworks.internal.ui;
+import java.util.Set;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizardPage;
@@ -23,8 +24,8 @@
return pageElement.getRequiresDataOperationId();
}
- public String getDataModelID() {
- return pageElement.getDataModelID();
+ public Set getDataModelIDs() {
+ return pageElement.getDataModelIDs();
}
public IDMPageGroupHandler getPageGroupHandler(IDataModel dataModel) {
diff --git a/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/ui/PageGroupManager.java b/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/ui/PageGroupManager.java
index f492f3d..38051a1 100644
--- a/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/ui/PageGroupManager.java
+++ b/plugins/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/ui/PageGroupManager.java
@@ -10,6 +10,8 @@
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
import java.util.Stack;
import java.util.Vector;
import org.eclipse.core.runtime.IConfigurationElement;
@@ -85,11 +87,19 @@
if (pageGroupStack.empty()) {
PageGroupEntry rootEntry = (PageGroupEntry) groupTable.get(rootPageGroup.getPageGroupID());
- String dataModelID = rootEntry.pageGroup.getDataModelID();
+ Set dataModelIDs = rootEntry.pageGroup.getDataModelIDs();
pageGroupStack.push(new StackEntry(rootEntry, -1));
- if (dataModelID != null)
- dataModelManager.addNestedDataModel(dataModelID);
+ if (dataModelIDs != null && dataModelIDs.size() > 0 )
+ {
+ Iterator ids = dataModelIDs.iterator();
+
+ while( ids.hasNext() )
+ {
+ String dataModelID = (String)ids.next();
+ dataModelManager.addNestedDataModel(dataModelID);
+ }
+ }
}
saveStackInfo();
@@ -128,11 +138,19 @@
operationManager.undoLastRun();
}
- String dataModelID = topEntry.pageGroupEntry.pageGroup.getDataModelID();
+ Set dataModelIDs = topEntry.pageGroupEntry.pageGroup.getDataModelIDs();
- if (dataModelID != null)
- dataModelManager.removeNestedDataModel(dataModelID);
-
+ if( dataModelIDs != null && dataModelIDs.size() > 0 )
+ {
+ Iterator ids = dataModelIDs.iterator();
+
+ while( ids.hasNext() )
+ {
+ String dataModelID = (String)ids.next();
+ dataModelManager.removeNestedDataModel(dataModelID);
+ }
+ }
+
pageGroupStack.pop();
if (!pageGroupStack.empty()) {
@@ -177,12 +195,20 @@
if (pageGroupStack.empty()) {
PageGroupEntry rootEntry = (PageGroupEntry) groupTable.get(rootPageGroup.getPageGroupID());
- String dataModelID = rootEntry.pageGroup.getDataModelID();
+ Set dataModelIDs = rootEntry.pageGroup.getDataModelIDs();
pageGroupStack.push(new StackEntry(rootEntry, -1));
- if (dataModelID != null)
- dataModelManager.addNestedDataModel(dataModelID);
+ if( dataModelIDs != null && dataModelIDs.size() > 0 )
+ {
+ Iterator ids = dataModelIDs.iterator();
+
+ while( ids.hasNext() )
+ {
+ String dataModelID = (String)ids.next();
+ dataModelManager.addNestedDataModel(dataModelID);
+ }
+ }
}
pageFound = findNextPage(false);
@@ -232,7 +258,7 @@
if (nextStackEntry != null) {
IDMPageGroup pageGroup = nextStackEntry.pageGroupEntry.pageGroup;
String requiresOperationsId = pageGroup.getRequiredDataOperationToRun();
- String dataModelID = pageGroup.getDataModelID();
+ Set dataModelIDs = pageGroup.getDataModelIDs();
// If this group requires an operation and it has not already been run
// then we need to run it.
@@ -247,9 +273,17 @@
}
}
- if (dataModelID != null)
- dataModelManager.addNestedDataModel(dataModelID);
-
+ if( dataModelIDs != null && dataModelIDs.size() > 0 )
+ {
+ Iterator ids = dataModelIDs.iterator();
+
+ while( ids.hasNext() )
+ {
+ String dataModelID = (String)ids.next();
+ dataModelManager.addNestedDataModel(dataModelID);
+ }
+ }
+
pageGroupStack.push(nextStackEntry);
pageFound = findNextPage(runOperations);
}
diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/AbstractDataModelOperation.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/AbstractDataModelOperation.java
index 0746994..4f79dbb 100644
--- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/AbstractDataModelOperation.java
+++ b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/AbstractDataModelOperation.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.wst.common.frameworks.datamodel;
+import java.util.HashSet;
+import java.util.Set;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.operations.AbstractOperation;
import org.eclipse.core.resources.IWorkspace;
@@ -98,8 +100,8 @@
return model;
}
- public String getDataModelID() {
- return null;
+ public Set getDataModelIDs() {
+ return new HashSet();
}
public ISchedulingRule getSchedulingRule() {
diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/IDataModelOperation.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/IDataModelOperation.java
index 672879b..480fea2 100644
--- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/IDataModelOperation.java
+++ b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/datamodel/IDataModelOperation.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.wst.common.frameworks.datamodel;
+import java.util.Set;
import org.eclipse.core.commands.operations.IUndoableOperation;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.wst.common.environment.Environment;
@@ -64,7 +65,7 @@
*/
public IDataModel getDataModel();
- public String getDataModelID();
+ public Set getDataModelIDs();
public ISchedulingRule getSchedulingRule();
diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/OperationManager.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/OperationManager.java
index 78e77e9..417baa2 100644
--- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/OperationManager.java
+++ b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/OperationManager.java
@@ -10,6 +10,8 @@
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Set;
import java.util.Stack;
import java.util.Vector;
import org.eclipse.core.commands.ExecutionException;
@@ -20,6 +22,7 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.wst.common.environment.Environment;
import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation;
@@ -40,8 +43,9 @@
private OperationListener preExecuteListener;
private OperationListener postExecuteListener;
private OperationListener undoExecuteListener;
+ private Environment environment;
- public OperationManager(DataModelManager aDataModelManager, IDataModelOperation aRootOperation) {
+ public OperationManager(DataModelManager aDataModelManager, IDataModelOperation aRootOperation, Environment aEnvironment) {
if (aRootOperation == null)
aRootOperation = new NullOperation();
@@ -53,6 +57,7 @@
operationTable = new HashMap();
runStopList = new Stack();
operationTable.put(aRootOperation.getID(), entry);
+ environment = aEnvironment;
addExtendedOperations(aRootOperation);
OperationListener defaultListener = new OperationListener() {
@@ -137,10 +142,18 @@
for (int index = runListEntry.executedOperations.size() - 1; index >= 0; index--) {
IDataModelOperation operation = (IDataModelOperation) runListEntry.executedOperations.elementAt(index);
- String dataModelID = operation.getDataModelID();
+ Set dataModelIDs = operation.getDataModelIDs();
- if (dataModelID != null)
- dataModelManager.removeNestedDataModel(dataModelID);
+ if( dataModelIDs != null && dataModelIDs.size() > 0 )
+ {
+ Iterator ids = dataModelIDs.iterator();
+
+ while( ids.hasNext() )
+ {
+ String dataModelID = (String)ids.next();
+ dataModelManager.removeNestedDataModel(dataModelID);
+ }
+ }
try {
undoExecuteListener.notify(operation);
@@ -194,12 +207,21 @@
continueRun = preExecuteListener.notify(operation);
if (continueRun) {
- String dataModelID = operation.getDataModelID();
+ Set dataModelIDs = operation.getDataModelIDs();
- if (dataModelID != null)
- dataModelManager.addNestedDataModel(dataModelID);
-
+ if (dataModelIDs != null && dataModelIDs.size() > 0 )
+ {
+ Iterator ids = dataModelIDs.iterator();
+
+ while( ids.hasNext() )
+ {
+ String dataModelID = (String)ids.next();
+ dataModelManager.addNestedDataModel(dataModelID);
+ }
+ }
+
operation.setDataModel(dataModel);
+ operation.setEnvironment( environment );
setStatus(runOperation(operation, false));
runListEntry.executedOperations.add(operation);
stackEntry.operationExecuted = true;
diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/datamodel/ExtendableOperationImpl.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/datamodel/ExtendableOperationImpl.java
index dd97aed..15df44a 100644
--- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/datamodel/ExtendableOperationImpl.java
+++ b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/datamodel/ExtendableOperationImpl.java
@@ -11,9 +11,10 @@
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashSet;
import java.util.Hashtable;
import java.util.List;
-
+import java.util.Set;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.operations.IUndoContext;
import org.eclipse.core.resources.IProject;
@@ -77,8 +78,8 @@
return null;
}
- public String getDataModelID() {
- return null;
+ public Set getDataModelIDs() {
+ return new HashSet();
}
/**