diff options
Diffstat (limited to 'bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst')
45 files changed, 0 insertions, 4681 deletions
diff --git a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/EnvironmentUI.properties b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/EnvironmentUI.properties deleted file mode 100644 index 7b5414cbe..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/EnvironmentUI.properties +++ /dev/null @@ -1,27 +0,0 @@ -############################################################################### -# 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 -############################################################################### - -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. - -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_ERROR_WIZARD_ID_NOT_FOUND=IWAB0013E Could not find wizard id: {0} diff --git a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/EnvironmentUIMessages.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/EnvironmentUIMessages.java deleted file mode 100644 index c7ce6df03..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/EnvironmentUIMessages.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * 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; - -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 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; - - static { - NLS.initializeMessages(BUNDLE_NAME, EnvironmentUIMessages.class); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/AntFileImportWizard.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/AntFileImportWizard.java deleted file mode 100644 index 274290f5c..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/AntFileImportWizard.java +++ /dev/null @@ -1,245 +0,0 @@ -package org.eclipse.wst.command.internal.env.ui.dialog; - - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IResource; -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.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.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.eclipse.wst.common.environment.IEnvironment; - -public class AntFileImportWizard extends Wizard implements INewWizard { - - //private IConfigurationElement fConfigElement; - private AntFileImportWizardPage mainPage; - /** - * The workbench. - */ - private IWorkbench workbench; - - /** - * 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() { - IPath destination = mainPage.getPath(); - if (destination == null) - { - return false; - } - else - { - //jvh: TODO: add extension so extenders of the command framework can register properties files to import - // here we pick up all registered Ant files and import - also would be nice to allow user to choose a subset - String[] sourceFiles = new String[]{"ant/wsgen.xml", "ant/axisclient.properties", "ant/axisservice.properties"}; //$NON-NLS$ - for (int i = 0; i < sourceFiles.length; i++) { - String fileSource = sourceFiles[i]; - String targetFile = fileSource; - //strip any leading segments off of targetFile - int fileStart = targetFile.lastIndexOf("/"); - if (fileStart >= 0) - { - targetFile = targetFile.substring(fileStart); - } - Plugin sourcePlugin = EnvPlugin.getInstance(); - //jvh: TODO - add real progress monitor in here... - copyIFile(sourcePlugin, fileSource, destination, targetFile, (IProgressMonitor)new NullProgressMonitor()); - } - } - return true; - } - - private IStatus copyIFile(Plugin plugin, String 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(); - context.setOverwriteFilesEnabled(true); - context.setCreateFoldersEnabled(true); - context.setCheckoutFilesEnabled(true); - IResource resource = FileResourceUtils.findResource(target); - if(resource != null) return Status.OK_STATUS; - FileResourceUtils.createFile(context, - target, - plugin.openStream(new Path(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.gif");//$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/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/AntFileImportWizardPage.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/AntFileImportWizardPage.java deleted file mode 100644 index da9442236..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/AntFileImportWizardPage.java +++ /dev/null @@ -1,45 +0,0 @@ -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.widgets.Composite; -import org.eclipse.ui.dialogs.WizardResourceImportPage; -import org.eclipse.wst.command.internal.env.ui.EnvironmentUIMessages; - -public class AntFileImportWizardPage extends WizardResourceImportPage{ - - public AntFileImportWizardPage(String pageName, - IStructuredSelection selection) { - super("WSAntFilesPage1", selection);//$NON-NLS-1$ - setTitle(pageName); - setDescription(EnvironmentUIMessages.WIZARD_PAGE_DESC_ANT); - } - - protected ITreeContentProvider getFileProvider() { - return null; - } - - public IPath getPath() - { - return getContainerFullPath(); - } - - protected void createSourceGroup(Composite parent) { - //don't need source group - } - - protected ITreeContentProvider getFolderProvider() { - return null; - } - - protected void createOptionsGroup(Composite parent) { - //empty - don't want an options group - } - - - -} - - - diff --git a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/ErrorDialog.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/ErrorDialog.java deleted file mode 100644 index 16cc76ad6..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/ErrorDialog.java +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************* - * 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; - -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/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/InfoDialog.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/InfoDialog.java deleted file mode 100644 index fa6c84f0a..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/InfoDialog.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * 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; - -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/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/MessageDialog.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/MessageDialog.java deleted file mode 100644 index f75cc47a2..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/MessageDialog.java +++ /dev/null @@ -1,580 +0,0 @@ -/******************************************************************************* - * 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; - -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_BOTH ) ); - composite.setLayoutData( new GridData( GridData.FILL_BOTH )); - - // 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 = 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 > 400 ? 400 : newHeight; - - getShell().setSize( new Point(windowSize.x, newHeight) ); - } -} diff --git a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/OptionsDialog.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/OptionsDialog.java deleted file mode 100644 index 24ceea306..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/OptionsDialog.java +++ /dev/null @@ -1,107 +0,0 @@ -/******************************************************************************* - * 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; - -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/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/StatusDialogConstants.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/StatusDialogConstants.java deleted file mode 100644 index 4e56788ec..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/StatusDialogConstants.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * 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/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/WarningDialog.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/WarningDialog.java deleted file mode 100644 index 9d28e3d2a..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/dialog/WarningDialog.java +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************* - * 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; - -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/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/eclipse/EclipseStatusHandler.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/eclipse/EclipseStatusHandler.java deleted file mode 100644 index 1c133103c..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/eclipse/EclipseStatusHandler.java +++ /dev/null @@ -1,202 +0,0 @@ -/******************************************************************************* - * 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.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.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.IStatusHandler; -import org.eclipse.wst.common.environment.StatusException; - - -/** - * This is the Eclipse UI version of the IStatusHandler - */ -public class EclipseStatusHandler implements IStatusHandler -{ - private IStatus worstStatus = Status.OK_STATUS; - private Shell shell = null; - - public EclipseStatusHandler() - { - } - - public EclipseStatusHandler( Shell theShell ) - { - shell = theShell; - } - - public IStatus getStatus() - { - return worstStatus; - } - - public void resetStatus() - { - worstStatus = Status.OK_STATUS; - } - - /** - * @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) - { - Runnable runnable = new Runnable() - { - public void run() - { - MessageDialog.openMessage( getShell(), - EnvironmentCoreMessages.TITLE_ERROR, - null, - status); - } - }; - - Display.getDefault().syncExec( runnable ); - - return false; - } - - private void checkStatus( IStatus status ) - { - if( status.getSeverity() > worstStatus.getSeverity() ) - { - worstStatus = status; - } - } - - /** - * @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/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/eclipse/EnvironmentUtils.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/eclipse/EnvironmentUtils.java deleted file mode 100644 index 60ea6d2a2..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/eclipse/EnvironmentUtils.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * 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.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/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/eclipse/SWTEnvironmentManager.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/eclipse/SWTEnvironmentManager.java deleted file mode 100644 index 99132bcc5..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/eclipse/SWTEnvironmentManager.java +++ /dev/null @@ -1,28 +0,0 @@ -/*************************************************************************************************** - * 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/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/plugin/EnvUIPlugin.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/plugin/EnvUIPlugin.java deleted file mode 100644 index 4c15d6091..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/plugin/EnvUIPlugin.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * 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/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/preferences/ActionDialogsPreferencePage.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/preferences/ActionDialogsPreferencePage.java deleted file mode 100644 index ed422d3a0..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/preferences/ActionDialogsPreferencePage.java +++ /dev/null @@ -1,242 +0,0 @@ -/******************************************************************************* - * 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.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> - * <extension - * point="org.eclipse.ui.preferencePages"> - * <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"> - * </page> - * * </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 (int i=0; e.hasMoreElements(); i++) - { - Button dialog = (Button) e.nextElement(); - dialog.setSelection( false ); - } - } - - private void handleHideAllEvent () - { - Enumeration e = checkBoxes_.elements(); - for (int i=0; e.hasMoreElements(); i++) - { - 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() - { - Enumeration e = checkBoxes_.elements(); - for (int i=0; e.hasMoreElements(); i++) - { - Button dialog = (Button) e.nextElement(); - dialog.setSelection(true); - } - } - - /** - * Initializes states of the controls from the preferences. - */ - private void initializeValues() - { - PersistentActionDialogsContext context = PersistentActionDialogsContext.getInstance(); - Enumeration e = checkBoxes_.keys(); - for (int i=0; e.hasMoreElements(); i++) - { - 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 (int i=0; e.hasMoreElements(); i++) - { - String id = (String) e.nextElement(); - context.setActionDialogEnabled(id, ((Button)checkBoxes_.get(id)).getSelection()); - } - } -} - diff --git a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/registry/WidgetRegistry.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/registry/WidgetRegistry.java deleted file mode 100644 index 5ab5b3104..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/registry/WidgetRegistry.java +++ /dev/null @@ -1,110 +0,0 @@ -/******************************************************************************* - * 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/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/CanFinishRegistry.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/CanFinishRegistry.java deleted file mode 100644 index bfe0a0e07..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/CanFinishRegistry.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * 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.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/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/CommandWidgetBinding.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/CommandWidgetBinding.java deleted file mode 100644 index afd591ba5..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/CommandWidgetBinding.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * 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.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/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/CommandWidgetBindingList.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/CommandWidgetBindingList.java deleted file mode 100644 index 7b8784584..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/CommandWidgetBindingList.java +++ /dev/null @@ -1,128 +0,0 @@ -/******************************************************************************* - * 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.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/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/CurrentPageCommand.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/CurrentPageCommand.java deleted file mode 100644 index 6509401e0..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/CurrentPageCommand.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * 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.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/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/DataObjectCommand.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/DataObjectCommand.java deleted file mode 100644 index 0450ad308..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/DataObjectCommand.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * 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/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/DynamicWizard.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/DynamicWizard.java deleted file mode 100644 index 5b94b66e5..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/DynamicWizard.java +++ /dev/null @@ -1,392 +0,0 @@ -/******************************************************************************* - * 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.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.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> - * <extension - * point="org.eclipse.ui.newWizards"> - * <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"> - * <description> - * %PLUGIN_NEW_WIZARD_DESC_WS_CLIENT - * </description> - * <selection - * class="org.eclipse.core.resources.IResource"> - * </selection> - * </wizard> - * </extension> - * - * </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> - * <extension - * point="org.eclipse.wst.command.env.dynamicWizard"> - * <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"> - * </dynamicWizard> - * </extension> - * </pre> - * - */ -public class DynamicWizard extends Wizard implements INewWizard, IExecutableExtension -{ - private String iconBannerName_; - private Bundle bundle_; - private SimpleCanFinishRegistry canFinishRegistry_; - private WizardPageManager pageManager_; - private String wizardTitle_; - private DataObjectCommand dataObjectCommand_ = null; - - protected IWizardPage startPage_ = null; - 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" ); - - 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 - */ - 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 - { - IExtensionRegistry registry = Platform.getExtensionRegistry(); - IExtensionPoint point = registry.getExtensionPoint("org.eclipse.wst.command.env.dynamicWizard"); - 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") ) - { - String id = elements[0].getAttribute( "id" ); - - if( id != null && id.equals( wizardId ) ) - { - wizardElement_ = elements[0]; - break; - } - } - } - - if( wizardElement_ == null ) - { - Status status = new Status( Status.ERROR, "id", 0, NLS.bind(EnvironmentUIMessages.MSG_ERROR_WIZARD_ID_NOT_FOUND, new String[]{ wizardId}) , null ); - throw new CoreException( status ); - } - } - - /** - * This method is called by the eclipse framework to initialize the - * wizard. - * - * @param workbench the eclipse workbench - * @param selection the initial selection that the user has made within - * eclipse. - */ - public void init ( IWorkbench workbench, IStructuredSelection selection ) - { - PersistentResourceContext context = PersistentResourceContext.getInstance(); - 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 - { - commandWidgetBinding_ = (CommandWidgetBinding)wizardElement_.createExecutableExtension( "class" ); - bundle_ = Platform.getBundle( wizardElement_.getNamespace() ); - iconBannerName_ = wizardElement_.getAttribute( "iconbanner" ); - wizardTitle_ = wizardElement_.getAttribute( "title" ); - } - catch( CoreException exc ) - { - exc.printStackTrace(); - } - - dataObjectCommand_ = new DataObjectCommand(); - startPage_ = null; - 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("/"); - 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() - { - if( startPage_ == null ) - { - startPage_ = pageManager_.getNextPage(); - } - - return startPage_; - } - - /** - * 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 ), "" ) ); - root.add( new SimpleFragment( new CurrentPageCommand( pageManager ), "" ) ); - root.add( commandWidgetBinding_.create().create() ); - root.add( new SimpleFragment( dataObjectCommand_, "" )); - - 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; - dataObjectCommand_ = null; - startPage_ = null; - commandWidgetBinding_ = null; - WidgetRegistry.initialize(); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/INamedWidgetContributor.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/INamedWidgetContributor.java deleted file mode 100644 index a5baf32b4..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/INamedWidgetContributor.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * 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/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/INamedWidgetContributorFactory.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/INamedWidgetContributorFactory.java deleted file mode 100644 index f14ff0380..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/INamedWidgetContributorFactory.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * 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/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/PageInfo.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/PageInfo.java deleted file mode 100644 index cbad7b240..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/PageInfo.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * 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.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/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/PageWizardDataEvents.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/PageWizardDataEvents.java deleted file mode 100644 index b4c858922..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/PageWizardDataEvents.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * 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.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/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SelectionCommand.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SelectionCommand.java deleted file mode 100644 index 1abb1e68a..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SelectionCommand.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * 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.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/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleCanFinishRegistry.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleCanFinishRegistry.java deleted file mode 100644 index 43d193ff0..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleCanFinishRegistry.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * 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.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/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleCommandEngineManager.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleCommandEngineManager.java deleted file mode 100644 index a92bb296f..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleCommandEngineManager.java +++ /dev/null @@ -1,275 +0,0 @@ -/******************************************************************************* - * 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.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.EclipseEnvironment; -import org.eclipse.wst.command.internal.env.ui.eclipse.EclipseStatusHandler; -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_; - private 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; - EclipseStatusHandler statusHandler = (EclipseStatusHandler)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; - } - - /** - * 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"); - - EclipseStatusHandler statusHandler = (EclipseStatusHandler)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"); - - EclipseStatusHandler statusHandler = (EclipseStatusHandler)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/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimplePageFactory.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimplePageFactory.java deleted file mode 100644 index 4c02e6be5..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimplePageFactory.java +++ /dev/null @@ -1,20 +0,0 @@ -/******************************************************************************* - * 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.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/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimplePopupPageFactory.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimplePopupPageFactory.java deleted file mode 100644 index ada9688e7..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimplePopupPageFactory.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * 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.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/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimplePopupWizardPage.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimplePopupWizardPage.java deleted file mode 100644 index d79c2ac82..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimplePopupWizardPage.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * 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.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.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -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; - } - - public void createControl( Composite parent ) - { - Composite composite = new Composite( parent, SWT.NONE ); - final PersistentActionDialogsContext context = PersistentActionDialogsContext.getInstance(); - - GridLayout gridlayout = new GridLayout(); - gridlayout.marginHeight = 0; - gridlayout.marginWidth = 0; - - composite.setLayout( gridlayout ); - GridData griddata = new GridData(GridData.FILL_BOTH ); - composite.setLayoutData( griddata ); - - super.createControl( composite ); - - // 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.setActionDialogEnabled( id_, button.getSelection() ); - } - }); - button.setSelection( false ); - - PlatformUI.getWorkbench().getHelpSystem().setHelp( button, infopop ); - } - - setControl( composite ); - } -} diff --git a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleWidgetContributor.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleWidgetContributor.java deleted file mode 100644 index 652acb165..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleWidgetContributor.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * 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.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/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleWidgetDataContributor.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleWidgetDataContributor.java deleted file mode 100644 index 5484c9ef0..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleWidgetDataContributor.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * 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.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/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleWidgetRegistry.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleWidgetRegistry.java deleted file mode 100644 index 0489bca3f..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleWidgetRegistry.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * 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.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/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleWizardPage.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleWizardPage.java deleted file mode 100644 index 4d2bb595f..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/SimpleWizardPage.java +++ /dev/null @@ -1,136 +0,0 @@ -/******************************************************************************* - * 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.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.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 ) - { - Composite control = new Composite( parent, SWT.NONE ); - control.setLayout( new GridLayout() ); - control.setLayoutData( new GridData( GridData.FILL_BOTH )); - - dataEvents_ = widget_.addControls( control, statusListener_ ); - - org.eclipse.jface.dialogs.Dialog.applyDialogFont(control); - setControl( 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/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetBindingToWidgetFactoryAdapter.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetBindingToWidgetFactoryAdapter.java deleted file mode 100644 index 152f7c8c8..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetBindingToWidgetFactoryAdapter.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * 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/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetContributor.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetContributor.java deleted file mode 100644 index b6db62601..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetContributor.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * 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.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/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetContributorFactory.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetContributorFactory.java deleted file mode 100644 index 65b5d0aa3..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetContributorFactory.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * 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.command.internal.env.ui.widgets; - -/** - * This interface provide a way for creating WidgetContributors - * - * - */ -public interface WidgetContributorFactory -{ - public WidgetContributor create(); -} diff --git a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetDataContributor.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetDataContributor.java deleted file mode 100644 index e9aa31db7..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetDataContributor.java +++ /dev/null @@ -1,20 +0,0 @@ -/******************************************************************************* - * 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.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/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetDataEvents.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetDataEvents.java deleted file mode 100644 index 4cb03f0fc..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetDataEvents.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * 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.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/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetRegistry.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetRegistry.java deleted file mode 100644 index c01107c0f..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WidgetRegistry.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * 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.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/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WizardPageFactory.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WizardPageFactory.java deleted file mode 100644 index c520979b2..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WizardPageFactory.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * 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.command.internal.env.ui.widgets; - - -/** - * - * - * - * - */ -public interface WizardPageFactory -{ - public PageWizardDataEvents getPage( PageInfo pageInfo, WizardPageManager manager ); -} diff --git a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WizardPageManager.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WizardPageManager.java deleted file mode 100644 index 37a8fe03e..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/WizardPageManager.java +++ /dev/null @@ -1,480 +0,0 @@ -/******************************************************************************* - * 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.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; - - - -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 IStatus runForwardToNextStop() - { - firstFragment_ = true; - nextPage_ = null; - - IWizardContainer container = wizard_.getContainer(); - - if( container == null || container.getCurrentPage() == null ) - { - container = null; - } - - return super.runForwardToNextStop( container ); - } - - public IWizardPage getCurrentPage() - { - return currentPage_; - } - - public boolean hasNextPage() - { - - nextPeekPage_ = null; - - try - { - nextPeekPage_ = getNextPageInGroup( widgetFactory_, 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(); - - nextPage_ = getNextPageInGroup( widgetFactory_, 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(); - } - - 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_ ); - - if( firstPage_ == null ) firstPage_ = page; - - 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_; - - // 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; - } - else - { - currentPage_ = nextPage_; - } - } - 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 = engine_.undoToLastStop(); - page = getPage( lastUndoFragment_ ); - } - while( page != startPage && !done ); - - currentPage_ = page; - } - - return doneOk; - } - - public boolean performCancel() - { - while( !engine_.undoToLastStop() ){} - - 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, 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_, 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, 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 = engine_.undoToLastStop(); - - 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 ) - { - StackEntry entry = (StackEntry)widgetStackStack_.peek(); - - 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_; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/popup/DynamicPopupWizard.java b/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/popup/DynamicPopupWizard.java deleted file mode 100644 index 4738f8b96..000000000 --- a/bundles/org.eclipse.wst.command.env.ui/src/org/eclipse/wst/command/internal/env/ui/widgets/popup/DynamicPopupWizard.java +++ /dev/null @@ -1,223 +0,0 @@ -/******************************************************************************* - * 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.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> - * <extension - * point="org.eclipse.ui.popupMenus"> - *<!-- IFile *.wsdl popup menu --> - * <objectContribution - * objectClass="org.eclipse.core.resources.IFile" - * nameFilter="*.wsdl" - * id="org.eclipse.jst.ws.consumption.ui.wizard.client.clientwizard"> - *<!-- WSDL To Java Bean Proxy --> - * <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"> - * </action> - * </objectContribution> - * </extension> - * - * <extension - * point="org.eclipse.wst.command.env.dynamicWizard"> - * <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"> - * </dynamicWizard> - * </extension> - *</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.setPageSize( 400, 500 ); - dialog.create(); - - if( startPage_ != 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; - } -} |