diff options
Diffstat (limited to 'plugins/org.eclipse.wst.server.ui/serverui/org/eclipse')
210 files changed, 0 insertions, 32376 deletions
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/FacetRuntimeComponentLabelProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/FacetRuntimeComponentLabelProvider.java deleted file mode 100644 index 08dff1fb8..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/FacetRuntimeComponentLabelProvider.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui; - -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.wst.common.project.facet.core.runtime.IRuntimeComponent; -import org.eclipse.wst.common.project.facet.ui.IRuntimeComponentLabelProvider; -/** - * A facet runtime label provider that can be used as an implementation of - * org.eclipse.wst.common.project.facet.ui.IRuntimeComponentLabelProvider in the - * org.eclipse.wst.common.project.facet.core.runtimes extension point. - */ -public class FacetRuntimeComponentLabelProvider implements IAdapterFactory { - private static final Class[] ADAPTER_TYPES = { IRuntimeComponentLabelProvider.class }; - - public final class RuntimeLabelProvider implements IRuntimeComponentLabelProvider { - private final IRuntimeComponent rc; - - public RuntimeLabelProvider(IRuntimeComponent rc) { - this.rc = rc; - } - - public String getLabel() { - return rc.getProperty("type"); - } - } - - public Object getAdapter(Object adaptable, Class adapterType) { - IRuntimeComponent rc = (IRuntimeComponent) adaptable; - return new RuntimeLabelProvider(rc); - } - - public Class[] getAdapterList() { - return ADAPTER_TYPES; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/IServerModule.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/IServerModule.java deleted file mode 100644 index 5f04206d4..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/IServerModule.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui; - -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IServer; -/** - * A helper interface for modules that are deployed to a server, commonly - * used to help actions interact with modules in the Servers view. - * - * @since 1.1 - */ -public interface IServerModule { - /** - * Return the server that the module belongs to. - * - * @return the server - */ - public IServer getServer(); - - /** - * Returns the module. - * - * @return the module - */ - public IModule[] getModule(); -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ServerLaunchConfigurationTab.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ServerLaunchConfigurationTab.java deleted file mode 100644 index b995481e3..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ServerLaunchConfigurationTab.java +++ /dev/null @@ -1,308 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; -import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.ui.PlatformUI; - -import org.eclipse.wst.server.core.*; -import org.eclipse.wst.server.core.internal.Server; -import org.eclipse.wst.server.ui.internal.*; -/** - * Server launch configuration tab. - * - * @since 1.0 - */ -public class ServerLaunchConfigurationTab extends AbstractLaunchConfigurationTab { - // flag to be used to decide whether to enable combo in launch config dialog - // after the user requests a launch, they cannot change it - private static final String READ_ONLY = "read-only"; - - private String[] serverTypeIds; - - private Combo serverCombo; - - private Label runtimeLabel; - private Label hostname; - - private IServer server; - - // list of servers that are in combo - private List<IServer> servers; - - private ILaunchConfigurationWorkingCopy wc; - - /** - * Create a new server launch configuration tab. - */ - public ServerLaunchConfigurationTab() { - this(new String[] {"*"}); - } - - /** - * Create a new server launch configuration tab with the given server type ids. - * - * @param serverTypeIds an array of server type ids - */ - public ServerLaunchConfigurationTab(String[] serverTypeIds) { - this.serverTypeIds = serverTypeIds; - } - - /** - * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(Composite) - */ - public void createControl(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.marginWidth = 5; - layout.marginHeight = 5; - layout.numColumns = 2; - composite.setLayout(layout); - - //GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - //data.widthHint = 200; - //composite.setLayoutData(data); - - Label label = new Label(composite, SWT.WRAP); - label.setText(Messages.serverLaunchDescription); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - data.horizontalSpan = 2; - data.grabExcessHorizontalSpace = false; - data.widthHint = 300; - label.setLayoutData(data); - - label = new Label(composite, SWT.NONE); - label.setText(Messages.serverLaunchServer); - serverCombo = new Combo(composite, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY); - serverCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - serverCombo.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) { - widgetSelected(e); - } - public void widgetSelected(SelectionEvent e) { - handleServerSelection(); - } - }); - PlatformUI.getWorkbench().getHelpSystem().setHelp(serverCombo, ContextIds.LAUNCH_CONFIGURATION_SERVER_COMBO); - - label = new Label(composite, SWT.NONE); - label.setText(Messages.serverLaunchRuntime); - runtimeLabel = new Label(composite, SWT.NONE); - runtimeLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - label = new Label(composite, SWT.NONE); - label.setText(Messages.serverLaunchHost); - hostname = new Label(composite, SWT.NONE); - hostname.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - // initialize - IServer[] servers2 = ServerCore.getServers(); - servers = new ArrayList<IServer>(); - if (servers2 != null) { - int size = servers2.length; - for (int i = 0; i < size; i++) { - IServer server2 = servers2[i]; - if (server2.getServerType() != null && isSupportedServer(server2.getServerType().getId())) { - serverCombo.add(server2.getName()); - servers.add(server2); - } - } - } - - // select first item in list - if (serverCombo.getItemCount() > 0) - serverCombo.select(0); - - handleServerSelection(); - - serverCombo.forceFocus(); - - Dialog.applyDialogFont(composite); - setControl(composite); - } - - private boolean isSupportedServer(String serverTypeId) { - if (serverTypeIds == null) - return true; - int size = serverTypeIds.length; - for (int i = 0; i < size; i++) { - if (matches(serverTypeId, serverTypeIds[i])) - return true; - } - return false; - } - - private static boolean matches(String a, String b) { - if (a == null || b == null || "*".equals(a) || "*".equals(b) || a.startsWith(b) || b.startsWith(a)) - return true; - return false; - } - - /** - * Called when a server is selected. - * This method should not be called directly. - */ - protected void handleServerSelection() { - if (servers.isEmpty()) - server = null; - else - server = servers.get(serverCombo.getSelectionIndex()); - IRuntime runtime = null; - if (server != null) { - runtime = server.getRuntime(); - hostname.setText(server.getHost()); - } else - hostname.setText(""); - - // check if "runtime" property is true or false - if (runtime != null && server != null && server.getServerType() != null && server.getServerType().hasRuntime()) - runtimeLabel.setText(runtime.getName()); - else - runtimeLabel.setText(""); - - try { - if (wc != null) - ((Server)server).setupLaunchConfiguration(wc, new NullProgressMonitor()); - } catch (Exception e) { - // ignore - } - - if (server == null) - setErrorMessage(Messages.errorNoServerSelected); - else if (server.getServerState() != IServer.STATE_STOPPED) - setErrorMessage(Messages.errorServerAlreadyRunning); - else - setErrorMessage(null); - - updateLaunchConfigurationDialog(); - } - - /** - * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(ILaunchConfigurationWorkingCopy) - */ - public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { - setErrorMessage(null); - if (serverCombo != null) { - serverCombo.setEnabled(true); - if (serverCombo.getItemCount() > 0) - serverCombo.select(0); - } - - if (servers != null) { - server = servers.get(serverCombo.getSelectionIndex()); - if (server != null) - ((Server) server).setupLaunchConfiguration(configuration, null); - } - wc = configuration; - } - - /** - * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(ILaunchConfiguration) - */ - public void initializeFrom(ILaunchConfiguration configuration) { - serverCombo.setEnabled(true); - // remove error message that other instances may have set - setErrorMessage(null); - - try { - // bug 137822 - set the ILaunchConfigurationWorkingCopy wc variable before calling the method handleServerSelection() - //if (configuration instanceof ILaunchConfigurationWorkingCopy) - // wc = (ILaunchConfigurationWorkingCopy)configuration; - - String serverId = configuration.getAttribute(Server.ATTR_SERVER_ID, ""); - if (serverId != null && !serverId.equals("")) { - server = ServerCore.findServer(serverId); - - if (server == null) { // server no longer exists - setErrorMessage(Messages.errorInvalidServer); - //serverCombo.clearSelection(); // appears to be broken...doesn't work with read only? - serverCombo.setEnabled(false); - return; - } - - serverCombo.setText(server.getName()); - if (server.getServerState() != IServer.STATE_STOPPED) - setErrorMessage(Messages.errorServerAlreadyRunning); - } else { - if (serverCombo.getItemCount() > 0) - serverCombo.select(0); - } - handleServerSelection(); - - // flag should only be set if launch has been attempted on the config - if (configuration.getAttribute(READ_ONLY, false)) - serverCombo.setEnabled(false); - } catch (CoreException e) { - // ignore - } - } - - /** - * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(ILaunchConfigurationWorkingCopy) - */ - public void performApply(ILaunchConfigurationWorkingCopy configuration) { - if (server != null) - configuration.setAttribute(Server.ATTR_SERVER_ID, server.getId()); - else - configuration.setAttribute(Server.ATTR_SERVER_ID, (String)null); - wc = configuration; - } - - /** - * @see org.eclipse.debug.ui.ILaunchConfigurationTab#isValid(ILaunchConfiguration) - */ - public boolean isValid(ILaunchConfiguration launchConfig) { - try { - String id = launchConfig.getAttribute(Server.ATTR_SERVER_ID, ""); - if (id != null && !id.equals("")) { - IServer server2 = ServerCore.findServer(id); - if (server2 == null) - return false; - if (server2.getServerState() == IServer.STATE_STOPPED) - return true; - } - } catch (CoreException e) { - // ignore - } - return false; - } - - /** - * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getImage() - */ - public Image getImage() { - return ImageResource.getImage(ImageResource.IMG_SERVER); - } - - /** - * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName() - */ - public String getName() { - return Messages.serverLaunchConfigurationTab; - } -} diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ServerUICore.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ServerUICore.java deleted file mode 100644 index 62093192e..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ServerUICore.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui; - -import org.eclipse.jface.viewers.ILabelProvider; - -import org.eclipse.wst.server.ui.internal.ServerLabelProvider; -/** - * Server UI core. - * <p> - * This class provides all its functionality through static members. - * It is not intended to be subclassed or instantiated. - * </p> - * @since 1.0 - */ -public final class ServerUICore { - /** - * Cannot instantiate ServerUICore - use static methods. - */ - private ServerUICore() { - // can't create - } - - /** - * Returns a label provider that can be used for all server - * objects in the UI. - * - * @return a label provider - */ - public static ILabelProvider getLabelProvider() { - return new ServerLabelProvider(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ServerUIUtil.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ServerUIUtil.java deleted file mode 100644 index 064a0fb1f..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ServerUIUtil.java +++ /dev/null @@ -1,76 +0,0 @@ -/********************************************************************** - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - **********************************************************************/ -package org.eclipse.wst.server.ui; - -import org.eclipse.wst.server.ui.internal.ServerUIPlugin; - -import org.eclipse.swt.widgets.Shell; -/** - * Server UI utility methods. - * <p> - * This class provides all its functionality through static members. - * It is not intended to be subclassed or instantiated. - * </p> - * @since 1.0 - */ -public final class ServerUIUtil { - /** - * Cannot instantiate ServerUIUtil - use static methods. - */ - private ServerUIUtil() { - // can't create - } - - /** - * Open the new runtime wizard. The given typeId and versionId are used to filter - * the set of runtimes displayed. - * - * @param shell a shell to use when creating the wizard - * @param typeId a module type id, or null for any module type - * @param versionId a module version, or null for any version - * @return <code>true</code> if a runtime was created, or - * <code>false</code> otherwise - */ - public static boolean showNewRuntimeWizard(Shell shell, String typeId, String versionId) { - return ServerUIPlugin.showNewRuntimeWizard(shell, typeId, versionId, null); - } - - /** - * Open the new runtime wizard. The given typeId, versionId, and runtimeTypeId are - * used to filter the set of runtimes displayed. - * - * @param shell a shell to use when creating the wizard - * @param typeId a module type id, or null for any module type - * @param versionId a module version, or null for any version - * @param runtimeTypeId a server runtime type, or null for any type - * @return <code>true</code> if a runtime was created, or - * <code>false</code> otherwise - * @since 2.0 - */ - public static boolean showNewRuntimeWizard(Shell shell, String typeId, String versionId, String runtimeTypeId) { - return ServerUIPlugin.showNewRuntimeWizard(shell, typeId, versionId, runtimeTypeId); - } - - /** - * Open the new server wizard. - * - * @param shell a shell to use when creating the wizard - * @param typeId a module type id, or null for any module type - * @param versionId a module version, or null for any version - * @param serverTypeId a server runtime type, or null for any type - * @return <code>true</code> if a server was created, or - * <code>false</code> otherwise - * @since 2.0 - */ - public static boolean showNewServerWizard(Shell shell, String typeId, String versionId, String serverTypeId) { - return ServerUIPlugin.showNewServerWizard(shell, typeId, versionId, serverTypeId); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/actions/RunOnServerAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/actions/RunOnServerAction.java deleted file mode 100644 index 5633299b6..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/actions/RunOnServerAction.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.actions; - -import org.eclipse.debug.core.ILaunchManager; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.wst.server.ui.internal.ImageResource; -import org.eclipse.wst.server.ui.internal.Messages; -import org.eclipse.wst.server.ui.internal.actions.RunOnServerActionDelegate; -/** - * "Run on Server" menu action. Allows the user to select an - * object, and have automatic server creation, launching, and - * the appropriate client to appear. A new instance of this - * action must be created for each object that the user selects. - * <p> - * This class may be instantiated; it is not intended to be subclassed. - * </p> - * - * @since 2.0 - */ -public class RunOnServerAction extends Action { - protected RunOnServerActionDelegate delegate; - - /** - * Create a new Run on Server action for run mode. - * - * @param object the object to attempt to run - */ - public RunOnServerAction(Object object) { - this(object, ILaunchManager.RUN_MODE); - } - - /** - * Create a new Run on Server action. - * - * @param object the object to attempt to run - * @param launchMode a {@link ILaunchManager} launch mode - */ - public RunOnServerAction(Object object, String launchMode) { - super(); - - if (ILaunchManager.DEBUG_MODE.equals(launchMode)) { - setText(Messages.actionDebugOnServer); - setDisabledImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_DTOOL_DEBUG_ON_SERVER)); - setHoverImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_CTOOL_DEBUG_ON_SERVER)); - setImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_ETOOL_DEBUG_ON_SERVER)); - } else if (ILaunchManager.PROFILE_MODE.equals(launchMode)) { - setText(Messages.actionProfileOnServer); - setDisabledImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_DTOOL_PROFILE_ON_SERVER)); - setHoverImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_CTOOL_PROFILE_ON_SERVER)); - setImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_ETOOL_PROFILE_ON_SERVER)); - } else { - setText(Messages.actionRunOnServer); - setDisabledImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_DTOOL_RUN_ON_SERVER)); - setHoverImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_CTOOL_RUN_ON_SERVER)); - setImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_ETOOL_RUN_ON_SERVER)); - } - - delegate = new RunOnServerActionDelegate(); - delegate.setLaunchMode(launchMode); - if (object != null) { - StructuredSelection sel = new StructuredSelection(object); - delegate.selectionChanged(this, sel); - } else - delegate.selectionChanged(this, null); - } - - /* (non-Javadoc) - * Method declared on IAction. - */ - public void run() { - delegate.run(this); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/IServerEditorPartInput.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/IServerEditorPartInput.java deleted file mode 100644 index 114c9d75a..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/IServerEditorPartInput.java +++ /dev/null @@ -1,36 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.editor; - -import org.eclipse.ui.IEditorInput; - -import org.eclipse.wst.server.core.IServerWorkingCopy; -/** - * An input into a server part or section editor. - * - * @since 1.0 - */ -public interface IServerEditorPartInput extends IEditorInput { - /** - * Returns the server to be edited. - * - * @return a working copy of the server - */ - public IServerWorkingCopy getServer(); - - /** - * Returns true if the server is read-only. - * - * @return boolean <code>true</code> if the server is read-only, - * and <code>false</code> otherwise - */ - public boolean isServerReadOnly(); -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorPart.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorPart.java deleted file mode 100644 index bb8fa6185..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorPart.java +++ /dev/null @@ -1,347 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.editor; - -import java.util.*; - -import org.eclipse.core.commands.operations.IUndoableOperation; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorSite; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.part.EditorPart; -import org.eclipse.wst.server.core.IServerWorkingCopy; -import org.eclipse.wst.server.ui.internal.editor.*; -/** - * An abstract server editor which implements the most common methods - * from IEditorPart. - * - * This class also provides each editor page with an error message which - * will be displayed on the status bar of the editor. - * - * @since 1.0 - */ -public abstract class ServerEditorPart extends EditorPart { - /** - * Property change id for the error message. - */ - public static final int PROP_ERROR = 5; - - private String errorMessage = null; - private Map<String, List<ServerEditorSection>> sectionToInsertionId = null; - private List<ServerEditorSection> sections = null; - private ServerResourceCommandManager commandManager; - private FormToolkit toolkit; - private IManagedForm managedForm; - - /** - * The server currently being edited. - */ - protected IServerWorkingCopy server; - - /** - * <code>true</code> if the server is read-only, and <code>false</code> - * otherwise. - */ - protected boolean readOnly; - - /** - * Create a new server editor part. - */ - public ServerEditorPart() { - super(); - } - - /** - * @see org.eclipse.ui.IEditorPart#doSave(IProgressMonitor) - */ - public void doSave(IProgressMonitor monitor) { - // do nothing - } - - /** - * @see org.eclipse.ui.IEditorPart#doSaveAs() - */ - public void doSaveAs() { - // do nothing - } - - /** - * @see org.eclipse.ui.IEditorPart#isDirty() - */ - public boolean isDirty() { - return false; - } - - /** - * @see org.eclipse.ui.IEditorPart#isSaveAsAllowed() - */ - public boolean isSaveAsAllowed() { - return false; - } - - /** - * Set the managed form that this part is using. - * - * @param managedForm a managed form - * @since 1.1 - */ - protected void setManagedForm(IManagedForm managedForm) { - this.managedForm = managedForm; - } - - /** - * Returns the managed form that this part is using, or <code>null</code> if no - * managed form has been set. - * - * @return managedForm the managed form that this part is using, or <code>null</code> - * if no managed form has been set - * @since 1.1 - */ - protected IManagedForm getManagedForm() { - return managedForm; - } - - /** - * Set an error message for this page. - * - * @param error the error message - * @see #getManagedForm() Use forms UI based for errors via {@link org.eclipse.ui.forms.IMessageManager} - * on the message form instead of this method - */ - public void setErrorMessage(String error) { - if (error == null && errorMessage == null) - return; - - if (error != null && error.equals(errorMessage)) - return; - - errorMessage = error; - super.firePropertyChange(PROP_ERROR); - } - - /** - * Updates the error message shown in the editor. - * - * @see #getManagedForm() Use forms UI based for errors via {@link org.eclipse.ui.forms.IMessageManager} - * on the message form instead of this method - */ - public void updateErrorMessage() { - super.firePropertyChange(PROP_ERROR); - } - - /** - * Return the error message for this page. - * - * @return the error message - * @see #getManagedForm() Use forms UI based for errors via {@link org.eclipse.ui.forms.IMessageManager} - * on the message form instead of this method - */ - public String getErrorMessage() { - if (errorMessage == null) { - Iterator iterator = getSections().iterator(); - while (iterator.hasNext()) { - ServerEditorSection section = (ServerEditorSection) iterator.next(); - String error = section.getErrorMessage(); - if (error != null) - return error; - } - } - return errorMessage; - } - - /** - * Returns error or status messages that will be displayed when the - * server resource is saved. If there are any error messages, the - * user will be unable to save the editor. - * - * @return a set of status - * @see #getManagedForm() Use forms UI based for errors via {@link org.eclipse.ui.forms.IMessageManager} - * on the message form instead of this method - */ - public IStatus[] getSaveStatus() { - Iterator iterator = getSections().iterator(); - List<IStatus> list = new ArrayList<IStatus>(); - while (iterator.hasNext()) { - ServerEditorSection section = (ServerEditorSection) iterator.next(); - IStatus[] status = section.getSaveStatus(); - if (status != null) { - int size = status.length; - for (int i = 0; i < size; i++) { - if (status[i].getSeverity() != IStatus.OK) - list.add(status[i]); - } - } - } - - int size = list.size(); - IStatus[] status = new IStatus[size]; - list.toArray(status); - return status; - } - - private List getSections() { - if (sections == null) { - sections = new ArrayList<ServerEditorSection>(); - sectionToInsertionId = new HashMap<String, List<ServerEditorSection>>(); - ServerEditor serverEditor = commandManager.getServerEditor(); - Iterator iterator = ServerEditorCore.getServerEditorPageSectionFactories().iterator(); - while (iterator.hasNext()) { - IServerEditorPageSectionFactory factory = (IServerEditorPageSectionFactory) iterator.next(); - String insertionId = factory.getInsertionId(); - - IServerEditorPartFactory pageFactory = serverEditor.getPageFactory(this); - if (pageFactory.supportsInsertionId(insertionId)) { - String serverTypeId = null; - if (server != null && server.getServerType() != null) - serverTypeId = server.getServerType().getId(); - if (serverTypeId != null && factory.supportsType(serverTypeId) - && factory.shouldCreateSection(server)) { - ServerEditorSection section = factory.createSection(); - if (section != null) { - section.setServerEditorPart(this); - sections.add(section); - List<ServerEditorSection> list = null; - try { - list = sectionToInsertionId.get(insertionId); - } catch (Exception e) { - // ignore - } - if (list == null) - list = new ArrayList<ServerEditorSection>(); - list.add(section); - sectionToInsertionId.put(insertionId, list); - } - } - } - } - } - return sections; - } - - private List getSections(String insertionId) { - if (insertionId == null) - return null; - - getSections(); - List<ServerEditorSection> list = new ArrayList<ServerEditorSection>(); - try { - List<ServerEditorSection> sections2 = sectionToInsertionId.get(insertionId); - if (sections2 != null) { - Iterator<ServerEditorSection> iterator = sections2.iterator(); - while (iterator.hasNext()) { - list.add(iterator.next()); - } - } - } catch (Exception e) { - // ignore - } - return list; - } - - /** - * @see org.eclipse.ui.IEditorPart#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput) - */ - public void init(IEditorSite site, IEditorInput input) { - setSite(site); - setInput(input); - if (input instanceof IServerEditorPartInput) { - IServerEditorPartInput sepi = (IServerEditorPartInput) input; - server = sepi.getServer(); - commandManager = ((ServerEditorPartInput) sepi).getServerCommandManager(); - readOnly = sepi.isServerReadOnly(); - } - - Iterator iterator = getSections().iterator(); - while (iterator.hasNext()) { - ServerEditorSection section = (ServerEditorSection) iterator.next(); - section.init(site, input); - } - } - - /** - * Executes the given operation and adds it to the operation history - * with the correct context. - * - * @param operation an operation ready to be executed - */ - public void execute(IUndoableOperation operation) { - commandManager.execute(operation); - } - - /** - * Return the server that is being edited. - * - * @return a server working copy - */ - public IServerWorkingCopy getServer() { - return server; - } - - /** - * Inserts editor sections into the given composite. - * - * @param parent the composite to add the section(s) to - * @param id the section insertion id - */ - public void insertSections(Composite parent, String id) { - if (id == null) - return; - - Iterator iterator = getSections(id).iterator(); - while (iterator.hasNext()) { - ServerEditorSection section = (ServerEditorSection) iterator.next(); - section.createSection(parent); - } - } - - /** - * Dispose of the editor. - */ - public void dispose() { - super.dispose(); - - Iterator iterator = getSections().iterator(); - while (iterator.hasNext()) { - ServerEditorSection section = (ServerEditorSection) iterator.next(); - section.dispose(); - } - - if (toolkit != null) { - toolkit.dispose(); - toolkit = null; - } - - commandManager = null; - sectionToInsertionId = null; - sections = null; - } - - /** - * Get a form toolkit to create widgets. It will be disposed automatically - * when the editor is closed. - * - * @param display the display - * @return FormToolkit - */ - protected FormToolkit getFormToolkit(Display display) { - if (managedForm != null) - return managedForm.getToolkit(); - - if (toolkit == null) - toolkit = new FormToolkit(display); - return toolkit; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorSection.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorSection.java deleted file mode 100644 index 88824d83e..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorSection.java +++ /dev/null @@ -1,176 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.editor; - -import org.eclipse.core.commands.operations.IUndoableOperation; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorSite; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.wst.server.core.IServerWorkingCopy; -import org.eclipse.wst.server.ui.internal.editor.ServerEditorPartInput; -import org.eclipse.wst.server.ui.internal.editor.ServerResourceCommandManager; -/** - * An abstract server editor section. - * - * @since 1.0 - */ -public abstract class ServerEditorSection { - private String errorMessage = null; - - private ServerResourceCommandManager commandManager; - - private Composite parentComp; - private ServerEditorPart editor; - - /** - * The server currently being edited. - */ - protected IServerWorkingCopy server; - - /** - * <code>true</code> if the server is read-only, and <code>false</code> - * otherwise. - */ - protected boolean readOnly; - - /** - * Initialize the section. - * - * @param site the editor site - * @param input the editor input - */ - public void init(IEditorSite site, IEditorInput input) { - if (input instanceof IServerEditorPartInput) { - IServerEditorPartInput sepi = (IServerEditorPartInput) input; - server = sepi.getServer(); - commandManager = ((ServerEditorPartInput) sepi).getServerCommandManager(); - readOnly = sepi.isServerReadOnly(); - } - } - - /** - * Executes the given operation and adds it to the operation history - * with the correct context. - * - * @param operation an operation ready to be executed - */ - public void execute(IUndoableOperation operation) { - commandManager.execute(operation); - } - - /** - * Create the section. - * - * @param parent the parent composite - */ - public void createSection(Composite parent) { - this.parentComp = parent; - } - - /** - * Return the shell of the section. - * - * @return the shell - */ - public Shell getShell() { - return parentComp.getShell(); - } - - /** - * Return the error message for this section. - * - * @return the error message - * @see #getManagedForm() Use forms UI based for errors via {@link org.eclipse.ui.forms.IMessageManager} - * on the message form instead of this method - */ - public String getErrorMessage() { - return errorMessage; - } - - /** - * Returns error or status messages that will be displayed when the - * server resource is saved. If there are any error messages, the - * user will be unable to save the editor. - * - * @return a status object with code <code>IStatus.OK</code> if this - * server can be saved, otherwise a status object indicating why - * it can't be - * @see #getManagedForm() Use forms UI based for errors via {@link org.eclipse.ui.forms.IMessageManager} - * on the message form instead of this method - */ - public IStatus[] getSaveStatus() { - return new IStatus[] { Status.OK_STATUS }; - } - - /** - * Set the editor part that this section belongs to. - * - * @param editor the editor - */ - public void setServerEditorPart(ServerEditorPart editor) { - this.editor = editor; - } - - /** - * Set an error message for this section. - * - * @param error an error message - * @see #getManagedForm() Use forms UI based for errors via {@link org.eclipse.ui.forms.IMessageManager} - * on the message form instead of this method - */ - public void setErrorMessage(String error) { - if (error == null && errorMessage == null) - return; - - if (error != null && error.equals(errorMessage)) - return; - - errorMessage = error; - if (editor != null) - editor.updateErrorMessage(); - } - - /** - * Get a form toolkit to create widgets. It will be disposed automatically - * when the editor is closed. - * - * @param display the display - * @return a FormToolkit - */ - protected FormToolkit getFormToolkit(Display display) { - return editor.getFormToolkit(display); - } - - /** - * Returns the managed form that the editor is using, or <code>null</code> if no - * managed form has been set. - * - * @return the managed form that the editor is using, or <code>null</code> if no - * managed form has been set - * @since 1.1 - */ - protected IManagedForm getManagedForm() { - return editor.getManagedForm(); - } - - /** - * Disposes of the section. - */ - public void dispose() { - // ignore - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/package.html b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/package.html deleted file mode 100644 index b464c187b..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/package.html +++ /dev/null @@ -1,22 +0,0 @@ -<html> -<head> -<META http-equiv="Content-Type" content="text/html; charset=UTF-8"> -<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> -<link rel="stylesheet" href="../../../../../..//apistyles.css" type="text/css"> -<title>WTP API overview</title> -</head> -<body> -<p>Provides editor support for the server tools UI.</p> -<table width="500"> -<tr> -<td> -<p>Using extension points, clients can provide pages, sections, and -actions to be added to the editor for a specific server type. This -package contains the delegate classes for these extension points, as -well as the API that they can use to put commands on the shared -editor command history stack and interact with the editing framework.</p> -</td> -</tr> -</table> -</body> -</html> diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/package.xml b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/package.xml deleted file mode 100644 index 024c4a2bc..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/package.xml +++ /dev/null @@ -1,22 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<html> -<head> - <!-- Escape to the root of your source folder --> - <meta - name="root" - content="../../../../../../" /> - <title>WTP API overview</title> -</head> - -<body> - -<abstract>Provides editor support for the server tools UI.</abstract> - -<p>Using extension points, clients can provide pages, sections, and -actions to be added to the editor for a specific server type. This -package contains the delegate classes for these extension points, as -well as the API that they can use to put commands on the shared -editor command history stack and interact with the editing framework.</p> - -</body> -</html>
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ContextIds.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ContextIds.java deleted file mode 100644 index 5ccd95d7a..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ContextIds.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal; -/** - * Context help id constants. - */ -public interface ContextIds { - public static final String SELECT_SERVER_WIZARD = ServerUIPlugin.PLUGIN_ID + ".swsi0000"; - public static final String SELECT_SERVER_EXISTING = ServerUIPlugin.PLUGIN_ID + ".swsi0002"; - public static final String SELECT_SERVER_EXISTING_TABLE = ServerUIPlugin.PLUGIN_ID + ".swsi0004"; - public static final String SELECT_SERVER_CREATE = ServerUIPlugin.PLUGIN_ID + ".swsi0010"; - public static final String SELECT_SERVER_CREATE_TABLE = ServerUIPlugin.PLUGIN_ID + ".swsi0012"; - public static final String SELECT_SERVER_PREFERENCE = ServerUIPlugin.PLUGIN_ID + ".swsi0014"; - - public static final String SELECT_CLIENT_WIZARD = ServerUIPlugin.PLUGIN_ID + ".swsc0000"; - public static final String SELECT_CLIENT = ServerUIPlugin.PLUGIN_ID + ".swsc0002"; - - public static final String NEW_SERVER_WIZARD = ServerUIPlugin.PLUGIN_ID + ".swns0000"; - public static final String NEW_SERVER_TYPE = ServerUIPlugin.PLUGIN_ID + ".swns0006"; - - public static final String SERVER_PROPERTY_PAGE = ServerUIPlugin.PLUGIN_ID + ".svcp0004"; - - public static final String NEW_RUNTIME_WIZARD = ServerUIPlugin.PLUGIN_ID + ".swnr0000"; - - public static final String LAUNCH_CONFIGURATION_SERVER_COMBO = ServerUIPlugin.PLUGIN_ID + ".swsl0000"; - - public static final String SELECT_TASK_WIZARD = ServerUIPlugin.PLUGIN_ID + ".sstw0000"; - - public static final String MODIFY_MODULES_COMPOSITE = ServerUIPlugin.PLUGIN_ID + ".swmm0000"; - - public static final String TERMINATE_SERVER_DIALOG = ServerUIPlugin.PLUGIN_ID + ".sdti0000"; - public static final String DELETE_SERVER_DIALOG = ServerUIPlugin.PLUGIN_ID + ".svcp0002"; - - public static final String PREF_GENERAL = ServerUIPlugin.PLUGIN_ID + ".spge0000"; - public static final String PREF_GENERAL_PUBLISH_BEFORE_START = ServerUIPlugin.PLUGIN_ID + ".spge0012"; - public static final String PREF_GENERAL_SHOW_ON_ACTIVITY = ServerUIPlugin.PLUGIN_ID + ".spge0022"; - public static final String PREF_GENERAL_SAVE_EDITORS = ServerUIPlugin.PLUGIN_ID + ".spge0024"; - public static final String PREF_GENERAL_LAUNCH_MODE = ServerUIPlugin.PLUGIN_ID + ".spge0030"; - public static final String PREF_GENERAL_LAUNCH_MODE_DEBUG = ServerUIPlugin.PLUGIN_ID + ".spge0031"; - public static final String PREF_GENERAL_ENABLE_BREAKPOINTS = ServerUIPlugin.PLUGIN_ID + ".spge0032"; - public static final String PREF_GENERAL_RESTART = ServerUIPlugin.PLUGIN_ID + ".spge0034"; - - public static final String VIEW_SERVERS = ServerUIPlugin.PLUGIN_ID + ".svcp0000"; - - public static final String PUBLISH_DETAILS_DIALOG = ServerUIPlugin.PLUGIN_ID + ".sdpd0000"; - public static final String PUBLISH_DETAILS_DIALOG_STATUS = ServerUIPlugin.PLUGIN_ID + ".sdpd0002"; - public static final String PUBLISH_DETAILS_DIALOG_DETAILS_BUTTON = ServerUIPlugin.PLUGIN_ID + ".sdpd0004"; - public static final String PUBLISH_DETAILS_DIALOG_DETAILS = ServerUIPlugin.PLUGIN_ID + ".sdpd0006"; - - public static final String PROMPT_IRREVERSIBLE_DIALOG = ServerUIPlugin.PLUGIN_ID + ".sdpi0000"; - - public static final String EDITOR_OVERVIEW_PAGE = ServerUIPlugin.PLUGIN_ID + ".seop0000"; - public static final String EDITOR_SERVER = ServerUIPlugin.PLUGIN_ID + ".seop0002"; - public static final String EDITOR_CONFIGURATION = ServerUIPlugin.PLUGIN_ID + ".seop0004"; - public static final String EDITOR_HOSTNAME = ServerUIPlugin.PLUGIN_ID + ".seop0006"; - public static final String EDITOR_RUNTIME = ServerUIPlugin.PLUGIN_ID + ".seop0008"; - public static final String EDITOR_AUTOPUBLISH_ENABLE = ServerUIPlugin.PLUGIN_ID + ".seop0012"; - public static final String EDITOR_AUTOPUBLISH_DISABLE = ServerUIPlugin.PLUGIN_ID + ".seop0016"; - public static final String EDITOR_PUBLISHTASKS_CONFIGURATION = ServerUIPlugin.PLUGIN_ID + ".seop0018"; - public static final String EDITOR_TIMEOUT_START = ServerUIPlugin.PLUGIN_ID + "spge0026"; - public static final String EDITOR_TIMEOUT_STOP = ServerUIPlugin.PLUGIN_ID + "spge0027"; - - public static final String AUDIO_PREFERENCES = ServerUIPlugin.PLUGIN_ID + ".aupr0000"; - public static final String AUDIO_PREFERENCES_ENABLE = ServerUIPlugin.PLUGIN_ID + ".aupr0002"; - public static final String AUDIO_PREFERENCES_VOLUME = ServerUIPlugin.PLUGIN_ID + ".aupr0004"; - public static final String AUDIO_PREFERENCES_SOUNDS_TABLE = ServerUIPlugin.PLUGIN_ID + ".aupr0006"; - public static final String AUDIO_PREFERENCES_PLAY = ServerUIPlugin.PLUGIN_ID + ".aupr0008"; - public static final String AUDIO_PREFERENCES_BROWSE = ServerUIPlugin.PLUGIN_ID + ".aupr0010"; - public static final String AUDIO_PREFERENCES_RESET = ServerUIPlugin.PLUGIN_ID + ".aupr0012"; -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/DefaultMonitorDelegate.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/DefaultMonitorDelegate.java deleted file mode 100644 index 279ddbbd2..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/DefaultMonitorDelegate.java +++ /dev/null @@ -1,116 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.osgi.util.NLS; -import org.eclipse.wst.internet.monitor.core.internal.provisional.IMonitor; -import org.eclipse.wst.internet.monitor.core.internal.provisional.IMonitorListener; -import org.eclipse.wst.internet.monitor.core.internal.provisional.IMonitorWorkingCopy; -import org.eclipse.wst.internet.monitor.core.internal.provisional.MonitorCore; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.ServerPort; -import org.eclipse.wst.server.core.internal.ServerMonitorDelegate; -import org.eclipse.wst.server.core.util.SocketUtil; -/** - * - */ -public class DefaultMonitorDelegate extends ServerMonitorDelegate { - protected Map<ServerPort, IMonitor> monitors = new HashMap<ServerPort, IMonitor>(); - protected IMonitorListener listener; - - private void addListener() { - if (listener != null) - return; - - listener = new IMonitorListener() { - public void monitorAdded(IMonitor monitor) { - // ignore - } - - public void monitorChanged(IMonitor monitor) { - // ignore - } - - public void monitorRemoved(IMonitor monitor) { - if (monitor == null) - return; - - Object monKey = null; - Iterator iterator = monitors.keySet().iterator(); - while (iterator.hasNext()) { - Object key = iterator.next(); - Object value = monitors.get(key); - if (monitor.equals(value)) - monKey = key; - } - if (monKey != null) - monitors.remove(monKey); - if (monitors.isEmpty()) { - MonitorCore.removeMonitorListener(listener); - listener = null; - } - } - }; - MonitorCore.addMonitorListener(listener); - } - - /* (non-Javadoc) - * @see org.eclipse.wst.server.core.model.ServerMonitorDelegate#startMonitoring(org.eclipse.wst.server.core.ServerPort) - */ - public int startMonitoring(IServer server, ServerPort port, int monitorPort) throws CoreException { - try { - IMonitor monitor = monitors.get(port); - int mport = -1; - if (monitor == null) { - mport = monitorPort; - if (mport == -1) - mport = SocketUtil.findUnusedPort(5000, 15000); - - // should search for a monitor first .. - IMonitorWorkingCopy wc = MonitorCore.createMonitor(); - wc.setLocalPort(mport); - wc.setRemoteHost(server.getHost()); - wc.setRemotePort(port.getPort()); - if ("HTTP".equals(port.getProtocol())) - wc.setProtocol("HTTP"); - monitor = wc.save(); - addListener(); - } else - mport = monitor.getLocalPort(); - monitor.start(); - monitors.put(port, monitor); - return mport; - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Could not start monitoring", e); - throw new CoreException(new Status(IStatus.ERROR, ServerUIPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorStartingMonitor, e.getLocalizedMessage()), null)); - } - } - - /* (non-Javadoc) - * @see org.eclipse.wst.server.core.model.ServerMonitorDelegate#stopMonitoring(org.eclipse.wst.server.core.ServerPort) - */ - public void stopMonitoring(IServer server, ServerPort port) { - try { - IMonitor monitor = monitors.get(port); - if (monitor != null) - monitor.stop(); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Could not stop monitoring", e); - } - } -} diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/DefaultServerImageDescriptor.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/DefaultServerImageDescriptor.java deleted file mode 100644 index 3c25b6afd..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/DefaultServerImageDescriptor.java +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal; - -import org.eclipse.jface.resource.CompositeImageDescriptor; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.ImageData; -import org.eclipse.swt.graphics.Point; -/** - * A OverlayImageDescriptor consists of a main icon and one or more overlays. - * The overlays are computed according to flags set on creation of the descriptor. - */ -public class DefaultServerImageDescriptor extends CompositeImageDescriptor { - private Image fBaseImage; - private Point fSize; - private Image overlay; - - /** - * Create a new OverlayImageDescriptor. - * - * @param baseImage an image descriptor used as the base image - */ - public DefaultServerImageDescriptor(Image baseImage) { - this(baseImage, ImageResource.getImage(ImageResource.IMG_DEFAULT_SERVER_OVERLAY)); - } - - /** - * - * @param baseImage - * @param overlay - */ - public DefaultServerImageDescriptor(Image baseImage, Image overlay) { - setBaseImage(baseImage); - this.overlay = overlay; - } - - /** - * @see CompositeImageDescriptor#getSize() - */ - protected Point getSize() { - if (fSize == null) { - ImageData data = getBaseImage().getImageData(); - setSize(new Point(data.width, data.height)); - } - return fSize; - } - - /** - * @see Object#equals(java.lang.Object) - */ - public boolean equals(Object object) { - if (!(object instanceof DefaultServerImageDescriptor)) - return false; - - DefaultServerImageDescriptor other = (DefaultServerImageDescriptor) object; - return (getBaseImage().equals(other.getBaseImage())); - } - - /** - * @see Object#hashCode() - */ - public int hashCode() { - return getBaseImage().hashCode(); - } - - /** - * @see CompositeImageDescriptor#drawCompositeImage(int, int) - */ - protected void drawCompositeImage(int width, int height) { - ImageData bg = getBaseImage().getImageData(); - if (bg == null) - bg = DEFAULT_IMAGE_DATA; - - drawImage(bg, 0, 0); - drawOverlays(); - } - - /** - * Add any overlays to the image as specified in the flags. - */ - protected void drawOverlays() { - ImageData data = overlay.getImageData(); - int x = getSize().x - data.width; - drawImage(data, x, 0); - } - - protected Image getBaseImage() { - return fBaseImage; - } - - protected void setBaseImage(Image baseImage) { - fBaseImage = baseImage; - } - - protected void setSize(Point size) { - fSize = size; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/DefaultServerLabelDecorator.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/DefaultServerLabelDecorator.java deleted file mode 100644 index 7b3eab352..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/DefaultServerLabelDecorator.java +++ /dev/null @@ -1,104 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.viewers.ILabelDecorator; -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.ISharedImages; -import org.eclipse.wst.server.core.internal.Server; -/** - * - */ -public class DefaultServerLabelDecorator implements ILabelDecorator { - protected Map<Object, Image> map = new HashMap<Object, Image>(); - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ILabelDecorator#decorateImage(org.eclipse.swt.graphics.Image, java.lang.Object) - */ - public Image decorateImage(Image image, Object element) { - try { - Image img = map.get(element); - if (img != null) - return img; - } catch (Exception e) { - // ignore - } - - DefaultServerImageDescriptor dsid = null; - if (element instanceof Server) { - IStatus status = ((Server) element).getServerStatus(); - if (status != null) { - ISharedImages sharedImages = ServerUIPlugin.getInstance().getWorkbench().getSharedImages(); - if (status.getSeverity() == IStatus.ERROR) - dsid = new DefaultServerImageDescriptor(image, sharedImages.getImage(ISharedImages.IMG_OBJS_ERROR_TSK)); - else if (status.getSeverity() == IStatus.WARNING) - dsid = new DefaultServerImageDescriptor(image, sharedImages.getImage(ISharedImages.IMG_OBJS_WARN_TSK)); - else if (status.getSeverity() == IStatus.INFO) - dsid = new DefaultServerImageDescriptor(image, sharedImages.getImage(ISharedImages.IMG_OBJS_INFO_TSK)); - } - } - - if (dsid == null) - dsid = new DefaultServerImageDescriptor(image); - Image image2 = dsid.createImage(); - map.put(element, image2); - return image2; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ILabelDecorator#decorateText(java.lang.String, java.lang.Object) - */ - public String decorateText(String text, Object element) { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener) - */ - public void addListener(ILabelProviderListener listener) { - // do nothing - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() - */ - public void dispose() { - try { - Iterator iterator = map.values().iterator(); - while (iterator.hasNext()) { - Image image = (Image) iterator.next(); - image.dispose(); - } - } catch (Exception e) { - Trace.trace(Trace.WARNING, "Could not dispose images", e); - } - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String) - */ - public boolean isLabelProperty(Object element, String property) { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener) - */ - public void removeListener(ILabelProviderListener listener) { - // do nothing - } -} diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/DeleteRuntimeDialog.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/DeleteRuntimeDialog.java deleted file mode 100644 index c1401e408..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/DeleteRuntimeDialog.java +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal; - -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.MessageDialog; -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.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; - -public class DeleteRuntimeDialog extends MessageDialog { - protected boolean promptDeleteServers; - protected boolean promptRemoveTargets; - protected boolean deleteServers; - protected boolean removeTargets; - - public DeleteRuntimeDialog(Shell parentShell, boolean promptDeleteServers, boolean promptRemoveTargets) { - super(parentShell, Messages.defaultDialogTitle, null, Messages.dialogRuntimeInUse, QUESTION, - new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0); - this.promptDeleteServers = promptDeleteServers; - this.promptRemoveTargets = promptRemoveTargets; - } - - protected Control createCustomArea(Composite parent) { - if (!promptDeleteServers && !promptRemoveTargets) - return null; - - Composite comp = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(1, true); - layout.horizontalSpacing = convertHorizontalDLUsToPixels(4); - layout.verticalSpacing = convertVerticalDLUsToPixels(3); - layout.marginWidth = 0; - layout.marginHeight = 0; - comp.setLayout(layout); - comp.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); - - if (promptDeleteServers) { - deleteServers = true; - final Button deleteServersButton = new Button(comp, SWT.CHECK); - deleteServersButton.setText(Messages.dialogRuntimeDeleteServers); - deleteServersButton.setSelection(true); - deleteServersButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - deleteServers = deleteServersButton.getSelection(); - } - }); - } - - if (promptRemoveTargets) { - removeTargets = true; - final Button removeTargetsButton = new Button(comp, SWT.CHECK); - removeTargetsButton.setText(Messages.dialogRuntimeRemoveTargets); - removeTargetsButton.setSelection(true); - removeTargetsButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - removeTargets = removeTargetsButton.getSelection(); - } - }); - } - - return comp; - } - - public boolean isDeleteServers() { - return deleteServers; - } - - public boolean isRemoveTargets() { - return removeTargets; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/DeleteServerDialog.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/DeleteServerDialog.java deleted file mode 100644 index 645e865e2..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/DeleteServerDialog.java +++ /dev/null @@ -1,272 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IResourceRuleFactory; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.core.runtime.jobs.MultiRule; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.osgi.util.NLS; -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.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.IServer.IOperationListener; -/** - * Dialog that prompts a user to delete server(s) and/or server configuration(s). - */ -public class DeleteServerDialog extends MessageDialog { - protected IServer[] servers; - protected IFolder[] configs; - - protected List<IServer> runningServersList; - protected boolean runningServerCanStop; - - protected Button checkDeleteConfigs; - protected Button checkDeleteRunning; - protected Button checkDeleteRunningStop; - - /** - * DeleteServerDialog constructor comment. - * - * @param parentShell a shell - * @param servers an array of servers - * @param configs an array of server configurations - */ - public DeleteServerDialog(Shell parentShell, IServer[] servers, IFolder[] configs) { - super(parentShell, Messages.deleteServerDialogTitle, null, null, QUESTION, - new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0); - - if (servers == null || configs == null) - throw new IllegalArgumentException(); - - this.servers = servers; - this.configs = configs; - - runningServersList = new ArrayList<IServer>(); - for (int i = 0 ; i < servers.length ; ++i) { - if (servers[i].getServerState() != IServer.STATE_STOPPED) - runningServersList.add(servers[i]); - - if (servers[i].canStop().isOK()) - runningServerCanStop = true; - } - - if (servers.length == 1) - message = NLS.bind(Messages.deleteServerDialogMessage, servers[0].getName()); - else - message = NLS.bind(Messages.deleteServerDialogMessageMany, servers.length + ""); - } - - /** - * - */ - protected Control createCustomArea(Composite parent) { - // create a composite with standard margins and spacing - Composite composite = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); - layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); - layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); - layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - composite.setFont(parent.getFont()); - PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, ContextIds.DELETE_SERVER_DIALOG); - - if (configs.length > 0) { - checkDeleteConfigs = new Button(composite, SWT.CHECK); - checkDeleteConfigs.setText(NLS.bind(Messages.deleteServerDialogLooseConfigurations, configs[0].getName())); - checkDeleteConfigs.setSelection(true); - } - - // prompt for stopping running servers - int size = runningServersList.size(); - if (size > 0) { - checkDeleteRunning = new Button(composite, SWT.CHECK); - checkDeleteRunning.setText(Messages.deleteServerDialogRunningServer); - checkDeleteRunning.setSelection(true); - - if (runningServerCanStop) { - checkDeleteRunningStop = new Button(composite, SWT.CHECK); - checkDeleteRunningStop.setText(Messages.deleteServerDialogRunningServerStop); - checkDeleteRunningStop.setSelection(true); - GridData data = new GridData(); - data.horizontalIndent = 15; - checkDeleteRunningStop.setLayoutData(data); - - checkDeleteRunning.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - checkDeleteRunningStop.setEnabled(checkDeleteRunning.getSelection()); - } - }); - } - } - - Dialog.applyDialogFont(composite); - - return composite; - } - - protected void buttonPressed(int buttonId) { - if (buttonId == OK) { - final boolean checked = (checkDeleteConfigs != null && checkDeleteConfigs.getSelection()); - final boolean deleteRunning = (checkDeleteRunning != null && checkDeleteRunning.getSelection()); - final boolean deleteRunningStop = (checkDeleteRunningStop != null && checkDeleteRunningStop.getSelection()); - - Thread t = new Thread("Delete servers") { - public void run() { - if (runningServersList.size() > 0) { - // stop servers and/or updates servers' list - prepareForDeletion(deleteRunning, deleteRunningStop); - } - - Job job = new Job(Messages.deleteServerTask) { - protected IStatus run(IProgressMonitor monitor) { - if (servers.length == 0) { - // all servers have been deleted from list - return Status.OK_STATUS; - } - try { - if (monitor.isCanceled()) - return Status.CANCEL_STATUS; - - int size = servers.length; - for (int i = 0; i < size; i++) - servers[i].delete(); - - if (monitor.isCanceled()) - return Status.CANCEL_STATUS; - - if (checked) { - size = configs.length; - for (int i = 0; i < size; i++) - configs[i].delete(true, true, monitor); - } - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error while deleting resources", e); - return new Status(IStatus.ERROR, ServerUIPlugin.PLUGIN_ID, 0, e.getMessage(), e); - } - - return Status.OK_STATUS; - } - }; - - // set rule for workspace and servers - int size = servers.length; - ISchedulingRule[] rules = new ISchedulingRule[size+1]; - for (int i = 0; i < size; i++) - rules[i] = servers[i]; - IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory(); - rules[size] = ruleFactory.createRule(ResourcesPlugin.getWorkspace().getRoot()); - job.setRule(MultiRule.combine(rules)); - job.setPriority(Job.BUILD); - - job.schedule(); - } - }; - t.setDaemon(true); - t.start(); - } - super.buttonPressed(buttonId); - } - - /** - * Updates servers' & configs' lists. If <code>deleteRunning</code> is <code>true</code> - * and a server can't be stopped, it isn't removed. - * @param deleteRunning if <code>true</code> running servers will be stopped - * before being deleted, if <code>false</code> running servers will be removed - * from deletion list. - */ - protected void prepareForDeletion(boolean deleteRunning, boolean stopRunning) { - // converts servers & configs to list to facilitate removal - List<IServer> serversList = new LinkedList<IServer>(Arrays.asList(servers)); - List<IFolder> configsList = new LinkedList<IFolder>(Arrays.asList(configs)); - if (!deleteRunning) { - // don't delete servers or configurations - int size = runningServersList.size(); - for (int i = 0; i < size; i++) { - IServer server = runningServersList.get(i); - serversList.remove(server); - if (server.getServerConfiguration() != null) - configsList.remove(server.getServerConfiguration()); - } - } else { - if (stopRunning) { - // stop running servers and wait for them (stop is asynchronous) - IServer s; - MultiServerStopListener listener = new MultiServerStopListener(); - int expected = 0; - Iterator iter = runningServersList.iterator(); - while (iter.hasNext()) { - s = (IServer) iter.next(); - if (s.canStop().isOK()) { - ++expected; - s.stop(false, listener); - } else { - // server can't be stopped, don't delete it - serversList.remove(s); - configsList.remove(s.getServerConfiguration()); - } - } - try { - while (expected != listener.getNumberStopped()) { - Thread.sleep(200); - } - } catch (InterruptedException e) { - Trace.trace(Trace.WARNING, "Interrupted while waiting for servers stop"); - } - } - } - servers = new IServer[serversList.size()]; - serversList.toArray(servers); - configs = new IFolder[configsList.size()]; - configsList.toArray(configs); - } - - /** - * Class used to wait all servers stop. Use one instance - * for a group of servers and loop to see if the number stopped - * equals the number of servers waiting to stop. - */ - class MultiServerStopListener implements IOperationListener { - protected int num; - - public void done(IStatus result) { - num++; - } - - public int getNumberStopped() { - return num; - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/EclipseUtil.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/EclipseUtil.java deleted file mode 100644 index dcdabd926..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/EclipseUtil.java +++ /dev/null @@ -1,221 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.model.IWorkbenchAdapter; - -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.ServerUtil; -import org.eclipse.wst.server.core.internal.ServerPlugin; -/** - * Eclipse utility methods. - */ -public class EclipseUtil { - /** - * EclipseUtil constructor comment. - */ - private EclipseUtil() { - super(); - } - - /** - * Creates a new server project with the given name. If path is - * null, it will be created in the default location. - * - * @param name java.lang.String - * @param path org.eclipse.core.resource.IPath - * @param monitor - * @return org.eclipse.core.runtime.IStatus - */ - private static IStatus createServerProject(String name, IPath path, IProgressMonitor monitor) { - //monitor = ProgressUtil.getMonitorFor(monitor); - //monitor.beginTask(ServerPlugin.getResource("%createServerProjectTask"), 3000); - - try { - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - IProject project = workspace.getRoot().getProject(name); - - // get a project descriptor - IProjectDescription description = workspace.newProjectDescription(name); - description.setLocation(path); - - project.create(description, ProgressUtil.getSubMonitorFor(monitor, 1000)); - if (monitor.isCanceled()) - return null; - project.open(ProgressUtil.getSubMonitorFor(monitor, 1000)); - if (monitor.isCanceled()) - return null; - - // add the server project nature - ServerPlugin.getProjectProperties(project).setServerProject(true, monitor); - - if (monitor.isCanceled()) - return null; - - return Status.OK_STATUS; - } catch (CoreException ce) { - Trace.trace(Trace.SEVERE, "Could not create server project named " + name, ce); - return new Status(IStatus.ERROR, ServerUIPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCouldNotCreateServerProjectStatus, ce.getMessage()), ce); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Could not create server project (2) named " + name, e); - return new Status(IStatus.ERROR, ServerUIPlugin.PLUGIN_ID, 0, Messages.errorCouldNotCreateServerProject, e); - } finally { - monitor.done(); - } - } - - /** - * Creates a new server project with the given name. If path is - * null, it will be created in the default location. - * - * @param shell a shell - * @param name a name - * @param path a path - * @param monitor a progress monitor, or null - */ - public static void createNewServerProject(final Shell shell, String name, IPath path, IProgressMonitor monitor) { - final IStatus status = createServerProject(name, path, monitor); - if (!status.isOK()) { - Display.getDefault().asyncExec(new Runnable() { - public void run() { - Shell shell2 = shell; - if (shell == null) - shell2 = getShell(); - openError(shell2, Messages.errorCouldNotCreateServerProject, status); - } - }); - } - } - - /** - * Returns the image for a project. - * - * @param project org.eclipse.core.resources.IProject - * @return org.eclipse.jface.resource.ImageDescriptor - */ - public static ImageDescriptor getProjectImageDescriptor(IProject project) { - if (project == null) - return null; - - IWorkbenchAdapter adapter = (IWorkbenchAdapter) project.getAdapter(IWorkbenchAdapter.class); - - if (adapter != null) - return adapter.getImageDescriptor(project); - - return null; - } - - /** - * Return a shell for the workbench. - * - * @return org.eclipse.swt.widgets.Shell - */ - public static Shell getShell() { - return getStandardDisplay().getActiveShell(); - } - - /** - * Returns the standard display to be used. The method first checks, if - * the thread calling this method has an associated display. If so, this - * display is returned. Otherwise the method returns the default display. - * - * @return the display - */ - public static Display getStandardDisplay() { - Display display = Display.getCurrent(); - if (display == null) - display = Display.getDefault(); - - return display; - } - - /** - * Open a dialog window. - * - * @param message java.lang.String - */ - public static void openError(final String message) { - Display.getDefault().asyncExec(new Runnable() { - public void run() { - Shell shell = getShell(); - MessageDialog.openError(shell, Messages.errorDialogTitle, message); - } - }); - } - - /** - * Open a dialog window. - * - * @param message java.lang.String - * @param status IStatus - */ - public static void openError(final String message, final IStatus status) { - Display.getDefault().asyncExec(new Runnable() { - public void run() { - Shell shell = getShell(); - ErrorDialog.openError(shell, Messages.errorDialogTitle, message, status); - } - }); - } - - /** - * Open a dialog window. - * - * @param shell the shell - * @param message the message - */ - public static void openError(Shell shell, String message) { - MessageDialog.openError(shell, Messages.errorDialogTitle, message); - } - - /** - * Open a dialog window. - * - * @param shell a shell - * @param message a message - * @param status a status - */ - public static void openError(Shell shell, String message, IStatus status) { - ErrorDialog.openError(shell, Messages.errorDialogTitle, message, status); - } - - /** - * Do a validateEdit() on the given server. - * - * @param shell a shell - * @param server a server - * @return true if validate edit worked - */ - public static boolean validateEdit(Shell shell, IServer server) { - IStatus status = ServerUtil.validateEdit(shell, server); - return validateEdit(shell, status); - } - - protected static boolean validateEdit(Shell shell, IStatus status) { - if (status != null && status.getSeverity() == IStatus.ERROR) { - // inform user - String message = Messages.editorValidateEditFailureMessage; - ErrorDialog.openError(shell, Messages.errorDialogTitle, message, status); - - // do not execute command - return false; - } - return true; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/GeneralToolTip.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/GeneralToolTip.java deleted file mode 100644 index e73c37b9f..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/GeneralToolTip.java +++ /dev/null @@ -1,34 +0,0 @@ -/********************************************************************** - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - **********************************************************************/ -package org.eclipse.wst.server.ui.internal; - -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Text; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.ui.internal.provisional.IServerToolTip; - -public class GeneralToolTip implements IServerToolTip { - public GeneralToolTip() { - // do nothing - } - - public void createContent(Composite parent, IServer server) { - Text text = new Text(parent,SWT.NONE); - text.setBackground(parent.getBackground()); - String s = ""; - if (server.getRuntime() != null) - s += server.getRuntime().getName() + " - "; - s += NLS.bind(Messages.modules, server.getModules().length + ""); - text.setText(s); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ImageResource.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ImageResource.java deleted file mode 100644 index cc365e3ba..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ImageResource.java +++ /dev/null @@ -1,368 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal; - -import java.net.URL; -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtensionDelta; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.ImageRegistry; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.eclipse.wst.server.core.ServerUtil; -/** - * Utility class to handle image resources. - */ -public class ImageResource { - // the image registry - private static ImageRegistry imageRegistry; - - // map of image descriptors since these - // will be lost by the image registry - private static Map<String, ImageDescriptor> imageDescriptors; - - // base urls for images - private static URL ICON_BASE_URL; - - static { - try { - String pathSuffix = "icons/"; - ICON_BASE_URL = ServerUIPlugin.getInstance().getBundle().getEntry(pathSuffix); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Could not set icon base URL", e); - } - } - - private static final String URL_CLCL = "clcl16/"; - private static final String URL_CTOOL = "ctool16/"; - - private static final String URL_ELCL = "elcl16/"; - private static final String URL_ETOOL = "etool16/"; - - private static final String URL_DLCL = "dlcl16/"; - private static final String URL_DTOOL = "dtool16/"; - - private static final String URL_OBJ = "obj16/"; - - private static final String URL_OVR = "ovr16/"; - - private static final String URL_WIZBAN = "wizban/"; - - // --- constants for images --- - - // Server State Images - public static final String IMG_CLCL_START = "IMG_CLCL_START"; - public static final String IMG_CLCL_START_DEBUG = "IMG_CLCL_START_DEBUG"; - public static final String IMG_CLCL_START_PROFILE = "IMG_CLCL_START_PROFILE"; - public static final String IMG_CLCL_STOP = "IMG_CLCL_STOP"; - public static final String IMG_CLCL_PUBLISH = "IMG_CLCL_PUBLISH"; - public static final String IMG_CLCL_DISCONNECT = "IMG_CLCL_DISCONNECT"; - - public static final String IMG_ELCL_START = "IMG_ELCL_START"; - public static final String IMG_ELCL_START_DEBUG = "IMG_ELCL_START_DEBUG"; - public static final String IMG_ELCL_START_PROFILE = "IMG_ELCL_START_PROFILE"; - public static final String IMG_ELCL_STOP = "IMG_ELCL_STOP"; - public static final String IMG_ELCL_PUBLISH = "IMG_ELCL_PUBLISH"; - public static final String IMG_ELCL_DISCONNECT = "IMG_ELCL_DISCONNECT"; - - public static final String IMG_DLCL_START = "IMG_DLCL_START"; - public static final String IMG_DLCL_START_DEBUG = "IMG_DLCL_START_DEBUG"; - public static final String IMG_DLCL_START_PROFILE = "IMG_DLCL_START_PROFILE"; - public static final String IMG_DLCL_STOP = "IMG_DLCL_STOP"; - public static final String IMG_DLCL_PUBLISH = "IMG_DLCL_PUBLISH"; - public static final String IMG_DLCL_DISCONNECT = "IMG_DLCL_DISCONNECT"; - - // Wizard Banner Images - public static final String IMG_WIZBAN_NEW_RUNTIME = "newServerWiz"; - public static final String IMG_WIZBAN_NEW_SERVER = "newServerWiz"; - public static final String IMG_WIZBAN_SELECT_SERVER_CLIENT = "wizClient"; - public static final String IMG_WIZBAN_SELECT_SERVER = "selectServer"; - public static final String IMG_WIZBAN_IMPORT_SERVER_CONFIGURATION = "importConfigWiz"; - - public static final String IMG_SERVER_STATE_STARTED = "stateStarted"; - public static final String IMG_SERVER_STATE_STARTED_DEBUG = "stateStartedDebug"; - public static final String IMG_SERVER_STATE_STARTED_PROFILE = "stateStartedProfile"; - public static final String IMG_SERVER_STATE_STOPPED = "stateStopped"; - - public static final String IMG_STATE_STARTED = "stateStarted2"; - public static final String IMG_STATE_STOPPED = "stateStopped2"; - - public static final String IMG_SERVER_STATE_STARTING_1 = "stateStarting1"; - public static final String IMG_SERVER_STATE_STARTING_2 = "stateStarting2"; - public static final String IMG_SERVER_STATE_STARTING_3 = "stateStarting3"; - - public static final String IMG_SERVER_STATE_STOPPING_1 = "stateStopping1"; - public static final String IMG_SERVER_STATE_STOPPING_2 = "stateStopping2"; - public static final String IMG_SERVER_STATE_STOPPING_3 = "stateStopping3"; - - // Server Client Images - public static final String IMG_CTOOL_RUN_ON_SERVER = "IMG_CTOOL_CLIENT"; - public static final String IMG_CTOOL_DEBUG_ON_SERVER = "IMG_CTOOL_CLIENT2"; - public static final String IMG_CTOOL_PROFILE_ON_SERVER = "IMG_CTOOL_CLIENT3"; - public static final String IMG_CTOOL_NEW_SERVER = "IMG_CTOOL_NEW_SERVER"; - public static final String IMG_CTOOL_NEW_SERVER_INSTANCE = "IMG_CTOOL_NEW_SERVER_INSTANCE"; - public static final String IMG_CTOOL_MODIFY_MODULES = "IMG_CTOOL_MODIFY_MODULES"; - - public static final String IMG_ETOOL_RUN_ON_SERVER = "IMG_ETOOL_CLIENT"; - public static final String IMG_ETOOL_DEBUG_ON_SERVER = "IMG_ETOOL_CLIENT2"; - public static final String IMG_ETOOL_PROFILE_ON_SERVER = "IMG_ETOOL_CLIENT3"; - public static final String IMG_ETOOL_MODIFY_MODULES = "IMG_ETOOL_MODIFY_MODULES"; - public static final String IMG_ETOOL_RESET_DEFAULT = "IMG_ETOOL_RESET_DEFAULT"; - - public static final String IMG_DTOOL_RUN_ON_SERVER = "IMG_DTOOL_CLIENT"; - public static final String IMG_DTOOL_DEBUG_ON_SERVER = "IMG_DTOOL_CLIENT2"; - public static final String IMG_DTOOL_PROFILE_ON_SERVER = "IMG_DTOOL_CLIENT3"; - public static final String IMG_DTOOL_MODIFY_MODULES = "IMG_DTOOL_MODIFY_MODULES"; - public static final String IMG_DTOOL_RESET_DEFAULT = "IMG_DTOOL_RESET_DEFAULT"; - - // General Object Images - public static final String IMG_SERVER = "server"; - public static final String IMG_SERVER_CONFIGURATION_NONE = "noConfiguration"; - public static final String IMG_SERVER_CONFIGURATION_MISSING = "configurationMissing"; - public static final String IMG_PROJECT_MISSING = "projectMissing"; - public static final String IMG_REPAIR_CONFIGURATION = "repairConfiguration"; - - public static final String IMG_PUBLISH_ENABLED = "publishEnabled"; - public static final String IMG_PUBLISH_DISABLED = "publishDisabled"; - - public static final String IMG_MONITOR_ON = "monitorOn"; - public static final String IMG_MONITOR_OFF = "monitorOff"; - - public static final String IMG_DEFAULT_SERVER_OVERLAY = "defaultServerOverlay"; - - // Audio images - public static final String IMG_AUDIO_SOUND = "sound"; - public static final String IMG_AUDIO_CATEGORY = "category"; - - /** - * Cannot construct an ImageResource. Use static methods only. - */ - private ImageResource() { - // do nothing - } - - /** - * Dispose of element images that were created. - */ - protected static void dispose() { - // do nothing - } - - /** - * Return the image with the given key. - * - * @param key java.lang.String - * @return org.eclipse.swt.graphics.Image - */ - public static Image getImage(String key) { - if (imageRegistry == null) - initializeImageRegistry(); - Image image = imageRegistry.get(key); - if (image == null) { - imageRegistry.put(key, ImageDescriptor.getMissingImageDescriptor()); - image = imageRegistry.get(key); - } - return image; - } - - /** - * Return the image descriptor with the given key. - * - * @param key java.lang.String - * @return org.eclipse.jface.resource.ImageDescriptor - */ - public static ImageDescriptor getImageDescriptor(String key) { - if (imageRegistry == null) - initializeImageRegistry(); - ImageDescriptor id = imageDescriptors.get(key); - if (id != null) - return id; - - return ImageDescriptor.getMissingImageDescriptor(); - } - - /** - * Initialize the image resources. - */ - protected static void initializeImageRegistry() { - imageRegistry = new ImageRegistry(); - imageDescriptors = new HashMap<String, ImageDescriptor>(); - - // wizard banners - registerImage(IMG_WIZBAN_NEW_SERVER, URL_WIZBAN + "new_server_wiz.png"); - registerImage(IMG_WIZBAN_IMPORT_SERVER_CONFIGURATION, URL_WIZBAN + "import_configuration_wiz.png"); - registerImage(IMG_WIZBAN_SELECT_SERVER_CLIENT, URL_WIZBAN + "select_client_wiz.png"); - registerImage(IMG_WIZBAN_SELECT_SERVER, URL_WIZBAN + "select_server_wiz.png"); - - // client images - registerImage(IMG_ETOOL_RUN_ON_SERVER, URL_ETOOL + "run_on_server.gif"); - registerImage(IMG_ETOOL_DEBUG_ON_SERVER, URL_ETOOL + "debug_on_server.gif"); - registerImage(IMG_ETOOL_PROFILE_ON_SERVER, URL_ETOOL + "profile_on_server.gif"); - registerImage(IMG_ETOOL_MODIFY_MODULES, URL_ETOOL + "wiz_modify_modules.gif"); - registerImage(IMG_ETOOL_RESET_DEFAULT, URL_ETOOL + "clear.gif"); - - registerImage(IMG_CTOOL_RUN_ON_SERVER, URL_CTOOL + "run_on_server.gif"); - registerImage(IMG_CTOOL_DEBUG_ON_SERVER, URL_CTOOL + "debug_on_server.gif"); - registerImage(IMG_CTOOL_PROFILE_ON_SERVER, URL_CTOOL + "profile_on_server.gif"); - registerImage(IMG_CTOOL_NEW_SERVER, URL_CTOOL + "wiz_new_server.gif"); - registerImage(IMG_CTOOL_NEW_SERVER_INSTANCE, URL_CTOOL + "wiz_new_instance.gif"); - registerImage(IMG_CTOOL_MODIFY_MODULES, URL_CTOOL + "wiz_modify_modules.gif"); - - registerImage(IMG_DTOOL_RUN_ON_SERVER, URL_DTOOL + "run_on_server.gif"); - registerImage(IMG_DTOOL_DEBUG_ON_SERVER, URL_DTOOL + "debug_on_server.gif"); - registerImage(IMG_DTOOL_PROFILE_ON_SERVER, URL_DTOOL + "profile_on_server.gif"); - registerImage(IMG_DTOOL_MODIFY_MODULES, URL_DTOOL + "wiz_modify_modules.gif"); - registerImage(IMG_DTOOL_RESET_DEFAULT, URL_DTOOL + "clear.gif"); - - // load server state images - registerImage(IMG_SERVER_STATE_STARTED, URL_OBJ + "server_started.gif"); - registerImage(IMG_SERVER_STATE_STARTED_DEBUG, URL_OBJ + "server_started_debug.gif"); - registerImage(IMG_SERVER_STATE_STARTED_PROFILE, URL_OBJ + "server_started_profile.gif"); - registerImage(IMG_SERVER_STATE_STOPPED, URL_OBJ + "server_stopped.gif"); - - registerImage(IMG_STATE_STARTED, URL_OBJ + "state_started.gif"); - registerImage(IMG_STATE_STOPPED, URL_OBJ + "state_stopped.gif"); - - registerImage(IMG_SERVER_STATE_STARTING_1, URL_OBJ + "server_starting1.gif"); - registerImage(IMG_SERVER_STATE_STARTING_2, URL_OBJ + "server_starting2.gif"); - registerImage(IMG_SERVER_STATE_STARTING_3, URL_OBJ + "server_starting3.gif"); - - registerImage(IMG_SERVER_STATE_STOPPING_1, URL_OBJ + "server_stopping1.gif"); - registerImage(IMG_SERVER_STATE_STOPPING_2, URL_OBJ + "server_stopping2.gif"); - registerImage(IMG_SERVER_STATE_STOPPING_3, URL_OBJ + "server_stopping3.gif"); - - // load action images - registerImage(IMG_ELCL_PUBLISH, URL_ELCL + "launch_publish.gif"); - registerImage(IMG_ELCL_START, URL_ELCL + "launch_run.gif"); - registerImage(IMG_ELCL_START_DEBUG, URL_ELCL + "launch_debug.gif"); - registerImage(IMG_ELCL_START_PROFILE, URL_ELCL + "launch_profile.gif"); - registerImage(IMG_ELCL_STOP, URL_ELCL + "launch_stop.gif"); - registerImage(IMG_ELCL_DISCONNECT, URL_ELCL + "launch_disconnect.gif"); - - registerImage(IMG_CLCL_PUBLISH, URL_CLCL + "launch_publish.gif"); - registerImage(IMG_CLCL_START, URL_CLCL + "launch_run.gif"); - registerImage(IMG_CLCL_START_DEBUG, URL_CLCL + "launch_debug.gif"); - registerImage(IMG_CLCL_START_PROFILE, URL_CLCL + "launch_profile.gif"); - registerImage(IMG_CLCL_STOP, URL_CLCL + "launch_stop.gif"); - registerImage(IMG_CLCL_DISCONNECT, URL_CLCL + "launch_disconnect.gif"); - - registerImage(IMG_DLCL_PUBLISH, URL_DLCL + "launch_publish.gif"); - registerImage(IMG_DLCL_START, URL_DLCL + "launch_run.gif"); - registerImage(IMG_DLCL_START_DEBUG, URL_DLCL + "launch_debug.gif"); - registerImage(IMG_DLCL_START_PROFILE, URL_DLCL + "launch_profile.gif"); - registerImage(IMG_DLCL_STOP, URL_DLCL + "launch_stop.gif"); - registerImage(IMG_DLCL_DISCONNECT, URL_DLCL + "launch_disconnect.gif"); - - // load general object images - registerImage(IMG_SERVER, URL_OBJ + "server.gif"); - registerImage(IMG_SERVER_CONFIGURATION_NONE, URL_OBJ + "configuration_none.gif"); - registerImage(IMG_SERVER_CONFIGURATION_MISSING, URL_OBJ + "configuration_missing.gif"); - registerImage(IMG_PROJECT_MISSING, URL_OBJ + "project_missing.gif"); - registerImage(IMG_REPAIR_CONFIGURATION, URL_OBJ + "repair_config.gif"); - - registerImage(IMG_PUBLISH_ENABLED, URL_OBJ + "publish_enabled.gif"); - registerImage(IMG_PUBLISH_DISABLED, URL_OBJ + "publish_disabled.gif"); - - registerImage(IMG_MONITOR_ON, URL_OBJ + "monitorOn.gif"); - registerImage(IMG_MONITOR_OFF, URL_OBJ + "monitorOff.gif"); - - registerImage(IMG_DEFAULT_SERVER_OVERLAY, URL_OVR + "default_server_ovr.gif"); - - // audio images - registerImage(IMG_AUDIO_SOUND, URL_OBJ + "audio_sound.gif"); - registerImage(IMG_AUDIO_CATEGORY, URL_OBJ + "audio_category.gif"); - - loadServerImages(); - - PlatformUI.getWorkbench().getProgressService().registerIconForFamily( - getImageDescriptor(IMG_SERVER), ServerUtil.SERVER_JOB_FAMILY); - } - - /** - * Register an image with the registry. - * - * @param key java.lang.String - * @param partialURL java.lang.String - */ - private static void registerImage(String key, String partialURL) { - try { - ImageDescriptor id = ImageDescriptor.createFromURL(new URL(ICON_BASE_URL, partialURL)); - imageRegistry.put(key, id); - imageDescriptors.put(key, id); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error registering image " + key + " from " + partialURL, e); - } - } - - /** - * Load the server images. - */ - private static void loadServerImages() { - Trace.trace(Trace.CONFIG, "->- Loading .serverImages extension point ->-"); - IExtensionRegistry registry = Platform.getExtensionRegistry(); - loadServerImages(registry.getConfigurationElementsFor(ServerUIPlugin.PLUGIN_ID, ServerUIPlugin.EXTENSION_SERVER_IMAGES)); - ServerUIPlugin.addRegistryListener(); - Trace.trace(Trace.CONFIG, "-<- Done loading .serverImages extension point -<-"); - } - - /** - * Load the server images. - */ - private static void loadServerImages(IConfigurationElement[] cf) { - int size = cf.length; - for (int i = 0; i < size; i++) { - try { - String name = cf[i].getDeclaringExtension().getContributor().getName(); - String iconPath = cf[i].getAttribute("icon"); - ImageDescriptor imageDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin(name, iconPath); - if (imageDescriptor == null && iconPath != null && iconPath.length() > 0) - imageDescriptor = ImageDescriptor.getMissingImageDescriptor(); - - if (imageDescriptor != null) { - String[] typeIds = ServerUIPlugin.tokenize(cf[i].getAttribute("typeIds"), ","); - int size2 = typeIds.length; - for (int j = 0; j < size2; j++) { - imageRegistry.put(typeIds[j], imageDescriptor); - imageDescriptors.put(typeIds[j], imageDescriptor); - } - } - Trace.trace(Trace.CONFIG, " Loaded serverImage: " + cf[i].getAttribute("id")); - } catch (Throwable t) { - Trace.trace(Trace.SEVERE, " Could not load serverImage: " + cf[i].getAttribute("id"), t); - } - } - } - - protected static void handleServerImageDelta(IExtensionDelta delta) { - if (imageRegistry == null) // not loaded yet - return; - - IConfigurationElement[] cf = delta.getExtension().getConfigurationElements(); - - if (delta.getKind() == IExtensionDelta.ADDED) - loadServerImages(cf); - else { - int size = cf.length; - for (int i = 0; i < size; i++) { - String typeId = cf[i].getAttribute("typeIds"); - imageRegistry.remove(typeId); - imageDescriptors.remove(typeId); - } - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/InitializeJob.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/InitializeJob.java deleted file mode 100644 index de1be52e5..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/InitializeJob.java +++ /dev/null @@ -1,44 +0,0 @@ -/********************************************************************** - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - **********************************************************************/ -package org.eclipse.wst.server.ui.internal; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.ServerCore; -/** - * Job to initialize the server UI. - */ -public class InitializeJob extends Job { - /** - * Create the job. - */ - public InitializeJob() { - super(Messages.jobInitializing); - } - - /** - * @see org.eclipse.core.runtime.jobs.Job#run(IProgressMonitor) - */ - protected IStatus run(IProgressMonitor monitor) { - IServer[] servers = ServerCore.getServers(); - if (servers != null) { - int size = servers.length; - for (int i = 0; i < size; i++) { - servers[i].addServerListener(ServerUIPlugin.serverListener); - servers[i].addPublishListener(ServerUIPlugin.publishListener); - } - } - return Status.OK_STATUS; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/LaunchClientJob.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/LaunchClientJob.java deleted file mode 100644 index e231a3f55..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/LaunchClientJob.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.swt.widgets.Display; -import org.eclipse.wst.server.core.*; -import org.eclipse.wst.server.core.internal.*; -/** - * - */ -public class LaunchClientJob extends ChainedJob { - protected IModule[] module; - protected IClient client; - protected ILaunchableAdapter launchableAdapter; - protected String launchMode; - protected IModuleArtifact moduleArtifact; - - public LaunchClientJob(IServer server, IModule[] module, String launchMode, IModuleArtifact moduleArtifact, ILaunchableAdapter launchableAdapter, IClient client) { - super(Messages.launchingClientTask, server); - this.module = module; - this.launchMode = launchMode; - this.moduleArtifact = moduleArtifact; - this.launchableAdapter = launchableAdapter; - this.client = client; - setRule(server); - } - - /** (non-Javadoc) - * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) - */ - protected IStatus run(IProgressMonitor monitor) { - Trace.trace(Trace.FINER, "LaunchClient job"); - - // wait for up to 5 minutes - final Server server = (Server) getServer(); - int state = server.getModuleState(module); - int count = ServerPreferences.getInstance().getModuleStartTimeout(); - while (state == IServer.STATE_STARTING && count > 0) { - if (monitor.isCanceled()) - return Status.CANCEL_STATUS; - - try { - Thread.sleep(2000); - } catch (Exception e) { - // ignore - } - count -= 2000; - state = server.getModuleState(module); - } - - Trace.trace(Trace.FINER, "LaunchClient job 2 " + state); - - if (monitor.isCanceled()) - return Status.CANCEL_STATUS; - - if (state == IServer.STATE_STARTING) - return Status.OK_STATUS; - - Trace.trace(Trace.FINER, "LaunchClient job 3"); - - // display client on UI thread - Display.getDefault().asyncExec(new Runnable() { - public void run() { - Trace.trace(Trace.FINEST, "Attempting to load client: " + client.getId()); - try { - Object launchable = launchableAdapter.getLaunchable(server, moduleArtifact); - IStatus status = client.launch(server, launchable, launchMode, server.getLaunch()); - if (status != null && status.getSeverity() == IStatus.ERROR) - EclipseUtil.openError(null, status); - } catch (CoreException ce) { - EclipseUtil.openError(null, ce.getStatus()); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Server client failed", e); - } - } - }); - Trace.trace(Trace.FINER, "LaunchClient job 4"); - return Status.OK_STATUS; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/LaunchingPreferencePage.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/LaunchingPreferencePage.java deleted file mode 100644 index 98e57bb87..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/LaunchingPreferencePage.java +++ /dev/null @@ -1,379 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.preference.PreferencePage; -import org.eclipse.wst.server.core.internal.ServerPreferences; -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.swt.widgets.Control; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.help.IWorkbenchHelpSystem; -/** - * The preference page that holds server launching properties. - */ -public class LaunchingPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { - protected ServerPreferences preferences; - protected ServerUIPreferences uiPreferences; - - protected Button publishBeforeStart; - - protected byte saveEditors; - protected Button[] saveButtons; - protected int launchMode; - protected Button[] launchModeButtons; - protected int launchMode2; - protected Button[] launchMode2Buttons; - protected int breakpointEnablement; - protected Button[] breakpointButtons; - protected int restartEnablement; - protected Button[] restartButtons; - - /** - * ServerPreferencesPage constructor comment. - */ - public LaunchingPreferencePage() { - super(); - - preferences = ServerPreferences.getInstance(); - uiPreferences = ServerUIPlugin.getPreferences(); - } - - /** - * Create the preference options. - * - * @param parent org.eclipse.swt.widgets.Composite - * @return org.eclipse.swt.widgets.Control - */ - protected Control createContents(Composite parent) { - initializeDialogUnits(parent); - IWorkbenchHelpSystem whs = PlatformUI.getWorkbench().getHelpSystem(); - whs.setHelp(parent, ContextIds.PREF_GENERAL); - - Composite composite = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.horizontalSpacing = convertHorizontalDLUsToPixels(4); - layout.verticalSpacing = convertVerticalDLUsToPixels(4); - layout.marginWidth = 0; - layout.marginHeight = 0; - layout.numColumns = 3; - composite.setLayout(layout); - GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL); - composite.setLayoutData(data); - - publishBeforeStart = new Button(composite, SWT.CHECK); - publishBeforeStart.setText(Messages.prefAutoPublish); - data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - data.horizontalSpan = 3; - publishBeforeStart.setLayoutData(data); - publishBeforeStart.setSelection(preferences.isAutoPublishing()); - whs.setHelp(publishBeforeStart, ContextIds.PREF_GENERAL_PUBLISH_BEFORE_START); - - Label label = new Label(composite, SWT.NONE); - data = new GridData(); - data.horizontalSpan = 3; - label.setLayoutData(data); - - createSaveEditorGroup(composite); - - createLaunchModeGroup(composite); - - createLaunchMode2Group(composite); - - createBreakpointsGroup(composite); - - createRestartGroup(composite); - - setSaveEditorStatus(uiPreferences.getSaveEditors()); - setLaunchModeStatus(uiPreferences.getLaunchMode()); - setLaunchMode2Status(uiPreferences.getLaunchMode2()); - setBreakpointsStatus(uiPreferences.getEnableBreakpoints()); - setRestartStatus(uiPreferences.getRestart()); - - Dialog.applyDialogFont(composite); - - return composite; - } - - protected void createSaveEditorGroup(Composite composite) { - Group group = new Group(composite, SWT.NONE); - group.setText(Messages.prefSaveEditors); - - GridLayout layout = new GridLayout(); - layout.numColumns = 3; - group.setLayout(layout); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 3; - group.setLayoutData(data); - - String[] messages = new String[] { - Messages.prefSaveEditorsAlways, Messages.prefSaveEditorsNever, - Messages.prefSaveEditorsPrompt - }; - - final byte[] options = new byte[] { - ServerUIPreferences.SAVE_EDITORS_ALWAYS, - ServerUIPreferences.SAVE_EDITORS_NEVER, - ServerUIPreferences.SAVE_EDITORS_PROMPT - }; - - Button[] buttons = new Button[3]; - IWorkbenchHelpSystem whs = PlatformUI.getWorkbench().getHelpSystem(); - for (int i = 0; i < 3; i++) { - buttons[i] = new Button(group, SWT.RADIO); - buttons[i].setText(messages[i]); - final int b = i; - buttons[i].addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - saveEditors = options[b]; - } - }); - whs.setHelp(buttons[i], ContextIds.PREF_GENERAL_SAVE_EDITORS); - } - saveButtons = buttons; - } - - protected void setSaveEditorStatus(byte status) { - saveEditors = status; - saveButtons[0].setSelection(saveEditors == ServerUIPreferences.SAVE_EDITORS_ALWAYS); - saveButtons[1].setSelection(saveEditors == ServerUIPreferences.SAVE_EDITORS_NEVER); - saveButtons[2].setSelection(saveEditors == ServerUIPreferences.SAVE_EDITORS_PROMPT); - } - - protected void createLaunchModeGroup(Composite composite) { - Group group = new Group(composite, SWT.NONE); - group.setText(Messages.prefLaunchMode); - - GridLayout layout = new GridLayout(); - layout.numColumns = 3; - group.setLayout(layout); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 3; - group.setLayoutData(data); - - String[] messages = new String[] { - Messages.prefLaunchModeRestart, Messages.prefLaunchModeContinue, - Messages.prefLaunchModePrompt - }; - - final byte[] options = new byte[] { - ServerUIPreferences.LAUNCH_MODE_RESTART, - ServerUIPreferences.LAUNCH_MODE_CONTINUE, - ServerUIPreferences.LAUNCH_MODE_PROMPT - }; - - Button[] buttons = new Button[3]; - IWorkbenchHelpSystem whs = PlatformUI.getWorkbench().getHelpSystem(); - for (int i = 0; i < 3; i++) { - buttons[i] = new Button(group, SWT.RADIO); - buttons[i].setText(messages[i]); - final int b = i; - buttons[i].addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - launchMode = options[b]; - } - }); - whs.setHelp(buttons[i], ContextIds.PREF_GENERAL_LAUNCH_MODE); - } - launchModeButtons = buttons; - } - - protected void setLaunchModeStatus(int mode) { - launchMode = mode; - launchModeButtons[0].setSelection(launchMode == ServerUIPreferences.LAUNCH_MODE_RESTART); - launchModeButtons[1].setSelection(launchMode == ServerUIPreferences.LAUNCH_MODE_CONTINUE); - launchModeButtons[2].setSelection(launchMode == ServerUIPreferences.LAUNCH_MODE_PROMPT); - } - - protected void createLaunchMode2Group(Composite composite) { - Group group = new Group(composite, SWT.NONE); - group.setText(Messages.prefLaunchMode2); - - GridLayout layout = new GridLayout(); - layout.numColumns = 4; - group.setLayout(layout); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 3; - group.setLayoutData(data); - - String[] messages = new String[] { - Messages.prefLaunchMode2Restart, Messages.prefLaunchMode2Breakpoints, - Messages.prefLaunchMode2Continue, Messages.prefLaunchMode2Prompt - }; - - final byte[] options = new byte[] { - ServerUIPreferences.LAUNCH_MODE2_RESTART, - ServerUIPreferences.LAUNCH_MODE2_DISABLE_BREAKPOINTS, - ServerUIPreferences.LAUNCH_MODE2_CONTINUE, - ServerUIPreferences.LAUNCH_MODE2_PROMPT - }; - - Button[] buttons = new Button[4]; - IWorkbenchHelpSystem whs = PlatformUI.getWorkbench().getHelpSystem(); - for (int i = 0; i < 4; i++) { - buttons[i] = new Button(group, SWT.RADIO); - buttons[i].setText(messages[i]); - final int b = i; - buttons[i].addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - launchMode2 = options[b]; - } - }); - whs.setHelp(buttons[i], ContextIds.PREF_GENERAL_LAUNCH_MODE_DEBUG); - } - launchMode2Buttons = buttons; - } - - protected void setLaunchMode2Status(int mode) { - launchMode2 = mode; - launchMode2Buttons[0].setSelection(launchMode2 == ServerUIPreferences.LAUNCH_MODE2_RESTART); - launchMode2Buttons[1].setSelection(launchMode2 == ServerUIPreferences.LAUNCH_MODE2_DISABLE_BREAKPOINTS); - launchMode2Buttons[2].setSelection(launchMode2 == ServerUIPreferences.LAUNCH_MODE2_CONTINUE); - launchMode2Buttons[3].setSelection(launchMode2 == ServerUIPreferences.LAUNCH_MODE2_PROMPT); - } - - protected void createBreakpointsGroup(Composite composite) { - Group group = new Group(composite, SWT.NONE); - group.setText(Messages.prefBreakpoints); - - GridLayout layout = new GridLayout(); - layout.numColumns = 3; - group.setLayout(layout); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 3; - group.setLayoutData(data); - - String[] messages = new String[] { - Messages.prefBreakpointsAlways, Messages.prefBreakpointsNever, - Messages.prefBreakpointsPrompt - }; - - final byte[] options = new byte[] { - ServerUIPreferences.ENABLE_BREAKPOINTS_ALWAYS, - ServerUIPreferences.ENABLE_BREAKPOINTS_NEVER, - ServerUIPreferences.ENABLE_BREAKPOINTS_PROMPT - }; - - Button[] buttons = new Button[3]; - IWorkbenchHelpSystem whs = PlatformUI.getWorkbench().getHelpSystem(); - for (int i = 0; i < 3; i++) { - buttons[i] = new Button(group, SWT.RADIO); - buttons[i].setText(messages[i]); - final int b = i; - buttons[i].addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - breakpointEnablement = options[b]; - } - }); - whs.setHelp(buttons[i], ContextIds.PREF_GENERAL_ENABLE_BREAKPOINTS); - } - breakpointButtons = buttons; - } - - protected void setBreakpointsStatus(int mode) { - breakpointEnablement = mode; - breakpointButtons[0].setSelection(breakpointEnablement == ServerUIPreferences.ENABLE_BREAKPOINTS_ALWAYS); - breakpointButtons[1].setSelection(breakpointEnablement == ServerUIPreferences.ENABLE_BREAKPOINTS_NEVER); - breakpointButtons[2].setSelection(breakpointEnablement == ServerUIPreferences.ENABLE_BREAKPOINTS_PROMPT); - } - - protected void createRestartGroup(Composite composite) { - Group group = new Group(composite, SWT.NONE); - group.setText(Messages.prefRestart); - - GridLayout layout = new GridLayout(); - layout.numColumns = 3; - group.setLayout(layout); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 3; - group.setLayoutData(data); - - String[] messages = new String[] { - Messages.prefRestartAlways, Messages.prefRestartNever, Messages.prefRestartPrompt - }; - - final byte[] options = new byte[] { - ServerUIPreferences.RESTART_ALWAYS, - ServerUIPreferences.RESTART_NEVER, - ServerUIPreferences.RESTART_PROMPT - }; - - Button[] buttons = new Button[3]; - IWorkbenchHelpSystem whs = PlatformUI.getWorkbench().getHelpSystem(); - for (int i = 0; i < 3; i++) { - buttons[i] = new Button(group, SWT.RADIO); - buttons[i].setText(messages[i]); - final int b = i; - buttons[i].addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - restartEnablement = options[b]; - } - }); - whs.setHelp(buttons[i], ContextIds.PREF_GENERAL_RESTART); - } - restartButtons = buttons; - } - - protected void setRestartStatus(int mode) { - restartEnablement = mode; - restartButtons[0].setSelection(restartEnablement == ServerUIPreferences.RESTART_ALWAYS); - restartButtons[1].setSelection(restartEnablement == ServerUIPreferences.RESTART_NEVER); - restartButtons[2].setSelection(restartEnablement == ServerUIPreferences.RESTART_PROMPT); - } - - /** - * Initializes this preference page using the passed workbench. - * - * @param workbench the current workbench - */ - public void init(IWorkbench workbench) { - // do nothing - } - - /** - * Performs special processing when this page's Defaults button has been pressed. - */ - protected void performDefaults() { - publishBeforeStart.setSelection(preferences.isDefaultAutoPublishing()); - - setSaveEditorStatus(uiPreferences.getDefaultSaveEditors()); - setLaunchModeStatus(uiPreferences.getDefaultLaunchMode()); - setLaunchMode2Status(uiPreferences.getDefaultLaunchMode2()); - setBreakpointsStatus(uiPreferences.getDefaultEnableBreakpoints()); - setRestartStatus(uiPreferences.getDefaultRestart()); - - super.performDefaults(); - } - - /** - * @see org.eclipse.jface.preference.IPreferencePage#performOk() - */ - public boolean performOk() { - preferences.setAutoPublishing(publishBeforeStart.getSelection()); - uiPreferences.setSaveEditors(saveEditors); - uiPreferences.setLaunchMode(launchMode); - uiPreferences.setLaunchMode2(launchMode2); - uiPreferences.setEnableBreakpoints(breakpointEnablement); - uiPreferences.setRestart(restartEnablement); - - return true; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/MarkerResolutionGenerator.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/MarkerResolutionGenerator.java deleted file mode 100644 index f45a073fa..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/MarkerResolutionGenerator.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal; - -import org.eclipse.core.resources.IMarker; -import org.eclipse.ui.IMarkerResolution; -import org.eclipse.ui.IMarkerResolutionGenerator2; - -public class MarkerResolutionGenerator implements IMarkerResolutionGenerator2 { - public boolean hasResolutions(IMarker marker) { - return true; - } - - public IMarkerResolution[] getResolutions(IMarker marker) { - return new IMarkerResolution[] { new RuntimeMarkerResolution() }; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.java deleted file mode 100644 index 55b7ce1cd..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.java +++ /dev/null @@ -1,366 +0,0 @@ -/********************************************************************** - * Copyright (c) 2005, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - **********************************************************************/ -package org.eclipse.wst.server.ui.internal; - -import org.eclipse.osgi.util.NLS; -/** - * Translated messages. - */ -public class Messages extends NLS { - public static String dialogMonitorDescription; - public static String dialogMonitorAddDescription; - public static String errorVersionLevel; - public static String loadingTask; - public static String createServerProjectDialogMessage; - public static String defaultServerProjectName; - public static String terminateServerDialogMessage; - public static String actionMonitorPort; - public static String deleteServerDialogTitle; - public static String deleteServerDialogMessage; - public static String deleteServerDialogMessageMany; - public static String deleteServerDialogLooseConfigurations; - public static String deleteServerDialogRunningServer; - public static String deleteServerDialogRunningServerStop; - public static String deleteServerTask; - public static String errorCouldNotCreateServerProjectStatus; - public static String savingTask; - public static String editorSaveErrorDialog; - public static String editorSaveErrorMessage; - public static String editorReadOnlyFiles; - public static String errorEditor; - public static String editorUndoDisabled; - public static String editorUndoEnabled; - public static String editorRedoDisabled; - public static String editorRedoEnabled; - public static String editorResourceDeleteTitle; - public static String editorResourceDeleteServerMessage; - public static String editorResourceDeleteSave; - public static String resourceDirtyDialogMessage; - public static String wizSelectClientTitle; - public static String wizSelectClientDescription; - public static String resourceDirtyDialogTitle; - public static String resourceDirtyDialogContinue; - public static String wizNewRuntimeWizardTitle; - public static String serverLaunchDescription; - public static String serverLaunchServer; - public static String serverLaunchHost; - public static String serverLaunchRuntime; - public static String errorNoServerSelected; - public static String errorServerAlreadyRunning; - public static String errorInvalidServer; - public static String serverLaunchConfigurationTab; - public static String runOnServerLaunchConfigName; - public static String wizSelectClientMessage; - public static String errorCouldNotCreateServerProject; - public static String errorDialogTitle; - public static String editorValidateEditFailureMessage; - public static String prefProjectNotModule; - public static String prefProject; - public static String prefProjectDefaultServer; - public static String prefProjectNotConfigured; - public static String prefProjectNoServer; - public static String propServerInfoName; - public static String propServerInfoType; - public static String propServerInfoVendor; - public static String toolTipEnableFocus; - public static String toolTipDisableFocus; - public static String errorCouldNotSavePreference; - public static String preferenceRuntimesDescription; - public static String add; - public static String edit; - public static String remove; - public static String search; - public static String dialogRuntimeSearchMessage; - public static String dialogRuntimeSearchTitle; - public static String dialogRuntimeSearchProgress; - public static String infoNoRuntimesFound; - public static String wizEditRuntimeWizardTitle; - public static String preferenceRuntimesTable; - public static String dialogRuntimeInUse; - public static String dialogRuntimeDeleteServers; - public static String dialogRuntimeRemoveTargets; - public static String defaultDialogTitle; - public static String preferenceRuntimesTitleLong; - public static String prefAutoPublish; - public static String prefLaunchMode; - public static String prefLaunchModeRestart; - public static String prefLaunchModeContinue; - public static String prefLaunchModePrompt; - public static String prefLaunchMode2; - public static String prefLaunchMode2Restart; - public static String prefLaunchMode2Continue; - public static String prefLaunchMode2Breakpoints; - public static String prefLaunchMode2Prompt; - public static String prefBreakpoints; - public static String prefBreakpointsAlways; - public static String prefBreakpointsNever; - public static String prefBreakpointsPrompt; - public static String prefRestart; - public static String prefRestartAlways; - public static String prefRestartNever; - public static String prefRestartPrompt; - public static String prefShowOnActivity; - public static String prefSaveEditors; - public static String prefSaveEditorsAlways; - public static String prefSaveEditorsNever; - public static String prefSaveEditorsPrompt; - public static String actionNew; - public static String actionNewServer; - public static String actionProperties; - public static String actionOpen; - public static String actionShowIn; - public static String actionCopy; - public static String actionPaste; - public static String actionDebugToolTip; - public static String actionDebug; - public static String actionDebugRestart; - public static String actionDebugRestartToolTip; - public static String actionStartToolTip; - public static String actionStart; - public static String actionProfileToolTip; - public static String actionProfile; - public static String actionProfileRestart; - public static String actionProfileRestartToolTip; - public static String actionRestartToolTip; - public static String actionRestart; - public static String actionPublishToolTip; - public static String actionPublish; - public static String actionPublishCleanToolTip; - public static String actionPublishClean; - public static String actionRename; - public static String actionDelete; - public static String actionRemove; - public static String dialogRemoveModuleConfirm; - public static String terminateServerDialogTitle; - public static String actionDebugOnServer; - public static String actionProfileOnServer; - public static String actionRunOnServer; - public static String processName; - public static String actionStopModule; - public static String actionStartModule; - public static String actionRestartModule; - public static String actionSwitchServerLocation; - public static String switchServerLocation; - public static String switchServerLocationMetadata; - public static String dialogAddRemoveModulesNone; - public static String actionSetNewServer; - public static String errorNoArtifact; - public static String errorNoModules; - public static String errorLaunchConfig; - public static String dialogModeWarningRun; - public static String dialogModeWarningDebug; - public static String dialogModeWarningProfile; - public static String dialogModeWarningRestart; - public static String dialogModeWarningBreakpoints; - public static String dialogModeWarningContinue; - public static String dialogBreakpoints; - public static String dialogBreakpointsReenable; - public static String dialogBreakpointsContinue; - public static String dialogRemember; - public static String dialogRestart; - public static String dialogRestartRestart; - public static String dialogRestartContinue; - public static String dialogPublishClean; - public static String errorNoServer; - public static String errorRootModule; - public static String hostname; - public static String wizModuleTitle; - public static String wizModuleDescription; - public static String wizModuleMessage; - public static String wizModuleAvailableList; - public static String wizModuleDeployedList; - public static String wizModuleAdd; - public static String wizModuleRemove; - public static String wizModuleAddAll; - public static String wizModuleRemoveAll; - public static String wizModuleRequiredModule; - public static String wizModuleRequiredModules; - public static String wizModulePublishImmediately; - public static String wizTaskTitle; - public static String wizTaskDescription; - public static String wizErrorInvalidFolder; - public static String wizErrorClosedProject; - public static String createServerProjectDialogTitle; - public static String wizNewServerTitle; - public static String wizNewServerDescription; - public static String wizNewServerRunOnServerDescription; - public static String wizNewServerSelect; - public static String wizNewServerManual; - public static String wizSelectServerPreferred; - public static String wizNewServerExisting; - public static String wizNewServerRuntime; - public static String wizNewServerRuntimeCreate; - public static String wizErrorServerCreationError; - public static String wizRunOnServerTitle; - public static String wizDebugOnServerTitle; - public static String wizProfileOnServerTitle; - public static String wizModuleArtifactsDescription; - public static String wizModuleArtifactsAvailableList; - public static String wizModuleArtifactsNoSelectionError; - public static String wizNewRuntimeTitle; - public static String wizNewRuntimeDescription; - public static String wizNewRuntimeCreateServer; - public static String performingTasks; - public static String wizModuleWizardTitle; - public static String wizNewServerWizardTitle; - public static String wizSelectClientWizardTitle; - public static String wizTaskWizardTitle; - public static String dialogMonitorTitle; - public static String dialogMonitorMonitorPort; - public static String dialogMonitorColumnStatus; - public static String dialogMonitorColumnType; - public static String dialogMonitorColumnPort; - public static String dialogMonitorColumnMonitorPort; - public static String dialogMonitorColumnContentType; - public static String dialogMonitorContentType; - public static String dialogMonitorContentTypeAll; - public static String dialogMonitorContentTypeWeb; - public static String dialogMonitorContentTypeWebServices; - public static String dialogMonitorNone; - public static String start; - public static String stop; - public static String started; - public static String stopped; - public static String columnName; - public static String columnType; - public static String runtimeTypeCompTree; - public static String configureRuntimes; - public static String addRuntime; - public static String wizNewServerSelectExisting; - public static String elementUnknownName; - public static String serverTypeCompLabel; - public static String serverName; - public static String serverNameDefault; - public static String viewServers; - public static String viewNoModules; - public static String viewServer; - public static String viewStatus; - public static String viewState; - public static String actionStopToolTip; - public static String actionStop; - public static String actionModifyModulesToolTip; - public static String actionModifyModules; - public static String actionMonitor; - public static String viewInitializing; - public static String viewSyncOkay; - public static String viewSyncRestart; - public static String viewSyncPublish; - public static String viewSyncRestartPublish; - public static String viewSyncPublishing; - public static String viewSyncOkay2; - public static String viewSyncRestart2; - public static String viewSyncPublish2; - public static String viewSyncRestartPublish2; - public static String viewSyncPublishing2; - public static String editorServerEditor; - public static String editorPromptIrreversible; - public static String editorRenameFiles; - public static String errorEditorCantSave; - public static String errorDuplicateName; - public static String editorReadOnly; - public static String editorWritable; - public static String editorResourceModifiedTitle; - public static String editorReadOnlyMessage; - public static String editorServerModifiedMessage; - public static String editorResourceWarnTitle; - public static String editorResourceWarnMessage; - public static String serverEditorOverviewPageTitle; - public static String serverEditorOverviewGeneralSection; - public static String serverEditorOverviewGeneralDescription; - public static String serverEditorOverviewServerName; - public static String serverEditorOverviewServerHostname; - public static String serverEditorOverviewRuntime; - public static String serverEditorOverviewRuntimeEdit; - public static String serverEditorOverviewServerConfigurationPath; - public static String serverEditorOverviewServerConfigurationBrowse; - public static String serverEditorOverviewServerConfigurationBrowseMessage; - public static String serverEditorOverviewPublishSection; - public static String serverEditorOverviewPublishDescription; - public static String serverEditorOverviewAutoPublishDisable; - public static String serverEditorOverviewAutoPublishEnabled; - public static String serverEditorOverviewAutoPublishEnabledInterval; - public static String serverEditorOverviewPublishCommand; - public static String serverEditorOverviewTimeoutSection; - public static String serverEditorOverviewTimeoutDescription; - public static String serverEditorOverviewTimeoutCommand; - public static String serverEditorOverviewPublishers; - public static String serverEditorOverviewStartTimeout; - public static String serverEditorOverviewStopTimeout; - public static String serverEditorOverviewServerHostnameCommand; - public static String serverEditorOverviewServerNameCommand; - public static String serverEditorOverviewRuntimeCommand; - public static String serverEditorOverviewOpenLaunchConfiguration; - public static String errorMissingConfiguration; - public static String errorConfigurationNotAccessible; - public static String viewStatusStarting4; - public static String viewStatusStarted2; - public static String viewStatusStopping4; - public static String viewStatusStopped2; - public static String viewStatusStarting; - public static String viewStatusStarting1; - public static String viewStatusStarting2; - public static String viewStatusStarting3; - public static String viewStatusStopping; - public static String viewStatusStopping1; - public static String viewStatusStopping2; - public static String viewStatusStopping3; - public static String viewStatusStartedDebug; - public static String viewStatusStartedProfile; - public static String viewStatusStarted; - public static String viewStatusStopped; - public static String actionStopToolTip2; - public static String actionStop2; - public static String launchingClientTask; - public static String wizNewInstallableServerTitle; - public static String wizNewInstallableServerDescription; - public static String wizNewInstallableServerMessage; - public static String wizNewInstallableServerConfirm; - public static String wizNewInstallableServerJob; - public static String wizNewInstallableServerRestart; - public static String wizNewInstallableServerSiteError; - public static String installableServerCompTree; - public static String installableServerLink; - public static String installableServerLocal; - public static String installableServerSearching; - public static String wizLicenseTitle; - public static String wizLicenseDescription; - public static String wizLicenseAccept; - public static String wizLicenseDecline; - public static String wizLicenseNone; - public static String jobInitializing; - public static String jobInitializingServersView; - public static String jobRestarting; - public static String clientDefaultName; - public static String clientDefaultDescription; - public static String moduleDecoratorProject; - public static String minutes; - public static String modules; - - public static String errorStartingMonitor; - public static String audioPrefSelectFile; - public static String audioPrefEnable; - public static String audioPrefVolume; - public static String audioPrefSounds; - public static String audioPrefSound; - public static String audioPrefFile; - public static String audioPrefPlay; - public static String audioPrefBrowse; - public static String audioPrefReset; - public static String audioUnknown; - public static String audioNone; - public static String audioDefault; - - public static String internalWebBrowserName; - - static { - NLS.initializeMessages(ServerUIPlugin.PLUGIN_ID + ".internal.Messages", Messages.class); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.properties b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.properties deleted file mode 100644 index 136eea8c5..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.properties +++ /dev/null @@ -1,509 +0,0 @@ -############################################################################### -# Copyright (c) 2004, 2008 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### - -# --------------- Wizards --------------- -# (If the first two lines in a group do not start with "wiz", it is because -# those lines are displayed in the workbench "New" wizard. The rest of the -# text is displayed in each actual wizard) - -# New Server (and Configuration) Wizard -wizNewServerWizardTitle=New Server -wizNewServerTitle=Define a New Server -wizNewServerDescription=Choose the type of server to create -wizNewServerRunOnServerDescription=Select which server to use -wizNewServerRuntime=Server &runtime environment: -wizNewServerRuntimeCreate=Create a new runtime environment - -wizNewServerSelect=How do you want to select the server? -wizNewServerExisting=Choose an e&xisting server -wizNewServerManual=&Manually define a new server -wizNewServerSelectExisting=Select the server that you want to use: - -# Select Server wizard -wizRunOnServerTitle=Run On Server -wizDebugOnServerTitle=Debug On Server -wizProfileOnServerTitle=Profile On Server -wizSelectServerPreferred=Always use this server when running this &project - -# Select Server Client Wizard -wizSelectClientWizardTitle=Select a Server Client -wizSelectClientTitle=Select a server client -wizSelectClientDescription=Select a client to use with this server. -wizSelectClientMessage=Multiple clients can run on the current selection. Select a client from the list below: - -# Select ModuleArtifact Wizard -wizModuleArtifactsDescription=Specify how to start the selected resource. -wizModuleArtifactsAvailableList=Available launchers: -wizModuleArtifactsNoSelectionError=You must select a launcher. - -# Task Wizard -wizTaskWizardTitle=Select Tasks -wizTaskTitle=Select Tasks -wizTaskDescription=Select the tasks to perform on the server. - -# New Runtime Wizard -wizNewRuntimeWizardTitle=New Server Runtime Environment -wizNewRuntimeTitle=New Server Runtime Environment -wizNewRuntimeDescription=Define a new server runtime environment -wizNewRuntimeCreateServer=&Create a new local server -wizEditRuntimeWizardTitle=Edit Server Runtime Environment - -# New Server Adapter Wizard -wizNewInstallableServerTitle=Install New Server Adapter -wizNewInstallableServerDescription=Download and install support for a new server -wizNewInstallableServerMessage=The following server adapters have been found on remote update manager sites. Select a server adapter to download and install. -wizNewInstallableServerConfirm=Support for {0} will now be downloaded and installed. You will be prompted to restart once the installation is complete. -wizNewInstallableServerJob=Installing {0} -wizNewInstallableServerRestart=Installation complete. The new server will not be available until after the workbench is restarted. Do you want to restart now? -wizNewInstallableServerSiteError=Could not connect to {0} - -# License wizard -wizLicenseTitle=Feature License -wizLicenseDescription=This license must be accepted before proceeding with the installation. -wizLicenseAccept=I &accept the terms of the license agreement -wizLicenseDecline=I &do not accept the terms of the license agreement -wizLicenseNone=Feature does not contain a license. - -# Add/Remove Modules -wizModuleWizardTitle=Add and Remove... -wizModuleTitle=Add and Remove -wizModuleDescription=Modify the resources that are configured on the server -wizModuleMessage=Move resources to the right to configure them on the server -wizModuleAvailableList=&Available: -wizModuleDeployedList=&Configured: -wizModuleAdd=A&dd > -wizModuleAddAll=Add A&ll >> -wizModuleRemove=< &Remove -wizModuleRemoveAll=<< Re&move All -wizModuleRequiredModule={0} is required and cannot be removed from the server -wizModuleRequiredModules=One of the required modules ({0}) must be added to the server -wizModulePublishImmediately=If server is started, publish changes &immediately - -# Wizard info and error messages -wizErrorInvalidFolder=The folder must be a server project or a folder within a server project -wizErrorClosedProject=The folder must not be in a closed project -wizErrorServerCreationError=Cannot create a server using the selected type - - -# --------------- Views --------------- - -# --- Server Configuration view --- -viewServers=Servers - -viewNoModules=Nothing deployed - -# Actions -actionDelete=Delete -actionRemove=Remove -actionOpen=Open -actionShowIn=Show In -actionCopy=Copy -actionPaste=Paste -actionMonitor=Monitorin&g -actionMonitorPort=Monitor port {0} ({1}) -actionProperties=Properties -actionNew=Ne&w -actionNewServer=Server - -# --- Servers view --- -viewInitializing=Initializing... - -# Column titles -viewServer=Server -viewStatus=Status -viewState=State - -# Actions -actionStart=&Start -actionStartToolTip=Start the server -actionDebug=&Debug -actionDebugToolTip=Start the server in debug mode -actionDebugRestart=Restart in Debug -actionDebugRestartToolTip=Restart the server in debug mode -actionProfile=Pro&file -actionProfileToolTip=Start the server in profiling mode -actionProfileRestart=Restart in Profile -actionProfileRestartToolTip=Restart the server in profiling mode -actionStop=S&top -actionStopToolTip=Stop the server -actionRestart=&Restart -actionRestartToolTip=Restart the server -actionPublish=Publish -actionPublishToolTip=Publish to the server -actionPublishClean=&Clean... -actionPublishCleanToolTip=Clean resources on the server -actionModifyModules=&Add and Remove... -actionModifyModulesToolTip=Add and Remove resources to the server -actionRestartModule=&Restart -actionStartModule=&Start -actionStopModule=S&top -actionSwitchServerLocation=Switch Location -switchServerLocation=Location: -switchServerLocationMetadata=[workspace metadata] -actionRename=Re&name - -# Status column text -viewStatusStarted=Started -viewStatusStartedDebug=Debugging -viewStatusStartedProfile=Profiling -viewStatusStopped=Stopped - -viewStatusStarting=Starting -viewStatusStarting1=Starting. -viewStatusStarting2=Starting.. -viewStatusStarting3=Starting... - -viewStatusStopping=Stopping -viewStatusStopping1=Stopping. -viewStatusStopping2=Stopping.. -viewStatusStopping3=Stopping... - -# Server State text -viewSyncOkay=Synchronized -viewSyncRestart=Restart -viewSyncPublish=Republish -viewSyncRestartPublish=Restart & republish -viewSyncPublishing=Publishing... - -# --- set 2 --- -# Actions -actionStop2=Disconnect -actionStopToolTip2=Disconnect from the server - -# Status column text -viewStatusStarting4=Connecting -viewStatusStarted2=Connected -viewStatusStopping4=Disconnecting -viewStatusStopped2=Disconnected - -# Server State text -viewSyncOkay2=Synchronized -viewSyncRestart2=Reconnect -viewSyncPublish2=Republish -viewSyncRestartPublish2=Reconnect and republish -viewSyncPublishing2=Publishing... - - -# --------------- Action Sets (toolbar icon groups) --------------- - -# Servers action set -actionSetNewServer=Create Server - -# Run on Server actions -actionRunOnServer=Run on Server... -actionDebugOnServer=Debug on Server... -actionProfileOnServer=Profile on Server... -processName=Run on Server - - -# --------------- Preferences --------------- - -# Names of the preference pages -preferenceRuntimesTitleLong=Server Runtime Environments - -# Server preferences -prefAutoPublish=Automatically publish w&hen starting servers -prefShowOnActivity=Show &Servers view when server state changes - -prefSaveEditors=Save dirty editors before starting the server -prefSaveEditorsAlways=A&lways -prefSaveEditorsNever=&Never -prefSaveEditorsPrompt=&Prompt - -prefLaunchMode=When switching to a different server mode -prefLaunchModeRestart=Re&start -prefLaunchModeContinue=&Continue -prefLaunchModePrompt=P&rompt - -prefLaunchMode2=When switching the server out of debug mode -prefLaunchMode2Restart=Rest&art -prefLaunchMode2Breakpoints=Disable &breakpoints -prefLaunchMode2Continue=Contin&ue -prefLaunchMode2Prompt=Pr&ompt - -prefBreakpoints=When switching the server into debug mode, re-enable breakpoints -prefBreakpointsAlways=Al&ways -prefBreakpointsNever=N&ever -prefBreakpointsPrompt=Pro&mpt - -prefRestart=When required, restart the server -prefRestartAlways=Alwa&ys -prefRestartNever=Ne&ver -prefRestartPrompt=Promp&t - -# Project properties preferences -prefProject=Project: -prefProjectDefaultServer=Always use the &following server when running this project: -prefProjectNotModule=This project cannot be used with servers. -prefProjectNotConfigured=This project is not associated with any servers. -prefProjectNoServer=<None> - -propServerInfoName=Name: -propServerInfoType=Type: -propServerInfoVendor=Vendor: - -# Tooltip -toolTipEnableFocus=Press 'F6' for Focus. -toolTipDisableFocus=Press 'ESC' to Hide. - -# Runtime Environments -preferenceRuntimesDescription=Add, remove, or edit server runtime environments. -preferenceRuntimesTable=Server runtime e&nvironments: - - -# --------------- Tasks (progress monitors) --------------- - -# General tasks -savingTask=Saving {0}. -loadingTask=Loading {0}. -performingTasks=Performing tasks. -launchingClientTask=Launching client -jobInitializing=Initializing Server Tools -jobRestarting=Restarting {0} -jobInitializingServersView=Initializing Servers view - -# --------------- Dialogs --------------- - -# Delete Server dialog -deleteServerDialogTitle=Delete Server -deleteServerDialogMessage=Are you sure you want to delete {0}? -deleteServerDialogMessageMany=Are you sure you want to delete the {0} servers? -deleteServerDialogLooseConfigurations=Delete unused server configuration(s) -deleteServerDialogRunningServer=Delete running server(s) -deleteServerDialogRunningServerStop=Stop server(s) before deleting -deleteServerTask=Deleting server(s)... - -# Create Server Project dialog -createServerProjectDialogTitle=Create Server Project -createServerProjectDialogMessage=Do you want to create a new server project with the name {0}? - -# Terminate Server dialog -terminateServerDialogTitle=Terminate Server -terminateServerDialogMessage=Server {0} is not responding. Do you want to terminate this server? Click OK to terminate the server or click Cancel to continue waiting. - -# Server resource dirty dialog -resourceDirtyDialogTitle=Server Resource Dirty -resourceDirtyDialogMessage=The server resource {0} has unsaved changes. Do you want to continue? -resourceDirtyDialogContinue=Continue - -# General dialogs -defaultDialogTitle=Server -dialogRemember=&Remember my decision - -# restart warning dialog -dialogModeWarningRun=The server is not in run mode. Select from one of the following options: -dialogModeWarningDebug=The server is not running in debug mode. Select from one of the following options: -dialogModeWarningProfile=The server is not running in profiling mode. Select from one of the following options: -dialogModeWarningRestart=&Switch mode (will restart if necessary) -dialogModeWarningBreakpoints=Disable &breakpoints and continue -dialogModeWarningContinue=&Continue in the current mode - -dialogBreakpoints=The server is running in debug mode but breakpoints have been disabled. Select from one of the following options: -dialogBreakpointsReenable=Re-&enable breakpoints -dialogBreakpointsContinue=&Continue without debugging - -dialogRestart=The server may need be restarted. Do you want to restart the server? -dialogRestartRestart=Re&start server -dialogRestartContinue=&Continue without restarting - -# Monitor dialog -dialogMonitorTitle=Monitoring Ports -dialogMonitorDescription=The following ports are being monitored on server {0}: -dialogMonitorAddDescription=The server {0} has the following ports that can be monitored: -dialogMonitorColumnPort=Server Port -dialogMonitorColumnType=Type -dialogMonitorColumnMonitorPort=Monitor Port -dialogMonitorColumnContentType=Content Type -dialogMonitorColumnStatus=Status -dialogMonitorMonitorPort=Monitor port: -dialogMonitorContentType=Content type: -dialogMonitorContentTypeAll=All -dialogMonitorContentTypeWeb=Web -dialogMonitorContentTypeWebServices=WebServices -dialogMonitorNone=<none> - -dialogPublishClean=Clean will discard all publish state and republish from scratch. Are you sure you want to clean all published resources? - -start=Start -stop=Stop -started=Started -stopped=Stopped - -# Confirm runtime removal -dialogRuntimeInUse=The runtime environment is currently being used and deleting it will cause compilation or run time problems. Delete the runtime environment anyway? -dialogRuntimeDeleteServers=Delete all affected servers? -dialogRuntimeRemoveTargets=Remove this runtime environment from targeted projects? - -# runtime locator search dialog -dialogRuntimeSearchTitle=Search For Runtime Environments -dialogRuntimeSearchMessage=Select the directory in which to search for server runtime environments: -dialogRuntimeSearchProgress=Searching for server runtime environments... - -# Can't add remove -dialogAddRemoveModulesNone=There are no resources that can be added or removed from the server. - -dialogRemoveModuleConfirm=Are you sure you want to remove the resource from the server? - -# --------------- Misc UI --------------- - -# runtime composite -runtimeTypeCompTree=Select the type of &runtime environment: -serverTypeCompLabel=Select the &server type: -serverName=Server na&me: -serverNameDefault=Rese&t default -configureRuntimes=&Configure runtime environments... -addRuntime=&Add... - -# installable server composite -installableServerCompTree=Select the &server support to install: -installableServerLink=Download additional server adapters -installableServerLocal=Examining local configuration -installableServerSearching=Searching {0} - -# misc composites -hostname=Server's &host name: - -# Server launch configuration tab -serverLaunchDescription=This launch configuration can be used to launch the server specified below. To access further options for configuring the server, open the server's editor from the Servers view. -serverLaunchConfigurationTab=Server -serverLaunchServer=Server: -serverLaunchRuntime=Runtime Environment: -serverLaunchHost=Host name: -runOnServerLaunchConfigName={0} - -# Error Messages -errorDialogTitle=Server Error -errorServerAlreadyRunning=Server already running -errorNoServerSelected=No server selected -errorInvalidServer=The server is invalid or missing -errorCouldNotCreateServerProject=Could not create server project -errorCouldNotCreateServerProjectStatus=Could not create server project: {0} -errorNoArtifact=The selection did not contain any resources that can run on a server. -errorLaunchConfig=This launch configuration is invalid and may be out of sync with the workspace -errorNoModules=The selection is not within a valid module. -errorNoServer=The selection cannot be run on any server. -errorCouldNotSavePreference=Could not save server preference information. -errorEditorCantSave=The server cannot be saved for the following reasons: -errorEditor=Could not open editor because {0} is not a valid server. Use Open With to open this file with a different editor. -errorVersionLevel=The server does not support version {1} of the {0} specification. -errorMissingConfiguration=The server configuration is missing or invalid -errorConfigurationNotAccessible=The server configuration is not accessible. The {0} project is closed. -errorRootModule=Could not find a valid parent module to add to the server. -errorDuplicateName=The name is already in use. Specify a different name. - -# Info messages -infoNoRuntimesFound=No new server runtime environments were found. - -# Default server creation names -# {0} will be replaced by a number if the given name is already being used -defaultServerProjectName=Servers{0} - -# Used when a name can't be found -elementUnknownName=<unknown> - -columnName=Name -columnType=Type - -add=&Add... -edit=&Edit... -remove=&Remove -search=&Search... - -clientDefaultName=Do nothing -clientDefaultDescription=Launch the module on the server but do not bring up a client application. - -# Module decorator -moduleDecoratorProject={0} ({1}) - -# Used for displaying time (so far only used in tooltip) -minutes={0} minutes -modules={0} modules - -# --------------- Editor support --------------- - -serverEditorOverviewPageTitle=Overview -serverEditorOverviewGeneralSection=General Information -serverEditorOverviewGeneralDescription=Specify the host name and other common settings. -serverEditorOverviewServerName=Server name: -serverEditorOverviewServerNameCommand=set server name -serverEditorOverviewServerConfigurationPath=Configuration path: -serverEditorOverviewServerConfigurationBrowse=Browse... -serverEditorOverviewServerConfigurationBrowseMessage=Specify the location of the server configuration. -serverEditorOverviewServerHostname=Host name: -serverEditorOverviewServerHostnameCommand=set host name -serverEditorOverviewRuntime=Runtime Environment: -serverEditorOverviewRuntimeEdit=Edit -serverEditorOverviewRuntimeCommand=set runtime environment - -serverEditorOverviewPublishSection=Publishing -serverEditorOverviewPublishDescription=Modify settings for publishing. -serverEditorOverviewAutoPublishDisable=Never publish automatically -serverEditorOverviewAutoPublishEnabled=Automatically publish when resources change -serverEditorOverviewAutoPublishEnabledInterval=Publishing interval (in seconds): -serverEditorOverviewPublishCommand=modify publish settings -serverEditorOverviewPublishers=Select publishing actions: -serverEditorOverviewTimeoutSection=Timeouts -serverEditorOverviewTimeoutDescription=Specify the time limit to complete server operations. -serverEditorOverviewStartTimeout=Start (in seconds): -serverEditorOverviewStopTimeout=Stop (in seconds): -serverEditorOverviewTimeoutCommand=modify timeout settings -serverEditorOverviewOpenLaunchConfiguration=Open launch configuration - -# Menu items. {0} will be replaced by one of the xxxEditorActionXxx fields -# from below. @Ctrl+Z is the menu mnemonic -editorUndoEnabled=Undo {0}@Ctrl+Z -editorUndoDisabled=Undo@Ctrl+Z -editorRedoEnabled=Redo {0}@Ctrl+Y -editorRedoDisabled=Redo@Ctrl+Y - -editorSaveErrorDialog=Save Problems -editorSaveErrorMessage=Error while saving. {0} - -editorReadOnly=Read Only -editorWritable=Writable -editorReadOnlyFiles=Read Only files: {0} - -editorServerEditor=Server Editor -editorPromptIrreversible=This operation cannot be undone. Do you want to proceed? -editorRenameFiles=The server has been renamed. Do you want to rename the corresponding files to match? - -# message if a dirty resource is deleted -editorResourceDeleteTitle=Server Deleted -editorResourceDeleteServerMessage=The server {0} has been deleted from the file system. Do you want to save your changes or close the editor without saving? -editorResourceDeleteSave=Save - -editorResourceModifiedTitle=File Changed -editorServerModifiedMessage=The server has been changed on the file system. Do you want to load the changes? - -editorValidateEditFailureMessage=The server cannot be edited. -editorReadOnlyMessage=File(s) being edited have become read-only. The editor will become read-only and changes will be lost. - -editorResourceWarnTitle=Server Modification Warning -editorResourceWarnMessage=The server you are modifying is read-only. All changes will be lost because the server cannot be saved. - - -audioPrefSelectFile=Select Audio File -audioPrefEnable=&Enable sounds -audioPrefVolume=&Volume: -audioPrefSounds=&Sounds: -audioPrefSound=Sound -audioPrefFile=Audio File -audioPrefPlay=&Play -audioPrefBrowse=&Browse... -audioPrefReset=&Reset - -audioUnknown=(unknown) -audioDefault=(default) -audioNone=(none) - -errorStartingMonitor=Could not start the server monitor: {0} - -internalWebBrowserName=Internal Web Browser diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ModuleLabelDecorator.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ModuleLabelDecorator.java deleted file mode 100644 index 5b12d9d97..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ModuleLabelDecorator.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jface.viewers.ILabelDecorator; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.ui.internal.view.servers.ModuleServer; -import org.eclipse.wst.server.ui.internal.viewers.BaseLabelProvider; - -public class ModuleLabelDecorator extends BaseLabelProvider implements ILabelDecorator { - public ModuleLabelDecorator() { - super(false); - } - - public Image decorateImage(Image image, Object element) { - try { - IModule module = null; - - if (element instanceof IModule) { - module = (IModule) element; - } else if (element instanceof ModuleServer) { - IModule[] modules = ((ModuleServer) element).module; - module = modules[modules.length - 1]; - } - if (module == null) - return null; - - IProject project = module.getProject(); - - if (project == null) - return null; - - return PlatformUI.getWorkbench().getDecoratorManager().decorateImage(image, project); - } catch (Exception e) { - return null; - } - } - - public String decorateText(String text, Object element) { - try { - IModule module = null; - - if (element instanceof IModule) { - module = (IModule) element; - } else if (element instanceof ModuleServer) { - IModule[] modules = ((ModuleServer) element).module; - module = modules[modules.length - 1]; - } - if (module == null) - return null; - - IProject project = module.getProject(); - - if (project == null) - return null; - - if (!project.getName().equals(text)) - text = NLS.bind(Messages.moduleDecoratorProject, new String[] {text, project.getName()}); - return PlatformUI.getWorkbench().getDecoratorManager().decorateText(text, project); - } catch (Exception e) { - return null; - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ModuleLabelDecorator2.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ModuleLabelDecorator2.java deleted file mode 100644 index a131fa71f..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ModuleLabelDecorator2.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jface.viewers.IDecoration; -import org.eclipse.jface.viewers.ILightweightLabelDecorator; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.ui.internal.view.servers.ModuleServer; -import org.eclipse.wst.server.ui.internal.viewers.BaseLabelProvider; - -public class ModuleLabelDecorator2 extends BaseLabelProvider implements ILightweightLabelDecorator { - public ModuleLabelDecorator2() { - super(false); - } - - public void decorate(Object element, IDecoration decoration) { - try { - IModule module = null; - - if (element instanceof IServer) { - decoration.addSuffix(" *"); - return; - } - - if (element instanceof IModule) { - module = (IModule) element; - } else if (element instanceof ModuleServer) { - IModule[] modules = ((ModuleServer) element).module; - module = modules[modules.length - 1]; - } - if (module == null) - return; - - IProject project = module.getProject(); - if (project == null) - return; - - String text = module.getName(); - - if (!project.getName().equals(text)) - decoration.addSuffix(" (" + project.getName() + ")"); - //text = NLS.bind(Messages.moduleDecoratorProject, new String[] {text, project.getName()}); - //return PlatformUI.getWorkbench().getDecoratorManager().decorateText(text, project); - } catch (Exception e) { - return; - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/OverlayImageDescriptor.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/OverlayImageDescriptor.java deleted file mode 100644 index fa265e068..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/OverlayImageDescriptor.java +++ /dev/null @@ -1,115 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal; - -import org.eclipse.debug.ui.DebugUITools; -import org.eclipse.debug.ui.IDebugUIConstants; -import org.eclipse.jface.resource.CompositeImageDescriptor; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.ImageData; -import org.eclipse.swt.graphics.Point; -/** - * A OverlayImageDescriptor consists of a main icon and one or more overlays. - * The overlays are computed according to flags set on creation of the descriptor. - */ -public class OverlayImageDescriptor extends CompositeImageDescriptor { - // flag to render the error overlay - public final static int ERROR = 0x001; - - private Image fBaseImage; - private int fFlags; - private Point fSize; - - /** - * Create a new OverlayImageDescriptor. - * - * @param baseImage an image descriptor used as the base image - * @param flags flags indicating which adornments are to be rendered - */ - public OverlayImageDescriptor(Image baseImage, int flags) { - setBaseImage(baseImage); - setFlags(flags); - } - - /** - * @see CompositeImageDescriptor#getSize() - */ - protected Point getSize() { - if (fSize == null) { - ImageData data = getBaseImage().getImageData(); - setSize(new Point(data.width, data.height)); - } - return fSize; - } - - /** - * @see Object#equals(java.lang.Object) - */ - public boolean equals(Object object) { - if (!(object instanceof OverlayImageDescriptor)) - return false; - - OverlayImageDescriptor other = (OverlayImageDescriptor) object; - return (getBaseImage().equals(other.getBaseImage()) && getFlags() == other.getFlags()); - } - - /** - * @see Object#hashCode() - */ - public int hashCode() { - return getBaseImage().hashCode() | getFlags(); - } - - /** - * @see CompositeImageDescriptor#drawCompositeImage(int, int) - */ - protected void drawCompositeImage(int width, int height) { - ImageData bg = getBaseImage().getImageData(); - if (bg == null) - bg = DEFAULT_IMAGE_DATA; - - drawImage(bg, 0, 0); - drawOverlays(); - } - - /** - * Add any overlays to the image as specified in the flags. - */ - protected void drawOverlays() { - int flags = getFlags(); - ImageData data = null; - if ((flags & ERROR) != 0) { - data = DebugUITools.getImage(IDebugUIConstants.IMG_OVR_ERROR).getImageData(); - int x = getSize().x - data.width; - drawImage(data, x, 0); - } - } - - protected Image getBaseImage() { - return fBaseImage; - } - - protected void setBaseImage(Image baseImage) { - fBaseImage = baseImage; - } - - protected int getFlags() { - return fFlags; - } - - protected void setFlags(int flags) { - fFlags = flags; - } - - protected void setSize(Point size) { - fSize = size; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ProgressUtil.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ProgressUtil.java deleted file mode 100644 index c5a3e8d4a..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ProgressUtil.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal; - -import org.eclipse.core.runtime.*; -/** - * Progress Monitor utility. - */ -public class ProgressUtil { - /** - * ProgressUtil constructor comment. - */ - private ProgressUtil() { - super(); - } - - /** - * Return a valid progress monitor. - * - * @param monitor org.eclipse.core.runtime.IProgressMonitor - * @return org.eclipse.core.runtime.IProgressMonitor - */ - public static IProgressMonitor getMonitorFor(IProgressMonitor monitor) { - if (monitor == null) - return new NullProgressMonitor(); - return monitor; - } - - /** - * Return a sub-progress monitor with the given amount on the - * current progress monitor. - * - * @param monitor org.eclipse.core.runtime.IProgressMonitor - * @param ticks int - * @return org.eclipse.core.runtime.IProgressMonitor - */ - public static IProgressMonitor getSubMonitorFor(IProgressMonitor monitor, int ticks) { - if (monitor == null) - return new NullProgressMonitor(); - if (monitor instanceof NullProgressMonitor) - return monitor; - return new SubProgressMonitor(monitor, ticks); - } - - /** - * Return a sub-progress monitor with the given amount on the - * current progress monitor. - * - * @param monitor a progress monitor, or null - * @param ticks a number of ticks - * @param style a style - * @return a progress monitor - */ - public static IProgressMonitor getSubMonitorFor(IProgressMonitor monitor, int ticks, int style) { - if (monitor == null) - return new NullProgressMonitor(); - if (monitor instanceof NullProgressMonitor) - return monitor; - return new SubProgressMonitor(monitor, ticks, style); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ProjectPropertyPage.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ProjectPropertyPage.java deleted file mode 100644 index e815b3789..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ProjectPropertyPage.java +++ /dev/null @@ -1,227 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.ILabelProvider; -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.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableItem; -import org.eclipse.ui.dialogs.PropertyPage; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IModuleType; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.ServerCore; -import org.eclipse.wst.server.core.ServerUtil; -import org.eclipse.wst.server.ui.ServerUICore; -/** - * PropertyPage for IProjects. It shows the server preference for the project. - */ -public class ProjectPropertyPage extends PropertyPage { - protected IProject project; - protected IModule module; - protected IServer server; - - protected Table table; - protected int count; - protected IServer defaultServer; - - /** - * ProjectPropertyPage constructor comment. - */ - public ProjectPropertyPage() { - super(); - } - - /** - * Create the body of the page. - * - * @param parent org.eclipse.swt.widgets.Composite - * @return org.eclipse.swt.widgets.Control - */ - protected Control createContents(Composite parent) { - try { - IAdaptable element = getElement(); - project = (IProject) element.getAdapter(IProject.class); - //if (element instanceof IProject) - // project = (IProject) element; - - Composite composite = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.marginHeight = 0; - layout.marginWidth = 0; - layout.numColumns = 2; - layout.verticalSpacing = 5; - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - - /*Label label = new Label(composite, SWT.WRAP); - label.setText(Messages.prefProjectDescription); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 2; - data.widthHint = 200; - label.setLayoutData(data);*/ - - module = ServerUtil.getModule(project); - if (module == null) { - Label label = new Label(composite, SWT.NONE); - label.setText(Messages.prefProjectNotModule); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - data.horizontalSpan = 2; - data.verticalIndent = 5; - label.setLayoutData(data); - } else { - IModuleType mt = module.getModuleType(); - if (mt != null) { - Label label = new Label(composite, SWT.NONE); - label.setText(Messages.prefProject); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - data.verticalIndent = 5; - label.setLayoutData(data); - - Label moduleKind = new Label(composite, SWT.NONE); - data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - data.verticalIndent = 5; - moduleKind.setLayoutData(data); - moduleKind.setText(module.getName() + " (" + mt.getName() + ")"); - } - - defaultServer = ServerCore.getDefaultServer(module); - - final IServer[] servers = getServersBySupportedModule(module); - if (servers == null || servers.length == 0) { - Label label = new Label(composite, SWT.WRAP); - label.setText(Messages.prefProjectNotConfigured); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - data.horizontalSpan = 2; - data.verticalIndent = 5; - label.setLayoutData(data); - } else { - Label label = new Label(composite, SWT.NONE); - label.setText(Messages.prefProjectDefaultServer); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING); - data.horizontalSpan = 2; - data.verticalIndent = 5; - label.setLayoutData(data); - - table = new Table(composite, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL); - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 2; - data.horizontalIndent = 15; - data.heightHint = 90; - table.setLayoutData(data); - - // add none option - TableItem item = new TableItem(table, SWT.NONE); - item.setText(Messages.prefProjectNoServer); - //item.setImage(); - - int size2 = servers.length; - count = 0; - ILabelProvider labelProvider = ServerUICore.getLabelProvider(); - for (int j = 0; j < size2; j++) { - item = new TableItem(table, SWT.NONE); - item.setText(labelProvider.getText(servers[j])); - item.setImage(labelProvider.getImage(servers[j])); - item.setData(servers[j]); - if (servers[j].equals(defaultServer)) - count = j + 1; - } - labelProvider.dispose(); - - table.setSelection(count); - - table.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - int index = table.getSelectionIndex(); - if (index == 0) - server = null; - else if (index > 0) - server = servers[index-1]; - } - }); - } - } - - Dialog.applyDialogFont(composite); - - return composite; - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error creating project property page", e); - return null; - } - } - - /** - * Returns a list of all servers that this module is configured on. - * - * @param module a module - * @return an array of servers - */ - protected static IServer[] getServersBySupportedModule(IModule module) { - if (module == null) - return new IServer[0]; - - // do it the slow way - go through all servers and - // see if this module is configured in it - List<IServer> list = new ArrayList<IServer>(); - IServer[] servers = ServerCore.getServers(); - if (servers != null) { - int size = servers.length; - for (int i = 0; i < size; i++) { - if (servers[i].getServerType() != null && - servers[i].getServerType().getRuntimeType() != null && - ServerUtil.isSupportedModule(servers[i].getServerType().getRuntimeType().getModuleTypes(), module.getModuleType())) - list.add(servers[i]); - } - } - - return list.toArray(new IServer[list.size()]); - } - - protected void performDefaults() { - if (table != null) { - table.select(count); - server = defaultServer; - } - - super.performDefaults(); - } - - /** - * @see org.eclipse.jface.preference.PreferencePage#performOk() - */ - public boolean performOk() { - if (module != null) { - try { - ServerCore.setDefaultServer(module, server, null); - } catch (CoreException e) { - Trace.trace(Trace.SEVERE, "Error setting preferred server", e); - EclipseUtil.openError(Messages.errorCouldNotSavePreference, e.getStatus()); - return false; - } - } - return super.performOk(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/RuntimeMarkerResolution.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/RuntimeMarkerResolution.java deleted file mode 100644 index 99252ad8a..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/RuntimeMarkerResolution.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal; - -import org.eclipse.core.resources.IMarker; -import org.eclipse.jface.preference.PreferenceDialog; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.IMarkerResolution2; -import org.eclipse.ui.dialogs.PreferencesUtil; - -public class RuntimeMarkerResolution implements IMarkerResolution2 { - public String getDescription() { - return Messages.wizNewRuntimeDescription; - } - - public Image getImage() { - return ImageResource.getImage(ImageResource.IMG_SERVER); - } - - public String getLabel() { - return Messages.wizNewServerRuntimeCreate; - } - - public void run(IMarker marker) { - showPreferencePage(); - } - - protected boolean showPreferencePage() { - String id = "org.eclipse.wst.server.ui.preferencePage"; - String id2 = "org.eclipse.wst.server.ui.runtime.preferencePage"; - final PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(null, id2, new String[] { id, id2 }, null); - return (dialog.open() == Window.OK); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/RuntimePreferencePage.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/RuntimePreferencePage.java deleted file mode 100644 index 3e020e136..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/RuntimePreferencePage.java +++ /dev/null @@ -1,409 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.runtime.CoreException; -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.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.preference.PreferencePage; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.window.Window; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Color; -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.DirectoryDialog; -import org.eclipse.swt.widgets.Label; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.server.core.*; -import org.eclipse.wst.server.core.internal.IRuntimeLocator; -import org.eclipse.wst.server.core.internal.ServerPlugin; -import org.eclipse.wst.server.core.internal.facets.FacetUtil; -import org.eclipse.wst.server.ui.internal.viewers.RuntimeComposite; -import org.eclipse.wst.server.ui.internal.wizard.TaskWizard; -import org.eclipse.wst.server.ui.internal.wizard.WizardTaskUtil; -import org.eclipse.wst.server.ui.internal.wizard.fragment.NewRuntimeWizardFragment; -import org.eclipse.wst.server.ui.wizard.WizardFragment; -/** - * The preference page that holds server runtimes. - */ -public class RuntimePreferencePage extends PreferencePage implements IWorkbenchPreferencePage { - protected Button edit; - protected Button remove; - protected Label pathLabel; - - /** - * RuntimePreferencesPage constructor comment. - */ - public RuntimePreferencePage() { - super(); - noDefaultAndApplyButton(); - } - - /** - * Create the preference options. - * - * @param parent org.eclipse.swt.widgets.Composite - * @return org.eclipse.swt.widgets.Control - */ - protected Control createContents(Composite parent) { - initializeDialogUnits(parent); - PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, ContextIds.PREF_GENERAL); - - Composite composite = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.horizontalSpacing = convertHorizontalDLUsToPixels(4); - layout.verticalSpacing = convertVerticalDLUsToPixels(3); - layout.marginWidth = 0; - layout.marginHeight = 0; - layout.numColumns = 2; - composite.setLayout(layout); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL); - composite.setLayoutData(data); - - Label label = new Label(composite, SWT.WRAP); - data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - data.horizontalSpan = 2; - label.setLayoutData(data); - label.setText(Messages.preferenceRuntimesDescription); - - label = new Label(composite, SWT.WRAP); - data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - data.horizontalSpan = 2; - data.verticalIndent = 5; - label.setLayoutData(data); - label.setText(Messages.preferenceRuntimesTable); - - final RuntimeComposite runtimeComp = new RuntimeComposite(composite, SWT.NONE, new RuntimeComposite.RuntimeSelectionListener() { - public void runtimeSelected(IRuntime runtime) { - if (runtime == null) { - edit.setEnabled(false); - remove.setEnabled(false); - pathLabel.setText(""); - } else { - IStatus status = runtime.validate(new NullProgressMonitor()); - if (status != null && status.getSeverity() == IStatus.ERROR) { - Color c = pathLabel.getDisplay().getSystemColor(SWT.COLOR_RED); - pathLabel.setForeground(c); - pathLabel.setText(status.getMessage()); - } else if (runtime.getLocation() != null) { - pathLabel.setForeground(edit.getForeground()); - pathLabel.setText(runtime.getLocation() + ""); - } else - pathLabel.setText(""); - - if (runtime.isReadOnly()) { - edit.setEnabled(false); - remove.setEnabled(false); - } else { - if (runtime.getRuntimeType() != null) - edit.setEnabled(ServerUIPlugin.hasWizardFragment(runtime.getRuntimeType().getId())); - else - edit.setEnabled(false); - remove.setEnabled(true); - } - } - } - }); - runtimeComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL)); - - Composite buttonComp = new Composite(composite, SWT.NONE); - layout = new GridLayout(); - layout.horizontalSpacing = 0; - layout.verticalSpacing = convertVerticalDLUsToPixels(3); - layout.marginWidth = 0; - layout.marginHeight = 0; - layout.numColumns = 1; - buttonComp.setLayout(layout); - data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL); - buttonComp.setLayoutData(data); - - Button add = SWTUtil.createButton(buttonComp, Messages.add); - add.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - if (showWizard(null) == Window.CANCEL) - return; - runtimeComp.refresh(); - } - }); - - edit = SWTUtil.createButton(buttonComp, Messages.edit); - edit.setEnabled(false); - edit.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - IRuntime runtime = runtimeComp.getSelectedRuntime(); - if (runtime != null) { - IRuntimeWorkingCopy runtimeWorkingCopy = runtime.createWorkingCopy(); - if (showWizard(runtimeWorkingCopy) != Window.CANCEL) { - try { - runtimeComp.refresh(runtime); - } catch (Exception ex) { - // ignore - } - } - } - } - }); - - remove = SWTUtil.createButton(buttonComp, Messages.remove); - remove.setEnabled(false); - remove.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - IRuntime runtime = runtimeComp.getSelectedRuntime(); - if (removeRuntime(runtime)) - runtimeComp.remove(runtime); - } - }); - - Button search = SWTUtil.createButton(buttonComp, Messages.search); - data = (GridData) search.getLayoutData(); - data.verticalIndent = 9; - search.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - try { - // select a target directory for the search - DirectoryDialog directoryDialog = new DirectoryDialog(getShell()); - directoryDialog.setMessage(Messages.dialogRuntimeSearchMessage); - directoryDialog.setText(Messages.dialogRuntimeSearchTitle); - - String pathStr = directoryDialog.open(); - if (pathStr == null) - return; - - final IPath path = new Path(pathStr); - - final ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); - dialog.setBlockOnOpen(false); - dialog.setCancelable(true); - dialog.open(); - final IProgressMonitor monitor = dialog.getProgressMonitor(); - final IRuntimeLocator[] locators = ServerPlugin.getRuntimeLocators(); - monitor.beginTask(Messages.dialogRuntimeSearchProgress, 100 * locators.length + 10); - final List<IRuntimeWorkingCopy> list = new ArrayList<IRuntimeWorkingCopy>(); - - final IRuntimeLocator.IRuntimeSearchListener listener = new IRuntimeLocator.IRuntimeSearchListener() { - public void runtimeFound(final IRuntimeWorkingCopy runtime) { - dialog.getShell().getDisplay().syncExec(new Runnable() { - public void run() { - monitor.subTask(runtime.getName()); - } - }); - list.add(runtime); - } - }; - - IRunnableWithProgress runnable = new IRunnableWithProgress() { - public void run(IProgressMonitor monitor2) { - int size = locators.length; - for (int i = 0; i < size; i++) { - if (!monitor2.isCanceled()) - try { - locators[i].searchForRuntimes(path, listener, monitor2); - } catch (CoreException ce) { - Trace.trace(Trace.WARNING, "Error locating runtimes: " + locators[i].getId(), ce); - } - } - Trace.trace(Trace.INFO, "Done search"); - } - }; - dialog.run(true, true, runnable); - - Trace.trace(Trace.FINER, "Found runtimes: " + list.size()); - - if (!monitor.isCanceled()) { - if (list.isEmpty()) { - EclipseUtil.openError(getShell(), Messages.infoNoRuntimesFound); - return; - } - monitor.worked(5); - // remove duplicates from list (based on location) - Trace.trace(Trace.FINER, "Removing duplicates"); - List<IRuntime> good = new ArrayList<IRuntime>(); - Iterator iterator2 = list.iterator(); - while (iterator2.hasNext()) { - boolean dup = false; - IRuntime wc = (IRuntime) iterator2.next(); - - IRuntime[] runtimes = ServerCore.getRuntimes(); - if (runtimes != null) { - int size = runtimes.length; - for (int i = 0; i < size; i++) { - if (runtimes[i].getLocation() != null && runtimes[i].getLocation().equals(wc.getLocation())) - dup = true; - } - } - if (!dup) - good.add(wc); - } - monitor.worked(5); - - // add to list - Trace.trace(Trace.FINER, "Adding runtimes: " + good.size()); - Iterator iterator = good.iterator(); - while (iterator.hasNext()) { - IRuntimeWorkingCopy wc = (IRuntimeWorkingCopy) iterator.next(); - wc.save(false, monitor); - } - monitor.done(); - } - dialog.close(); - } catch (Exception ex) { - Trace.trace(Trace.SEVERE, "Error finding runtimes", ex); - } - runtimeComp.refresh(); - } - }); - - pathLabel = new Label(parent, SWT.NONE); - pathLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - Dialog.applyDialogFont(composite); - - return composite; - } - - protected boolean removeRuntime(IRuntime runtime) { - if (runtime == null) - return false; - - // check for use - IServer[] servers = ServerCore.getServers(); - List<IServer> list = new ArrayList<IServer>(); - if (servers != null) { - int size = servers.length; - for (int i = 0; i < size; i++) { - if (runtime.equals(servers[i].getRuntime())) - list.add(servers[i]); - } - } - - boolean inUse = false; - try { - inUse = FacetUtil.isRuntimeTargeted(runtime); - } catch (Throwable t) { - // ignore - facet framework not found - } - - if (!list.isEmpty() || inUse) { - DeleteRuntimeDialog dialog = new DeleteRuntimeDialog(getShell(), !list.isEmpty(), inUse); - if (dialog.open() != 0) - return false; - - if (dialog.isDeleteServers()) { - Iterator iter = list.iterator(); - while (iter.hasNext()) { - try { - IServer server = (IServer) iter.next(); - server.delete(); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error deleting server", e); - } - } - } - if (dialog.isRemoveTargets()) { - try { - FacetUtil.removeTargets(runtime, new NullProgressMonitor()); - } catch (Throwable t) { - // ignore - facet framework not found - } - } - } - - try { - runtime.delete(); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error deleting runtime", e); - } - return true; - } - - protected int showWizard(final IRuntimeWorkingCopy runtimeWorkingCopy) { - String title = null; - WizardFragment fragment = null; - TaskModel taskModel = new TaskModel(); - if (runtimeWorkingCopy == null) { - title = Messages.wizNewRuntimeWizardTitle; - fragment = new WizardFragment() { - protected void createChildFragments(List<WizardFragment> list) { - list.add(new NewRuntimeWizardFragment()); - list.add(WizardTaskUtil.SaveRuntimeFragment); - } - }; - } else { - title = Messages.wizEditRuntimeWizardTitle; - final WizardFragment fragment2 = ServerUIPlugin.getWizardFragment(runtimeWorkingCopy.getRuntimeType().getId()); - if (fragment2 == null) { - edit.setEnabled(false); - return Window.CANCEL; - } - taskModel.putObject(TaskModel.TASK_RUNTIME, runtimeWorkingCopy); - fragment = new WizardFragment() { - protected void createChildFragments(List<WizardFragment> list) { - list.add(fragment2); - list.add(WizardTaskUtil.SaveRuntimeFragment); - } - }; - } - TaskWizard wizard = new TaskWizard(title, fragment, taskModel); - wizard.setForcePreviousAndNextButtons(true); - WizardDialog dialog = new WizardDialog(getShell(), wizard); - return dialog.open(); - } - - protected IRuntime getSelection(ISelection sel2) { - IStructuredSelection sel = (IStructuredSelection) sel2; - return (IRuntime) sel.getFirstElement(); - } - - /** - * Initializes this preference page using the passed workbench. - * - * @param workbench the current workbench - */ - public void init(IWorkbench workbench) { - // do nothing - } - - /** - * @see org.eclipse.jface.preference.PreferencePage#performOk() - */ - public boolean performOk() { - return true; - } - - /** - * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean) - */ - public void setVisible(boolean visible) { - super.setVisible(visible); - if (visible) - setTitle(Messages.preferenceRuntimesTitleLong); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/SWTUtil.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/SWTUtil.java deleted file mode 100644 index 87749cdd9..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/SWTUtil.java +++ /dev/null @@ -1,112 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.FontMetrics; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Spinner; -/** - * SWT Utility class. - */ -public class SWTUtil { - private static FontMetrics fontMetrics; - - protected static void initializeDialogUnits(Control testControl) { - // Compute and store a font metric - GC gc = new GC(testControl); - gc.setFont(JFaceResources.getDialogFont()); - fontMetrics = gc.getFontMetrics(); - gc.dispose(); - } - - /** - * Returns a width hint for a button control. - */ - protected static int getButtonWidthHint(Button button) { - int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH); - return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); - } - - /** - * Create a new button with the standard size. - * - * @param comp the component to add the button to - * @param label the button label - * @return a button - */ - public static Button createButton(Composite comp, String label) { - Button b = new Button(comp, SWT.PUSH); - b.setText(label); - if (fontMetrics == null) - initializeDialogUnits(comp); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING); - data.widthHint = getButtonWidthHint(b); - b.setLayoutData(data); - return b; - } - - /** - * Convert DLUs to pixels. - * - * @param comp a component - * @param x pixels - * @return dlus - */ - public static int convertHorizontalDLUsToPixels(Composite comp, int x) { - if (fontMetrics == null) - initializeDialogUnits(comp); - return Dialog.convertHorizontalDLUsToPixels(fontMetrics, x); - } - - /** - * Convert DLUs to pixels. - * - * @param comp a component - * @param y pixels - * @return dlus - */ - public static int convertVerticalDLUsToPixels(Composite comp, int y) { - if (fontMetrics == null) - initializeDialogUnits(comp); - return Dialog.convertVerticalDLUsToPixels(fontMetrics, y); - } - - /** - * Set the tooltip of a spinner that represents a time in seconds. - * - * @param spinner - */ - public static void setSpinnerTooltip(Spinner spinner) { - int seconds = spinner.getSelection(); - String tooltipText; - if (seconds <= 60) - tooltipText = null; - else if ((seconds % 60) == 0) { // the seconds are exact minutes - int minutes = seconds / 60; - tooltipText = NLS.bind(Messages.minutes, minutes + ""); - } else { - int minutes = seconds / 60; - int modSec = (seconds % 60); - String secondsText = (modSec < 10) ? "0" + modSec : Integer.toString(modSec); - tooltipText = NLS.bind(Messages.minutes, minutes + ":" + secondsText); - } - spinner.setToolTipText(tooltipText); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerAdapterFactory.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerAdapterFactory.java deleted file mode 100644 index d52614933..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerAdapterFactory.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal; - -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.ui.IActionFilter; -import org.eclipse.ui.model.IWorkbenchAdapter; -import org.eclipse.wst.server.ui.ServerUICore; -/** - * Adapter factory to adapt servers to IActionFilter. - */ -public class ServerAdapterFactory implements IAdapterFactory { - IActionFilter actionFilter = new IActionFilter() { - public boolean testAttribute(Object target, String name, String value) { - return ServerPropertyTester.checkProperty(target, name, value); - } - }; - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class) - */ - public Object getAdapter(Object adaptableObject, Class adapterType) { - if (adapterType == IActionFilter.class) - return actionFilter; - - if (adapterType == IWorkbenchAdapter.class) - return ServerUICore.getLabelProvider(); - - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList() - */ - public Class[] getAdapterList() { - return new Class[] { IActionFilter.class }; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerLabelProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerLabelProvider.java deleted file mode 100644 index 1cd741dde..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerLabelProvider.java +++ /dev/null @@ -1,299 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.IColorProvider; -import org.eclipse.jface.viewers.ILabelDecorator; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.jface.viewers.LabelProviderChangedEvent; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.model.IWorkbenchAdapter; - -import org.eclipse.wst.server.core.*; -import org.eclipse.wst.server.core.internal.IClient; -import org.eclipse.wst.server.core.internal.Trace; -import org.eclipse.wst.server.ui.internal.view.servers.ModuleServer; -/** - * A label provider for all server related objects. - */ -public class ServerLabelProvider implements ILabelProvider, IColorProvider, IWorkbenchAdapter { - private ILabelDecorator decorator; - protected transient List<ILabelProviderListener> listeners; - protected ILabelProviderListener providerListener; - - public ServerLabelProvider() { - decorator = PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator(); - providerListener = new ILabelProviderListener() { - public void labelProviderChanged(LabelProviderChangedEvent event) { - fireListener(event); - } - }; - decorator.addListener(providerListener); - } - - public void addListener(ILabelProviderListener listener) { - if (listener == null) - throw new IllegalArgumentException("Listener cannot be null"); - - if (listeners == null) - listeners = new ArrayList<ILabelProviderListener>(); - listeners.add(listener); - } - - public void removeListener(ILabelProviderListener listener) { - if (listener == null) - throw new IllegalArgumentException("Listener cannot be null"); - - if (listeners != null) - listeners.remove(listener); - } - - protected void fireListener(LabelProviderChangedEvent event) { - if (listeners == null || listeners.isEmpty()) - return; - - int size = listeners.size(); - ILabelProviderListener[] srl = new ILabelProviderListener[size]; - listeners.toArray(srl); - - for (int i = 0; i < size; i++) { - try { - srl[i].labelProviderChanged(event); - } catch (Exception e) { - Trace.trace(Trace.WARNING, " Error firing label change event to " + srl[i], e); - } - } - } - - protected Image getModuleImage(String typeId) { - if (typeId == null) - return null; - - Image image = ImageResource.getImage(typeId); - int ind = typeId.indexOf("."); - while (image == null && ind >= 0) { - typeId = typeId.substring(0, ind); - image = ImageResource.getImage(typeId); - } - return image; - } - - protected ImageDescriptor getModuleImageDescriptor(String typeId) { - if (typeId == null) - return null; - - ImageDescriptor image = ImageResource.getImageDescriptor(typeId); - int ind = typeId.indexOf("."); - while (image == null && ind >= 0) { - typeId = typeId.substring(0, ind); - image = ImageResource.getImageDescriptor(typeId); - } - return image; - } - - /* - * @see ILabelProvider#getImage(Object) - */ - public ImageDescriptor getImageDescriptor(Object element) { - try { - if (element instanceof IRuntimeType) { - IRuntimeType runtimeType = (IRuntimeType) element; - return ImageResource.getImageDescriptor(runtimeType.getId()); - } else if (element instanceof IRuntime) { - IRuntime runtime = (IRuntime) element; - return ImageResource.getImageDescriptor(runtime.getRuntimeType().getId()); - } else if (element instanceof IServerType) { - IServerType serverType = (IServerType) element; - return ImageResource.getImageDescriptor(serverType.getId()); - } else if (element instanceof IServer) { - IServer server = (IServer) element; - return ImageResource.getImageDescriptor(server.getServerType().getId()); - } else if (element instanceof IModule) { - IModule module = (IModule) element; - IModuleType mt = module.getModuleType(); - return getModuleImageDescriptor(mt.getId()); - } else if (element instanceof IModule[]) { - IModule[] modules = (IModule[]) element; - IModule module = modules[modules.length - 1]; - IModuleType mt = module.getModuleType(); - return getModuleImageDescriptor(mt.getId()); - } else if (element instanceof IWorkbenchAdapter) { - return ((IWorkbenchAdapter) element).getImageDescriptor(null); - } - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Could not get image descriptor", e); - } - return null; - } - - private Image decorate(Image image, Object obj) { - Image dec = decorator.decorateImage(image, obj); - if (dec != null) - return dec; - return image; - } - - private String decorate(String text, Object obj) { - String dec = decorator.decorateText(text, obj); - if (dec != null) - return dec; - return text; - } - - /* - * @see ILabelProvider#getImage(Object) - */ - public Image getImage(Object element) { - try { - if (element instanceof IRuntimeType) { - IRuntimeType runtimeType = (IRuntimeType) element; - return decorate(ImageResource.getImage(runtimeType.getId()), runtimeType); - } else if (element instanceof IRuntime) { - IRuntime runtime = (IRuntime) element; - return decorate(ImageResource.getImage(runtime.getRuntimeType().getId()), runtime); - } else if (element instanceof IServerType) { - IServerType serverType = (IServerType) element; - return decorate(ImageResource.getImage(serverType.getId()), serverType); - } else if (element instanceof IServer) { - IServer server = (IServer) element; - if (server.getServerType() == null) - return null; - - return decorate(ImageResource.getImage(server.getServerType().getId()), server); - } else if (element instanceof IModule) { - IModule module = (IModule) element; - IModuleType mt = module.getModuleType(); - if (mt == null) - return null; - - return decorate(getModuleImage(mt.getId()), module); - } else if (element instanceof IModule[]) { - IModule[] modules = (IModule[]) element; - IModule module = modules[modules.length - 1]; - IModuleType mt = module.getModuleType(); - if (mt == null) - return null; - - return decorate(getModuleImage(mt.getId()), modules); - } else if (element instanceof ModuleServer) { - ModuleServer ms = (ModuleServer) element; - IModule module = ms.module[ms.module.length - 1]; - IModuleType mt = module.getModuleType(); - if (mt == null) - return null; - - return decorate(getModuleImage(mt.getId()), ms); - } - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Could not get image descriptor", e); - } - return null; - } - - protected String getString(String s) { - if (s == null) - return ""; - - return s; - } - - /* - * @see ILabelProvider#getText(Object) - */ - public String getText(Object element) { - if (element == null) - return ""; - - if (element instanceof IRuntime) { - IRuntime runtime = (IRuntime) element; - return decorate(getString((runtime).getName()), runtime); - } else if (element instanceof IServer) { - IServer server = (IServer) element; - return decorate(getString((server).getName()), server); - } else if (element instanceof IRuntimeType) { - IRuntimeType rt = (IRuntimeType) element; - return decorate(rt.getName(), rt); - } else if (element instanceof IServerType) { - IServerType st = (IServerType) element; - return decorate(st.getName(), st); - } else if (element instanceof IClient) { - IClient client = (IClient) element; - return decorate(client.getName(), client); - } else if (element instanceof IModule) { - IModule module = (IModule) element; - return decorate(module.getName(), module); - } else if (element instanceof IModule[]) { - IModule[] modules = (IModule[]) element; - IModule module = modules[modules.length - 1]; - return decorate(module.getName(), modules); - } else if (element instanceof ModuleServer) { - ModuleServer ms = (ModuleServer) element; - IModule module = ms.module[ms.module.length - 1]; - return decorate(module.getName(), ms); - } else if (element instanceof IWorkbenchAdapter) { - return ((IWorkbenchAdapter) element).getLabel(null); - } - - return ""; - } - - /* - * @see IBaseLabelProvider#isLabelProperty(Object, String) - */ - public boolean isLabelProperty(Object element, String property) { - return false; - } - - /* - * @see IBaseLabelProvider#dispose() - */ - public void dispose() { - decorator.removeListener(providerListener); - } - - public Color getBackground(Object element) { - return null; - } - - public Color getForeground(Object element) { - if (element instanceof ModuleServer) { - ModuleServer ms = (ModuleServer)element; - - IModule module = ms.module[0]; - if (module.isExternal()) { - Color c = Display.getCurrent().getSystemColor(SWT.COLOR_GRAY); - return c; - } - } - return null; - } - - public Object[] getChildren(Object o) { - return null; - } - - public String getLabel(Object o) { - return getText(o); - } - - public Object getParent(Object o) { - return null; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerLaunchShortcut.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerLaunchShortcut.java deleted file mode 100644 index bd0504dfa..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerLaunchShortcut.java +++ /dev/null @@ -1,134 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.ui.ILaunchShortcut2; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; - -import org.eclipse.wst.server.core.internal.ServerPlugin; -import org.eclipse.wst.server.ui.internal.actions.RunOnServerActionDelegate; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IFileEditorInput; -/** - * - */ -public class ServerLaunchShortcut implements ILaunchShortcut2 { - /* (non-Javadoc) - * @see ILaunchShortcut#launch(ISelection, String) - */ - public void launch(ISelection selection, final String mode) { - RunOnServerActionDelegate ros = new RunOnServerActionDelegate(); - ros.setLaunchMode(mode); - IAction action = new Action() { - // dummy action - }; - ros.selectionChanged(action, selection); - ros.run(action); - } - - /* (non-Javadoc) - * @see ILaunchShortcut#launch(IEditorPart, String) - */ - public void launch(IEditorPart editor, String mode) { - if (editor == null) - return; - - // check if the editor input itself can be run. Otherwise, check if - // the editor has a file input that can be run - IEditorInput input = editor.getEditorInput(); - - if (ServerPlugin.hasModuleArtifact(input)) { - launch(new StructuredSelection(input), mode); - } else if (input instanceof IFileEditorInput) { - IFileEditorInput fei = (IFileEditorInput) input; - IFile file = fei.getFile(); - if (ServerPlugin.hasModuleArtifact(file)) - launch(new StructuredSelection(file), mode); - } - } - - /** - * Given the specified <code>ISelection</code> this method returns an array of - * <code>ILaunchConfiguration</code>s that apply to the current selection, - * i.e. all of the launch configurations that could be used to launch the given - * selection. - * @param selection the current selection - * @return an array of <code>ILaunchConfiguration</code>s that could be - * used to launch the given selection, or an empty array, never <code>null</code> - */ - public ILaunchConfiguration[] getLaunchConfigurations(ISelection selection) { - return new ILaunchConfiguration[0]; - } - - /* (non-Javadoc) - * @see ILaunchShortcut2#getLaunchConfigurations(IEditorPart) - */ - public ILaunchConfiguration[] getLaunchConfigurations(IEditorPart editor) { - if (editor == null) - return new ILaunchConfiguration[0]; - - // check if the editor input itself can be run. Otherwise, check if - // the editor has a file input that can be run - IEditorInput input = editor.getEditorInput(); - - if (ServerPlugin.hasModuleArtifact(input)) { - return getLaunchConfigurations(new StructuredSelection(input)); - } else if (input instanceof IFileEditorInput) { - IFileEditorInput fei = (IFileEditorInput) input; - IFile file = fei.getFile(); - if (ServerPlugin.hasModuleArtifact(file)) - return getLaunchConfigurations(new StructuredSelection(file)); - } - return new ILaunchConfiguration[0]; - } - - /** - * Given the specified <code>ISelection</code> this method returns an - * <code>IResource</code> that directly maps to the current selection. - * This mapping is then leveraged by the context launching framework - * to try and launch the resource. - * @param selection the current selection - * @return an <code>IResource</code> that would be used during context - * sensitive launching or <code>null</code> if one is not to be provided or does not exist. - */ - public IResource getLaunchableResource(ISelection selection) { - return null; - } - - /* (non-Javadoc) - * @see ILaunchShortcut2#getLaunchableResource(IEditorPart) - */ - public IResource getLaunchableResource(IEditorPart editor) { - if (editor == null) - return null; - - // check if the editor input itself can be run. Otherwise, check if - // the editor has a file input that can be run - IEditorInput input = editor.getEditorInput(); - - if (ServerPlugin.hasModuleArtifact(input)) { - return getLaunchableResource(new StructuredSelection(input)); - } else if (input instanceof IFileEditorInput) { - IFileEditorInput fei = (IFileEditorInput) input; - IFile file = fei.getFile(); - if (ServerPlugin.hasModuleArtifact(file)) - return getLaunchableResource(new StructuredSelection(file)); - } - return null; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerPreferencePage.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerPreferencePage.java deleted file mode 100644 index dc23338ee..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerPreferencePage.java +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.preference.PreferencePage; -import org.eclipse.swt.SWT; -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.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.help.IWorkbenchHelpSystem; -import org.eclipse.wst.server.core.internal.ServerPreferences; -/** - * The preference page that holds server properties. - */ -public class ServerPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { - protected ServerPreferences preferences; - protected ServerUIPreferences uiPreferences; - - protected Button showOnActivity; - - /** - * ServerPreferencesPage constructor comment. - */ - public ServerPreferencePage() { - super(); - - preferences = ServerPreferences.getInstance(); - uiPreferences = ServerUIPlugin.getPreferences(); - } - - /** - * Create the preference options. - * - * @param parent org.eclipse.swt.widgets.Composite - * @return org.eclipse.swt.widgets.Control - */ - protected Control createContents(Composite parent) { - initializeDialogUnits(parent); - IWorkbenchHelpSystem whs = PlatformUI.getWorkbench().getHelpSystem(); - whs.setHelp(parent, ContextIds.PREF_GENERAL); - - Composite composite = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.horizontalSpacing = convertHorizontalDLUsToPixels(4); - layout.verticalSpacing = convertVerticalDLUsToPixels(4); - layout.marginWidth = 0; - layout.marginHeight = 0; - layout.numColumns = 3; - composite.setLayout(layout); - GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL); - composite.setLayoutData(data); - - showOnActivity = new Button(composite, SWT.CHECK); - showOnActivity.setText(Messages.prefShowOnActivity); - data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - data.horizontalSpan = 3; - showOnActivity.setLayoutData(data); - showOnActivity.setSelection(uiPreferences.getShowOnActivity()); - whs.setHelp(showOnActivity, ContextIds.PREF_GENERAL_SHOW_ON_ACTIVITY); - - Dialog.applyDialogFont(composite); - - return composite; - } - - /** - * Initializes this preference page using the passed workbench. - * - * @param workbench the current workbench - */ - public void init(IWorkbench workbench) { - // do nothing - } - - /** - * Performs special processing when this page's Defaults button has been pressed. - */ - protected void performDefaults() { - showOnActivity.setSelection(uiPreferences.getDefaultShowOnActivity()); - - super.performDefaults(); - } - - /** - * @see org.eclipse.jface.preference.IPreferencePage#performOk() - */ - public boolean performOk() { - uiPreferences.setShowOnActivity(showOnActivity.getSelection()); - - return true; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerPropertyPage.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerPropertyPage.java deleted file mode 100644 index 53a714707..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerPropertyPage.java +++ /dev/null @@ -1,160 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jface.dialogs.Dialog; -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.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.PropertyPage; -import org.eclipse.ui.help.IWorkbenchHelpSystem; -import org.eclipse.wst.server.core.IRuntimeType; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.IServerType; -import org.eclipse.wst.server.core.internal.Server; -/** - * PropertyPage for servers. - */ -public class ServerPropertyPage extends PropertyPage { - protected IServer server; - - protected IServer defaultServer; - - /** - * ServerPropertyPage constructor comment. - */ - public ServerPropertyPage() { - super(); - } - - /** - * Create the body of the page. - * - * @param parent org.eclipse.swt.widgets.Composite - * @return org.eclipse.swt.widgets.Control - */ - protected Control createContents(Composite parent) { - try { - IAdaptable element = getElement(); - server = (IServer) element.getAdapter(IServer.class); - - Composite composite = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.marginHeight = 0; - layout.marginWidth = 0; - layout.numColumns = 3; - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - - IWorkbenchHelpSystem whs = PlatformUI.getWorkbench().getHelpSystem(); - whs.setHelp(composite, ContextIds.SERVER_PROPERTY_PAGE); - - // name - Label label = new Label(composite, SWT.NONE); - label.setText(Messages.propServerInfoName); - - label = new Label(composite, SWT.NONE); - label.setText(server.getName()); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 2; - label.setLayoutData(data); - - // type - label = new Label(composite, SWT.NONE); - label.setText(Messages.propServerInfoType); - - IServerType serverType = server.getServerType(); - label = new Label(composite, SWT.NONE); - if (serverType != null) - label.setText(serverType.getName()); - else - label.setText(Messages.elementUnknownName); - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 2; - label.setLayoutData(data); - - // vendor - label = new Label(composite, SWT.NONE); - label.setText(Messages.propServerInfoVendor); - - IRuntimeType runtimeType = null; - if (serverType != null) - runtimeType = serverType.getRuntimeType(); - label = new Label(composite, SWT.NONE); - if (runtimeType != null) - label.setText(runtimeType.getVendor()); - else - label.setText(Messages.elementUnknownName); - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 2; - label.setLayoutData(data); - - // location - label = new Label(composite, SWT.NONE); - label.setText(Messages.switchServerLocation); - label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING)); - - final Label serverLocation = new Label(composite, SWT.NONE); - final Server svr = (Server) server; - if (svr.getFile() != null) - serverLocation.setText(svr.getFile().getFullPath().toPortableString()); - else - serverLocation.setText(Messages.switchServerLocationMetadata); - - serverLocation.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING)); - - Button switchLocation = new Button(composite, SWT.PUSH); - switchLocation.setText(Messages.actionSwitchServerLocation); - switchLocation.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); - switchLocation.setEnabled(!server.isReadOnly()); - switchLocation.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - try { - Server.switchLocation(svr, null); - } catch (CoreException ce) { - Trace.trace(Trace.SEVERE, "Error switching server location", ce); - } - if (svr.getFile() != null) - serverLocation.setText(svr.getFile().getFullPath().toPortableString()); - else - serverLocation.setText(Messages.switchServerLocationMetadata); - } - }); - - Dialog.applyDialogFont(composite); - - return composite; - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error creating property page", e); - return null; - } - } - - protected void performDefaults() { - super.performDefaults(); - } - - /** - * @see org.eclipse.jface.preference.PreferencePage#performOk() - */ - public boolean performOk() { - return super.performOk(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerPropertyTester.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerPropertyTester.java deleted file mode 100644 index e3853d05b..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerPropertyTester.java +++ /dev/null @@ -1,147 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal; - -import org.eclipse.core.expressions.PropertyTester; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.ui.IFileEditorInput; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.ServerUtil; -import org.eclipse.wst.server.core.internal.ServerPlugin; -import org.eclipse.wst.server.ui.internal.view.servers.ModuleServer; -/** - * - */ -public class ServerPropertyTester extends PropertyTester { - /* (non-Javadoc) - * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object) - */ - public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { - if (expectedValue instanceof String) - return checkProperty(receiver, property, (String) expectedValue); - if (expectedValue != null) - return checkProperty(receiver, property, expectedValue.toString()); - - return checkProperty(receiver, property, null); - } - - protected static boolean checkProperty(Object target, String property, String value) { - if ("isRunnable".equals(property)) { - // check if project has a module associated with it - if (target instanceof IProject) { - IModule m = ServerUtil.getModule((IProject) target); - if (m == null) - return false; - } - - // check for runnable object - boolean b = ServerPlugin.hasModuleArtifact(target); - if (b) - return true; - - /*if (!(receiver instanceof IEditorPart)) - return false; - - // check if the editor input itself can be run. Otherwise, check if - // the editor has a file input that can be run - IEditorPart editor = (IEditorPart) receiver; - IEditorInput input = editor.getEditorInput(); - - b = ServerPlugin.hasModuleArtifact(input); - if (b) - return true;*/ - - if (target instanceof IFileEditorInput) { - IFileEditorInput fei = (IFileEditorInput) target; - IFile file = fei.getFile(); - b = ServerPlugin.hasModuleArtifact(file); - if (b) - return true; - } - return false; - } else if ("serverType".equals(property)) { - IServer server = null; - if (target instanceof IServer) { - server = (IServer) target; - } else if (target instanceof ModuleServer) { - ModuleServer ms = (ModuleServer) target; - server = ms.server; - } - if (server == null || server.getServerType() == null) - return false; - - String[] typeIds = ServerPlugin.tokenize(value, ","); - return matches(server.getServerType().getId(), typeIds); - } else if ("moduleType".equals(property)) { - IModule[] module = null; - if (target instanceof IModule[]) { - module = (IModule[]) target; - } else if (target instanceof IModule) { - module = new IModule[] {(IModule) target}; - } else if (target instanceof ModuleServer) { - ModuleServer ms = (ModuleServer) target; - module = ms.module; - } - if (module == null) - return false; - if (module.length == 0) - return false; - - String[] values = ServerPlugin.tokenize(value, ","); - IModule m = module[module.length - 1]; - return matches(m.getModuleType().getId(), values); - } else if ("moduleVersion".equals(property)) { - IModule[] module = null; - if (target instanceof IModule[]) { - module = (IModule[]) target; - } else if (target instanceof IModule) { - module = new IModule[] {(IModule) target}; - } else if (target instanceof ModuleServer) { - ModuleServer ms = (ModuleServer) target; - module = ms.module; - } - if (module == null) - return false; - if (module.length == 0) - return false; - - String[] values = ServerPlugin.tokenize(value, ","); - IModule m = module[module.length - 1]; - return matches(m.getModuleType().getVersion(), values); - } - return false; - } - - /** - * Returns true if the given type (given by the id) can use this action. - * - * @return boolean - */ - protected static boolean matches(String id, String[] typeIds) { - if (id == null || id.length() == 0) - return false; - - if (typeIds == null) - return false; - - int size = typeIds.length; - for (int i = 0; i < size; i++) { - if (typeIds[i].endsWith("*")) { - if (id.length() >= typeIds[i].length() && id.startsWith(typeIds[i].substring(0, typeIds[i].length() - 1))) - return true; - } else if (id.equals(typeIds[i])) - return true; - } - return false; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerToolTip.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerToolTip.java deleted file mode 100644 index 09224577c..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerToolTip.java +++ /dev/null @@ -1,296 +0,0 @@ -/********************************************************************** - * Copyright (c) 2007, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - **********************************************************************/ -package org.eclipse.wst.server.ui.internal; - -import java.io.IOException; -import java.io.StringReader; -import java.util.ArrayList; -import java.util.Hashtable; -import java.util.Iterator; - -import org.eclipse.core.runtime.*; -import org.eclipse.jface.internal.text.html.HTML2TextReader; -import org.eclipse.jface.text.TextPresentation; -import org.eclipse.jface.window.ToolTip; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.StyleRange; -import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.events.*; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.widgets.*; -import org.eclipse.wst.server.core.*; -import org.eclipse.wst.server.core.internal.Trace; -import org.eclipse.wst.server.ui.IServerModule; -import org.eclipse.wst.server.ui.internal.provisional.IServerToolTip; - -public class ServerToolTip extends ToolTip { - protected Hashtable<String,ArrayList<IServerToolTip>> toolTipProviders = new Hashtable<String,ArrayList<IServerToolTip>>(); - protected static Shell CURRENT_TOOLTIP; - protected Label hintLabel; - protected Tree tree; - protected int x; - protected int y; - - public ServerToolTip(final Tree tree) { - super(tree); - - this.tree = tree; - - tree.addMouseMoveListener(new MouseMoveListener() { - public void mouseMove(MouseEvent e) { - x = e.x; - y = e.y; - } - }); - - tree.addKeyListener(new KeyListener() { - public void keyPressed(KeyEvent e) { - if (e == null) - return; - - if (e.keyCode == SWT.ESC) { - if (CURRENT_TOOLTIP != null) { - CURRENT_TOOLTIP.dispose(); - CURRENT_TOOLTIP = null; - } - activate(); - } - if (e.keyCode == SWT.F6) { - if (CURRENT_TOOLTIP == null) { - deactivate(); - hide(); - createFocusedTooltip(tree); - } - } - } - public void keyReleased(KeyEvent e){ - // nothing to do - } - }); - - loadExtensions(); - } - - public void createFocusedTooltip(final Control control) { - final Shell stickyTooltip = new Shell(control.getShell(), SWT.ON_TOP | SWT.TOOL - | SWT.NO_FOCUS); - stickyTooltip.setLayout(new FillLayout()); - stickyTooltip.setBackground(stickyTooltip.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); - - control.getDisplay().asyncExec(new Runnable() { - public void run() { - Event event = new Event(); - event.x = x; - event.y = y; - event.widget = tree; - - createToolTipContentArea(event, stickyTooltip); - stickyTooltip.pack(); - - stickyTooltip.setLocation(stickyTooltip.getDisplay().getCursorLocation()); - hintLabel.setText(Messages.toolTipDisableFocus); - stickyTooltip.setVisible(true); -// Eventually we want to add a listener that checks if -// the mouseDown event is occurring outside of the bounds of the tooltip -// if it is, then hide the tooltip -// addListener(stickyTooltip); - } - }); - CURRENT_TOOLTIP = stickyTooltip; - } - -// read the createFocusedTooltip method for information on why this is commented out -// -// private void addListener(Control control){ -// control.addMouseListener(new StickyTipMouseListener()); -// if (control instanceof Composite){ -// Control[] childrens = ((Composite)control).getChildren(); -// for (Control child :childrens){ -// addListener(child); -// } -// } -// -// } - - - @Override - protected Object getToolTipArea(Event event) { - Object o = tree.getItem(new Point(event.x,event.y)); - return o; - } - - protected final boolean shouldCreateToolTip(Event event) { - if (tree.getItem(new Point(event.x, event.y)) == null) - return false; - return super.shouldCreateToolTip(event); - } - - protected Composite createToolTipContentArea(Event event, Composite parent) { - Object o = tree.getItem(new Point(event.x, event.y)); - if (o == null) - return null; - - IServer server = null; - IServerModule module = null; - if (o instanceof TreeItem) { - Object obj = ((TreeItem)o).getData(); - if (obj instanceof IServer) - server = (IServer) obj; - if (obj instanceof IServerModule) - module = (IServerModule) obj; - } - - FillLayout layout = (FillLayout)parent.getLayout(); - layout.type = SWT.VERTICAL; - parent.setLayout(layout); - - // set the default text for the tooltip - StyledText sText = new StyledText(parent, SWT.NONE); - sText.setEditable(false); - sText.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); - - if (module != null) { - IModule[] modules = module.getModule(); - IModule m = modules[modules.length - 1]; - sText.setText("<b>" + m.getName() + "</b>"); - //sText.setText("<b>" + m.getName() + "</b></p>" + m.getModuleType().getName()); - - StyledText sText2 = new StyledText(parent, SWT.NONE); - sText2.setEditable(false); - sText2.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); - sText2.setText(m.getModuleType().getName()); - } - - if (server != null) { - sText.setText("<b>" + server.getName() + "</b>"); - - // add adopters content - if (server.getServerType() != null) { - ArrayList<IServerToolTip> listOfProviders = toolTipProviders.get(server.getServerType().getId()); - - final Composite adoptersComposite = new Composite(parent,SWT.NONE); - adoptersComposite.setLayout(new FillLayout()); - adoptersComposite.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); - - if (listOfProviders != null) { - for (IServerToolTip tipProvider : listOfProviders) { - tipProvider.createContent(adoptersComposite,server); - } - } - } - } - - // add the F3 text - hintLabel = new Label(parent,SWT.BORDER); - hintLabel.setAlignment(SWT.RIGHT); - hintLabel.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); - hintLabel.setText(Messages.toolTipEnableFocus); - hintLabel.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY)); - - final Font font; - Display display = parent.getDisplay(); - FontData[] fd = parent.getFont().getFontData(); - int size2 = fd.length; - for (int i = 0; i < size2; i++) - fd[i].setHeight(7); - font = new Font(display, fd); - parent.addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - font.dispose(); - } - }); - hintLabel.setFont(font); - - parseText(sText.getText(),sText); - - return parent; - } - - protected void parseText(String htmlText,StyledText sText) { - TextPresentation presentation = new TextPresentation(); - HTML2TextReader reader = new HTML2TextReader(new StringReader(htmlText), presentation); - String text; - - try { - text = reader.getString(); - } catch (IOException e) { - text= ""; //$NON-NLS-1$ - } - - sText.setText(text); - Iterator iter = presentation.getAllStyleRangeIterator(); - while (iter.hasNext()) { - StyleRange sr = (StyleRange)iter.next(); - sText.setStyleRange(sr); - } - } - - private void loadExtensions() { - Trace.trace(Trace.EXTENSION_POINT, "->- Loading serverToolTip extension point ->-"); - - // search for extension points - IExtensionRegistry reg = Platform.getExtensionRegistry(); - IConfigurationElement[] extensions = reg.getConfigurationElementsFor(ServerUIPlugin.PLUGIN_ID + ".serverToolTip"); - - IServerType[] serverTypes = ServerCore.getServerTypes(); - - for (int i=0; i < extensions.length; i++){ - IConfigurationElement exElement = extensions[i]; - - try { - // sort the extensions based on serverType - String exServerType = exElement.getAttribute("serverTypes"); - - for (IServerType serverType : serverTypes) { - if ("*".equals(exServerType) || exServerType.startsWith(serverType.getId())) { - IServerToolTip exTooltip = (IServerToolTip) exElement.createExecutableExtension("class"); - ArrayList<IServerToolTip> listOfProviders = new ArrayList<IServerToolTip>(); - if (toolTipProviders.containsKey(serverType)) - listOfProviders = toolTipProviders.get(serverType); - - listOfProviders.add(exTooltip); - toolTipProviders.put(serverType.getId(), listOfProviders); - } - } - } catch (CoreException e) { - Trace.trace(Trace.SEVERE, "Tooltip failed to load" + extensions[i].toString(), e); - } - Trace.trace(Trace.EXTENSION_POINT, " Loaded serverToolTip: " + extensions[i].getAttribute("id")); - } - } - -// read the createFocusedTooltip method for information on why this is commented out -// -// protected class StickyTipMouseListener implements MouseListener{ -// -// public void mouseDoubleClick(MouseEvent e) { -// // Auto-generated method stub -// -// } -// -// public void mouseDown(MouseEvent e) { -// //System.out.println("mouseDown"); -// if (CURRENT_TOOLTIP.getBounds().contains(new Point(e.x,e.y)) == true){ -// CURRENT_TOOLTIP.setVisible(false); -// CURRENT_TOOLTIP.dispose(); -// activate(); -// CURRENT_TOOLTIP.removeMouseListener(this); -// } -// } -// -// public void mouseUp(MouseEvent e) { -// // Auto-generated method stub -// } -// } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerUIPlugin.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerUIPlugin.java deleted file mode 100644 index 5d09bdc94..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerUIPlugin.java +++ /dev/null @@ -1,924 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.StringTokenizer; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.*; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.wizard.WizardDialog; - -import org.eclipse.wst.server.core.*; -import org.eclipse.wst.server.core.internal.*; -import org.eclipse.wst.server.core.internal.Trace; -import org.eclipse.wst.server.core.model.LaunchableAdapterDelegate; -import org.eclipse.wst.server.core.util.PublishAdapter; -import org.eclipse.wst.server.ui.internal.actions.RunOnServerActionDelegate; -import org.eclipse.wst.server.ui.internal.editor.IServerEditorInput; -import org.eclipse.wst.server.ui.internal.editor.ServerEditorCore; -import org.eclipse.wst.server.ui.internal.editor.ServerEditorInput; -import org.eclipse.wst.server.ui.internal.view.servers.ModuleServer; -import org.eclipse.wst.server.ui.internal.viewers.InitialSelectionProvider; -import org.eclipse.wst.server.ui.internal.wizard.TaskWizard; -import org.eclipse.wst.server.ui.internal.wizard.WizardTaskUtil; -import org.eclipse.wst.server.ui.internal.wizard.fragment.ModifyModulesWizardFragment; -import org.eclipse.wst.server.ui.internal.wizard.fragment.NewRuntimeWizardFragment; -import org.eclipse.wst.server.ui.internal.wizard.fragment.NewServerWizardFragment; -import org.eclipse.wst.server.ui.internal.wizard.fragment.TasksWizardFragment; -import org.eclipse.wst.server.ui.wizard.WizardFragment; - -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IViewPart; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.eclipse.ui.progress.IWorkbenchSiteProgressService; -import org.osgi.framework.BundleContext; -/** - * The server UI plugin class. - */ -public class ServerUIPlugin extends AbstractUIPlugin { - protected static final String VIEW_ID = "org.eclipse.wst.server.ui.ServersView"; - - // server UI plugin id - public static final String PLUGIN_ID = "org.eclipse.wst.server.ui"; - - protected static final String EXTENSION_SERVER_IMAGES = "serverImages"; - private static final String EXTENSION_WIZARD_FRAGMENTS = "wizardFragments"; - public static final String EXTENSION_EDITOR_PAGES = "editorPages"; - public static final String EXTENSION_EDITOR_PAGE_SECTIONS = "editorPageSections"; - - //public static final byte START = 0; - public static final byte STOP = 1; - //public static final byte RESTART = 2; - - public static class DefaultLaunchableAdapter extends LaunchableAdapterDelegate { - public static final String ID = "org.eclipse.wst.server.ui.launchable.adapter.default"; - public Object getLaunchable(IServer server, IModuleArtifact moduleArtifact) { - return "launchable"; - } - } - - // singleton instance of this class - private static ServerUIPlugin singleton; - - protected Map imageDescriptors = new HashMap(); - - // cached copy of all runtime wizards - private static Map<String, WizardFragmentData> wizardFragments; - - // cached initial selection provider - private static InitialSelectionProvider selectionProvider; - - private static IRegistryChangeListener registryListener; - - protected static class RegistryChangeListener implements IRegistryChangeListener { - public void registryChanged(IRegistryChangeEvent event) { - IExtensionDelta[] deltas = event.getExtensionDeltas(ServerUIPlugin.PLUGIN_ID, EXTENSION_WIZARD_FRAGMENTS); - if (deltas != null) { - for (int i = 0; i < deltas.length; i++) { - handleWizardFragmentDelta(deltas[i]); - } - } - - deltas = event.getExtensionDeltas(ServerUIPlugin.PLUGIN_ID, EXTENSION_SERVER_IMAGES); - if (deltas != null) { - for (int i = 0; i < deltas.length; i++) { - ImageResource.handleServerImageDelta(deltas[i]); - } - } - - deltas = event.getExtensionDeltas(ServerUIPlugin.PLUGIN_ID, EXTENSION_EDITOR_PAGES); - if (deltas != null) { - for (int i = 0; i < deltas.length; i++) { - ServerEditorCore.handleEditorPageFactoriesDelta(deltas[i]); - } - } - - deltas = event.getExtensionDeltas(ServerUIPlugin.PLUGIN_ID, EXTENSION_EDITOR_PAGE_SECTIONS); - if (deltas != null) { - for (int i = 0; i < deltas.length; i++) { - ServerEditorCore.handleEditorPageSectionFactoriesDelta(deltas[i]); - } - } - } - } - - static class WizardFragmentData { - String id; - IConfigurationElement ce; - WizardFragment fragment; - - public WizardFragmentData(String id, IConfigurationElement ce) { - this.id = id; - this.ce = ce; - } - } - - protected static List<IServer> terminationWatches = new ArrayList<IServer>(); - - protected IServerLifecycleListener serverLifecycleListener = new IServerLifecycleListener() { - public void serverAdded(IServer server) { - server.addServerListener(serverListener); - ((Server) server).addPublishListener(publishListener); - } - - public void serverChanged(IServer server) { - // ignore - } - - public void serverRemoved(IServer server) { - server.removeServerListener(serverListener); - ((Server) server).removePublishListener(publishListener); - } - }; - - protected static IServerListener serverListener = new IServerListener() { - public void serverChanged(ServerEvent event) { - int eventKind = event.getKind(); - // if (eventKind == (ServerEvent.SERVER_CHANGE | ServerEvent.STATE_CHANGE)) { - if ((eventKind & ServerEvent.STATE_CHANGE) != 0) { - showServersView(true); - } else if ((eventKind & ServerEvent.SERVER_CHANGE) != 0) { - showServersView(false); - } - } - }; - - protected static IPublishListener publishListener = new PublishAdapter() { - public void publishStarted(IServer server) { - showServersView(false); - } - - public void publishFinished(IServer server, IStatus status) { - showServersView(false); - } - }; - - /** - * Create the ServerUIPlugin. - */ - public ServerUIPlugin() { - super(); - singleton = this; - } - - /** - * Returns the singleton instance of this plugin. - * - * @return org.eclipse.wst.server.ui.internal.plugin.ServerUIPlugin - */ - public static ServerUIPlugin getInstance() { - return singleton; - } - - /** - * Convenience method for logging. - * - * @param status org.eclipse.core.runtime.IStatus - */ - public static void log(IStatus status) { - getInstance().getLog().log(status); - } - - /** - * Return the UI preferences. - * - * @return ServerUIPreferences - */ - public static ServerUIPreferences getPreferences() { - return new ServerUIPreferences(); - } - - /** - * @see Plugin#start(org.osgi.framework.BundleContext) - */ - public void start(BundleContext context) throws Exception { - Trace.trace(Trace.CONFIG, "----->----- Server UI plugin start ----->-----"); - super.start(context); - - ServerUIPreferences prefs = getPreferences(); - prefs.setDefaults(); - - ServerCore.addServerLifecycleListener(serverLifecycleListener); - - InitializeJob job = new InitializeJob(); - job.schedule(); - } - - /** - * @see Plugin#stop(org.osgi.framework.BundleContext) - */ - public void stop(BundleContext context) throws Exception { - Trace.trace(Trace.CONFIG, "-----<----- Server UI plugin stop -----<-----"); - super.stop(context); - - if (registryListener != null) { - IExtensionRegistry registry = Platform.getExtensionRegistry(); - registry.removeRegistryChangeListener(registryListener); - } - - ImageResource.dispose(); - - IServer[] servers = ServerCore.getServers(); - if (servers != null) { - int size = servers.length; - for (int i = 0; i < size; i++) { - servers[i].removeServerListener(serverListener); - ((Server) servers[i]).removePublishListener(publishListener); - } - } - - ServerCore.removeServerLifecycleListener(serverLifecycleListener); - } - - /** - * Adds a watch to this server. If it hasn't stopped in a - * reasonable amount of time, the user will be prompted to - * terminate the server. - * - * @param shell a shell - * @param server a server - * @param mode a debug mode - */ - public static void addTerminationWatch(final Shell shell, final IServer server, final int mode) { - if (terminationWatches.contains(server)) - return; - - terminationWatches.add(server); - - class TerminateThread extends Thread { - public boolean alive = true; - public IServerListener listener; - - public TerminateThread() { - super("Server Termination Thread"); - } - - public void run() { - while (alive) { - int delay = server.getStartTimeout() * 1000; - if (mode == 1) - delay = server.getStopTimeout() * 1000; - else if (mode == 2) - delay += server.getStopTimeout() * 1000; - - if (delay < 0) - return; - - try { - Thread.sleep(delay); - } catch (InterruptedException e) { - // ignore - } - - if (server.getServerState() == IServer.STATE_STOPPED) - alive = false; - - if (alive) { - Display.getDefault().syncExec(new Runnable() { - public void run() { - TerminationDialog dialog = new TerminationDialog(shell, server.getName()); - dialog.open(); - if (dialog.getReturnCode() == IDialogConstants.OK_ID) { - // only try calling terminate once. Also, make sure that it didn't stop while - // the dialog was open - if (server.getServerState() != IServer.STATE_STOPPED) - server.stop(true); - alive = false; - } - } - }); - } - if (!alive) { - if (listener != null) - server.removeServerListener(listener); - terminationWatches.remove(server); - } - } - } - } - - final TerminateThread t = new TerminateThread(); - t.setDaemon(true); - t.setPriority(Thread.NORM_PRIORITY - 2); - - // add listener to stop the thread if/when the server stops - IServerListener listener = new IServerListener() { - public void serverChanged(ServerEvent event) { - int eventKind = event.getKind(); - IServer server2 = event.getServer(); - if (eventKind == (ServerEvent.SERVER_CHANGE | ServerEvent.STATE_CHANGE)) { - if (server2.getServerState() == IServer.STATE_STOPPED) - t.alive = false; - } - } - }; - t.listener = listener; - server.addServerListener(listener); - - t.start(); - } - - /** - * Returns the server that came from the given file, or <code>null</code> - * if none. This convenience method searches the list of known - * servers ({@link ServerCore#getServers()}) for the one with a matching - * location ({@link Server#getFile()}). The file may not be null. - * - * @param file a server file - * @return the server instance, or <code>null</code> if - * there is no server associated with the given file - */ - public static IServer findServer(IFile file) { - if (file == null) - throw new IllegalArgumentException(); - - IServer[] servers = ServerCore.getServers(); - if (servers != null) { - int size = servers.length; - for (int i = 0; i < size; i++) { - if (file.equals(((Server)servers[i]).getFile())) - return servers[i]; - } - } - return null; - } - - /** - * Returns an array of all known runtime instances of - * the given runtime type. This convenience method filters the list of known - * runtime ({@link ServerCore#getRuntimes()}) for ones with a matching - * runtime type ({@link IRuntime#getRuntimeType()}). The array will not - * contain any working copies. - * <p> - * A new array is returned on each call, so clients may store or modify the result. - * </p> - * - * @param runtimeType the runtime type - * @return a possibly-empty list of runtime instances {@link IRuntime} - * of the given runtime type - */ - public static IRuntime[] getRuntimes(IRuntimeType runtimeType) { - List<IRuntime> list = new ArrayList<IRuntime>(); - IRuntime[] runtimes = ServerCore.getRuntimes(); - if (runtimes != null) { - int size = runtimes.length; - for (int i = 0; i < size; i++) { - if (runtimes[i].getRuntimeType() != null && runtimes[i].getRuntimeType().equals(runtimeType)) - list.add(runtimes[i]); - } - } - - IRuntime[] r = new IRuntime[list.size()]; - list.toArray(r); - return r; - } - - /** - * Open the given server with the server editor. - * - * @param server - */ - public static void editServer(IServer server) { - if (server == null) - return; - - editServer(server.getId()); - } - - /** - * Open the given server id with the server editor. - * - * @param serverId - */ - protected static void editServer(String serverId) { - if (serverId == null) - return; - - IWorkbenchWindow workbenchWindow = ServerUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow(); - IWorkbenchPage page = workbenchWindow.getActivePage(); - - try { - IServerEditorInput input = new ServerEditorInput(serverId); - page.openEditor(input, IServerEditorInput.EDITOR_ID); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error opening server editor", e); - } - } - - /** - * Use the preference to prompt the user to save dirty editors, if applicable. - * - * @return boolean - Returns false if the user cancelled the operation - */ - public static boolean saveEditors() { - byte b = ServerUIPlugin.getPreferences().getSaveEditors(); - if (b == ServerUIPreferences.SAVE_EDITORS_NEVER) - return true; - return ServerUIPlugin.getInstance().getWorkbench().saveAllEditors(b == ServerUIPreferences.SAVE_EDITORS_PROMPT); - } - - /** - * Prompts the user if the server is dirty. Returns true if the server was - * not dirty or if the user decided to continue anyway. Returns false if - * the server is dirty and the user chose to cancel the operation. - * - * @param shell a shell - * @param server a server - * @return boolean - */ - public static boolean promptIfDirty(Shell shell, IServer server) { - if (server == null) - return false; - - if (!(server instanceof IServerWorkingCopy)) - return true; - - String title = Messages.resourceDirtyDialogTitle; - - IServerWorkingCopy wc = (IServerWorkingCopy) server; - if (wc.isDirty()) { - String message = NLS.bind(Messages.resourceDirtyDialogMessage, server.getName()); - String[] labels = new String[] {Messages.resourceDirtyDialogContinue, IDialogConstants.CANCEL_LABEL}; - MessageDialog dialog = new MessageDialog(shell, title, null, message, MessageDialog.INFORMATION, labels, 0); - - if (dialog.open() != 0) - return false; - } - - return true; - } - - /** - * Show the Servers view. The Servers is never given focus. - * - * @param bringToFront <code>true</code> to make the Servers view push to the top - * of the z-order, and <code>false</code> to just highlight it - */ - protected static void showServersView(final boolean bringToFront) { - if (!getPreferences().getShowOnActivity()) - return; - - Display.getDefault().asyncExec(new Runnable() { - public void run() { - try { - IWorkbench workbench = ServerUIPlugin.getInstance().getWorkbench(); - IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); - if (workbenchWindow == null) { - Trace.trace(Trace.FINER, "No active workbench window"); - return; - } - - IWorkbenchPage page = workbenchWindow.getActivePage(); - - IViewPart view2 = page.findView(VIEW_ID); - - if (view2 != null) { - if (bringToFront) - page.bringToTop(view2); - else { - IWorkbenchSiteProgressService wsps = (IWorkbenchSiteProgressService) - view2.getSite().getAdapter(IWorkbenchSiteProgressService.class); - wsps.warnOfContentChange(); - } - } else - page.showView(VIEW_ID); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error opening Servers view", e); - } - } - }); - } - - /** - * Returns true if the given server is already started in the given - * mode, or could be (re)started in the start mode. - * - * @param server - * @param launchMode - * @return boolean - */ - public static boolean isCompatibleWithLaunchMode(IServer server, String launchMode) { - if (server == null || launchMode == null) - return false; - - int state = server.getServerState(); - if (state == IServer.STATE_STARTED && launchMode.equals(server.getMode())) - return true; - - if (server.getServerType() != null && server.getServerType().supportsLaunchMode(launchMode)) - return true; - return false; - } - - /** - * Open the new runtime wizard. - * - * @param shell a shell - * @param type a module type id - * @param version a module version id - * @param runtimeTypeId a runtime type id - * @return true if a new runtime was created - */ - public static boolean showNewRuntimeWizard(Shell shell, final String type, final String version, final String runtimeTypeId) { - WizardFragment fragment = new WizardFragment() { - protected void createChildFragments(List<WizardFragment> list) { - list.add(new NewRuntimeWizardFragment(type, version, runtimeTypeId)); - list.add(WizardTaskUtil.SaveRuntimeFragment); - } - }; - TaskWizard wizard = new TaskWizard(Messages.wizNewRuntimeWizardTitle, fragment); - wizard.setForcePreviousAndNextButtons(true); - WizardDialog dialog = new WizardDialog(shell, wizard); - return (dialog.open() == IDialogConstants.OK_ID); - } - - /** - * Open the new runtime wizard. - * - * @param shell a shell - * @param runtimeTypeId a runtime type id - * @return true if a new runtime was created - */ - public static boolean showNewRuntimeWizard(Shell shell, final String runtimeTypeId) { - IRuntimeType runtimeType = null; - if (runtimeTypeId != null) - runtimeType = ServerCore.findRuntimeType(runtimeTypeId); - if (runtimeType != null) { - try { - final IRuntimeWorkingCopy runtime = runtimeType.createRuntime(null, null); - TaskModel taskModel = new TaskModel(); - taskModel.putObject(TaskModel.TASK_RUNTIME, runtime); - - WizardFragment fragment = new WizardFragment() { - protected void createChildFragments(List<WizardFragment> list) { - list.add(getWizardFragment(runtimeTypeId)); - list.add(WizardTaskUtil.SaveRuntimeFragment); - } - }; - TaskWizard wizard = new TaskWizard(Messages.wizNewRuntimeWizardTitle, fragment, taskModel); - wizard.setForcePreviousAndNextButtons(true); - WizardDialog dialog = new WizardDialog(shell, wizard); - return (dialog.open() == IDialogConstants.OK_ID); - } catch (Exception e) { - return false; - } - } - return showNewRuntimeWizard(shell, null, null, runtimeTypeId); - } - - /** - * Open the new server wizard. - * - * @param shell a shell - * @param typeId a module type id, or null for any module type - * @param versionId a module version, or null for any version - * @param serverTypeId a server runtime type, or null for any type - * @return <code>true</code> if a server was created, or - * <code>false</code> otherwise - */ - public static boolean showNewServerWizard(Shell shell, final String typeId, final String versionId, final String serverTypeId) { - WizardFragment fragment = new WizardFragment() { - protected void createChildFragments(List<WizardFragment> list) { - list.add(new NewServerWizardFragment(new ModuleType(typeId, versionId), serverTypeId)); - - list.add(WizardTaskUtil.TempSaveRuntimeFragment); - list.add(WizardTaskUtil.TempSaveServerFragment); - - list.add(new ModifyModulesWizardFragment()); - list.add(new TasksWizardFragment()); - - list.add(WizardTaskUtil.SaveRuntimeFragment); - list.add(WizardTaskUtil.SaveServerFragment); - list.add(WizardTaskUtil.SaveHostnameFragment); - } - }; - - TaskWizard wizard = new TaskWizard(Messages.wizNewServerWizardTitle, fragment); - wizard.setForcePreviousAndNextButtons(true); - WizardDialog dialog = new WizardDialog(shell, wizard); - return (dialog.open() == IDialogConstants.OK_ID); - } - - /** - * Returns true if the given id has possible wizard fragments, and - * false otherwise. - * - * @param typeId the server or runtime type id - * @return true if the given id has possible wizard fragments, and - * false otherwise - */ - public static boolean hasWizardFragment(String typeId) { - if (typeId == null) - return false; - - if (wizardFragments == null) - loadWizardFragments(); - - Iterator iterator = wizardFragments.keySet().iterator(); - while (iterator.hasNext()) { - String key = (String) iterator.next(); - if (typeId.equals(key)) - return true; - } - return false; - } - - /** - * Returns the wizard fragment with the given id. - * - * @param typeId the server or runtime type id - * @return a wizard fragment, or <code>null</code> if none could be found - */ - public static WizardFragment getWizardFragment(String typeId) { - if (typeId == null) - return null; - - if (wizardFragments == null) - loadWizardFragments(); - - Iterator iterator = wizardFragments.keySet().iterator(); - while (iterator.hasNext()) { - String key = (String) iterator.next(); - if (typeId.equals(key)) { - WizardFragmentData data = wizardFragments.get(key); - return getWizardFragment(data); - } - } - return null; - } - - /** - * Load the wizard fragments. - */ - private static synchronized void loadWizardFragments() { - if (wizardFragments != null) - return; - Trace.trace(Trace.CONFIG, "->- Loading .wizardFragments extension point ->-"); - IExtensionRegistry registry = Platform.getExtensionRegistry(); - IConfigurationElement[] cf = registry.getConfigurationElementsFor(ServerUIPlugin.PLUGIN_ID, EXTENSION_WIZARD_FRAGMENTS); - - Map<String, WizardFragmentData> map = new HashMap<String, WizardFragmentData>(cf.length); - loadWizardFragments(cf, map); - addRegistryListener(); - wizardFragments = map; - - Trace.trace(Trace.CONFIG, "-<- Done loading .wizardFragments extension point -<-"); - } - - /** - * Load wizard fragments. - */ - private static synchronized void loadWizardFragments(IConfigurationElement[] cf, Map<String, WizardFragmentData> map) { - for (int i = 0; i < cf.length; i++) { - try { - String id = cf[i].getAttribute("typeIds"); - String[] ids = tokenize(id, ","); - int size = ids.length; - for (int j = 0; j < size; j++) - map.put(ids[j], new WizardFragmentData(id, cf[i])); - Trace.trace(Trace.CONFIG, " Loaded wizardFragment: " + id); - } catch (Throwable t) { - Trace.trace(Trace.SEVERE, " Could not load wizardFragment: " + cf[i].getAttribute("id"), t); - } - } - } - - /** - * Returns the initial selection provider. - * - * @return an initial selection provider, or <code>null</code> if none could be found - */ - public static InitialSelectionProvider getInitialSelectionProvider() { - if (selectionProvider == null) - loadInitialSelectionProvider(); - - return selectionProvider; - } - - /** - * Load the initial selection provider. - */ - private static synchronized void loadInitialSelectionProvider() { - if (selectionProvider != null) - return; - - Trace.trace(Trace.CONFIG, "->- Loading .initialSelectionProvider extension point ->-"); - IExtensionRegistry registry = Platform.getExtensionRegistry(); - IConfigurationElement[] cf = registry.getConfigurationElementsFor(ServerUIPlugin.PLUGIN_ID, "initialSelectionProvider"); - - if (cf.length == 1) { - try { - selectionProvider = (InitialSelectionProvider) cf[0].createExecutableExtension("class"); - Trace.trace(Trace.CONFIG, " Loaded initialSelectionProvider: " + cf[0].getAttribute("id")); - } catch (Throwable t) { - Trace.trace(Trace.SEVERE, " Could not load initialSelectionProvider: " + cf[0].getAttribute("id"), t); - } - } else if (cf.length > 1) - Trace.trace(Trace.WARNING, "More that one initial selection provider found - ignoring"); - else - Trace.trace(Trace.CONFIG, "No initial selection provider found"); - - if (selectionProvider == null) - selectionProvider = new InitialSelectionProvider(); - - Trace.trace(Trace.CONFIG, "-<- Done loading .initialSelectionProvider extension point -<-"); - } - - protected static WizardFragment getWizardFragment(WizardFragmentData fragment) { - if (fragment == null) - return null; - - if (fragment.fragment == null) { - try { - long time = System.currentTimeMillis(); - fragment.fragment = (WizardFragment) fragment.ce.createExecutableExtension("class"); - Trace.trace(Trace.PERFORMANCE, "ServerUIPlugin.getWizardFragment(): <" + (System.currentTimeMillis() - time) + "> " + fragment.ce.getAttribute("id")); - } catch (Throwable t) { - Trace.trace(Trace.SEVERE, "Could not create wizardFragment: " + fragment.ce.getAttribute("id"), t); - } - } - return fragment.fragment; - } - - public static void runOnServer(Object object, String launchMode) { - RunOnServerActionDelegate delegate = new RunOnServerActionDelegate(); - Action action = new Action() { - // dummy action - }; - if (object != null) { - StructuredSelection sel = new StructuredSelection(object); - delegate.selectionChanged(action, sel); - } else - delegate.selectionChanged(action, null); - - delegate.run(action); - } - - public static synchronized void addRegistryListener() { - if (registryListener != null) - return; - - registryListener = new RegistryChangeListener(); - IExtensionRegistry registry = Platform.getExtensionRegistry(); - registry.addRegistryChangeListener(registryListener, ServerUIPlugin.PLUGIN_ID); - } - - protected static void handleWizardFragmentDelta(IExtensionDelta delta) { - if (wizardFragments == null) // not loaded yet - return; - - IConfigurationElement[] cf = delta.getExtension().getConfigurationElements(); - - Map<String, WizardFragmentData> map = new HashMap<String, WizardFragmentData>(wizardFragments); - if (delta.getKind() == IExtensionDelta.ADDED) { - loadWizardFragments(cf, map); - } else { - /*int size = wizardFragments.size(); - WizardFragment[] wf = new WizardFragment[size]; - wizardFragments.toArray(wf); - int size2 = cf.length; - - for (int i = 0; i < size; i++) { - for (int j = 0; j < size2; j++) { - if (wf[i].getId().equals(cf[j].getAttribute("id"))) { - wf[i].dispose(); - wizardFragments.remove(wf[i]); - } - } - }*/ - } - wizardFragments = map; - } - - /** - * Utility method to tokenize a string into an array. - * - * @param str a string to be parsed - * @param delim the delimiters - * @return an array containing the tokenized string - */ - public static String[] tokenize(String str, String delim) { - if (str == null) - return new String[0]; - - List<String> list = new ArrayList<String>(); - - StringTokenizer st = new StringTokenizer(str, delim); - while (st.hasMoreTokens()) { - String s = st.nextToken(); - if (s != null && s.length() > 0) - list.add(s.trim()); - } - - String[] s = new String[list.size()]; - list.toArray(s); - return s; - } - - /** - * Returns the launchable clients for the given server and launchable - * object. - * - * @param server org.eclipse.wst.server.core.IServer - * @param launchable - * @param launchMode String - * @return an array of clients - */ - public static IClient[] getClients(IServer server, Object launchable, String launchMode) { - if (server == null || launchable == null) - return new IClient[0]; - - ArrayList<IClient> list = new ArrayList<IClient>(5); - IClient[] clients = ServerPlugin.getClients(); - if (clients != null) { - int size = clients.length; - for (int i = 0; i < size; i++) { - Trace.trace(Trace.FINEST, "client= " + clients[i]); - if (clients[i].supports(server, launchable, launchMode)) - list.add(clients[i]); - } - } - - IClient[] clients2 = new IClient[list.size()]; - list.toArray(clients2); - return clients2; - } - - public static Object[] getLaunchableAdapter(IServer server, IModuleArtifact moduleArtifact) throws CoreException { - ILaunchableAdapter[] adapters = ServerPlugin.getLaunchableAdapters(); - if (adapters != null) { - int size2 = adapters.length; - IStatus lastStatus = null; - for (int j = 0; j < size2; j++) { - ILaunchableAdapter adapter = adapters[j]; - try { - Object launchable2 = adapter.getLaunchable(server, moduleArtifact); - Trace.trace(Trace.FINEST, "adapter= " + adapter + ", launchable= " + launchable2); - if (launchable2 != null) - return new Object[] { adapter, launchable2 }; - } catch (CoreException ce) { - lastStatus = ce.getStatus(); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error in launchable adapter", e); - } - } - if (lastStatus != null) - throw new CoreException(lastStatus); - } - - // backup - ILaunchableAdapter launchableAdapter = ServerPlugin.findLaunchableAdapter(DefaultLaunchableAdapter.ID); - Object launchable = launchableAdapter.getLaunchable(server, moduleArtifact); - return new Object[] { launchableAdapter, launchable }; - } - - public static Object[] adaptLabelChangeObjects(Object[] obj) { - if (obj == null) - return obj; - - List<Object> list = new ArrayList<Object>(); - int size = obj.length; - for (int i = 0; i < size; i++) { - if (obj[i] instanceof IModule) { - list.add(obj[i]); - } else if (obj[i] instanceof IServer) { - list.add(obj[i]); - } else if (obj[i] instanceof ModuleServer) { - list.add(obj[i]); - } else if (obj[i] instanceof IProject) { - IProject proj = (IProject) obj[i]; - IModule[] m = ServerUtil.getModules(proj); - int size2 = m.length; - for (int j = 0; j < size2; j++) - list.add(m[j]); - } - } - - Object[] o = new Object[list.size()]; - list.toArray(o); - return o; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerUIPreferences.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerUIPreferences.java deleted file mode 100644 index e9c6e3a0f..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerUIPreferences.java +++ /dev/null @@ -1,364 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.StringTokenizer; - -import org.eclipse.core.runtime.Preferences; -/** - * Helper class that stores preference information for server tools UI. - */ -public class ServerUIPreferences { - private static final String PREF_IMPORT_LOCATION = "import-location"; - private static final String PREF_SAVE_EDITORS = "save-editors"; - private static final String PREF_HOST_NAMES = "host-names"; - private static final String PREF_SHOW_ON_ACTIVITY = "show-on-activity"; - private static final String PREF_LAUNCH_MODE = "launch-mode"; - private static final String PREF_LAUNCH_MODE2 = "launch-mode2"; - private static final String PREF_ENABLE_BREAKPOINTS = "enable-breakpoints"; - private static final String PREF_RESTART = "restart"; - private static final String PREF_CREATE_SERVER_WITH_RUNTIME = "create-server"; - private static final String PREF_PUBLISH_ON_ADD_REMOVE = "publish-on-add-remove"; - - public static final byte SAVE_EDITORS_ALWAYS = 2; - public static final byte SAVE_EDITORS_NEVER = 0; - public static final byte SAVE_EDITORS_PROMPT = 1; - - public static final byte LAUNCH_MODE_PROMPT = 0; - public static final byte LAUNCH_MODE_CONTINUE = 1; - public static final byte LAUNCH_MODE_RESTART = 2; - - public static final byte LAUNCH_MODE2_PROMPT = 0; - public static final byte LAUNCH_MODE2_CONTINUE = 1; - public static final byte LAUNCH_MODE2_RESTART = 2; - public static final byte LAUNCH_MODE2_DISABLE_BREAKPOINTS = 3; - - public static final byte ENABLE_BREAKPOINTS_PROMPT = 0; - public static final byte ENABLE_BREAKPOINTS_ALWAYS = 1; - public static final byte ENABLE_BREAKPOINTS_NEVER = 2; - - public static final byte RESTART_PROMPT = 0; - public static final byte RESTART_ALWAYS = 1; - public static final byte RESTART_NEVER = 2; - - private static final int MAX_HOSTNAMES = 10; - - private Preferences preferences; - - /** - * ServerUIPreference constructor comment. - */ - public ServerUIPreferences() { - super(); - preferences = ServerUIPlugin.getInstance().getPluginPreferences(); - } - - public void setDefaults() { - preferences.setDefault(PREF_LAUNCH_MODE, getDefaultLaunchMode()); - preferences.setDefault(PREF_LAUNCH_MODE2, getDefaultLaunchMode2()); - preferences.setDefault(PREF_ENABLE_BREAKPOINTS, getDefaultEnableBreakpoints()); - preferences.setDefault(PREF_RESTART, getDefaultRestart()); - preferences.setDefault(PREF_SAVE_EDITORS, getDefaultSaveEditors()); - preferences.setDefault(PREF_HOST_NAMES, "localhost"); - preferences.setDefault(PREF_SHOW_ON_ACTIVITY, true); - preferences.setDefault(PREF_CREATE_SERVER_WITH_RUNTIME, false); - preferences.setDefault(PREF_PUBLISH_ON_ADD_REMOVE, true); - } - - /** - * Returns the default value of whether the user should be prompted - * when the launch mode of the server doesn't match. - * - * @return byte - */ - public byte getDefaultLaunchMode() { - return LAUNCH_MODE_PROMPT; - } - - /** - * Returns whether the user should be prompted when the launch mode - * of the server doesn't match. - * - * @return int - */ - public int getLaunchMode() { - return preferences.getInt(PREF_LAUNCH_MODE); - } - - /** - * Sets whether the user should be prompted when the launch mode - * of the server doesn't match. - * - * @param b a launch mode constant - */ - public void setLaunchMode(int b) { - preferences.setValue(PREF_LAUNCH_MODE, b); - ServerUIPlugin.getInstance().savePluginPreferences(); - } - - /** - * Returns the default value of whether the user should be prompted - * when the launch mode of the server doesn't match. - * - * @return byte - */ - public byte getDefaultLaunchMode2() { - return LAUNCH_MODE2_PROMPT; - } - - /** - * Returns whether the user should be prompted when the launch mode - * of the server doesn't match. - * - * @return int - */ - public int getLaunchMode2() { - return preferences.getInt(PREF_LAUNCH_MODE2); - } - - /** - * Sets whether the user should be prompted when the launch mode - * of the server doesn't match. - * - * @param b a launch mode constant - */ - public void setLaunchMode2(int b) { - preferences.setValue(PREF_LAUNCH_MODE2, b); - ServerUIPlugin.getInstance().savePluginPreferences(); - } - - /** - * Returns the default value of whether the user should be prompted - * when the breakpoint enablement doesn't match the server state. - * - * @return int - */ - public byte getDefaultEnableBreakpoints() { - return ENABLE_BREAKPOINTS_PROMPT; - } - - /** - * Returns whether the user should be prompted when the breakpoint - * enablement doesn't match the server state. - * - * @return int - */ - public int getEnableBreakpoints() { - return preferences.getInt(PREF_ENABLE_BREAKPOINTS); - } - - /** - * Sets whether the user should be prompted when the breakpoint - * enablement doesn't match the server state. - * - * @param b a breakpoint enablement constant - */ - public void setEnableBreakpoints(int b) { - preferences.setValue(PREF_ENABLE_BREAKPOINTS, b); - ServerUIPlugin.getInstance().savePluginPreferences(); - } - - /** - * Returns the default value of whether the user should be prompted - * when the server requires restarting. - * - * @return int - */ - public byte getDefaultRestart() { - return RESTART_PROMPT; - } - - /** - * Returns whether the user should be prompted when the server requires - * restarting. - * - * @return int - */ - public int getRestart() { - return preferences.getInt(PREF_RESTART); - } - - /** - * Sets whether the user should be prompted when the server requires restarting. - * - * @param b a breakpoint enablement constant - */ - public void setRestart(int b) { - preferences.setValue(PREF_RESTART, b); - ServerUIPlugin.getInstance().savePluginPreferences(); - } - - /** - * Returns the import location. - * - * @return java.lang.String - */ - public String getImportLocation() { - return preferences.getString(PREF_IMPORT_LOCATION); - } - - /** - * Sets the import location. - * - * @param s the import location - */ - public void setImportLocation(String s) { - preferences.setValue(PREF_IMPORT_LOCATION, s); - ServerUIPlugin.getInstance().savePluginPreferences(); - } - - /** - * Returns the default setting for saving editors before launching. - * - * @return byte - */ - public byte getDefaultSaveEditors() { - return SAVE_EDITORS_PROMPT; - } - - /** - * Returns the setting for saving editors before launching. - * - * @return byte - */ - public byte getSaveEditors() { - return (byte) preferences.getInt(PREF_SAVE_EDITORS); - } - - /** - * Sets the value for saving editors before launching. - * - * @param b - */ - public void setSaveEditors(byte b) { - preferences.setValue(PREF_SAVE_EDITORS, b); - ServerUIPlugin.getInstance().savePluginPreferences(); - } - - /** - * Returns the default setting for opening the servers view on activity. - * - * @return boolean - */ - public boolean getDefaultShowOnActivity() { - return true; - } - - /** - * Returns the setting for opening the servers view on activity. - * - * @return boolean - */ - public boolean getShowOnActivity() { - return preferences.getBoolean(PREF_SHOW_ON_ACTIVITY); - } - - /** - * Sets the value for opening the servers view on activity. - * - * @param b - */ - public void setShowOnActivity(boolean b) { - preferences.setValue(PREF_SHOW_ON_ACTIVITY, b); - ServerUIPlugin.getInstance().savePluginPreferences(); - } - - /** - * Return the list of most recently used hostnames. - * - * @return the hostnames - */ - public List<String> getHostnames() { - String s = preferences.getString(PREF_HOST_NAMES); - StringTokenizer st = new StringTokenizer(s, "|*|"); - List<String> list = new ArrayList<String>(); - while (st.hasMoreTokens()) { - list.add(st.nextToken()); - } - return list; - } - - /** - * Add a new hostname to the most recently used list. - * - * @param hostname - */ - public void addHostname(String hostname) { - if ("localhost".equals(hostname)) - return; - - List<String> list = getHostnames(); - - // remove duplicates - if (list.contains(hostname)) - list.remove(hostname); - - // always add second (leave localhost first) - list.add(1, hostname); - - // remove least used hostname - if (list.size() > MAX_HOSTNAMES) - list.remove(list.size() - 1); - - StringBuffer sb = new StringBuffer(); - Iterator iterator = list.iterator(); - while (iterator.hasNext()) { - String s = (String) iterator.next(); - sb.append(s); - sb.append("|*|"); - } - preferences.setValue(PREF_HOST_NAMES, sb.toString()); - ServerUIPlugin.getInstance().savePluginPreferences(); - } - - /** - * Returns the setting for whether a server should be created with runtimes - * when possible. - * - * @return boolean - */ - public boolean getCreateServerWithRuntime() { - return preferences.getBoolean(PREF_CREATE_SERVER_WITH_RUNTIME); - } - - /** - * Sets the value for whether a server should be created with runtimes - * when possible. - * - * @param b - */ - public void setCreateServerWithRuntime(boolean b) { - preferences.setValue(PREF_CREATE_SERVER_WITH_RUNTIME, b); - ServerUIPlugin.getInstance().savePluginPreferences(); - } - - /** - * Returns the setting for publishing when modules are added or removed. - * - * @return boolean - */ - public boolean getPublishOnAddRemoveModule() { - return preferences.getBoolean(PREF_PUBLISH_ON_ADD_REMOVE); - } - - /** - * Sets the value for publishing when modules are added or removed. - * - * @param b - */ - public void setPublishOnAddRemoveModule(boolean b) { - preferences.setValue(PREF_PUBLISH_ON_ADD_REMOVE, b); - ServerUIPlugin.getInstance().savePluginPreferences(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Startup.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Startup.java deleted file mode 100644 index 066ada67e..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Startup.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal; - -import org.eclipse.core.runtime.IStatus; - -import org.eclipse.wst.server.core.*; -import org.eclipse.wst.server.core.internal.IStartup; -import org.eclipse.wst.server.core.internal.Server; -import org.eclipse.wst.server.core.util.PublishAdapter; -import org.eclipse.wst.server.ui.internal.audio.Audio; -/** - * - */ -public class Startup implements IStartup { - /** - * @see org.eclipse.wst.server.core.internal.IStartup#startup() - */ - public void startup() { - Trace.trace(Trace.FINEST, "Audio startup"); - - final IPublishListener publishListener = new PublishAdapter() { - public void publishFinished(IServer server, IStatus status) { - Audio.playSound("org.eclipse.wst.server.sound.publishFinished"); - } - }; - - final IServerListener serverListener = new IServerListener() { - public void serverChanged(ServerEvent event) { - int eventKind = event.getKind(); - IServer server = event.getServer(); - if (eventKind == (ServerEvent.SERVER_CHANGE | ServerEvent.STATE_CHANGE)) { - int state = server.getServerState(); - if (state == IServer.STATE_STARTED) - Audio.playSound("org.eclipse.wst.server.sound.serverStart"); - else if (state == IServer.STATE_STOPPED) - Audio.playSound("org.eclipse.wst.server.sound.serverStop"); - } - } - }; - - IServerLifecycleListener listener = new IServerLifecycleListener() { - public void serverAdded(IServer server) { - server.addServerListener(serverListener); - ((Server) server).addPublishListener(publishListener); - } - - public void serverChanged(IServer server) { - // do nothing - } - - public void serverRemoved(IServer server) { - server.removeServerListener(serverListener); - ((Server) server).removePublishListener(publishListener); - } - }; - ServerCore.addServerLifecycleListener(listener); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/TerminationDialog.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/TerminationDialog.java deleted file mode 100644 index a14eb7784..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/TerminationDialog.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.osgi.util.NLS; -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.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; -/** - * Dialog that prompts a user to see if a server should - * be terminated. - */ -public class TerminationDialog extends Dialog { - protected String serverName; - - /** - * TerminationDialog constructor comment. - * - * @param parentShell a shell - * @param serverName a server name - */ - public TerminationDialog(Shell parentShell, String serverName) { - super(parentShell); - this.serverName = serverName; - setBlockOnOpen(true); - } - - /** - * - */ - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - newShell.setText(Messages.terminateServerDialogTitle); - } - - /** - * Creates and returns the contents of the upper part - * of this dialog (above the button bar). - * - * @param parent the parent composite to contain the dialog area - * @return the dialog area control - */ - protected Control createDialogArea(Composite parent) { - // create a composite with standard margins and spacing - Composite composite = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); - layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); - layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); - layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - composite.setFont(parent.getFont()); - PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, ContextIds.TERMINATE_SERVER_DIALOG); - - Label label = new Label(composite, SWT.WRAP); - label.setText(NLS.bind(Messages.terminateServerDialogMessage, new String[] {serverName})); - GridData data = new GridData(); - data.widthHint = 400; - label.setLayoutData(data); - - Dialog.applyDialogFont(composite); - - return composite; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Trace.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Trace.java deleted file mode 100644 index c8513f727..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Trace.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal; - -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.HashSet; -import java.util.Set; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -/** - * Helper class to route trace output. - */ -public class Trace { - public static final byte CONFIG = 0; - public static final byte INFO = 1; - public static final byte WARNING = 2; - public static final byte SEVERE = 3; - public static final byte FINEST = 4; - public static final byte FINER = 5; - public static final byte PERFORMANCE = 6; - public static final byte EXTENSION_POINT = 7; - - private static final String[] levelNames = new String[] { - "CONFIG ", "INFO ", "WARNING", "SEVERE ", "FINER ", "FINEST ", "PERF ", "EXTENSION"}; - - private static final SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yy HH:mm.ss.SSS"); - - private static Set<String> logged = new HashSet<String>(); - - /** - * Trace constructor comment. - */ - private Trace() { - super(); - } - - /** - * Trace the given text. - * - * @param level a trace level - * @param s a message - */ - public static void trace(byte level, String s) { - trace(level, s, null); - } - - /** - * Trace the given message and exception. - * - * @param level a trace level - * @param s a message - * @param t a throwable - */ - public static void trace(byte level, String s, Throwable t) { - if (s == null) - return; - - if (level == SEVERE) { - if (!logged.contains(s)) { - ServerUIPlugin.getInstance().getLog().log(new Status(IStatus.ERROR, ServerUIPlugin.PLUGIN_ID, s, t)); - logged.add(s); - } - } - - if (!ServerUIPlugin.getInstance().isDebugging()) - return; - - StringBuffer sb = new StringBuffer(ServerUIPlugin.PLUGIN_ID); - sb.append(" "); - sb.append(levelNames[level]); - sb.append(" "); - sb.append(sdf.format(new Date())); - sb.append(" "); - sb.append(s); - System.out.println(sb.toString()); - if (t != null) - t.printStackTrace(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/WebLaunchableClient.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/WebLaunchableClient.java deleted file mode 100644 index fb694d0a5..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/WebLaunchableClient.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.debug.core.ILaunch; -import org.eclipse.ui.browser.IWebBrowser; -import org.eclipse.ui.browser.IWorkbenchBrowserSupport; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.model.ClientDelegate; -import org.eclipse.wst.server.core.util.HttpLaunchable; -/** - * - */ -public class WebLaunchableClient extends ClientDelegate { - /* - * @see ClientDelegate#supports(ILaunchable) - */ - public boolean supports(IServer server, Object launchable, String launchMode) { - return (launchable instanceof HttpLaunchable); - } - - /* - * @see ClientDelegate#launch(ILaunchable) - */ - public IStatus launch(IServer server, Object launchable, String launchMode, ILaunch launch) { - HttpLaunchable http = (HttpLaunchable) launchable; - try { - IWorkbenchBrowserSupport browserSupport = ServerUIPlugin.getInstance().getWorkbench().getBrowserSupport(); - IWebBrowser browser = browserSupport.createBrowser(IWorkbenchBrowserSupport.LOCATION_BAR | IWorkbenchBrowserSupport.NAVIGATION_BAR, null, null, null); - browser.openURL(http.getURL()); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error opening browser", e); - } - return null; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/AbstractServerActionDelegate.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/AbstractServerActionDelegate.java deleted file mode 100644 index 4bde13af8..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/AbstractServerActionDelegate.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.actions; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.ui.internal.EclipseUtil; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IActionDelegate; -/** - * - */ -public abstract class AbstractServerActionDelegate implements IActionDelegate { - protected List<IServer> servers; - - /** - * Return true if this server can currently be acted on. - * - * @return boolean - * @param server org.eclipse.wst.server.core.IServer - */ - public abstract boolean accept(IServer server); - - /** - * Perform action on this server. - * - * @param shell a shell - * @param server a server - */ - public abstract void perform(Shell shell, IServer server); - - /* (non-Javadoc) - * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) - */ - public void run(IAction action) { - Shell shell = EclipseUtil.getShell(); - Iterator iterator = servers.iterator(); - Object obj = iterator.next(); - if (obj instanceof IServer) { - IServer server = (IServer) obj; - if (accept(server)) - perform(shell, server); - selectionChanged(action, new StructuredSelection(servers)); - } - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) - */ - public void selectionChanged(IAction action, ISelection selection) { - servers = new ArrayList<IServer>(); - if (selection.isEmpty() || !(selection instanceof StructuredSelection)) { - action.setEnabled(false); - return; - } - - boolean enabled = false; - Iterator iterator = ((StructuredSelection) selection).iterator(); - while (iterator.hasNext()) { - Object obj = iterator.next(); - if (obj instanceof IServer) { - IServer server = (IServer) obj; - if (accept(server)) { - servers.add(server); - enabled = true; - } - } else { - action.setEnabled(false); - return; - } - } - action.setEnabled(enabled); - } -} diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/BreakpointDialog.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/BreakpointDialog.java deleted file mode 100644 index 1285833ce..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/BreakpointDialog.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.actions; - -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.wst.server.ui.internal.Messages; -/** - * Custom message dialog that is used when the server is not in the correct launch mode. - */ -public class BreakpointDialog extends MessageDialog { - protected boolean remember; - - public BreakpointDialog(Shell parentShell) { - super(parentShell, Messages.wizDebugOnServerTitle, null, - Messages.dialogBreakpoints, MessageDialog.WARNING, - new String[] {IDialogConstants.OK_LABEL, IDialogConstants.PROCEED_LABEL, - IDialogConstants.CANCEL_LABEL}, 0); - } - - protected Control createCustomArea(Composite parent) { - final Button rememberB = new Button(parent, SWT.CHECK); - rememberB.setText(Messages.dialogRemember); - rememberB.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - remember = rememberB.getSelection(); - } - }); - return rememberB; - } - - public boolean isRemember() { - return remember; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/LaunchWizardAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/LaunchWizardAction.java deleted file mode 100644 index a1ee767d8..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/LaunchWizardAction.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.actions; - -import org.eclipse.jface.action.Action; -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.IWorkbench; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.IWorkbenchWizard; -import org.eclipse.ui.PlatformUI; -/** - * An abstract action that opens up a workbench wizard when run. - */ -abstract class LaunchWizardAction extends Action { - /** - * LaunchWizardAction - */ - public LaunchWizardAction() { - super(); - } - - /** - * Return the workbench wizard that should be opened. - * - * @return the wizard to open - */ - protected abstract IWorkbenchWizard getWizard(); - - /* - * @see IAction.run() - */ - public void run() { - IWorkbench workbench = PlatformUI.getWorkbench(); - IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); - ISelection selection = workbenchWindow.getSelectionService().getSelection(); - - IStructuredSelection selectionToPass = null; - if (selection instanceof IStructuredSelection) - selectionToPass = (IStructuredSelection) selection; - else - selectionToPass = StructuredSelection.EMPTY; - - IWorkbenchWizard wizard = getWizard(); - wizard.init(workbench, selectionToPass); - WizardDialog dialog = new WizardDialog(workbench.getActiveWorkbenchWindow().getShell(), wizard); - dialog.open(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/NewServerAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/NewServerAction.java deleted file mode 100644 index 136235a93..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/NewServerAction.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.actions; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.wizard.WizardDialog; - -import org.eclipse.wst.server.ui.internal.wizard.NewServerWizard; -/** - * Action to create a new server. - */ -public class NewServerAction extends NewWizardAction { - protected String[] ids; - protected String[] values; - - /** - * Create a new NewServerAction. - */ - public NewServerAction() { - super(); - } - - /** - * Create a new NewServerAction with some initial task model - * properties. - * - * @param ids - * @param values - */ - public NewServerAction(String[] ids, String[] values) { - super(); - this.ids = ids; - this.values = values; - } - - /** - * Performs this action. - * <p> - * This method is called when the delegating action has been triggered. - * Implement this method to do the actual work. - * </p> - * - * @param action the action proxy that handles the presentation portion of the - * action - */ - public void run(IAction action) { - NewServerWizard wizard = null; - if (ids == null) - wizard = new NewServerWizard(); - else - wizard = new NewServerWizard(ids, values); - wizard.init(workbench, selection); - WizardDialog dialog = new WizardDialog(workbench.getActiveWorkbenchWindow().getShell(), wizard); - dialog.open(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/NewServerWizardAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/NewServerWizardAction.java deleted file mode 100644 index 0c1a2f6f6..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/NewServerWizardAction.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.actions; - -import org.eclipse.ui.IWorkbenchWizard; -import org.eclipse.wst.server.ui.internal.ImageResource; -import org.eclipse.wst.server.ui.internal.Messages; -import org.eclipse.wst.server.ui.internal.wizard.NewServerWizard; -/** - * An action to invoke the new server and server configuration wizard. - */ -public class NewServerWizardAction extends LaunchWizardAction { - protected String[] ids; - protected String[] values; - - /** - * New server action. - */ - public NewServerWizardAction() { - super(); - - setImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_CTOOL_NEW_SERVER)); - setText(Messages.actionSetNewServer); - } - - /** - * New server action. - * - * @param ids ids to pass into the action - * @param values values to pass into the action - */ - public NewServerWizardAction(String[] ids, String[] values) { - this(); - this.ids = ids; - this.values = values; - } - - /** - * Return the wizard that should be opened. - * - * @return org.eclipse.ui.IWorkbenchWizard - */ - protected IWorkbenchWizard getWizard() { - return new NewServerWizard(ids, values); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/NewWizardAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/NewWizardAction.java deleted file mode 100644 index afcf36f32..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/NewWizardAction.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.actions; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.IWorkbenchWindowActionDelegate; -/** - * Action to create a new server element through a wizard. - */ -public abstract class NewWizardAction implements IWorkbenchWindowActionDelegate { - protected IWorkbench workbench; - protected IStructuredSelection selection; - - /** - * NewWizardAction constructor comment. - */ - public NewWizardAction() { - super(); - } - - /** - * Disposes this action delegate. The implementor should unhook any references - * to itself so that garbage collection can occur. - */ - public void dispose() { - // do nothing - } - - /** - * Initializes this action delegate with the workbench window it will work in. - * - * @param window the window that provides the context for this delegate - */ - public void init(IWorkbenchWindow window) { - workbench = window.getWorkbench(); - } - - /** - * Notifies this action delegate that the selection in the workbench has changed. - * <p> - * Implementers can use this opportunity to change the availability of the - * action or to modify other presentation properties. - * </p> - * - * @param action the action proxy that handles presentation portion of the action - * @param sel the current selection in the workbench - */ - public void selectionChanged(IAction action, ISelection sel) { - if (sel instanceof IStructuredSelection) - selection = (IStructuredSelection) sel; - else - selection = null; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/OptionsMessageDialog.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/OptionsMessageDialog.java deleted file mode 100644 index 2de77e3a9..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/OptionsMessageDialog.java +++ /dev/null @@ -1,104 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.actions; - -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.MessageDialog; -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.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.Shell; -import org.eclipse.wst.server.ui.internal.Messages; -/** - * Custom message dialog that displays a set of options. - * Return value is the option - */ -public class OptionsMessageDialog extends MessageDialog { - protected int radio; - protected boolean remember; - protected String[] options; - - public OptionsMessageDialog(Shell parentShell, String title, String dialogMessage, String[] options) { - super(parentShell, title, null, dialogMessage, MessageDialog.QUESTION, - new String[] {IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL}, 0); - this.options = options; - if (options == null) - throw new IllegalArgumentException("Must have at least one option"); - } - - protected Control createDialogArea(Composite parent) { - // create message area - createMessageArea(parent); - // create the top level composite for the dialog area - /*Composite composite = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.marginHeight = 0; - layout.marginWidth = 0; - composite.setLayout(layout); - GridData data = new GridData(GridData.FILL_BOTH); - data.horizontalSpan = 2; - composite.setLayoutData(data);*/ - createCustomArea(parent); - return parent; - } - - protected Control createCustomArea(Composite parent) { - int size = options.length; - for (int i = 0; i < size; i++) { - new Label(parent, SWT.NONE); - - Button radioB = new Button(parent, SWT.RADIO); - radioB.setText(options[i]); - final int x = i; - radioB.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - radio = x; - } - }); - if (i == 0) { - radioB.setSelection(true); - radio = 0; - } - } - - new Label(parent, SWT.NONE); - new Label(parent, SWT.NONE); - - final Button rememberB = new Button(parent, SWT.CHECK); - rememberB.setText(Messages.dialogRemember); - GridData data = new GridData(); - data.horizontalSpan = 2; - rememberB.setLayoutData(data); - rememberB.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - remember = rememberB.getSelection(); - } - }); - return rememberB; - } - - protected void buttonPressed(int buttonId) { - if (buttonId == 0) - setReturnCode(radio); - else - setReturnCode(9); - close(); - } - - public boolean isRemember() { - return remember; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RunOnServerAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RunOnServerAction.java deleted file mode 100644 index 67642d326..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RunOnServerAction.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.actions; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.wst.server.ui.internal.ImageResource; -import org.eclipse.wst.server.ui.internal.Messages; -/** - * "Run on Server" menu action. Allows the user to select an - * object, and have automatic server creation, launching, and - * the appropriate client to appear. A new instance of this - * action must be created for each object that the user selects. - */ -public class RunOnServerAction extends Action { - protected RunOnServerActionDelegate delegate; - - /** - * Run on server action. - * - * @param object the object to attempt to debug - */ - public RunOnServerAction(Object object) { - super(Messages.actionRunOnServer); - - setDisabledImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_DTOOL_RUN_ON_SERVER)); - setHoverImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_CTOOL_RUN_ON_SERVER)); - setImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_ETOOL_RUN_ON_SERVER)); - - delegate = new RunOnServerActionDelegate(); - if (object != null) { - StructuredSelection sel = new StructuredSelection(object); - delegate.selectionChanged(this, sel); - } else - delegate.selectionChanged(this, null); - } - - /** - * Implementation of method defined on <code>IAction</code>. - */ - public void run() { - delegate.run(this); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RunOnServerActionDelegate.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RunOnServerActionDelegate.java deleted file mode 100644 index 6df0cf299..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RunOnServerActionDelegate.java +++ /dev/null @@ -1,817 +0,0 @@ -/********************************************************************** - * Copyright (c) 2003, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - **********************************************************************/ -package org.eclipse.wst.server.ui.internal.actions; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.debug.core.*; -import org.eclipse.debug.ui.IDebugUIConstants; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.window.Window; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.wst.server.core.*; -import org.eclipse.wst.server.core.internal.IClient; -import org.eclipse.wst.server.core.internal.ILaunchableAdapter; -import org.eclipse.wst.server.core.internal.ServerPlugin; -import org.eclipse.wst.server.core.internal.Trace; -import org.eclipse.wst.server.core.model.ModuleArtifactDelegate; -import org.eclipse.wst.server.ui.internal.*; -import org.eclipse.wst.server.ui.internal.viewers.ModuleArtifactComposite; -import org.eclipse.wst.server.ui.internal.wizard.*; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.IWorkbenchWindowActionDelegate; -/** - * Support for starting/stopping server and clients for resources running on a server. - */ -public class RunOnServerActionDelegate implements IWorkbenchWindowActionDelegate { - protected static final String[] launchModes = { - ILaunchManager.RUN_MODE, ILaunchManager.DEBUG_MODE, ILaunchManager.PROFILE_MODE }; - - protected Object selection; - - protected IWorkbenchWindow window; - - protected static Object globalSelection; - - protected static Map<String, Boolean> globalLaunchMode; - protected String launchMode = ILaunchManager.RUN_MODE; - - protected boolean tasksAndClientShown; - - protected ILaunchableAdapter launchableAdapter; - protected IClient client; - - /** - * RunOnServerActionDelegate constructor comment. - */ - public RunOnServerActionDelegate() { - super(); - } - - /** - * Disposes this action delegate. The implementor should unhook any references - * to itself so that garbage collection can occur. - */ - public void dispose() { - window = null; - } - - /** - * Initializes this action delegate with the workbench window it will work in. - * - * @param newWindow the window that provides the context for this delegate - */ - public void init(IWorkbenchWindow newWindow) { - window = newWindow; - } - - public IServer getServer(IModule module, IModuleArtifact moduleArtifact, IProgressMonitor monitor) throws CoreException { - IServer server = ServerCore.getDefaultServer(module); - - // ignore preference if the server doesn't support this mode. - if (server != null && !ServerUIPlugin.isCompatibleWithLaunchMode(server, launchMode)) - server = null; - - if (server != null && !ServerUtil.containsModule(server, module, monitor)) { - IServerWorkingCopy wc = server.createWorkingCopy(); - try { - ServerUtil.modifyModules(wc, new IModule[] { module }, new IModule[0], monitor); - wc.save(false, monitor); - } catch (CoreException ce) { - Trace.trace(Trace.SEVERE, "Could not add module to server", ce); - server = null; - } - } - - Shell shell; - if (window != null) - shell = window.getShell(); - else - shell = ServerUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getShell(); - - if (server == null) { - // try the full wizard - Trace.trace(Trace.FINEST, "Launching wizard"); - RunOnServerWizard wizard = new RunOnServerWizard(module, launchMode, moduleArtifact); - WizardDialog dialog = new WizardDialog(shell, wizard); - if (dialog.open() == Window.CANCEL) { - if (monitor != null) - monitor.setCanceled(true); - return null; - } - - try { - Job.getJobManager().join("org.eclipse.wst.server.ui.family", null); - } catch (Exception e) { - Trace.trace(Trace.WARNING, "Error waiting for job", e); - } - server = wizard.getServer(); - boolean preferred = wizard.isPreferredServer(); - tasksAndClientShown = true; - client = wizard.getSelectedClient(); - launchableAdapter = wizard.getLaunchableAdapter(); - - // set preferred server if requested - if (server != null && preferred) { - try { - ServerCore.setDefaultServer(module, server, monitor); - } catch (CoreException ce) { - String message = Messages.errorCouldNotSavePreference; - ErrorDialog.openError(shell, Messages.errorDialogTitle, message, ce.getStatus()); - } - } - } - - try { - Job.getJobManager().join("org.eclipse.wst.server.ui.family", new NullProgressMonitor()); - } catch (Exception e) { - Trace.trace(Trace.WARNING, "Error waiting for job", e); - } - - return server; - } - - /** - * Run the resource on a server. - */ - protected void run() { - final IModuleArtifact[] moduleArtifacts = ServerPlugin.getModuleArtifacts(selection); - if (moduleArtifacts == null || moduleArtifacts.length == 0 || moduleArtifacts[0] == null) { - EclipseUtil.openError(Messages.errorNoArtifact); - Trace.trace(Trace.FINEST, "No module artifact found"); - return; - } - - Shell shell2 = null; - if (window != null) - shell2 = window.getShell(); - else { - try { - shell2 = ServerUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getShell(); - } catch (Exception e) { - // ignore - } - if (shell2 == null) - shell2 = Display.getDefault().getActiveShell(); - } - final Shell shell = shell2; - final IAdaptable info = new IAdaptable() { - public Object getAdapter(Class adapter) { - if (Shell.class.equals(adapter)) - return shell; - return null; - } - }; - - // get a valid ModuleArtifact that we can use for launching - // TODO The ModuleArtifactComposite should be part of the RunOnServerWizard - final IModuleArtifact moduleArtifact; - if (moduleArtifacts.length > 1) { - ModuleArtifactComposite artifactComposite = new ModuleArtifactComposite(shell, moduleArtifacts, launchMode); - if (artifactComposite.open() == Window.CANCEL) - return; - - moduleArtifact = artifactComposite.getSelection(); - } else - moduleArtifact = moduleArtifacts[0]; - - if (moduleArtifact.getModule() == null) { // 149425 - EclipseUtil.openError(Messages.errorNoModules); - Trace.trace(Trace.FINEST, "Module artifact not contained in a module"); - return; - } - final IModule module = moduleArtifact.getModule(); - - // check for servers with the given start mode - IServer[] servers = ServerCore.getServers(); - boolean found = false; - if (servers != null) { - int size = servers.length; - for (int i = 0; i < size && !found; i++) { - if (ServerUIPlugin.isCompatibleWithLaunchMode(servers[i], launchMode)) { - try { - IModule[] parents = servers[i].getRootModules(module, null); - if (parents != null && parents.length > 0) - found = true; - } catch (Exception e) { - // ignore - } - } - } - } - - if (!found) { - // no existing server supports the project and start mode! - // check if there might be another one that can be created - IServerType[] serverTypes = ServerCore.getServerTypes(); - if (serverTypes != null) { - int size = serverTypes.length; - for (int i = 0; i < size && !found; i++) { - IServerType type = serverTypes[i]; - IModuleType[] moduleTypes = type.getRuntimeType().getModuleTypes(); - if (type.supportsLaunchMode(launchMode) && ServerUtil.isSupportedModule(moduleTypes, module.getModuleType())) { - found = true; - } - } - } - if (!found) { - EclipseUtil.openError(Messages.errorNoServer); - Trace.trace(Trace.FINEST, "No server for start mode"); - return; - } - } - - if (!ServerUIPlugin.saveEditors()) - return; - - tasksAndClientShown = false; - IServer server2 = null; - client = null; - launchableAdapter = null; - try { - IProgressMonitor monitor = new NullProgressMonitor(); - server2 = getServer(module, moduleArtifact, monitor); - if (monitor.isCanceled()) - return; - - if (server2 != null) { - IFolder folder = server2.getServerConfiguration(); - if (folder != null && folder.getProject() != null && !folder.getProject().isOpen()) - folder.getProject().open(monitor); - } - } catch (CoreException ce) { - EclipseUtil.openError(shell, ce.getLocalizedMessage()); - return; - } - final IServer server = server2; - //if (monitor.isCanceled()) - // return; - - Trace.trace(Trace.FINEST, "Server: " + server); - - if (server == null) { - EclipseUtil.openError(Messages.errorNoServer); - Trace.trace(Trace.SEVERE, "No server found"); - return; - } - - if (!ServerUIPlugin.promptIfDirty(shell, server)) - return; - - if (!tasksAndClientShown) { - RunOnServerWizard wizard = new RunOnServerWizard(server, launchMode, moduleArtifact); - if (wizard.shouldAppear()) { - WizardDialog dialog = new WizardDialog(shell, wizard); - if (dialog.open() == Window.CANCEL) - return; - } else - wizard.performFinish(); - client = wizard.getSelectedClient(); - launchableAdapter = wizard.getLaunchableAdapter(); - } - - // if there is no client, use a dummy - if (client == null) { - client = new IClient() { - public String getDescription() { - return Messages.clientDefaultDescription; - } - - public String getId() { - return "org.eclipse.wst.server.ui.client.default"; - } - - public String getName() { - return Messages.clientDefaultName; - } - - public IStatus launch(IServer server3, Object launchable2, String launchMode3, ILaunch launch) { - return Status.OK_STATUS; - } - - public boolean supports(IServer server3, Object launchable2, String launchMode3) { - return true; - } - }; - } - - if (moduleArtifact instanceof ModuleArtifactDelegate) { - boolean canLoad = false; - try { - Class c = Class.forName(moduleArtifact.getClass().getName()); - if (c.newInstance() != null) - canLoad = true; - } catch (Throwable t) { - Trace.trace(Trace.WARNING, "Could not load module artifact delegate class, switching to backup"); - } - if (canLoad) { - try { - IProgressMonitor monitor = new NullProgressMonitor(); - ILaunchConfiguration config = getLaunchConfiguration(server, (ModuleArtifactDelegate) moduleArtifact, launchableAdapter, client, monitor); - config.launch(launchMode, monitor); - } catch (CoreException ce) { - Trace.trace(Trace.SEVERE, "Could not launch Run on Server", ce); - } - return; - } - } - - Thread thread = new Thread("Run on Server") { - public void run() { - Trace.trace(Trace.FINEST, "Ready to launch"); - - // start server if it's not already started - // and cue the client to start - IModule[] modules = new IModule[] { module }; // TODO: get parent hierarchy correct - int state = server.getServerState(); - if (state == IServer.STATE_STARTING) { - LaunchClientJob clientJob = new LaunchClientJob(server, modules, launchMode, moduleArtifact, launchableAdapter, client); - clientJob.schedule(); - } else if (state == IServer.STATE_STARTED) { - boolean restart = false; - String mode = server.getMode(); - IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager(); - boolean disabledBreakpoints = false; - - if (server.getServerRestartState()) { - int result = openRestartDialog(shell); - if (result == 0) { - launchMode = mode; - restart = true; - } else if (result == 9) // cancel - return; - } - if (!restart) { - if (!ILaunchManager.RUN_MODE.equals(mode) && ILaunchManager.RUN_MODE.equals(launchMode)) { - boolean breakpointsOption = false; - if (breakpointManager.isEnabled() && ILaunchManager.DEBUG_MODE.equals(mode)) - breakpointsOption = true; - int result = openOptionsDialog(shell, Messages.wizRunOnServerTitle, Messages.dialogModeWarningRun, breakpointsOption); - if (result == 0) - restart = true; - else if (result == 1) { - breakpointManager.setEnabled(false); - disabledBreakpoints = true; - launchMode = mode; - } else if (result == 2) - launchMode = mode; - else // result == 9 // cancel - return; - } else if (!ILaunchManager.DEBUG_MODE.equals(mode) && ILaunchManager.DEBUG_MODE.equals(launchMode)) { - int result = openOptionsDialog(shell, Messages.wizDebugOnServerTitle, Messages.dialogModeWarningDebug, false); - if (result == 0) - restart = true; - else if (result == 1) - launchMode = mode; - else // result == 9 // cancel - return; - } else if (!ILaunchManager.PROFILE_MODE.equals(mode) && ILaunchManager.PROFILE_MODE.equals(launchMode)) { - boolean breakpointsOption = false; - if (breakpointManager.isEnabled() && ILaunchManager.DEBUG_MODE.equals(mode)) - breakpointsOption = true; - int result = openOptionsDialog(shell, Messages.wizProfileOnServerTitle, Messages.dialogModeWarningProfile, breakpointsOption); - if (result == 0) - restart = true; - else if (result == 1) { - breakpointManager.setEnabled(false); - disabledBreakpoints = true; - launchMode = mode; - } else if (result == 2) - launchMode = mode; - else // result == 9 // cancel - return; - } - - if (ILaunchManager.DEBUG_MODE.equals(launchMode)) { - if (!breakpointManager.isEnabled() && !disabledBreakpoints) { - int result = openBreakpointDialog(shell); - if (result == 0) - breakpointManager.setEnabled(true); - else if (result == 1) { - // ignore - } else // result == 2 - return; - } - } - } - - final LaunchClientJob clientJob = new LaunchClientJob(server, modules, launchMode, moduleArtifact, launchableAdapter, client); - if (restart) { - final IServer server3 = server; - server.restart(launchMode, new IServer.IOperationListener() { - public void done(IStatus result) { - // Only publish if the server requires publish before launching the client. - if (server3.shouldPublish()) { - server3.publish(IServer.PUBLISH_INCREMENTAL, null, info, new IServer.IOperationListener() { - public void done(IStatus result2) { - if (result2.isOK()) - clientJob.schedule(); - } - }); - } else { - clientJob.schedule(); - } - } - }); - } else { - // Only publish if the server requires publish before launching the client. - if (server.shouldPublish()) { - server.publish(IServer.PUBLISH_INCREMENTAL, null, info, new IServer.IOperationListener() { - public void done(IStatus result) { - if (result.isOK()) - clientJob.schedule(); - } - }); - } else { - clientJob.schedule(); - } - } - } else if (state != IServer.STATE_STOPPING) { - final LaunchClientJob clientJob = new LaunchClientJob(server, modules, launchMode, moduleArtifact, launchableAdapter, client); - - server.start(launchMode, new IServer.IOperationListener() { - public void done(IStatus result) { - if (result.isOK()) - clientJob.schedule(); - } - }); - } - } - }; - thread.setDaemon(true); - thread.start(); - } - - protected void setupLaunchConfiguration(ILaunchConfigurationWorkingCopy config, IServer server, ModuleArtifactDelegate moduleArtifact, ILaunchableAdapter launchableAdapter, IClient client) { - String launchName = NLS.bind(Messages.runOnServerLaunchConfigName, moduleArtifact.getName()); - launchName = getValidLaunchConfigurationName(launchName); - if (!launchName.equals(config.getName())) { - ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); - launchName = launchManager.generateUniqueLaunchConfigurationNameFrom(launchName); - config.rename(launchName); - } - - config.setAttribute(RunOnServerLaunchConfigurationDelegate.ATTR_SERVER_ID, server.getId()); - config.setAttribute(RunOnServerLaunchConfigurationDelegate.ATTR_MODULE_ARTIFACT, moduleArtifact.serialize()); - config.setAttribute(RunOnServerLaunchConfigurationDelegate.ATTR_MODULE_ARTIFACT_CLASS, moduleArtifact.getClass().getName()); - if (launchableAdapter != null) - config.setAttribute(RunOnServerLaunchConfigurationDelegate.ATTR_LAUNCHABLE_ADAPTER_ID, launchableAdapter.getId()); - else - config.setAttribute(RunOnServerLaunchConfigurationDelegate.ATTR_LAUNCHABLE_ADAPTER_ID, (String)null); - config.setAttribute(RunOnServerLaunchConfigurationDelegate.ATTR_CLIENT_ID, client.getId()); - - try { - IProject project = moduleArtifact.getModule().getProject(); - config.setMappedResources(new IResource[] { project }); - } catch (Exception e) { - Trace.trace(Trace.WARNING, "Could not associate launch with a project", e); - } - } - - protected ILaunchConfiguration getLaunchConfiguration(IServer server, ModuleArtifactDelegate moduleArtifact, ILaunchableAdapter launchableAdapter2, IClient client2, IProgressMonitor monitor) throws CoreException { - String serverId = server.getId(); - ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); - ILaunchConfigurationType launchConfigType = launchManager.getLaunchConfigurationType("org.eclipse.wst.server.ui.launchConfigurationType"); - ILaunchConfiguration[] launchConfigs = null; - try { - launchConfigs = launchManager.getLaunchConfigurations(launchConfigType); - } catch (CoreException e) { - // ignore - } - - if (launchConfigs != null) { - int size = launchConfigs.length; - for (int i = 0; i < size; i++) { - List list = launchConfigs[i].getAttribute(IDebugUIConstants.ATTR_FAVORITE_GROUPS, (List)null); - if (list == null || list.isEmpty()) { - try { - String serverId2 = launchConfigs[i].getAttribute(RunOnServerLaunchConfigurationDelegate.ATTR_SERVER_ID, (String) null); - if (serverId.equals(serverId2)) { - final ILaunchConfigurationWorkingCopy wc = launchConfigs[i].getWorkingCopy(); - setupLaunchConfiguration(wc, server, moduleArtifact, launchableAdapter2, client2); - if (wc.isDirty()) { - try { - return wc.doSave(); - } catch (CoreException ce) { - Trace.trace(Trace.SEVERE, "Error configuring launch", ce); - } - } - return launchConfigs[i]; - } - } catch (CoreException e) { - Trace.trace(Trace.SEVERE, "Error configuring launch", e); - } - } - } - } - - // create a new launch configuration - String launchName = NLS.bind(Messages.runOnServerLaunchConfigName, moduleArtifact.getName()); - launchName = getValidLaunchConfigurationName(launchName); - launchName = launchManager.generateUniqueLaunchConfigurationNameFrom(launchName); - ILaunchConfigurationWorkingCopy wc = launchConfigType.newInstance(null, launchName); - wc.setAttribute(RunOnServerLaunchConfigurationDelegate.ATTR_SERVER_ID, serverId); - setupLaunchConfiguration(wc, server, moduleArtifact, launchableAdapter2, client2); - return wc.doSave(); - } - - protected static final char[] INVALID_CHARS = new char[] {'\\', ':', '*', '?', '"', '<', '>', '|', '\0', '@', '&'}; - protected String getValidLaunchConfigurationName(String s) { - if (s == null || s.length() == 0) - return "1"; - int size = INVALID_CHARS.length; - for (int i = 0; i < size; i++) { - s = s.replace(INVALID_CHARS[i], '_'); - } - return s; - } - - /** - * Open an options dialog. - * - * @param shell - * @param title - * @param message - * @param breakpointsOption - * @return a dialog return constant - */ - protected static int openOptionsDialog(final Shell shell, final String title, final String message, final boolean breakpointsOption) { - if (breakpointsOption) { - int current = ServerUIPlugin.getPreferences().getLaunchMode2(); - if (current == ServerUIPreferences.LAUNCH_MODE2_RESTART) - return 0; - else if (current == ServerUIPreferences.LAUNCH_MODE2_DISABLE_BREAKPOINTS) - return 1; - else if (current == ServerUIPreferences.LAUNCH_MODE2_CONTINUE) - return 2; - } else { - int current = ServerUIPlugin.getPreferences().getLaunchMode(); - if (current == ServerUIPreferences.LAUNCH_MODE_RESTART) - return 0; - else if (current == ServerUIPreferences.LAUNCH_MODE_CONTINUE) - return 1; - } - final int[] i = new int[1]; - shell.getDisplay().syncExec(new Runnable() { - public void run() { - OptionsMessageDialog dialog = null; - String[] items = null; - if (breakpointsOption) { - items = new String[] { - Messages.dialogModeWarningRestart, - Messages.dialogModeWarningBreakpoints, - Messages.dialogModeWarningContinue - }; - } else { - items = new String[] { - Messages.dialogModeWarningRestart, - Messages.dialogModeWarningContinue - }; - } - - dialog = new OptionsMessageDialog(shell, title, message, items); - i[0] = dialog.open(); - - if (dialog.isRemember()) { - if (breakpointsOption) { - if (i[0] == 0) - ServerUIPlugin.getPreferences().setLaunchMode2(ServerUIPreferences.LAUNCH_MODE2_RESTART); - else if (i[0] == 1) - ServerUIPlugin.getPreferences().setLaunchMode2(ServerUIPreferences.LAUNCH_MODE2_DISABLE_BREAKPOINTS); - else if (i[0] == 2) - ServerUIPlugin.getPreferences().setLaunchMode2(ServerUIPreferences.LAUNCH_MODE2_CONTINUE); - } else { - if (i[0] == 0) - ServerUIPlugin.getPreferences().setLaunchMode(ServerUIPreferences.LAUNCH_MODE_RESTART); - else if (i[0] == 1) - ServerUIPlugin.getPreferences().setLaunchMode(ServerUIPreferences.LAUNCH_MODE_CONTINUE); - } - } - } - }); - return i[0]; - } - - /** - * Open an options dialog. - * - * @param shell - * @return a dialog return constant - */ - protected static int openBreakpointDialog(final Shell shell) { - int current = ServerUIPlugin.getPreferences().getEnableBreakpoints(); - if (current == ServerUIPreferences.ENABLE_BREAKPOINTS_ALWAYS) - return 0; - else if (current == ServerUIPreferences.ENABLE_BREAKPOINTS_NEVER) - return 1; - - final int[] i = new int[1]; - shell.getDisplay().syncExec(new Runnable() { - public void run() { - OptionsMessageDialog dialog = new OptionsMessageDialog(shell, - Messages.wizDebugOnServerTitle, Messages.dialogBreakpoints, new String[] { - Messages.dialogBreakpointsReenable, Messages.dialogModeWarningContinue}); - i[0] = dialog.open(); - if (dialog.isRemember()) { - if (i[0] == 0) - ServerUIPlugin.getPreferences().setEnableBreakpoints(ServerUIPreferences.ENABLE_BREAKPOINTS_ALWAYS); - else if (i[0] == 1) - ServerUIPlugin.getPreferences().setEnableBreakpoints(ServerUIPreferences.ENABLE_BREAKPOINTS_NEVER); - } - } - }); - return i[0]; - } - - /** - * Open a restart options dialog. - * - * @param shell - * @return a dialog return constant - */ - protected static int openRestartDialog(final Shell shell) { - int current = ServerUIPlugin.getPreferences().getRestart(); - if (current == ServerUIPreferences.RESTART_ALWAYS) - return 0; - else if (current == ServerUIPreferences.RESTART_NEVER) - return 1; - - final int[] i = new int[1]; - shell.getDisplay().syncExec(new Runnable() { - public void run() { - OptionsMessageDialog dialog = new OptionsMessageDialog(shell, - Messages.defaultDialogTitle, Messages.dialogRestart, new String[] { - Messages.dialogRestartRestart, Messages.dialogRestartContinue}); - i[0] = dialog.open(); - if (dialog.isRemember()) { - if (i[0] == 0) - ServerUIPlugin.getPreferences().setRestart(ServerUIPreferences.RESTART_ALWAYS); - else if (i[0] == 1) - ServerUIPlugin.getPreferences().setRestart(ServerUIPreferences.RESTART_NEVER); - } - } - }); - return i[0]; - } - - /** - * The delegating action has been performed. Implement - * this method to do the actual work. - * - * @param action action proxy that handles the presentation - * portion of the plugin action - */ - public void run(IAction action) { - Trace.trace(Trace.FINEST, "Running on Server..."); - try { - run(); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Run on Server Error", e); - } - } - - protected boolean isEnabled() { - try { - Boolean b = globalLaunchMode.get(getLaunchMode()); - return b.booleanValue(); - } catch (Exception e) { - // ignore - } - return false; - } - - /** - * Returns the start mode that the server should use. - */ - protected String getLaunchMode() { - return launchMode; - } - - /** - * Set the launch mode. - * - * @param launchMode a {@link ILaunchManager} launch mode - */ - public void setLaunchMode(String launchMode) { - this.launchMode = launchMode; - } - - /** - * Determine which clients can act on the current selection. - * - * @param action action proxy that handles presentation - * portion of the plugin action - * @param sel current selection in the desktop - */ - public void selectionChanged(IAction action, ISelection sel) { - Trace.trace(Trace.FINEST, "> selectionChanged"); - selection = null; - long time = System.currentTimeMillis(); - if (sel == null || sel.isEmpty() || !(sel instanceof IStructuredSelection)) { - action.setEnabled(false); - globalSelection = null; - return; - } - - IStructuredSelection select = (IStructuredSelection) sel; - Iterator iterator = select.iterator(); - if (iterator.hasNext()) - selection = iterator.next(); - if (iterator.hasNext()) { // more than one selection (should never happen) - action.setEnabled(false); - selection = null; - globalSelection = null; - return; - } - - if (selection != globalSelection) { - Trace.trace(Trace.FINEST, "Selection: " + selection); - if (selection != null) - Trace.trace(Trace.FINEST, "Selection type: " + selection.getClass().getName()); - globalSelection = selection; - globalLaunchMode = new HashMap<String, Boolean>(); - if (!ServerPlugin.hasModuleArtifact(globalSelection)) { - action.setEnabled(false); - return; - } - - Trace.trace(Trace.FINEST, "checking for module artifact"); - // TODO - multiple module artifacts - IModuleArtifact[] moduleArtifacts = ServerPlugin.getModuleArtifacts(globalSelection); - IModuleArtifact moduleArtifact = null; - if (moduleArtifacts != null && moduleArtifacts.length > 0) - moduleArtifact = moduleArtifacts[0]; - - IModule module = null; - if (moduleArtifact != null) - module = moduleArtifact.getModule(); - Trace.trace(Trace.FINEST, "moduleArtifact= " + moduleArtifact + ", module= " + module); - if (module != null) - findGlobalLaunchModes(module); - else { - globalLaunchMode.put(ILaunchManager.RUN_MODE, new Boolean(true)); - globalLaunchMode.put(ILaunchManager.DEBUG_MODE, new Boolean(true)); - globalLaunchMode.put(ILaunchManager.PROFILE_MODE, new Boolean(true)); - } - } - - action.setEnabled(isEnabled()); - Trace.trace(Trace.FINEST, "< selectionChanged " + (System.currentTimeMillis() - time)); - } - - /** - * Determines whether there is a server factory available for the given module - * and the various start modes. - */ - protected void findGlobalLaunchModes(IModule module) { - IServerType[] serverTypes = ServerCore.getServerTypes(); - if (serverTypes != null) { - int size = serverTypes.length; - for (int i = 0; i < size; i++) { - IServerType type = serverTypes[i]; - if (isValidServerType(type, module)) { - for (byte b = 0; b < launchModes.length; b++) { - if (type.supportsLaunchMode(launchModes[b])) { - globalLaunchMode.put(launchModes[b], new Boolean(true)); - } - } - } - } - } - } - - /** - * Returns true if the given server type can launch the module. - */ - protected boolean isValidServerType(IServerType type, IModule module) { - try { - IRuntimeType runtimeType = type.getRuntimeType(); - ServerUtil.isSupportedModule(runtimeType.getModuleTypes(), module.getModuleType()); - } catch (Exception e) { - return false; - } - return true; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RunOnServerLaunchConfigurationDelegate.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RunOnServerLaunchConfigurationDelegate.java deleted file mode 100644 index 4a4303a40..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RunOnServerLaunchConfigurationDelegate.java +++ /dev/null @@ -1,273 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.actions; - -import org.eclipse.core.runtime.CoreException; -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.debug.core.DebugPlugin; -import org.eclipse.debug.core.IBreakpointManager; -import org.eclipse.debug.core.ILaunch; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchManager; -import org.eclipse.debug.core.model.LaunchConfigurationDelegate; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.ServerCore; -import org.eclipse.wst.server.core.internal.IClient; -import org.eclipse.wst.server.core.internal.ILaunchableAdapter; -import org.eclipse.wst.server.core.internal.ServerPlugin; -import org.eclipse.wst.server.core.model.ModuleArtifactDelegate; -import org.eclipse.wst.server.ui.internal.EclipseUtil; -import org.eclipse.wst.server.ui.internal.LaunchClientJob; -import org.eclipse.wst.server.ui.internal.Messages; -import org.eclipse.wst.server.ui.internal.ServerUIPlugin; -import org.eclipse.wst.server.ui.internal.Trace; - -public class RunOnServerLaunchConfigurationDelegate extends LaunchConfigurationDelegate { - public static final String ATTR_SERVER_ID = "server-id"; - public static final String ATTR_MODULE_ARTIFACT = "module-artifact"; - public static final String ATTR_MODULE_ARTIFACT_CLASS = "module-artifact-class"; - - public static final String ATTR_LAUNCHABLE_ADAPTER_ID = "launchable-adapter-id"; - public static final String ATTR_CLIENT_ID = "client-id"; - - protected boolean saveBeforeLaunch(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException { - // ignore - return true; - } - - public void launch(ILaunchConfiguration configuration, String launchMode, final ILaunch launch2, - IProgressMonitor monitor) throws CoreException { - - String serverId = configuration.getAttribute(ATTR_SERVER_ID, (String)null); - String moduleArt = configuration.getAttribute(ATTR_MODULE_ARTIFACT, (String)null); - String moduleArtifactClass = configuration.getAttribute(ATTR_MODULE_ARTIFACT_CLASS, (String)null); - String laId = configuration.getAttribute(ATTR_LAUNCHABLE_ADAPTER_ID, (String)null); - String clientId = configuration.getAttribute(ATTR_CLIENT_ID, (String)null); - - IServer server = ServerCore.findServer(serverId); - IModule module = null; - ModuleArtifactDelegate moduleArtifact = null; - ILaunchableAdapter launchableAdapter = null; - if (laId != null) - launchableAdapter = ServerPlugin.findLaunchableAdapter(laId); - IClient client = ServerPlugin.findClient(clientId); - - try { - Class c = Class.forName(moduleArtifactClass); - moduleArtifact = (ModuleArtifactDelegate) c.newInstance(); - moduleArtifact.deserialize(moduleArt); - module = moduleArtifact.getModule(); - } catch (Throwable t) { - Trace.trace(Trace.WARNING, "Could not load module artifact delegate class"); - } - - if (moduleArtifact == null) - throw new CoreException(new Status(IStatus.ERROR, ServerUIPlugin.PLUGIN_ID, Messages.errorLaunchConfig)); - - if (module == null) - throw new CoreException(new Status(IStatus.ERROR, ServerUIPlugin.PLUGIN_ID, Messages.errorLaunchConfig)); - - if (server == null) - throw new CoreException(new Status(IStatus.ERROR, ServerUIPlugin.PLUGIN_ID, Messages.errorInvalidServer)); - - if (launchableAdapter == null) - throw new CoreException(new Status(IStatus.ERROR, ServerUIPlugin.PLUGIN_ID, Messages.errorLaunchConfig)); - - final Shell[] shell2 = new Shell[1]; - Display.getDefault().syncExec(new Runnable() { - public void run() { - shell2[0] = EclipseUtil.getShell(); - } - }); - final Shell shell = shell2[0]; - final IAdaptable info = new IAdaptable() { - public Object getAdapter(Class adapter) { - if (Shell.class.equals(adapter)) - return shell; - return null; - } - }; - - if (client == null) { - // if there is no client, use a dummy - client = new IClient() { - public String getDescription() { - return Messages.clientDefaultDescription; - } - - public String getId() { - return "org.eclipse.wst.server.ui.client.default"; - } - - public String getName() { - return Messages.clientDefaultName; - } - - public IStatus launch(IServer server3, Object launchable2, String launchMode3, ILaunch launch) { - return Status.OK_STATUS; - } - - public boolean supports(IServer server3, Object launchable2, String launchMode3) { - return true; - } - }; - } - - Trace.trace(Trace.FINEST, "Ready to launch"); - launch2.addProcess(new RunOnServerProcess(launch2)); - - // start server if it's not already started - // and cue the client to start - IModule[] modules = new IModule[] { module }; // TODO: get parent hierarchy correct - int state = server.getServerState(); - if (state == IServer.STATE_STARTING) { - LaunchClientJob clientJob = new LaunchClientJob(server, modules, launchMode, moduleArtifact, launchableAdapter, client); - clientJob.schedule(); - } else if (state == IServer.STATE_STARTED) { - boolean restart = false; - String mode = server.getMode(); - IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager(); - boolean disabledBreakpoints = false; - - if (server.getServerRestartState()) { // TODO - restart state might not be set until after publish - int result = RunOnServerActionDelegate.openRestartDialog(shell); - if (result == 0) { - launchMode = mode; - restart = true; - } else if (result == 9) { // cancel - launch2.terminate(); - return; - } - } - if (!restart) { - if (!ILaunchManager.RUN_MODE.equals(mode) && ILaunchManager.RUN_MODE.equals(launchMode)) { - boolean breakpointsOption = false; - if (breakpointManager.isEnabled() && ILaunchManager.DEBUG_MODE.equals(mode)) - breakpointsOption = true; - int result = RunOnServerActionDelegate.openOptionsDialog(shell, Messages.wizRunOnServerTitle, Messages.dialogModeWarningRun, breakpointsOption); - if (result == 0) - restart = true; - else if (result == 1) { - breakpointManager.setEnabled(false); - disabledBreakpoints = true; - launchMode = mode; - } else if (result == 2) - launchMode = mode; - else { // result == 9 // cancel - launch2.terminate(); - return; - } - } else if (!ILaunchManager.DEBUG_MODE.equals(mode) && ILaunchManager.DEBUG_MODE.equals(launchMode)) { - int result = RunOnServerActionDelegate.openOptionsDialog(shell, Messages.wizDebugOnServerTitle, Messages.dialogModeWarningDebug, false); - if (result == 0) - restart = true; - else if (result == 1) - launchMode = mode; - else { // result == 9 // cancel - launch2.terminate(); - return; - } - } else if (!ILaunchManager.PROFILE_MODE.equals(mode) && ILaunchManager.PROFILE_MODE.equals(launchMode)) { - boolean breakpointsOption = false; - if (breakpointManager.isEnabled() && ILaunchManager.DEBUG_MODE.equals(mode)) - breakpointsOption = true; - int result = RunOnServerActionDelegate.openOptionsDialog(shell, Messages.wizProfileOnServerTitle, Messages.dialogModeWarningProfile, breakpointsOption); - if (result == 0) - restart = true; - else if (result == 1) { - breakpointManager.setEnabled(false); - disabledBreakpoints = true; - launchMode = mode; - } else if (result == 2) - launchMode = mode; - else {// result == 9 // cancel - launch2.terminate(); - return; - } - } - - if (ILaunchManager.DEBUG_MODE.equals(launchMode)) { - if (!breakpointManager.isEnabled() && !disabledBreakpoints) { - int result = RunOnServerActionDelegate.openBreakpointDialog(shell); - if (result == 0) - breakpointManager.setEnabled(true); - else if (result == 1) { - // ignore - } else { // result == 2 - launch2.terminate(); - return; - } - } - } - } - - final LaunchClientJob clientJob = new LaunchClientJob(server, modules, launchMode, moduleArtifact, launchableAdapter, client); - if (restart) { - final IServer server2 = server; - server.restart(launchMode, new IServer.IOperationListener() { - public void done(IStatus result) { - // Only publish if the server requires publish before launching the client. - if (server2.shouldPublish()) { - server2.publish(IServer.PUBLISH_INCREMENTAL, null, info, new IServer.IOperationListener() { - public void done(IStatus result2) { - if (result2.isOK()) - clientJob.schedule(); - } - }); - } else { - clientJob.schedule(); - } - } - }); - } else { - // Only publish if the server requires publish before launching the client. - if (server.shouldPublish()) { - server.publish(IServer.PUBLISH_INCREMENTAL, null, info, new IServer.IOperationListener() { - public void done(IStatus result) { - if (result.isOK()) - clientJob.schedule(); - } - }); - } else { - clientJob.schedule(); - } - } - } else if (state != IServer.STATE_STOPPING) { - final LaunchClientJob clientJob = new LaunchClientJob(server, modules, launchMode, moduleArtifact, launchableAdapter, client); - - /*ChainedJob myJob = new ChainedJob("test", server) { - protected IStatus run(IProgressMonitor monitor2) { - try { - LaunchConfigurationManager lcm = DebugUIPlugin.getDefault().getLaunchConfigurationManager(); - lcm.setRecentLaunch(launch2); - } catch (Throwable t) { - Trace.trace(Trace.WARNING, "Could not tweak debug launch history"); - } - return Status.OK_STATUS; - } - };*/ - - server.start(launchMode, new IServer.IOperationListener() { - public void done(IStatus result) { - if (result.isOK()) - clientJob.schedule(); - } - }); - } - launch2.terminate(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RunOnServerProcess.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RunOnServerProcess.java deleted file mode 100644 index fc76ce13a..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RunOnServerProcess.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.actions; - -import org.eclipse.debug.core.DebugException; -import org.eclipse.debug.core.ILaunch; -import org.eclipse.debug.core.model.IProcess; -import org.eclipse.debug.core.model.IStreamsProxy; -import org.eclipse.wst.server.ui.internal.Messages; -/** - * Dummy IProcess so that a Run on Server launch can be terminated. - */ -public class RunOnServerProcess implements IProcess { - protected ILaunch launch; - protected boolean isTerminated; - - public RunOnServerProcess(ILaunch launch) { - this.launch = launch; - } - - public String getAttribute(String arg0) { - return null; - } - - public int getExitValue() throws DebugException { - return 0; - } - - public String getLabel() { - return Messages.processName; - } - - public ILaunch getLaunch() { - return launch; - } - - public IStreamsProxy getStreamsProxy() { - return null; - } - - public void setAttribute(String arg0, String arg1) { - // ignore - } - - public Object getAdapter(Class arg0) { - return null; - } - - public boolean canTerminate() { - return true; - } - - public boolean isTerminated() { - return isTerminated; - } - - public void terminate() throws DebugException { - isTerminated = true; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/audio/Audio.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/audio/Audio.java deleted file mode 100644 index 24f7717fe..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/audio/Audio.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.audio; - -/** - * Audio is the main interface to the audio plugin.<p> - * - * Adding a new sound to your plugin is as easy as ABC: - * <ul> - * <li>A: Add the following requires to your plugin.xml:<br> - * <pre><import plugin="org.eclipse.wst.server.util"></pre></li> - * - * <li>B: Define a new sound extension point in your plugin.xml:<br> - * <pre><extension point="org.eclipse.wst.server.util.sound"> - * <category id="org.eclipse.myPlugin" - * name="My Plugin Name"/> - * <sound id="org.eclipse.myPlugin.mySound" - * category="org.eclipse.myPlugin" - * name="Something Happened" - * location="sounds/mySound.wav"/> - * <sound id="org.eclipse.myPlugin.myOtherSounds" - * category="org.eclipse.myPlugin" - * name="Another Event Happened"/> - * </extension></pre><br> - * (the location is optional. If it is not specified, the sound - * will not play until the user specifies an audio file)</li> - * - * <li>C: Call the sounds when the appropriate events occur within - * your plugin:<br> - * <pre>org.eclipse.wst.audio.Audio.playSound("org.eclipse.myPlugin.mySound");</pre></li> - * </ul> - */ -public class Audio { - /** - * AudioCore constructor comment. - */ - private Audio() { - super(); - } - - /** - * Plays the sound with the given id. - * - * @param id java.lang.String - */ - public static void playSound(String id) { - AudioCore.getInstance().playSound(id); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/audio/AudioCore.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/audio/AudioCore.java deleted file mode 100644 index dd4e08254..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/audio/AudioCore.java +++ /dev/null @@ -1,693 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.audio; - -import java.util.*; -import java.io.*; -import java.net.URL; -import javax.sound.sampled.*; - -import org.eclipse.core.runtime.*; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.wst.server.ui.internal.ServerUIPlugin; -import org.eclipse.wst.server.ui.internal.Trace; -/** - * Main audio plugin class. - */ -public class AudioCore { - protected static AudioCore instance; - - public static final String PREF_SOUND_ENABLED = "soundEnabled"; - public static final String PREF_VOLUME = "volume"; - - public static final String SOUNDS_FILE = "sounds.xml"; - public static final String DISABLED_FILE = "disabled-sounds.xml"; - - // Categories - map of String id to String names - private Map<String, String> categories; - - // Sounds - map of String id to Sound - private Map<String, Sound> sounds; - - // specific sounds or categories that have been disabled, by id - private List<String> disabledSounds; - private List<String> disabledCategories; - - // SoundMap - map of String id to an IPath - private Map<String, IPath> userSoundMap; - - /** - * AudioCore constructor comment. - */ - private AudioCore() { - super(); - - loadExtensionPoints(); - - loadSoundMap(); - loadDisabledLists(); - - - } - - /** - * Return the categories - * - * @return java.util.Map - */ - protected Map<String, String> getCategories() { - return categories; - } - - /** - * Returns the audio clip. - * - * @param url java.net.URL - * @return javax.sound.sampled.Clip - */ - protected static Clip getClip(URL url) { - try { - AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(url); - - AudioFormat format = audioInputStream.getFormat(); - - /** - * we can't yet open the device for ALAW/ULAW playback, - * convert ALAW/ULAW to PCM - */ - if ((format.getEncoding() == AudioFormat.Encoding.ULAW) || - (format.getEncoding() == AudioFormat.Encoding.ALAW)) { - AudioFormat tmp = new AudioFormat( - AudioFormat.Encoding.PCM_SIGNED, - format.getSampleRate(), - format.getSampleSizeInBits() * 2, - format.getChannels(), - format.getFrameSize() * 2, - format.getFrameRate(), true); - audioInputStream = AudioSystem.getAudioInputStream(tmp, audioInputStream); - format = tmp; - } - DataLine.Info info = new DataLine.Info( - Clip.class, audioInputStream.getFormat(), - ((int) audioInputStream.getFrameLength() * - format.getFrameSize())); - - Clip clip = (Clip) AudioSystem.getLine(info); - clip.open(audioInputStream); - return clip; - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Could not get clip: " + url, e); - } - return null; - } - - /** - * Returns true if audio is currently available on this system. - * - * @return boolean - */ - protected static boolean isAudioSupported() { - try { - boolean sound = false; - Mixer.Info[] info2 = AudioSystem.getMixerInfo(); - if (info2 != null) { - int size = info2.length; - for (int i = 0; i < size; i++) { - //Trace.trace(" " + info2[i]); - Mixer mixer = AudioSystem.getMixer(info2[i]); - if (mixer != null) { - //Trace.trace(" Mixer:" + mixer); - //Trace.trace(" " + mixer.getLineInfo()); - try { - Line.Info info = mixer.getLineInfo(); - Line line = mixer.getLine(info); - //Trace.trace(" Line:" + line); - if (line != null && line.toString().indexOf("Output") >= 0) - sound = true; - } catch (Exception e) { - // ignore - } - } - } - } - return sound; - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Could not verify audio status", e); - } - return true; - } - - /** - * Returns true if sound is enabled. - * - * @return boolean - */ - public boolean getDefaultSoundsEnabled() { - return getPreferenceStore().getDefaultBoolean(PREF_SOUND_ENABLED); - } - - /** - * Returns the default volume. - * - * @return int - */ - public int getDefaultVolume() { - return getPreferenceStore().getDefaultInt(PREF_VOLUME); - } - - /** - * Returns the singleton instance. - * - * @return org.eclipse.audio.internal.AudioCore - */ - public static AudioCore getInstance() { - if (instance == null) - instance = new AudioCore(); - return instance; - } - - /** - * - * @return org.eclipse.jface.preference.IPreferenceStore - */ - protected IPreferenceStore getPreferenceStore() { - return ServerUIPlugin.getInstance().getPreferenceStore(); - } - - /** - * Returns the sound with the given id. - * - * @param id java.lang.String - * @return org.eclipse.audio.Sound - */ - protected Sound getSound(String id) { - try { - return sounds.get(id); - } catch (Exception e) { - return null; - } - } - - /** - * Return the sounds. - * - * @return java.util.Map - */ - protected Map<String, Sound> getSounds() { - return sounds; - } - - /** - * Returns the full user sound map. - * - * @return java.util.Map - */ - protected Map<String, IPath> getUserSoundMap() { - if (userSoundMap == null) - loadSoundMap(); - return userSoundMap; - } - - /** - * Return the current URL for this sound. - * - * @param id java.lang.String - * @return java.net.URL - */ - protected IPath getUserSoundPath(String id) { - try { - if (userSoundMap == null) - loadSoundMap(); - - IPath path = userSoundMap.get(id); - if (path != null) - return path; - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Could not get sound URL: " + id, e); - } - return null; - } - - /** - * Returns the preferred volume. - * - * @return int - */ - public int getVolume() { - return getPreferenceStore().getInt(PREF_VOLUME); - } - - /** - * Initialize the default preferences. - * - * @param store org.eclipse.jface.preference.IPreferenceStore - */ - public static void initializeDefaultPreferences(IPreferenceStore store) { - store.setDefault(PREF_VOLUME, 18); - } - - /** - * Returns true if the given category is enabled. - * - * @param id java.lang.String - * @return boolean - */ - public boolean isCategoryEnabled(String id) { - if (id == null) - return false; - - if (disabledCategories == null) - loadDisabledLists(); - - return (!disabledCategories.contains(id)); - } - - /** - * Returns true if sound is enabled. - * - * @return boolean - */ - public boolean isSoundEnabled() { - return getPreferenceStore().getBoolean(PREF_SOUND_ENABLED); - } - - /** - * Returns true if the given sound is enabled. - * - * @param id java.lang.String - * @return boolean - */ - public boolean isSoundEnabled(String id) { - if (id == null) - return false; - - if (disabledSounds == null) - loadDisabledLists(); - - return (!disabledSounds.contains(id)); - } - - /** - * Saves the disabled sound list. - */ - private void loadDisabledLists() { - String filename = ServerUIPlugin.getInstance().getStateLocation().append(DISABLED_FILE).toOSString(); - - FileInputStream in = null; - disabledCategories = new ArrayList<String>(); - disabledSounds = new ArrayList<String>(); - try { - in = new FileInputStream(filename); - IMemento memento = XMLMemento.loadMemento(in); - - IMemento cat = memento.getChild("categories"); - IMemento[] children = cat.getChildren("category"); - - int size = children.length; - for (int i = 0; i < size; i++) { - try { - IMemento child = children[i]; - String id = child.getString("id"); - - disabledCategories.add(id); - } catch (Exception ex) { - Trace.trace(Trace.SEVERE, "Error reading URL map ", ex); - } - } - - IMemento sound = memento.getChild("sounds"); - children = sound.getChildren("sound"); - - size = children.length; - for (int i = 0; i < size; i++) { - try { - IMemento child = children[i]; - String id = child.getString("id"); - - disabledSounds.add(id); - } catch (Exception ex) { - Trace.trace(Trace.SEVERE, "Error reading URL map ", ex); - } - } - } catch (Exception e) { - //AudioPlugin.log(new Status(IStatus.WARNING, AudioPlugin.PLUGIN_ID, 0, "Could not load disabled sound information", e)); - } finally { - if (in != null) { - try { - in.close(); - } catch (Exception e) { - // ignore - } - } - } - } - - /** - * Load extension point. - */ - private void loadExtensionPoints() { - // load extension points - IExtensionRegistry registry = Platform.getExtensionRegistry(); - IConfigurationElement[] cf = registry.getConfigurationElementsFor(ServerUIPlugin.PLUGIN_ID, "audio"); - - int size = cf.length; - categories = new HashMap<String, String>(); - sounds = new HashMap<String, Sound>(); - - for (int i = 0; i < size; i++) { - try { - String elementName = cf[i].getName(); - String id = cf[i].getAttribute("id"); - String name = cf[i].getAttribute("name"); - if ("category".equals(elementName)) { - categories.put(id, name); - } else if ("sound".equals(elementName)) { - String category = cf[i].getAttribute("category"); - String location = cf[i].getAttribute("location"); - - URL realURL = null; - if (location != null && location.length() > 0) { - String pluginId = cf[i].getDeclaringExtension().getContributor().getName(); - URL url = FileLocator.find(Platform.getBundle(pluginId), new Path(location), null); - realURL = FileLocator.resolve(url); - } - - Sound sound = new Sound(id, category, name, realURL); - sounds.put(id, sound); - } - } catch (Throwable t) { - Trace.trace(Trace.SEVERE, "Could not load audio: " + cf[i].getAttribute("id"), t); - } - } - } - - /** - * Saves the disabled sound list. - */ - private void loadSoundMap() { - String filename = ServerUIPlugin.getInstance().getStateLocation().append(SOUNDS_FILE).toOSString(); - - InputStream in = null; - userSoundMap = new HashMap<String, IPath>(); - try { - in = new FileInputStream(filename); - IMemento memento = XMLMemento.loadMemento(in); - - IMemento[] children = memento.getChildren("map"); - - int size = children.length; - for (int i = 0; i < size; i++) { - try { - IMemento child = children[i]; - String id = child.getString("id"); - String pathStr = child.getString("path"); - IPath path = new Path(pathStr); - - userSoundMap.put(id, path); - } catch (Exception ex) { - Trace.trace(Trace.SEVERE, "Error reading URL map ", ex); - } - } - } catch (Exception e) { - // ignore - } finally { - if (in != null) { - try { - in.close(); - } catch (Exception e) { - // ignore - } - } - } - } - - /** - * Play the sound with the given id. (provided that - * the user has enabled the sound) - * - * @param id java.lang.String - */ - public void playSound(String id) { - if (!isSoundEnabled()) - return; - - if (!isSoundEnabled(id)) - return; - - try { - Sound sound = sounds.get(id); - String category = sound.getCategory(); - if (category != null && categories.containsKey(category)) { - if (!isCategoryEnabled(category)) - return; - } - - URL url = sound.getLocation(); - IPath path = getUserSoundPath(id); - if (path != null) - url = path.toFile().toURL(); - - playSound(url, getVolume()); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error playing audio: " + id, e); - } - } - - /** - * Plays the sound at the given url. - * - * @param url java.net.URL - */ - protected static void playSound(URL url, final int volume) { - try { - Trace.trace(Trace.FINEST, "playSound"); - if (url == null || volume <= 0) - return; - - final Clip clip = getClip(url); - if (clip == null) - return; - - Trace.trace(Trace.FINEST, "playing"); - - Thread t = new Thread("Sound Thread") { - public void run() { - // set gain - FloatControl gainControl = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN); - double value = volume / 20.0; - float dB = (float) (Math.log(value==0.0?0.0001:value)/Math.log(10.0)*20.0); - gainControl.setValue(dB); - - Trace.trace(Trace.FINEST, "start"); - clip.start(); - try { - sleep(99); - } catch (Exception e) { - // ignore - } - - while (clip.isActive()) { - try { - sleep(99); - } catch (Exception e) { - break; - } - } - clip.stop(); - clip.close(); - Trace.trace(Trace.FINEST, "stop"); - } - }; - t.setDaemon(true); - t.start(); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error playing audio: " + url, e); - } - } - - /** - * Saves the disabled sounds and categories list. - */ - private void saveDisabledLists() { - String filename = ServerUIPlugin.getInstance().getStateLocation().append(DISABLED_FILE).toOSString(); - - FileOutputStream fout = null; - try { - XMLMemento memento = XMLMemento.createWriteRoot("disabled"); - - IMemento cat = memento.createChild("categories"); - Iterator iterator = disabledCategories.iterator(); - while (iterator.hasNext()) { - IMemento child = cat.createChild("category"); - String id = (String) iterator.next(); - child.putString("id", id); - } - - IMemento sound = memento.createChild("sounds"); - iterator = disabledSounds.iterator(); - while (iterator.hasNext()) { - IMemento child = sound.createChild("sound"); - String id = (String) iterator.next(); - child.putString("id", id); - } - - fout = new FileOutputStream(filename); - memento.save(fout); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Could not save disabled information", e); - } finally { - if (fout != null) { - try { - fout.close(); - } catch (Exception e) { - // ignore - } - } - } - } - - /** - * Saves the disabled sound list. - */ - private void saveSoundMap() { - String filename = ServerUIPlugin.getInstance().getStateLocation().append(SOUNDS_FILE).toOSString(); - - FileOutputStream fout = null; - try { - XMLMemento memento = XMLMemento.createWriteRoot("sound-map"); - - Iterator iterator = userSoundMap.keySet().iterator(); - while (iterator.hasNext()) { - IMemento child = memento.createChild("map"); - String id = (String) iterator.next(); - child.putString("id", id); - IPath path = userSoundMap.get(id); - child.putString("path", path.toString()); - } - - fout = new FileOutputStream(filename); - memento.save(fout); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Could not save URL map information", e); - } finally { - if (fout != null) { - try { - fout.close(); - } catch (Exception e) { - // ignore - } - } - } - } - - /** - * Enable or disable a specific category. - * - * @param id java.lang.String - * @param b boolean - */ - public void setCategoryEnabled(String id, boolean b) { - if (id == null) - return; - - if (disabledCategories == null) - loadDisabledLists(); - - if (b) { - if (disabledCategories.contains(id)) { - disabledCategories.remove(id); - saveDisabledLists(); - } - } else { - if (!disabledCategories.contains(id)) { - disabledCategories.add(id); - saveDisabledLists(); - } - } - } - - /** - * Enable or disable a specific sound. - * - * @param id java.lang.String - * @param b boolean - */ - public void setSoundEnabled(String id, boolean b) { - if (id == null) - return; - - if (disabledSounds == null) - loadDisabledLists(); - - if (b) { - if (disabledSounds.contains(id)) { - disabledSounds.remove(id); - saveDisabledLists(); - } - } else { - if (!disabledSounds.contains(id)) { - disabledSounds.add(id); - saveDisabledLists(); - } - } - } - - /** - * Sets whether sound is enabled. - * - * @param enabled - */ - public void setSoundsEnabled(boolean enabled) { - getPreferenceStore().setValue(PREF_SOUND_ENABLED, enabled); - } - - /** - * Sets the current URL for this sound. - * - * @param id java.lang.String - * @param path IPath - */ - protected void setSoundURL(String id, IPath path) { - if (id == null || path == null) - return; - - try { - if (userSoundMap == null) - loadSoundMap(); - - userSoundMap.put(id, path); - saveSoundMap(); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Could not get sound URL: " + id, e); - } - } - - /** - * Sets the full user sound map. - * - * @param map the sound map - */ - protected void setUserSoundMap(Map<String, IPath> map) { - if (map != null) { - userSoundMap = map; - saveSoundMap(); - } - } - - /** - * Sets the volume. - * - * @param volume the volume - */ - public void setVolume(int volume) { - getPreferenceStore().setValue(PREF_VOLUME, volume); - } -} diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/audio/AudioPreferencePage.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/audio/AudioPreferencePage.java deleted file mode 100644 index fa4ea359a..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/audio/AudioPreferencePage.java +++ /dev/null @@ -1,468 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.audio; - -import java.net.URL; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.HashMap; -import java.util.Iterator; - -import org.eclipse.core.runtime.*; -import org.eclipse.swt.events.*; -import org.eclipse.jface.viewers.*; -import org.eclipse.swt.layout.*; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.*; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.preference.PreferencePage; -import org.eclipse.ui.IWorkbenchPreferencePage; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.help.IWorkbenchHelpSystem; -import org.eclipse.wst.server.ui.internal.ContextIds; -import org.eclipse.wst.server.ui.internal.Messages; -import org.eclipse.wst.server.ui.internal.SWTUtil; -import org.eclipse.wst.server.ui.internal.Trace; -/** - * Audio preference page. - */ -public class AudioPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { - protected Button enableButton; - protected Spinner volume; - - protected Map<String, IPath> userSoundMap; - - protected CategoryTableViewer viewer; - - boolean soundAvailable = true; - - /** - * AudioPreferencePage constructor comment. - */ - public AudioPreferencePage() { - super(); - - loadUserMapInfo(); - } - - protected IPath chooseAudioFile() { - FileDialog dialog = new FileDialog(getShell(), SWT.SINGLE); - dialog.setText(Messages.audioPrefSelectFile); - dialog.setFilterExtensions(new String[] {"*.au;*.wav"}); - dialog.setFilterPath(null); - dialog.open(); - - String[] filenames = dialog.getFileNames(); - if (filenames != null && filenames.length > 0) { - String filterPath = dialog.getFilterPath(); - return new Path(filterPath + java.io.File.separator + filenames[0]); - } - return null; - } - - /** - * Creates and returns the SWT control for the customized body - * of this preference page under the given parent composite. - * <p> - * This framework method must be implemented by concrete - * subclasses. - * </p> - * - * @param parent the parent composite - * @return the new control - */ - protected Control createContents(Composite parent) { - initializeDialogUnits(parent); - IWorkbenchHelpSystem whs = PlatformUI.getWorkbench().getHelpSystem(); - whs.setHelp(parent, ContextIds.AUDIO_PREFERENCES); - - final AudioCore core = AudioCore.getInstance(); - - Composite composite = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 3; - layout.horizontalSpacing = convertHorizontalDLUsToPixels(4); - layout.verticalSpacing = convertVerticalDLUsToPixels(3); - layout.marginWidth = 0; - layout.marginHeight = 0; - composite.setLayout(layout); - GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL); - composite.setLayoutData(data); - - enableButton = new Button(composite, SWT.CHECK); - enableButton.setText(Messages.audioPrefEnable); - enableButton.setSelection(AudioCore.getInstance().isSoundEnabled()); - data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - data.horizontalSpan = 3; - enableButton.setLayoutData(data); - whs.setHelp(enableButton, ContextIds.AUDIO_PREFERENCES_ENABLE); - - final Label volumeLabel = new Label(composite, SWT.NONE); - volumeLabel.setText(Messages.audioPrefVolume); - data = new GridData(); - data.horizontalIndent = 20; - volumeLabel.setLayoutData(data); - volumeLabel.setEnabled(enableButton.getSelection()); - - volume = new Spinner(composite, SWT.BORDER); - volume.setMinimum(0); - volume.setMaximum(20); - volume.setSelection(AudioCore.getInstance().getVolume()); - data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); - data.horizontalSpan = 2; - data.widthHint = 60; - volume.setLayoutData(data); - volume.setEnabled(enableButton.getSelection()); - whs.setHelp(volume, ContextIds.AUDIO_PREFERENCES_VOLUME); - - enableButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - volumeLabel.setEnabled(enableButton.getSelection()); - volume.setEnabled(enableButton.getSelection()); - } - }); - - Label label = new Label(composite, SWT.NONE); - data = new GridData(); - data.horizontalSpan = 3; - label.setLayoutData(data); - - label = new Label(composite, SWT.NONE); - label.setText(Messages.audioPrefSounds); - data = new GridData(); - data.horizontalSpan = 3; - label.setLayoutData(data); - - final Table table = new Table(composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.FULL_SELECTION | SWT.CHECK); - data = new GridData(GridData.FILL_BOTH); - data.horizontalSpan = 2; - table.setLayoutData(data); - whs.setHelp(table, ContextIds.AUDIO_PREFERENCES_SOUNDS_TABLE); - - viewer = new CategoryTableViewer(table); - - TableLayout tableLayout = new TableLayout(); - table.setLayout(tableLayout); - table.setHeaderVisible(true); - - tableLayout.addColumnData(new ColumnPixelData(23, false)); - TableColumn col = new TableColumn(table, SWT.CENTER, 0); - col.setResizable(false); - - tableLayout.addColumnData(new ColumnWeightData(11, 110, true)); - col = new TableColumn(table, SWT.NONE, 1); - col.setText(Messages.audioPrefSound); - col.setResizable(true); - - tableLayout.addColumnData(new ColumnWeightData(15, 150, true)); - col = new TableColumn(table, SWT.NONE, 2); - col.setText(Messages.audioPrefFile); - col.setResizable(true); - - viewer.setContentProvider(new AudioTableContentProvider()); - viewer.setLabelProvider(new AudioTableLabelProvider(this)); - viewer.setInput("root"); - - setCheckState(viewer); - - viewer.addCheckStateListener(new ICheckStateListener() { - public void checkStateChanged(CheckStateChangedEvent event) { - boolean checked = event.getChecked(); - Object obj = event.getElement(); - - if (obj instanceof String) { - String id = (String) obj; - core.setCategoryEnabled(id, checked); - //viewer.refresh(); - Iterator iterator = AudioTableContentProvider.getSoundsByCategory(id).iterator(); - while (iterator.hasNext()) { - Sound s = (Sound) iterator.next(); - viewer.setChecked(s, checked); - core.setSoundEnabled(s.getId(), checked); - } - } else { - Sound sound = (Sound) obj; - core.setSoundEnabled(sound.getId(), checked); - } - } - }); - - Composite right = new Composite(composite, SWT.NONE); - layout = new GridLayout(); - layout.numColumns = 1; - layout.horizontalSpacing = convertHorizontalDLUsToPixels(4); - layout.verticalSpacing = convertVerticalDLUsToPixels(4); - layout.marginWidth = 0; - layout.marginHeight = 0; - right.setLayout(layout); - data = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_FILL); - right.setLayoutData(data); - - // play button and table selection listener - final Button playButton = SWTUtil.createButton(right, Messages.audioPrefPlay); - playButton.setEnabled(false); - whs.setHelp(playButton, ContextIds.AUDIO_PREFERENCES_PLAY); - - final Button browseButton = SWTUtil.createButton(right, Messages.audioPrefBrowse); - browseButton.setEnabled(false); - whs.setHelp(browseButton, ContextIds.AUDIO_PREFERENCES_BROWSE); - - final Button resetButton = SWTUtil.createButton(right, Messages.audioPrefReset); - resetButton.setEnabled(false); - whs.setHelp(resetButton, ContextIds.AUDIO_PREFERENCES_RESET); - - viewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - try { - IStructuredSelection sel = (IStructuredSelection) event.getSelection(); - Object obj = sel.getFirstElement(); - if (obj instanceof Sound) { - Sound sound = (Sound) obj; - URL url = getSoundURL(sound.getId()); - if (url != null && soundAvailable) - playButton.setEnabled(true); - else - playButton.setEnabled(false); - browseButton.setEnabled(true); - - if (getUserSoundPath(sound.getId()) != null) - resetButton.setEnabled(true); - else - resetButton.setEnabled(false); - } else { - playButton.setEnabled(false); - browseButton.setEnabled(false); - resetButton.setEnabled(false); - } - } catch (Exception ex) { - Trace.trace(Trace.SEVERE, "Error in table selection", ex); - } - } - }); - - soundAvailable = AudioCore.isAudioSupported(); - if (soundAvailable) { - playButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - try { - int sel = table.getSelectionIndex(); - Sound sound = (Sound) table.getItem(sel).getData(); - AudioCore.playSound(getSoundURL(sound.getId()), volume.getSelection()); - } catch (Exception ex) { - Trace.trace(Trace.SEVERE, "Error in table selection", ex); - } - } - }); - } else - playButton.setEnabled(false); - - browseButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - try { - IPath path = chooseAudioFile(); - if (path != null) { - int sel = table.getSelectionIndex(); - Sound sound = (Sound) table.getItem(sel).getData(); - setUserSoundPath(sound.getId(), path); - viewer.refresh(sound); - playButton.setEnabled(true); - } - } catch (Exception ex) { - Trace.trace(Trace.SEVERE, "Error browsing", ex); - } - } - }); - - resetButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - try { - int sel = table.getSelectionIndex(); - Sound sound = (Sound) table.getItem(sel).getData(); - removeUserSoundPath(sound.getId()); - viewer.refresh(sound); - //playButton.setEnabled(true); - } catch (Exception ex) { - Trace.trace(Trace.SEVERE, "Error reseting sound", ex); - } - } - }); - - Dialog.applyDialogFont(composite); - - return composite; - } - - protected void setCheckState(CheckboxTableViewer viewer) { - AudioCore core = AudioCore.getInstance(); - - Map<String, String> categories = core.getCategories(); - - // first, find all the categories and sort - List<String> cats = new ArrayList<String>(); - Iterator iterator = categories.keySet().iterator(); - while (iterator.hasNext()) - cats.add((String)iterator.next()); - - // list them, ignoring empty ones - iterator = categories.keySet().iterator(); - while (iterator.hasNext()) { - String id = (String) iterator.next(); - List l = AudioTableContentProvider.getSoundsByCategory(id); - if (!l.isEmpty()) { - if (core.isCategoryEnabled(id)) - viewer.setChecked(id, true); - - int size = l.size(); - for (int i = 0; i < size; i++) { - Sound s = (Sound) l.get(i); - if (core.isSoundEnabled(s.getId())) - viewer.setChecked(s, true); - } - } - } - - // finally, list the "misc" sounds - List l = AudioTableContentProvider.getSoundsByCategory(null); - if (!l.isEmpty()) { - int size = l.size(); - for (int i = 0; i < size; i++) { - Sound s = (Sound) l.get(i); - if (core.isSoundEnabled(s.getId())) - viewer.setChecked(s, true); - } - } - } - - /** - * - * @return org.eclipse.core.runtime.IPath - * @param id java.lang.String - */ - protected URL getSoundURL(String id) { - try { - IPath path = userSoundMap.get(id); - if (path != null) - return path.toFile().toURL(); - } catch (Exception e) { - // ignore - } - - return AudioCore.getInstance().getSound(id).getLocation(); - } - - /** - * - * @return org.eclipse.core.runtime.IPath - * @param id java.lang.String - */ - protected IPath getUserSoundPath(String id) { - try { - IPath path = userSoundMap.get(id); - if (path != null) - return path; - } catch (Exception e) { - // ignore - } - return null; - } - - /** - * Initializes this preference page for the given workbench. - * <p> - * This method is called automatically as the preference page is being created - * and initialized. Clients must not call this method. - * </p> - * - * @param workbench the workbench - */ - public void init(IWorkbench workbench) { - // do nothing - } - - /** - * - */ - protected void loadUserMapInfo() { - // create a copy of the user sound map - Map<String, IPath> map = AudioCore.getInstance().getUserSoundMap(); - userSoundMap = new HashMap<String, IPath>(map.size()); - - Iterator iterator = map.keySet().iterator(); - while (iterator.hasNext()) { - String id = (String) iterator.next(); - IPath path = map.get(id); - userSoundMap.put(id, path); - } - } - - /** - * @see PreferencePage#performDefaults() - */ - protected void performDefaults() { - AudioCore core = AudioCore.getInstance(); - - enableButton.setSelection(core.getDefaultSoundsEnabled()); - volume.setSelection(core.getDefaultVolume()); - - userSoundMap = new HashMap<String, IPath>(); - viewer.refresh(); - - super.performDefaults(); - } - - /** - * @see PreferencePage#performOk() - */ - public boolean performOk() { - AudioCore core = AudioCore.getInstance(); - core.setSoundsEnabled(enableButton.getSelection()); - core.setVolume(volume.getSelection()); - - core.setUserSoundMap(userSoundMap); - viewer.refresh(); - - return super.performOk(); - } - - /** - * - */ - protected void removeUserSoundPath(String id) { - if (userSoundMap.containsKey(id)) - userSoundMap.remove(id); - } - - /** - * - */ - protected void saveUserMapInfo() { - // create a copy of the user sound map - Map map = AudioCore.getInstance().getUserSoundMap(); - userSoundMap = new HashMap<String, IPath>(map.size()); - - Iterator iterator = map.keySet().iterator(); - while (iterator.hasNext()) { - String id = (String) iterator.next(); - IPath path = (IPath) map.get(id); - userSoundMap.put(id, path); - } - } - - /** - * - * @param path org.eclipse.core.runtime.IPath - */ - protected void setUserSoundPath(String id, IPath path) { - userSoundMap.put(id, path); - } -} diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/audio/AudioTableContentProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/audio/AudioTableContentProvider.java deleted file mode 100644 index ceea15cd9..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/audio/AudioTableContentProvider.java +++ /dev/null @@ -1,155 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.audio; - -import java.util.*; -import org.eclipse.wst.server.ui.internal.viewers.BaseContentProvider; -/** - * Audio table content provider. - */ -class AudioTableContentProvider extends BaseContentProvider { - protected static final String MISC_CATEGORY = "miscCategory"; - - /** - * AudioTableContentProvider constructor comment. - */ - public AudioTableContentProvider() { - super(); - } - - /** - * Returns the elements to display in the viewer - * when its input is set to the given element. - * These elements can be presented as rows in a table, items in a list, etc. - * The result is not modified by the viewer. - * - * @param inputElement the input element - * @return the array of elements to display in the viewer - */ - public Object[] getElements(Object inputElement) { - AudioCore core = AudioCore.getInstance(); - - Map<String, String> categories = core.getCategories(); - Map<String, Sound> sounds = core.getSounds(); - - List<Object> list = new ArrayList<Object>(sounds.size()); - - // first, find all the categories and sort - List<String> cats = new ArrayList<String>(); - Iterator iterator = categories.keySet().iterator(); - while (iterator.hasNext()) - cats.add((String) iterator.next()); - sortCategories(cats); - - // list them, ignoring empty ones - iterator = categories.keySet().iterator(); - while (iterator.hasNext()) { - String id = (String) iterator.next(); - List<Sound> l = getSoundsByCategory(id); - if (!l.isEmpty()) { - list.add(id); - sortSounds(l); - - int size = l.size(); - for (int i = 0; i < size; i++) - list.add(l.get(i)); - } - } - - // finally, list the "misc" sounds - List<Sound> l = getSoundsByCategory(null); - if (!l.isEmpty()) { - list.add(MISC_CATEGORY); - sortSounds(l); - - int size = l.size(); - for (int i = 0; i < size; i++) - list.add(l.get(i)); - } - - return list.toArray(); - } - - /** - * Returns the sounds from the given category. Use null - * to return all miscelleneous sounds with no category or - * an invalid category. - * - * @return java.util.List - * @param category java.lang.String - */ - protected static List<Sound> getSoundsByCategory(String category) { - AudioCore core = AudioCore.getInstance(); - - Map<String, Sound> sounds = core.getSounds(); - Map<String, String> categories = core.getCategories(); - List<Sound> list = new ArrayList<Sound>(); - - Iterator iterator = sounds.keySet().iterator(); - while (iterator.hasNext()) { - String id = (String) iterator.next(); - Sound sound = sounds.get(id); - if (category != null && category.equals(sound.getCategory())) - list.add(sound); - else if (category == null && (sound.getCategory() == null || !categories.containsKey(sound.getCategory()))) - list.add(sound); - } - return list; - } - - /** - * Sorts a list of categories, in place. - * - * @param list java.util.List - */ - protected void sortCategories(List<String> list) { - int size = list.size(); - if (size < 2) - return; - - Map<String, String> categories = AudioCore.getInstance().getCategories(); - - for (int i = 0; i < size - 1; i++) { - for (int j = i+1; j < size; j++) { - String a = list.get(i); - String aa = categories.get(a); - String b = list.get(j); - String bb = categories.get(b); - if (aa.compareTo(bb) > 0) { - list.set(i, b); - list.set(j, a); - } - } - } - } - - /** - * Sorts a list of sounds, in place. - * - * @param sounds java.util.List - */ - protected void sortSounds(List<Sound> sounds) { - int size = sounds.size(); - if (size < 2) - return; - - for (int i = 0; i < size - 1; i++) { - for (int j = i+1; j < size; j++) { - Sound a = sounds.get(i); - Sound b = sounds.get(j); - if (a.getName().compareTo(b.getName()) > 0) { - sounds.set(i, b); - sounds.set(j, a); - } - } - } - } -} diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/audio/AudioTableLabelProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/audio/AudioTableLabelProvider.java deleted file mode 100644 index 26dd8c5d7..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/audio/AudioTableLabelProvider.java +++ /dev/null @@ -1,156 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.audio; - -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.core.runtime.*; -import java.net.URL; -import java.util.Map; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.server.ui.internal.ImageResource; -import org.eclipse.wst.server.ui.internal.Messages; -import org.eclipse.jface.viewers.ITableLabelProvider; -/** - * Audio table label provider. - */ -class AudioTableLabelProvider implements ITableLabelProvider { - protected AudioPreferencePage page; - - /** - * AudioTableLabelProvider constructor comment. - * - * @param page the preference page - */ - public AudioTableLabelProvider(AudioPreferencePage page) { - super(); - this.page = page; - } - - /** - * Adds a listener to this label provider. - * Has no effect if an identical listener is already registered. - * <p> - * Label provider listeners are informed about state changes - * that affect the rendering of the viewer that uses this label provider. - * </p> - * - * @param listener a label provider listener - */ - public void addListener(ILabelProviderListener listener) { - // do nothing - } - - /** - * Disposes of this label provider. When a label provider is - * attached to a viewer, the viewer will automatically call - * this method when the viewer is being closed. When label providers - * are used outside of the context of a viewer, it is the client's - * responsibility to ensure that this method is called when the - * provider is no longer needed. - */ - public void dispose() { - // do nothing - } - - /** - * @see ITableLabelProvider#getColumnImage(java.lang.Object, int) - */ - public Image getColumnImage(Object element, int columnIndex) { - /*AudioCore core = AudioCore.getInstance(); - - if (columnIndex == 0) { - if (element instanceof String) { - if (element != AudioTableContentProvider.MISC_CATEGORY) { - if (core.isCategoryEnabled((String) element)) - return ImageResource.getImage(ImageResource.IMG_AUDIO_ENABLED); - return ImageResource.getImage(ImageResource.IMG_AUDIO_DISABLED); - } - return null; - } - Sound sound = (Sound) element; - if (!core.isCategoryEnabled(sound.getCategory())) - return ImageResource.getImage(ImageResource.IMG_AUDIO_UNAVAILABLE); - if (core.isSoundEnabled(sound.getId())) - return ImageResource.getImage(ImageResource.IMG_AUDIO_ENABLED); - return ImageResource.getImage(ImageResource.IMG_AUDIO_DISABLED); - } else*/ - if (columnIndex == 1) { - if (element instanceof String) - return ImageResource.getImage(ImageResource.IMG_AUDIO_CATEGORY); - return ImageResource.getImage(ImageResource.IMG_AUDIO_SOUND); - } - return null; - } - - /** - * @see ITableLabelProvider#getColumnText(java.lang.Object, int) - */ - public String getColumnText(Object element, int columnIndex) { - if (columnIndex == 0) - return ""; - - if (element instanceof String) { - String categoryId = (String) element; - if (columnIndex == 1) { - if (categoryId.equals(AudioTableContentProvider.MISC_CATEGORY)) - return ""; //(Miscellaneous)"; - Map categories = AudioCore.getInstance().getCategories(); - return (String) categories.get(categoryId); - } - return ""; - } - Sound sound = (Sound) element; - - if (columnIndex == 1) { - String s = sound.getName(); - if (s != null) - return s; - return Messages.audioUnknown; - } else if (columnIndex == 2) { - IPath path = page.getUserSoundPath(sound.getId()); - if (path != null) - return path.lastSegment(); - - URL url = page.getSoundURL(sound.getId()); - if (url == null) - return Messages.audioNone; - return Messages.audioDefault; - } - return ""; - } - - /** - * Returns whether the label would be affected - * by a change to the given property of the given element. - * This can be used to optimize a non-structural viewer update. - * If the property mentioned in the update does not affect the label, - * then the viewer need not update the label. - * - * @param element the element - * @param property the property - * @return <code>true</code> if the label would be affected, - * and <code>false</code> if it would be unaffected - */ - public boolean isLabelProperty(Object element, String property) { - return false; - } - - /** - * Removes a listener to this label provider. - * Has no affect if an identical listener is not registered. - * - * @param listener a label provider listener - */ - public void removeListener(ILabelProviderListener listener) { - // do nothing - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/audio/CategoryTableViewer.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/audio/CategoryTableViewer.java deleted file mode 100644 index 85c7dd735..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/audio/CategoryTableViewer.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.audio; - -import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableItem; -import org.eclipse.swt.widgets.Widget; -/** - * - */ -public class CategoryTableViewer extends CheckboxTableViewer { - protected Color color; - - public CategoryTableViewer(Table table) { - super(table); - createColor(table); - } - - protected void createColor(Control c) { - color = new Color(c.getDisplay(), 255, 255, 225); - c.addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - color.dispose(); - } - }); - } - - public void doUpdateItem(Widget widget, Object element, boolean fullMap) { - if (color == null) - return; - if (widget instanceof TableItem) { - TableItem item = (TableItem) widget; - if (element instanceof String) { - item.setBackground(color); - } else - item.setBackground(null); - } - super.doUpdateItem(widget, element, fullMap); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/audio/IMemento.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/audio/IMemento.java deleted file mode 100644 index 6f149f54d..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/audio/IMemento.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.audio; -/** - * Interface to a memento used for saving the important state of an object - * in a form that can be persisted in the file system. - * <p> - * Mementos were designed with the following requirements in mind: - * <ol> - * <li>Certain objects need to be saved and restored across platform sessions. - * </li> - * <li>When an object is restored, an appropriate class for an object might not - * be available. It must be possible to skip an object in this case.</li> - * <li>When an object is restored, the appropriate class for the object may be - * different from the one when the object was originally saved. If so, the - * new class should still be able to read the old form of the data.</li> - * </ol> - * </p> - * <p> - * Mementos meet these requirements by providing support for storing a - * mapping of arbitrary string keys to primitive values, and by allowing - * mementos to have other mementos as children (arranged into a tree). - * A robust external storage format based on XML is used. - * </p><p> - * The key for an attribute may be any alpha numeric value. However, the - * value of <code>TAG_ID</code> is reserved for internal use. - * </p><p> - * This interface is not intended to be implemented by clients. - * </p> - */ -public interface IMemento { - /** - * Creates a new child of this memento with the given type. - * <p> - * The <code>getChild</code> and <code>getChildren</code> methods - * are used to retrieve children of a given type. - * </p> - * - * @param type the type - * @return a new child memento - * @see #getChild - * @see #getChildren - */ - public IMemento createChild(String type); - - /** - * Returns the first child with the given type id. - * - * @param type the type id - * @return the first child with the given type - */ - public IMemento getChild(String type); - - /** - * Returns all children with the given type id. - * - * @param type the type id - * @return the list of children with the given type - */ - public IMemento[] getChildren(String type); - - /** - * Returns the string value of the given key. - * - * @param key the key - * @return the value, or <code>null</code> if the key was not found or was found - * but was not an integer - */ - public String getString(String key); - - /** - * Sets the value of the given key to the given string. - * - * @param key the key - * @param value the value - */ - public void putString(String key, String value); -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/audio/Sound.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/audio/Sound.java deleted file mode 100644 index de29438c7..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/audio/Sound.java +++ /dev/null @@ -1,110 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.audio; - -import java.net.URL; -/** - * A single sound. - */ -class Sound { - protected String id; - protected String name; - public URL location; - protected String category; - - /** - * Sound constructor comment. - */ - public Sound() { - super(); - } - - /** - * Sound constructor comment. - * - * @param id an id - * @param category a category - * @param name a name - * @param loc location - */ - public Sound(String id, String category, String name, URL loc) { - super(); - - this.id = id; - this.category = category; - this.name = name; - this.location = loc; - } - - /** - * - * @return org.eclipse.audio.Category - */ - public String getCategory() { - return category; - } - - /** - * - * @return java.lang.String - */ - public String getId() { - return id; - } - - /** - * - * @return java.net.URL - */ - public URL getLocation() { - return location; - } - - /** - * - * @return java.lang.String - */ - public String getName() { - return name; - } - - /** - * - * @param newCategory org.eclipse.audio.Category - */ - public void setCategory(String newCategory) { - category = newCategory; - } - - /** - * - * @param newId java.lang.String - */ - public void setId(String newId) { - id = newId; - } - - /** - * - * @param newLocation java.net.URL - */ - public void setLocation(URL newLocation) { - location = newLocation; - } - - /** - * - * @param newName java.lang.String - */ - public void setName(String newName) { - name = newName; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/audio/XMLMemento.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/audio/XMLMemento.java deleted file mode 100644 index 890cbaa73..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/audio/XMLMemento.java +++ /dev/null @@ -1,219 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.audio; - -import java.io.*; -import java.util.*; -import org.w3c.dom.*; -import org.xml.sax.*; -import javax.xml.parsers.*; -import javax.xml.transform.*; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; -/** - * A Memento is a class independent container for persistence - * info. It is a reflection of 3 storage requirements. - * - * 1) We need the ability to persist an object and restore it. - * 2) The class for an object may be absent. If so we would - * like to skip the object and keep reading. - * 3) The class for an object may change. If so the new class - * should be able to read the old persistence info. - * - * We could ask the objects to serialize themselves into an - * ObjectOutputStream, DataOutputStream, or Hashtable. However - * all of these approaches fail to meet the second requirement. - * - * Memento supports binary persistence with a version ID. - */ -public final class XMLMemento implements IMemento { - private Document factory; - private Element element; - - /** - * Answer a memento for the document and element. For simplicity - * you should use createReadRoot and createWriteRoot to create the initial - * mementos on a document. - */ - private XMLMemento(Document doc, Element el) { - factory = doc; - element = el; - } - - /* - * @see IMemento - */ - public IMemento createChild(String type) { - Element child = factory.createElement(type); - element.appendChild(child); - return new XMLMemento(factory, child); - } - - /** - * Create a Document from a Reader and answer a root memento for reading - * a document. - */ - protected static XMLMemento createReadRoot(Reader reader) { - Document document = null; - try { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - DocumentBuilder parser = factory.newDocumentBuilder(); - document = parser.parse(new InputSource(reader)); - Node node = document.getFirstChild(); - if (node instanceof Element) - return new XMLMemento(document, (Element) node); - } catch (Exception e) { - // ignore - } - return null; - } - - /** - * Answer a root memento for writing a document. - * - * @param type a type - * @return a memento - */ - protected static XMLMemento createWriteRoot(String type) { - Document document; - try { - document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); - Element element = document.createElement(type); - document.appendChild(element); - return new XMLMemento(document, element); - } catch (ParserConfigurationException e) { - throw new Error(e); - } - } - - /* - * @see IMemento - */ - public IMemento getChild(String type) { - - // Get the nodes. - NodeList nodes = element.getChildNodes(); - int size = nodes.getLength(); - if (size == 0) - return null; - - // Find the first node which is a child of this node. - for (int nX = 0; nX < size; nX ++) { - Node node = nodes.item(nX); - if (node instanceof Element) { - Element element2 = (Element)node; - if (element2.getNodeName().equals(type)) - return new XMLMemento(factory, element2); - } - } - - // A child was not found. - return null; - } - - /* - * @see IMemento - */ - public IMemento [] getChildren(String type) { - - // Get the nodes. - NodeList nodes = element.getChildNodes(); - int size = nodes.getLength(); - if (size == 0) - return new IMemento[0]; - - // Extract each node with given type. - List<Element> list = new ArrayList<Element>(size); - for (int nX = 0; nX < size; nX ++) { - Node node = nodes.item(nX); - if (node instanceof Element) { - Element element2 = (Element)node; - if (element2.getNodeName().equals(type)) - list.add(element2); - } - } - - // Create a memento for each node. - size = list.size(); - IMemento [] results = new IMemento[size]; - for (int x = 0; x < size; x ++) { - results[x] = new XMLMemento(factory, list.get(x)); - } - return results; - } - - /* - * @see IMemento - */ - public String getString(String key) { - Attr attr = element.getAttributeNode(key); - if (attr == null) - return null; - return attr.getValue(); - } - - /** - * Loads a memento from the given filename. - * - * @param in java.io.InputStream - * @return org.eclipse.ui.IMemento - */ - public static IMemento loadMemento(InputStream in) { - Document document = null; - try { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - DocumentBuilder parser = factory.newDocumentBuilder(); - document = parser.parse(in); - Node node = document.getFirstChild(); - if (node instanceof Element) - return new XMLMemento(document, (Element) node); - } catch (Exception e) { - // ignore - } finally { - try { - in.close(); - } catch (Exception e) { - // ignore - } - } - return null; - } - - /* - * @see IMemento - */ - public void putString(String key, String value) { - if (value == null) - return; - element.setAttribute(key, value); - } - - /** - * Save this Memento to a Writer. - */ - protected void save(OutputStream os) throws IOException { - Result result = new StreamResult(os); - Source source = new DOMSource(factory); - try { - Transformer transformer = TransformerFactory.newInstance().newTransformer(); - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ - transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ - transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$ - transformer.transform(source, result); - } - catch (TransformerConfigurationException e) { - throw (IOException) (new IOException().initCause(e)); - } - catch (TransformerException e) { - throw (IOException) (new IOException().initCause(e)); - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/CNFManagedUIDecorator.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/CNFManagedUIDecorator.java deleted file mode 100644 index a06d04e5c..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/CNFManagedUIDecorator.java +++ /dev/null @@ -1,132 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008,2009 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.server.ui.internal.cnf; - -import org.eclipse.debug.core.ILaunchManager; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.ui.internal.ImageResource; -import org.eclipse.wst.server.ui.internal.Messages; -import org.eclipse.wst.server.ui.internal.provisional.UIDecorator; - -public class CNFManagedUIDecorator extends UIDecorator { - private static final String[] serverStateUnmanaged = new String[] { - "", - Messages.viewStatusStarting4, - Messages.viewStatusStarted2, - Messages.viewStatusStopping4, - Messages.viewStatusStopped2}; - - private static final Image[] startingImages = new Image[] { - ImageResource.getImage(ImageResource.IMG_SERVER_STATE_STARTING_1), - ImageResource.getImage(ImageResource.IMG_SERVER_STATE_STARTING_2), - ImageResource.getImage(ImageResource.IMG_SERVER_STATE_STARTING_3) - }; - - private static final ImageDescriptor[] startingImagesDescriptor = new ImageDescriptor[] { - ImageResource.getImageDescriptor(ImageResource.IMG_SERVER_STATE_STARTING_1), - ImageResource.getImageDescriptor(ImageResource.IMG_SERVER_STATE_STARTING_2), - ImageResource.getImageDescriptor(ImageResource.IMG_SERVER_STATE_STARTING_3) - }; - - private static final Image[] stoppingImages = new Image[] { - ImageResource.getImage(ImageResource.IMG_SERVER_STATE_STOPPING_1), - ImageResource.getImage(ImageResource.IMG_SERVER_STATE_STOPPING_2), - ImageResource.getImage(ImageResource.IMG_SERVER_STATE_STOPPING_2) - }; - - private static final ImageDescriptor[] stoppingImagesDescriptor = new ImageDescriptor[] { - ImageResource.getImageDescriptor(ImageResource.IMG_SERVER_STATE_STOPPING_1), - ImageResource.getImageDescriptor(ImageResource.IMG_SERVER_STATE_STOPPING_2), - ImageResource.getImageDescriptor(ImageResource.IMG_SERVER_STATE_STOPPING_3) - }; - - - /** - * @see UIDecorator#getStateLabel(int, String, int) - */ - public String getStateLabel(int state, String mode, int count) { - if (state == IServer.STATE_UNKNOWN) - return ""; - else if (state == IServer.STATE_STARTING) - return Messages.viewStatusStarting; - else if (state == IServer.STATE_STOPPING) - return Messages.viewStatusStopping; - else if (state == IServer.STATE_STARTED) { - if (ILaunchManager.DEBUG_MODE.equals(mode)) - return Messages.viewStatusStartedDebug; - else if (ILaunchManager.PROFILE_MODE.equals(mode)) - return Messages.viewStatusStartedProfile; - else - return Messages.viewStatusStarted; - } else if (state == IServer.STATE_STOPPED) - return Messages.viewStatusStopped; - - return serverStateUnmanaged[state]; - } - - /** - * @see UIDecorator#getStateImage(int, String, int) - */ - public Image getStateImage(int state, String mode, int count) { - if (state == IServer.STATE_UNKNOWN) - return null; - else if (state == IServer.STATE_STARTING) - return startingImages[count]; - else if (state == IServer.STATE_STOPPING) - return stoppingImages[count]; - else if (state == IServer.STATE_STOPPED) - return ImageResource.getImage(ImageResource.IMG_SERVER_STATE_STOPPED); - else { //if (state == IServer.STATE_STARTED) { - //String mode = server.getMode(); - if (ILaunchManager.DEBUG_MODE.equals(mode)) - return ImageResource.getImage(ImageResource.IMG_SERVER_STATE_STARTED_DEBUG); - else if (ILaunchManager.PROFILE_MODE.equals(mode)) - return ImageResource.getImage(ImageResource.IMG_SERVER_STATE_STARTED_PROFILE); - else - return ImageResource.getImage(ImageResource.IMG_SERVER_STATE_STARTED); - } - } - - /** - * @see UIDecorator#getStateImage(int, String, int) - */ - public ImageDescriptor getStateImageDescriptor(int state, String mode, int count) { - if (state == IServer.STATE_UNKNOWN) - return null; - else if (state == IServer.STATE_STARTING) - return startingImagesDescriptor[count]; - else if (state == IServer.STATE_STOPPING) - return stoppingImagesDescriptor[count]; - else if (state == IServer.STATE_STOPPED) - return ImageResource.getImageDescriptor(ImageResource.IMG_SERVER_STATE_STOPPED); - else { //if (state == IServer.STATE_STARTED) { - //String mode = server.getMode(); - if (ILaunchManager.DEBUG_MODE.equals(mode)) - return ImageResource.getImageDescriptor(ImageResource.IMG_SERVER_STATE_STARTED_DEBUG); - else if (ILaunchManager.PROFILE_MODE.equals(mode)) - return ImageResource.getImageDescriptor(ImageResource.IMG_SERVER_STATE_STARTED_PROFILE); - else - return ImageResource.getImageDescriptor(ImageResource.IMG_SERVER_STATE_STARTED); - } - } - - - - public String getModuleName() { - return "module"; - } - - public boolean canRestart() { - return true; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/ServerActionProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/ServerActionProvider.java deleted file mode 100644 index e7480aecf..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/ServerActionProvider.java +++ /dev/null @@ -1,299 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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 - Base Code - * Red Hat - Refactor for CNF - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.cnf; - -import java.util.Iterator; - -import org.eclipse.debug.core.ILaunchManager; -import org.eclipse.jface.action.*; -import org.eclipse.jface.bindings.TriggerSequence; -import org.eclipse.jface.viewers.*; -import org.eclipse.swt.dnd.Clipboard; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.*; -import org.eclipse.ui.actions.ActionFactory; -import org.eclipse.ui.keys.IBindingService; -import org.eclipse.ui.navigator.*; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.ServerPort; -import org.eclipse.wst.server.core.model.ServerDelegate; -import org.eclipse.wst.server.ui.internal.Messages; -import org.eclipse.wst.server.ui.internal.ServerUIPlugin; -import org.eclipse.wst.server.ui.internal.Trace; -import org.eclipse.wst.server.ui.internal.actions.NewServerWizardAction; -import org.eclipse.wst.server.ui.internal.view.servers.*; - -public class ServerActionProvider extends CommonActionProvider { - public static final String NEW_MENU_ID = "org.eclipse.wst.server.ui.internal.cnf.newMenuId"; - public static final String SHOW_IN_MENU_ID = "org.eclipse.ui.navigate.showInQuickMenu"; - public static final String TOP_SECTION_START_SEPARATOR = "org.eclipse.wst.server.ui.internal.cnf.topSectionStart"; - public static final String TOP_SECTION_END_SEPARATOR = "org.eclipse.wst.server.ui.internal.cnf.topSectionEnd"; - public static final String EDIT_SECTION_START_SEPARATOR = "org.eclipse.wst.server.ui.internal.cnfeditSectionStart"; - public static final String EDIT_SECTION_END_SEPARATOR = "org.eclipse.wst.server.ui.internal.cnf.editSectionEnd"; - public static final String CONTROL_SERVER_SECTION_START_SEPARATOR = "org.eclipse.wst.server.ui.internal.cnf.controlServerSectionStart"; - public static final String CONTROL_SERVER_SECTION_END_SEPARATOR = "org.eclipse.wst.server.ui.internal.cnf.controlServerSectionEnd"; - public static final String SERVER_ETC_SECTION_START_SEPARATOR = "org.eclipse.wst.server.ui.internal.cnf.serverEtcSectionStart"; - public static final String SERVER_ETC_SECTION_END_SEPARATOR = "org.eclipse.wst.server.ui.internal.cnf.serverEtcSectionEnd"; - public static final String CONTROL_MODULE_SECTION_START_SEPARATOR = "org.eclipse.wst.server.ui.internal.cnf.controlModuleSectionStart"; - public static final String CONTROL_MODULE_SECTION_END_SEPARATOR = "org.eclipse.wst.server.ui.internal.cnf.controlModuleSectionEnd"; - - private ICommonActionExtensionSite actionSite; - private Clipboard clipboard; - public ServerActionProvider() { - super(); - } - - public void init(ICommonActionExtensionSite aSite) { - super.init(aSite); - this.actionSite = aSite; - ICommonViewerSite site = aSite.getViewSite(); - if( site instanceof ICommonViewerWorkbenchSite ) { - StructuredViewer v = aSite.getStructuredViewer(); - if( v instanceof CommonViewer ) { - CommonViewer cv = (CommonViewer)v; - ICommonViewerWorkbenchSite wsSite = (ICommonViewerWorkbenchSite)site; - addListeners(cv); - makeServerActions(cv, wsSite.getSelectionProvider()); - } - } - } - - - // actions on a server - protected Action[] actions; - protected Action actionModifyModules; - protected Action openAction, showInConsoleAction, showInDebugAction, propertiesAction, monitorPropertiesAction; - protected Action copyAction, pasteAction, deleteAction, renameAction; - protected Action noneAction = new Action(Messages.dialogMonitorNone) { - // dummy action - }; - - private void addListeners(CommonViewer tableViewer) { - tableViewer.addOpenListener(new IOpenListener() { - public void open(OpenEvent event) { - try { - IStructuredSelection sel = (IStructuredSelection) event.getSelection(); - Object data = sel.getFirstElement(); - if (!(data instanceof IServer)) - return; - IServer server = (IServer) data; - ServerUIPlugin.editServer(server); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Could not open server", e); - } - } - }); - } - - private void makeServerActions(CommonViewer tableViewer, ISelectionProvider provider) { - clipboard = new Clipboard(tableViewer.getTree().getDisplay()); - Shell shell = tableViewer.getTree().getShell(); - - actions = new Action[6]; - // create the start actions - actions[0] = new StartAction(shell, provider, ILaunchManager.DEBUG_MODE); - actions[1] = new StartAction(shell, provider, ILaunchManager.RUN_MODE); - actions[2] = new StartAction(shell, provider, ILaunchManager.PROFILE_MODE); - - // create the stop action - actions[3] = new StopAction(shell, provider); - - // create the publish actions - actions[4] = new PublishAction(shell, provider); - actions[5] = new PublishCleanAction(shell, provider); - - // create the open action - openAction = new OpenAction(provider); - - // create copy, paste, and delete actions - pasteAction = new PasteAction(shell, provider, clipboard); - copyAction = new CopyAction(provider, clipboard, pasteAction); - deleteAction = new DeleteAction(shell, provider); - renameAction = new RenameAction(shell, tableViewer, provider); - - // create the other actions - actionModifyModules = new ModuleSloshAction(shell, provider); - showInConsoleAction = new ShowInConsoleAction(provider); - showInDebugAction = new ShowInDebugAction(provider); - - // create the properties action - propertiesAction = new PropertiesAction(shell, provider); - monitorPropertiesAction = new PropertiesAction(shell, "org.eclipse.wst.server.ui.properties.monitor", provider); - } - - public void fillActionBars(IActionBars actionBars) { - actionBars.setGlobalActionHandler("org.eclipse.wst.server.debug", actions[0]); - actionBars.setGlobalActionHandler("org.eclipse.wst.server.run", actions[1]); - actionBars.setGlobalActionHandler("org.eclipse.wst.server.stop", actions[3]); - actionBars.setGlobalActionHandler("org.eclipse.wst.server.publish", actions[4]); - actionBars.setGlobalActionHandler("org.eclipse.ui.navigator.Open", openAction); - actionBars.setGlobalActionHandler(ActionFactory.PROPERTIES.getId(), propertiesAction); - actionBars.updateActionBars(); - actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyAction); - actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), pasteAction); - actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), deleteAction); - actionBars.setGlobalActionHandler(ActionFactory.RENAME.getId(), renameAction); - - IContributionManager cm = actionBars.getToolBarManager(); - cm.removeAll(); - - for (int i = 0; i < actions.length - 1; i++) - cm.add(actions[i]); - } - - public void fillContextMenu(IMenuManager menu) { - // This is a temp workaround to clean up the default group that are provided by CNF - menu.removeAll(); - - ICommonViewerSite site = actionSite.getViewSite(); - IStructuredSelection selection = null; - Shell shell = actionSite.getViewSite().getShell(); - if( site instanceof ICommonViewerWorkbenchSite ) { - ICommonViewerWorkbenchSite wsSite = (ICommonViewerWorkbenchSite)site; - selection = (IStructuredSelection) wsSite.getSelectionProvider().getSelection(); - } - - IServer server = null; - IModule[] module = null; - if (selection != null && !selection.isEmpty()) { - Iterator iterator = selection.iterator(); - Object obj = iterator.next(); - if (obj instanceof IServer) - server = (IServer) obj; - if (obj instanceof ModuleServer) { - ModuleServer ms = (ModuleServer) obj; - server = ms.server; - module = ms.module; - } - if (iterator.hasNext()) { - server = null; - module = null; - } - } - - menu.add(invisibleSeparator(TOP_SECTION_START_SEPARATOR)); - addTopSection(menu, server, module); - menu.add(invisibleSeparator(TOP_SECTION_END_SEPARATOR)); - menu.add(new Separator()); - - if (server != null && module == null) { - menu.add(invisibleSeparator(EDIT_SECTION_START_SEPARATOR)); - menu.add(copyAction); - menu.add(pasteAction); - menu.add(deleteAction); - menu.add(renameAction); - menu.add(invisibleSeparator(EDIT_SECTION_END_SEPARATOR)); - - menu.add(new Separator()); - - menu.add(invisibleSeparator(CONTROL_SERVER_SECTION_START_SEPARATOR)); - for (int i = 0; i < actions.length; i++) - menu.add(actions[i]); - menu.add(invisibleSeparator(CONTROL_SERVER_SECTION_END_SEPARATOR)); - - menu.add(new Separator()); - - menu.add(invisibleSeparator(SERVER_ETC_SECTION_START_SEPARATOR)); - menu.add(actionModifyModules); - addMonitor(server, menu, shell); - menu.add(invisibleSeparator(SERVER_ETC_SECTION_END_SEPARATOR)); - menu.add(new Separator()); - - } else if (server != null && module != null) { - - menu.add(invisibleSeparator(CONTROL_MODULE_SECTION_START_SEPARATOR)); - menu.add(new StartModuleAction(server, module)); - menu.add(new StopModuleAction(server, module)); - menu.add(new RestartModuleAction(server, module)); - if(module.length == 1) { - menu.add(new RemoveModuleAction(shell, server, module[0])); - } - menu.add(invisibleSeparator(CONTROL_MODULE_SECTION_END_SEPARATOR)); - } - - menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); - menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS+"-end")); - menu.add(propertiesAction); - } - - protected void addTopSection(IMenuManager menu, IServer server, IModule[] module) { - MenuManager newMenu = new MenuManager(Messages.actionNew, NEW_MENU_ID); - IAction newServerAction = new NewServerWizardAction(); - newServerAction.setText(Messages.actionNewServer); - newMenu.add(newServerAction); - menu.add(newMenu); - - // open action - if (server != null && module == null) { - menu.add(openAction); - - String text = Messages.actionShowIn; - final IWorkbench workbench = PlatformUI.getWorkbench(); - final IBindingService bindingService = (IBindingService) workbench - .getAdapter(IBindingService.class); - final TriggerSequence[] activeBindings = bindingService - .getActiveBindingsFor(SHOW_IN_MENU_ID); - if (activeBindings.length > 0) { - text += "\t" + activeBindings[0].format(); - } - - MenuManager showInMenu = new MenuManager(text, SHOW_IN_MENU_ID); - showInMenu.add(showInConsoleAction); - showInMenu.add(showInDebugAction); - menu.add(showInMenu); - } - } - - protected void addMonitor(IServer server, IMenuManager menu, Shell shell) { - - if (server.getServerType() != null) { - final MenuManager menuManager = new MenuManager(Messages.actionMonitor); - - final IServer server2 = server; - final Shell shell2 = shell; - menuManager.addMenuListener(new IMenuListener() { - public void menuAboutToShow(IMenuManager manager) { - menuManager.removeAll(); - if (server2.getAdapter(ServerDelegate.class) != null) { - ServerPort[] ports = server2.getServerPorts(null); - if (ports != null) { - int size = ports.length; - for (int i = 0; i < size; i++) { - if (!ports[i].isAdvanced()) - menuManager.add(new MonitorServerPortAction(shell2, server2, ports[i])); - } - } - } - - if (menuManager.isEmpty()) - menuManager.add(noneAction); - - menuManager.add(new Separator()); - menuManager.add(monitorPropertiesAction); - } - }); - - // add an initial menu item so that the menu appears correctly - noneAction.setEnabled(false); - menuManager.add(noneAction); - menu.add(menuManager); - } - } - - - private Separator invisibleSeparator(String s) { - Separator sep = new Separator(s); - sep.setVisible(false); - return sep; - } -} diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/ServerContentProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/ServerContentProvider.java deleted file mode 100644 index 5f463e884..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/ServerContentProvider.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008,2009 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.server.ui.internal.cnf; - -import java.util.*; - -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.ServerCore; -import org.eclipse.wst.server.core.internal.Server; -import org.eclipse.wst.server.ui.internal.view.servers.ModuleServer; -import org.eclipse.wst.server.ui.internal.viewers.BaseContentProvider; - -public class ServerContentProvider extends BaseContentProvider implements ITreeContentProvider{ - // TODO Angel Says: Need to review if this is needed - public static Object INITIALIZING = new Object(); - - // TODO Angel Says: Need to review how to port this function into CNF - // servers that are currently publishing and starting - protected static Set<String> publishing = new HashSet<String>(4); - - public Object[] getElements(Object element) { - List<IServer> list = new ArrayList<IServer>(); - IServer[] servers = ServerCore.getServers(); - if (servers != null) { - int size = servers.length; - for (int i = 0; i < size; i++) { - if (!((Server)servers[i]).isPrivate()) - list.add(servers[i]); - } - } - return list.toArray(); - } - - public Object[] getChildren(Object element) { - if (element instanceof ModuleServer) { - ModuleServer ms = (ModuleServer) element; - try { - IModule[] children = ms.server.getChildModules(ms.module, null); - int size = children.length; - ModuleServer[] ms2 = new ModuleServer[size]; - for (int i = 0; i < size; i++) { - int size2 = ms.module.length; - IModule[] module = new IModule[size2 + 1]; - System.arraycopy(ms.module, 0, module, 0, size2); - module[size2] = children[i]; - ms2[i] = new ModuleServer(ms.server, module); - } - return ms2; - } catch (Exception e) { - return null; - } - } - - IServer server = (IServer) element; - IModule[] modules = server.getModules(); - int size = modules.length; - ModuleServer[] ms = new ModuleServer[size]; - for (int i = 0; i < size; i++) { - ms[i] = new ModuleServer(server, new IModule[] { modules[i] }); - } - return ms; - } - - public Object getParent(Object element) { - if (element instanceof ModuleServer) { - ModuleServer ms = (ModuleServer) element; - return ms.server; - } - return null; - } - - public boolean hasChildren(Object element) { - if (element instanceof ModuleServer) { - // Check if the module server has child modules. - ModuleServer curModuleServer = (ModuleServer)element; - IServer curServer = curModuleServer.server; - IModule[] curModule = curModuleServer.module; - if (curServer != null && curModule != null) { - IModule[] curChildModule = curServer.getChildModules(curModule, null); - if (curChildModule != null && curChildModule.length > 0) - return true; - return false; - } - return false; - } - if( element instanceof IServer ) { - return ((IServer) element).getModules().length > 0; - } - return false; - } -} diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/ServerDecorator.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/ServerDecorator.java deleted file mode 100644 index 75c764516..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/ServerDecorator.java +++ /dev/null @@ -1,204 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008,2009 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.server.ui.internal.cnf; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.viewers.*; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.ISharedImages; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.IServerType; -import org.eclipse.wst.server.core.internal.Server; -import org.eclipse.wst.server.ui.ServerUICore; -import org.eclipse.wst.server.ui.internal.ImageResource; -import org.eclipse.wst.server.ui.internal.Messages; -import org.eclipse.wst.server.ui.internal.ServerUIPlugin; -import org.eclipse.wst.server.ui.internal.provisional.UIDecoratorManager; -import org.eclipse.wst.server.ui.internal.view.servers.ModuleServer; - -public class ServerDecorator extends LabelProvider implements ILightweightLabelDecorator { - - public static final String[] syncState = new String[] { - Messages.viewSyncOkay, - Messages.viewSyncRestart, - Messages.viewSyncPublish, - Messages.viewSyncRestartPublish, - Messages.viewSyncPublishing}; - - public static final String[] syncStateUnmanaged = new String[] { - Messages.viewSyncOkay2, - Messages.viewSyncRestart2, - Messages.viewSyncPublish2, - Messages.viewSyncRestartPublish2, - Messages.viewSyncPublishing2}; - - public static final String[] modulePublishState = new String[] { - "", - Messages.viewSyncOkay, - Messages.viewSyncPublish, - Messages.viewSyncPublish}; - - private static ServerDecorator instance; - public static ServerDecorator getDefault() { - return instance; - } - - private static int count = 0; - public static void animate() { - count = (count + 1)%3; - } - public static int getCount() { - return count; - } - - public ServerDecorator() { - instance = this; - } - - public void decorate(Object element, IDecoration decoration) { - if( element instanceof IServer ) { - IServer server = (IServer)element; - String state = getServerStateLabel(server ); - String status = getServerStatusLabel(server ); - - decoration.addSuffix(combine(state, status)); - } else if( element instanceof ModuleServer ) { - ModuleServer module = (ModuleServer)element; - String state = getModuleStateText(module); - String status = getModuleStatusText(module); - - decoration.addSuffix(combine(state, status)); - } - } - - public void redecorate(IServer server) { - fireLabelProviderChanged(new LabelProviderChangedEvent(this)); - } - - /* - * Utility methods - */ - public static Image getServerImage(IServer server) { - return server == null ? null : - server.getServerType() == null ? null : - ImageResource.getImage(server.getServerType().getId()); - } - - public static String getServerStateLabel(IServer server) { - return server == null ? null : - server.getServerType() == null ? null : - getStateLabel(server.getServerType(), server.getServerState(), server.getMode()); - } - - public static String getStateLabel(IServerType serverType, int state, String mode) { - return serverType == null ? null : - UIDecoratorManager.getCNFUIDecorator(serverType).getStateLabel(state, mode, count); - } - - public static String getServerStatusLabel(IServer server) { - IStatus status = ((Server) server).getServerStatus(); - if (status != null) - return status.getMessage(); - - if (server.getServerType() == null) - return ""; - - if (server.getServerState() == IServer.STATE_UNKNOWN) - return ""; - - String serverId = server.getId(); - if (ServerContentProvider.publishing.contains(serverId)) - return ServerDecorator.syncState[4]; - - // republish - int i = 0; - if (server.shouldPublish()) { - if (((Server)server).isPublishUnknown()) - return ""; - i += 2; - } - - if (server.shouldRestart()) - i = 1; - - return syncState[i]; - } - - public static Image getServerStateImage(IServer server) { - return server == null ? null : - getStateImage(server.getServerType(), server.getServerState(), server.getMode()); - } - - public static Image getStateImage(IServerType serverType, int state, String mode) { - return serverType == null ? null : - UIDecoratorManager.getCNFUIDecorator(serverType).getStateImage(state, mode, getCount()); - } - - public static String getModuleText(ModuleServer ms ) { - if (ms == null || ms.module == null) - return ""; - int size = ms.module.length; - return ms.module[size - 1].getName(); - } - - public static Image getModuleImage(ModuleServer ms) { - if( ms != null ) { - ILabelProvider labelProvider = ServerUICore.getLabelProvider(); - Image image = labelProvider.getImage(ms.module[ms.module.length - 1]); - labelProvider.dispose(); - return image; - } - return null; - } - - public static String getModuleStateText(ModuleServer ms) { - return ""; - } - - public static String getModuleStatusText(ModuleServer ms) { - if( ms != null && ms.server != null && ms.module != null ) { - IStatus status = ((Server) ms.server).getModuleStatus(ms.module); - if (status != null) - return status.getMessage(); - - return modulePublishState[ms.server.getModulePublishState(ms.module)]; - } - return ""; - } - - public static Image getModuleStatusImage(ModuleServer ms) { - IStatus status = ((Server) ms.server).getModuleStatus(ms.module); - if (status != null) { - ISharedImages sharedImages = ServerUIPlugin.getInstance().getWorkbench().getSharedImages(); - if (status.getSeverity() == IStatus.ERROR) - return sharedImages.getImage(ISharedImages.IMG_OBJS_ERROR_TSK); - else if (status.getSeverity() == IStatus.WARNING) - return sharedImages.getImage(ISharedImages.IMG_OBJS_WARN_TSK); - else if (status.getSeverity() == IStatus.INFO) - return sharedImages.getImage(ISharedImages.IMG_OBJS_INFO_TSK); - } - return null; - } - - protected String combine(String state, String status) { - if(isEmpty(state) && isEmpty(status)) - return ""; - if( isEmpty(state)) - return " [" + status + "]"; - if( isEmpty(status)) - return " [" + state + "]"; - return " [" + state + ", " + status + "]"; - } - - protected boolean isEmpty(String s) { - return (s == null || "".equals(s)); - } -} diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/ServerLabelProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/ServerLabelProvider.java deleted file mode 100644 index 7ea62fd0c..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/ServerLabelProvider.java +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008,2009 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.server.ui.internal.cnf; - -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.ui.ServerUICore; -import org.eclipse.wst.server.ui.internal.ImageResource; -import org.eclipse.wst.server.ui.internal.Messages; -import org.eclipse.wst.server.ui.internal.ServerUIPlugin; -import org.eclipse.wst.server.ui.internal.view.servers.ModuleServer; -/** - * Server table label provider. - */ -public class ServerLabelProvider extends LabelProvider { - - /** - * ServerTableLabelProvider constructor comment. - */ - public ServerLabelProvider() { - super(); - //TODO: Angel says: Look at bug# 258184 - } - - public String getText(Object element) { - if (element instanceof ModuleServer) { - ModuleServer ms = (ModuleServer) element; - if (ms.module == null) - return ""; - int size = ms.module.length; - String name = ms.module[size - 1].getName(); - return name; - } - - if( element instanceof IServer ) { - IServer server = (IServer) element; - return notNull(server.getName()); - } - - if( element == ServerContentProvider.INITIALIZING) - return Messages.viewInitializing; - - if (element instanceof IWorkspaceRoot){ - return Platform.getResourceString(ServerUIPlugin.getInstance().getBundle(), "%viewServers"); - } - - return "-"; - } - - public Image getImage(Object element) { - Image image = null; - if (element instanceof ModuleServer) { - ModuleServer ms = (ModuleServer) element; - ILabelProvider labelProvider = ServerUICore.getLabelProvider(); - image = labelProvider.getImage(ms.module[ms.module.length - 1]); - labelProvider.dispose(); - } else if( element instanceof IServer ) { - IServer server = (IServer) element; - if (server.getServerType() != null) { - // TODO Angel says: Need to fix this - // Because we are now grabbing the ServerState the type will not show. - // It might be best to create a new icon for the state, perhaps just the - // play/stop images, without the server - image = ServerDecorator.getServerStateImage(server); - if (image == null){ - image = ImageResource.getImage(server.getServerType().getId()); - } - } - } - return image; - } - - protected String notNull(String s) { - if (s == null) - return ""; - return s; - } - - public boolean isLabelProperty(Object element, String property) { - if (element instanceof IServer){ - if (property.equalsIgnoreCase("ICON")){ - return true; - } - } - return true; - } -} diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/ServersView2.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/ServersView2.java deleted file mode 100644 index be923da08..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/ServersView2.java +++ /dev/null @@ -1,357 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008,2009 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.server.ui.internal.cnf; - -import java.util.HashSet; -import java.util.Set; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IDecoratorManager; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.navigator.CommonNavigator; -import org.eclipse.ui.navigator.CommonViewer; -import org.eclipse.wst.server.core.IPublishListener; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.IServerLifecycleListener; -import org.eclipse.wst.server.core.IServerListener; -import org.eclipse.wst.server.core.ServerCore; -import org.eclipse.wst.server.core.ServerEvent; -import org.eclipse.wst.server.core.internal.Server; -import org.eclipse.wst.server.core.internal.UpdateServerJob; -import org.eclipse.wst.server.core.util.PublishAdapter; -import org.eclipse.wst.server.ui.internal.Messages; -import org.eclipse.wst.server.ui.internal.ServerToolTip; -import org.eclipse.wst.server.ui.internal.Trace; -/** - * A view of servers, their modules, and status. - */ -public class ServersView2 extends CommonNavigator { - - protected CommonViewer tableViewer; - - protected IServerLifecycleListener serverResourceListener; - protected IPublishListener publishListener; - protected IServerListener serverListener; - - // servers that are currently publishing and starting - protected static Set<String> publishing = new HashSet<String>(4); - protected static Set<String> starting = new HashSet<String>(4); - protected boolean animationActive = false; - protected boolean stopAnimation = false; - - /** - * ServersView constructor comment. - */ - public ServersView2() { - super(); - } - - @Override - public void createPartControl(Composite parent) { - super.createPartControl(parent); - deferInitialization(); - } - - private void deferInitialization() { - // TODO Angel Says: Need to do a final check on this line below. I don't think there is anything else - // that we need from to port from the old Servers View - //initializeActions(getCommonViewer()); - - Job job = new Job(Messages.jobInitializingServersView) { - public IStatus run(IProgressMonitor monitor) { - IServer[] servers = ServerCore.getServers(); - int size = servers.length; - for (int i = 0; i < size; i++) { - ((Server)servers[i]).getAllModules().iterator(); - } - - - Display.getDefault().asyncExec(new Runnable() { - public void run() { - try { - deferredInitialize(); - } catch (Exception e) { - // ignore - view has already been closed - } - } - }); - return Status.OK_STATUS; - } - }; - - job.setSystem(true); - job.setPriority(Job.SHORT); - job.schedule(); - } - - protected void deferredInitialize() { - addListener(); - tableViewer = getCommonViewer(); - getSite().setSelectionProvider(tableViewer); - - // init the tooltip - ServerToolTip toolTip = new ServerToolTip(tableViewer.getTree()); - toolTip.setShift(new Point(10, 3)); - toolTip.setPopupDelay(400); // in ms - toolTip.setHideOnMouseDown(true); - toolTip.activate(); - - if (tableViewer.getTree().getItemCount() > 0) { - Object obj = tableViewer.getTree().getItem(0).getData(); - tableViewer.setSelection(new StructuredSelection(obj)); - } - - Thread thread = new Thread() { - public void run() { - try { - Thread.sleep(5000); - } catch (Exception e) { - // ignore - } - IServer[] servers = ServerCore.getServers(); - int size = servers.length; - for (int i = 0; i < size; i++) { - IServer server = servers[i]; - if (server.getServerType() != null && server.getServerState() == IServer.STATE_UNKNOWN) { - UpdateServerJob job = new UpdateServerJob(server); - job.schedule(); - } - } - } - }; - thread.setDaemon(true); - thread.setPriority(Thread.MIN_PRIORITY + 1); - thread.start(); - } - - protected void handlePublishChange(IServer server, boolean isPublishing) { - String serverId = server.getId(); - if (isPublishing) - publishing.add(serverId); - else - publishing.remove(serverId); - - refreshServerState(server); - } - - /** - * @deprecated - * @param server - */ - protected void refreshServer(final IServer server){ - Trace.trace(Trace.FINEST, "Refreshing UI for server="+server); - Display.getDefault().asyncExec(new Runnable() { - public void run() { - IDecoratorManager dm = PlatformUI.getWorkbench().getDecoratorManager(); - dm.update("org.eclipse.wst.server.ui.navigatorDecorator"); - tableViewer.setSelection(tableViewer.getSelection()); - } - }); - } - - protected void refreshServerContent(final IServer server){ - Trace.trace(Trace.FINEST, "Refreshing Content for server="+server); - Display.getDefault().asyncExec(new Runnable() { - public void run() { - tableViewer.refresh(server, true); - } - }); - } - - protected void refreshServerState(final IServer server){ - Trace.trace(Trace.FINEST, "Refreshing UI for server="+server); - Display.getDefault().asyncExec(new Runnable() { - public void run() { - IDecoratorManager dm = PlatformUI.getWorkbench().getDecoratorManager(); - dm.update("org.eclipse.wst.server.ui.navigatorDecorator"); - tableViewer.setSelection(tableViewer.getSelection()); - } - }); - } - - protected void addListener(){ - // To enable the UI updating of servers and its childrens - serverResourceListener = new IServerLifecycleListener() { - public void serverAdded(IServer server) { - addServer(server); - server.addServerListener(serverListener); - ((Server) server).addPublishListener(publishListener); - } - public void serverChanged(IServer server) { - refreshServerContent(server); - } - public void serverRemoved(IServer server) { - removeServer(server); - server.removeServerListener(serverListener); - ((Server) server).removePublishListener(publishListener); - } - }; - ServerCore.addServerLifecycleListener(serverResourceListener); - - // To enable the refresh of the State decorator - publishListener = new PublishAdapter() { - public void publishStarted(IServer server) { - handlePublishChange(server, true); - } - - public void publishFinished(IServer server, IStatus status) { - handlePublishChange(server, false); - } - }; - - serverListener = new IServerListener() { - public void serverChanged(ServerEvent event) { - if (event == null) - return; - - int eventKind = event.getKind(); - IServer server = event.getServer(); - if ((eventKind & ServerEvent.SERVER_CHANGE) != 0) { - // server change event - if ((eventKind & ServerEvent.STATE_CHANGE) != 0) { - int state = event.getState(); - String id = server.getId(); - if (state == IServer.STATE_STARTING || state == IServer.STATE_STOPPING) { - boolean startThread = false; - synchronized (starting) { - if (!starting.contains(id)) { - if (starting.isEmpty()) - startThread = true; - starting.add(id); - } - } - if (startThread) - startThread(); - } else { - boolean stopThread = false; - synchronized (starting) { - if (starting.contains(id)) { - starting.remove(id); - if (starting.isEmpty()) - stopThread = true; - } - } - if (stopThread) - stopThread(); - } - refreshServerState(server); - } - } else if ((eventKind & ServerEvent.MODULE_CHANGE) != 0) { - // module change event - if ((eventKind & ServerEvent.STATE_CHANGE) != 0 || (eventKind & ServerEvent.PUBLISH_STATE_CHANGE) != 0) { - refreshServerContent(server); - } - } - // TODO Angel Says: I don't think we need this - //refreshServer(server); - } - }; - - // add listeners to servers - IServer[] servers = ServerCore.getServers(); - if (servers != null) { - int size = servers.length; - for (int i = 0; i < size; i++) { - servers[i].addServerListener(serverListener); - ((Server) servers[i]).addPublishListener(publishListener); - } - } - } - - protected void addServer(final IServer server) { - Display.getDefault().asyncExec(new Runnable() { - public void run() { - tableViewer.add(tableViewer.getInput(), server); - } - }); - } - - protected void removeServer(final IServer server) { - Display.getDefault().asyncExec(new Runnable() { - public void run() { - tableViewer.remove(server); - } - }); - } - - @Override - public void dispose() { - ServerCore.removeServerLifecycleListener(serverResourceListener); - - // remove listeners from servers - IServer[] servers = ServerCore.getServers(); - if (servers != null) { - int size = servers.length; - for (int i = 0; i < size; i++) { - servers[i].removeServerListener(serverListener); - ((Server) servers[i]).removePublishListener(publishListener); - } - } - super.dispose(); - } - - /** - * Start the animation thread - */ - protected void startThread() { - if (animationActive) - return; - - stopAnimation = false; - - final Display display = tableViewer == null ? Display.getDefault() : tableViewer.getControl().getDisplay(); - final int SLEEP = 200; - final Runnable[] animator = new Runnable[1]; - animator[0] = new Runnable() { - public void run() { - if (!stopAnimation) { - try { - int size = 0; - String[] servers; - synchronized (starting) { - size = starting.size(); - servers = new String[size]; - starting.toArray(servers); - - } - - for (int i = 0; i < size; i++) { - IServer server = ServerCore.findServer(servers[i]); - if (server != null ) { - ServerDecorator.animate(); - tableViewer.update(server, new String[]{"ICON"}); - } - } - } catch (Exception e) { - Trace.trace(Trace.FINEST, "Error in Servers view animation", e); - } - display.timerExec(SLEEP, animator[0]); - } - } - }; - Display.getDefault().asyncExec(new Runnable() { - public void run() { - display.timerExec(SLEEP, animator[0]); - } - }); - } - - protected void stopThread() { - stopAnimation = true; - } -} diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/ServersViewDropAdapterAssistant.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/ServersViewDropAdapterAssistant.java deleted file mode 100644 index 80c905abf..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/cnf/ServersViewDropAdapterAssistant.java +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright (c) 2009 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 - Base Code - * Red Hat - Refactor for CNF - */ - -package org.eclipse.wst.server.ui.internal.cnf; - -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.*; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.util.LocalSelectionTransfer; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.swt.dnd.DND; -import org.eclipse.swt.dnd.DropTargetEvent; -import org.eclipse.swt.dnd.TransferData; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.navigator.CommonDropAdapter; -import org.eclipse.ui.navigator.CommonDropAdapterAssistant; -import org.eclipse.wst.server.core.*; -import org.eclipse.wst.server.core.internal.ServerPlugin; -import org.eclipse.wst.server.ui.internal.EclipseUtil; -import org.eclipse.wst.server.ui.internal.ServerUIPlugin; -import org.eclipse.wst.server.ui.internal.actions.RunOnServerActionDelegate; - -public class ServersViewDropAdapterAssistant extends CommonDropAdapterAssistant { - - private List dndElementList; - - public IStatus validatePluginTransferDrop( - IStructuredSelection aDragSelection, Object aDropTarget) { - initializeSelection(aDragSelection); - return internalValidate(aDropTarget, dndElementList); - } - - public IStatus validateDrop(Object target, int operation, - TransferData transferType) { - if (LocalSelectionTransfer.getTransfer().isSupportedType(transferType)) { - ISelection s = LocalSelectionTransfer.getTransfer().getSelection(); - initializeSelection(s); - return internalValidate(target, dndElementList); - } - return Status.CANCEL_STATUS; - } - - protected void initializeSelection(ISelection s) { - if (dndElementList != null) - return; - if (!(s instanceof IStructuredSelection)) { - dndElementList = Collections.EMPTY_LIST; - return; - } - dndElementList = ((IStructuredSelection) s).toList(); - } - - protected IStatus internalValidate(Object target, List elements) { - if (target instanceof IServer) { - IServer server = (IServer) target; - Object next; - if (elements != null) { - Iterator i = elements.iterator(); - while (i.hasNext()) { - next = i.next(); - IModuleArtifact[] moduleArtifacts = ServerPlugin - .getModuleArtifacts(next); - if (moduleArtifacts != null && moduleArtifacts.length > 0) { - for (int j = 0; j < moduleArtifacts.length; j++) { - if (moduleArtifacts[j] != null - && moduleArtifacts[j].getModule() != null) { - IModuleType[] moduleTypes = server - .getServerType().getRuntimeType() - .getModuleTypes(); - if (ServerUtil.isSupportedModule(moduleTypes, - moduleArtifacts[j].getModule() - .getModuleType())) { - return Status.OK_STATUS; - } - } - } - } - } - } - } - clear(); - return Status.CANCEL_STATUS; - } - - public IStatus handleDrop(CommonDropAdapter dropAdapter, DropTargetEvent dropTargetEvent, Object target) { - IStatus status = internalHandleDrop(target, dndElementList); - if (status.isOK()) - dropTargetEvent.detail = DND.DROP_NONE; - return status; - } - - public IStatus handlePluginTransferDrop(IStructuredSelection aDragSelection, Object aDropTarget) { - return internalHandleDrop(aDropTarget, dndElementList); - } - - protected IStatus internalHandleDrop(Object target, List elements) { - boolean b = false; - if (target instanceof IServer) { - b = true; - if (dndElementList != null) { - Iterator iterator = elements.iterator(); - while (iterator.hasNext()) { - Object data2 = iterator.next(); - if (!doRunOnServerAction((IServer) target, data2)) - b = false; - } - } - } - clear(); - return b ? Status.OK_STATUS : Status.CANCEL_STATUS; - } - - private void clear() { - dndElementList = null; - } - - protected boolean doRunOnServerAction(IServer server, Object data) { - // check if the selection is a project (module) that we can add to the server - IProject project = (IProject) Platform.getAdapterManager().getAdapter( - data, IProject.class); - if (project != null) { - IModule[] modules = ServerUtil.getModules(project); - if (modules != null && modules.length == 1) { - try { - IServerWorkingCopy wc = server.createWorkingCopy(); - IModule[] parents = wc.getRootModules(modules[0], null); - if (parents == null || parents.length == 0) - return false; - - if (ServerUtil.containsModule(server, parents[0], null)) - return false; - - IModule[] add = new IModule[] { parents[0] }; - if (wc.canModifyModules(add, null, null).getSeverity() != IStatus.ERROR) { - wc.modifyModules(modules, null, null); - wc.save(false, null); - return true; - } - } catch (final CoreException ce) { - final Shell shell = getShell(); - shell.getDisplay().asyncExec(new Runnable() { - public void run() { - EclipseUtil.openError(shell, ce - .getLocalizedMessage()); - } - }); - return true; - } - } - } - - // otherwise, try Run on Server - final IServer finalServer = server; - RunOnServerActionDelegate ros = new RunOnServerActionDelegate() { - public IServer getServer(IModule module, - IModuleArtifact moduleArtifact, IProgressMonitor monitor) - throws CoreException { - if (!ServerUIPlugin.isCompatibleWithLaunchMode(finalServer, - launchMode)) - return null; - - if (!ServerUtil.containsModule(finalServer, module, monitor)) { - IServerWorkingCopy wc = finalServer.createWorkingCopy(); - try { - ServerUtil.modifyModules(wc, new IModule[] { module }, - new IModule[0], monitor); - wc.save(false, monitor); - } catch (CoreException ce) { - throw ce; - } - } - - return finalServer; - } - }; - Action action = new Action() { - // dummy action - }; - ros.selectionChanged(action, new StructuredSelection(data)); - - ros.run(action); - return true; - } -} diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/command/ServerCommand.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/command/ServerCommand.java deleted file mode 100644 index ac73935f9..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/command/ServerCommand.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.command; - -import org.eclipse.core.commands.operations.AbstractOperation; -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.server.core.IServerWorkingCopy; -/** - * A command on a server. - */ -public abstract class ServerCommand extends AbstractOperation { - protected IServerWorkingCopy server; - - /** - * ServerCommand constructor. - * - * @param server a server - * @param name a label - */ - public ServerCommand(IServerWorkingCopy server, String name) { - super(name); - this.server = server; - } - - public abstract void execute(); - - public IStatus execute(IProgressMonitor monitor, IAdaptable adapt) { - execute(); - return Status.OK_STATUS; - } - - public abstract void undo(); - - public IStatus undo(IProgressMonitor monitor, IAdaptable adapt) { - undo(); - return Status.OK_STATUS; - } - - public IStatus redo(IProgressMonitor monitor, IAdaptable adapt) { - return execute(monitor, adapt); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/command/SetPublisherEnablementCommand.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/command/SetPublisherEnablementCommand.java deleted file mode 100644 index f065601a9..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/command/SetPublisherEnablementCommand.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.command; - -import org.eclipse.wst.server.core.IServerWorkingCopy; -import org.eclipse.wst.server.core.internal.Publisher; -import org.eclipse.wst.server.core.internal.ServerWorkingCopy; -import org.eclipse.wst.server.ui.internal.Messages; -/** - * Command to change the server's publisher setting. - */ -public class SetPublisherEnablementCommand extends ServerCommand { - protected Publisher pub; - protected boolean enabled; - protected boolean oldEnabled; - - /** - * SetPublisherEnablementCommand constructor. - * - * @param server a server - * @param pub a publisher - * @param enabled whether the publisher should be enabled or disabled - */ - public SetPublisherEnablementCommand(IServerWorkingCopy server, Publisher pub, boolean enabled) { - super(server, Messages.serverEditorOverviewPublishCommand); - this.pub = pub; - this.enabled = enabled; - } - - /** - * Execute the command. - */ - public void execute() { - ServerWorkingCopy swc = (ServerWorkingCopy) server; - oldEnabled = swc.isPublisherEnabled(pub); - swc.setPublisherEnabled(pub, enabled); - } - - /** - * Undo the command. - */ - public void undo() { - ServerWorkingCopy swc = (ServerWorkingCopy) server; - swc.setPublisherEnabled(pub, oldEnabled); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/command/SetServerAutoPublishDefaultCommand.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/command/SetServerAutoPublishDefaultCommand.java deleted file mode 100644 index 298928e3d..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/command/SetServerAutoPublishDefaultCommand.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.command; - -import org.eclipse.wst.server.core.IServerWorkingCopy; -import org.eclipse.wst.server.core.internal.ServerWorkingCopy; -import org.eclipse.wst.server.ui.internal.Messages; -/** - * Command to change the server's auto-publish setting. - */ -public class SetServerAutoPublishDefaultCommand extends ServerCommand { - protected int setting; - protected int oldSetting; - - /** - * SetServerAutoPublishDefaultCommand constructor. - * - * @param server a server - * @param setting the auto-publish setting - */ - public SetServerAutoPublishDefaultCommand(IServerWorkingCopy server, int setting) { - super(server, Messages.serverEditorOverviewPublishCommand); - this.setting = setting; - } - - /** - * Execute the command. - */ - public void execute() { - ServerWorkingCopy swc = (ServerWorkingCopy) server; - oldSetting = swc.getAutoPublishSetting(); - swc.setAutoPublishSetting(setting); - } - - /** - * Undo the command. - */ - public void undo() { - ServerWorkingCopy swc = (ServerWorkingCopy) server; - swc.setAutoPublishSetting(oldSetting); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/command/SetServerAutoPublishTimeCommand.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/command/SetServerAutoPublishTimeCommand.java deleted file mode 100644 index ab949f45e..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/command/SetServerAutoPublishTimeCommand.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.command; - -import org.eclipse.wst.server.core.IServerWorkingCopy; -import org.eclipse.wst.server.core.internal.ServerWorkingCopy; -import org.eclipse.wst.server.ui.internal.Messages; -/** - * Command to change the server's auto-publish setting. - */ -public class SetServerAutoPublishTimeCommand extends ServerCommand { - protected int time; - protected int oldTime; - - /** - * SetServerAutoPublishDefaultCommand constructor. - * - * @param server a server - * @param time a publish time - */ - public SetServerAutoPublishTimeCommand(IServerWorkingCopy server, int time) { - super(server, Messages.serverEditorOverviewPublishCommand); - this.time = time; - } - - /** - * Execute the command. - */ - public void execute() { - ServerWorkingCopy swc = (ServerWorkingCopy) server; - oldTime = swc.getAutoPublishTime(); - swc.setAutoPublishTime(time); - } - - /** - * Undo the command. - */ - public void undo() { - ServerWorkingCopy swc = (ServerWorkingCopy) server; - swc.setAutoPublishTime(oldTime); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/command/SetServerConfigurationFolderCommand.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/command/SetServerConfigurationFolderCommand.java deleted file mode 100644 index 931bb617d..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/command/SetServerConfigurationFolderCommand.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.command; - -import org.eclipse.core.resources.IFolder; -import org.eclipse.wst.server.core.IServerWorkingCopy; -import org.eclipse.wst.server.ui.internal.Messages; -/** - * Command to change the server configuration folder. - */ -public class SetServerConfigurationFolderCommand extends ServerCommand { - protected IFolder folder; - protected IFolder oldFolder; - - /** - * SetServerConfigurationFolderCommand constructor. - * - * @param server a server - * @param folder a new server configuration location - */ - public SetServerConfigurationFolderCommand(IServerWorkingCopy server, IFolder folder) { - super(server, Messages.serverEditorOverviewServerHostnameCommand); - this.folder = folder; - } - - /** - * Execute the command. - */ - public void execute() { - oldFolder = server.getServerConfiguration(); - server.setServerConfiguration(folder); - } - - /** - * Undo the command. - */ - public void undo() { - server.setServerConfiguration(oldFolder); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/command/SetServerHostnameCommand.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/command/SetServerHostnameCommand.java deleted file mode 100644 index 158bd8412..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/command/SetServerHostnameCommand.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.command; - -import org.eclipse.wst.server.core.IServerWorkingCopy; -import org.eclipse.wst.server.ui.internal.Messages; -/** - * Command to change the server hostname. - */ -public class SetServerHostnameCommand extends ServerCommand { - protected String name; - protected String oldName; - - /** - * SetServerHostnameCommand constructor. - * - * @param server a server - * @param name a hostname or IP address - */ - public SetServerHostnameCommand(IServerWorkingCopy server, String name) { - super(server, Messages.serverEditorOverviewServerHostnameCommand); - this.name = name; - } - - /** - * Execute the command. - */ - public void execute() { - oldName = server.getHost(); - server.setHost(name); - } - - /** - * Undo the command. - */ - public void undo() { - server.setHost(oldName); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/command/SetServerNameCommand.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/command/SetServerNameCommand.java deleted file mode 100644 index 7ba416f57..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/command/SetServerNameCommand.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.command; - -import org.eclipse.wst.server.core.IServerWorkingCopy; -import org.eclipse.wst.server.ui.internal.Messages; -/** - * Command to change the server name. - */ -public class SetServerNameCommand extends ServerCommand { - protected String name; - protected String oldName; - - /** - * SetServerNameCommand constructor. - * - * @param server a server - * @param name a name for the server - */ - public SetServerNameCommand(IServerWorkingCopy server, String name) { - super(server, Messages.serverEditorOverviewServerNameCommand); - this.name = name; - } - - /** - * Execute the command. - */ - public void execute() { - oldName = server.getName(); - server.setName(name); - } - - /** - * Undo the command. - */ - public void undo() { - server.setName(oldName); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/command/SetServerRuntimeCommand.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/command/SetServerRuntimeCommand.java deleted file mode 100644 index 70c9a06e7..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/command/SetServerRuntimeCommand.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.command; - -import org.eclipse.wst.server.core.IRuntime; -import org.eclipse.wst.server.core.IServerWorkingCopy; -import org.eclipse.wst.server.ui.internal.Messages; -/** - * Command to change the server runtime. - */ -public class SetServerRuntimeCommand extends ServerCommand { - protected IRuntime runtime; - protected IRuntime oldRuntime; - - /** - * SetServerRuntimeCommand constructor. - * - * @param server a server - * @param runtime a server runtime - */ - public SetServerRuntimeCommand(IServerWorkingCopy server, IRuntime runtime) { - super(server, Messages.serverEditorOverviewRuntimeCommand); - this.runtime = runtime; - } - - /** - * Execute the command. - */ - public void execute() { - oldRuntime = server.getRuntime(); - server.setRuntime(runtime); - } - - /** - * Undo the command. - */ - public void undo() { - server.setRuntime(oldRuntime); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/command/SetServerStartTimeoutCommand.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/command/SetServerStartTimeoutCommand.java deleted file mode 100644 index d3f6d6dd9..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/command/SetServerStartTimeoutCommand.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.command; - -import org.eclipse.wst.server.core.IServerWorkingCopy; -import org.eclipse.wst.server.core.internal.ServerWorkingCopy; -import org.eclipse.wst.server.ui.internal.Messages; -/** - * Command to change the server's start timeout setting. - */ -public class SetServerStartTimeoutCommand extends ServerCommand { - protected int time; - protected int oldTime; - - /** - * SetServerStartTimeoutCommand constructor. - * - * @param server a server - * @param time a publish time - */ - public SetServerStartTimeoutCommand(IServerWorkingCopy server, int time) { - super(server, Messages.serverEditorOverviewTimeoutCommand); - this.time = time; - } - - /** - * Execute the command. - */ - public void execute() { - ServerWorkingCopy swc = (ServerWorkingCopy) server; - oldTime = swc.getStartTimeout(); - swc.setStartTimeout(time); - } - - /** - * Undo the command. - */ - public void undo() { - ServerWorkingCopy swc = (ServerWorkingCopy) server; - swc.setStartTimeout(oldTime); - } -} diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/command/SetServerStopTimeoutCommand.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/command/SetServerStopTimeoutCommand.java deleted file mode 100644 index dcc185857..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/command/SetServerStopTimeoutCommand.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.command; - -import org.eclipse.wst.server.core.IServerWorkingCopy; -import org.eclipse.wst.server.core.internal.ServerWorkingCopy; -import org.eclipse.wst.server.ui.internal.Messages; -/** - * Command to change the server's stop timeout setting. - */ -public class SetServerStopTimeoutCommand extends ServerCommand { - protected int time; - protected int oldTime; - - /** - * SetServerStopTimeoutCommand constructor. - * - * @param server a server - * @param time a publish time - */ - public SetServerStopTimeoutCommand(IServerWorkingCopy server, int time) { - super(server, Messages.serverEditorOverviewTimeoutCommand); - this.time = time; - } - - /** - * Execute the command. - */ - public void execute() { - ServerWorkingCopy swc = (ServerWorkingCopy) server; - oldTime = swc.getStopTimeout(); - swc.setStopTimeout(time); - } - - /** - * Undo the command. - */ - public void undo() { - ServerWorkingCopy swc = (ServerWorkingCopy) server; - swc.setStopTimeout(oldTime); - } -} diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/GlobalCommandManager.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/GlobalCommandManager.java deleted file mode 100644 index 7b33baac7..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/GlobalCommandManager.java +++ /dev/null @@ -1,731 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.editor; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.commands.operations.IUndoableOperation; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.wst.server.core.*; -import org.eclipse.wst.server.core.internal.Server; -import org.eclipse.wst.server.ui.editor.IServerEditorPartInput; -import org.eclipse.wst.server.ui.internal.Messages; -import org.eclipse.wst.server.ui.internal.Trace; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -/** - * - */ -public class GlobalCommandManager { - // maximum number of commands in the history - private static final int MAX_HISTORY = 200; - - class ServerResourceCommand { - IUndoableOperation command; - String id; - } - - // commands in the undo history - protected List<ServerResourceCommand> undoList = new ArrayList<ServerResourceCommand>(); - - // size of the undo stack on last save - protected int undoSaveIndex = 0; - - // commands in the redo history - protected List<ServerResourceCommand> redoList = new ArrayList<ServerResourceCommand>(); - - class CommandManagerInfo { - // number of open editors on this resource - int count; - - // true if the resource has not been saved since - // the last change - boolean isDirty; - - // true if the resource is read-only - boolean isReadOnly; - - // the element id - String id; - - // the working copy - IServerWorkingCopy wc; - - // files and timestamps - Map<IFile, Long> fileMap; - - int timestamp; - } - - protected Map<String, CommandManagerInfo> commandManagers = new HashMap<String, CommandManagerInfo>(); - - // property change listeners - protected List<PropertyChangeListener> propertyListeners; - public static final String PROP_DIRTY = "dirtyState"; - public static final String PROP_UNDO = "undoAction"; - public static final String PROP_REDO = "redoAction"; - public static final String PROP_RELOAD = "reload"; - - protected static GlobalCommandManager instance; - - public static GlobalCommandManager getInstance() { - if (instance == null) - instance = new GlobalCommandManager(); - return instance; - } - - /** - * Add a property change listener to this instance. - * - * @param listener java.beans.PropertyChangeListener - */ - public void addPropertyChangeListener(PropertyChangeListener listener) { - if (propertyListeners == null) - propertyListeners = new ArrayList<PropertyChangeListener>(); - propertyListeners.add(listener); - } - - /** - * Remove a property change listener from this instance. - * - * @param listener java.beans.PropertyChangeListener - */ - public void removePropertyChangeListener(PropertyChangeListener listener) { - if (propertyListeners != null) - propertyListeners.remove(listener); - } - - /** - * Fire a property change event. - */ - protected void firePropertyChangeEvent(String propertyName, Object oldValue, Object newValue) { - if (propertyListeners == null) - return; - - PropertyChangeEvent event = new PropertyChangeEvent(this, propertyName, oldValue, newValue); - //Trace.trace("Firing: " + event + " " + oldValue); - try { - int size = propertyListeners.size(); - PropertyChangeListener[] pcl = new PropertyChangeListener[size]; - propertyListeners.toArray(pcl); - - for (int i = 0; i < size; i++) - try { - pcl[i].propertyChange(event); - } catch (Exception e) { - // ignore - } - } catch (Exception e) { - // ignore - } - } - - /** - * Get the command manager for a given id. - * - * @param id an id - */ - public void getCommandManager(String id) { - Trace.trace(Trace.FINEST, "Getting command manager for " + id); - try { - CommandManagerInfo info = commandManagers.get(id); - if (info != null) { - info.count ++; - return; - } - } catch (Exception e) { - Trace.trace(Trace.WARNING, "Could not find existing command manager", e); - } - Trace.trace(Trace.FINEST, "Creating new command manager for " + id); - try { - CommandManagerInfo info = new CommandManagerInfo(); - info.count = 1; - info.id = id; - IServer server = null; - if (id != null) - server = ServerCore.findServer(id); - if (server != null) - info.wc = server.createWorkingCopy(); - info.isDirty = false; - info.isReadOnly = false; - commandManagers.put(id, info); - updateTimestamps(id); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Could not obtain command manager", e); - } - return; - } - - /** - * Release the command manager for a given id. - * - * @param id an id - */ - public void releaseCommandManager(String id) { - Trace.trace(Trace.FINEST, "Releasing command manager for " + id); - try { - CommandManagerInfo info = commandManagers.get(id); - if (info != null) { - info.count --; - if (info.count == 0) { - commandManagers.remove(id); - clearUndoList(id); - clearRedoList(id); - } - } - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Could not release command manager", e); - } - } - - /** - * Reload the command manager for a given id. - * - * @param id an id - */ - public void reload(String id) { - try { - CommandManagerInfo info = getExistingCommandManagerInfo(id); - if (info != null) { - IServer server = null; - if (id != null) - server = ServerCore.findServer(id); - if (server != null) - info.wc = server.createWorkingCopy(); - firePropertyChangeEvent(PROP_RELOAD, id, null); - } - clearUndoList(id); - clearRedoList(id); - undoSaveIndex = undoList.size(); - setDirtyState(id, false); - updateTimestamps(id); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Could not release command manager", e); - } - } - - /** - * - */ - protected CommandManagerInfo getExistingCommandManagerInfo(String id) { - try { - return commandManagers.get(id); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Could not find existing command manager info"); - } - return null; - } - - /** - * Returns true if there is only one command manager. - * - * @param id an id - * @return <code>true</code> if the only command manager - */ - public boolean isOnlyCommandManager(String id) { - CommandManagerInfo info = getExistingCommandManagerInfo(id); - return (info != null && info.count == 1); - } - - protected IServerEditorPartInput getPartInput(String serverId, ServerResourceCommandManager serverCommandManager) { - CommandManagerInfo serverInfo = null; - IServerWorkingCopy server = null; - boolean serverReadOnly = false; - if (serverId != null) { - serverInfo = getExistingCommandManagerInfo(serverId); - if (serverInfo == null) - return null; - - server = serverInfo.wc; - serverReadOnly = serverInfo.isReadOnly; - } - - return new ServerEditorPartInput(serverCommandManager, server, serverReadOnly); - } - - /** - * - */ - protected IServerWorkingCopy getServerResource(String id) { - CommandManagerInfo info = getExistingCommandManagerInfo(id); - if (info == null) - return null; - - return info.wc; - } - - /** - * Return the currently active shell. - * - * @return a shell - */ - private Shell getShell() { - try { - Display d = Display.getCurrent(); - if (d == null) - d = Display.getDefault(); - - return d.getActiveShell(); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Could not get shell", e); - return null; - } - } - - /** - * Execute the given command and place it in the undo stack. - * If the command cannot be undone, the user will be notified - * before it is executed. - * - * @param id an id - * @param command a task - */ - public void executeCommand(String id, IUndoableOperation command) { - final Shell shell = getShell(); - - if (!command.canUndo() && !undoList.isEmpty()) { - try { - if (!MessageDialog.openConfirm(shell, Messages.editorServerEditor, Messages.editorPromptIrreversible)) - return; - } catch (Exception e) { - // ignore - } - } - - ServerResourceCommand src = new ServerResourceCommand(); - src.id = id; - src.command = command; - - try { - IAdaptable adaptable = new IAdaptable() { - public Object getAdapter(Class adapter) { - if (Shell.class.equals(adapter)) - return shell; - return null; - } - }; - IStatus status = command.execute(new NullProgressMonitor(), adaptable); - if (status != null && !status.isOK()) - MessageDialog.openError(shell, Messages.editorServerEditor, status.getMessage()); - } catch (ExecutionException ce) { - Trace.trace(Trace.SEVERE, "Error executing command", ce); - return; - } - - CommandManagerInfo info = getExistingCommandManagerInfo(id); - if (info == null) - return; - - if (command.canUndo()) - addToUndoList(src); - else { - undoSaveIndex = -1; - clearUndoList(id); - } - - // clear redo list since a new command has been executed. - clearRedoList(id); - - setDirtyState(id, true); - } - - /** - * Add a command to the history. - */ - private void addToUndoList(ServerResourceCommand src) { - undoList.add(src); - - // limit history growth - if (undoList.size() > MAX_HISTORY) - undoList.remove(0); - - firePropertyChangeEvent(PROP_UNDO, src.id, null); - } - - /** - * Clears the undo of a particular resource. - */ - private void clearUndoList(String id) { - int i = 0; - boolean modified = false; - while (i < undoList.size()) { - ServerResourceCommand src = undoList.get(i); - if (src.id.equals(id)) { - modified = true; - undoList.remove(i); - } else - i++; - } - if (modified) - firePropertyChangeEvent(PROP_UNDO, id, null); - } - - /** - * Clears the redo of a particular resource. - */ - private void clearRedoList(String id) { - int i = 0; - boolean modified = false; - while (i < redoList.size()) { - ServerResourceCommand src = redoList.get(i); - if (src.id.equals(id)) { - redoList.remove(i); - modified = true; - } else - i++; - } - if (modified) - firePropertyChangeEvent(PROP_REDO, id, null); - } - - /** - * Returns true if there is a command that can be undone. - * @return boolean - */ - protected boolean canUndo(String a, String b) { - Iterator iterator = undoList.iterator(); - while (iterator.hasNext()) { - ServerResourceCommand src = (ServerResourceCommand) iterator.next(); - if (src.id == a || src.id == b) - return true; - } - return false; - } - - /** - * Returns true if there is a command that can be redone. - * @return boolean - */ - protected boolean canRedo(String a, String b) { - Iterator iterator = redoList.iterator(); - while (iterator.hasNext()) { - ServerResourceCommand src = (ServerResourceCommand) iterator.next(); - if (src.id == a || src.id == b) - return true; - } - return false; - } - - /** - * Returns the command that would be undone next. - * - * @param a an id - * @return a task - */ - public IUndoableOperation getUndoCommand(String a) { - int size = undoList.size(); - for (int i = size - 1; i >= 0; i--) { - ServerResourceCommand src = undoList.get(i); - if (src.id == a) - return src.command; - } - return null; - } - - /** - * Returns the command that would be redone next. - * - * @param a an id - * @return a task - */ - public IUndoableOperation getRedoCommand(String a) { - int size = redoList.size(); - for (int i = size - 1; i >= 0; i--) { - ServerResourceCommand src = redoList.get(i); - if (src.id == a) - return src.command; - } - return null; - } - - /** - * Returns true if the server resource is "dirty". - * - * @param id an id - * @return a task - */ - public boolean isDirty(String id) { - CommandManagerInfo info = getExistingCommandManagerInfo(id); - if (info == null) - return false; - - return info.isDirty; - } - - /** - * Returns true if the server resource is read-only. - * - * @param id an id - * @return boolean - */ - public boolean isReadOnly(String id) { - CommandManagerInfo info = getExistingCommandManagerInfo(id); - if (info == null) - return false; - return info.isReadOnly; - } - - /** - * Sets the server resource read-only flag. - * - * @param id an id - * @param readOnly <code>true</code> to set read-only, <code>false</code> otherwise - */ - public void setReadOnly(String id, boolean readOnly) { - CommandManagerInfo info = getExistingCommandManagerInfo(id); - if (info == null) - return; - - if (info.isReadOnly == readOnly) - return; - info.isReadOnly = readOnly; - firePropertyChangeEvent(PROP_RELOAD, id, null); - } - - /** - * Returns true if the server resource files are read-only. - * - * @param id an id - * @return <code>true</code> if the files are read-only - */ - public boolean areFilesReadOnly(String id) { - CommandManagerInfo info = getExistingCommandManagerInfo(id); - if (info == null) - return false; - return (getReadOnlyFiles(id).length > 0); - } - - /** - * Sets the dirty state and fires an event if needed. - * @param dirty boolean - */ - private void setDirtyState(String id, boolean dirty) { - CommandManagerInfo info = getExistingCommandManagerInfo(id); - if (info.isDirty == dirty) - return; - - info.isDirty = dirty; - firePropertyChangeEvent(PROP_DIRTY, id, null); - } - - /** - * Undo the last command. - */ - protected void undo(String a) { - ServerResourceCommand src = null; - Iterator iterator = undoList.iterator(); - while (iterator.hasNext()) { - ServerResourceCommand src2 = (ServerResourceCommand) iterator.next(); - if (src2.id == a) - src = src2; - } - if (src == null) - return; - - try { - src.command.undo(null, null); - } catch (ExecutionException ee) { - // do something - } - - undoList.remove(src); - firePropertyChangeEvent(PROP_UNDO, src.id, null); - redoList.add(src); - firePropertyChangeEvent(PROP_REDO, src.id, null); - - if (undoSaveIndex == undoList.size()) - setDirtyState(src.id, false); - else - setDirtyState(src.id, true); - } - - /** - * Redo the last command. - */ - protected void redo(String a) { - ServerResourceCommand src = null; - Iterator iterator = redoList.iterator(); - while (iterator.hasNext()) { - ServerResourceCommand src2 = (ServerResourceCommand) iterator.next(); - if (src2.id == a) - src = src2; - } - if (src == null) - return; - - try { - final Shell shell = getShell(); - IAdaptable adaptable = new IAdaptable() { - public Object getAdapter(Class adapter) { - if (Shell.class.equals(adapter)) - return shell; - return null; - } - }; - IStatus status = src.command.execute(new NullProgressMonitor(), adaptable); - if (status != null && !status.isOK()) - MessageDialog.openError(shell, Messages.editorServerEditor, status.getMessage()); - } catch (ExecutionException ce) { - Trace.trace(Trace.SEVERE, "Error executing command", ce); - return; - } - redoList.remove(src); - firePropertyChangeEvent(PROP_REDO, src.id, null); - undoList.add(src); - firePropertyChangeEvent(PROP_UNDO, src.id, null); - - if (undoSaveIndex == undoList.size()) - setDirtyState(src.id, false); - else - setDirtyState(src.id, true); - } - - /** - * Clears the history list. - * - * @param id an id - */ - public void resourceSaved(String id) { - undoSaveIndex = undoList.size(); - setDirtyState(id, false); - } - - /** - * Return an array of read-only files. - * - * @param server a server - * @return a possibly empty array of files - */ - public static IFile[] getReadOnlyFiles(IServerAttributes server) { - try { - List<IFile> list = new ArrayList<IFile>(); - IFile file = ((Server)server).getFile(); - - if (file != null) - list.add(file); - - IFile[] files = new IFile[list.size()]; - list.toArray(files); - return files; - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "getReadOnlyFiles", e); - } - return null; - } - - /** - * - */ - protected IFile[] getServerResourceFiles(String id) { - if (id == null) - return new IFile[0]; - - CommandManagerInfo info = getExistingCommandManagerInfo(id); - if (info == null) - return new IFile[0]; - - return getReadOnlyFiles(info.wc); - } - - protected IFile[] getReadOnlyFiles(String id) { - List<IFile> list = new ArrayList<IFile>(); - IFile[] files = getServerResourceFiles(id); - int size = files.length; - for (int i = 0; i < size; i++) { - if (files[i].isReadOnly()) - list.add(files[i]); - } - - IFile[] fileList = new IFile[list.size()]; - list.toArray(fileList); - return fileList; - } - - /** - * Update the timestamps. - * - * @param id an id - */ - public void updateTimestamps(String id) { - CommandManagerInfo info = getExistingCommandManagerInfo(id); - if (info == null) - return; - - info.fileMap = new HashMap<IFile, Long>(); - IFile[] files = getServerResourceFiles(id); - if (files != null) { - int size = files.length; - - for (int i = 0; i < size; i++) { - if (files[i] != null) { - File f = files[i].getLocation().toFile(); - if (f != null) { - long time = f.lastModified(); - info.fileMap.put(files[i], new Long(time)); - } - } - } - } - info.timestamp = getTimestamp(info); - } - - protected static int getTimestamp(CommandManagerInfo info) { - IServer server = info.wc.getOriginal(); - - if (server != null) - return ((Server)server).getTimestamp(); - return -1; - } - - /** - * - */ - protected boolean hasChanged(String id) { - CommandManagerInfo info = getExistingCommandManagerInfo(id); - if (info == null) - return false; - IFile[] files = getServerResourceFiles(id); - int size = files.length; - - int count = 0; - for (int i = 0; i < size; i++) { - count++; - File f = files[i].getLocation().toFile(); - try { - Long time = info.fileMap.get(files[i]); - if (time.longValue() != f.lastModified()) - return true; - } catch (Exception e) { - return true; - } - } - - int timestamp = getTimestamp(info); - if (info.timestamp != timestamp) - return true; - - if (count != info.fileMap.size()) - return true; - return false; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/IOrdered.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/IOrdered.java deleted file mode 100644 index 8872f8bd8..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/IOrdered.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.editor; -/** - * An object that has an absolute ordering, and can be ordered against other objects. - * - * <p> - * [issue: It is notoriously difficult to place any kind of - * useful order on objects that are contributed independently by - * non-collaborating parties. The IOrdered mechanism is weak, and - * can't really solve the problem. Issues of presentation are usually - * best left to the UI, which can sort objects based on arbitrary - * properties.] - * </p> - * - * <p>This interface is not intended to be implemented by clients.</p> - */ -public interface IOrdered { - /** - * Returns the order (index/priority). - * - * @return int - */ - public int getOrder(); -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/IServerEditorActionFactory.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/IServerEditorActionFactory.java deleted file mode 100644 index 41791ecf6..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/IServerEditorActionFactory.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.editor; - -import org.eclipse.jface.action.IAction; -import org.eclipse.ui.IEditorSite; - -import org.eclipse.wst.server.core.IServerWorkingCopy; -import org.eclipse.wst.server.ui.editor.IServerEditorPartInput; -/** - * - */ -public interface IServerEditorActionFactory extends IOrdered { - /** - * Returns the id. - * - * @return an id - */ - public String getId(); - - /** - * Returns the name. - * - * @return a name - */ - public String getName(); - - /** - * Returns true if the given server resource type (given by the - * id) can be opened with this editor. This result is based on - * the result of the getFactoryIds() method. - * - * @param id an id - * @return boolean - */ - public boolean supportsServerElementType(String id); - - /** - * Returns true if this editor page should be visible with the given server. - * This allows (for instance) complex configuration pages to only be shown when used - * with non-unittest servers. - * - * @param server a server - * @return <code>true</code> if the action should display - */ - public boolean shouldDisplay(IServerWorkingCopy server); - - /** - * Create the action. - * - * @param site an editor site - * @param input a server editor input - * @return an action - */ - public IAction createAction(IEditorSite site, IServerEditorPartInput input); -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/IServerEditorInput.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/IServerEditorInput.java deleted file mode 100644 index 61ec8d9eb..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/IServerEditorInput.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.editor; - -import org.eclipse.wst.server.ui.internal.ServerUIPlugin; -import org.eclipse.ui.IEditorInput; -/** - * This is the editor input for the server and server - * configuration editor. The input includes both a server - * and server configuration. - * - * <p>This interface is not intended to be implemented by clients.</p> - */ -public interface IServerEditorInput extends IEditorInput { - public static final String EDITOR_ID = ServerUIPlugin.PLUGIN_ID + ".editor"; - - /** - * Returns the server id. - * - * @return java.lang.String - */ - public String getServerId(); -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/IServerEditorPageSectionFactory.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/IServerEditorPageSectionFactory.java deleted file mode 100644 index 474385334..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/IServerEditorPageSectionFactory.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.editor; - -import org.eclipse.wst.server.core.IServerWorkingCopy; -import org.eclipse.wst.server.ui.editor.ServerEditorSection; -/** - * - */ -public interface IServerEditorPageSectionFactory extends IOrdered { - /** - * Returns the id. - * - * @return the id - */ - public String getId(); - - /** - * Returns true if the given server resource type (given by the - * id) can be opened with this editor. This result is based on - * the result of the types attribute. - * - * @param id the type id - * @return boolean - */ - public boolean supportsType(String id); - - public String getInsertionId(); - - /** - * Returns true if this editor page section should be visible with the given server. - * This allows (for instance) complex configuration pages to only be shown when used - * with non-unittest servers. - * - * @param server a server - * @return <code>true</code> if the section should be shown, and <code>false</code> otherwise - */ - public boolean shouldCreateSection(IServerWorkingCopy server); - - /** - * Create the editor page section. - * - * @return the section - */ - public ServerEditorSection createSection(); -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/IServerEditorPartFactory.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/IServerEditorPartFactory.java deleted file mode 100644 index dc601de6e..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/IServerEditorPartFactory.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.editor; - -import org.eclipse.ui.IEditorPart; - -import org.eclipse.wst.server.core.IServerWorkingCopy; -/** - * - */ -public interface IServerEditorPartFactory extends IOrdered { - /** - * Returns the id. - * - * @return the id - */ - public String getId(); - - /** - * Return the displayable name. - * - * @return the name - */ - public String getName(); - - /** - * Returns true if the given server resource type (given by the - * id) can be opened with this editor. This result is based on - * the result of the types attribute. - * - * @param id a server type id - * @return <code>true</code> if the type is supported - */ - public boolean supportsType(String id); - - /** - * Returns true if a given insertion id is supported. - * - * @param id - * @return <code>true</code> if the insertion id is supported - */ - public boolean supportsInsertionId(String id); - - /** - * Returns true if this editor page should be visible with the given server. - * This allows (for instance) complex configuration pages to only be shown when used - * with non-unittest servers. - * - * @param server a server - * @return <code>true</code> if the page should be visible - */ - public boolean shouldCreatePage(IServerWorkingCopy server); - - /** - * Create the editor page. - * - * @return the editor page - */ - public IEditorPart createPage(); -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/OverviewEditorPart.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/OverviewEditorPart.java deleted file mode 100644 index db47e6b5a..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/OverviewEditorPart.java +++ /dev/null @@ -1,1037 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.editor; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchConfigurationType; -import org.eclipse.debug.core.ILaunchManager; -import org.eclipse.debug.ui.DebugUITools; -import org.eclipse.jface.dialogs.IMessageProvider; -import org.eclipse.jface.fieldassist.AutoCompleteField; -import org.eclipse.jface.fieldassist.ControlDecoration; -import org.eclipse.jface.fieldassist.FieldDecoration; -import org.eclipse.jface.fieldassist.FieldDecorationRegistry; -import org.eclipse.jface.fieldassist.TextContentAdapter; -import org.eclipse.jface.viewers.CheckStateChangedEvent; -import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.viewers.ICheckStateListener; -import org.eclipse.jface.window.Window; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Spinner; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorSite; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.ContainerSelectionDialog; -import org.eclipse.ui.forms.IFormColors; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.ManagedForm; -import org.eclipse.ui.forms.events.HyperlinkAdapter; -import org.eclipse.ui.forms.events.HyperlinkEvent; -import org.eclipse.ui.forms.widgets.*; -import org.eclipse.ui.help.IWorkbenchHelpSystem; -import org.eclipse.wst.server.core.*; -import org.eclipse.wst.server.core.internal.Publisher; -import org.eclipse.wst.server.core.internal.Server; -import org.eclipse.wst.server.core.internal.ServerPlugin; -import org.eclipse.wst.server.core.internal.ServerType; -import org.eclipse.wst.server.core.util.SocketUtil; -import org.eclipse.wst.server.ui.editor.*; -import org.eclipse.wst.server.ui.internal.ContextIds; -import org.eclipse.wst.server.ui.internal.ImageResource; -import org.eclipse.wst.server.ui.internal.Messages; -import org.eclipse.wst.server.ui.internal.SWTUtil; -import org.eclipse.wst.server.ui.internal.ServerUIPlugin; -import org.eclipse.wst.server.ui.internal.Trace; -import org.eclipse.wst.server.ui.internal.command.*; -import org.eclipse.wst.server.ui.internal.viewers.BaseContentProvider; -import org.eclipse.wst.server.ui.internal.viewers.BaseLabelProvider; -import org.eclipse.wst.server.ui.internal.wizard.TaskWizard; -import org.eclipse.wst.server.ui.internal.wizard.WizardTaskUtil; -import org.eclipse.wst.server.ui.wizard.WizardFragment; -/** - * Server general editor page. - */ -public class OverviewEditorPart extends ServerEditorPart { - protected Text serverName; - protected Text serverConfiguration; - protected Text hostname; - protected Combo runtimeCombo; - protected Button browse; - protected Button autoPublishDisable; - protected Button autoPublishEnable; - protected Spinner autoPublishTime; - protected Table publishersTable; - protected CheckboxTableViewer publishersViewer; - protected Spinner startTimeoutSpinner; - protected Spinner stopTimeoutSpinner; - protected ManagedForm managedForm; - - protected boolean updating; - - protected IRuntime[] runtimes; - - protected PropertyChangeListener listener; - - protected IRuntimeLifecycleListener runtimeListener; - - class PublisherContentProvider extends BaseContentProvider { - protected Publisher[] pubs; - public PublisherContentProvider(Publisher[] pubs) { - this.pubs = pubs; - } - - public Object[] getElements(Object inputElement) { - return pubs; - } - } - - class PublishLabelProvider extends BaseLabelProvider { - public String getText(Object element) { - if (element instanceof Publisher) { - Publisher pub = (Publisher) element; - return pub.getName(); - } - return ""; - } - } - - /** - * OverviewEditorPart constructor comment. - */ - public OverviewEditorPart() { - super(); - } - - /** - * - */ - protected void addChangeListener() { - listener = new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - if (event.getPropertyName().equals("configuration-id") && serverConfiguration != null) - validate(); - - // following code behaves poorly because there is no default local or remote - // publishing time per server or server type. as a result it sets the value - // to the default, which seems to be more harm than good until we revamp the - // default publishing times - /*if ("hostname".equals(event.getPropertyName())) { - final String oldHostname = (String) event.getOldValue(); - final String newHostname = (String) event.getNewValue(); - final boolean isNewHostnameLocalhost = SocketUtil.isLocalhost(newHostname); - if (isNewHostnameLocalhost != SocketUtil.isLocalhost(oldHostname)) { - // run this code only if the hostname changed from - // 'localhost' to a remote name, or vice-versa - hostname.getDisplay().asyncExec(new Runnable() { - public void run() { - try { - if (isNewHostnameLocalhost) { - int autoPublishTime2 = ServerPreferences.getInstance().getAutoPublishLocalTime(); - ((ServerWorkingCopy)getServer()).setAutoPublishTime(autoPublishTime2); - } else { - int autoPublishTime2 = ServerPreferences.getInstance().getAutoPublishRemoteTime(); - ((ServerWorkingCopy)getServer()).setAutoPublishTime(autoPublishTime2); - } - } catch (Exception e) { - Trace.trace(Trace.WARNING, "Could not update publish time to new host"); - } - } - }); - } - }*/ - - if (updating) - return; - updating = true; - if (event.getPropertyName().equals("name")) - updateNames(); - else if (event.getPropertyName().equals("hostname") && hostname != null) { - hostname.setText((String) event.getNewValue()); - } else if (event.getPropertyName().equals("runtime-id")) { - String runtimeId = (String) event.getNewValue(); - IRuntime runtime = null; - if (runtimeId != null) - runtime = ServerCore.findRuntime(runtimeId); - if (runtimeCombo != null) { - int size = runtimes.length; - for (int i = 0; i < size; i++) { - if (runtimes[i].equals(runtime)) - runtimeCombo.select(i); - } - } - } else if (event.getPropertyName().equals("configuration-id") && serverConfiguration != null) { - String path = (String) event.getNewValue(); - serverConfiguration.setText(path); - } else if (event.getPropertyName().equals(Server.PROP_AUTO_PUBLISH_TIME)) { - Integer curAutoPublishTime = (Integer)event.getNewValue(); - autoPublishTime.setSelection(curAutoPublishTime.intValue()); - SWTUtil.setSpinnerTooltip(autoPublishTime); - validate(); - } else if (event.getPropertyName().equals(Server.PROP_AUTO_PUBLISH_SETTING)) { - Integer autoPublishSetting = (Integer)event.getNewValue(); - int setting = autoPublishSetting.intValue(); - autoPublishEnable.setSelection(setting == Server.AUTO_PUBLISH_ENABLE); - autoPublishDisable.setSelection(setting == Server.AUTO_PUBLISH_DISABLE); - autoPublishTime.setEnabled(setting == Server.AUTO_PUBLISH_ENABLE); - validate(); - } else if (event.getPropertyName().equals(Server.PROP_START_TIMEOUT)) { - Integer time = (Integer)event.getNewValue(); - startTimeoutSpinner.setSelection(time.intValue()); - SWTUtil.setSpinnerTooltip(startTimeoutSpinner); - } else if (event.getPropertyName().equals(Server.PROP_STOP_TIMEOUT)) { - Integer time = (Integer)event.getNewValue(); - stopTimeoutSpinner.setSelection(time.intValue()); - SWTUtil.setSpinnerTooltip(stopTimeoutSpinner); - } else if (Server.PROP_PUBLISHERS.equals(event.getPropertyName())) { - if (publishersViewer == null) - return; - - List<String> list = (List<String>) event.getNewValue(); - Iterator<String> iter = list.iterator(); - while (iter.hasNext()) { - String id = iter.next(); - int ind = id.indexOf(":"); - boolean enabled = false; - if ("true".equals(id.substring(ind+1))) - enabled = true; - id = id.substring(0, ind); - Publisher pub = ServerPlugin.findPublisher(id); - if (pub != null) - publishersViewer.setChecked(pub, enabled); - } - } - updating = false; - } - }; - if (server != null) - server.addPropertyChangeListener(listener); - } - - protected void updateNames() { - if (serverName != null) - serverName.setText(server.getName()); - } - - /** - * Creates the SWT controls for this workbench part. - * - * @param parent the parent control - */ - public final void createPartControl(final Composite parent) { - managedForm = new ManagedForm(parent); - setManagedForm(managedForm); - ScrolledForm form = managedForm.getForm(); - FormToolkit toolkit = managedForm.getToolkit(); - toolkit.decorateFormHeading(form.getForm()); - form.setText(Messages.serverEditorOverviewPageTitle); - form.setImage(ImageResource.getImage(ImageResource.IMG_SERVER)); - form.getBody().setLayout(new GridLayout()); - - Composite columnComp = toolkit.createComposite(form.getBody()); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - //layout.marginHeight = 10; - //layout.marginWidth = 10; - layout.verticalSpacing = 0; - layout.horizontalSpacing = 10; - columnComp.setLayout(layout); - columnComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL)); - - // left column - Composite leftColumnComp = toolkit.createComposite(columnComp); - layout = new GridLayout(); - layout.marginHeight = 0; - layout.marginWidth = 0; - layout.verticalSpacing = 10; - layout.horizontalSpacing = 0; - leftColumnComp.setLayout(layout); - leftColumnComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL)); - - createGeneralSection(leftColumnComp, toolkit); - - insertSections(leftColumnComp, "org.eclipse.wst.server.editor.overview.left"); - - // right column - Composite rightColumnComp = toolkit.createComposite(columnComp); - layout = new GridLayout(); - layout.marginHeight = 0; - layout.marginWidth = 0; - layout.verticalSpacing = 10; - layout.horizontalSpacing = 0; - rightColumnComp.setLayout(layout); - rightColumnComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL)); - - createPublishSection(rightColumnComp, toolkit); - createTimeoutSection(rightColumnComp, toolkit); - - insertSections(rightColumnComp, "org.eclipse.wst.server.editor.overview.right"); - - form.reflow(true); - - initialize(); - } - - protected void createGeneralSection(Composite leftColumnComp, FormToolkit toolkit) { - Section section = toolkit.createSection(leftColumnComp, ExpandableComposite.TITLE_BAR | Section.DESCRIPTION); - section.setText(Messages.serverEditorOverviewGeneralSection); - section.setDescription(Messages.serverEditorOverviewGeneralDescription); - section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL)); - - Composite composite = toolkit.createComposite(section); - GridLayout layout = new GridLayout(); - layout.numColumns = 3; - layout.marginHeight = 5; - layout.marginWidth = 10; - layout.verticalSpacing = 5; - layout.horizontalSpacing = 5; - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL)); - IWorkbenchHelpSystem whs = PlatformUI.getWorkbench().getHelpSystem(); - whs.setHelp(composite, ContextIds.EDITOR_OVERVIEW_PAGE); - toolkit.paintBordersFor(composite); - section.setClient(composite); - - int decorationWidth = FieldDecorationRegistry.getDefault().getMaximumDecorationWidth(); - - // server name - if (server != null) { - createLabel(toolkit, composite, Messages.serverEditorOverviewServerName); - - serverName = toolkit.createText(composite, server.getName()); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 2; - data.horizontalIndent = decorationWidth; - serverName.setLayoutData(data); - serverName.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - if (updating) - return; - updating = true; - execute(new SetServerNameCommand(getServer(), serverName.getText())); - updating = false; - validate(); - } - }); - whs.setHelp(serverName, ContextIds.EDITOR_SERVER); - - // hostname - createLabel(toolkit, composite, Messages.serverEditorOverviewServerHostname); - - hostname = toolkit.createText(composite, server.getHost()); - final ControlDecoration hostnameDecoration = new ControlDecoration(hostname, SWT.TOP | SWT.LEAD); - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 2; - data.horizontalIndent = decorationWidth; - hostname.setLayoutData(data); - hostname.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - if (updating) - return; - updating = true; - execute(new SetServerHostnameCommand(getServer(), hostname.getText())); - updating = false; - } - }); - whs.setHelp(hostname, ContextIds.EDITOR_HOSTNAME); - - FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault(); - FieldDecoration fd = registry.getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL); - hostnameDecoration.setImage(fd.getImage()); - hostnameDecoration.setDescriptionText(fd.getDescription()); - hostnameDecoration.hide(); - - hostname.addFocusListener(new FocusListener() { - public void focusGained(FocusEvent e) { - hostnameDecoration.show(); - } - - public void focusLost(FocusEvent e) { - hostnameDecoration.hide(); - } - }); - - //updateDecoration(hostnameDecoration, new Status(IStatus.INFO, ServerUIPlugin.PLUGIN_ID, "Press Ctrl-Space")); - - List<String> hosts = ServerUIPlugin.getPreferences().getHostnames(); - String[] hosts2 = hosts.toArray(new String[hosts.size()]); - new AutoCompleteField(hostname, new TextContentAdapter(), hosts2); - } - - // runtime - if (server != null && server.getServerType() != null && server.getServerType().hasRuntime()) { - final Hyperlink link = toolkit.createHyperlink(composite, Messages.serverEditorOverviewRuntime, SWT.NONE); - link.addHyperlinkListener(new HyperlinkAdapter() { - public void linkActivated(HyperlinkEvent e) { - IRuntime runtime = server.getRuntime(); - if (runtime != null && ServerUIPlugin.hasWizardFragment(runtime.getRuntimeType().getId())) - editRuntime(runtime); - } - }); - - final IRuntime runtime = server.getRuntime(); - if (runtime == null || !ServerUIPlugin.hasWizardFragment(runtime.getRuntimeType().getId())) - link.setEnabled(false); - - IRuntimeType runtimeType = server.getServerType().getRuntimeType(); - runtimes = ServerUIPlugin.getRuntimes(runtimeType); - - runtimeCombo = new Combo(composite, SWT.READ_ONLY); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalIndent = decorationWidth; - data.horizontalSpan = 2; - runtimeCombo.setLayoutData(data); - updateRuntimeCombo(); - - int size = runtimes.length; - for (int i = 0; i < size; i++) { - if (runtimes[i].equals(runtime)) - runtimeCombo.select(i); - } - - runtimeCombo.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - try { - if (updating) - return; - updating = true; - IRuntime newRuntime = runtimes[runtimeCombo.getSelectionIndex()]; - execute(new SetServerRuntimeCommand(getServer(), newRuntime)); - link.setEnabled(newRuntime != null && !ServerUIPlugin.hasWizardFragment(newRuntime.getRuntimeType().getId())); - updating = false; - } catch (Exception ex) { - // ignore - } - } - public void widgetDefaultSelected(SelectionEvent e) { - widgetSelected(e); - } - }); - whs.setHelp(runtimeCombo, ContextIds.EDITOR_RUNTIME); - - // add runtime listener - runtimeListener = new IRuntimeLifecycleListener() { - public void runtimeChanged(final IRuntime runtime2) { - // may be name change of current runtime - Display.getDefault().syncExec(new Runnable() { - public void run() { - if (runtime2.equals(getServer().getRuntime())) { - try { - if (updating) - return; - updating = true; - execute(new SetServerRuntimeCommand(getServer(), runtime2)); - updating = false; - } catch (Exception ex) { - // ignore - } - } - - if (runtimeCombo != null && !runtimeCombo.isDisposed()) { - updateRuntimeCombo(); - - int size2 = runtimes.length; - for (int i = 0; i < size2; i++) { - if (runtimes[i].equals(runtime)) - runtimeCombo.select(i); - } - } - } - }); - } - - public void runtimeAdded(final IRuntime runtime2) { - Display.getDefault().syncExec(new Runnable() { - public void run() { - if (runtimeCombo != null && !runtimeCombo.isDisposed()) { - updateRuntimeCombo(); - - int size2 = runtimes.length; - for (int i = 0; i < size2; i++) { - if (runtimes[i].equals(runtime)) - runtimeCombo.select(i); - } - } - } - }); - } - - public void runtimeRemoved(IRuntime runtime2) { - Display.getDefault().syncExec(new Runnable() { - public void run() { - if (runtimeCombo != null && !runtimeCombo.isDisposed()) { - updateRuntimeCombo(); - - int size2 = runtimes.length; - for (int i = 0; i < size2; i++) { - if (runtimes[i].equals(runtime)) - runtimeCombo.select(i); - } - } - } - }); - } - }; - - ServerCore.addRuntimeLifecycleListener(runtimeListener); - } - - // server configuration path - if (server != null && server.getServerType() != null && server.getServerType().hasServerConfiguration()) { - createLabel(toolkit, composite, Messages.serverEditorOverviewServerConfigurationPath); - - IFolder folder = server.getServerConfiguration(); - if (folder == null) - serverConfiguration = toolkit.createText(composite, Messages.elementUnknownName); - else - serverConfiguration = toolkit.createText(composite, "" + server.getServerConfiguration().getFullPath()); - - serverConfiguration.setEditable(false); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalIndent = decorationWidth; - data.widthHint = 75; - serverConfiguration.setLayoutData(data); - - whs.setHelp(serverConfiguration, ContextIds.EDITOR_CONFIGURATION); - - final IFolder currentFolder = server.getServerConfiguration(); - browse = toolkit.createButton(composite, Messages.serverEditorOverviewServerConfigurationBrowse, SWT.PUSH); - browse.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - ContainerSelectionDialog dialog = new ContainerSelectionDialog(serverConfiguration.getShell(), - currentFolder, true, Messages.serverEditorOverviewServerConfigurationBrowseMessage); - dialog.showClosedProjects(false); - - if (dialog.open() != Window.CANCEL) { - Object[] result = dialog.getResult(); - if (result != null && result.length == 1) { - IPath path = (IPath) result[0]; - - IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - IResource resource = root.findMember(path); - if (resource != null && resource instanceof IFolder) { - IFolder folder2 = (IFolder) resource; - - if (updating) - return; - updating = true; - execute(new SetServerConfigurationFolderCommand(getServer(), folder2)); - serverConfiguration.setText(folder2.getFullPath().toString()); - updating = false; - } - } - } - } - }); - browse.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); - } - - if (server != null && server.getServerType() != null) { - IServerType serverType = server.getServerType(); - if (serverType.supportsLaunchMode(ILaunchManager.RUN_MODE) || serverType.supportsLaunchMode(ILaunchManager.DEBUG_MODE) - || serverType.supportsLaunchMode(ILaunchManager.PROFILE_MODE)) { - ILaunchConfigurationType launchType = ((ServerType) serverType).getLaunchConfigurationType(); - if (launchType != null && launchType.isPublic()) { - final Hyperlink link = toolkit.createHyperlink(composite, Messages.serverEditorOverviewOpenLaunchConfiguration, SWT.NONE); - GridData data = new GridData(); - data.horizontalSpan = 2; - link.setLayoutData(data); - link.addHyperlinkListener(new HyperlinkAdapter() { - public void linkActivated(HyperlinkEvent e) { - try { - ILaunchConfiguration launchConfig = ((Server) getServer()).getLaunchConfiguration(true, null); - // TODO: use correct launch group - DebugUITools.openLaunchConfigurationPropertiesDialog(link.getShell(), launchConfig, "org.eclipse.debug.ui.launchGroup.run"); - } catch (CoreException ce) { - Trace.trace(Trace.SEVERE, "Could not create launch configuration", ce); - } - } - }); - } - } - } - } - - protected void createPublishSection(Composite rightColumnComp, FormToolkit toolkit) { - Section section = toolkit.createSection(rightColumnComp, ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR | Section.DESCRIPTION | ExpandableComposite.FOCUS_TITLE); - section.setText(Messages.serverEditorOverviewPublishSection); - section.setDescription(Messages.serverEditorOverviewPublishDescription); - section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL)); - - Composite composite = toolkit.createComposite(section); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - layout.marginHeight = 5; - layout.marginWidth = 10; - layout.verticalSpacing = 5; - layout.horizontalSpacing = 15; - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL)); - IWorkbenchHelpSystem whs = PlatformUI.getWorkbench().getHelpSystem(); - whs.setHelp(composite, ContextIds.EDITOR_OVERVIEW_PAGE); - toolkit.paintBordersFor(composite); - section.setClient(composite); - - // auto-publish - if (server != null) { - final Server svr = (Server) server; - int publishSetting = svr.getAutoPublishSetting(); - - GridData data = new GridData(GridData.FILL_HORIZONTAL); - autoPublishDisable = toolkit.createButton(composite, Messages.serverEditorOverviewAutoPublishDisable, SWT.RADIO); - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 2; - autoPublishDisable.setLayoutData(data); - autoPublishDisable.setSelection(publishSetting == Server.AUTO_PUBLISH_DISABLE); - whs.setHelp(autoPublishDisable, ContextIds.EDITOR_AUTOPUBLISH_DISABLE); - - autoPublishEnable = toolkit.createButton(composite, Messages.serverEditorOverviewAutoPublishEnabled, SWT.RADIO); - autoPublishEnable.setSelection(publishSetting == Server.AUTO_PUBLISH_ENABLE); - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 2; - autoPublishEnable.setLayoutData(data); - whs.setHelp(autoPublishEnable, ContextIds.EDITOR_AUTOPUBLISH_ENABLE); - - final Label autoPublishTimeLabel = createLabel(toolkit,composite, Messages.serverEditorOverviewAutoPublishEnabledInterval); - data = new GridData(); - data.horizontalIndent = 20; - autoPublishTimeLabel.setLayoutData(data); - autoPublishTimeLabel.setEnabled(autoPublishEnable.getSelection()); - - autoPublishTime = new Spinner(composite, SWT.BORDER); - autoPublishTime.setMinimum(0); - autoPublishTime.setIncrement(5); - autoPublishTime.setMaximum(120); - autoPublishTime.setSelection(svr.getAutoPublishTime()); - data = new GridData(GridData.HORIZONTAL_ALIGN_END); - data.widthHint = 30; - autoPublishTime.setLayoutData(data); - autoPublishTime.setEnabled(autoPublishEnable.getSelection()); - SWTUtil.setSpinnerTooltip(autoPublishTime); - whs.setHelp(autoPublishTime, ContextIds.EDITOR_AUTOPUBLISH_ENABLE); - - autoPublishEnable.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - if (updating || !autoPublishEnable.getSelection()) - return; - updating = true; - execute(new SetServerAutoPublishDefaultCommand(getServer(), Server.AUTO_PUBLISH_ENABLE)); - updating = false; - autoPublishTimeLabel.setEnabled(autoPublishEnable.getSelection()); - autoPublishTime.setEnabled(autoPublishEnable.getSelection()); - validate(); - } - }); - - autoPublishDisable.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - if (updating || !autoPublishDisable.getSelection()) - return; - updating = true; - execute(new SetServerAutoPublishDefaultCommand(getServer(), Server.AUTO_PUBLISH_DISABLE)); - updating = false; - autoPublishTimeLabel.setEnabled(autoPublishEnable.getSelection()); - autoPublishTime.setEnabled(autoPublishEnable.getSelection()); - validate(); - } - }); - - autoPublishTime.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - if (updating) - return; - updating = true; - execute(new SetServerAutoPublishTimeCommand(getServer(), autoPublishTime.getSelection())); - SWTUtil.setSpinnerTooltip(autoPublishTime); - updating = false; - validate(); - } - }); - - // publishers - Publisher[] pubs = ((Server)server).getAllPublishers(); - if (pubs != null && pubs.length > 0) { - Label label = toolkit.createLabel(composite, Messages.serverEditorOverviewPublishers); - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 2; - label.setLayoutData(data); - - publishersTable = toolkit.createTable(composite, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.CHECK); - publishersTable.setHeaderVisible(false); - publishersTable.setLinesVisible(false); - whs.setHelp(publishersTable, ContextIds.EDITOR_PUBLISHTASKS_CONFIGURATION); - - data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL); - data.horizontalSpan = 2; - data.heightHint = 80; - publishersTable.setLayoutData(data); - - publishersViewer = new CheckboxTableViewer(publishersTable); - publishersViewer.setColumnProperties(new String[] {"name"}); - publishersViewer.setContentProvider(new PublisherContentProvider(pubs)); - publishersViewer.setLabelProvider(new PublishLabelProvider()); - publishersViewer.setInput("root"); - - Publisher[] pubs2 = ((Server)server).getEnabledPublishers(); - for (Publisher p : pubs2) - publishersViewer.setChecked(p, true); - - publishersViewer.addCheckStateListener(new ICheckStateListener() { - public void checkStateChanged(CheckStateChangedEvent event) { - Object element = event.getElement(); - if (element == null || !(element instanceof Publisher)) - return; - if (updating) - return; - updating = true; - execute(new SetPublisherEnablementCommand(getServer(), (Publisher) element, event.getChecked())); - updating = false; - } - }); - } - } - } - - protected void createTimeoutSection(Composite rightColumnComp, FormToolkit toolkit) { - Section section = toolkit.createSection(rightColumnComp, ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR | Section.DESCRIPTION | ExpandableComposite.FOCUS_TITLE); - section.setText(Messages.serverEditorOverviewTimeoutSection); - section.setDescription(Messages.serverEditorOverviewTimeoutDescription); - section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL)); - - Composite composite = toolkit.createComposite(section); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - layout.marginHeight = 5; - layout.marginWidth = 10; - layout.verticalSpacing = 5; - layout.horizontalSpacing = 15; - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL)); - IWorkbenchHelpSystem whs = PlatformUI.getWorkbench().getHelpSystem(); - whs.setHelp(composite, ContextIds.EDITOR_OVERVIEW_PAGE); - toolkit.paintBordersFor(composite); - section.setClient(composite); - - // timeouts - if (server != null) { - final Server svr = (Server) server; - - // start timeout label - final Label startTimeoutLabel = createLabel(toolkit, composite, Messages.serverEditorOverviewStartTimeout); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalIndent = 20; - startTimeoutLabel.setLayoutData(data); - - startTimeoutSpinner = new Spinner(composite, SWT.BORDER); - startTimeoutSpinner.setEnabled(true); - startTimeoutSpinner.setMinimum(1); - startTimeoutSpinner.setMaximum(60*60*24); // 24 hours - startTimeoutSpinner.setIncrement(5); - startTimeoutSpinner.setSelection(svr.getStartTimeout()); - SWTUtil.setSpinnerTooltip(startTimeoutSpinner); - data = new GridData(GridData.HORIZONTAL_ALIGN_END); - data.widthHint = 30; - startTimeoutSpinner.setLayoutData(data); - whs.setHelp(startTimeoutSpinner, ContextIds.EDITOR_TIMEOUT_START); - - // stop timeout label - final Label stopTimeoutLabel = createLabel(toolkit, composite, Messages.serverEditorOverviewStopTimeout); - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalIndent = 20; - stopTimeoutLabel.setLayoutData(data); - - stopTimeoutSpinner = new Spinner(composite, SWT.BORDER); - stopTimeoutSpinner.setEnabled(true); - stopTimeoutSpinner.setMinimum(1); - stopTimeoutSpinner.setMaximum(60*60*24); // 24 hours - stopTimeoutSpinner.setIncrement(5); - stopTimeoutSpinner.setSelection(svr.getStopTimeout()); - SWTUtil.setSpinnerTooltip(stopTimeoutSpinner); - data = new GridData(GridData.HORIZONTAL_ALIGN_END); - data.widthHint = 30; - stopTimeoutSpinner.setLayoutData(data); - whs.setHelp(stopTimeoutSpinner, ContextIds.EDITOR_TIMEOUT_STOP); - - startTimeoutSpinner.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - if (updating) - return; - updating = true; - execute(new SetServerStartTimeoutCommand(getServer(), startTimeoutSpinner.getSelection())); - SWTUtil.setSpinnerTooltip(startTimeoutSpinner); - updating = false; - validate(); - } - }); - stopTimeoutSpinner.addModifyListener(new ModifyListener(){ - public void modifyText(ModifyEvent e) { - if (updating) - return; - updating = true; - execute(new SetServerStopTimeoutCommand(getServer(), stopTimeoutSpinner.getSelection())); - SWTUtil.setSpinnerTooltip(stopTimeoutSpinner); - updating = false; - validate(); - } - }); - } - } - - protected void editRuntime(IRuntime runtime) { - IRuntimeWorkingCopy runtimeWorkingCopy = runtime.createWorkingCopy(); - if (showWizard(runtimeWorkingCopy) != Window.CANCEL) { - try { - runtimeWorkingCopy.save(false, null); - } catch (Exception ex) { - // ignore - } - } - } - - protected int showWizard(final IRuntimeWorkingCopy runtimeWorkingCopy) { - String title = Messages.wizEditRuntimeWizardTitle; - final WizardFragment fragment2 = ServerUIPlugin.getWizardFragment(runtimeWorkingCopy.getRuntimeType().getId()); - if (fragment2 == null) - return Window.CANCEL; - - TaskModel taskModel = new TaskModel(); - taskModel.putObject(TaskModel.TASK_RUNTIME, runtimeWorkingCopy); - - WizardFragment fragment = new WizardFragment() { - protected void createChildFragments(List<WizardFragment> list) { - list.add(fragment2); - list.add(WizardTaskUtil.SaveRuntimeFragment); - } - }; - - TaskWizard wizard = new TaskWizard(title, fragment, taskModel); - wizard.setForcePreviousAndNextButtons(true); - WizardDialog dialog = new WizardDialog(getEditorSite().getShell(), wizard); - return dialog.open(); - } - - protected void updateRuntimeCombo() { - IRuntimeType runtimeType = server.getServerType().getRuntimeType(); - runtimes = ServerUIPlugin.getRuntimes(runtimeType); - - if (SocketUtil.isLocalhost(server.getHost()) && runtimes != null) { - List<IRuntime> runtimes2 = new ArrayList<IRuntime>(); - int size = runtimes.length; - for (int i = 0; i < size; i++) { - IRuntime runtime2 = runtimes[i]; - if (!runtime2.isStub()) - runtimes2.add(runtime2); - } - runtimes = new IRuntime[runtimes2.size()]; - runtimes2.toArray(runtimes); - } - - int size = runtimes.length; - String[] items = new String[size]; - for (int i = 0; i < size; i++) - items[i] = runtimes[i].getName(); - - runtimeCombo.setItems(items); - } - - protected Label createLabel(FormToolkit toolkit, Composite parent, String text) { - Label label = toolkit.createLabel(parent, text); - label.setForeground(toolkit.getColors().getColor(IFormColors.TITLE)); - return label; - } - - public void dispose() { - super.dispose(); - - if (server != null) - server.removePropertyChangeListener(listener); - - if (runtimeListener != null) - ServerCore.removeRuntimeLifecycleListener(runtimeListener); - - if (managedForm != null) { - managedForm.dispose(); - managedForm = null; - } - } - - /* (non-Javadoc) - * Initializes the editor part with a site and input. - */ - public void init(IEditorSite site, IEditorInput input) { - super.init(site, input); - - addChangeListener(); - initialize(); - } - - /** - * Initialize the fields in this editor. - */ - protected void initialize() { - if (serverName == null) - return; - updating = true; - - if (server != null) { - serverName.setText(server.getName()); - if (readOnly) - serverName.setEditable(false); - else - serverName.setEditable(true); - - hostname.setText(server.getHost()); - if (readOnly) - hostname.setEditable(false); - else - hostname.setEditable(true); - - if (runtimeCombo != null) { - updateRuntimeCombo(); - IRuntime runtime = server.getRuntime(); - int size2 = runtimes.length; - for (int i = 0; i < size2; i++) { - if (runtimes[i].equals(runtime)) - runtimeCombo.select(i); - } - if (readOnly) - runtimeCombo.setEnabled(false); - else - runtimeCombo.setEnabled(true); - } - - if (serverConfiguration != null) { - IFolder folder = server.getServerConfiguration(); - if (folder == null) - serverConfiguration.setText(Messages.elementUnknownName); - else - serverConfiguration.setText("" + server.getServerConfiguration().getFullPath()); - if (readOnly) { - serverConfiguration.setEditable(false); - browse.setEnabled(false); - } else { - serverConfiguration.setEditable(true); - browse.setEnabled(true); - } - } - - Server svr = (Server) server; - int publishSetting = svr.getAutoPublishSetting(); - autoPublishDisable.setSelection(publishSetting == Server.AUTO_PUBLISH_DISABLE); - autoPublishEnable.setSelection(publishSetting == Server.AUTO_PUBLISH_ENABLE); - autoPublishTime.setSelection(svr.getAutoPublishTime()); - - if (readOnly) { - autoPublishDisable.setEnabled(false); - autoPublishEnable.setEnabled(false); - autoPublishTime.setEnabled(false); - } else { - autoPublishDisable.setEnabled(true); - autoPublishEnable.setEnabled(true); - autoPublishTime.setEnabled(publishSetting == Server.AUTO_PUBLISH_ENABLE); - } - } - - updating = false; - validate(); - } - - protected void validate() { - IManagedForm mForm = getManagedForm(); - if (mForm == null) - return; - - mForm.getMessageManager().removeMessage("name", serverName); - if (server != null && serverName != null) { - if (ServerPlugin.isNameInUse(server, serverName.getText().trim())) - mForm.getMessageManager().addMessage("name", Messages.errorDuplicateName, null, IMessageProvider.ERROR, serverName); - } - - if (serverConfiguration != null) { - mForm.getMessageManager().removeMessage("config", serverConfiguration); - if (server != null && server.getServerType() != null && server.getServerType().hasServerConfiguration()) { - IFolder folder = getServer().getServerConfiguration(); - - if (folder == null || !folder.exists()) { - IProject project = null; - if (folder != null) - project = folder.getProject(); - if (project != null && project.exists() && !project.isOpen()) - mForm.getMessageManager().addMessage("config", NLS.bind(Messages.errorConfigurationNotAccessible, project.getName()), null, IMessageProvider.ERROR, serverConfiguration); - else - mForm.getMessageManager().addMessage("config", Messages.errorMissingConfiguration, null, IMessageProvider.ERROR, serverConfiguration); - } - } - } - - mForm.getMessageManager().update(); - } - - protected void updateDecoration(ControlDecoration decoration, IStatus status) { - if (status != null) { - Image newImage = null; - FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault(); - switch (status.getSeverity()) { - case IStatus.INFO: - //newImage = registry.getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage(); - newImage = registry.getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED).getImage(); - break; - case IStatus.WARNING: - newImage = registry.getFieldDecoration(FieldDecorationRegistry.DEC_WARNING).getImage(); - break; - case IStatus.ERROR: - newImage = registry.getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage(); - } - decoration.setDescriptionText(status.getMessage()); - decoration.setImage(newImage); - decoration.show(); - } else { - decoration.setDescriptionText(null); - decoration.hide(); - } - } - - /* - * @see IWorkbenchPart#setFocus() - */ - public void setFocus() { - if (serverName != null) - serverName.setFocus(); - else if (serverConfiguration != null) - serverConfiguration.setFocus(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditor.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditor.java deleted file mode 100644 index 6d6a8cd83..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditor.java +++ /dev/null @@ -1,980 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.editor; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.util.*; -import java.util.List; - -import org.eclipse.core.commands.operations.IUndoableOperation; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.runtime.*; -import org.eclipse.jface.action.*; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.window.Window; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.events.*; -import org.eclipse.swt.widgets.*; -import org.eclipse.ui.*; -import org.eclipse.ui.part.MultiPageEditorPart; - -import org.eclipse.wst.server.core.*; -import org.eclipse.wst.server.core.internal.Server; -import org.eclipse.wst.server.core.internal.ServerWorkingCopy; -import org.eclipse.wst.server.ui.ServerUICore; -import org.eclipse.wst.server.ui.editor.*; -import org.eclipse.wst.server.ui.internal.*; -/** - * A multi-page server resource editor. - */ -public class ServerEditor extends MultiPageEditorPart { - /** - * Internal part and shell activation listener - */ - class ActivationListener extends ShellAdapter implements IPartListener { - private IWorkbenchPart fActivePart; - private boolean fIsHandlingActivation = false; - - public void partActivated(IWorkbenchPart part) { - fActivePart = part; - handleActivation(); - } - - public void partBroughtToTop(IWorkbenchPart part) { - // do nothing - } - - public void partClosed(IWorkbenchPart part) { - // do nothing - } - - public void partDeactivated(IWorkbenchPart part) { - fActivePart = null; - } - - public void partOpened(IWorkbenchPart part) { - // do nothing - } - - public void shellActivated(ShellEvent e) { - handleActivation(); - } - - private void handleActivation() { - if (fIsHandlingActivation) - return; - - if (fActivePart == ServerEditor.this) { - fIsHandlingActivation = true; - try { - checkResourceState(); - } finally { - fIsHandlingActivation = false; - } - } - } - } - - class LifecycleListener implements IServerLifecycleListener { - public void serverAdded(IServer oldServer) { - // do nothing - } - public void serverChanged(IServer oldServer) { - // do nothing - } - public void serverRemoved(IServer oldServer) { - if (oldServer.equals(server) && !isDirty()) - closeEditor(); - } - } - - protected IServerWorkingCopy server; - protected String serverId; - protected String serverName; - - protected GlobalCommandManager commandManager; - - protected PropertyChangeListener listener; - - protected IAction undoAction; - protected IAction redoAction; - - protected TextAction cutAction; - protected TextAction copyAction; - protected TextAction pasteAction; - protected boolean updatingActions; - - protected IAction[] editorActions; - - protected java.util.List<IEditorPart> serverPages; - - // on focus change flag - protected boolean resourceDeleted; - - // input given to the contained pages - protected IServerEditorPartInput editorPartInput; - - // status line and status - protected IStatusLineManager status; - protected StatusLineContributionItem statusItem; - - private ActivationListener activationListener = new ActivationListener(); - protected LifecycleListener resourceListener; - - // used for disabling resource change check when saving through editor - protected boolean isSaving = false; - - protected Map<IEditorPart, IServerEditorPartFactory> pageToFactory = new HashMap<IEditorPart, IServerEditorPartFactory>(); - - /** - * ServerEditor constructor comment. - */ - public ServerEditor() { - super(); - - ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages(); - - undoAction = new Action() { - public void run() { - getCommandManager().undo(serverId); - } - }; - undoAction.setEnabled(false); - undoAction.setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_UNDO)); - //undoAction.setHoverImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_UNDO_HOVER)); - //undoAction.setDisabledImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_UNDO_DISABLED)); - - redoAction = new Action() { - public void run() { - getCommandManager().redo(serverId); - } - }; - redoAction.setEnabled(false); - redoAction.setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_REDO)); - //redoAction.setHoverImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_REDO_HOVER)); - //redoAction.setDisabledImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_REDO_DISABLED)); - } - - /** - * Close the editor correctly. - */ - protected void closeEditor() { - Display.getDefault().asyncExec(new Runnable() { - public void run() { - getEditorSite().getPage().closeEditor(ServerEditor.this, false); - } - }); - } - - protected void createActions() { - List<IAction> actionList = new ArrayList<IAction>(); - - // add server actions - if (server != null && server.getServerType() != null) { - Iterator iterator = ServerEditorCore.getServerEditorActionFactories().iterator(); - String id = server.getServerType().getId(); - while (iterator.hasNext()) { - ServerEditorActionFactory factory = (ServerEditorActionFactory) iterator.next(); - if (factory.supportsServerElementType(id) && factory.shouldDisplay(server)) - actionList.add(factory.createAction(getEditorSite(), editorPartInput)); - } - } - - editorActions = new IAction[actionList.size()]; - actionList.toArray(editorActions); - } - - public IServerEditorPartFactory getPageFactory(ServerEditorPart part) { - try { - return pageToFactory.get(part); - } catch (Exception e) { - // ignore - } - return null; - } - - /** - * Creates the pages of this multi-page editor. - * <p> - * Subclasses of <code>MultiPageEditor</code> must implement this method. - * </p> - */ - protected void createPages() { - try { - int index = 0; - serverPages = new ArrayList<IEditorPart>(); - - // add editor pages - int pageCount = 0; - - String serverTypeId = null; - if (server != null && server.getServerType() != null) - serverTypeId = server.getServerType().getId(); - - Iterator iterator = ServerEditorCore.getServerEditorPageFactories().iterator(); - while (iterator.hasNext()) { - IServerEditorPartFactory factory = (IServerEditorPartFactory) iterator.next(); - if (factory.supportsType(serverTypeId) && factory.shouldCreatePage(server)) { - Trace.trace(Trace.FINEST, "Adding page: " + factory.getId() + " " + editorPartInput); - try { - IEditorPart page = factory.createPage(); - if (page != null) { - pageToFactory.put(page, factory); - index = addPage(page, editorPartInput); - setPageText(index, factory.getName()); - - serverPages.add(page); - - pageCount ++; - } - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Could not display editor page " + factory.getId(), e); - } - } - } - - if (pageCount > 0) - setActivePage(0); - - // register for events that might change the cut/copy/paste actions - int count = getPageCount(); - for (int i = 0; i < count; i++) { - Control control = getControl(i); - registerEvents(control); - } - updateActions(); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error creating server editor pages", e); - } - } - - public void dispose() { - if (activationListener != null) { - IWorkbenchWindow window = getSite().getWorkbenchWindow(); - window.getPartService().removePartListener(activationListener); - Shell shell = window.getShell(); - if (shell != null && !shell.isDisposed()) - shell.removeShellListener(activationListener); - activationListener = null; - } - - if (resourceListener != null) - ServerCore.removeServerLifecycleListener(resourceListener); - - if (serverName != null && !server.getName().equals(serverName)) { - // only prompt if the server is in the workspace or there is a configuration - if (server.getServerConfiguration() != null || ((Server)server).getFile() != null) { - String title = Messages.editorServerEditor; - String message = Messages.editorRenameFiles; - if (MessageDialog.openQuestion(getEditorSite().getShell(), title, message)) - try { - ((ServerWorkingCopy)server).renameFiles(null); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error renaming server", e); - } - } - } - - super.dispose(); - if (commandManager != null) { - commandManager.removePropertyChangeListener(listener); - - if (serverId != null) - commandManager.releaseCommandManager(serverId); - - commandManager = null; - } - } - - /* (non-Javadoc) - * Saves the contents of this editor. - * <p> - * Subclasses must override this method to implement the open-save-close lifecycle - * for an editor. For greater details, see <code>IEditorPart</code> - * </p> - * - * @see IEditorPart - */ - public void doSave(IProgressMonitor monitor) { - // set the isSaving flag to true - isSaving = true; - - // check pages for errors first - java.util.List<String> errors = new ArrayList<String>(); - Iterator iterator = serverPages.iterator(); - int count = 0; - int maxSeverity = -1; - while (iterator.hasNext()) { - IEditorPart part = (IEditorPart) iterator.next(); - if (part instanceof ServerEditorPart) { - IStatus[] status2 = ((ServerEditorPart) part).getSaveStatus(); - if (status2 != null) { - int size = status2.length; - for (int i = 0; i < size; i++) { - errors.add("[" + getPageText(count) + "] " + status2[i].getMessage()); - maxSeverity = Math.max(maxSeverity, status2[i].getSeverity()); - } - } - } - count ++; - } - if (!errors.isEmpty() && maxSeverity > IStatus.OK) { - StringBuffer sb = new StringBuffer(); - sb.append(Messages.errorEditorCantSave + "\n"); - iterator = errors.iterator(); - while (iterator.hasNext()) - sb.append("\t" + ((String) iterator.next()) + "\n"); - - if (maxSeverity == IStatus.ERROR) { - MessageDialog.openError(getEditorSite().getShell(), getPartName(), sb.toString()); - monitor.setCanceled(true); - // reset the isSaving flag - isSaving = false; - return; - } else if (maxSeverity == IStatus.WARNING) - MessageDialog.openWarning(getEditorSite().getShell(), getPartName(), sb.toString()); - else // if (maxSeverity == IStatus.INFO) - MessageDialog.openInformation(getEditorSite().getShell(), getPartName(), sb.toString()); - } - - try { - monitor = ProgressUtil.getMonitorFor(monitor); - int ticks = 2000; - String name = ""; - if (server != null) - name = server.getName(); - monitor.beginTask(NLS.bind(Messages.savingTask, name), ticks); - if (server != null) - ticks /= 2; - - if (server != null) { - server.save(false, ProgressUtil.getSubMonitorFor(monitor, ticks)); - getCommandManager().resourceSaved(serverId); - commandManager.updateTimestamps(serverId); - } - - ILabelProvider labelProvider = ServerUICore.getLabelProvider(); - if (server != null) - setPartName(labelProvider.getText(server)); - labelProvider.dispose(); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error saving server editor", e); - - monitor.setCanceled(true); - - String title = Messages.editorSaveErrorDialog; - String message = NLS.bind(Messages.editorSaveErrorMessage, e.getLocalizedMessage()); - MessageDialog.openError(getEditorSite().getShell(), title, message); - } finally { - monitor.done(); - } - // reset the isSaving flag - isSaving = false; - } - - /* (non-Javadoc) - * Saves the contents of this editor to another object. - * <p> - * Subclasses must override this method to implement the open-save-close lifecycle - * for an editor. For greater details, see <code>IEditorPart</code> - * </p> - * - * @see IEditorPart - */ - public void doSaveAs() { - // do nothing - } - - /** - * Fire a property change event. - * - * @param i a property change value - */ - protected void firePropertyChange(int i) { - if (i == ServerEditorPart.PROP_ERROR) - updateStatusError(); - super.firePropertyChange(i); - } - - /** - * Return the global command manager. - * - * @return the global command manager - */ - public GlobalCommandManager getCommandManager() { - return commandManager; - } - - /** - * Return the redo action. - * - * @return org.eclipse.jface.action.Action - */ - public IAction getRedoAction() { - return redoAction; - } - - /** - * Return the undo action. - * - * @return org.eclipse.jface.action.Action - */ - public IAction getUndoAction() { - return undoAction; - } - - /* (non-Javadoc) - * Sets the cursor and selection state for this editor to the passage defined - * by the given marker. - * <p> - * Subclasses may override. For greater details, see <code>IEditorPart</code> - * </p> - * - * @see IEditorPart - */ - public void gotoMarker(IMarker marker) { - // do nothing - } - - /** - * Update the cut, copy, and paste actions. - */ - public void updateActionsImpl() { - if (updatingActions) - return; - - updatingActions = true; - Display.getDefault().asyncExec(new Runnable() { - public void run() { - updatingActions = false; - updateActions(); - } - }); - } - - /** - * Update the cut, copy, and paste actions. - */ - public void updateActions() { - cutAction.update(); - copyAction.update(); - pasteAction.update(); - } - - /** - * Update the cut, copy, and paste actions. - */ - protected void updateStatusLine() { - if (statusItem != null) { - boolean readOnly = false; - if (server != null && commandManager.isReadOnly(serverId)) - readOnly = true; - - if (readOnly) - statusItem.setText(Messages.editorReadOnly); - else - statusItem.setText(Messages.editorWritable); - } - - if (status != null) { - StringBuffer sb = new StringBuffer(); - boolean first = true; - if (server != null) { - IFile[] files = commandManager.getReadOnlyFiles(serverId); - for (int i = 0; i < files.length; i++) { - if (!first) - sb.append(", "); - sb.append(files[i].getName()); - first = false; - } - } - /*if (serverConfiguration != null) { - IFile[] files = commandManager.getReadOnlyFiles(serverConfigurationId); - for (int i = 0; i < files.length; i++) { - if (!first) - sb.append(", "); - sb.append(files[i].getName()); - first = false; - } - }*/ - if (sb.length() > 1) - status.setMessage(NLS.bind(Messages.editorReadOnlyFiles, sb.toString())); - else - status.setMessage(""); - } - } - - /** - * - */ - public void updateStatusError() { - if (status == null) - return; - - String error = null; - IEditorPart part = getActiveEditor(); - if (part instanceof ServerEditorPart) - error = ((ServerEditorPart) part).getErrorMessage(); - - Iterator iterator = serverPages.iterator(); - int count = 0; - while (error == null && iterator.hasNext()) { - part = (IEditorPart) iterator.next(); - if (part instanceof ServerEditorPart) { - error = ((ServerEditorPart) part).getErrorMessage(); - if (error != null) - error = "[" + getPageText(count) + "] " + error; - } - count ++; - } - status.setErrorMessage(error); - } - - /** - * - */ - protected void pageChange(int newPageIndex) { - super.pageChange(newPageIndex); - updateStatusError(); - } - - /** - * Set the status. - * - * @param status a status line manager - * @param item a status contribution item - */ - public void setStatus(IStatusLineManager status, StatusLineContributionItem item) { - this.status = status; - this.statusItem = item; - updateStatusError(); - } - - /** - * Register for key and traversal events to enable/disable the cut/copy/paste actions. - */ - protected void registerEvents(Control control) { - if (control == null) - return; - - if (control instanceof Text || control instanceof Combo) { - // register the world... any of these actions could cause the state to change - control.addTraverseListener(new TraverseListener() { - public void keyTraversed(TraverseEvent event) { - updateActionsImpl(); - } - }); - control.addKeyListener(new KeyListener() { - public void keyPressed(KeyEvent event) { - updateActionsImpl(); - } - public void keyReleased(KeyEvent event) { - updateActionsImpl(); - } - }); - control.addMouseListener(new MouseListener() { - public void mouseDown(MouseEvent event) { - // do nothing - } - public void mouseUp(MouseEvent event) { - updateActionsImpl(); - } - public void mouseDoubleClick(MouseEvent event) { - updateActionsImpl(); - } - }); - control.addFocusListener(new FocusListener() { - public void focusGained(FocusEvent event) { - updateActionsImpl(); - } - public void focusLost(FocusEvent event) { - updateActionsImpl(); - } - }); - if (control instanceof Text) { - Text text = (Text) control; - text.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent event) { - updateActionsImpl(); - } - }); - text.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent event) { - updateActionsImpl(); - } - public void widgetDefaultSelected(SelectionEvent event) { - updateActionsImpl(); - } - }); - } else { - Combo combo = (Combo) control; - combo.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent event) { - updateActionsImpl(); - } - }); - combo.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent event) { - updateActionsImpl(); - } - public void widgetDefaultSelected(SelectionEvent event) { - updateActionsImpl(); - } - }); - } - } - - if (control instanceof Composite) { - Control[] children = ((Composite)control).getChildren(); - if (children != null) { - int size = children.length; - for (int i = 0; i < size; i++) - registerEvents(children[i]); - } - } - } - - /* (non-Javadoc) - * Initializes the editor part with a site and input. - * <p> - * Subclasses of <code>EditorPart</code> must implement this method. Within - * the implementation subclasses should verify that the input type is acceptable - * and then save the site and input. Here is sample code: - * </p> - * <pre> - * if (!(input instanceof IFileEditorInput)) - * throw new PartInitException("Invalid Input: Must be IFileEditorInput"); - * setSite(site); - * setInput(editorInput); - * </pre> - */ - public void init(IEditorSite site, IEditorInput input) throws PartInitException { - commandManager = GlobalCommandManager.getInstance(); - super.init(site, input); - - if (input instanceof IFileEditorInput) { - IFileEditorInput fei = (IFileEditorInput) input; - IFile file = fei.getFile(); - if (file != null && file.exists()) { - IServer server2 = ServerUIPlugin.findServer(file); - if (server2 != null) - serverId = server2.getId(); - } - if (serverId == null) { - if (file == null) - throw new PartInitException(NLS.bind(Messages.errorEditor, Messages.elementUnknownName)); - throw new PartInitException(NLS.bind(Messages.errorEditor, file.getName())); - } - } else if (input instanceof IServerEditorInput) { - IServerEditorInput sei = (IServerEditorInput) input; - serverId = sei.getServerId(); - } - - if (serverId != null) { - commandManager.getCommandManager(serverId); - server = commandManager.getServerResource(serverId); - } - - ILabelProvider labelProvider = ServerUICore.getLabelProvider(); - if (server != null) { - setPartName(labelProvider.getText(server)); - setTitleImage(labelProvider.getImage(server)); - setTitleToolTip(serverId); - serverName = server.getName(); - } else - setPartName("-"); - labelProvider.dispose(); - labelProvider = null; - - cutAction = new TextAction(site.getShell().getDisplay(), TextAction.CUT_ACTION); - copyAction = new TextAction(site.getShell().getDisplay(), TextAction.COPY_ACTION); - pasteAction = new TextAction(site.getShell().getDisplay(), TextAction.PASTE_ACTION); - - listener = new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - if (GlobalCommandManager.PROP_DIRTY.equals(event.getPropertyName())) { - Object obj = event.getOldValue(); - if (obj == serverId) - firePropertyChange(PROP_DIRTY); - } else if (GlobalCommandManager.PROP_UNDO.equals(event.getPropertyName())) { - Object obj = event.getOldValue(); - if (obj == serverId) - updateUndoAction(); - } else if (GlobalCommandManager.PROP_REDO.equals(event.getPropertyName())) { - Object obj = event.getOldValue(); - if (obj == serverId) - updateRedoAction(); - } else if (GlobalCommandManager.PROP_RELOAD.equals(event.getPropertyName())) { - Object obj = event.getOldValue(); - if (obj == serverId) { - server = commandManager.getServerResource(serverId); - refresh(); - } - } - } - }; - if (server != null && commandManager.isDirty(serverId)) - firePropertyChange(PROP_DIRTY); - - commandManager.addPropertyChangeListener(listener); - - // create editor input - ServerResourceCommandManager serverCommandManager = null; - if (server != null) - serverCommandManager = new ServerResourceCommandManager(this, serverId, commandManager); - editorPartInput = commandManager.getPartInput(serverId, serverCommandManager); - - createActions(); - - // add resource listener - resourceListener = new LifecycleListener(); - ServerCore.addServerLifecycleListener(resourceListener); - - IWorkbenchWindow window = getSite().getWorkbenchWindow(); - window.getPartService().addPartListener(activationListener); - window.getShell().addShellListener(activationListener); - } - - /* (non-Javadoc) - * Returns whether the contents of this editor have changed since the last save - * operation. - * <p> - * Subclasses must override this method to implement the open-save-close lifecycle - * for an editor. For greater details, see <code>IEditorPart</code> - * </p> - * - * @see IEditorPart - */ - public boolean isDirty() { - if (commandManager != null) { - if (server != null && commandManager.isDirty(serverId)) - return true; - } - return false; - } - - /* (non-Javadoc) - * Returns whether the "save as" operation is supported by this editor. - * <p> - * Subclasses must override this method to implement the open-save-close lifecycle - * for an editor. For greater details, see <code>IEditorPart</code> - * </p> - * - * @see IEditorPart - */ - public boolean isSaveAsAllowed() { - return false; - } - - /** - * Update the undo action. - */ - protected void updateUndoAction() { - IUndoableOperation command = commandManager.getUndoCommand(serverId); - if (command == null) { - undoAction.setText(Messages.editorUndoDisabled); - undoAction.setToolTipText(""); - undoAction.setDescription(""); - undoAction.setEnabled(false); - } else { - String text = NLS.bind(Messages.editorUndoEnabled, new Object[] {command.getLabel()}); - undoAction.setText(text); - undoAction.setToolTipText(command.getLabel()); - undoAction.setDescription(command.getLabel()); - undoAction.setEnabled(true); - } - } - - /** - * Update the redo action. - */ - protected void updateRedoAction() { - IUndoableOperation command = commandManager.getRedoCommand(serverId); - if (command == null) { - redoAction.setText(Messages.editorRedoDisabled); - redoAction.setToolTipText(""); - redoAction.setDescription(""); - redoAction.setEnabled(false); - } else { - String text = NLS.bind(Messages.editorRedoEnabled, new Object[] {command.getLabel()}); - redoAction.setText(text); - redoAction.setToolTipText(command.getLabel()); - redoAction.setDescription(command.getLabel()); - redoAction.setEnabled(true); - } - } - - /** - * Return the cut action. - * - * @return org.eclipse.jface.action.IAction - */ - public IAction getCutAction() { - return cutAction; - } - - /** - * Return the copy action. - * - * @return org.eclipse.jface.action.IAction - */ - public IAction getCopyAction() { - return copyAction; - } - - /** - * Return the paste action. - * - * @return org.eclipse.jface.action.IAction - */ - public IAction getPasteAction() { - return pasteAction; - } - - /** - * Returns the editor actions. - * - * @return org.eclipse.jface.action.IAction - */ - public IAction[] getEditorActions() { - return editorActions; - } - - /** - * Update the server pages with new input. - */ - protected void refresh() { - // create editor input - ServerResourceCommandManager serverCommandManager = null; - if (server != null) - serverCommandManager = new ServerResourceCommandManager(this, serverId, commandManager); - editorPartInput = commandManager.getPartInput(serverId, serverCommandManager); - - Iterator iterator = serverPages.iterator(); - while (iterator.hasNext()) { - IEditorPart part = (IEditorPart) iterator.next(); - try { - part.init(part.getEditorSite(), editorPartInput); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error refresh()ing editor part", e); - } - } - } - - /** - * - */ - protected void promptReadOnlyServerFile(String id) { - commandManager.setReadOnly(id, true); - String title = Messages.editorResourceModifiedTitle; - String message = Messages.editorReadOnlyMessage; - MessageDialog.openInformation(getEditorSite().getShell(), title, message); - } - - /** - * - */ - protected void promptReloadServerFile(String id) { - String title = Messages.editorResourceModifiedTitle; - String message = Messages.editorServerModifiedMessage; - - if (MessageDialog.openQuestion(getEditorSite().getShell(), title, message)) { - /*try { - //wc.refreshLocal(IResource.DEPTH_ONE, new NullProgressMonitor()); - //TODO: refresh local server - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error refreshing server", e); - }*/ - commandManager.reload(id); - } - } - - /** - * - */ - public void setFocus() { - super.setFocus(); - } - - /** - * - */ - protected void checkResourceState() { - // do not check the resource state change if saving through the editor - if (isSaving) { - // do nothing - return; - } - - // check for deleted files - if (resourceDeleted) { - String title = Messages.editorResourceDeleteTitle; - String message = null; - if (server != null) - message = NLS.bind(Messages.editorResourceDeleteServerMessage, server.getName()); - String[] labels = new String[] {Messages.editorResourceDeleteSave, IDialogConstants.CLOSE_LABEL}; - MessageDialog dialog = new MessageDialog(getEditorSite().getShell(), title, null, message, MessageDialog.INFORMATION, labels, 0); - - if (dialog.open() == 0) - doSave(new NullProgressMonitor()); - else - closeEditor(); - return; - } - resourceDeleted = false; - - // check for server changes - if (serverId != null) { - if (!commandManager.isDirty(serverId)) { - if (commandManager.hasChanged(serverId)) { - IServer newServer = ServerCore.findServer(serverId); - if (newServer != null && ((Server)newServer).getTimestamp() > ((Server)server).getTimestamp()) - commandManager.reload(serverId); - else - promptReloadServerFile(serverId); - } - } else { - if (commandManager.hasChanged(serverId) && !commandManager.areFilesReadOnly(serverId)) - promptReloadServerFile(serverId); - else if (commandManager.areFilesReadOnly(serverId) && !commandManager.isReadOnly(serverId)) - promptReadOnlyServerFile(serverId); - } - if (commandManager.isReadOnly(serverId) && !commandManager.areFilesReadOnly(serverId)) - commandManager.setReadOnly(serverId, false); - commandManager.updateTimestamps(serverId); - } - - updateStatusLine(); - } - - /** - * Set the title tooltip. - * - * @return the title tooltip - */ - public String getTitleToolTip() { - Server server2 = (Server) server; - if (server != null && server2.getFile() != null) - return server2.getFile().getFullPath().toString(); - else if (server != null) - return server.getName(); - else - return "error"; - } - - public int getOrientation() { - return Window.getDefaultOrientation(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorActionBarContributor.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorActionBarContributor.java deleted file mode 100644 index ae4c948dd..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorActionBarContributor.java +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.editor; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.IStatusLineManager; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.wst.server.ui.internal.Trace; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.actions.ActionFactory; -import org.eclipse.ui.part.EditorActionBarContributor; -/** - * Server editor action bar contributor. - */ -public class ServerEditorActionBarContributor extends EditorActionBarContributor { - public static final String SERVER_EDITOR_SEPARATOR = "server-editor-additions"; - - // current editor - protected ServerEditor editor; - - /** - * ServerEditorActionBarContributor constructor comment. - */ - public ServerEditorActionBarContributor() { - super(); - } - - /** - * Sets the active editor for the contributor. - * <p> - * The <code>EditorActionBarContributor</code> implementation of this method does - * nothing. Subclasses may reimplement. This generally entails disconnecting - * from the old editor, connecting to the new editor, and updating the actions - * to reflect the new editor. - * </p> - * - * @param targetEditor the new target editor - */ - public void setActiveEditor(IEditorPart targetEditor) { - super.setActiveEditor(targetEditor); - - if (targetEditor != null && targetEditor.equals(editor)) - return; - - IActionBars actionBars = getActionBars(); - boolean actionBarsUpdated = false; - - if (editor != null) { - editor.setStatus(null, null); - - IStatusLineManager status = actionBars.getStatusLineManager(); - status.removeAll(); - - IToolBarManager tbm = actionBars.getToolBarManager(); - tbm.removeAll(); - - actionBarsUpdated = true; - } - - if (targetEditor instanceof ServerEditor) { - editor = (ServerEditor) targetEditor; - Trace.trace(Trace.FINEST, "Editor action bar contributor for: " + editor); - editor.updateUndoAction(); - editor.updateRedoAction(); - - actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), editor.getUndoAction()); - actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), editor.getRedoAction()); - - actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), editor.getCopyAction()); - actionBars.setGlobalActionHandler(ActionFactory.CUT.getId(), editor.getCutAction()); - actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), editor.getPasteAction()); - - IStatusLineManager status = actionBars.getStatusLineManager(); - StatusLineContributionItem item = new StatusLineContributionItem("id"); - status.add(item); - - editor.setStatus(status, item); - editor.updateStatusLine(); - - IAction[] actions = editor.getEditorActions(); - IToolBarManager tbm = actionBars.getToolBarManager(); - tbm.add(new Separator(SERVER_EDITOR_SEPARATOR)); - boolean modified = false; - if (actions != null) { - int size = actions.length; - Trace.trace(Trace.FINEST, "Attempting to add editor actions: " + size); - for (int i = 0; i < size; i++) { - Trace.trace(Trace.FINEST, "action: " + actions[i]); - tbm.appendToGroup(SERVER_EDITOR_SEPARATOR, actions[i]); - modified = true; - } - } - - if (modified) - tbm.update(false); - actionBarsUpdated = true; - } else - editor = null; - - if (actionBarsUpdated) - actionBars.updateActionBars(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorActionFactory.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorActionFactory.java deleted file mode 100644 index 1b178963b..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorActionFactory.java +++ /dev/null @@ -1,164 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.editor; - -import java.util.ArrayList; -import java.util.List; -import java.util.StringTokenizer; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.jface.action.IAction; -import org.eclipse.wst.server.core.IServerWorkingCopy; -import org.eclipse.wst.server.ui.editor.IServerEditorPartInput; -import org.eclipse.wst.server.ui.internal.Trace; -import org.eclipse.wst.server.ui.internal.provisional.ServerEditorActionFactoryDelegate; -import org.eclipse.ui.IEditorSite; -/** - * A default server that can be created for a set of given - * natures. - */ -public class ServerEditorActionFactory implements IServerEditorActionFactory { - private IConfigurationElement element; - private ServerEditorActionFactoryDelegate delegate; - - /** - * ServerEditorActionFactory constructor. - * - * @param element a configuration element - */ - public ServerEditorActionFactory(IConfigurationElement element) { - super(); - this.element = element; - } - - /** - * - */ - protected IConfigurationElement getConfigurationElement() { - return element; - } - - /** - * Returns the id of this default server. - * - * @return java.lang.String - */ - public String getId() { - return element.getAttribute("id"); - } - - /** - * Returns the id of this default server. - * - * @return java.lang.String - */ - public String getName() { - return element.getAttribute("name"); - } - - /** - * Returns the order. - * - * @return int - */ - public int getOrder() { - try { - String o = element.getAttribute("order"); - return Integer.parseInt(o); - } catch (NumberFormatException e) { - return -1; - } - } - - /** - * Return the ids of the server resource factories (specified - * using Java-import style) that this page may support. - * - * @return java.lang.String[] - */ - public String[] getTypeIds() { - try { - List<String> list = new ArrayList<String>(); - StringTokenizer st = new StringTokenizer(element.getAttribute("typeIds"), ","); - while (st.hasMoreTokens()) { - String str = st.nextToken(); - if (str != null && str.length() > 0) - list.add(str); - } - String[] s = new String[list.size()]; - list.toArray(s); - return s; - } catch (Exception e) { - //Trace.trace("Could not get server resource from: " + element.getAttribute("serverResources")); - return null; - } - } - - /** - * @see IServerEditorActionFactory#supportsServerElementType(String) - */ - public boolean supportsServerElementType(String id) { - if (id == null || id.length() == 0) - return false; - - String[] s = getTypeIds(); - if (s == null) - return false; - - int size = s.length; - for (int i = 0; i < size; i++) { - if (s[i].endsWith("*")) { - if (id.length() >= s[i].length() && id.startsWith(s[i].substring(0, s[i].length() - 1))) - return true; - } else if (id.equals(s[i])) - return true; - } - return false; - } - - /* - * - */ - public ServerEditorActionFactoryDelegate getDelegate() { - if (delegate == null) { - try { - delegate = (ServerEditorActionFactoryDelegate) element.createExecutableExtension("class"); - } catch (Throwable t) { - Trace.trace(Trace.SEVERE, "Could not create server action factory delegate", t); - } - } - return delegate; - } - - /** - * @see IServerEditorActionFactory#shouldDisplay(IServerWorkingCopy) - */ - public boolean shouldDisplay(IServerWorkingCopy server) { - try { - return getDelegate().shouldDisplay(server); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error calling delegate", e); - return false; - } - } - - /** - * @see IServerEditorActionFactory#createAction(IEditorSite, IServerEditorPartInput) - */ - public IAction createAction(IEditorSite site, IServerEditorPartInput input) { - try { - return getDelegate().createAction(site, input); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error calling delegate", e); - return null; - } - } -} diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorCore.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorCore.java deleted file mode 100644 index 9cf30ce64..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorCore.java +++ /dev/null @@ -1,231 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.editor; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtensionDelta; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.Platform; -import org.eclipse.wst.server.ui.internal.ServerUIPlugin; -import org.eclipse.wst.server.ui.internal.Trace; -/** - * - */ -public class ServerEditorCore { - // cached copy of all editor factories and actions - private static List<ServerEditorPartFactory> editorPageFactories; - private static List<ServerEditorPageSectionFactory> editorPageSectionFactories; - private static List editorActionFactories; - - /** - * Returns a List of all editor page factories - * - * @return java.util.List - */ - public static List<ServerEditorPartFactory> getServerEditorPageFactories() { - if (editorPageFactories == null) - loadEditorPageFactories(); - return editorPageFactories; - } - - /** - * Returns a List of all editor page section factories - * - * @return java.util.List - */ - public static List getServerEditorPageSectionFactories() { - if (editorPageSectionFactories == null) - loadEditorPageSectionFactories(); - return editorPageSectionFactories; - } - - /** - * Load the editor page factory extension point. - */ - private static void loadEditorPageFactories() { - Trace.trace(Trace.CONFIG, "->- Loading .editorPages extension point ->-"); - IExtensionRegistry registry = Platform.getExtensionRegistry(); - IConfigurationElement[] cf = registry.getConfigurationElementsFor(ServerUIPlugin.PLUGIN_ID, ServerUIPlugin.EXTENSION_EDITOR_PAGES); - List<ServerEditorPartFactory> list = new ArrayList<ServerEditorPartFactory>(cf.length); - loadEditorPageFactories(cf, list); - editorPageFactories = list; - ServerUIPlugin.addRegistryListener(); - Trace.trace(Trace.CONFIG, "-<- Done loading .editorPages extension point -<-"); - } - - /** - * Load the editor page factory extension point. - */ - private static void loadEditorPageFactories(IConfigurationElement[] cf, List<ServerEditorPartFactory> list) { - int size = cf.length; - for (int i = 0; i < size; i++) { - try { - list.add(new ServerEditorPartFactory(cf[i])); - Trace.trace(Trace.CONFIG, " Loaded editorPage: " + cf[i].getAttribute("id")); - } catch (Throwable t) { - Trace.trace(Trace.SEVERE, " Could not load editorPage: " + cf[i].getAttribute("id"), t); - } - } - - // sort pages - sortOrderedList(list); - } - - public static void handleEditorPageFactoriesDelta(IExtensionDelta delta) { - if (editorPageFactories == null) // not loaded yet - return; - - IConfigurationElement[] cf = delta.getExtension().getConfigurationElements(); - - List<ServerEditorPartFactory> list = new ArrayList<ServerEditorPartFactory>(editorPageFactories); - if (delta.getKind() == IExtensionDelta.ADDED) - loadEditorPageFactories(cf, list); - else { - int size = list.size(); - ServerEditorPartFactory[] sepf = new ServerEditorPartFactory[size]; - list.toArray(sepf); - int size2 = cf.length; - - for (int i = 0; i < size; i++) { - for (int j = 0; j < size2; j++) { - if (sepf[i].getId().equals(cf[j].getAttribute("id"))) { - list.remove(sepf[i]); - } - } - } - } - editorPageFactories = list; - } - - /** - * Load the editor page section factory extension point. - */ - private static void loadEditorPageSectionFactories() { - Trace.trace(Trace.CONFIG, "->- Loading .editorPageSections extension point ->-"); - IExtensionRegistry registry = Platform.getExtensionRegistry(); - IConfigurationElement[] cf = registry.getConfigurationElementsFor(ServerUIPlugin.PLUGIN_ID, ServerUIPlugin.EXTENSION_EDITOR_PAGE_SECTIONS); - List<ServerEditorPageSectionFactory> list = new ArrayList<ServerEditorPageSectionFactory>(cf.length); - loadEditorPageSectionFactories(cf, list); - editorPageSectionFactories = list; - ServerUIPlugin.addRegistryListener(); - Trace.trace(Trace.CONFIG, "-<- Done loading .editorPageSections extension point -<-"); - } - - /** - * Load the editor page section factory extension point. - */ - private static void loadEditorPageSectionFactories(IConfigurationElement[] cf, List<ServerEditorPageSectionFactory> list) { - int size = cf.length; - for (int i = 0; i < size; i++) { - try { - list.add(new ServerEditorPageSectionFactory(cf[i])); - Trace.trace(Trace.CONFIG, " Loaded editorPageSection: " + cf[i].getAttribute("id")); - } catch (Throwable t) { - Trace.trace(Trace.SEVERE, " Could not load editorPageSection: " + cf[i].getAttribute("id"), t); - } - } - - // sort sections - sortOrderedList(list); - } - - public static void handleEditorPageSectionFactoriesDelta(IExtensionDelta delta) { - if (editorPageSectionFactories == null) // not loaded yet - return; - - IConfigurationElement[] cf = delta.getExtension().getConfigurationElements(); - - List<ServerEditorPageSectionFactory> list = new ArrayList<ServerEditorPageSectionFactory>(editorPageSectionFactories); - if (delta.getKind() == IExtensionDelta.ADDED) - loadEditorPageSectionFactories(cf, list); - else { - int size = list.size(); - ServerEditorPageSectionFactory[] seps = new ServerEditorPageSectionFactory[size]; - list.toArray(seps); - int size2 = cf.length; - - for (int i = 0; i < size; i++) { - for (int j = 0; j < size2; j++) { - if (seps[i].getId().equals(cf[j].getAttribute("id"))) { - list.remove(seps[i]); - } - } - } - } - editorPageSectionFactories = list; - } - - /** - * Returns a List of all editor action factories. - * - * @return java.util.List - */ - public static List getServerEditorActionFactories() { - if (editorActionFactories == null) - loadEditorActionFactories(); - return editorActionFactories; - } - - /** - * Load the editor action factories extension point. - */ - private static void loadEditorActionFactories() { - Trace.trace(Trace.CONFIG, "->- Loading .editorActions extension point ->-"); - IExtensionRegistry registry = Platform.getExtensionRegistry(); - IConfigurationElement[] cf = registry.getConfigurationElementsFor(ServerUIPlugin.PLUGIN_ID, "editorActions"); - - int size = cf.length; - List<ServerEditorActionFactory> list = new ArrayList<ServerEditorActionFactory>(size); - for (int i = 0; i < size; i++) { - try { - list.add(new ServerEditorActionFactory(cf[i])); - Trace.trace(Trace.CONFIG, " Loaded editorAction: " + cf[i].getAttribute("id")); - } catch (Throwable t) { - Trace.trace(Trace.SEVERE, " Could not load editorAction: " + cf[i].getAttribute("id"), t); - } - } - - // sort pages - sortOrderedList(list); - editorActionFactories = list; - - Trace.trace(Trace.CONFIG, "-<- Done loading .editorActions extension point -<-"); - } - - /** - * Sort the given list of IOrdered items into indexed order. This method - * modifies the original list, but returns the value for convenience. - * - * @param list java.util.List - * @return java.util.List - */ - public static List sortOrderedList(List list) { - if (list == null) - return null; - - int size = list.size(); - for (int i = 0; i < size - 1; i++) { - for (int j = i + 1; j < size; j++) { - IOrdered a = (IOrdered) list.get(i); - IOrdered b = (IOrdered) list.get(j); - if (a.getOrder() > b.getOrder()) { - IOrdered temp = a; - list.set(i, b); - list.set(j, temp); - } - } - } - return list; - } -} diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorInput.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorInput.java deleted file mode 100644 index 31861ac4c..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorInput.java +++ /dev/null @@ -1,182 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.editor; - -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.ServerCore; -import org.eclipse.wst.server.core.internal.Server; -import org.eclipse.wst.server.ui.internal.ImageResource; -import org.eclipse.ui.IMemento; -import org.eclipse.ui.IPersistableElement; -/** - * The editor input for server configurations and instances. The - * input points to a resource that is either an instance or - * configuration. - * - * <p>Editors supporting this editor input should use the ResourceManager - * to load their own copy of the resource. Each editor is responsible - * for managing this resource and making sure that only one copy is - * loaded from disk when multiple editors are opened on the same - * resource.</p> - * - * <p>When the editor saves back to the resource, the server tooling - * will notice the change and reload the new configuration.</p> - * - * <p>Editors should call setEditing(resource, true) when the first - * editor opens on a particular resource, and setEditing(resource, - * false) when the last editor on a resource closes. This will - * ensure that the server tooling does not try to edit the resource - * and cause conflicting changes while an editor is open.</p> - */ -public class ServerEditorInput implements IServerEditorInput, IPersistableElement { - private String serverId; - - /** - * ServerEditorInput constructor comment. - * - * @param serverId a server id - */ - public ServerEditorInput(String serverId) { - super(); - this.serverId = serverId; - } - - /** - * Returns the server id. - * @return org.eclipse.core.resources.IResource - */ - public String getServerId() { - return serverId; - } - - /** - * @see Object#equals(Object) - */ - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!(obj instanceof ServerEditorInput)) - return false; - ServerEditorInput other = (ServerEditorInput) obj; - if (serverId == null) { - if (other.serverId != null) - return false; - } else if (!serverId.equals(other.serverId)) - return false; - return true; - } - - /** - * Returns whether the editor input exists. - * <p> - * This method is primarily used to determine if an editor input should - * appear in the "File Most Recently Used" menu. An editor input will appear - * in the list until the return value of <code>exists</code> becomes - * <code>false</code> or it drops off the bottom of the list. - * - * @return <code>true</code> if the editor input exists; <code>false</code> - * otherwise - */ - public boolean exists() { - if (serverId != null && ServerCore.findServer(serverId) == null) - return false; - - return true; - } - - /** - * Returns an object which is an instance of the given class - * associated with this object. Returns <code>null</code> if - * no such object can be found. - * - * @param adapter the adapter class to look up - * @return a object castable to the given class, - * or <code>null</code> if this object does not - * have an adapter for the given class - */ - public Object getAdapter(Class adapter) { - return Platform.getAdapterManager().getAdapter(this, adapter); - } - - /** - * Returns the ID of an element factory which can be used to recreate - * this object. An element factory extension with this ID must exist - * within the workbench registry. - * - * @return the element factory ID - */ - public String getFactoryId() { - return ServerEditorInputFactory.FACTORY_ID; - } - - public ImageDescriptor getImageDescriptor() { - return ImageResource.getImageDescriptor(ImageResource.IMG_SERVER); - } - - /** - * Returns the name of this editor input for display purposes. - * <p> - * For instance, if the fully qualified input name is - * <code>"a\b\MyFile.gif"</code>, the return value would be just - * <code>"MyFile.gif"</code>. - * - * @return the file name string - */ - public String getName() { - if (serverId != null) { - IServer server = ServerCore.findServer(serverId); - if (server != null) - return server.getName(); - return serverId; - } - return ""; - } - - /* - * Returns an object that can be used to save the state of this editor input. - * - * @return the persistable element, or <code>null</code> if this editor input - * cannot be persisted - */ - public IPersistableElement getPersistable() { - return this; - } - - public String getToolTipText() { - String s = null; - if (serverId != null) { - IServer server = ServerCore.findServer(serverId); - if (server != null) { - Server server2 = (Server) server; - if (server2.getFile() != null) { - s = server2.getFile().getFullPath().makeRelative().toString(); - if (s.startsWith("/")) - s = s.substring(1); - } else - s = server.getName(); - } - } - if (s == null) - s = ""; - return s; - } - - /** - * Saves the state of an element within a memento. - * - * @param memento the storage area for element state - */ - public void saveState(IMemento memento) { - ServerEditorInputFactory.saveState(memento, this); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorInputFactory.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorInputFactory.java deleted file mode 100644 index 83e062c7f..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorInputFactory.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.editor; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.ui.IElementFactory; -import org.eclipse.ui.IMemento; -/** - * This factory is used in the persistence of ServerResourceEditorInput - * instances. This allows the user to close the workbench with an - * open editor and reopen to the same editor. - */ -public class ServerEditorInputFactory implements IElementFactory { - protected final static String FACTORY_ID = "org.eclipse.wst.server.ui.editor.input.factory"; - protected final static String SERVER_ID = "server-id"; - - /** - * ServerEditorInputFactory constructor comment. - */ - public ServerEditorInputFactory() { - // do nothing - } - - /* - * Creates editor input based on the state in the memento. - */ - public IAdaptable createElement(IMemento memento) { - // get the resource names - String serverId = memento.getString(SERVER_ID); - - return new ServerEditorInput(serverId); - } - - /** - * Saves the state of an element within a memento. - * - * @param memento the storage area for element state - * @param input server editor input - */ - public static void saveState(IMemento memento, ServerEditorInput input) { - if (input == null) - return; - - if (input.getServerId() != null) - memento.putString(SERVER_ID, input.getServerId()); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorPageSectionFactory.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorPageSectionFactory.java deleted file mode 100644 index b5cc2f4d2..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorPageSectionFactory.java +++ /dev/null @@ -1,205 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.editor; - -import java.util.ArrayList; -import java.util.List; -import java.util.StringTokenizer; - -import org.eclipse.core.expressions.*; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; - -import org.eclipse.wst.server.core.IServerWorkingCopy; -import org.eclipse.wst.server.ui.editor.*; -import org.eclipse.wst.server.ui.internal.Trace; -/** - * - */ -public class ServerEditorPageSectionFactory implements IServerEditorPageSectionFactory { - private IConfigurationElement element; - private Expression fContextualLaunchExpr = null; - - /** - * ServerEditorPageSectionFactory constructor. - * - * @param element a configuration element - */ - public ServerEditorPageSectionFactory(IConfigurationElement element) { - super(); - this.element = element; - } - - /** - * - */ - protected IConfigurationElement getConfigurationElement() { - return element; - } - - /** - * Returns the id of this factory. - * - * @return java.lang.String - */ - public String getId() { - return element.getAttribute("id"); - } - - /** - * Returns the order. - * - * @return int - */ - public int getOrder() { - try { - String o = element.getAttribute("order"); - return Integer.parseInt(o); - } catch (NumberFormatException e) { - return -1; - } - } - - /** - * Returns the insertion id of this factory. - * - * @return the insertion id - */ - public String getInsertionId() { - return element.getAttribute("insertionId"); - } - - /** - * Return the ids of the server resource factories (specified - * using Java-import style) that this page may support. - * - * @return an array of type ids - */ - protected String[] getTypeIds() { - try { - List<String> list = new ArrayList<String>(); - StringTokenizer st = new StringTokenizer(element.getAttribute("typeIds"), ","); - while (st.hasMoreTokens()) { - String str = st.nextToken(); - if (str != null && str.length() > 0) - list.add(str.trim()); - } - String[] s = new String[list.size()]; - list.toArray(s); - return s; - } catch (Exception e) { - //Trace.trace("Could not get server resource from: " + element.getAttribute("serverResources")); - return null; - } - } - - /** - * @see IServerEditorPageSectionFactory#supportsType(String) - */ - public boolean supportsType(String id) { - if (id == null || id.length() == 0) - return false; - - String[] s = getTypeIds(); - if (s == null) - return false; - - int size = s.length; - for (int i = 0; i < size; i++) { - if (s[i].endsWith("*")) { - if (id.length() >= s[i].length() && id.startsWith(s[i].substring(0, s[i].length() - 1))) - return true; - } else if (id.equals(s[i])) - return true; - } - return false; - } - - /** - * @see IServerEditorPageSectionFactory#shouldCreateSection(IServerWorkingCopy) - */ - public boolean shouldCreateSection(IServerWorkingCopy server) { - try { - return isEnabled(server); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error calling delegate", e); - return false; - } - } - - /** - * @see IServerEditorPageSectionFactory#createSection() - */ - public ServerEditorSection createSection() { - try { - return (ServerEditorSection) element.createExecutableExtension("class"); - } catch (Throwable t) { - Trace.trace(Trace.SEVERE, "Could not create server editor section", t); - return null; - } - } - - /** - * Returns an expression that represents the enablement logic for the - * contextual launch element of this launch shortcut description or - * <code>null</code> if none. - * @return an evaluatable expression or <code>null</code> - * @throws CoreException if the configuration element can't be - * converted. Reasons include: (a) no handler is available to - * cope with a certain configuration element or (b) the XML - * expression tree is malformed. - */ - public Expression getContextualLaunchEnablementExpression() throws CoreException { - if (fContextualLaunchExpr == null) { - IConfigurationElement[] elements = element.getChildren(ExpressionTagNames.ENABLEMENT); - IConfigurationElement enablement = elements.length > 0 ? elements[0] : null; - - if (enablement != null) - fContextualLaunchExpr = ExpressionConverter.getDefault().perform(enablement); - } - return fContextualLaunchExpr; - } - - /** - * Evaluate the given expression within the given context and return - * the result. Returns <code>true</code> iff result is either TRUE or NOT_LOADED. - * This allows optimistic inclusion of shortcuts before plugins are loaded. - * Returns <code>false</code> if exp is <code>null</code>. - * - * @param exp the enablement expression to evaluate or <code>null</code> - * @param context the context of the evaluation. Usually, the - * user's selection. - * @return the result of evaluating the expression - * @throws CoreException - */ - protected boolean evalEnablementExpression(IEvaluationContext context, Expression exp) throws CoreException { - return (exp != null) ? ((exp.evaluate(context)) != EvaluationResult.FALSE) : false; - } - - /** - * Returns true if enabled for the given object. - * - * @param obj an object - * @return <code>true</code> if enabled - * @throws CoreException if anything goes wrong - */ - public boolean isEnabled(Object obj) throws CoreException { - if (getContextualLaunchEnablementExpression() == null) - return true; - IEvaluationContext context = new EvaluationContext(null, obj); - context.addVariable("server", obj); - return evalEnablementExpression(context, getContextualLaunchEnablementExpression()); - } - - public String toString() { - return "ServerEditorSection [" + getId() + ", " + getInsertionId() + ", " + getOrder() + "]"; - } -} diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorPartFactory.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorPartFactory.java deleted file mode 100644 index 680cc2245..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorPartFactory.java +++ /dev/null @@ -1,243 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.editor; - -import java.util.ArrayList; -import java.util.List; -import java.util.StringTokenizer; - -import org.eclipse.core.expressions.*; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.wst.server.core.IServerWorkingCopy; -import org.eclipse.wst.server.ui.internal.Trace; -import org.eclipse.ui.IEditorPart; -/** - * - */ -public class ServerEditorPartFactory implements IServerEditorPartFactory { - private IConfigurationElement element; - private Expression fContextualLaunchExpr = null; - - /** - * ServerEditorPartFactory constructor. - * - * @param element a configuration element - */ - public ServerEditorPartFactory(IConfigurationElement element) { - super(); - this.element = element; - } - - /** - * - */ - protected IConfigurationElement getConfigurationElement() { - return element; - } - - /** - * Returns the id of this part factory. - * - * @return java.lang.String - */ - public String getId() { - return element.getAttribute("id"); - } - - /** - * Returns the name of this part factory. - * - * @return java.lang.String - */ - public String getName() { - return element.getAttribute("name"); - } - - protected String[] getInsertionIds() { - try { - String insertionIds = element.getAttribute("insertionIds"); - List<String> list = new ArrayList<String>(); - if (insertionIds != null && insertionIds.length() > 0) { - StringTokenizer st = new StringTokenizer(insertionIds, ","); - while (st.hasMoreTokens()) { - String str = st.nextToken(); - if (str != null && str.length() > 0) - list.add(str.trim()); - } - } - String[] s = new String[list.size()]; - list.toArray(s); - return s; - } catch (Exception e) { - //Trace.trace("Could not get server resource from: " + element.getAttribute("serverResources")); - return null; - } - } - - /** - * @see IServerEditorPartFactory#supportsInsertionId(String) - */ - public boolean supportsInsertionId(String id) { - if (id == null || id.length() == 0) - return false; - - String[] s = getInsertionIds(); - if (s == null) - return false; - - int size = s.length; - for (int i = 0; i < size; i++) { - if (s[i].endsWith("*")) { - if (id.length() >= s[i].length() && id.startsWith(s[i].substring(0, s[i].length() - 1))) - return true; - } else if (id.equals(s[i])) - return true; - } - return false; - } - - /** - * Returns the order. - * - * @return int - */ - public int getOrder() { - try { - String o = element.getAttribute("order"); - return Integer.parseInt(o); - } catch (NumberFormatException e) { - return -1; - } - } - - /** - * Return the ids of the server and server configuration type ids (specified - * using Java-import style) that this page may support. - * - * @return an array of type ids - */ - protected String[] getTypeIds() { - try { - List<String> list = new ArrayList<String>(); - StringTokenizer st = new StringTokenizer(element.getAttribute("typeIds"), ","); - while (st.hasMoreTokens()) { - String str = st.nextToken(); - if (str != null && str.length() > 0) - list.add(str.trim()); - } - String[] s = new String[list.size()]; - list.toArray(s); - return s; - } catch (Exception e) { - //Trace.trace("Could not get server resource from: " + element.getAttribute("serverResources")); - return null; - } - } - - /** - * @see IServerEditorPartFactory#supportsType(String) - */ - public boolean supportsType(String id) { - String[] s = getTypeIds(); - if (s == null || s.length == 0 || "*".equals(s[0])) - return true; - - if (id == null || id.length() == 0) - return false; - - int size = s.length; - for (int i = 0; i < size; i++) { - if (s[i].endsWith("*")) { - if (id.length() >= s[i].length() && id.startsWith(s[i].substring(0, s[i].length() - 1))) - return true; - } else if (id.equals(s[i])) - return true; - } - return false; - } - - /** - * @see IServerEditorPartFactory#shouldCreatePage(IServerWorkingCopy) - */ - public boolean shouldCreatePage(IServerWorkingCopy server) { - try { - return isEnabled(server); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error calling delegate", e); - return false; - } - } - - /** - * @see IServerEditorPartFactory#createPage() - */ - public IEditorPart createPage() { - try { - return (IEditorPart) element.createExecutableExtension("class"); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error calling delegate", e); - return null; - } - } - - /** - * Returns an expression that represents the enablement logic for the - * contextual launch element of this launch shortcut description or - * <code>null</code> if none. - * @return an evaluatable expression or <code>null</code> - * @throws CoreException if the configuration element can't be - * converted. Reasons include: (a) no handler is available to - * cope with a certain configuration element or (b) the XML - * expression tree is malformed. - */ - public Expression getContextualLaunchEnablementExpression() throws CoreException { - if (fContextualLaunchExpr == null) { - IConfigurationElement[] elements = element.getChildren(ExpressionTagNames.ENABLEMENT); - IConfigurationElement enablement = elements.length > 0 ? elements[0] : null; - - if (enablement != null) - fContextualLaunchExpr = ExpressionConverter.getDefault().perform(enablement); - } - return fContextualLaunchExpr; - } - - /** - * Evaluate the given expression within the given context and return - * the result. Returns <code>true</code> iff result is either TRUE or NOT_LOADED. - * This allows optimistic inclusion of shortcuts before plugins are loaded. - * Returns <code>false</code> if exp is <code>null</code>. - * - * @param exp the enablement expression to evaluate or <code>null</code> - * @param context the context of the evaluation. Usually, the - * user's selection. - * @return the result of evaluating the expression - * @throws CoreException - */ - protected boolean evalEnablementExpression(IEvaluationContext context, Expression exp) throws CoreException { - return (exp != null) ? ((exp.evaluate(context)) != EvaluationResult.FALSE) : false; - } - - /** - * Returns true if enabled for the given object. - * - * @param obj an object - * @return <code>true</code> if enabled - * @throws CoreException if anything goes wrong - */ - public boolean isEnabled(Object obj) throws CoreException { - if (getContextualLaunchEnablementExpression() == null) - return true; - IEvaluationContext context = new EvaluationContext(null, obj); - context.addVariable("server", obj); - return evalEnablementExpression(context, getContextualLaunchEnablementExpression()); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorPartInput.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorPartInput.java deleted file mode 100644 index 79045b29c..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditorPartInput.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.editor; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.ui.IPersistableElement; - -import org.eclipse.wst.server.core.IServerWorkingCopy; -import org.eclipse.wst.server.ui.editor.IServerEditorPartInput; -/** - * - */ -public class ServerEditorPartInput implements IServerEditorPartInput { - protected IServerWorkingCopy server; - protected boolean serverReadOnly; - protected ServerResourceCommandManager serverCommandManager; - - public ServerEditorPartInput(ServerResourceCommandManager serverCommandManager, - IServerWorkingCopy server, boolean serverReadOnly) { - - this.server = server; - this.serverReadOnly = serverReadOnly; - this.serverCommandManager = serverCommandManager; - } - - public String getName() { - return "-"; - } - - public String getToolTipText() { - return "-"; - } - - public boolean exists() { - return true; - } - - public Object getAdapter(Class adapter) { - return null; - } - - public ImageDescriptor getImageDescriptor() { - return null; - } - - public IPersistableElement getPersistable() { - return null; - } - - /** - * Returns the server to be edited. - * - * @return IServerResource - */ - public IServerWorkingCopy getServer() { - return server; - } - - /** - * Returns true if the server is read-only. - * - * @return boolean - */ - public boolean isServerReadOnly() { - return serverReadOnly; - } - - public ServerResourceCommandManager getServerCommandManager() { - return serverCommandManager; - } - - public String toString() { - return "ServerEditorPartInput [" + server + "]"; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerResourceCommandManager.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerResourceCommandManager.java deleted file mode 100644 index 662fffcc2..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerResourceCommandManager.java +++ /dev/null @@ -1,102 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.editor; - -import org.eclipse.core.commands.operations.IUndoableOperation; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.wst.server.core.*; -import org.eclipse.wst.server.ui.internal.Messages; -/** - * A command manager for a single server resource. - */ -public class ServerResourceCommandManager { - protected ServerEditor editor; - protected GlobalCommandManager commandManager; - protected String id; - - public ServerResourceCommandManager(ServerEditor editor, String id, GlobalCommandManager commandManager) { - this.editor = editor; - this.commandManager = commandManager; - this.id = id; - } - - public boolean isReadOnly() { - return commandManager.isReadOnly(id); - } - - /** - * Execute the given command and place it in the undo stack. - * If the command cannot be undone, the user will be notifed - * before it is executed. - * - * @param operation an undoable operation - */ - public void execute(IUndoableOperation operation) { - if (!validateEdit()) - return; - - if (commandManager.isReadOnly(id)) { - warnReadOnly(); - return; - } - commandManager.executeCommand(id, operation); - } - - protected void warnReadOnly() { - String title = Messages.editorResourceWarnTitle; - String message = Messages.editorResourceWarnMessage; - - MessageDialog.openWarning(editor.getEditorSite().getShell(), title, message); - } - - /** - * - */ - protected boolean validateEdit() { - if (commandManager.isDirty(id)) - return true; - - IFile[] files = commandManager.getReadOnlyFiles(id); - if (files.length == 0) - return true; - - IStatus status = ResourcesPlugin.getWorkspace().validateEdit(files, editor.getEditorSite().getShell()); - - if (status.getSeverity() == IStatus.ERROR) { - // inform user - String message = Messages.editorValidateEditFailureMessage; - ErrorDialog.openError(editor.getEditorSite().getShell(), Messages.errorDialogTitle, message, status); - - // change to read-only - commandManager.setReadOnly(id, true); - - // do not execute command - return false; - } - // check file timestamp - IServerAttributes serverfile = commandManager.getServerResource(id); - if (commandManager.hasChanged(id)) { - if (serverfile instanceof IServer) - editor.promptReloadServerFile(id); - } - - // allow edit - return true; - } - - public ServerEditor getServerEditor() { - return editor; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/StatusLineContributionItem.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/StatusLineContributionItem.java deleted file mode 100644 index d4a68e56e..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/StatusLineContributionItem.java +++ /dev/null @@ -1,91 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.editor; - -import org.eclipse.jface.action.ContributionItem; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CLabel; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.texteditor.IStatusField; -/** - * Contribution item for the status line. - */ -public class StatusLineContributionItem extends ContributionItem implements IStatusField { - - static class StatusLineLabel extends CLabel { - - private static int INDENT= 3; // left and right margin used in CLabel - - private Point fFixedSize; - - public StatusLineLabel(Composite parent, int style) { - super(parent, style); - - GC gc= new GC(parent); - gc.setFont(parent.getFont()); - Point extent= gc.textExtent("MMMMMMMMM"); //$NON-NLS-1$ - gc.dispose(); - - fFixedSize= new Point(extent.x + INDENT * 2, 10); - } - - public Point computeSize(int wHint, int hHint, boolean changed) { - return fFixedSize; - } - } - - private String fText; - private Image fImage; - private StatusLineLabel fLabel; - - /** - * Creates a new item with the given id. - * - * @param id the item's id - */ - StatusLineContributionItem(String id) { - super(id); - } - - /* - * @see IStatusField#setText - */ - public void setText(String text) { - fText= text; - if (fLabel != null && !fLabel.isDisposed()) { - fLabel.setText(fText); - } - } - - /* - * @see IStatusField#setImage(Image) - */ - public void setImage(Image image) { - fImage= image; - if (fLabel != null && !fLabel.isDisposed()) { - fLabel.setImage(fImage); - } - } - - /* - * @see IContributionItem#fill(Composite) - */ - public void fill(Composite parent) { - fLabel= new StatusLineLabel(parent, SWT.SHADOW_IN); - fLabel.setData(this); - - if (fText != null) - fLabel.setText(fText); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/TextAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/TextAction.java deleted file mode 100644 index 458b5bf04..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/TextAction.java +++ /dev/null @@ -1,246 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.editor; - -import org.eclipse.jface.action.Action; -import org.eclipse.wst.server.ui.internal.Trace; -import org.eclipse.swt.SWTError; -import org.eclipse.swt.dnd.Clipboard; -import org.eclipse.swt.dnd.TextTransfer; -import org.eclipse.swt.dnd.Transfer; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Text; -/** - * Text actions (cut, copy, paste) for the Web browser. - */ -public class TextAction extends Action { - protected Display display; - protected Clipboard clipboard; - protected byte type; - - public static final byte CUT_ACTION = 0; - public static final byte COPY_ACTION = 1; - public static final byte PASTE_ACTION = 2; - - /** - * TextAction constructor comment. - */ - protected TextAction(Display display, byte type) { - super("Text action: " + type); - this.display = display; - clipboard = new Clipboard(display); - this.type = type; - } - - protected Control getControl() { - Control control = display.getFocusControl(); - return control; - } - - protected Point getControlSelection() { - Control control = getControl(); - if (control == null) - return null; - - if (control instanceof Text) { - Text text = (Text) control; - return text.getSelection(); - } else if (control instanceof Combo) { - Combo combo = (Combo) control; - return combo.getSelection(); - } else - return null; - } - - protected void setControlSelection(Point sel) { - Control control = getControl(); - if (control == null) - return; - - if (control instanceof Text) { - Text text = (Text) control; - text.setSelection(sel); - } else if (control instanceof Combo) { - Combo combo = (Combo) control; - combo.setSelection(sel); - } - } - - protected String getControlText() { - Control control = getControl(); - if (control == null) - return null; - - if (control instanceof Text) { - Text text = (Text) control; - return text.getText(); - } else if (control instanceof Combo) { - Combo combo = (Combo) control; - return combo.getText(); - } else - return null; - } - - protected void setControlText(String text) { - Control control = getControl(); - if (control == null) - return; - - if (control instanceof Text) { - Text text2 = (Text) control; - text2.setText(text); - } else if (control instanceof Combo) { - Combo combo = (Combo) control; - combo.setText(text); - } - } - - /** - * Copies the selected text to the clipboard. The text will be put in the - * clipboard in plain text format. - */ - public void copy() { - Point selection = getControlSelection(); - String text = getControlText(); - if (selection == null || text == null) - return; - - int length = selection.y - selection.x; - if (length > 0) { - TextTransfer plainTextTransfer = TextTransfer.getInstance(); - try { - clipboard.setContents( - new String[] { text.substring(selection.x, selection.y) }, - new Transfer[] { plainTextTransfer }); - } catch (SWTError error) { - // Copy to clipboard failed. This happens when another application - // is accessing the clipboard while we copy. Ignore the error. - } - } - } - - /** - * Moves the selected text to the clipboard. The text will be put in the - * clipboard in plain text format and RTF format. - */ - public void cut(){ - Point selection = getControlSelection(); - if (selection == null) - return; - - if (selection.y > selection.x) { - copy(); - delete(); - } - } - - /** - * Deletes the character to the right of the caret. Delete the selected text if any. - */ - public void delete() { - Point selection = getControlSelection(); - String text = getControlText(); - if (selection == null || text == null) - return; - - if (selection.x != selection.y) { - text = text.substring(0, selection.x) + text.substring(selection.y); - setControlText(text); - setControlSelection(new Point(selection.x, selection.x)); - } - } - - /** - * Replaces the selection with the clipboard text or insert the text at - * the current caret offset if there is no selection. - * If the widget has the SWT.SINGLE style and the clipboard text contains - * more than one line, only the first line without line delimiters is - * inserted in the widget. - */ - public void paste() { - TextTransfer transfer = TextTransfer.getInstance(); - Point selection = getControlSelection(); - String text = getControlText(); - if (selection == null) - return; - - String newText = (String) clipboard.getContents(transfer); - if (newText != null && newText.length() > 0) { - if (text == null) - text = newText; - else - text = text.substring(0, selection.x) + newText + text.substring(selection.y); - setControlText(text); - - // set the selection to the end of the paste - int x = selection.x + newText.length(); - setControlSelection(new Point(x, x)); - } - } - - /** - * Execute the action. - */ - public void run() { - if (display == null) - return; - if (type == CUT_ACTION) - cut(); - else if (type == COPY_ACTION) - copy(); - else if (type == PASTE_ACTION) - paste(); - } - - /** - * Update the actions enabled/disabled state. - */ - protected void update() { - if (getControl() == null) { - setEnabled(false); - return; - } - Point selection = getControlSelection(); - String text = getControlText(); - - try { - if (type == CUT_ACTION) - setEnabled(text != null && text.length() > 0 && selection != null && selection.x < selection.y); - else if (type == COPY_ACTION) - setEnabled(text != null && text.length() > 0 && selection != null && selection.x < selection.y); - else if (type == PASTE_ACTION) { - Control control = getControl(); - if (!control.isEnabled()) { - setEnabled(false); - return; - } - if (!(control instanceof Text)) { - setEnabled(false); - return; - } - - Text text2 = (Text) control; - if (!text2.getEditable()) { - setEnabled(false); - return; - } - TextTransfer transfer = TextTransfer.getInstance(); - String newText = (String) clipboard.getContents(transfer); - setEnabled(newText != null && newText.length() > 0); - } - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error updating text action", e); - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/provisional/IServerToolTip.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/provisional/IServerToolTip.java deleted file mode 100644 index f2853d1dd..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/provisional/IServerToolTip.java +++ /dev/null @@ -1,32 +0,0 @@ -/********************************************************************** - * Copyright (c) 2007,2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - **********************************************************************/ -package org.eclipse.wst.server.ui.internal.provisional; - -import org.eclipse.swt.widgets.Composite; -import org.eclipse.wst.server.core.IServer; -/** - * Provides extra information to the hover over mouse action of a server - * <p> - * <b>Provisional API:</b> This class/interface is part of an interim API that is still under development and expected to - * change significantly before reaching stability. It is being made available at this early stage to solicit feedback - * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken - * (repeatedly) as the API evolves. - * </p> - */ -public interface IServerToolTip { - /** - * Allows adopters to add widgets to the tooltip. - * - * @param parent the parent - * @param server the server - */ - public void createContent(Composite parent, IServer server); -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/provisional/ManagedUIDecorator.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/provisional/ManagedUIDecorator.java deleted file mode 100644 index 29206c58f..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/provisional/ManagedUIDecorator.java +++ /dev/null @@ -1,102 +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.server.ui.internal.provisional; - -import org.eclipse.debug.core.ILaunchManager; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.ui.internal.ImageResource; -import org.eclipse.wst.server.ui.internal.Messages; - -public class ManagedUIDecorator extends UIDecorator { - private static final String[] serverStateUnmanaged = new String[] { - "", - Messages.viewStatusStarting4, - Messages.viewStatusStarted2, - Messages.viewStatusStopping4, - Messages.viewStatusStopped2}; - - private static final String[] startingText = new String[] { - Messages.viewStatusStarting1, - Messages.viewStatusStarting2, - Messages.viewStatusStarting3}; - - private static final String[] stoppingText = new String[] { - Messages.viewStatusStopping1, - Messages.viewStatusStopping2, - Messages.viewStatusStopping3}; - - private static final Image[] startingImages = new Image[] { - ImageResource.getImage(ImageResource.IMG_SERVER_STATE_STARTING_1), - ImageResource.getImage(ImageResource.IMG_SERVER_STATE_STARTING_2), - ImageResource.getImage(ImageResource.IMG_SERVER_STATE_STARTING_3) - }; - - private static final Image[] stoppingImages = new Image[] { - ImageResource.getImage(ImageResource.IMG_SERVER_STATE_STOPPING_1), - ImageResource.getImage(ImageResource.IMG_SERVER_STATE_STOPPING_2), - ImageResource.getImage(ImageResource.IMG_SERVER_STATE_STOPPING_2) - }; - - /** - * @see UIDecorator#getStateLabel(int, String, int) - */ - public String getStateLabel(int state, String mode, int count) { - if (state == IServer.STATE_UNKNOWN) - return ""; - else if (state == IServer.STATE_STARTING) - return startingText[count]; - else if (state == IServer.STATE_STOPPING) - return stoppingText[count]; - else if (state == IServer.STATE_STARTED) { - if (ILaunchManager.DEBUG_MODE.equals(mode)) - return Messages.viewStatusStartedDebug; - else if (ILaunchManager.PROFILE_MODE.equals(mode)) - return Messages.viewStatusStartedProfile; - else - return Messages.viewStatusStarted; - } else if (state == IServer.STATE_STOPPED) - return Messages.viewStatusStopped; - - return serverStateUnmanaged[state]; - } - - /** - * @see UIDecorator#getStateImage(int, String, int) - */ - public Image getStateImage(int state, String mode, int count) { - if (state == IServer.STATE_UNKNOWN) - return null; - else if (state == IServer.STATE_STARTING) - return startingImages[count]; - else if (state == IServer.STATE_STOPPING) - return stoppingImages[count]; - else if (state == IServer.STATE_STOPPED) - return ImageResource.getImage(ImageResource.IMG_SERVER_STATE_STOPPED); - else { //if (state == IServer.STATE_STARTED) { - //String mode = server.getMode(); - if (ILaunchManager.DEBUG_MODE.equals(mode)) - return ImageResource.getImage(ImageResource.IMG_SERVER_STATE_STARTED_DEBUG); - else if (ILaunchManager.PROFILE_MODE.equals(mode)) - return ImageResource.getImage(ImageResource.IMG_SERVER_STATE_STARTED_PROFILE); - else - return ImageResource.getImage(ImageResource.IMG_SERVER_STATE_STARTED); - } - } - - public String getModuleName() { - return "module"; - } - - public boolean canRestart() { - return true; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/provisional/ServerEditorActionFactoryDelegate.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/provisional/ServerEditorActionFactoryDelegate.java deleted file mode 100644 index 834074f9f..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/provisional/ServerEditorActionFactoryDelegate.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.provisional; - -import org.eclipse.jface.action.IAction; -import org.eclipse.ui.IEditorSite; - -import org.eclipse.wst.server.core.IServerWorkingCopy; -import org.eclipse.wst.server.ui.editor.IServerEditorPartInput; -/** - * - */ -public abstract class ServerEditorActionFactoryDelegate { - /** - * Returns true if this editor action should be visible on the given - * server. This allows actions to be filtered based on the server type - * or server attributes. - * - * @param server the server being edited - * @return <code>true</code> if the action should be displayed, or - * <code>false</code> otherwise - */ - public boolean shouldDisplay(IServerWorkingCopy server) { - return true; - } - - /** - * Create the action. - * - * @param site the editor site - * @param input the server editor port input - * @return an action that can be run against the server - */ - public abstract IAction createAction(IEditorSite site, IServerEditorPartInput input); -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/provisional/UIDecorator.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/provisional/UIDecorator.java deleted file mode 100644 index 72820ca2b..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/provisional/UIDecorator.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005,2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.provisional; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.server.ui.internal.ImageResource; -import org.eclipse.wst.server.ui.internal.Messages; - -public abstract class UIDecorator { - public static final int ACTION_STOP = 0; - - /** - * Returns a string representing the given state. - * - * @param state a server state - * @param mode a launch mode - * @param count a timer count - * @return java.lang.String - */ - public abstract String getStateLabel(int state, String mode, int count); - - /** - * Returns an image representing the given state. - * - * @param state a server state - * @param mode a launch mode - * @param count a timer count - * @return org.eclipse.jface.parts.IImage - */ - public abstract Image getStateImage(int state, String mode, int count); - - public ImageDescriptor getStateImageDescriptor(int state, String mode, int count){ - return null; - } - - public String getModuleName() { - return "module"; - } - - public boolean canRestart() { - return false; - } - - public void setupAction(Action action, int action2) { - action.setToolTipText(Messages.actionStopToolTip); - action.setText(Messages.actionStop); - action.setImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_ELCL_STOP)); - action.setHoverImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_CLCL_STOP)); - action.setDisabledImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_DLCL_STOP)); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/provisional/UIDecoratorManager.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/provisional/UIDecoratorManager.java deleted file mode 100644 index 036d7f324..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/provisional/UIDecoratorManager.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005,2009 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.server.ui.internal.provisional; - -import org.eclipse.wst.server.core.IServerType; -import org.eclipse.wst.server.ui.internal.cnf.CNFManagedUIDecorator; - -public class UIDecoratorManager { - protected static UIDecorator decorator = new ManagedUIDecorator(); - protected static UIDecorator decorator2 = new CNFManagedUIDecorator(); - - public static UIDecorator getUIDecorator(IServerType serverType) { - return decorator; - } - - public static UIDecorator getCNFUIDecorator(IServerType serverType) { - return decorator2; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/AbstractServerAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/AbstractServerAction.java deleted file mode 100644 index 1899f5406..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/AbstractServerAction.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.view.servers; - -import java.util.Iterator; - -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.actions.SelectionProviderAction; - -import org.eclipse.wst.server.core.IServer; -/** - * An abstract class for an action on a server. - */ -public abstract class AbstractServerAction extends SelectionProviderAction { - protected Shell shell; - - public AbstractServerAction(ISelectionProvider selectionProvider, String text) { - this(null, selectionProvider, text); - } - - public AbstractServerAction(Shell shell, ISelectionProvider selectionProvider, String text) { - super(selectionProvider, text); - this.shell = shell; - setEnabled(false); - } - - /** - * Return true if this server can currently be acted on. - * - * @return boolean - * @param server a server - */ - public boolean accept(IServer server) { - return true; - } - - /** - * Perform action on this server. - * - * @param server a server - */ - public abstract void perform(IServer server); - - public void run() { - Iterator iterator = getStructuredSelection().iterator(); - Object obj = iterator.next(); - if (obj instanceof IServer) { - IServer server = (IServer) obj; - if (accept(server)) - perform(server); - selectionChanged(getStructuredSelection()); - } - } - - /** - * Update the enabled state. - * - * @param sel a selection - */ - public void selectionChanged(IStructuredSelection sel) { - if (sel.isEmpty()) { - setEnabled(false); - return; - } - boolean enabled = false; - Iterator iterator = sel.iterator(); - while (iterator.hasNext()) { - Object obj = iterator.next(); - if (obj instanceof IServer) { - IServer server = (IServer) obj; - if (accept(server)) - enabled = true; - } else { - setEnabled(false); - return; - } - } - setEnabled(enabled); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/CopyAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/CopyAction.java deleted file mode 100644 index 79cff129f..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/CopyAction.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.view.servers; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.swt.dnd.Clipboard; -import org.eclipse.swt.dnd.TextTransfer; -import org.eclipse.swt.dnd.Transfer; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.ui.internal.Messages; -/** - * "Copy" menu action. - */ -public class CopyAction extends AbstractServerAction { - protected Action pasteAction; - private Clipboard clipboard; - - /** - * CopyAction constructor. - * - * @param sp a selection provider - * @param clipboard the clipboard - * @param pasteAction the paste action - */ - public CopyAction(ISelectionProvider sp, Clipboard clipboard, Action pasteAction) { - super(sp, Messages.actionCopy); - ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages(); - setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY)); - setDisabledImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED)); - setActionDefinitionId(IWorkbenchActionDefinitionIds.COPY); - - this.clipboard = clipboard; - this.pasteAction = pasteAction; - } - - public boolean accept(IServer server) { - return server != null && server.getServerType() != null; - } - - public void perform(IServer server) { - clipboard.setContents(new Object[] { new IServer[] { server }, server.getName() }, - new Transfer[] { ServerTransfer.getInstance(), TextTransfer.getInstance() }); - pasteAction.setEnabled(true); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/DeleteAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/DeleteAction.java deleted file mode 100644 index 43bf11eaf..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/DeleteAction.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.view.servers; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IFolder; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.ServerCore; -import org.eclipse.wst.server.ui.internal.DeleteServerDialog; -import org.eclipse.wst.server.ui.internal.Messages; -import org.eclipse.swt.widgets.Shell; -/** - * Action for deleting server resources. - */ -public class DeleteAction extends AbstractServerAction { - protected IServer[] servers; - protected IFolder[] configs; - - /** - * DeleteAction constructor. - * - * @param shell a shell - * @param sp a selection provider - */ - public DeleteAction(Shell shell, ISelectionProvider sp) { - super(shell, sp, Messages.actionDelete); - ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages(); - setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE)); - setDisabledImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED)); - setActionDefinitionId(IWorkbenchActionDefinitionIds.DELETE); - } - - public boolean accept(IServer server) { - servers = new IServer[] { server }; - List<IFolder> list = new ArrayList<IFolder>(); - - int size = servers.length; - for (int i = 0; i < size; i++) { - if (servers[i].isReadOnly()) - return false; - - if (servers[i].getServerConfiguration() != null) - list.add(servers[i].getServerConfiguration()); - } - - // remove configurations that are still referenced by other servers - IServer[] servers2 = ServerCore.getServers(); - if (servers2 != null) { - int size2 = servers2.length; - for (int j = 0; j < size2; j++) { - boolean found = false; - for (int i = 0; i < size; i++) { - if (servers[i].equals(servers2[j])) - found = true; - } - if (!found) { - IFolder folder = servers2[j].getServerConfiguration(); - if (folder != null && list.contains(folder)) - list.remove(folder); - } - } - } - - configs = new IFolder[list.size()]; - list.toArray(configs); - return true; - } - - public void perform(IServer server) { - DeleteServerDialog dsd = new DeleteServerDialog(shell, servers, configs); - dsd.open(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ModuleServer.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ModuleServer.java deleted file mode 100644 index bdffa04f5..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ModuleServer.java +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.view.servers; - -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.ui.IServerModule; -/** - * A utility class for referencing a server and a module at the same time. - */ -public class ModuleServer implements IServerModule { - /** - * The server - */ - public IServer server; - - /** - * The module - */ - public IModule[] module; - - /** - * Create a new module-server. - * - * @param server the server - * @param module the module - */ - public ModuleServer(IServer server, IModule[] module) { - this.server = server; - this.module = module; - if (module == null) - throw new IllegalArgumentException(); - } - - /** - * Return the server that the module belongs to. - * - * @return the server - */ - public IServer getServer() { - return server; - } - - /** - * Returns the module. - * - * @return the module - */ - public IModule[] getModule() { - return module; - } - - /** - * @see Object#equals(Object) - */ - public boolean equals(Object obj) { - if (!(obj instanceof ModuleServer)) - return false; - - ModuleServer ms = (ModuleServer) obj; - - if (ms.server == null && server != null) - return false; - - if (ms.server != null && !ms.server.equals(server)) - return false; - - if (ms.module.length != module.length) - return false; - - int size = module.length; - for (int i = 0; i < size; i++) { - if (!module[i].equals(ms.module[i])) - return false; - } - return true; - } - - /** - * @see Object#toString() - */ - public String toString() { - StringBuffer sb = new StringBuffer(); - if (server != null) - sb.append("Server-Module [" + server.getId() + "/" + server.getName() + ", ("); - else - sb.append("Server-Module [null, ("); - - int size = module.length; - for (int i = 0; i < size; i++) { - if (i > 0) - sb.append(", "); - sb.append(module[i].getName()); - } - sb.append(")]"); - return sb.toString(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ModuleSloshAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ModuleSloshAction.java deleted file mode 100644 index 029d0717c..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ModuleSloshAction.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.view.servers; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.swt.widgets.Shell; - -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.ServerUtil; -import org.eclipse.wst.server.ui.internal.ImageResource; -import org.eclipse.wst.server.ui.internal.Messages; -import org.eclipse.wst.server.ui.internal.wizard.ModifyModulesWizard; -/** - * - */ -public class ModuleSloshAction extends AbstractServerAction { - public ModuleSloshAction(Shell shell, ISelectionProvider selectionProvider) { - super(shell, selectionProvider, Messages.actionModifyModules); - setToolTipText(Messages.actionModifyModulesToolTip); - setImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_ETOOL_MODIFY_MODULES)); - setHoverImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_CTOOL_MODIFY_MODULES)); - setDisabledImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_DTOOL_MODIFY_MODULES)); - } - - /** - * Return true if this server can currently be acted on. - * @return boolean - * @param server a server - */ - public boolean accept(IServer server) { - return server.getServerType() != null; - } - - /** - * Perform action on this server. - * @param server a server - */ - public void perform(final IServer server) { - if (server == null) - return; - - // check if there are any modules first - // get currently deployed modules - List<IModule> deployed = new ArrayList<IModule>(); - List<IModule> modules = new ArrayList<IModule>(); - IModule[] currentModules = server.getModules(); - if (currentModules != null) { - int size = currentModules.length; - for (int i = 0; i < size; i++) { - deployed.add(currentModules[i]); - } - } - - // get remaining modules - IModule[] modules2 = ServerUtil.getModules(server.getServerType().getRuntimeType().getModuleTypes()); - if (modules2 != null) { - int size = modules2.length; - for (int i = 0; i < size; i++) { - IModule module = modules2[i]; - if (!deployed.contains(module)) { - IStatus status = server.canModifyModules(new IModule[] { module }, null, null); - if (status != null && status.getSeverity() != IStatus.ERROR) - modules.add(module); - } - } - } - - if (deployed.isEmpty() && modules.isEmpty()) { - MessageDialog.openInformation(shell, Messages.defaultDialogTitle, Messages.dialogAddRemoveModulesNone); - return; - } - - ModifyModulesWizard wizard = new ModifyModulesWizard(server); - WizardDialog dialog = new WizardDialog(shell, wizard); - dialog.open(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/MonitorPropertyPage.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/MonitorPropertyPage.java deleted file mode 100644 index df9c3f2f9..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/MonitorPropertyPage.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.view.servers; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jface.dialogs.Dialog; - -import org.eclipse.ui.dialogs.PropertyPage; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.ui.internal.Messages; -import org.eclipse.wst.server.ui.internal.viewers.MonitorComposite; -import org.eclipse.osgi.util.NLS; -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.Control; -import org.eclipse.swt.widgets.Label; -/** - * Preference page that allows a user to monitor ports from a server. - */ -public class MonitorPropertyPage extends PropertyPage { - protected IServer server; - protected MonitorComposite monitorComp; - - /** - * MonitorPropertyPage constructor comment. - */ - public MonitorPropertyPage() { - super(); - } - - /** - * Create the body of the page. - * - * @param parent org.eclipse.swt.widgets.Composite - * @return org.eclipse.swt.widgets.Control - */ - protected Control createContents(Composite parent) { - IAdaptable element = getElement(); - server = (IServer) element.getAdapter(IServer.class); - - // create a composite with standard margins and spacing - Composite composite = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.marginHeight = 0; - layout.marginWidth = 0; - composite.setLayout(layout); - GridData data = new GridData(GridData.FILL_BOTH); - data.widthHint = 550; - composite.setLayoutData(data); - composite.setFont(parent.getFont()); - //WorkbenchHelp.setHelp(composite, ContextIds.TERMINATE_SERVER_DIALOG); - - Label label = new Label(composite, SWT.WRAP); - label.setText(NLS.bind(Messages.dialogMonitorDescription, new String[] { server.getName() } )); - data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - label.setLayoutData(data); - - monitorComp = new MonitorComposite(composite, SWT.NONE, null, server); - monitorComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL)); - - Dialog.applyDialogFont(composite); - - return composite; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/MonitorServerPortAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/MonitorServerPortAction.java deleted file mode 100644 index d63b630af..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/MonitorServerPortAction.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.view.servers; - -import org.eclipse.jface.action.Action; - -import org.eclipse.wst.server.core.*; -import org.eclipse.wst.server.core.internal.IMonitoredServerPort; -import org.eclipse.wst.server.core.internal.IServerMonitorManager; -import org.eclipse.wst.server.core.internal.ServerMonitorManager; -import org.eclipse.wst.server.ui.internal.Messages; -import org.eclipse.wst.server.ui.internal.Trace; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.widgets.Shell; -/** - * Monitor a server port. - */ -public class MonitorServerPortAction extends Action { - protected Shell shell; - protected IServer server; - protected ServerPort port; - protected IMonitoredServerPort monitoredPort; - protected boolean checked; - - public MonitorServerPortAction(Shell shell, IServer server, ServerPort port) { - super(NLS.bind(Messages.actionMonitorPort, new String[] { port.getPort() + "", port.getName() })); - - this.shell = shell; - this.server = server; - this.port = port; - - IMonitoredServerPort[] msps = ServerMonitorManager.getInstance().getMonitoredPorts(server); - if (msps != null) { - int size = msps.length; - for (int i = 0; i < size; i++) { - if (port.equals(msps[i].getServerPort()) && // msps[i].isStarted() && - (msps[i].getContentTypes() == null || msps[i].getContentTypes().length == 0 || - (port.getContentTypes() != null && msps[i].getContentTypes().length == port.getContentTypes().length))) - monitoredPort = msps[i]; - } - } - - checked = monitoredPort != null; // && monitoredPort.isStarted(); - setChecked(checked); - } - - /** - * Enable or disable monitoring. - */ - public void run() { - IServerMonitorManager smm = ServerMonitorManager.getInstance(); - if (checked) { - smm.removeMonitor(monitoredPort); - } else { - if (monitoredPort == null) - monitoredPort = smm.createMonitor(server, port, -1, null); - - try { - smm.startMonitor(monitoredPort); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Could not monitor", e); - } - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/OpenAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/OpenAction.java deleted file mode 100644 index a1155f2fc..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/OpenAction.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.view.servers; - -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.ui.internal.Messages; -import org.eclipse.wst.server.ui.internal.ServerUIPlugin; -import org.eclipse.wst.server.ui.internal.Trace; -/** - * "Open" menu action. - */ -public class OpenAction extends AbstractServerAction { - /** - * OpenAction constructor. - * - * @param sp a selection provider - */ - public OpenAction(ISelectionProvider sp) { - super(sp, Messages.actionOpen); - - //setActionDefinitionId("org.eclipse.ui.navigator.Open"); - setActionDefinitionId("org.eclipse.jdt.ui.edit.text.java.open.editor"); - } - - public void perform(IServer server) { - try { - ServerUIPlugin.editServer(server); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error editing element", e); - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/PasteAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/PasteAction.java deleted file mode 100644 index 5f31880e5..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/PasteAction.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007,2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.view.servers; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.dnd.Clipboard; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.SelectionProviderAction; -import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.IServerWorkingCopy; -import org.eclipse.wst.server.core.ServerUtil; -import org.eclipse.wst.server.core.internal.ServerWorkingCopy; -import org.eclipse.wst.server.ui.internal.Messages; -import org.eclipse.wst.server.ui.internal.Trace; -/** - * "Paste" menu action. - */ -public class PasteAction extends SelectionProviderAction { - private Clipboard clipboard; - - /** - * PasteAction constructor. - * - * @param shell a shell; - * @param sp a selection provider - * @param clipboard the clipboard - */ - public PasteAction(Shell shell, ISelectionProvider sp, Clipboard clipboard) { - super(sp, Messages.actionPaste); - ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages(); - setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE)); - setDisabledImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED)); - setActionDefinitionId(IWorkbenchActionDefinitionIds.PASTE); - - this.clipboard = clipboard; - } - - /** - * Update the enabled state. - * - * @param sel a selection - */ - public void selectionChanged(IStructuredSelection sel) { - ServerTransfer serverTransfer = ServerTransfer.getInstance(); - IServer[] servers = (IServer[]) clipboard.getContents(serverTransfer); - setEnabled(servers != null && servers.length > 0); - } - - /** - * Implementation of method defined on <code>IAction</code>. - */ - public void run() { - ServerTransfer serverTransfer = ServerTransfer.getInstance(); - IServer[] servers = (IServer[]) clipboard.getContents(serverTransfer); - - if (servers == null) - return; - - int size = servers.length; - for (int i = 0; i < size; i++) { - try { - IServerWorkingCopy wc = servers[i].createWorkingCopy(); - ((ServerWorkingCopy)wc).disassociate(); - wc.setName("Temp"); // sets the name from the current one so that the - // default name generation will work - ServerUtil.setServerDefaultName(wc); - wc.save(false, null); - } catch (CoreException ce) { - Trace.trace(Trace.SEVERE, "Failure to copy server", ce); - } - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/PropertiesAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/PropertiesAction.java deleted file mode 100644 index 7e0ad9639..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/PropertiesAction.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.view.servers; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.dialogs.PreferencesUtil; -import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds; - -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.ui.internal.Messages; -/** - * Action to show the property page for a server. - */ -public class PropertiesAction extends AbstractServerAction { - protected String propertyPageId; - - public PropertiesAction(Shell shell, ISelectionProvider selectionProvider) { - this(shell, null, selectionProvider); - } - - public PropertiesAction(Shell shell, String propertyPageId, ISelectionProvider selectionProvider) { - super(shell, selectionProvider, Messages.actionProperties); - this.propertyPageId = propertyPageId; - if (propertyPageId == null) - setActionDefinitionId(IWorkbenchActionDefinitionIds.PROPERTIES); - - try { - selectionChanged((IStructuredSelection) selectionProvider.getSelection()); - } catch (Exception e) { - // ignore - } - } - - public void perform(IServer server) { - if (propertyPageId == null) - propertyPageId = "org.eclipse.wst.server.ui.properties"; - Dialog dialog = PreferencesUtil.createPropertyDialogOn(shell, server, propertyPageId, null, null); - dialog.open(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/PublishAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/PublishAction.java deleted file mode 100644 index 5ed16ee8e..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/PublishAction.java +++ /dev/null @@ -1,66 +0,0 @@ -/********************************************************************** - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - **********************************************************************/ -package org.eclipse.wst.server.ui.internal.view.servers; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.ui.internal.ImageResource; -import org.eclipse.wst.server.ui.internal.Messages; -import org.eclipse.wst.server.ui.internal.ServerUIPlugin; -import org.eclipse.swt.widgets.Shell; -/** - * Publish to a server. - */ -public class PublishAction extends AbstractServerAction { - public PublishAction(Shell shell, ISelectionProvider selectionProvider) { - super(shell, selectionProvider, Messages.actionPublish); - setToolTipText(Messages.actionPublishToolTip); - setImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_ELCL_PUBLISH)); - setHoverImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_CLCL_PUBLISH)); - setDisabledImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_DLCL_PUBLISH)); - setActionDefinitionId("org.eclipse.wst.server.publish"); - try { - selectionChanged((IStructuredSelection) selectionProvider.getSelection()); - } catch (Exception e) { - // ignore - } - } - - public boolean accept(IServer server) { - return server.canPublish().isOK(); - } - - public void perform(IServer server) { - publish(server, shell); - } - - public static void publish(IServer server, final Shell shell) { - if (shell != null && !ServerUIPlugin.promptIfDirty(shell, server)) - return; - - if (!ServerUIPlugin.saveEditors()) - return; - - IAdaptable info = new IAdaptable() { - public Object getAdapter(Class adapter) { - if (Shell.class.equals(adapter)) - return shell; - if (String.class.equals(adapter)) - return "user"; - return null; - } - }; - - server.publish(IServer.PUBLISH_INCREMENTAL, null, info, null); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/PublishCleanAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/PublishCleanAction.java deleted file mode 100644 index 442e0e3f8..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/PublishCleanAction.java +++ /dev/null @@ -1,69 +0,0 @@ -/********************************************************************** - * Copyright (c) 2007, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - **********************************************************************/ -package org.eclipse.wst.server.ui.internal.view.servers; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.ui.internal.Messages; -import org.eclipse.wst.server.ui.internal.ServerUIPlugin; -import org.eclipse.swt.widgets.Shell; -/** - * Clean publish to a server. - */ -public class PublishCleanAction extends AbstractServerAction { - public PublishCleanAction(Shell shell, ISelectionProvider selectionProvider) { - super(shell, selectionProvider, Messages.actionPublishClean); - setToolTipText(Messages.actionPublishCleanToolTip); - try { - selectionChanged((IStructuredSelection) selectionProvider.getSelection()); - } catch (Exception e) { - // ignore - } - } - - /** - * Return true if this server can currently be acted on. - * @return boolean - * @param server a server - */ - public boolean accept(IServer server) { - return server.canPublish().isOK(); - } - - /** - * Perform action on this server. - * @param server a server - */ - public void perform(IServer server) { - if (!ServerUIPlugin.promptIfDirty(shell, server)) - return; - - if (!ServerUIPlugin.saveEditors()) - return; - - if (MessageDialog.openConfirm(shell, Messages.defaultDialogTitle, Messages.dialogPublishClean)) { - IAdaptable info = new IAdaptable() { - public Object getAdapter(Class adapter) { - if (Shell.class.equals(adapter)) - return shell; - if (String.class.equals(adapter)) - return "user"; - return null; - } - }; - - server.publish(IServer.PUBLISH_CLEAN, null, info, null); - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/RemoveModuleAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/RemoveModuleAction.java deleted file mode 100644 index 756ba364e..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/RemoveModuleAction.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.view.servers; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.IServerWorkingCopy; -import org.eclipse.wst.server.ui.internal.Messages; -import org.eclipse.wst.server.ui.internal.ServerUIPlugin; -import org.eclipse.wst.server.ui.internal.Trace; -import org.eclipse.swt.widgets.Shell; -/** - * Action for removing a module from a server. - */ -public class RemoveModuleAction extends Action { - protected IServer server; - protected IModule module; - protected Shell shell; - - /** - * RemoveModuleAction constructor. - * - * @param shell a shell - * @param server a server - * @param module a module - */ - public RemoveModuleAction(Shell shell, IServer server, IModule module) { - super(Messages.actionRemove); - this.shell = shell; - - this.server = server; - this.module = module; - } - - /** - * Invoked when an action occurs. - */ - public void run() { - if (MessageDialog.openConfirm(shell, Messages.defaultDialogTitle, Messages.dialogRemoveModuleConfirm)) { - try { - IServerWorkingCopy wc = server.createWorkingCopy(); - wc.modifyModules(null, new IModule[] { module }, null); - server = wc.save(true, null); - - if (server.getServerState() != IServer.STATE_STOPPED && - ServerUIPlugin.getPreferences().getPublishOnAddRemoveModule()) { - final IAdaptable info = new IAdaptable() { - public Object getAdapter(Class adapter) { - if (Shell.class.equals(adapter)) - return shell; - return null; - } - }; - server.publish(IServer.PUBLISH_INCREMENTAL, null, info, null); - } - } catch (Exception e) { - Trace.trace(Trace.WARNING, "Could not remove module", e); - } - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/RenameAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/RenameAction.java deleted file mode 100644 index 1fd8de5ef..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/RenameAction.java +++ /dev/null @@ -1,288 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.view.servers; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.TreeEditor; -import org.eclipse.swt.events.FocusAdapter; -import org.eclipse.swt.events.FocusEvent; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; -import org.eclipse.swt.widgets.Tree; -import org.eclipse.swt.widgets.TreeItem; -import org.eclipse.ui.actions.TextActionHandler; -import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds; - -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.IServerWorkingCopy; -import org.eclipse.wst.server.core.internal.ServerPlugin; -import org.eclipse.wst.server.ui.internal.Messages; -/** - * Action to rename a server. - */ -public class RenameAction extends AbstractServerAction { - /* - * The tree editing widgets. If treeEditor is null then edit using the - * dialog. We keep the editorText around so that we can close it if a new - * selection is made. - */ - protected TreeEditor treeEditor; - - protected Tree tree; - - protected Text textEditor; - - protected Composite textEditorParent; - - private TextActionHandler textActionHandler; - - // The server being edited if this is being done inline - protected IServer editedServer; - - protected boolean saving = false; - - public RenameAction(Shell shell, TreeViewer viewer, ISelectionProvider selectionProvider) { - super(shell, selectionProvider, Messages.actionRename); - setActionDefinitionId(IWorkbenchActionDefinitionIds.RENAME); - this.tree = viewer.getTree(); - this.treeEditor = new TreeEditor(tree); - try { - selectionChanged((IStructuredSelection) selectionProvider.getSelection()); - } catch (Exception e) { - // ignore - } - } - - public void perform(IServer server) { - runWithInlineEditor(server); - } - - /* - * Run the receiver using an inline editor from the supplied navigator. The - * navigator will tell the action when the path is ready to run. - */ - private void runWithInlineEditor(IServer server) { - queryNewServerNameInline(server); - } - - /** - * On Mac the text widget already provides a border when it has focus, so - * there is no need to draw another one. The value of returned by this - * method is usd to control the inset we apply to the text field bound's in - * order to get space for drawing a border. A value of 1 means a one-pixel - * wide border around the text field. A negative value supresses the border. - * However, in M9 the system property - * "org.eclipse.swt.internal.carbon.noFocusRing" has been introduced as a - * temporary workaround for bug #28842. The existence of the property turns - * the native focus ring off if the widget is contained in a main window - * (not dialog). The check for the property should be removed after a final - * fix for #28842 has been provided. - */ - private static int getCellEditorInset(Control c) { - // special case for MacOS X - if ("carbon".equals(SWT.getPlatform())) { //$NON-NLS-1$ - if (System - .getProperty("org.eclipse.swt.internal.carbon.noFocusRing") == null || c.getShell().getParent() != null) { //$NON-NLS-1$ - return -2; // native border - } - } - return 1; // one pixel wide black border - } - - /** - * Get the Tree being edited. - * - * @returnTree - */ - private Tree getTree() { - return tree; - } - - private Composite createParent() { - Tree tree2 = getTree(); - Composite result = new Composite(tree2, SWT.NONE); - TreeItem[] selectedItems = tree2.getSelection(); - treeEditor.horizontalAlignment = SWT.LEFT; - treeEditor.grabHorizontal = true; - treeEditor.setEditor(result, selectedItems[0]); - return result; - } - - /** - * Return the new name to be given to the target resource or - * <code>null<code> - * if the query was canceled. Rename the currently selected server using the table editor. - * Continue the action when the user is done. - * - * @param server the server to rename - */ - private void queryNewServerNameInline(final IServer server) { - // Make sure text editor is created only once. Simply reset text - // editor when action is executed more than once. Fixes bug 22269 - if (textEditorParent == null) { - createTextEditor(server); - } - textEditor.setText(server.getName()); - - // Open text editor with initial size - textEditorParent.setVisible(true); - Point textSize = textEditor.computeSize(SWT.DEFAULT, SWT.DEFAULT); - textSize.x += textSize.y; // Add extra space for new characters - Point parentSize = textEditorParent.getSize(); - int inset = getCellEditorInset(textEditorParent); - textEditor.setBounds(2, inset, Math.min(textSize.x, parentSize.x - 4), - parentSize.y - 2 * inset); - textEditorParent.redraw(); - textEditor.selectAll(); - textEditor.setFocus(); - } - - /** - * Create the text editor widget. - * - * @param server the server to rename - */ - private void createTextEditor(final IServer server) { - // Create text editor parent. This draws a nice bounding rect - textEditorParent = createParent(); - textEditorParent.setVisible(false); - final int inset = getCellEditorInset(textEditorParent); - if (inset > 0) { - textEditorParent.addListener(SWT.Paint, new Listener() { - public void handleEvent(Event e) { - Point textSize = textEditor.getSize(); - Point parentSize = textEditorParent.getSize(); - e.gc.drawRectangle(0, 0, Math.min(textSize.x + 4, - parentSize.x - 1), parentSize.y - 1); - } - }); - } - // Create inner text editor - textEditor = new Text(textEditorParent, SWT.NONE); - textEditor.setFont(tree.getFont()); - textEditorParent.setBackground(textEditor.getBackground()); - textEditor.addListener(SWT.Modify, new Listener() { - public void handleEvent(Event e) { - Point textSize = textEditor.computeSize(SWT.DEFAULT, - SWT.DEFAULT); - textSize.x += textSize.y; // Add extra space for new - // characters. - Point parentSize = textEditorParent.getSize(); - textEditor.setBounds(2, inset, Math.min(textSize.x, - parentSize.x - 4), parentSize.y - 2 * inset); - textEditorParent.redraw(); - } - }); - textEditor.addListener(SWT.Traverse, new Listener() { - public void handleEvent(Event event) { - - // Workaround for Bug 20214 due to extra - // traverse events - switch (event.detail) { - case SWT.TRAVERSE_ESCAPE: - // Do nothing in this case - disposeTextWidget(); - event.doit = true; - event.detail = SWT.TRAVERSE_NONE; - break; - case SWT.TRAVERSE_RETURN: - saveChangesAndDispose(server); - event.doit = true; - event.detail = SWT.TRAVERSE_NONE; - break; - } - } - }); - textEditor.addFocusListener(new FocusAdapter() { - public void focusLost(FocusEvent fe) { - saveChangesAndDispose(server); - } - }); - - if (textActionHandler != null) { - textActionHandler.addText(textEditor); - } - } - - /** - * Close the text widget and reset the editorText field. - */ - protected void disposeTextWidget() { - if (textActionHandler != null) - textActionHandler.removeText(textEditor); - - if (textEditorParent != null) { - textEditorParent.dispose(); - textEditorParent = null; - textEditor = null; - treeEditor.setEditor(null, null); - } - } - - /** - * Save the changes and dispose of the text widget. - * - * @param server the server to rename - */ - protected void saveChangesAndDispose(IServer server) { - if (saving == true) - return; - - saving = true; - // Cache the resource to avoid selection loss since a selection of - // another item can trigger this method - editedServer = server; - final String newName = textEditor.getText(); - // Run this in an async to make sure that the operation that triggered - // this action is completed. Otherwise this leads to problems when the - // icon of the item being renamed is clicked (i.e., which causes the - // rename text widget to lose focus and trigger this method) - getTree().getShell().getDisplay().asyncExec(new Runnable() { - public void run() { - try { - if (!newName.equals(editedServer.getName())) { - if (ServerPlugin.isNameInUse(editedServer, newName)) { - MessageDialog.openError(shell, Messages.defaultDialogTitle, Messages.errorDuplicateName); - } else { - try { - IServerWorkingCopy wc = editedServer.createWorkingCopy(); - wc.setName(newName); - wc.save(false, null); - } catch (CoreException ce) { - // ignore for now - } - } - } - editedServer = null; - // Dispose the text widget regardless - disposeTextWidget(); - // Ensure the Navigator tree has focus, which it may not if - // the text widget previously had focus - if (tree != null && !tree.isDisposed()) { - tree.setFocus(); - } - } finally { - saving = false; - } - } - }); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/RestartModuleAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/RestartModuleAction.java deleted file mode 100644 index 662f8a2cb..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/RestartModuleAction.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.view.servers; - -import org.eclipse.jface.action.Action; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.ui.internal.Messages; -/** - * Restart a module on a server. - */ -public class RestartModuleAction extends Action { - protected IServer server; - protected IModule[] module; - - public RestartModuleAction(IServer server, IModule[] module) { - super(); - this.server = server; - this.module = module; - - setText(Messages.actionRestartModule); - - setEnabled(server.getServerState() == IServer.STATE_STARTED - && server.getModuleState(module) != IServer.STATE_UNKNOWN - && server.canControlModule(module, null).isOK()); - } - - /** - * Implementation of method defined on <code>IAction</code>. - */ - public void run() { - server.restartModule(module, null); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerActionHandler.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerActionHandler.java deleted file mode 100644 index 656553a57..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerActionHandler.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.view.servers; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.debug.core.ILaunchManager; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.handlers.HandlerUtil; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.ui.internal.actions.RunOnServerActionDelegate; -/** - * Server action handler. - */ -public class ServerActionHandler extends AbstractHandler { - public Object execute(ExecutionEvent event) throws ExecutionException { - ISelection sel = HandlerUtil.getCurrentSelectionChecked(event); - Object obj = null; - if (sel instanceof IStructuredSelection) { - IStructuredSelection select = (IStructuredSelection) sel; - obj = select.getFirstElement(); - } - - String id = event.getCommand().getId(); - if (id.endsWith("publish")) { - if (obj instanceof IServer) { - PublishAction.publish((IServer) obj, HandlerUtil.getActiveShell(event)); - } else - throw new ExecutionException("No server selected"); - return null; - } - - String mode = ILaunchManager.RUN_MODE; - if (id.endsWith("debug")) - mode = ILaunchManager.DEBUG_MODE; - else if (id.endsWith("profile")) - mode = ILaunchManager.PROFILE_MODE; - else if (id.endsWith("stop")) - mode = null; - - if (obj instanceof IServer) { - IServer server = (IServer) obj; - if (mode == null) - StopAction.stop(server, HandlerUtil.getActiveShell(event)); - else - StartAction.start(server, mode, HandlerUtil.getActiveShell(event)); - return null; - } - - RunOnServerActionDelegate ros = new RunOnServerActionDelegate(); - ros.setLaunchMode(mode); - IAction action = new Action() { - // dummy action - }; - ros.selectionChanged(action, sel); - ros.run(action); - - return null; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerTableLabelProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerTableLabelProvider.java deleted file mode 100644 index 34f7733ff..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerTableLabelProvider.java +++ /dev/null @@ -1,322 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.view.servers; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.IServerType; -import org.eclipse.wst.server.core.internal.Server; -import org.eclipse.wst.server.ui.ServerUICore; -import org.eclipse.wst.server.ui.internal.ImageResource; -import org.eclipse.wst.server.ui.internal.Messages; -import org.eclipse.wst.server.ui.internal.ServerUIPlugin; -import org.eclipse.wst.server.ui.internal.provisional.UIDecoratorManager; -import org.eclipse.wst.server.ui.internal.viewers.BaseCellLabelProvider; -import org.eclipse.wst.server.ui.internal.viewers.ServerTreeContentProvider; -import org.eclipse.swt.graphics.Image; -/** - * Server table label provider. - */ -public class ServerTableLabelProvider extends BaseCellLabelProvider { - public static final String[] syncState = new String[] { - Messages.viewSyncOkay, - Messages.viewSyncRestart, - Messages.viewSyncPublish, - Messages.viewSyncRestartPublish, - Messages.viewSyncPublishing}; - - public static final String[] syncStateUnmanaged = new String[] { - Messages.viewSyncOkay2, - Messages.viewSyncRestart2, - Messages.viewSyncPublish2, - Messages.viewSyncRestartPublish2, - Messages.viewSyncPublishing2}; - - private static final String[] modulePublishState = new String[] { - "", - Messages.viewSyncOkay, - Messages.viewSyncPublish, - Messages.viewSyncPublish}; - - private int count = 0; - - protected IServer defaultServer; - - /** - * ServerTableLabelProvider constructor comment. - */ - public ServerTableLabelProvider() { - // Ensure decorator is initialized. - super(null); - } - - public void setDefaultServer(IServer ds) { - defaultServer = ds; - } - - public IServer getDefaultServer() { - return defaultServer; - } - - public Image getColumnImage(Object element, int columnIndex) { - if (element instanceof ServerTreeContentProvider.TreeElement) { - if (columnIndex == 0) { - ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages(); - return sharedImages.getImage(ISharedImages.IMG_OBJ_FOLDER); - } - return null; - } - if (element instanceof ModuleServer) { - ModuleServer ms = (ModuleServer) element; - if (columnIndex == 0) { - //return ServerUICore.getLabelProvider().getImage(ms.module[ms.module.length - 1]); - ILabelProvider labelProvider = ServerUICore.getLabelProvider(); - Image image = labelProvider.getImage(ms.module[ms.module.length - 1]); - labelProvider.dispose(); - if (decorator != null) { - Image dec = decorator.decorateImage(image, ms); - if (dec != null) - return dec; - } - return image; - } else if (columnIndex == 1) { - if (ms.server == null) - return null; - - /*int state = ms.server.getModuleState(ms.module); - if (state == IServer.STATE_STARTED) - return ImageResource.getImage(ImageResource.IMG_STATE_STARTED); - else if (state == IServer.STATE_STOPPED) - return ImageResource.getImage(ImageResource.IMG_STATE_STOPPED); - */ - return getStateImage(ms.server.getServerType(), ms.server.getModuleState(ms.module), null); - } else if (columnIndex == 2) { - IStatus status = ((Server) ms.server).getModuleStatus(ms.module); - if (status != null) { - ISharedImages sharedImages = ServerUIPlugin.getInstance().getWorkbench().getSharedImages(); - if (status.getSeverity() == IStatus.ERROR) - return sharedImages.getImage(ISharedImages.IMG_OBJS_ERROR_TSK); - else if (status.getSeverity() == IStatus.WARNING) - return sharedImages.getImage(ISharedImages.IMG_OBJS_WARN_TSK); - else if (status.getSeverity() == IStatus.INFO) - return sharedImages.getImage(ISharedImages.IMG_OBJS_INFO_TSK); - } - } - return null; - } - IServer server = (IServer) element; - if (columnIndex == 0) { - if (server.getServerType() != null) { - Image image = ImageResource.getImage(server.getServerType().getId()); - /*IStatus status = ((Server) server).getServerStatus(); - if (defaultServer != null && defaultServer.equals(server) || status != null) { - Image decorated = decorator.decorateImage(image, element); - if (decorated != null) - return decorated; - }*/ - //return image; - if (decorator != null) { - Image dec = decorator.decorateImage(image, server); - if (dec != null) - return dec; - } - return image; - } - return null; - } else if (columnIndex == 1) { - IServerType serverType = server.getServerType(); - if (serverType == null) - return null; - //if (serverType.getServerStateSet() == IServerType.SERVER_STATE_SET_PUBLISHED) - // return null; - return getServerStateImage(server); - } else - return null; - } - - public String getText(Object element) { - return getColumnText(element, 0); - } - - public String getColumnText(Object element, int columnIndex) { - if (element instanceof ServerTreeContentProvider.TreeElement) { - if (columnIndex == 0) - return ((ServerTreeContentProvider.TreeElement) element).text; - return ""; - } - if (element instanceof ModuleServer) { - ModuleServer ms = (ModuleServer) element; - if (columnIndex == 0) { - if (ms.module == null) - return ""; - int size = ms.module.length; - String name = ms.module[size - 1].getName(); - if (decorator != null) { - String dec = decorator.decorateText(name, ms); - if (dec != null) - return dec; - } - return name; - } else if (columnIndex == 1) { - if (ms.server == null) - return ""; - return getStateLabel(ms.server.getServerType(), ms.server.getModuleState(ms.module), null); - } else if (columnIndex == 2) { - IStatus status = ((Server) ms.server).getModuleStatus(ms.module); - if (status != null) - return status.getMessage(); - - return modulePublishState[ms.server.getModulePublishState(ms.module)]; - } - } - IServer server = (IServer) element; - if (columnIndex == 0) - return notNull(server.getName()); - else if (columnIndex == 1) { - IServerType serverType = server.getServerType(); - if (serverType != null) - return getServerStateLabel(server); - - return ""; - } else if (columnIndex == 2) { - IStatus status = ((Server) server).getServerStatus(); - if (status != null) - return status.getMessage(); - - if (server.getServerType() == null) - return ""; - - //if (server.getServerType().hasServerConfiguration() && server.getServerConfiguration() == null) - // return Messages.viewNoConfiguration"); - - if (server.getServerState() == IServer.STATE_UNKNOWN) - return ""; - - String serverId = server.getId(); - if (ServerTableViewer.publishing.contains(serverId)) - return syncState[4]; - - // republish - int i = 0; - if (server.shouldPublish()) { - if (((Server)server).isPublishUnknown()) - return ""; - i += 2; - } - - if (server.shouldRestart()) - i = 1; - - //IServerType serverType = server.getServerType(); - // TODO: state set - //if (serverType.getServerStateSet() == IServerType.SERVER_STATE_SET_MANAGED) - return syncState[i]; - //return syncStateUnmanaged[i]; - } else - return "-"; - } - - protected String notNull(String s) { - if (s == null) - return ""; - return s; - } - - public boolean isLabelProperty(Object element, String property) { - return false; - } - - /** - * Returns an image representing the server's state. - * - * @return org.eclipse.jface.parts.IImage - * @param server org.eclipse.wst.server.core.IServer - */ - protected Image getServerStateImage(IServer server) { - return getStateImage(server.getServerType(), server.getServerState(), server.getMode()); - } - - /** - * Returns an image representing the given state. - * - * @return org.eclipse.jface.parts.IImage - */ - protected Image getStateImage(IServerType serverType, int state, String mode) { - return UIDecoratorManager.getUIDecorator(serverType).getStateImage(state, mode, count); - /*if (state == IServer.STATE_UNKNOWN) - return null; - else if (state == IServer.STATE_STARTING) - return startingImages[count]; - else if (state == IServer.STATE_STOPPING) - return stoppingImages[count]; - else if (state == IServer.STATE_STOPPED) - return ImageResource.getImage(ImageResource.IMG_SERVER_STATE_STOPPED); - else { //if (state == IServer.STATE_STARTED) { - //String mode = server.getMode(); - if (ILaunchManager.DEBUG_MODE.equals(mode)) - return ImageResource.getImage(ImageResource.IMG_SERVER_STATE_STARTED_DEBUG); - else if (ILaunchManager.PROFILE_MODE.equals(mode)) - return ImageResource.getImage(ImageResource.IMG_SERVER_STATE_STARTED_PROFILE); - else - return ImageResource.getImage(ImageResource.IMG_SERVER_STATE_STARTED); - }*/ - } - - /** - * Returns a string representing the server's state. - * - * @return java.lang.String - * @param server org.eclipse.wst.server.core.IServer - */ - protected String getServerStateLabel(IServer server) { - return getStateLabel(server.getServerType(), server.getServerState(), server.getMode()); - } - - /** - * Returns a string representing the given state. - * - * @return java.lang.String - */ - protected String getStateLabel(IServerType serverType, int state, String mode) { - return UIDecoratorManager.getUIDecorator(serverType).getStateLabel(state, mode, count); - /*if (stateSet == IServerType.SERVER_STATE_SET_PUBLISHED) - return ""; - - if (stateSet == IServerType.SERVER_STATE_SET_MANAGED) { - if (state == IServer.STATE_UNKNOWN) - return ""; - else if (state == IServer.STATE_STARTING) - return startingText[count]; - else if (state == IServer.STATE_STOPPING) - return stoppingText[count]; - else if (state == IServer.STATE_STARTED) { - if (ILaunchManager.DEBUG_MODE.equals(mode)) - return Messages.viewStatusStartedDebug"); - else if (ILaunchManager.PROFILE_MODE.equals(mode)) - return Messages.viewStatusStartedProfile"); - else - return Messages.viewStatusStarted"); - } else if (state == IServer.STATE_STOPPED) - return Messages.viewStatusStopped"); - } - - return serverStateUnmanaged[state];*/ - } - - protected void animate() { - count ++; - if (count > 2) - count = 0; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerTableViewer.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerTableViewer.java deleted file mode 100644 index e3a5bb445..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerTableViewer.java +++ /dev/null @@ -1,620 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.view.servers; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.viewers.*; - -import org.eclipse.wst.server.core.*; -import org.eclipse.wst.server.core.internal.Server; -import org.eclipse.wst.server.core.util.PublishAdapter; -import org.eclipse.wst.server.ui.internal.Trace; -import org.eclipse.wst.server.ui.internal.viewers.BaseContentProvider; -import org.eclipse.swt.SWT; -import org.eclipse.swt.dnd.Clipboard; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Item; -import org.eclipse.swt.widgets.Tree; -import org.eclipse.swt.widgets.TreeColumn; -import org.eclipse.swt.widgets.TreeItem; -import org.eclipse.swt.widgets.Widget; -import org.eclipse.ui.PlatformUI; -/** - * Tree view showing servers and their associations. - */ -public class ServerTableViewer extends TreeViewer { - protected static final String ROOT = "root"; - protected static Color color; - protected static Font font; - protected Clipboard clipboard; - - protected IServerLifecycleListener serverResourceListener; - protected IPublishListener publishListener; - protected IServerListener serverListener; - - protected static Object deletedElement = null; - - // servers that are currently publishing and starting - protected static Set<String> publishing = new HashSet<String>(4); - protected static Set<String> starting = new HashSet<String>(4); - - protected ServerTableLabelProvider labelProvider; - //protected ISelectionListener dsListener; - - protected ServersView view; - - protected boolean animationActive = false; - protected boolean stopAnimation = false; - - public class ServerContentProvider extends BaseContentProvider implements ITreeContentProvider { - public Object[] getElements(Object element) { - List<IServer> list = new ArrayList<IServer>(); - IServer[] servers = ServerCore.getServers(); - if (servers != null) { - int size = servers.length; - for (int i = 0; i < size; i++) { - if (!((Server)servers[i]).isPrivate()) - list.add(servers[i]); - } - } - return list.toArray(); - } - - public Object[] getChildren(Object element) { - if (element instanceof ModuleServer) { - ModuleServer ms = (ModuleServer) element; - try { - IModule[] children = ms.server.getChildModules(ms.module, null); - int size = children.length; - ModuleServer[] ms2 = new ModuleServer[size]; - for (int i = 0; i < size; i++) { - int size2 = ms.module.length; - IModule[] module = new IModule[size2 + 1]; - System.arraycopy(ms.module, 0, module, 0, size2); - module[size2] = children[i]; - ms2[i] = new ModuleServer(ms.server, module); - } - return ms2; - } catch (Exception e) { - return null; - } - } - - IServer server = (IServer) element; - IModule[] modules = server.getModules(); - int size = modules.length; - ModuleServer[] ms = new ModuleServer[size]; - for (int i = 0; i < size; i++) { - ms[i] = new ModuleServer(server, new IModule[] { modules[i] }); - } - return ms; - } - - public Object getParent(Object element) { - if (element instanceof ModuleServer) { - ModuleServer ms = (ModuleServer) element; - return ms.server; - } - return null; - } - - public boolean hasChildren(Object element) { - if (element instanceof ModuleServer) { - // Check if the module server has child modules. - ModuleServer curModuleServer = (ModuleServer)element; - IServer curServer = curModuleServer.server; - IModule[] curModule = curModuleServer.module; - if (curServer != null && curModule != null) { - IModule[] curChildModule = curServer.getChildModules(curModule, null); - if (curChildModule != null && curChildModule.length > 0) - return true; - - return false; - } - - return false; - } - - IServer server = (IServer) element; - return server.getModules().length > 0; - } - } - - protected void startThread() { - if (animationActive) - return; - - stopAnimation = false; - - final Display display = getTree().getDisplay(); - final int SLEEP = 200; - final Runnable[] animator = new Runnable[1]; - animator[0] = new Runnable() { - public void run() { - if (!stopAnimation) { - try { - labelProvider.animate(); - - int size = 0; - String[] servers; - synchronized (starting) { - size = starting.size(); - servers = new String[size]; - starting.toArray(servers); - } - - for (int i = 0; i < size; i++) { - IServer server = ServerCore.findServer(servers[i]); - if (server != null && getTree() != null && !getTree().isDisposed()) - updateAnimation(server); - } - } catch (Exception e) { - Trace.trace(Trace.FINEST, "Error in Servers view animation", e); - } - display.timerExec(SLEEP, animator[0]); - } - } - }; - Display.getDefault().asyncExec(new Runnable() { - public void run() { - display.timerExec(SLEEP, animator[0]); - } - }); - } - - protected void stopThread() { - stopAnimation = true; - } - - /** - * ServerTableViewer constructor comment. - * - * @param view the view - * @param tree the tree - */ - public ServerTableViewer(final ServersView view, final Tree tree) { - super(tree); - this.view = view; - clipboard = new Clipboard(tree.getDisplay()); - } - - protected void initialize() { - ColumnViewerToolTipSupport.enableFor(this); - setContentProvider(new ServerContentProvider()); - labelProvider = new ServerTableLabelProvider(); - setLabelProvider(labelProvider); - - setComparator(new ServerViewerComparator(labelProvider)); - - setInput(ROOT); - addListeners(); - - /*dsListener = new ISelectionListener() { - public void selectionChanged(IWorkbenchPart part, ISelection selection) { - if (!(selection instanceof IStructuredSelection)) - return; - IStructuredSelection sel = (IStructuredSelection) selection; - final Object obj = sel.getFirstElement(); - IProject proj = null; - if (obj instanceof IResource) { - IResource res = (IResource) obj; - proj = res.getProject(); - } - if (proj == null && obj != null) { - try { - IResource res = (IResource) Platform.getAdapterManager().getAdapter(obj, IResource.class); - if (res != null) - proj = res.getProject(); - } catch (Exception e) { - // ignore - } - } - if (proj != null) { - final IProject project = proj; - final IModule module = ServerUtil.getModule(project); - Display.getDefault().asyncExec(new Runnable() { - public void run() { - if (getTree() == null || getTree().isDisposed()) - return; - - IServer defaultServer = null; - if (module != null) - defaultServer = ServerCore.getDefaultServer(module); - - IServer oldDefaultServer = labelProvider.getDefaultServer(); - if ((oldDefaultServer == null && defaultServer == null) - || (oldDefaultServer != null && oldDefaultServer.equals(defaultServer))) - return; - labelProvider.setDefaultServer(defaultServer); - - if (oldDefaultServer != null) - refresh(oldDefaultServer); - if (defaultServer != null) - refresh(defaultServer); - } - }); - } - } - }; - view.getViewSite().getPage().addSelectionListener(dsListener);*/ - - if (color == null) { - Display display = getControl().getDisplay(); - color = display.getSystemColor(SWT.COLOR_DARK_GRAY); - FontData[] fd = getControl().getFont().getFontData(); - int size = fd.length; - for (int i = 0; i < size; i++) - fd[i].setStyle(SWT.ITALIC); - font = new Font(display, fd); - } - } - - protected void handleLabelProviderChanged(LabelProviderChangedEvent event) { - Object[] obj = event.getElements(); - if (obj == null) - refresh(true); - else { - obj = adaptLabelChangeObjects(obj); - int size = obj.length; - for (int i = 0; i < size; i++) - update(obj[i], null); - } - } - - /** - * Resort the table based on field. - * - * @param column the column being updated - * @param col - */ - protected void resortTable(final TreeColumn column, int col) { - ServerViewerComparator sorter = (ServerViewerComparator) getComparator(); - - if (col == sorter.getTopPriority()) - sorter.reverseTopPriority(); - else - sorter.setTopPriority(col); - - PlatformUI.getWorkbench().getDisplay().asyncExec( - new Runnable() { - public void run() { - refresh(); - updateDirectionIndicator(column); - } - }); - } - - /** - * Update the direction indicator as column is now the primary column. - * - * @param column - */ - protected void updateDirectionIndicator(TreeColumn column) { - getTree().setSortColumn(column); - if (((ServerViewerComparator) getComparator()).getTopPriorityDirection() == ServerViewerComparator.ASCENDING) - getTree().setSortDirection(SWT.UP); - else - getTree().setSortDirection(SWT.DOWN); - } - - protected Object[] adaptLabelChangeObjects(Object[] obj) { - if (obj == null) - return obj; - - List<Object> list = new ArrayList<Object>(); - int size = obj.length; - for (int i = 0; i < size; i++) { - if (obj[i] instanceof IModule) { - list.add(obj[i]); - } else if (obj[i] instanceof IServer) { - list.add(obj[i]); - } else if (obj[i] instanceof ModuleServer) { - list.add(obj[i]); - } else if (obj[i] instanceof IProject) { - IProject proj = (IProject) obj[i]; - - List<Object> list2 = new ArrayList<Object>(); - getTreeChildren(list2, view.treeTable); - - Iterator iterator = list2.iterator(); - while (iterator.hasNext()) { - Object o = iterator.next(); - if (o instanceof ModuleServer) { - ModuleServer ms = (ModuleServer) o; - if (proj.equals(ms.module[ms.module.length - 1].getProject())) - list.add(ms); - } - } - } - } - - Object[] o = new Object[list.size()]; - list.toArray(o); - return o; - } - - private void getTreeChildren(List<Object> list, Widget widget) { - Item[] items = getChildren(widget); - for (int i = 0; i < items.length; i++) { - Item item = items[i]; - Object data = item.getData(); - if (data != null) - list.add(data); - - if (getExpanded(item)) { - // only recurse if it is expanded - if - // not then the children aren't visible - getTreeChildren(list, item); - } - } - } - - protected void addListeners() { - serverResourceListener = new IServerLifecycleListener() { - public void serverAdded(IServer server) { - addServer(server); - server.addServerListener(serverListener); - ((Server) server).addPublishListener(publishListener); - } - public void serverChanged(IServer server) { - refreshServer(server); - } - public void serverRemoved(IServer server) { - removeServer(server); - server.removeServerListener(serverListener); - ((Server) server).removePublishListener(publishListener); - } - }; - ServerCore.addServerLifecycleListener(serverResourceListener); - - publishListener = new PublishAdapter() { - public void publishStarted(IServer server) { - handlePublishChange(server, true); - } - - public void publishFinished(IServer server, IStatus status) { - handlePublishChange(server, false); - } - }; - - serverListener = new IServerListener() { - public void serverChanged(ServerEvent event) { - if (event == null) - return; - - int eventKind = event.getKind(); - IServer server = event.getServer(); - if ((eventKind & ServerEvent.SERVER_CHANGE) != 0) { - // server change event - if ((eventKind & ServerEvent.STATE_CHANGE) != 0) { - refreshServer(server); - int state = event.getState(); - String id = server.getId(); - if (state == IServer.STATE_STARTING || state == IServer.STATE_STOPPING) { - boolean startThread = false; - synchronized (starting) { - if (!starting.contains(id)) { - if (starting.isEmpty()) - startThread = true; - starting.add(id); - } - } - if (startThread) - startThread(); - } else { - boolean stopThread = false; - synchronized (starting) { - if (starting.contains(id)) { - starting.remove(id); - if (starting.isEmpty()) - stopThread = true; - } - } - if (stopThread) - stopThread(); - } - } else - refreshServer(server); - } else if ((eventKind & ServerEvent.MODULE_CHANGE) != 0) { - // module change event - if ((eventKind & ServerEvent.STATE_CHANGE) != 0 || (eventKind & ServerEvent.PUBLISH_STATE_CHANGE) != 0) { - refreshServer(server); - } - } - } - }; - - // add listeners to servers - IServer[] servers = ServerCore.getServers(); - if (servers != null) { - int size = servers.length; - for (int i = 0; i < size; i++) { - servers[i].addServerListener(serverListener); - ((Server) servers[i]).addPublishListener(publishListener); - } - } - } - - protected void refreshServer(final IServer server) { - Display.getDefault().asyncExec(new Runnable() { - public void run() { - try { - refresh(server); - ISelection sel = ServerTableViewer.this.getSelection(); - ServerTableViewer.this.setSelection(sel); - } catch (Exception e) { - // ignore - } - } - }); - } - - protected void handleDispose(DisposeEvent event) { - stopThread(); - //if (dsListener != null) - // view.getViewSite().getPage().removeSelectionListener(dsListener); - - ServerCore.removeServerLifecycleListener(serverResourceListener); - - // remove listeners from server - IServer[] servers = ServerCore.getServers(); - if (servers != null) { - int size = servers.length; - for (int i = 0; i < size; i++) { - if (serverListener != null) - servers[i].removeServerListener(serverListener); - if (publishListener != null) - ((Server) servers[i]).removePublishListener(publishListener); - } - } - - clipboard.dispose(); - - super.handleDispose(event); - } - - /** - * Called when the publish state changes. - * @param server org.eclipse.wst.server.core.IServer - */ - protected void handlePublishChange(IServer server, boolean isPublishing) { - String serverId = server.getId(); - if (isPublishing) - publishing.add(serverId); - else - publishing.remove(serverId); - - refreshServer(server); - } - - /** - * - */ - protected void handleServerModulesChanged(IServer server2) { - if (server2 == null) - return; - - IServer[] servers = ServerCore.getServers(); - if (servers != null) { - int size = servers.length; - for (int i = 0; i < size; i++) { - if (server2.equals(servers[i])) - refresh(servers[i]); - } - } - } - - /** - * Called when an element is added. - * @param server org.eclipse.wst.server.core.IServer - */ - protected void handleServerResourceAdded(IServer server) { - add(null, server); - } - - /*protected void handleServerResourceAdded(IServerConfiguration configuration) { - configurationChange(configuration, true); - }*/ - - /** - * Called when an element is changed. - * @param server org.eclipse.wst.server.core.IServer - */ - protected void handleServerResourceChanged(IServer server) { - refresh(server); - } - - /*protected void handleServerResourceChanged(IServerConfiguration configuration) { - IServer[] servers = ServerCore.getServers(); - if (servers != null) { - int size = servers.length; - for (int i = 0; i < size; i++) { - IServerConfiguration config = servers[i].getServerConfiguration(); - if (configuration.equals(config)) - refresh(servers[i]); - } - } - }*/ - - /** - * Called when an element is removed. - * @param server org.eclipse.wst.server.core.IServer - */ - protected void handleServerResourceRemoved(IServer server) { - remove(server); - - String serverId = server.getId(); - publishing.remove(serverId); - - view.getViewSite().getActionBars().getStatusLineManager().setMessage(null, null); - } - - /*protected void handleServerResourceRemoved(IServerConfiguration configuration) { - configurationChange(configuration, false); - }*/ - - protected void addServer(final IServer server) { - Display.getDefault().asyncExec(new Runnable() { - public void run() { - add(ROOT, server); - } - }); - } - - protected void removeServer(final IServer server) { - Display.getDefault().asyncExec(new Runnable() { - public void run() { - remove(server); - } - }); - } - - public void doUpdateItem(Widget widget, Object element, boolean fullMap) { - if (widget instanceof TreeItem && color != null) { - TreeItem item = (TreeItem) widget; - if (element instanceof ModuleServer) { - ModuleServer ms = (ModuleServer) element; - IModule m = ms.module[ms.module.length-1]; - if (m.isExternal()) - item.setForeground(color); - else - item.setForeground(null); - if (ms.server.getModulePublishState(ms.module) != IServer.PUBLISH_STATE_NONE) - item.setFont(0, font); - else - item.setFont(0, null); - } - } - super.doUpdateItem(widget, element, fullMap); - } - - protected void updateAnimation(IServer server) { - try { - Widget widget = doFindItem(server); - TreeItem item = (TreeItem) widget; - item.setText(1, labelProvider.getColumnText(server, 1)); - item.setImage(1, labelProvider.getColumnImage(server, 1)); - } catch (Exception e) { - Trace.trace(Trace.WARNING, "Error in optimized animation", e); - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerTransfer.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerTransfer.java deleted file mode 100644 index 1f43dc032..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerTransfer.java +++ /dev/null @@ -1,121 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.view.servers; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; - -import org.eclipse.swt.dnd.ByteArrayTransfer; -import org.eclipse.swt.dnd.DND; -import org.eclipse.swt.dnd.TransferData; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.internal.IMemento; -import org.eclipse.wst.server.core.internal.Server; -import org.eclipse.wst.server.core.internal.XMLMemento; -/* - * The element serialization format is: - * (int) number of servers - * Then, the following for each server: - * (String) id - */ -public class ServerTransfer extends ByteArrayTransfer { - private static final ServerTransfer instance = new ServerTransfer(); - - // Create a unique ID to make sure that different Eclipse - // applications use different "types" of <code>JavaElementTransfer</code> - private static final String TYPE_NAME = "server-transfer-format:" + System.currentTimeMillis() + ":" + instance.hashCode(); - - private static final int TYPEID = registerType(TYPE_NAME); - - private ServerTransfer() { - // do nothing - } - - /** - * Returns the singleton instance. - * - * @return the singleton instance - */ - public static ServerTransfer getInstance() { - return instance; - } - - /* (non-Javadoc) - * Method declared on Transfer. - */ - protected int[] getTypeIds() { - return new int[] { TYPEID }; - } - - /* (non-Javadoc) - * Method declared on Transfer. - */ - protected String[] getTypeNames() { - return new String[] { TYPE_NAME }; - } - - /* (non-Javadoc) - * @see org.eclipse.swt.dnd.Transfer#javaToNative(java.lang.Object, org.eclipse.swt.dnd.TransferData) - */ - protected void javaToNative(Object data, TransferData transferData) { - if (!(data instanceof IServer[])) - return; - - IServer[] servers = (IServer[]) data; - try { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - - XMLMemento memento = XMLMemento.createWriteRoot("servers"); - - // write each element - for (int i = 0; i < servers.length; i++) { - IMemento child = memento.createChild("server"); - ((Server)servers[i]).serialize(child); - } - - memento.save(out); - - // cleanup - out.close(); - byte[] bytes = out.toByteArray(); - super.javaToNative(bytes, transferData); - } catch (IOException e) { - // it's best to send nothing if there were problems - } - } - - /* (non-Javadoc) - * @see org.eclipse.swt.dnd.Transfer#nativeToJava(org.eclipse.swt.dnd.TransferData) - */ - protected Object nativeToJava(TransferData transferData) { - byte[] bytes = (byte[]) super.nativeToJava(transferData); - if (bytes == null) - return null; - ByteArrayInputStream in = new ByteArrayInputStream(bytes); - try { - IMemento memento = XMLMemento.loadMemento(in); - IMemento[] children = memento.getChildren("server"); - - int count = children.length; - IServer[] results = new IServer[count]; - for (int i = 0; i < count; i++) { - Server server = new Server(null); - server.deserialize(children[i]); - results[i] = server; - } - return results; - } catch (Exception e) { - DND.error(DND.ERROR_INVALID_DATA); - } - return null; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerViewerComparator.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerViewerComparator.java deleted file mode 100644 index 40db302ff..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerViewerComparator.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.view.servers; - -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerComparator; - -public class ServerViewerComparator extends ViewerComparator { - public static final int MAX_DEPTH = 3; - public static final int ASCENDING = 1; - public static final int DESCENDING = -1; - - protected ServerTableLabelProvider labelProvider; - - protected int[] priorities = new int[] { 0 }; - - protected int[] directions = new int[] { ASCENDING }; - - public ServerViewerComparator(ServerTableLabelProvider labelProvider) { - this.labelProvider = labelProvider; - } - - public void setTopPriority(int priority) { - if (priorities[0] == priority) - return; - - int len = priorities.length + 1; - if (len > MAX_DEPTH) - len = MAX_DEPTH; - - int[] temp = new int[len]; - System.arraycopy(priorities, 0, temp, 1, len - 1); - temp[0] = priority; - priorities = temp; - - temp = new int[len]; - System.arraycopy(directions, 0, temp, 1, len - 1); - temp[0] = ASCENDING; - directions = temp; - } - - public int getTopPriority() { - return priorities[0]; - } - - public void setTopPriorityDirection(int direction) { - if (direction == ASCENDING || direction == DESCENDING) { - directions[0] = direction; - } - } - - public int getTopPriorityDirection() { - return directions[0]; - } - - public void reverseTopPriority() { - directions[0] *= -1; - } - - public int compare(Viewer viewer, Object e1, Object e2, int a) { - int col = priorities[a]; - - String s1 = labelProvider.getColumnText(e1, col); - String s2 = labelProvider.getColumnText(e2, col); - - int s = s1.compareToIgnoreCase(s2) * directions[a]; - if (s == 0) { - if (a == priorities.length - 1) - return 0; - return compare(viewer, e1, e2, a+1); - } - return s; - } - - public int compare(Viewer viewer, Object e1, Object e2) { - return compare(viewer, e1, e2, 0); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServersView.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServersView.java deleted file mode 100644 index 5d754ad86..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServersView.java +++ /dev/null @@ -1,460 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.view.servers; - -import java.util.Iterator; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.debug.core.ILaunchManager; -import org.eclipse.jface.action.*; -import org.eclipse.jface.bindings.TriggerSequence; -import org.eclipse.jface.viewers.*; -import org.eclipse.wst.server.core.*; -import org.eclipse.wst.server.core.internal.Server; -import org.eclipse.wst.server.core.internal.UpdateServerJob; -import org.eclipse.wst.server.core.model.ServerDelegate; -import org.eclipse.wst.server.ui.internal.*; -import org.eclipse.wst.server.ui.internal.actions.NewServerWizardAction; -import org.eclipse.swt.SWT; -import org.eclipse.swt.dnd.DND; -import org.eclipse.swt.dnd.FileTransfer; -import org.eclipse.swt.dnd.Transfer; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Tree; -import org.eclipse.swt.widgets.TreeColumn; -import org.eclipse.swt.widgets.TreeItem; -import org.eclipse.ui.*; -import org.eclipse.ui.actions.ActionFactory; -import org.eclipse.ui.contexts.IContextService; -import org.eclipse.ui.keys.IBindingService; -import org.eclipse.ui.part.ResourceTransfer; -import org.eclipse.ui.part.ViewPart; -import org.eclipse.ui.views.navigator.LocalSelectionTransfer; -/** - * A view of servers, their modules, and status. - */ -public class ServersView extends ViewPart { - private static final String TAG_COLUMN_WIDTH = "columnWidth"; - private static final String SERVERS_VIEW_CONTEXT = "org.eclipse.ui.serverViewScope"; - - protected Action noneAction = new Action(Messages.dialogMonitorNone) { - // dummy action - }; - - protected int[] cols; - - protected Tree treeTable; - protected ServerTableViewer tableViewer; - - // actions on a server - protected Action[] actions; - protected Action actionModifyModules; - protected Action openAction, showInConsoleAction, showInDebugAction, propertiesAction, monitorPropertiesAction; - protected Action copyAction, pasteAction, deleteAction, renameAction; - - /** - * ServersView constructor comment. - */ - public ServersView() { - super(); - } - - protected SelectionListener getHeaderListener(final int col) { - return new SelectionAdapter() { - /** - * Handles the case of user selecting the header area. - */ - public void widgetSelected(SelectionEvent e) { - if (tableViewer == null) - return; - TreeColumn column = (TreeColumn) e.widget; - tableViewer.resortTable(column, col); - } - }; - } - - /** - * createPartControl method comment. - * - * @param parent a parent composite - */ - public void createPartControl(Composite parent) { - treeTable = new Tree(parent, SWT.SINGLE | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL); - treeTable.setHeaderVisible(true); - treeTable.setLinesVisible(false); - treeTable.setLayoutData(new GridData(GridData.FILL_BOTH)); - treeTable.setFont(parent.getFont()); - PlatformUI.getWorkbench().getHelpSystem().setHelp(treeTable, ContextIds.VIEW_SERVERS); - - // add columns - TreeColumn column = new TreeColumn(treeTable, SWT.SINGLE); - column.setText(Messages.viewServer); - column.setWidth(cols[0]); - column.addSelectionListener(getHeaderListener(0)); - treeTable.setSortColumn(column); - treeTable.setSortDirection(SWT.UP); - - TreeColumn column2 = new TreeColumn(treeTable, SWT.SINGLE); - column2.setText(Messages.viewState); - column2.setWidth(cols[1]); - column2.addSelectionListener(getHeaderListener(1)); - - TreeColumn column3 = new TreeColumn(treeTable, SWT.SINGLE); - column3.setText(Messages.viewStatus); - column3.setWidth(cols[2]); - column3.addSelectionListener(getHeaderListener(2)); - - IContextService contextSupport = (IContextService)getSite().getService(IContextService.class); - contextSupport.activateContext(SERVERS_VIEW_CONTEXT); - - deferInitialization(); - } - - private void deferInitialization() { - TreeItem item = new TreeItem(treeTable, SWT.NONE); - item.setText(Messages.viewInitializing); - - tableViewer = new ServerTableViewer(this, treeTable); - initializeActions(tableViewer); - - Job job = new Job(Messages.jobInitializingServersView) { - public IStatus run(IProgressMonitor monitor) { - IServer[] servers = ServerCore.getServers(); - int size = servers.length; - for (int i = 0; i < size; i++) { - ((Server)servers[i]).getAllModules().iterator(); - /*while (iterator.hasNext()) { - Module module = (Module) iterator.next(); - module.g - }*/ - } - - Display.getDefault().asyncExec(new Runnable() { - public void run() { - try { - deferredInitialize(); - } catch (Exception e) { - // ignore - view has already been closed - } - } - }); - return Status.OK_STATUS; - } - }; - - job.setSystem(true); - job.setPriority(Job.SHORT); - job.schedule(); - } - - protected void deferredInitialize() { - tableViewer.initialize(); - tableViewer.addOpenListener(new IOpenListener() { - public void open(OpenEvent event) { - try { - IStructuredSelection sel = (IStructuredSelection) event.getSelection(); - Object data = sel.getFirstElement(); - if (!(data instanceof IServer)) - return; - IServer server = (IServer) data; - ServerUIPlugin.editServer(server); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Could not open server", e); - } - } - }); - - MenuManager menuManager = new MenuManager("#PopupMenu"); - menuManager.setRemoveAllWhenShown(true); - final Shell shell = treeTable.getShell(); - menuManager.addMenuListener(new IMenuListener() { - public void menuAboutToShow(IMenuManager mgr) { - fillContextMenu(shell, mgr); - } - }); - Menu menu = menuManager.createContextMenu(treeTable); - treeTable.setMenu(menu); - getSite().registerContextMenu(menuManager, tableViewer); - getSite().setSelectionProvider(tableViewer); - - initDragAndDrop(); - - // init the tooltip - ServerToolTip toolTip = new ServerToolTip(treeTable); - toolTip.setShift(new Point(10, 3)); - toolTip.setPopupDelay(400); // in ms - toolTip.setHideOnMouseDown(true); - toolTip.activate(); - - if (tableViewer.getTree().getItemCount() > 0) { - Object obj = tableViewer.getTree().getItem(0).getData(); - tableViewer.setSelection(new StructuredSelection(obj)); - } - - Thread thread = new Thread() { - public void run() { - try { - Thread.sleep(5000); - } catch (Exception e) { - // ignore - } - IServer[] servers = ServerCore.getServers(); - int size = servers.length; - for (int i = 0; i < size; i++) { - IServer server = servers[i]; - if (server.getServerType() != null && server.getServerState() == IServer.STATE_UNKNOWN) { - UpdateServerJob job = new UpdateServerJob(server); - job.schedule(); - } - } - } - }; - thread.setDaemon(true); - thread.setPriority(Thread.MIN_PRIORITY + 1); - thread.start(); - } - - public void init(IViewSite site, IMemento memento) throws PartInitException { - super.init(site, memento); - cols = new int[3]; - for (int i = 0; i < 3; i++) { - cols[i] = 200; - if (memento != null) { - Integer in = memento.getInteger(TAG_COLUMN_WIDTH + i); - if (in != null && in.intValue() > 5) - cols[i] = in.intValue(); - } - } - } - - public void saveState(IMemento memento) { - TreeColumn[] tc = treeTable.getColumns(); - for (int i = 0; i < 3; i++) { - int width = tc[i].getWidth(); - if (width != 0) - memento.putInteger(TAG_COLUMN_WIDTH + i, width); - } - } - - /** - * Initialize actions - * - * @param provider a selection provider - */ - public void initializeActions(ISelectionProvider provider) { - Shell shell = getSite().getShell(); - IActionBars actionBars = getViewSite().getActionBars(); - - actions = new Action[6]; - // create the start actions - actions[0] = new StartAction(shell, provider, ILaunchManager.DEBUG_MODE); - actionBars.setGlobalActionHandler("org.eclipse.wst.server.debug", actions[0]); - actions[1] = new StartAction(shell, provider, ILaunchManager.RUN_MODE); - actionBars.setGlobalActionHandler("org.eclipse.wst.server.run", actions[1]); - actions[2] = new StartAction(shell, provider, ILaunchManager.PROFILE_MODE); - - // create the stop action - actions[3] = new StopAction(shell, provider); - actionBars.setGlobalActionHandler("org.eclipse.wst.server.stop", actions[3]); - - // create the publish actions - actions[4] = new PublishAction(shell, provider); - actionBars.setGlobalActionHandler("org.eclipse.wst.server.publish", actions[4]); - actions[5] = new PublishCleanAction(shell, provider); - - // create the open action - openAction = new OpenAction(provider); - actionBars.setGlobalActionHandler("org.eclipse.ui.navigator.Open", openAction); - - // create copy, paste, and delete actions - pasteAction = new PasteAction(shell, provider, tableViewer.clipboard); - copyAction = new CopyAction(provider, tableViewer.clipboard, pasteAction); - deleteAction = new DeleteAction(shell, provider); - renameAction = new RenameAction(shell, tableViewer, provider); - actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyAction); - actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), pasteAction); - actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), deleteAction); - actionBars.setGlobalActionHandler(ActionFactory.RENAME.getId(), renameAction); - - // create the other actions - actionModifyModules = new ModuleSloshAction(shell, provider); - showInConsoleAction = new ShowInConsoleAction(provider); - showInDebugAction = new ShowInDebugAction(provider); - - // create the properties action - propertiesAction = new PropertiesAction(shell, provider); - actionBars.setGlobalActionHandler(ActionFactory.PROPERTIES.getId(), propertiesAction); - monitorPropertiesAction = new PropertiesAction(shell, "org.eclipse.wst.server.ui.properties.monitor", provider); - - // add toolbar buttons - IContributionManager cm = actionBars.getToolBarManager(); - for (int i = 0; i < actions.length - 1; i++) - cm.add(actions[i]); - - cm.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); - } - - private static void fillNewContextMenu(Shell shell, ISelection selection, IMenuManager menu) { - IAction newServerAction = new NewServerWizardAction(); - newServerAction.setText(Messages.actionNewServer); - menu.add(newServerAction); - } - - protected void fillContextMenu(Shell shell, IMenuManager menu) { - // get selection but avoid no selection or multiple selection - IServer server = null; - IModule[] module = null; - IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection(); - if (!selection.isEmpty()) { - Iterator iterator = selection.iterator(); - Object obj = iterator.next(); - if (obj instanceof IServer) - server = (IServer) obj; - if (obj instanceof ModuleServer) { - ModuleServer ms = (ModuleServer) obj; - server = ms.server; - module = ms.module; - } - if (iterator.hasNext()) { - server = null; - module = null; - } - } - - // new action - MenuManager newMenu = new MenuManager(Messages.actionNew); - fillNewContextMenu(null, selection, newMenu); - menu.add(newMenu); - - // open action - if (server != null && module == null) { - menu.add(openAction); - - String text = Messages.actionShowIn; - final IWorkbench workbench = PlatformUI.getWorkbench(); - final IBindingService bindingService = (IBindingService) workbench - .getAdapter(IBindingService.class); - final TriggerSequence[] activeBindings = bindingService - .getActiveBindingsFor("org.eclipse.ui.navigate.showInQuickMenu"); - if (activeBindings.length > 0) { - text += "\t" + activeBindings[0].format(); - } - - MenuManager showInMenu = new MenuManager(text); - showInMenu.add(showInConsoleAction); - showInMenu.add(showInDebugAction); - //IActionBars actionBars = getViewSite().getActionBars(); - //actionBars.setGlobalActionHandler("group.show", showInMenu); - menu.add(showInMenu); - menu.add(new Separator()); - } else - menu.add(new Separator()); - - if (server != null) { - if (module == null) { - menu.add(copyAction); - menu.add(pasteAction); - menu.add(deleteAction); - menu.add(renameAction); - } else if (module.length == 1) - menu.add(new RemoveModuleAction(shell, server, module[0])); - menu.add(new Separator()); - } - - if (server != null && module == null) { - // server actions - for (int i = 0; i < actions.length; i++) - menu.add(actions[i]); - - menu.add(new Separator()); - menu.add(actionModifyModules); - - // monitor - if (server.getServerType() != null) { - final MenuManager menuManager = new MenuManager(Messages.actionMonitor); - - final IServer server2 = server; - final Shell shell2 = shell; - menuManager.addMenuListener(new IMenuListener() { - public void menuAboutToShow(IMenuManager manager) { - menuManager.removeAll(); - if (server2.getAdapter(ServerDelegate.class) != null) { - ServerPort[] ports = server2.getServerPorts(null); - if (ports != null) { - int size = ports.length; - for (int i = 0; i < size; i++) { - if (!ports[i].isAdvanced()) - menuManager.add(new MonitorServerPortAction(shell2, server2, ports[i])); - } - } - } - - if (menuManager.isEmpty()) - menuManager.add(noneAction); - - menuManager.add(new Separator()); - menuManager.add(monitorPropertiesAction); - } - }); - - // add an initial menu item so that the menu appears correctly - noneAction.setEnabled(false); - menuManager.add(noneAction); - menu.add(menuManager); - } - } - - if (server != null && module != null) { - menu.add(new Separator()); - menu.add(new StartModuleAction(server, module)); - menu.add(new StopModuleAction(server, module)); - menu.add(new RestartModuleAction(server, module)); - } - - menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); - menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS+"-end")); - - if (server != null) { - menu.add(new Separator()); - menu.add(propertiesAction); - } - } - - /** - * - */ - public void setFocus() { - if (treeTable != null) - treeTable.setFocus(); - } - - /** - * Adds drag and drop support to the Servers view. - */ - protected void initDragAndDrop() { - int ops = DND.DROP_COPY; - Transfer[] transfers = new Transfer[] { LocalSelectionTransfer.getInstance(), - ResourceTransfer.getInstance(), FileTransfer.getInstance() }; - //tableViewer.addDragSupport(ops, transfers, new ServersViewDragAdapter(viewer)); - tableViewer.addDropSupport(ops | DND.DROP_DEFAULT, transfers, new ServersViewDropAdapter(tableViewer)); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServersViewDropAdapter.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServersViewDropAdapter.java deleted file mode 100644 index 27b349129..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServersViewDropAdapter.java +++ /dev/null @@ -1,197 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.view.servers; - -import java.util.Iterator; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerDropAdapter; -import org.eclipse.swt.dnd.DND; -import org.eclipse.swt.dnd.DropTargetEvent; -import org.eclipse.swt.dnd.FileTransfer; -import org.eclipse.swt.dnd.TransferData; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.part.ResourceTransfer; -import org.eclipse.ui.views.navigator.LocalSelectionTransfer; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IModuleArtifact; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.IServerWorkingCopy; -import org.eclipse.wst.server.core.ServerUtil; -import org.eclipse.wst.server.ui.internal.EclipseUtil; -import org.eclipse.wst.server.ui.internal.ServerUIPlugin; -import org.eclipse.wst.server.ui.internal.Trace; -import org.eclipse.wst.server.ui.internal.actions.RunOnServerActionDelegate; -/** - * - */ -public class ServersViewDropAdapter extends ViewerDropAdapter { - protected ServersViewDropAdapter(Viewer viewer) { - super(viewer); - } - - public void dragEnter(DropTargetEvent event) { - if (event.detail == DND.DROP_DEFAULT) - event.detail = DND.DROP_COPY; - - super.dragEnter(event); - } - - public boolean performDrop(Object data) { - Object target = getCurrentTarget(); - IServer server = null; - if (target instanceof IServer) - server = (IServer) target; - - if (server == null) - return false; - - Iterator iterator = null; - if (data instanceof IStructuredSelection) { - IStructuredSelection sel = (IStructuredSelection) data; - iterator = sel.iterator(); - } - - if (iterator == null) - return false; - - boolean b = true; - while (iterator.hasNext()) { - Object data2 = iterator.next(); - if (!doSel(server, data2)) - b = false; - } - return b; - } - - protected boolean doSel(IServer server, Object data) { - // check if the selection is a project (module) that we can add to the server - IProject project = (IProject) Platform.getAdapterManager().getAdapter(data, IProject.class); - if (project != null) { - IModule[] modules = ServerUtil.getModules(project); - if (modules != null && modules.length == 1) { - try { - IServerWorkingCopy wc = server.createWorkingCopy(); - IModule[] parents = wc.getRootModules(modules[0], null); - if (parents == null || parents.length == 0) - return false; - - if (ServerUtil.containsModule(server, parents[0], null)) - return false; - - IModule[] add = new IModule[] { parents[0] }; - if (wc.canModifyModules(add, null, null).getSeverity() != IStatus.ERROR) { - wc.modifyModules(modules, null, null); - wc.save(false, null); - return true; - } - } catch (final CoreException ce) { - final Shell shell = getViewer().getControl().getShell(); - shell.getDisplay().asyncExec(new Runnable() { - public void run() { - EclipseUtil.openError(shell, ce.getLocalizedMessage()); - } - }); - return true; - } - } - } - - // otherwise, try Run on Server - final IServer finalServer = server; - RunOnServerActionDelegate ros = new RunOnServerActionDelegate() { - public IServer getServer(IModule module, IModuleArtifact moduleArtifact, IProgressMonitor monitor) throws CoreException { - if (!ServerUIPlugin.isCompatibleWithLaunchMode(finalServer, launchMode)) - return null; - - if (!ServerUtil.containsModule(finalServer, module, monitor)) { - IServerWorkingCopy wc = finalServer.createWorkingCopy(); - try { - ServerUtil.modifyModules(wc, new IModule[] { module }, new IModule[0], monitor); - wc.save(false, monitor); - } catch (CoreException ce) { - throw ce; - } - } - - return finalServer; - } - }; - Action action = new Action() { - // - }; - ros.selectionChanged(action, new StructuredSelection(data)); - - //if (!action.isEnabled()) - // return false; - - ros.run(action); - return true; - } - - public boolean validateDrop(Object target, int operation, TransferData transferType) { - if (target == null) - return false; - /*IServer server = null; - if (target instanceof IServer) - server = (IServer) target;*/ - //if (!ServerUIPlugin.hasModuleArtifact(target)) - // return false; - - Trace.trace(Trace.FINER, "Drop target: " + target + " " + operation + " " + transferType); - - if (FileTransfer.getInstance().isSupportedType(transferType)) - return true; - if (ResourceTransfer.getInstance().isSupportedType(transferType)) - return true; - if (LocalSelectionTransfer.getInstance().isSupportedType(transferType)) - return true; - - return false; - } - - /** - * Returns the resource selection from the LocalSelectionTransfer. - * - * @return the resource selection from the LocalSelectionTransfer - */ - /*private IResource[] getSelectedResources() { - ArrayList selectedResources = new ArrayList(); - - ISelection selection = LocalSelectionTransfer.getInstance() - .getSelection(); - if (selection instanceof IStructuredSelection) { - IStructuredSelection ssel = (IStructuredSelection) selection; - for (Iterator i = ssel.iterator(); i.hasNext();) { - Object o = i.next(); - if (o instanceof IResource) { - selectedResources.add(o); - } - else if (o instanceof IAdaptable) { - IAdaptable a = (IAdaptable) o; - IResource r = (IResource) a.getAdapter(IResource.class); - if (r != null) { - selectedResources.add(r); - } - } - } - } - return (IResource[]) selectedResources.toArray(new IResource[selectedResources.size()]); - }*/ -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ShowInConsoleAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ShowInConsoleAction.java deleted file mode 100644 index d9d4a0383..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ShowInConsoleAction.java +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.view.servers; - -import org.eclipse.debug.core.ILaunch; -import org.eclipse.debug.core.model.IProcess; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.console.ConsolePlugin; -import org.eclipse.ui.console.IConsole; -import org.eclipse.ui.console.IConsoleConstants; -import org.eclipse.ui.console.IConsoleManager; -import org.eclipse.ui.console.IConsoleView; -import org.eclipse.ui.views.IViewDescriptor; -import org.eclipse.ui.views.IViewRegistry; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.ui.internal.Trace; -/** - * "Show in Console" menu action. - */ -public class ShowInConsoleAction extends AbstractServerAction { - /** - * ShowInConsoleAction constructor. - * - * @param sp a selection provider - */ - public ShowInConsoleAction(ISelectionProvider sp) { - super(sp, "Console"); - - IViewRegistry reg = PlatformUI.getWorkbench().getViewRegistry(); - IViewDescriptor desc = reg.find(IConsoleConstants.ID_CONSOLE_VIEW); - setText(desc.getLabel()); - setImageDescriptor(desc.getImageDescriptor()); - } - - public boolean accept(IServer server) { - return (server.getServerType() != null && server.getServerState() != IServer.STATE_STOPPED); - } - - public void perform(IServer server) { - try { - ILaunch launch = server.getLaunch(); - selectProcess(launch.getProcesses()[0]); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error opening console", e); - } - } - - protected void selectProcess(IProcess process) { - // see bug 250999 - debug UI must be loaded before looking for debug consoles - org.eclipse.debug.ui.console.IConsole.class.toString(); - - IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager(); - IConsole[] consoles = consoleManager.getConsoles(); - int size = consoles.length; - IConsole console = null; - for (int i = 0; i < size; i++) { - if (consoles[i] instanceof org.eclipse.debug.ui.console.IConsole) { - org.eclipse.debug.ui.console.IConsole con = (org.eclipse.debug.ui.console.IConsole) consoles[i]; - if (process.equals(con.getProcess())) - console = consoles[i]; - } - } - - if (console == null) - return; - - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow() ; - if (window != null) { - IWorkbenchPage page = window.getActivePage(); - if (page != null) { - IWorkbenchPart part = page.findView(IConsoleConstants.ID_CONSOLE_VIEW); - if (part == null) { - try { - part = page.showView(IConsoleConstants.ID_CONSOLE_VIEW); - } catch (PartInitException e) { - Trace.trace(Trace.SEVERE, "Could not open console view"); - } - } - if (part != null) { - page.activate(part); - IConsoleView view = (IConsoleView) part.getAdapter(IConsoleView.class); - if (view != null) { - view.setFocus(); - view.display(console); - } - } - } - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ShowInDebugAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ShowInDebugAction.java deleted file mode 100644 index a542cb5e1..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ShowInDebugAction.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.view.servers; - -import org.eclipse.debug.core.ILaunch; -import org.eclipse.debug.core.model.IProcess; -import org.eclipse.debug.ui.IDebugUIConstants; -import org.eclipse.debug.ui.IDebugView; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.views.IViewDescriptor; -import org.eclipse.ui.views.IViewRegistry; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.ui.internal.Trace; -/** - * "Show in Console" menu action. - */ -public class ShowInDebugAction extends AbstractServerAction { - /** - * ShowInConsoleAction constructor. - * - * @param sp a selection provider - */ - public ShowInDebugAction(ISelectionProvider sp) { - super(sp, "Console!"); - - IViewRegistry reg = PlatformUI.getWorkbench().getViewRegistry(); - IViewDescriptor desc = reg.find(IDebugUIConstants.ID_DEBUG_VIEW); - setText(desc.getLabel()); - setImageDescriptor(desc.getImageDescriptor()); - } - - public boolean accept(IServer server) { - return (server.getServerType() != null && server.getServerState() != IServer.STATE_STOPPED); - } - - public void perform(IServer server) { - try { - ILaunch launch = server.getLaunch(); - selectProcess(launch.getProcesses()[0]); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error showing in debug", e); - } - } - - protected void selectProcess(IProcess process) { - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow() ; - if (window != null) { - IWorkbenchPage page = window.getActivePage(); - if (page != null) { - IWorkbenchPart part = page.findView(IDebugUIConstants.ID_DEBUG_VIEW); - if (part == null) { - try { - part = page.showView(IDebugUIConstants.ID_DEBUG_VIEW); - } catch (PartInitException e) { - Trace.trace(Trace.SEVERE, "Could not open debug view"); - } - } - if (part != null) { - IDebugView view = (IDebugView)part.getAdapter(IDebugView.class); - if (view != null) { - view.setFocus(); - Viewer viewer = view.getViewer(); - if (viewer != null) { - viewer.setSelection(new StructuredSelection(process)); - } - } - } - } - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ShowInMenuAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ShowInMenuAction.java deleted file mode 100644 index 8a6667c0a..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ShowInMenuAction.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.view.servers; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IMenuCreator; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.wst.server.ui.internal.Messages; -/** - * "ShowInMenuAction" menu action. - */ -public class ShowInMenuAction extends Action { - /** - * ShowInMenuAction constructor. - * - * @param sp a selection provider - */ - public ShowInMenuAction(final ISelectionProvider sp) { - super(Messages.actionShowIn); - - setActionDefinitionId("org.eclipse.ui.navigate.showInQuickMenu"); - setMenuCreator(new IMenuCreator() { - private MenuManager menuManager; - public void dispose() { - if (menuManager != null) - menuManager.dispose(); - } - - public Menu getMenu(Control parent) { - System.out.println("creating menu1"); - return getMenuManager().createContextMenu(parent); - } - - public Menu getMenu(Menu parent) { - System.out.println("creating menu2"); - //return getMenuManager().createContextMenu(parent.getShell()); - return null; - } - - private MenuManager getMenuManager() { - System.out.println("creating menu"); - if (menuManager != null) - return menuManager; - - menuManager = new MenuManager(Messages.actionShowIn); - menuManager.add(new ShowInConsoleAction(sp)); - menuManager.add(new ShowInDebugAction(sp)); - return menuManager; - } - }); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/StartAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/StartAction.java deleted file mode 100644 index 2fb7f3967..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/StartAction.java +++ /dev/null @@ -1,187 +0,0 @@ -/********************************************************************** - * Copyright (c) 2003, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - **********************************************************************/ -package org.eclipse.wst.server.ui.internal.view.servers; - -import java.util.Iterator; - -import org.eclipse.debug.core.ILaunchManager; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.IServer.IOperationListener; -import org.eclipse.wst.server.ui.internal.ImageResource; -import org.eclipse.wst.server.ui.internal.Messages; -import org.eclipse.wst.server.ui.internal.ServerUIPlugin; -import org.eclipse.wst.server.ui.internal.Trace; -import org.eclipse.wst.server.ui.internal.provisional.UIDecoratorManager; -import org.eclipse.swt.widgets.Shell; -/** - * Start a server. - */ -public class StartAction extends AbstractServerAction { - protected String launchMode = ILaunchManager.RUN_MODE; - - public StartAction(Shell shell, ISelectionProvider selectionProvider, String launchMode) { - super(shell, selectionProvider, "start"); - this.launchMode = launchMode; - if (launchMode == ILaunchManager.RUN_MODE) { - setToolTipText(Messages.actionStartToolTip); - setText(Messages.actionStart); - setImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_ELCL_START)); - setHoverImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_CLCL_START)); - setDisabledImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_DLCL_START)); - setActionDefinitionId("org.eclipse.wst.server.run"); - } else if (launchMode == ILaunchManager.DEBUG_MODE) { - setToolTipText(Messages.actionDebugToolTip); - setText(Messages.actionDebug); - setImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_ELCL_START_DEBUG)); - setHoverImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_CLCL_START_DEBUG)); - setDisabledImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_DLCL_START_DEBUG)); - setActionDefinitionId("org.eclipse.wst.server.debug"); - } else if (launchMode == ILaunchManager.PROFILE_MODE) { - setToolTipText(Messages.actionProfileToolTip); - setText(Messages.actionProfile); - setImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_ELCL_START_PROFILE)); - setHoverImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_CLCL_START_PROFILE)); - setDisabledImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_DLCL_START_PROFILE)); - } - try { - selectionChanged((IStructuredSelection) selectionProvider.getSelection()); - } catch (Exception e) { - // ignore - } - } - - /** - * Update the name of the Action label, depending on the status of the server. - * @param sel the IStructuredSelection from the view - */ - private void updateText(IStructuredSelection sel){ - if (this.launchMode == ILaunchManager.RUN_MODE) { - if (sel.isEmpty()) { - setText(Messages.actionStart); - return; - } - Iterator iterator = sel.iterator(); - while (iterator.hasNext()) { - Object obj = iterator.next(); - if (obj instanceof IServer) { - IServer server = (IServer) obj; - if (server.getServerState() == IServer.STATE_STARTED || - server.getServerState() == IServer.STATE_STARTING) { - setText(Messages.actionRestart); - setToolTipText(Messages.actionRestartToolTip); - } else { - setText(Messages.actionStart); - setToolTipText(Messages.actionStartToolTip); - } - } - } - } else if (this.launchMode == ILaunchManager.DEBUG_MODE) { - if (sel.isEmpty()) { - setText(Messages.actionDebug); - return; - } - Iterator iterator = sel.iterator(); - while (iterator.hasNext()) { - Object obj = iterator.next(); - if (obj instanceof IServer) { - IServer server = (IServer) obj; - if (server.getServerState() == IServer.STATE_STARTED || - server.getServerState() == IServer.STATE_STARTING) { - setText(Messages.actionDebugRestart); - setToolTipText(Messages.actionDebugRestartToolTip); - } else { - setText(Messages.actionDebug); - setToolTipText(Messages.actionDebugToolTip); - } - } - } - } else if (this.launchMode == ILaunchManager.PROFILE_MODE) { - if (sel.isEmpty()) { - setText(Messages.actionProfile); - return; - } - Iterator iterator = sel.iterator(); - while (iterator.hasNext()) { - Object obj = iterator.next(); - if (obj instanceof IServer) { - IServer server = (IServer) obj; - if (server.getServerState() == IServer.STATE_STARTED || - server.getServerState() == IServer.STATE_STARTING) { - setText(Messages.actionProfileRestart); - setToolTipText(Messages.actionProfileRestartToolTip); - } else { - setText(Messages.actionProfile); - setToolTipText(Messages.actionProfileToolTip); - } - } - } - } - } - - /** - * Return true if this server can currently be acted on. - * @return boolean - * @param server a server - */ - public boolean accept(IServer server) { - if (server.getServerState() != IServer.STATE_STARTED) { // start - return server.canStart(launchMode).isOK(); - } - // restart - String mode2 = launchMode; - if (mode2 == null) - mode2 = server.getMode(); - return server.getServerType() != null && UIDecoratorManager.getUIDecorator(server.getServerType()).canRestart() && server.canRestart(mode2).isOK(); - } - - /** - * Perform action on this server. - * @param server a server - */ - public void perform(IServer server) { - start(server, launchMode, shell); - } - - public static void start(IServer server, String launchMode, final Shell shell) { - if (server.getServerState() != IServer.STATE_STARTED) { - if (!ServerUIPlugin.saveEditors()) - return; - - /*final IAdaptable info = new IAdaptable() { - public Object getAdapter(Class adapter) { - if (Shell.class.equals(adapter)) - return shell; - return null; - } - };*/ - server.start(launchMode, (IOperationListener)null); - } else { - if (shell != null && !ServerUIPlugin.promptIfDirty(shell, server)) - return; - - try { - String launchMode2 = launchMode; - if (launchMode2 == null) - launchMode2 = server.getMode(); - server.restart(launchMode2, (IOperationListener) null); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error restarting server", e); - } - } - } - - public void selectionChanged(IStructuredSelection sel) { - super.selectionChanged(sel); - updateText(sel); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/StartModuleAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/StartModuleAction.java deleted file mode 100644 index 9395ebb01..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/StartModuleAction.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.view.servers; - -import org.eclipse.jface.action.Action; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.ui.internal.ImageResource; -import org.eclipse.wst.server.ui.internal.Messages; -/** - * Start a module on a server. - */ -public class StartModuleAction extends Action { - protected IServer server; - protected IModule[] module; - - public StartModuleAction(IServer server, IModule[] module) { - super(); - this.server = server; - this.module = module; - - setText(Messages.actionStartModule); - setImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_ELCL_START)); - setHoverImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_CLCL_START)); - setDisabledImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_DLCL_START)); - setEnabled(server.getServerState() == IServer.STATE_STARTED - && (server.getModuleState(module) == IServer.STATE_STOPPED - || server.getModuleState(module) == IServer.STATE_UNKNOWN) - && server.canControlModule(module, null).isOK()); - } - - /** - * Implementation of method defined on <code>IAction</code>. - */ - public void run() { - server.startModule(module, null); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/StopAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/StopAction.java deleted file mode 100644 index e1f495f30..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/StopAction.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.view.servers; - -import org.eclipse.core.runtime.jobs.IJobManager; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.ServerUtil; -import org.eclipse.wst.server.core.internal.Server; -import org.eclipse.wst.server.ui.internal.ImageResource; -import org.eclipse.wst.server.ui.internal.Messages; -import org.eclipse.wst.server.ui.internal.ServerUIPlugin; -import org.eclipse.swt.widgets.Shell; -/** - * Stop (terminate) a server. - */ -public class StopAction extends AbstractServerAction { - public StopAction(Shell shell, ISelectionProvider selectionProvider) { - super(shell, selectionProvider, Messages.actionStop); - setToolTipText(Messages.actionStopToolTip); - setImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_ELCL_STOP)); - setHoverImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_CLCL_STOP)); - setDisabledImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_DLCL_STOP)); - setActionDefinitionId("org.eclipse.wst.server.stop"); - try { - selectionChanged((IStructuredSelection) selectionProvider.getSelection()); - } catch (Exception e) { - // ignore - } - } - - /** - * Return true if this server can currently be acted on. - * @return boolean - * @param server a server - */ - public boolean accept(IServer server) { - if (server.getServerType() == null) - return false; - return server.getServerType() != null && server.canStop().isOK(); - } - - /** - * Perform action on this server. - * @param server a server - */ - public void perform(IServer server) { - stop(server, shell); - } - - public static void stop(IServer server, Shell shell) { - ServerUIPlugin.addTerminationWatch(shell, server, ServerUIPlugin.STOP); // TODO - should redo - - IJobManager jobManager = Job.getJobManager(); - Job[] jobs = jobManager.find(ServerUtil.SERVER_JOB_FAMILY); - for (Job j: jobs) { - if (j instanceof Server.StartJob) { - Server.StartJob startJob = (Server.StartJob) j; - if (startJob.getServer().equals(server)) { - startJob.cancel(); - return; - } - } - } - - server.stop(false); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/StopModuleAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/StopModuleAction.java deleted file mode 100644 index a0b4d137e..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/StopModuleAction.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.view.servers; - -import org.eclipse.jface.action.Action; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.ui.internal.ImageResource; -import org.eclipse.wst.server.ui.internal.Messages; -/** - * Stop a module on a server. - */ -public class StopModuleAction extends Action { - protected IServer server; - protected IModule[] module; - - public StopModuleAction(IServer server, IModule[] module) { - super(); - this.server = server; - this.module = module; - - setText(Messages.actionStopModule); - setImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_ELCL_STOP)); - setHoverImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_CLCL_STOP)); - setDisabledImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_DLCL_STOP)); - setEnabled(server.getServerState() == IServer.STATE_STARTED - && (server.getModuleState(module) == IServer.STATE_STARTED - || server.getModuleState(module) == IServer.STATE_UNKNOWN) - && server.canControlModule(module, null).isOK()); - } - - /** - * Implementation of method defined on <code>IAction</code>. - */ - public void run() { - server.stopModule(module, null); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/AbstractTableComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/AbstractTableComposite.java deleted file mode 100644 index 7f0362c2a..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/AbstractTableComposite.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.viewers; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.TableViewer; -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.Table; -/** - * - */ -public abstract class AbstractTableComposite extends Composite { - protected Table table; - protected TableViewer tableViewer; - - public AbstractTableComposite(Composite parent, int style) { - super(parent, style); - - createWidgets(); - } - - protected void createWidgets() { - GridLayout layout = new GridLayout(); - layout.marginWidth = 0; - layout.marginHeight = 0; - layout.numColumns = 1; - setLayout(layout); - - GridData data = new GridData(GridData.FILL_BOTH); - setLayoutData(data); - - createTable(); - data = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL); - table.setLayoutData(data); - table.setLinesVisible(true); - createTableViewer(); - } - - protected void createTable() { - table = new Table(this, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE); - } - - protected void createTableViewer() { - tableViewer = new LockedTableViewer(table); - } - - protected TableViewer getTableViewer() { - return tableViewer; - } - - protected Object getSelection(ISelection sel2) { - IStructuredSelection sel = (IStructuredSelection) sel2; - return sel.getFirstElement(); - } - - public void refresh() { - tableViewer.refresh(); - } - - public void refresh(Object obj) { - tableViewer.refresh(obj); - } - - public void remove(Object obj) { - tableViewer.remove(obj); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/AbstractTreeComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/AbstractTreeComposite.java deleted file mode 100644 index 784fafadb..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/AbstractTreeComposite.java +++ /dev/null @@ -1,163 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.viewers; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.DoubleClickEvent; -import org.eclipse.jface.viewers.IDoubleClickListener; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.viewers.ViewerSorter; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Link; -import org.eclipse.ui.dialogs.FilteredTree; -/** - * - */ -public abstract class AbstractTreeComposite extends Composite { - protected FilteredTree tree; - protected TreeViewer treeViewer; - protected Label description; - - public AbstractTreeComposite(Composite parent) { - super(parent, SWT.NONE); - - createWidgets(); - } - - protected void createWidgets() { - GridLayout layout = new GridLayout(); - layout.horizontalSpacing = 3; - layout.verticalSpacing = 3; - layout.marginWidth = 0; - layout.marginHeight = 0; - layout.numColumns = 2; - setLayout(layout); - - String descriptionText = getDescriptionLabel(); - if (descriptionText != null) { - Label label = new Label(this, SWT.WRAP); - label.setText(descriptionText); - GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER); - data.horizontalSpan = 2; - label.setLayoutData(data); - } - - String details = getDetailsLabel(); - if (details != null) { - Link prefLink = new Link(this, SWT.NONE); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END); - data.horizontalSpan = 2; - prefLink.setLayoutData(data); - prefLink.setText("<a>" + details + "</a>"); - prefLink.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - detailsSelected(); - } - }); - } - - Label label = new Label(this, SWT.WRAP); - label.setText(getTitleLabel()); - GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER); - if (descriptionText != null && details == null) - data.verticalIndent = 7; - data.horizontalSpan = 2; - label.setLayoutData(data); - - createTree(); - data = new GridData(GridData.FILL_BOTH); - data.horizontalSpan = 2; - tree.setLayoutData(data); - - treeViewer = tree.getViewer(); - treeViewer.setSorter(new ViewerSorter()); - treeViewer.addDoubleClickListener(new IDoubleClickListener() { - public void doubleClick(DoubleClickEvent event) { - IStructuredSelection s = (IStructuredSelection) event.getSelection(); - Object element = s.getFirstElement(); - if (treeViewer.isExpandable(element)) - treeViewer.setExpandedState(element, !treeViewer.getExpandedState(element)); - } - }); - - if (hasDescription()) { - description = new Label(this, SWT.WRAP); - description.setText("Multi\nLine\nMessage"); - Dialog.applyDialogFont(this); - Point p = description.computeSize(SWT.DEFAULT, SWT.DEFAULT); - description.setText(""); - data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER); - data.horizontalSpan = 2; - if (p.y > 10) - data.heightHint = p.y; - else - data.heightHint = 42; - description.setLayoutData(data); - } - - tree.forceFocus(); - } - - protected void createTree() { - tree = new FilteredTree(this, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE, new ServerPatternFilter()); - } - - protected abstract String getDescriptionLabel(); - - protected abstract String getTitleLabel(); - - protected boolean hasDescription() { - return true; - } - - protected void setDescription(String text) { - if (description != null && text != null) - description.setText(text); - } - - protected TreeViewer getTreeViewer() { - return treeViewer; - } - - protected Object getSelection(ISelection sel2) { - IStructuredSelection sel = (IStructuredSelection) sel2; - return sel.getFirstElement(); - } - - public void refresh() { - treeViewer.refresh(); - } - - public void refresh(Object obj) { - treeViewer.refresh(obj); - } - - public void remove(Object obj) { - treeViewer.remove(obj); - } - - protected String getDetailsLabel() { - return null; - } - - protected void detailsSelected() { - // do nothing - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/AbstractTreeContentProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/AbstractTreeContentProvider.java deleted file mode 100644 index 3e5e096b7..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/AbstractTreeContentProvider.java +++ /dev/null @@ -1,208 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.viewers; - -import java.util.*; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.wst.server.ui.internal.ServerUIPlugin; -/** - * Runtime type content provider. - */ -public abstract class AbstractTreeContentProvider implements ITreeContentProvider { - public static final String ROOT = "root"; - - protected Object initialSelection; - - public class TreeElement { - public String text; - public List<Object> contents; - } - - protected Object[] elements; - protected Map<Object, TreeElement> elementToParentMap = new HashMap<Object, TreeElement>(2); - protected Map<String, TreeElement> textMap = new HashMap<String, TreeElement>(2); - - /** - * AbstractTreeContentProvider constructor comment. - */ - public AbstractTreeContentProvider() { - super(); - - fillTree(); - } - - public AbstractTreeContentProvider(boolean init) { - super(); - } - - protected abstract void fillTree(); - - protected void clean() { - elements = null; - elementToParentMap = new HashMap<Object, TreeElement>(2); - textMap = new HashMap<String, TreeElement>(2); - - initialSelection = null; - } - - protected TreeElement getOrCreate(List<TreeElement> list, String text) { - try { - Object obj = textMap.get(text); - if (obj != null) - return (TreeElement) obj; - } catch (Exception e) { - return null; - } - - TreeElement element = new TreeElement(); - element.text = text; - element.contents = new ArrayList<Object>(); - textMap.put(text, element); - list.add(element); - return element; - } - - protected TreeElement getOrCreate(List<TreeElement> list, String id, String text) { - try { - Object obj = textMap.get(id); - if (obj != null) - return (TreeElement) obj; - } catch (Exception e) { - return null; - } - - TreeElement element = new TreeElement(); - element.text = text; - element.contents = new ArrayList<Object>(); - textMap.put(id, element); - list.add(element); - return element; - } - - protected TreeElement getByText(String text) { - try { - return textMap.get(text); - } catch (Exception e) { - return null; - } - } - - protected TreeElement getParentImpl(Object obj) { - try { - return elementToParentMap.get(obj); - } catch (Exception e) { - return null; - } - } - - /** - * Disposes of this content provider. - * This is called by the viewer when it is disposed. - */ - public void dispose() { - // do nothing - } - - /** - * Returns the elements to display in the viewer - * when its input is set to the given element. - * These elements can be presented as rows in a table, items in a list, etc. - * The result is not modified by the viewer. - * - * @param element the input element - * @return the array of elements to display in the viewer - */ - public Object[] getElements(Object element) { - return elements; - } - - public Object[] getChildren(Object element) { - if (!(element instanceof TreeElement)) - return null; - - TreeElement rte = (TreeElement) element; - return rte.contents.toArray(); - } - - public Object getParent(Object element) { - return getParentImpl(element); - } - - public boolean hasChildren(Object element) { - Object[] children = getChildren(element); - return children != null && children.length > 0; - } - - /** - * Notifies this content provider that the given viewer's input - * has been switched to a different element. - * <p> - * A typical use for this method is registering the content provider as a listener - * to changes on the new input (using model-specific means), and deregistering the viewer - * from the old input. In response to these change notifications, the content provider - * propagates the changes to the viewer. - * </p> - * - * @param viewer the viewer - * @param oldInput the old input element, or <code>null</code> if the viewer - * did not previously have an input - * @param newInput the new input element, or <code>null</code> if the viewer - * does not have an input - */ - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - // do nothing - } - - private Object[] getAllObjects() { - List<Object> list = new ArrayList<Object>(); - Object[] obj = getElements(null); - if (obj != null) { - int size = obj.length; - for (int i = 0; i < size; i++) { - if (!(obj[i] instanceof AbstractTreeContentProvider.TreeElement)) - list.add(obj[i]); - getAllChildren(list, obj[i]); - } - } - return list.toArray(); - } - - private void getAllChildren(List<Object> list, Object element) { - Object[] obj = getChildren(element); - if (obj != null) { - int size = obj.length; - for (int i = 0; i < size; i++) { - if (!(obj[i] instanceof AbstractTreeContentProvider.TreeElement)) - list.add(obj[i]); - getAllChildren(list, obj[i]); - } - } - } - - public Object getInitialSelection() { - if (initialSelection == null) { - InitialSelectionProvider isp = ServerUIPlugin.getInitialSelectionProvider(); - initialSelection = isp.getInitialSelection(getAllObjects()); - } - return initialSelection; - } - - public Object getInitialSelection(IProject project){ - if (initialSelection == null) { - InitialSelectionProvider isp = ServerUIPlugin.getInitialSelectionProvider(); - initialSelection = isp.getInitialSelection(getAllObjects(),project); - } - return initialSelection; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/AbstractTreeLabelProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/AbstractTreeLabelProvider.java deleted file mode 100644 index 04dbf678b..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/AbstractTreeLabelProvider.java +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.viewers; - -import org.eclipse.jface.viewers.ILabelDecorator; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; -/** - * Abstract tree label provider. - */ -public abstract class AbstractTreeLabelProvider extends BaseLabelProvider { - /** - * A standard tree label provider. - */ - public AbstractTreeLabelProvider() { - super(); - } - - /** - * A standard tree label provider. - * - * @param decorator a label decorator, or null if no decorator is required - */ - public AbstractTreeLabelProvider(ILabelDecorator decorator) { - super(decorator); - } - - /** - * @see BaseLabelProvider#getImage(Object) - */ - public Image getImage(Object element) { - if (element instanceof ServerTreeContentProvider.TreeElement) { - ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages(); - return sharedImages.getImage(ISharedImages.IMG_OBJ_FOLDER); - } - Image image = getImageImpl(element); - if (decorator != null) { - Image dec = decorator.decorateImage(image, element); - if (dec != null) - return dec; - } - return image; - } - - /** - * Return an image for the given element. - * - * @param element an element - * @return an image - */ - protected abstract Image getImageImpl(Object element); - - /** - * @see BaseLabelProvider#getText(Object) - */ - public String getText(Object element) { - if (element instanceof ServerTreeContentProvider.TreeElement) { - return ((ServerTreeContentProvider.TreeElement) element).text; - } - String text = getTextImpl(element); - if (decorator != null) { - String dec = decorator.decorateText(text, element); - if (dec != null && !dec.equals("")) - return dec; - } - return text; - } - - /** - * Return a label for the given element. - * - * @param element an element - * @return a label - */ - protected abstract String getTextImpl(Object element); -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/BaseCellLabelProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/BaseCellLabelProvider.java deleted file mode 100644 index 94ecc8cdd..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/BaseCellLabelProvider.java +++ /dev/null @@ -1,100 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.viewers; - -import org.eclipse.jface.viewers.*; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.ui.PlatformUI; -/** - * A basic cell label provider. - */ -public abstract class BaseCellLabelProvider extends ColumnLabelProvider { - public ILabelDecorator decorator; - protected ILabelProviderListener providerListener; - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ColumnLabelProvider#update(org.eclipse.jface.viewers.ViewerCell) - */ - public void update(ViewerCell cell){ - super.update(cell); - Object element = cell.getElement(); - int index = cell.getColumnIndex(); - cell.setText(getColumnText(element,index)); - Image image = getColumnImage(element, index); - cell.setImage(image); - } - - /** - * Create a BaseCellLabelProvider - */ - public BaseCellLabelProvider() { - super(); - } - - /** - * Create a BaseCellLabelProvider with a decorator at the front of the row - * @param decorator - */ - public BaseCellLabelProvider(ILabelDecorator decorator) { - super(); - - if (decorator == null){ - decorator = PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator(); - providerListener = new ILabelProviderListener() { - @SuppressWarnings("synthetic-access") - public void labelProviderChanged(LabelProviderChangedEvent event) { - fireLabelProviderChanged(event); - } - }; - decorator.addListener(providerListener); - } - - this.decorator = decorator; - } - - public Point getToolTipShift(Object object) { - return new Point(5, 5); - } - - public int getToolTipDisplayDelayTime(Object object) { - return 2000; - } - - public int getToolTipTimeDisplayed(Object object) { - return 5000; - } - - public void dispose() { - if (decorator != null && providerListener != null) { - decorator.removeListener(providerListener); - } - super.dispose(); - } - - /** - * Extenders of this class would implement this method to provide an image to the column based on the element - * being passed - * @param element - * @param index - * @return an image - */ - public abstract Image getColumnImage(Object element, int index); - - /** - * Extenders of this class would implement this method to provide a text label to the column based on the element - * being passed - * @param element - * @param index - * @return a string - */ - public abstract String getColumnText(Object element, int index); -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/BaseContentProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/BaseContentProvider.java deleted file mode 100644 index a9552ad9e..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/BaseContentProvider.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.viewers; - -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.Viewer; - -public abstract class BaseContentProvider implements IStructuredContentProvider { - public BaseContentProvider() { - super(); - } - - public void dispose() { - // do nothing - } - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - // do nothing - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/BaseLabelProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/BaseLabelProvider.java deleted file mode 100644 index a8cf616cd..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/BaseLabelProvider.java +++ /dev/null @@ -1,142 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.viewers; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jface.viewers.ILabelDecorator; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.jface.viewers.LabelProviderChangedEvent; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.server.core.internal.Trace; -/** - * A basic label provider. - */ -public abstract class BaseLabelProvider implements ILabelProvider { - protected ILabelDecorator decorator; - private transient List<ILabelProviderListener> listeners; - private ILabelProviderListener providerListener; - - /** - * A basic ILabelProvider with no decorator. - */ - public BaseLabelProvider() { - this(null); - } - - /** - * A basic ILabelProvider with support for a decorator. - * - * @param decorator a label decorator, or null if no decorator is required - */ - public BaseLabelProvider(ILabelDecorator decorator) { - super(); - if (decorator == null) - decorator = PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator(); - - this.decorator = decorator; - if (decorator != null) { - providerListener = new ILabelProviderListener() { - public void labelProviderChanged(LabelProviderChangedEvent event) { - fireListener(event); - } - }; - decorator.addListener(providerListener); - } - } - - /** - * Use this method to avoid having a label decorator. This method is NOT API. - * - * @param noDecorator - */ - public BaseLabelProvider(boolean noDecorator) { - super(); - } - - /** - * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener) - */ - public void addListener(ILabelProviderListener listener) { - if (listener == null) - throw new IllegalArgumentException("Listener cannot be null"); - - if (listeners == null) - listeners = new ArrayList<ILabelProviderListener>(); - listeners.add(listener); - } - - /** - * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener) - */ - public void removeListener(ILabelProviderListener listener) { - if (listener == null) - throw new IllegalArgumentException("Listener cannot be null"); - - if (listeners != null) - listeners.remove(listener); - } - - protected void fireListener(LabelProviderChangedEvent event) { - if (listeners == null || listeners.isEmpty()) - return; - - int size = listeners.size(); - ILabelProviderListener[] srl = new ILabelProviderListener[size]; - listeners.toArray(srl); - - for (int i = 0; i < size; i++) { - try { - srl[i].labelProviderChanged(event); - } catch (Exception e) { - Trace.trace(Trace.WARNING, " Error firing label change event to " + srl[i], e); - } - } - } - - /** - * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() - */ - public void dispose() { - if (decorator != null) - decorator.removeListener(providerListener); - } - - /** - * @see ILabelProvider#getImage(java.lang.Object) - */ - public Image getImage(Object element) { - return null; - } - - /** - * @see ILabelProvider#getText(java.lang.Object) - */ - public String getText(Object element) { - return ""; - } - - /** - * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String) - */ - public boolean isLabelProperty(Object element, String property) { - return false; - } - - protected String notNull(String s) { - if (s == null) - return ""; - return s; - } -} diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/DefaultViewerSorter.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/DefaultViewerSorter.java deleted file mode 100644 index 97f615852..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/DefaultViewerSorter.java +++ /dev/null @@ -1,208 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.viewers; - -import java.util.ArrayList; -import java.util.List; -import java.util.StringTokenizer; - -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerSorter; -import org.eclipse.wst.server.core.IRuntimeType; -import org.eclipse.wst.server.core.IServerType; -/** - * Class used to sort categories, runtime types, and server types in the - * New wizards. - */ -public class DefaultViewerSorter extends ViewerSorter { - public static class Version implements Comparable { - private static final String SEPARATORS = ".,"; - - private final String[] segments; - - private Version(String[] segments) { - this.segments = segments; - } - - public static Version parseVersion(String version) { - List<String> list = new ArrayList<String>(); - StringTokenizer st = new StringTokenizer(version, SEPARATORS, false); - while (st.hasMoreTokens()) - list.add(st.nextToken()); - - String[] s = new String[list.size()]; - list.toArray(s); - return new Version(s); - } - - private int compareTo(String s1, String s2) { - try { - int i1 = Integer.parseInt(s1); - int i2 = Integer.parseInt(s2); - if (i1 == i2) - return 0; - if (i1 > i2) - return 1; - return -1; - } catch (Exception e) { - // ignore - } - return s1.compareTo(s2); - } - - public int compareTo(Object object) { - if (object == this) - return 0; - - Version other = (Version) object; - int i = 0; - while (i < segments.length && i < other.segments.length) { - String s1 = segments[i]; - String s2 = other.segments[i]; - int c = compareTo(s1, s2); - if (c != 0) - return c; - i++; - } - - if (i == segments.length && i == other.segments.length) - return 0; - - if (i == segments.length) - return -1; - return 1; - } - } - - /** - * @see ViewerSorter#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) - */ - public int compare(Viewer viewer, Object o1, Object o2) { - if (o1 instanceof AbstractTreeContentProvider.TreeElement) - o1 = ((AbstractTreeContentProvider.TreeElement) o1).text; - - if (o2 instanceof AbstractTreeContentProvider.TreeElement) - o2 = ((AbstractTreeContentProvider.TreeElement) o2).text; - - // filter out strings - if (o1 instanceof String && o2 instanceof String) - return compareCategories((String) o1, (String) o2); - if (o1 instanceof String) - return -1; - if (o2 instanceof String) - return 1; - - if (o1 instanceof IRuntimeType && o2 instanceof IRuntimeType) - return compareRuntimeTypes((IRuntimeType) o1, (IRuntimeType) o2); - - if (o1 instanceof IServerType && o2 instanceof IServerType) - return compareServerTypes((IServerType) o1, (IServerType) o2); - - return 0; - } - - /** - * Sort two category names. - * - * @param s1 the first category - * @param s2 the second category - * @return a negative number if the first element is less than the - * second element; the value <code>0</code> if the first element is - * equal to the second element; and a positive number if the first - * element is greater than the second element - */ - protected static int compareCategories(String s1, String s2) { - try { - Version v1 = Version.parseVersion(s1); - Version v2 = Version.parseVersion(s2); - - return v1.compareTo(v2); - } catch (NumberFormatException nfe) { - // ignore - } - - return s1.compareTo(s2); - } - - /** - * Returns <code>true</code> if the two items are in the same 'family', and - * <code>false</code> otherwise. - * - * @param s1 - first name - * @param v1 - first version - * @param s2 - second name - * @param v2 - second version - * @return <code>true</code> if the two items are in the same 'family', and - * <code>false</code> otherwise - */ - protected static boolean isSameFamily(String s1, String v1, String s2, String v2) { - if (s1 == null || s2 == null) - return false; - - if (v1 != null) { - int ind = s1.indexOf(v1); - if (ind >= 0) - s1 = s1.substring(0, ind) + s1.substring(ind+v1.length()); - } - - if (v2 != null) { - int ind = s2.indexOf(v2); - if (ind >= 0) - s2 = s2.substring(0, ind) + s2.substring(ind+v2.length()); - } - return (s1.equals(s2)); - } - - protected static int compareVersions(String s1, String s2) { - Version v1 = Version.parseVersion(s1); - Version v2 = Version.parseVersion(s2); - - return v1.compareTo(v2); - } - - /** - * Sort two runtime types. - * - * @param r1 the first runtime type - * @param r2 the second runtime type - * @return a negative number if the first element is less than the - * second element; the value <code>0</code> if the first element is - * equal to the second element; and a positive number if the first - * element is greater than the second element - */ - protected static int compareRuntimeTypes(IRuntimeType r1, IRuntimeType r2) { - if (isSameFamily(r1.getName(), r1.getVersion(), r2.getName(), r2.getVersion())) - return compareVersions(r1.getVersion(), r2.getVersion()); - - return r1.getName().compareToIgnoreCase(r2.getName()); - } - - /** - * Sort two server types. - * - * @param s1 the first server type - * @param s2 the second server type - * @return a negative number if the first element is less than the - * second element; the value <code>0</code> if the first element is - * equal to the second element; and a positive number if the first - * element is greater than the second element - */ - protected static int compareServerTypes(IServerType s1, IServerType s2) { - IRuntimeType r1 = s1.getRuntimeType(); - IRuntimeType r2 = s2.getRuntimeType(); - if (r1 != null && r2 != null) { - if (isSameFamily(s1.getName(), r1.getVersion(), s2.getName(), r2.getVersion())) - return compareVersions(r1.getVersion(), r2.getVersion()); - } - - return s1.getName().compareToIgnoreCase(s2.getName()); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ILockedLabelProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ILockedLabelProvider.java deleted file mode 100644 index 7171e03a6..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ILockedLabelProvider.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.viewers; -/** - * Extends <code>ITableLabelProvider</code> with methods to provide - * lock information. - */ -public interface ILockedLabelProvider { - /** - * Returns the lock info for the element. This value will be used - * to change the presentation of the table row. - * - * @param element the object representing the entire row, or - * <code>null</code> indicating that no input object is set - * in the viewer - * @return <code>true</code> if the item is locked, and <code>false</code> - * otherwise - */ - public boolean isLocked(Object element); -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/InitialSelectionProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/InitialSelectionProvider.java deleted file mode 100644 index 248fad9ba..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/InitialSelectionProvider.java +++ /dev/null @@ -1,264 +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.server.ui.internal.viewers; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.viewers.ViewerSorter; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; -import org.eclipse.wst.server.core.*; -import org.eclipse.wst.server.core.internal.ResourceManager; -import org.eclipse.wst.server.core.internal.facets.FacetUtil; -import org.eclipse.wst.server.ui.internal.ServerUIPlugin; -import org.eclipse.wst.server.ui.internal.Trace; -/** - * Class used to sort categories, runtime types, and server types in the - * New wizards. - */ -public class InitialSelectionProvider extends ViewerSorter { - - public Object getInitialSelection(Object[] obj) { - if (obj == null || obj.length == 0) - return null; - - if (obj[0] instanceof IRuntimeType) { - int size = obj.length; - IRuntimeType[] rt = new IRuntimeType[size]; - for (int i = 0; i < size; i++) - rt[i] = (IRuntimeType) obj[i]; - return getInitialSelection(rt); - } - - if (obj[0] instanceof IServerType) { - int size = obj.length; - IServerType[] st = new IServerType[size]; - for (int i = 0; i < size; i++) - st[i] = (IServerType) obj[i]; - return getInitialSelection(st); - } - - if (obj[0] instanceof IServer) { - int size = obj.length; - IServer[] st = new IServer[size]; - for (int i = 0; i < size; i++) - st[i] = (IServer) obj[i]; - return getInitialSelection(st); - } - - return null; - } - - /** - * - * @param serverTypes - * @return the initial selection - */ - public IServerType getInitialSelection(IServerType[] serverTypes) { - if (serverTypes == null) - return null; - - int size = serverTypes.length; - for (int i = 0; i < size; i++) { - if (hasRuntime(serverTypes[i])) - return serverTypes[i]; - } - return getDefaultServerType(serverTypes); - } - - /** - * - * @param servers - * @return the initial selection - */ - public IServer getInitialSelection(IServer[] servers) { - return getInitialSelection(servers,null); - } - - /** - * Allows adopters to provide an initial selection out of a list of items. - * <p> - * The <code>IProject</code> can be null, in cases where a project selection was not available (ie: New Server Wizard) - * </p><p> - * Returning <code>null</code> means no object is applicable to be selected. - * </p> - * - * @param servers - * @param project - * @return - */ - public IServer getInitialSelection(IServer[] servers, IProject project){ - if (servers == null) - return null; - - IServer rval = servers[0]; - - if (project != null){ - try{ - // check for the targeted runtime of the project - IFacetedProject facetedProject = ProjectFacetsManager.create(project); - if (facetedProject != null){ - org.eclipse.wst.common.project.facet.core.runtime.IRuntime facetedRuntime = facetedProject.getPrimaryRuntime(); - if (facetedRuntime != null){ - IRuntime runtime = FacetUtil.getRuntime(facetedRuntime); - IServer server = findServerFromRuntime(runtime.getId()); - if (server != null){ - rval = server; - } - } - } - } - catch (CoreException ce){ - Trace.trace(Trace.WARNING,"Could not create a faceted project",ce); - } - } - return rval; - } - - /** - * - * @param runtimeTypes - * @return the initial selection - */ - public IRuntimeType getInitialSelection(IRuntimeType[] runtimeTypes) { - if (runtimeTypes == null) - return null; - - int size = runtimeTypes.length; - for (int i = 0; i < size; i++) { - if (hasRuntime(runtimeTypes[i])) - return runtimeTypes[i]; - } - return getDefaultRuntimeType(runtimeTypes); - } - - protected boolean hasRuntime(IServerType serverType) { - return hasRuntime(serverType.getRuntimeType()); - } - - protected boolean hasRuntime(IRuntimeType runtimeType) { - if (runtimeType == null) - return false; - IRuntime[] runtimes = ServerUIPlugin.getRuntimes(runtimeType); - return runtimes != null && runtimes.length > 0; - } - - /** - * Returns a default server type, typically the 'first' one sorted - * alphabetically by name. - * - * @param serverTypes - * @return the default server type - */ - protected IServerType getDefaultServerType(IServerType[] serverTypes) { - if (serverTypes == null) - return null; - - int size = serverTypes.length; - if (size == 1) - return serverTypes[0]; - - IServerType first = serverTypes[0]; - for (int i = 1; i < size; i++) { - if (DefaultViewerSorter.compareServerTypes(first, serverTypes[i]) > 0) - first = serverTypes[i]; - } - return first; - } - - /** - * Returns a default runtime type, typically the 'first' one sorted - * alphabetically by name. - * - * @param runtimeTypes - * @return the default runtime type - */ - protected IRuntimeType getDefaultRuntimeType(IRuntimeType[] runtimeTypes) { - if (runtimeTypes == null) - return null; - - int size = runtimeTypes.length; - if (size == 1) - return runtimeTypes[0]; - - IRuntimeType first = runtimeTypes[0]; - for (int i = 1; i < size; i++) { - if (DefaultViewerSorter.compareRuntimeTypes(first, runtimeTypes[i]) > 0) - first = runtimeTypes[i]; - } - return first; - } - - /** - * Allows adopters to provide an initial selection out of a list of items. - * <p> - * The <code>IProject</code> can be null, in cases where a project selection was not available (ie: New Server Wizard) - * </p><p> - * Returning <code>null</code> means no object is applicable to be selected. - * </p> - * - * @param obj Contains an array of all the possible object to be selected. - * @param project - * @return The object to be selected from the <code>obj[]</code> - */ - public Object getInitialSelection(Object [] obj, IProject project){ - if (obj == null || obj.length == 0) - return null; - - if (obj[0] instanceof IRuntimeType) { - int size = obj.length; - IRuntimeType[] rt = new IRuntimeType[size]; - for (int i = 0; i < size; i++) - rt[i] = (IRuntimeType) obj[i]; - return getInitialSelection(rt); - } - - if (obj[0] instanceof IServerType) { - int size = obj.length; - IServerType[] st = new IServerType[size]; - for (int i = 0; i < size; i++) - st[i] = (IServerType) obj[i]; - return getInitialSelection(st); - } - - if (obj[0] instanceof IServer) { - int size = obj.length; - IServer[] st = new IServer[size]; - for (int i = 0; i < size; i++) - st[i] = (IServer) obj[i]; - return getInitialSelection(st,project); - } - - return null; - } - - /** - * Returns the server with the given runtime id, or <code>null</code> - * if none. This convenience method searches the list of registered servers - * for the matching runtime id. The id may not be null. - * - * @param runtimeId - * @return - */ - private static IServer findServerFromRuntime(String runtimeId){ - if (runtimeId == null) - throw new IllegalArgumentException(); - - IServer [] servers = ResourceManager.getInstance().getServers(); - for (IServer server:servers){ - if (runtimeId == server.getRuntime().getId()){ - return server; - } - } - return null; - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/LockedCheckboxTableViewer.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/LockedCheckboxTableViewer.java deleted file mode 100644 index ea06b4b55..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/LockedCheckboxTableViewer.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.viewers; - -import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableItem; -import org.eclipse.swt.widgets.Widget; -/** - * - */ -public class LockedCheckboxTableViewer extends CheckboxTableViewer { - protected Color color; - - public LockedCheckboxTableViewer(Table table) { - super(table); - createColor(table); - } - - protected void createColor(Control c) { - color = new Color(c.getDisplay(), 255, 255, 225); - c.addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - color.dispose(); - } - }); - } - - public void doUpdateItem(Widget widget, Object element, boolean fullMap) { - if (color == null) - return; - if (widget instanceof TableItem) { - TableItem item = (TableItem) widget; - if (getLabelProvider() instanceof ILockedLabelProvider) { - ILockedLabelProvider provider = (ILockedLabelProvider) getLabelProvider(); - if (provider.isLocked(element)) { - item.setBackground(color); - item.setImage(0, null); - } else - item.setBackground(null); - } - } - super.doUpdateItem(widget, element, fullMap); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/LockedTableViewer.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/LockedTableViewer.java deleted file mode 100644 index 1ec2d15b9..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/LockedTableViewer.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.viewers; - -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableItem; -import org.eclipse.swt.widgets.Widget; -/** - * - */ -public class LockedTableViewer extends TableViewer { - protected Color color; - - public LockedTableViewer(Composite parent) { - super(parent); - createColor(parent); - } - - public LockedTableViewer(Composite parent, int style) { - super(parent, style); - createColor(parent); - } - - public LockedTableViewer(Table table) { - super(table); - createColor(table); - } - - protected void createColor(Control c) { - color = new Color(c.getDisplay(), 255, 255, 225); - c.addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - color.dispose(); - } - }); - } - - public void doUpdateItem(Widget widget, Object element, boolean fullMap) { - if (color == null) - return; - if (widget instanceof TableItem) { - TableItem item = (TableItem) widget; - if (getLabelProvider() instanceof ILockedLabelProvider) { - ILockedLabelProvider provider = (ILockedLabelProvider) getLabelProvider(); - if (provider.isLocked(element)) { - item.setBackground(color); - item.setImage(0, null); - } else - item.setBackground(null); - } - } - super.doUpdateItem(widget, element, fullMap); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ModuleArtifactComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ModuleArtifactComposite.java deleted file mode 100644 index 119c787d5..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ModuleArtifactComposite.java +++ /dev/null @@ -1,184 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007,2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.viewers; - -import org.eclipse.debug.core.ILaunchManager; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.viewers.*; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; -import org.eclipse.wst.server.core.IModuleArtifact; -import org.eclipse.wst.server.core.model.ModuleArtifactDelegate; -import org.eclipse.wst.server.ui.internal.Messages; - -public class ModuleArtifactComposite extends Dialog { - protected IModuleArtifact[] moduleArtifacts; - private ListViewer listViewer; - private String launchMode; - private IModuleArtifact selection; - - /** - * Creates a Selection dialog with the list of available IModuleArtifact for the selected resource - * @param parent - * @param moduleArtifacts - * @param launchMode - */ - public ModuleArtifactComposite(Shell parent,final IModuleArtifact[] moduleArtifacts, String launchMode){ - super(parent); - setShellStyle(SWT.RESIZE | getShellStyle()); - this.moduleArtifacts = moduleArtifacts; - this.launchMode = launchMode; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) - */ - protected void configureShell(Shell shell) { - super.configureShell(shell); - shell.setText(getWindowTitle()); - } - - /** - * Based on the launch mode, return the NLS String for the Dialog. - * - * @return the window title - */ - private String getWindowTitle() { - String title = Messages.wizRunOnServerTitle; - - if (ILaunchManager.DEBUG_MODE.equals(launchMode)) - title = Messages.wizDebugOnServerTitle; - else if (ILaunchManager.PROFILE_MODE.equals(launchMode)) - title = Messages.wizProfileOnServerTitle; - return title; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) - */ - protected Control createDialogArea(Composite parent) { - Composite composite = new Composite(parent,SWT.NONE); - - GridLayout layout = new GridLayout(); - layout.marginWidth = 10; - layout.marginHeight = 10; - layout.verticalSpacing = 10; - layout.numColumns = 1; - - GridData data = new GridData(GridData.FILL_BOTH); - - composite.setLayout(layout); - composite.setLayoutData(data); - composite.setFont(parent.getFont()); - - Text description = new Text(composite,SWT.NONE); - description.setText(Messages.wizModuleArtifactsDescription); - description.setEditable(false); - description.setCursor(composite.getDisplay().getSystemCursor(SWT.CURSOR_ARROW)); - - createContent(composite); - - return composite; - } - - private void createContent(Composite parent) { - Composite contentComposite = new Composite(parent,SWT.NONE |SWT.RESIZE); - GridLayout layout = new GridLayout(); - layout.marginWidth = 10; - layout.verticalSpacing = 5; - layout.numColumns = 1; - - GridData data = new GridData(GridData.FILL_BOTH); - - contentComposite.setLayout(layout); - contentComposite.setLayoutData(data); - contentComposite.setFont(parent.getFont()); - - Label tableTitle = new Label(contentComposite,SWT.None); - tableTitle.setText(Messages.wizModuleArtifactsAvailableList); - - listViewer = new ListViewer(contentComposite,SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); - data = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL); - listViewer.getList().setLayoutData(data); - listViewer.getList().setFocus(); - - listViewer.setContentProvider(new BaseContentProvider() { - public Object[] getElements(Object inputElement) { - return moduleArtifacts; - } - }); - - listViewer.setLabelProvider(new BaseLabelProvider() { - public String getText(Object element) { - if (element instanceof ModuleArtifactDelegate) { - // Try to display the object using its name - ModuleArtifactDelegate moduleArtifact = (ModuleArtifactDelegate)element; - String artifactName = moduleArtifact.getName(); - if (artifactName != null && artifactName.length() >= 0) { - int classNameIndex = artifactName.lastIndexOf("."); - String packageName = artifactName.substring(0, classNameIndex); - String className = artifactName.substring(classNameIndex+1); - if (packageName != null && (packageName.length()<=0) == false){ - return className + " ("+moduleArtifact.getName()+")"; - } - return moduleArtifact.getName(); - } - - // If the name is empty we can then use the module artifact class name - return moduleArtifact.getClass().getName(); - } - return Messages.elementUnknownName; - } - }); - - listViewer.addDoubleClickListener(new IDoubleClickListener() { - public void doubleClick(DoubleClickEvent event) { - buttonPressed(IDialogConstants.OK_ID); - } - }); - - listViewer.setInput(AbstractTreeContentProvider.ROOT); - } - - /** - * Return the selection of the dialog - * - * @return the selected module artifact - */ - public IModuleArtifact getSelection() { - IStructuredSelection selection2 = (IStructuredSelection) listViewer.getSelection(); - if (selection2 == null || selection2.getFirstElement() == null) - return selection; - - selection = (IModuleArtifact)selection2.getFirstElement(); - return selection; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int) - */ - protected void buttonPressed(int buttonId) { - if (buttonId == IDialogConstants.OK_ID) { - if (getSelection() == null){ - MessageBox messageBox = new MessageBox(getShell(),SWT.ICON_ERROR | SWT.OK); - messageBox.setMessage(Messages.wizModuleArtifactsNoSelectionError); - messageBox.setText(getWindowTitle()); - messageBox.open(); - // bypass the call to super, so that this Dialog doesn't get disposed - return; - } - } - super.buttonPressed(buttonId); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/MonitorComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/MonitorComposite.java deleted file mode 100644 index 17064c78e..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/MonitorComposite.java +++ /dev/null @@ -1,231 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.viewers; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.viewers.*; -import org.eclipse.jface.window.Window; -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.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.ServerPort; -import org.eclipse.wst.server.core.internal.IMonitoredServerPort; -import org.eclipse.wst.server.core.internal.IServerMonitorManager; -import org.eclipse.wst.server.core.internal.ServerMonitorManager; -import org.eclipse.wst.server.ui.internal.EclipseUtil; -import org.eclipse.wst.server.ui.internal.Messages; -import org.eclipse.wst.server.ui.internal.SWTUtil; -/** - * - */ -public class MonitorComposite extends Composite { - //protected ServerPort selection; - protected PortSelectionListener listener; - protected IServer server; - - protected IServerMonitorManager smm; - - protected Table monitorTable; - protected TableViewer monitorTableViewer; - - public interface PortSelectionListener { - public void portSelected(ServerPort port); - } - - public MonitorComposite(Composite parent, int style, PortSelectionListener listener2, IServer server) { - super(parent, style); - this.listener = listener2; - this.server = server; - - smm = ServerMonitorManager.getInstance(); - - GridLayout layout = new GridLayout(); - layout.marginWidth = 0; - layout.marginHeight = 0; - layout.verticalSpacing = 5; - layout.horizontalSpacing = 5; - layout.numColumns = 2; - setLayout(layout); - - GridData data = new GridData(GridData.FILL_BOTH); - setLayoutData(data); - - monitorTable = new Table(this, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.FULL_SELECTION); - data = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL); - //data.horizontalSpan = 2; - data.heightHint = 150; - //data.widthHint = 340; - monitorTable.setLayoutData(data); - monitorTable.setLinesVisible(true); - monitorTableViewer = new TableViewer(monitorTable); - - TableLayout tableLayout = new TableLayout(); - monitorTable.setLayout(tableLayout); - monitorTable.setHeaderVisible(true); - - tableLayout.addColumnData(new ColumnWeightData(8, 80, true)); - TableColumn col = new TableColumn(monitorTable, SWT.NONE); - col.setText(Messages.dialogMonitorColumnStatus); - - tableLayout.addColumnData(new ColumnWeightData(12, 120, true)); - col = new TableColumn(monitorTable, SWT.NONE); - col.setText(Messages.dialogMonitorColumnType); - - tableLayout.addColumnData(new ColumnWeightData(8, 80, true)); - col = new TableColumn(monitorTable, SWT.NONE); - col.setText(Messages.dialogMonitorColumnPort); - - tableLayout.addColumnData(new ColumnWeightData(8, 80, true)); - col = new TableColumn(monitorTable, SWT.NONE); - col.setText(Messages.dialogMonitorColumnMonitorPort); - - tableLayout.addColumnData(new ColumnWeightData(8, 80, true)); - col = new TableColumn(monitorTable, SWT.NONE); - col.setText(Messages.dialogMonitorColumnContentType); - - monitorTableViewer.setContentProvider(new MonitorContentProvider(server)); - monitorTableViewer.setLabelProvider(new MonitorLabelProvider(server)); - monitorTableViewer.setInput(AbstractTreeContentProvider.ROOT); - - monitorTableViewer.setSorter(new ViewerSorter() { - public int compare(Viewer viewer, Object e1, Object e2) { - IMonitoredServerPort port1 = (IMonitoredServerPort) e1; - IMonitoredServerPort port2 = (IMonitoredServerPort) e2; - if (port1.getServerPort().getPort() == port2.getServerPort().getPort()) { - if (port1.getMonitorPort() == port2.getMonitorPort()) { - return 0; - } else if (port1.getMonitorPort() > port2.getMonitorPort()) - return 1; - else - return -1; - } else if (port1.getServerPort().getPort() > port2.getServerPort().getPort()) - return 1; - else - return -1; - } - }); - - Composite buttonComp = new Composite(this, SWT.NONE); - buttonComp.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING)); - layout = new GridLayout(); - layout.marginWidth = 0; - layout.marginHeight = 0; - buttonComp.setLayout(layout); - - final IServer server2 = server; - Button add = SWTUtil.createButton(buttonComp, Messages.add); - add.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - MonitorDialog dialog = new MonitorDialog(getShell(), server2); - if (dialog.open() != Window.CANCEL) { - ServerPort port = dialog.getServerPort(); - IMonitoredServerPort sp = smm.createMonitor(server2, port, dialog.getMonitorPort(), dialog.getContentTypes()); - if (sp != null) - monitorTableViewer.add(sp); - } - } - }); - if (server.getServerType() == null) - add.setEnabled(false); - - final Button edit = SWTUtil.createButton(buttonComp, Messages.edit); - edit.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - IStructuredSelection sel = (IStructuredSelection) monitorTableViewer.getSelection(); - IMonitoredServerPort port = (IMonitoredServerPort) sel.getFirstElement(); - MonitorDialog dialog = new MonitorDialog(getShell(), server2, port.getServerPort(), port.getMonitorPort(), port.getContentTypes()); - if (dialog.open() != Window.CANCEL) { - smm.removeMonitor(port); - monitorTableViewer.remove(port); - port = smm.createMonitor(server2, dialog.getServerPort(), dialog.getMonitorPort(), dialog.getContentTypes()); - if (port != null) { - monitorTableViewer.add(port); - monitorTableViewer.setSelection(new StructuredSelection(port)); - } - } - } - }); - edit.setEnabled(false); - - final Button remove = SWTUtil.createButton(buttonComp, Messages.remove); - remove.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - IMonitoredServerPort msp = (IMonitoredServerPort) getSelection(monitorTableViewer.getSelection()); - if (msp.isStarted()) - smm.stopMonitor(msp); - smm.removeMonitor(msp); - monitorTableViewer.remove(msp); - } - }); - remove.setEnabled(false); - - final Button start = SWTUtil.createButton(buttonComp, Messages.start); - start.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - IStructuredSelection sel = (IStructuredSelection) monitorTableViewer.getSelection(); - IMonitoredServerPort msp = (IMonitoredServerPort) sel.getFirstElement(); - try { - smm.startMonitor(msp); - } catch (CoreException ce) { - EclipseUtil.openError(getShell(), ce.getLocalizedMessage()); - } - monitorTableViewer.refresh(msp); - monitorTableViewer.setSelection(new StructuredSelection(msp)); - } - }); - start.setEnabled(false); - - final Button stop = SWTUtil.createButton(buttonComp, Messages.stop); - stop.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - IStructuredSelection sel = (IStructuredSelection) monitorTableViewer.getSelection(); - IMonitoredServerPort msp = (IMonitoredServerPort) sel.getFirstElement(); - smm.stopMonitor(msp); - monitorTableViewer.refresh(msp); - monitorTableViewer.setSelection(new StructuredSelection(msp)); - } - }); - stop.setEnabled(false); - - monitorTableViewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - IMonitoredServerPort port = (IMonitoredServerPort) getSelection(monitorTableViewer.getSelection()); - if (port != null) { - edit.setEnabled(!port.isStarted()); - remove.setEnabled(true); - start.setEnabled(!port.isStarted()); - stop.setEnabled(port.isStarted()); - } else { - edit.setEnabled(false); - remove.setEnabled(false); - start.setEnabled(false); - stop.setEnabled(false); - } - } - }); - - IMonitoredServerPort[] msps = ServerMonitorManager.getInstance().getMonitoredPorts(server); - if (msps != null && msps.length > 0) - monitorTableViewer.setSelection(new StructuredSelection(msps[0])); - } - - protected Object getSelection(ISelection sel2) { - IStructuredSelection sel = (IStructuredSelection) sel2; - return sel.getFirstElement(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/MonitorContentProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/MonitorContentProvider.java deleted file mode 100644 index 58931368a..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/MonitorContentProvider.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.viewers; - -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.internal.ServerMonitorManager; -/** - * Monitor port content provider. - */ -public class MonitorContentProvider extends BaseContentProvider { - protected IServer server; - - public MonitorContentProvider(IServer server) { - super(); - this.server = server; - } - - public Object[] getElements(Object inputElement) { - return ServerMonitorManager.getInstance().getMonitoredPorts(server); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/MonitorDialog.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/MonitorDialog.java deleted file mode 100644 index b68ee86db..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/MonitorDialog.java +++ /dev/null @@ -1,247 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.viewers; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.viewers.*; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; - -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.ServerPort; -import org.eclipse.wst.server.ui.internal.Messages; -/** - * Dialog that prompts a user to add or edit a server monitor. - */ -public class MonitorDialog extends Dialog { - protected IServer server; - protected ServerPort port; - protected int monitorPort = -1; - protected String[] portContentTypes; - protected String[] contentTypes; - protected boolean isEdit = false; - protected boolean portChanged = false; - - protected Button ok; - - protected Table table; - protected TableViewer tableViewer; - protected boolean init; - - /** - * MonitorDialog constructor comment. - * - * @param parentShell the shell - * @param server the server - */ - public MonitorDialog(Shell parentShell, IServer server) { - super(parentShell); - - this.server = server; - } - - public MonitorDialog(Shell parentShell, IServer server, ServerPort port, int monitorPort, String[] contentTypes) { - this(parentShell, server); - this.monitorPort = monitorPort; - this.contentTypes = contentTypes; - this.port = port; - isEdit = true; - } - - /** - * - */ - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - newShell.setText(Messages.dialogMonitorTitle); - } - - protected void createButtonsForButtonBar(Composite parent) { - ok = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); - createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); - } - - /** - * - */ - protected Control createDialogArea(Composite parent) { - // create a composite with standard margins and spacing - Composite composite = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); - layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); - layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); - layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); - layout.numColumns = 2; - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - composite.setFont(parent.getFont()); - //WorkbenchHelp.setHelp(composite, ContextIds.TERMINATE_SERVER_DIALOG); - - Label label = new Label(composite, SWT.WRAP); - label.setText(NLS.bind(Messages.dialogMonitorAddDescription, new String[] { server.getName() } )); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - data.horizontalSpan = 2; - data.widthHint = 275; - label.setLayoutData(data); - - table = new Table(composite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE | SWT.FULL_SELECTION); - data = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL); - data.heightHint = 100; - data.horizontalSpan = 2; - table.setLayoutData(data); - table.setLinesVisible(true); - tableViewer = new TableViewer(table); - - TableLayout tableLayout = new TableLayout(); - table.setLayout(tableLayout); - table.setHeaderVisible(true); - - tableLayout.addColumnData(new ColumnWeightData(12, 120, true)); - TableColumn col = new TableColumn(table, SWT.NONE); - col.setText(Messages.dialogMonitorColumnType); - - tableLayout.addColumnData(new ColumnWeightData(4, 40, true)); - col = new TableColumn(table, SWT.NONE); - col.setText(Messages.dialogMonitorColumnPort); - - tableViewer.setContentProvider(new PortContentProvider(server)); - tableViewer.setLabelProvider(new PortLabelProvider(server)); - tableViewer.setInput(AbstractTreeContentProvider.ROOT); - - tableViewer.setSorter(new ViewerSorter() { - public int compare(Viewer viewer, Object e1, Object e2) { - ServerPort port1 = (ServerPort) e1; - ServerPort port2 = (ServerPort) e2; - if (port1.getPort() == port2.getPort()) - return 0; - else if (port1.getPort() > port2.getPort()) - return 1; - else - return -1; - } - }); - - label = new Label(composite, SWT.NONE); - label.setText(Messages.dialogMonitorMonitorPort); - - final Text portText = new Text(composite, SWT.BORDER); - data = new GridData(GridData.FILL_HORIZONTAL); - data.widthHint = 150; - portText.setLayoutData(data); - if (monitorPort >= 0) - portText.setText(monitorPort + ""); - - portText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - try { - monitorPort = Integer.parseInt(portText.getText()); - if (ok != null) - ok.setEnabled(true); - } catch (Exception ex) { - monitorPort = -1; - if (ok != null) - ok.setEnabled(false); - } - portChanged = true; - } - }); - - label = new Label(composite, SWT.NONE); - label.setText(Messages.dialogMonitorContentType); - - final Combo combo = new Combo(composite, SWT.READ_ONLY); - data = new GridData(GridData.FILL_HORIZONTAL); - data.widthHint = 150; - combo.setLayoutData(data); - combo.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - int size = combo.getItemCount(); - int sel = combo.getSelectionIndex(); - if (sel == size - 1) - contentTypes = portContentTypes; - else - contentTypes = new String[] { portContentTypes[sel] }; - } - }); - - tableViewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - port = (ServerPort) getSelection(tableViewer.getSelection()); - if (port == null) - return; - if (!portChanged) { - portText.setText((port.getPort() + 1) + ""); - portChanged = false; - } - portContentTypes = port.getContentTypes(); - String[] s = null; - String all = Messages.dialogMonitorContentTypeAll; - if (portContentTypes == null || portContentTypes.length == 1) { - s = new String[] { all }; - } else { - int size = portContentTypes.length; - s = new String[size+1]; - for (int i = 0; i < size; i++) { - s[i] = MonitorLabelProvider.getContentTypeString(portContentTypes[i]); - } - s[size] = all; - } - combo.setItems(s); - combo.setText(all); - } - }); - - Dialog.applyDialogFont(composite); - - if (port != null) { - portChanged = true; - String[] ct = contentTypes; - tableViewer.setSelection(new StructuredSelection(port)); - if (ct != null && ct.length > 0) - combo.setText(MonitorLabelProvider.getContentTypeString(ct[0])); - } else if (tableViewer != null) { - try { - Object obj = tableViewer.getElementAt(0); - if (obj != null) - tableViewer.setSelection(new StructuredSelection(obj)); - } catch (Exception e) { - // ignore - } - } - - portChanged = false; - - return composite; - } - - protected Object getSelection(ISelection sel2) { - IStructuredSelection sel = (IStructuredSelection) sel2; - return sel.getFirstElement(); - } - - public int getMonitorPort() { - return monitorPort; - } - - public ServerPort getServerPort() { - return port; - } - - public String[] getContentTypes() { - return contentTypes; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/MonitorLabelProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/MonitorLabelProvider.java deleted file mode 100644 index 3d2a784be..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/MonitorLabelProvider.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.viewers; - -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.swt.graphics.Image; - -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.internal.IMonitoredServerPort; -import org.eclipse.wst.server.ui.internal.ImageResource; -import org.eclipse.wst.server.ui.internal.Messages; -/** - * Monitor port label provider. - */ -public class MonitorLabelProvider extends BaseLabelProvider implements ITableLabelProvider { - protected IServer server; - - public MonitorLabelProvider(IServer server) { - super(); - this.server = server; - } - - public Image getColumnImage(Object element, int columnIndex) { - IMonitoredServerPort port = (IMonitoredServerPort) element; - if (columnIndex == 0) { - if (port.isStarted()) - return ImageResource.getImage(ImageResource.IMG_MONITOR_ON); - return ImageResource.getImage(ImageResource.IMG_MONITOR_OFF); - } - return null; - } - - public String getColumnText(Object element, int columnIndex) { - IMonitoredServerPort port = (IMonitoredServerPort) element; - if (columnIndex == 0) { - if (port.isStarted()) - return Messages.started; - return Messages.stopped; - } else if (columnIndex == 1) - return notNull(port.getServerPort().getName()); - else if (columnIndex == 2) - return port.getServerPort().getPort() + ""; - else if (columnIndex == 3) - return port.getMonitorPort() + ""; - else { - String[] content = port.getContentTypes(); - if (content == null || content.length == 0) - return Messages.dialogMonitorContentTypeAll; - - StringBuffer sb = new StringBuffer(); - int size = content.length; - for (int i = 0; i < size; i++) { - if (i > 0) - sb.append(","); - sb.append(getContentTypeString(content[i])); - } - return sb.toString(); - } - } - - protected static String getContentTypeString(String s) { - if ("web".equals(s)) - return Messages.dialogMonitorContentTypeWeb; - else if ("webservices".equals(s)) - return Messages.dialogMonitorContentTypeWebServices; - else - return s; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/PortContentProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/PortContentProvider.java deleted file mode 100644 index e6221c98d..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/PortContentProvider.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.viewers; - -import org.eclipse.wst.server.core.IServer; -/** - * Monitor port content provider. - */ -public class PortContentProvider extends BaseContentProvider { - protected IServer server; - - public PortContentProvider(IServer server) { - super(); - this.server = server; - } - - public Object[] getElements(Object inputElement) { - return server.getServerPorts(null); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/PortLabelProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/PortLabelProvider.java deleted file mode 100644 index 7c674f750..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/PortLabelProvider.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.viewers; - -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.swt.graphics.Image; - -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.ServerPort; -/** - * Server port label provider. - */ -public class PortLabelProvider extends BaseLabelProvider implements ITableLabelProvider { - protected IServer server; - - public PortLabelProvider(IServer server) { - super(); - this.server = server; - } - - public Image getColumnImage(Object element, int columnIndex) { - return null; - } - - public String getColumnText(Object element, int columnIndex) { - ServerPort port = (ServerPort) element; - if (columnIndex == 0) - return notNull(port.getName()); - else if (columnIndex == 1) - return port.getPort() + ""; - else - return ""; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeComposite.java deleted file mode 100644 index e2739d217..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeComposite.java +++ /dev/null @@ -1,171 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.viewers; - -import org.eclipse.jface.viewers.*; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.events.KeyListener; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.wst.server.core.IRuntime; -import org.eclipse.wst.server.core.IRuntimeWorkingCopy; -import org.eclipse.wst.server.ui.internal.Messages; -import org.eclipse.wst.server.ui.internal.ServerUIPlugin; -/** - * - */ -public class RuntimeComposite extends AbstractTableComposite { - protected IRuntime selection; - protected IRuntime defaultRuntime; - protected RuntimeSelectionListener listener; - - public interface RuntimeSelectionListener { - public void runtimeSelected(IRuntime runtime); - } - - class RuntimeViewerSorter extends ViewerSorter { - boolean sortByName; - public RuntimeViewerSorter(boolean sortByName) { - this.sortByName = sortByName; - } - - public int compare(Viewer viewer, Object e1, Object e2) { - IRuntime r1 = (IRuntime) e1; - IRuntime r2 = (IRuntime) e2; - if (sortByName) - return getComparator().compare(notNull(r1.getName()), notNull(r2.getName())); - - if (r1.getRuntimeType() == null) - return -1; - if (r2.getRuntimeType() == null) - return 1; - return getComparator().compare(notNull(r1.getRuntimeType().getName()), notNull(r2.getRuntimeType().getName())); - } - - protected String notNull(String s) { - if (s == null) - return ""; - return s; - } - } - - public RuntimeComposite(Composite parent, int style, RuntimeSelectionListener listener2) { - super(parent, style); - this.listener = listener2; - - TableLayout tableLayout = new TableLayout(); - table.setLayout(tableLayout); - table.setHeaderVisible(true); - - tableLayout.addColumnData(new ColumnWeightData(0, 160, true)); - TableColumn col = new TableColumn(table, SWT.NONE); - col.setText(Messages.columnName); - col.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - tableViewer.setSorter(new RuntimeViewerSorter(true)); - } - - public void widgetDefaultSelected(SelectionEvent e) { - widgetSelected(e); - } - }); - - tableLayout.addColumnData(new ColumnWeightData(0, 125, true)); - col = new TableColumn(table, SWT.NONE); - col.setText(Messages.columnType); - col.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - tableViewer.setSorter(new RuntimeViewerSorter(false)); - } - - public void widgetDefaultSelected(SelectionEvent e) { - widgetSelected(e); - } - }); - - tableViewer.setContentProvider(new RuntimeContentProvider()); - - ILabelProvider labelProvider = new RuntimeTableLabelProvider(); - labelProvider.addListener(new ILabelProviderListener() { - public void labelProviderChanged(LabelProviderChangedEvent event) { - Object[] obj = event.getElements(); - if (obj == null) - tableViewer.refresh(true); - else { - obj = ServerUIPlugin.adaptLabelChangeObjects(obj); - int size = obj.length; - for (int i = 0; i < size; i++) - tableViewer.refresh(obj[i], true); - } - } - }); - tableViewer.setLabelProvider(labelProvider); - - tableViewer.setInput(AbstractTreeContentProvider.ROOT); - tableViewer.setColumnProperties(new String[] {"name", "type"}); - tableViewer.setSorter(new RuntimeViewerSorter(true)); - - tableViewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - Object obj = getSelection(event.getSelection()); - if (obj instanceof IRuntime) - selection = (IRuntime) obj; - else - selection = null; - listener.runtimeSelected(selection); - } - }); - - table.addKeyListener(new KeyListener() { - public void keyPressed(KeyEvent e) { - if (e.character == 'l') { - try { - IRuntime runtime = getSelectedRuntime(); - IRuntimeWorkingCopy wc = runtime.createWorkingCopy(); - wc.setReadOnly(!runtime.isReadOnly()); - wc.save(false, null); - refresh(runtime); - } catch (Exception ex) { - // ignore - } - } - } - - public void keyReleased(KeyEvent e) { - // do nothing - } - }); - - // after adding an item do the packing of the table - if (table.getItemCount() > 0) { - TableColumn[] columns = table.getColumns(); - for (int i=0; i < columns.length; i++) - columns[i].pack(); - table.pack(); - } - } - - protected void createTable() { - table = new Table(this, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE); - } - - protected void createTableViewer() { - tableViewer = new LockedTableViewer(table); - } - - public IRuntime getSelectedRuntime() { - return selection; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeContentProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeContentProvider.java deleted file mode 100644 index 8d7e673f2..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeContentProvider.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.viewers; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jface.viewers.IStructuredContentProvider; - -import org.eclipse.wst.server.core.IRuntime; -import org.eclipse.wst.server.core.ServerCore; -import org.eclipse.wst.server.core.internal.Runtime; -/** - * Runtime content provider. - */ -public class RuntimeContentProvider extends BaseContentProvider { - /** - * RuntimeContentProvider constructor comment. - */ - public RuntimeContentProvider() { - super(); - } - - /** - * @see IStructuredContentProvider#getElements(Object) - */ - public Object[] getElements(Object inputElement) { - List<IRuntime> list = new ArrayList<IRuntime>(); - IRuntime[] runtimes = ServerCore.getRuntimes(); - if (runtimes != null) { - int size = runtimes.length; - for (int i = 0; i < size; i++) { - if (!((Runtime)runtimes[i]).isPrivate()) - list.add(runtimes[i]); - } - } - return list.toArray(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTableLabelProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTableLabelProvider.java deleted file mode 100644 index b20124230..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTableLabelProvider.java +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.viewers; - -import org.eclipse.jface.viewers.ILabelDecorator; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.wst.server.core.IRuntime; -import org.eclipse.wst.server.core.IRuntimeType; -import org.eclipse.wst.server.ui.internal.ImageResource; -import org.eclipse.swt.graphics.Image; -/** - * Runtime table label provider. - */ -public class RuntimeTableLabelProvider extends BaseLabelProvider implements ITableLabelProvider, ILockedLabelProvider { - /** - * RuntimeTableLabelProvider constructor comment. - */ - public RuntimeTableLabelProvider() { - super(); - } - - /** - * RuntimeTableLabelProvider constructor comment. - * - * @param decorator a label decorator, or null if no decorator is required - */ - public RuntimeTableLabelProvider(ILabelDecorator decorator) { - super(decorator); - } - - /** - * @see ITableLabelProvider#getColumnImage(Object, int) - */ - public Image getColumnImage(Object element, int columnIndex) { - if (columnIndex == 0) { - IRuntime runtime = (IRuntime) element; - IRuntimeType runtimeType = runtime.getRuntimeType(); - if (runtimeType != null) { - Image image = ImageResource.getImage(runtimeType.getId()); - if (decorator != null) { - Image dec = decorator.decorateImage(image, element); - if (dec != null) - return dec; - } - return image; - } - } - return null; - } - - /** - * @see ITableLabelProvider#getColumnText(Object, int) - */ - public String getColumnText(Object element, int columnIndex) { - IRuntime runtime = (IRuntime) element; - if (columnIndex == 0) { - String text = notNull(runtime.getName()); - if (decorator != null) { - String dec = decorator.decorateText(text, element); - if (dec != null) - return dec; - } - return text; - } else if (columnIndex == 1) { - IRuntimeType runtimeType = runtime.getRuntimeType(); - if (runtimeType != null) - return notNull(runtimeType.getName()); - return ""; - } else - return ""; - } - - public boolean isLocked(Object element) { - IRuntime runtime = (IRuntime) element; - return runtime.isReadOnly(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTreeContentProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTreeContentProvider.java deleted file mode 100644 index b35adfa66..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTreeContentProvider.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.viewers; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.wst.server.core.IRuntime; -import org.eclipse.wst.server.core.IRuntimeType; -import org.eclipse.wst.server.core.ServerCore; -import org.eclipse.wst.server.ui.internal.Trace; -/** - * Runtime content provider. - */ -public class RuntimeTreeContentProvider extends AbstractTreeContentProvider { - /** - * RuntimeTreeContentProvider constructor. - */ - public RuntimeTreeContentProvider() { - super(); - } - - public void fillTree() { - clean(); - List<TreeElement> list = new ArrayList<TreeElement>(); - IRuntime[] runtimes = ServerCore.getRuntimes(); - if (runtimes != null) { - int size = runtimes.length; - for (int i = 0; i < size; i++) { - IRuntimeType runtimeType = runtimes[i].getRuntimeType(); - try { - TreeElement ele = getOrCreate(list, runtimeType.getVendor()); - ele.contents.add(runtimes[i]); - elementToParentMap.put(runtimes[i], ele); - } catch (Exception e) { - Trace.trace(Trace.WARNING, "Error in runtime content provider", e); - } - } - } - elements = list.toArray(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTreeLabelProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTreeLabelProvider.java deleted file mode 100644 index c7d035cd5..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTreeLabelProvider.java +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.viewers; - -import org.eclipse.jface.viewers.ILabelDecorator; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.wst.server.core.IRuntime; -import org.eclipse.wst.server.core.IRuntimeType; -import org.eclipse.wst.server.ui.internal.ImageResource; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; -/** - * Runtime label provider. - */ -public class RuntimeTreeLabelProvider extends AbstractTreeLabelProvider implements ITableLabelProvider { - /** - * RuntimeTreeLabelProvider constructor comment. - */ - public RuntimeTreeLabelProvider() { - super(); - } - - /** - * RuntimeTreeLabelProvider constructor comment. - * - * @param decorator a label decorator, or null if no decorator is required - */ - public RuntimeTreeLabelProvider(ILabelDecorator decorator) { - super(decorator); - } - - /** - * - */ - protected Image getImageImpl(Object element) { - IRuntime runtime = (IRuntime) element; - IRuntimeType runtimeType = runtime.getRuntimeType(); - if (runtimeType != null) { - Image image = ImageResource.getImage(runtimeType.getId()); - if (decorator != null) { - Image dec = decorator.decorateImage(image, element); - if (dec != null) - return dec; - } - return image; - } - return null; - } - - /** - * - */ - protected String getTextImpl(Object element) { - IRuntime runtime = (IRuntime) element; - return notNull(runtime.getName()); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int) - */ - public Image getColumnImage(Object element, int columnIndex) { - if (columnIndex == 0) { - if (element instanceof ServerTreeContentProvider.TreeElement) { - ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages(); - return sharedImages.getImage(ISharedImages.IMG_OBJ_FOLDER); - } - return getImageImpl(element); - } - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int) - */ - public String getColumnText(Object element, int columnIndex) { - if (element instanceof ServerTreeContentProvider.TreeElement) { - if (columnIndex == 0) - return ((ServerTreeContentProvider.TreeElement) element).text; - return ""; - } - IRuntime runtime = (IRuntime) element; - if (columnIndex == 0) { - String text = notNull(runtime.getName()); - if (decorator != null) { - String dec = decorator.decorateText(text, runtime); - if (dec != null) - return dec; - } - return text; - } else if (columnIndex == 1) { - if (runtime.getRuntimeType() != null) - return notNull(runtime.getRuntimeType().getName()); - return ""; - } - return ""; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTypeComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTypeComposite.java deleted file mode 100644 index e341a687e..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTypeComposite.java +++ /dev/null @@ -1,134 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.viewers; - -import org.eclipse.jface.viewers.*; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Shell; - -import org.eclipse.wst.server.core.IRuntimeType; -import org.eclipse.wst.server.discovery.Discovery; -import org.eclipse.wst.server.ui.internal.Messages; -import org.eclipse.wst.server.ui.internal.ServerUIPlugin; -/** - * - */ -public class RuntimeTypeComposite extends AbstractTreeComposite { - protected IRuntimeType selection; - protected RuntimeTypeSelectionListener listener; - protected boolean creation; - protected String type; - protected String version; - protected String runtimeTypeId; - - protected RuntimeTypeTreeContentProvider contentProvider; - protected boolean initialSelection = true; - - public interface RuntimeTypeSelectionListener { - public void runtimeTypeSelected(IRuntimeType runtimeType); - } - - public RuntimeTypeComposite(Composite parent, boolean creation, RuntimeTypeSelectionListener listener2, String type, String version, String runtimeTypeId) { - super(parent); - this.listener = listener2; - this.creation = creation; - this.type = type; - this.version = version; - this.runtimeTypeId = runtimeTypeId; - - contentProvider = new RuntimeTypeTreeContentProvider(creation, type, version, runtimeTypeId); - treeViewer.setContentProvider(contentProvider); - - ILabelProvider labelProvider = new RuntimeTypeTreeLabelProvider(); - labelProvider.addListener(new ILabelProviderListener() { - public void labelProviderChanged(LabelProviderChangedEvent event) { - Object[] obj = event.getElements(); - if (obj == null) - treeViewer.refresh(true); - else { - obj = ServerUIPlugin.adaptLabelChangeObjects(obj); - int size = obj.length; - for (int i = 0; i < size; i++) - treeViewer.refresh(obj[i], true); - } - } - }); - treeViewer.setLabelProvider(labelProvider); - treeViewer.setInput(AbstractTreeContentProvider.ROOT); - - treeViewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - Object obj = getSelection(event.getSelection()); - if (obj instanceof IRuntimeType) { - selection = (IRuntimeType) obj; - setDescription(selection.getDescription()); - } else { - selection = null; - setDescription(""); - } - listener.runtimeTypeSelected(selection); - } - }); - - treeViewer.setSorter(new DefaultViewerSorter()); - } - - public void setVisible(boolean visible) { - super.setVisible(visible); - if (visible && initialSelection) { - initialSelection = false; - if (contentProvider.getInitialSelection() != null) - treeViewer.setSelection(new StructuredSelection(contentProvider.getInitialSelection()), true); - } - } - - protected String getTitleLabel() { - return Messages.runtimeTypeCompTree; - } - - protected String getDescriptionLabel() { - return null; - } - - public void refresh() { - ISelection sel = treeViewer.getSelection(); - treeViewer.setContentProvider(new RuntimeTypeTreeContentProvider(creation, type, version, runtimeTypeId)); - treeViewer.setSelection(sel); - } - - public IRuntimeType getSelectedRuntimeType() { - return selection; - } - - protected String getDetailsLabel() { - return Messages.installableServerLink; - } - - private void closeWizard(Composite comp) { - if (comp == null || comp.isDisposed()) - return; - - Composite c = comp.getParent(); - if (c instanceof Shell) { - Shell s = (Shell) c; - s.close(); - } - closeWizard(c); - } - - protected void detailsSelected() { - if (Discovery.launchExtensionWizard(getShell(), Messages.wizNewInstallableServerTitle, - Messages.wizNewInstallableServerDescription)) { - //refresh(); - closeWizard(this); - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTypeTreeContentProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTypeTreeContentProvider.java deleted file mode 100644 index e169f8478..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTypeTreeContentProvider.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.viewers; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.wst.server.core.*; -/** - * Runtime type content provider. - */ -public class RuntimeTypeTreeContentProvider extends AbstractTreeContentProvider { - protected boolean creation; - protected String type; - protected String version; - protected String runtimeTypeId; - - /** - * RuntimeTypeContentProvider constructor. - * - * @param creation true to include runtimes that can be created - */ - public RuntimeTypeTreeContentProvider(boolean creation) { - super(); - this.creation = creation; - } - - public RuntimeTypeTreeContentProvider(boolean creation, String type, String version, String runtimeTypeId) { - super(false); - this.type = type; - this.version = version; - this.runtimeTypeId = runtimeTypeId; - this.creation = creation; - - fillTree(); - } - - public void fillTree() { - clean(); - List<TreeElement> list = new ArrayList<TreeElement>(); - IRuntimeType[] runtimeTypes = ServerUtil.getRuntimeTypes(type, version, runtimeTypeId); - if (runtimeTypes != null) { - int size = runtimeTypes.length; - for (int i = 0; i < size; i++) { - IRuntimeType runtimeType = runtimeTypes[i]; - if (!creation || runtimeType.canCreate()) { - TreeElement ele = getOrCreate(list, runtimeType.getVendor()); - ele.contents.add(runtimeType); - elementToParentMap.put(runtimeType, ele); - } - } - } - elements = list.toArray(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTypeTreeLabelProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTypeTreeLabelProvider.java deleted file mode 100644 index c973c6bf2..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTypeTreeLabelProvider.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.viewers; - -import org.eclipse.wst.server.core.IRuntimeType; -import org.eclipse.wst.server.ui.internal.ImageResource; -import org.eclipse.jface.viewers.ILabelDecorator; -import org.eclipse.swt.graphics.Image; -/** - * Runtime type label provider. - */ -public class RuntimeTypeTreeLabelProvider extends AbstractTreeLabelProvider { - /** - * RuntimeTypeTreeLabelProvider constructor comment. - */ - public RuntimeTypeTreeLabelProvider() { - super(); - } - - /** - * RuntimeTypeTreeLabelProvider constructor comment. - * - * @param decorator a label decorator, or null if no decorator is required - */ - public RuntimeTypeTreeLabelProvider(ILabelDecorator decorator) { - super(decorator); - } - - /** - * - */ - protected Image getImageImpl(Object element) { - IRuntimeType runtimeType = (IRuntimeType) element; - return ImageResource.getImage(runtimeType.getId()); - } - - /** - * - */ - protected String getTextImpl(Object element) { - IRuntimeType runtimeType = (IRuntimeType) element; - return notNull(runtimeType.getName()); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerComposite.java deleted file mode 100644 index 2588b1056..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerComposite.java +++ /dev/null @@ -1,174 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.viewers; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.LabelProviderChangedEvent; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Tree; -import org.eclipse.swt.widgets.TreeColumn; -import org.eclipse.ui.dialogs.FilteredTree; - -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.ui.internal.Messages; -import org.eclipse.wst.server.ui.internal.ServerUIPlugin; -import org.eclipse.wst.server.ui.internal.view.servers.ServerTableLabelProvider; -/** - * - */ -public class ServerComposite extends AbstractTreeComposite { - protected IServer selection; - protected ServerSelectionListener listener; - protected ServerTreeContentProvider contentProvider; - protected boolean initialSelection = true; - - protected IModule module; - protected String launchMode; - protected boolean includeIncompatibleVersions; - - public interface ServerSelectionListener { - public void serverSelected(IServer server); - } - - public ServerComposite(Composite parent, ServerSelectionListener listener2, IModule module, String launchMode) { - super(parent); - this.module = module; - this.launchMode = launchMode; - - this.listener = listener2; - - Tree tree2 = treeViewer.getTree(); - TreeColumn column = new TreeColumn(tree2, SWT.SINGLE); - column.setText(Messages.viewServer); - column.setWidth(325); - - TreeColumn column2 = new TreeColumn(tree2, SWT.SINGLE); - column2.setText(Messages.viewState); - column2.setWidth(100); - - contentProvider = new ServerTreeContentProvider(module, launchMode); - treeViewer.setContentProvider(contentProvider); - - //ILabelProvider labelProvider = new ServerTreeLabelProvider(); - ILabelProvider labelProvider = new ServerTableLabelProvider(); - labelProvider.addListener(new ILabelProviderListener() { - public void labelProviderChanged(LabelProviderChangedEvent event) { - Object[] obj = event.getElements(); - if (obj == null) - treeViewer.refresh(true); - else { - obj = ServerUIPlugin.adaptLabelChangeObjects(obj); - int size = obj.length; - for (int i = 0; i < size; i++) - treeViewer.refresh(obj[i], true); - } - } - }); - treeViewer.setLabelProvider(labelProvider); - treeViewer.setInput(AbstractTreeContentProvider.ROOT); - treeViewer.expandToLevel(1); - - treeViewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - Object obj = getSelection(event.getSelection()); - if (obj instanceof IServer) { - selection = (IServer) obj; - setDescription(selection.getServerType().getRuntimeType().getDescription()); - } else { - selection = null; - setDescription(""); - } - listener.serverSelected(selection); - } - }); - } - - protected void createTree() { - tree = new FilteredTree(this, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE | SWT.FULL_SELECTION, new ServerPatternFilter()); - } - - public void setIncludeIncompatibleVersions(boolean b) { - includeIncompatibleVersions = b; - ISelection sel = treeViewer.getSelection(); - contentProvider.setIncludeIncompatibleVersions(b); - treeViewer.refresh(); - treeViewer.setSelection(sel, true); - } - - public void setVisible(boolean visible) { - super.setVisible(visible); - if (visible && initialSelection) { - initialSelection = false; - deferInitialization(); - } - } - - public void refreshAll() { - ISelection sel = treeViewer.getSelection(); - contentProvider = new ServerTreeContentProvider(module, launchMode); - contentProvider.setIncludeIncompatibleVersions(includeIncompatibleVersions); - treeViewer.setContentProvider(contentProvider); - treeViewer.setSelection(sel); - } - - protected String getDescriptionLabel() { - return null; - } - - protected String getTitleLabel() { - return Messages.wizNewServerSelectExisting; - } - - public IServer getSelectedServer() { - return selection; - } - - public void setSelection(IServer server) { - if (server != null) - treeViewer.setSelection(new StructuredSelection(server), true); - else - treeViewer.setSelection(null); - } - - protected void deferInitialization() { - Job job = new Job(Messages.jobInitializingServersView) { - public IStatus run(IProgressMonitor monitor) { - Display.getDefault().asyncExec(new Runnable() { - public void run() { - try { - if (contentProvider.getInitialSelection(module.getProject()) != null) - treeViewer.setSelection(new StructuredSelection(contentProvider.getInitialSelection(module.getProject())), true); - } catch (Exception e) { - // ignore - wizard has already been closed - } - } - }); - return Status.OK_STATUS; - } - }; - - job.setSystem(true); - job.setPriority(Job.SHORT); - job.schedule(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerPatternFilter.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerPatternFilter.java deleted file mode 100644 index 5d1e89e20..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerPatternFilter.java +++ /dev/null @@ -1,122 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.viewers; - -import org.eclipse.jface.viewers.AbstractTreeViewer; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.ui.dialogs.PatternFilter; -import org.eclipse.wst.server.core.IModuleType; -import org.eclipse.wst.server.core.IRuntime; -import org.eclipse.wst.server.core.IRuntimeType; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.IServerType; - -public class ServerPatternFilter extends PatternFilter { - protected boolean isLeafMatch(Viewer viewer, Object element) { - boolean b = super.isLeafMatch(viewer, element); - if (b) - return true; - - Object parent = ((ITreeContentProvider) ((AbstractTreeViewer) viewer) - .getContentProvider()).getParent(element); - if (parent != null) { - String labelText = ((ILabelProvider) ((StructuredViewer) viewer).getLabelProvider()) - .getText(parent); - - if (labelText != null && wordMatches(labelText)) - return true; - } - - if (element instanceof IRuntimeType && matchesRuntimeType((IRuntimeType) element)) - return true; - if (element instanceof IRuntime && matchesRuntime((IRuntime) element)) - return true; - if (element instanceof IServerType && matchesServerType((IServerType) element)) - return true; - if (element instanceof IServer && matchesServer((IServer) element)) - return true; - - return false; - } - - protected boolean matchesModuleType(IModuleType mt) { - String text = mt.getName(); - if (wordMatches(text)) - return true; - text = mt.getVersion(); - if (wordMatches(text)) - return true; - return false; - } - - protected boolean matchesRuntimeType(IRuntimeType rt) { - String text = rt.getName(); - if (wordMatches(text)) - return true; - text = rt.getDescription(); - if (wordMatches(text)) - return true; - text = rt.getVendor(); - if (wordMatches(text)) - return true; - text = rt.getVersion(); - if (wordMatches(text)) - return true; - - IModuleType[] mts = rt.getModuleTypes(); - if (mts != null) { - int size = mts.length; - for (int i = 0; i < size; i++) { - if (matchesModuleType(mts[i])) - return true; - } - } - return false; - } - - protected boolean matchesRuntime(IRuntime r) { - String text = r.getName(); - if (wordMatches(text)) - return true; - if (r.getLocation() != null) { - text = r.getLocation().toPortableString(); - if (wordMatches(text)) - return true; - text = r.getLocation().toOSString(); - if (wordMatches(text)) - return true; - } - if (r.getRuntimeType() != null && matchesRuntimeType(r.getRuntimeType())) - return true; - return false; - } - - protected boolean matchesServerType(IServerType st) { - String text = st.getDescription(); - if (wordMatches(text)) - return true; - if (st.getRuntimeType() != null && matchesRuntimeType(st.getRuntimeType())) - return true; - return false; - } - - protected boolean matchesServer(IServer st) { - String text = st.getName(); - if (wordMatches(text)) - return true; - if (st.getServerType() != null && matchesServerType(st.getServerType())) - return true; - return false; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTreeContentProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTreeContentProvider.java deleted file mode 100644 index 758a16a6b..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTreeContentProvider.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.viewers; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IModuleType; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.ServerCore; -import org.eclipse.wst.server.core.ServerUtil; -import org.eclipse.wst.server.ui.internal.ServerUIPlugin; -/** - * Runtime type content provider. - */ -public class ServerTreeContentProvider extends AbstractTreeContentProvider { - protected IModule module; - protected String launchMode; - protected boolean includeIncompatibleVersions; - - /** - * ServerTreeContentProvider constructor. - */ - public ServerTreeContentProvider() { - super(); - } - - public ServerTreeContentProvider(IModule module, String launchMode) { - super(false); - this.module = module; - this.launchMode = launchMode; - - fillTree(); - } - - public void setIncludeIncompatibleVersions(boolean b) { - includeIncompatibleVersions = b; - fillTree(); - } - - protected void fillTree() { - clean(); - List<TreeElement> list = new ArrayList<TreeElement>(); - IServer[] servers = ServerCore.getServers(); - if (servers != null) { - int size = servers.length; - for (int i = 0; i < size; i++) { - if (acceptServer(servers[i])) { - TreeElement te = getOrCreate(list, servers[i].getHost()); - te.contents.add(servers[i]); - elementToParentMap.put(servers[i], te); - } - } - } - elements = list.toArray(); - } - - protected boolean acceptServer(IServer server) { - if (module == null || launchMode == null) - return true; - if (!ServerUIPlugin.isCompatibleWithLaunchMode(server, launchMode)) - return false; - - IModuleType mt = module.getModuleType(); - if (includeIncompatibleVersions) { - if (!ServerUtil.isSupportedModule(server.getServerType().getRuntimeType().getModuleTypes(), mt.getId(), null)) - return false; - } else { - if (!ServerUtil.isSupportedModule(server.getServerType().getRuntimeType().getModuleTypes(), mt.getId(), mt.getVersion())) - return false; - } - return true; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTypeComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTypeComposite.java deleted file mode 100644 index d6a100b7d..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTypeComposite.java +++ /dev/null @@ -1,187 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.viewers; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.LabelProviderChangedEvent; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; - -import org.eclipse.wst.server.core.IModuleType; -import org.eclipse.wst.server.core.IServerType; -import org.eclipse.wst.server.discovery.Discovery; -import org.eclipse.wst.server.ui.internal.Messages; -import org.eclipse.wst.server.ui.internal.ServerUIPlugin; -/** - * - */ -public class ServerTypeComposite extends AbstractTreeComposite { - protected IServerType selection; - protected ServerTypeSelectionListener listener; - protected ServerTypeTreeContentProvider contentProvider; - protected boolean initialSelection = true; - - protected IModuleType moduleType; - protected String serverTypeId; - - protected boolean isLocalhost; - protected boolean includeIncompatibleVersions; - - public interface ServerTypeSelectionListener { - public void serverTypeSelected(IServerType type); - } - - public ServerTypeComposite(Composite parent, IModuleType moduleType, String serverTypeId, ServerTypeSelectionListener listener2) { - super(parent); - this.listener = listener2; - - this.moduleType = moduleType; - this.serverTypeId = serverTypeId; - - contentProvider = new ServerTypeTreeContentProvider(moduleType, serverTypeId); - treeViewer.setContentProvider(contentProvider); - - ILabelProvider labelProvider = new ServerTypeTreeLabelProvider(); - labelProvider.addListener(new ILabelProviderListener() { - public void labelProviderChanged(LabelProviderChangedEvent event) { - Object[] obj = event.getElements(); - if (obj == null) - treeViewer.refresh(true); - else { - obj = ServerUIPlugin.adaptLabelChangeObjects(obj); - int size = obj.length; - for (int i = 0; i < size; i++) - treeViewer.refresh(obj[i], true); - } - } - }); - treeViewer.setLabelProvider(labelProvider); - treeViewer.setInput(AbstractTreeContentProvider.ROOT); - - treeViewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - Object obj = getSelection(event.getSelection()); - if (obj instanceof IServerType) { - selection = (IServerType) obj; - setDescription(selection.getDescription()); - } else { - selection = null; - setDescription(""); - } - listener.serverTypeSelected(selection); - } - }); - - treeViewer.setSorter(new DefaultViewerSorter()); - } - - public void setVisible(boolean visible) { - super.setVisible(visible); - if (visible && initialSelection) { - initialSelection = false; - deferInitialization(); - } - } - - protected void deferInitialization() { - Job job = new Job(Messages.jobInitializingServersView) { - public IStatus run(IProgressMonitor monitor) { - Display.getDefault().asyncExec(new Runnable() { - public void run() { - try { - if (contentProvider.getInitialSelection() != null) - treeViewer.setSelection(new StructuredSelection(contentProvider.getInitialSelection()), true); - } catch (Exception e) { - // ignore - wizard has already been closed - } - } - }); - return Status.OK_STATUS; - } - }; - - job.setSystem(true); - job.setPriority(Job.SHORT); - job.schedule(); - } - - public boolean setHost(boolean newHost) { - if (isLocalhost == newHost) - return false; - - isLocalhost = newHost; - ISelection sel = treeViewer.getSelection(); - contentProvider.setLocalhost(isLocalhost); - treeViewer.refresh(); - //treeViewer.expandToLevel(2); - treeViewer.setSelection(sel, true); - return true; - } - - public void setIncludeIncompatibleVersions(boolean b) { - includeIncompatibleVersions = b; - ISelection sel = treeViewer.getSelection(); - contentProvider.setIncludeIncompatibleVersions(b); - treeViewer.refresh(); - treeViewer.setSelection(sel, true); - } - - protected String getDescriptionLabel() { - return null; - } - - protected String getTitleLabel() { - return Messages.serverTypeCompLabel; - } - - public IServerType getSelectedServerType() { - return selection; - } - - public void refresh() { - ISelection sel = treeViewer.getSelection(); - treeViewer.setContentProvider(new ServerTypeTreeContentProvider(moduleType, serverTypeId)); - treeViewer.setSelection(sel); - } - - protected String getDetailsLabel() { - return Messages.installableServerLink; - } - - private void closeWizard(Composite comp) { - if (comp == null || comp.isDisposed()) - return; - Composite c = comp.getParent(); - if (c instanceof Shell) { - Shell s = (Shell) c; - s.close(); - } - closeWizard(c); - } - - protected void detailsSelected() { - if (Discovery.launchExtensionWizard(getShell(), Messages.wizNewInstallableServerTitle, - Messages.wizNewInstallableServerDescription)) { - //refresh(); - closeWizard(this); - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTypeTreeContentProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTypeTreeContentProvider.java deleted file mode 100644 index 86cf3e422..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTypeTreeContentProvider.java +++ /dev/null @@ -1,120 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.viewers; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.wst.server.core.*; -import org.eclipse.wst.server.ui.internal.ServerUIPlugin; -import org.eclipse.wst.server.ui.internal.Trace; -/** - * Server type content provider. - */ -public class ServerTypeTreeContentProvider extends AbstractTreeContentProvider { - protected boolean localhost; - - protected IModuleType moduleType; - protected String serverTypeId; - protected boolean includeIncompatibleVersions; - - /** - * ServerTypeTreeContentProvider constructor. - * - * @param moduleType a module type - * @param serverTypeId a server type id, or null to match any id - */ - public ServerTypeTreeContentProvider(IModuleType moduleType, String serverTypeId) { - super(false); - localhost = true; - - this.moduleType = moduleType; - this.serverTypeId = serverTypeId; - - fillTree(); - } - - public void fillTree() { - clean(); - - List<TreeElement> list = new ArrayList<TreeElement>(); - IServerType[] serverTypes = ServerCore.getServerTypes(); - if (serverTypes != null) { - int size = serverTypes.length; - for (int i = 0; i < size; i++) { - IServerType serverType = serverTypes[i]; - if (include(serverType)) { - try { - IRuntimeType runtimeType = serverType.getRuntimeType(); - TreeElement ele = getOrCreate(list, runtimeType.getVendor()); - ele.contents.add(serverType); - elementToParentMap.put(serverType, ele); - } catch (Exception e) { - Trace.trace(Trace.WARNING, "Error in server configuration content provider", e); - } - } - } - } - elements = list.toArray(); - } - - protected boolean include(IServerType serverType) { - if (serverTypeId != null && !serverType.getId().startsWith(serverTypeId)) - return false; - - IRuntimeType runtimeType = serverType.getRuntimeType(); - if (runtimeType == null) - return false; - - String moduleTypeId = null; - if (moduleType != null) - moduleTypeId = moduleType.getId(); - if (includeIncompatibleVersions) { - if (!ServerUtil.isSupportedModule(runtimeType.getModuleTypes(), moduleTypeId, null)) - return false; - } else { - String moduleVersion = null; - if (moduleType != null) - moduleVersion = moduleType.getVersion(); - if (!ServerUtil.isSupportedModule(runtimeType.getModuleTypes(), moduleTypeId, moduleVersion)) - return false; - } - - if (localhost || serverType.supportsRemoteHosts()) - return true; - - return false; - } - - protected boolean checkForNonStubEnvironmentRuntime(IServerType serverType) { - IRuntimeType runtimeType = serverType.getRuntimeType(); - IRuntime[] runtimes = ServerUIPlugin.getRuntimes(runtimeType); - if (runtimes == null || runtimes.length == 0) - return false; - - int size = runtimes.length; - for (int i = 0; i < size; i++) { - if (!runtimes[i].isStub()) - return true; - } - return false; - } - - public void setLocalhost(boolean local) { - localhost = local; - fillTree(); - } - - public void setIncludeIncompatibleVersions(boolean b) { - includeIncompatibleVersions = b; - fillTree(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTypeTreeLabelProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTypeTreeLabelProvider.java deleted file mode 100644 index a8722323b..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTypeTreeLabelProvider.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.viewers; - -import org.eclipse.wst.server.core.IServerType; -import org.eclipse.wst.server.ui.internal.ImageResource; -import org.eclipse.jface.viewers.ILabelDecorator; -import org.eclipse.swt.graphics.Image; -/** - * Server type label provider. - */ -public class ServerTypeTreeLabelProvider extends AbstractTreeLabelProvider { - /** - * ServerTypeTreeLabelProvider constructor comment. - */ - public ServerTypeTreeLabelProvider() { - super(); - } - - /** - * ServerTypeTreeLabelProvider constructor comment. - * - * @param decorator a label decorator, or null if no decorator is required - */ - public ServerTypeTreeLabelProvider(ILabelDecorator decorator) { - super(decorator); - } - - /** - * - */ - protected Image getImageImpl(Object element) { - IServerType type = (IServerType) element; - return ImageResource.getImage(type.getId()); - } - - /** - * - */ - protected String getTextImpl(Object element) { - IServerType type = (IServerType) element; - return notNull(type.getName()); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/Version.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/Version.java deleted file mode 100644 index c1970c886..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/Version.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.viewers; - -import java.util.ArrayList; -import java.util.List; -import java.util.StringTokenizer; - -public class Version { - private static final String SEPARATOR = "."; - - private String[] version; - - public Version(String s) { - StringTokenizer st = new StringTokenizer(s, SEPARATOR); - List<String> list = new ArrayList<String>(); - - while (st.hasMoreTokens()) { - String str = st.nextToken(); - int size = str.length(); - for (int i = 0; i < size; i++) { - if (!Character.isLetterOrDigit(str.charAt(i))) - throw new NumberFormatException("Version strings cannot contain '" + str.charAt(i) + "'"); - } - list.add(str); - } - - version = new String[list.size()]; - list.toArray(version); - } - - public static Version parseVersion(String s) { - return new Version(s); - } - - public static int compare(Version v1, Version v2) { - int v1l = v1.version.length; - int v2l = v2.version.length; - - int size = Math.min(v1l, v2l); - for (int i = 0; i < size; i++) { - try { - double d1 = Double.parseDouble(v1.version[i]); - double d2 = Double.parseDouble(v2.version[i]); - - int c = Double.compare(d1, d2); - if (c != 0) - return c; - } catch (NumberFormatException nfe) { - // ignore - } - - int c = v1.version[i].compareTo(v2.version[i]); - if (c != 0) - return c; - } - if (v1l == v2l) - return 0; - if (v1l > v2l) - return 1; - return -1; - } -} diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/webbrowser/OpenBrowserWorkbenchAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/webbrowser/OpenBrowserWorkbenchAction.java deleted file mode 100644 index 4002e200f..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/webbrowser/OpenBrowserWorkbenchAction.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.webbrowser; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.action.IAction; -import org.eclipse.ui.*; -import org.eclipse.ui.browser.IWebBrowser; -import org.eclipse.ui.browser.IWorkbenchBrowserSupport; -import org.eclipse.wst.server.ui.internal.ServerUIPlugin; -import org.eclipse.wst.server.ui.internal.Trace; -/** - * Action to open the Web broswer. - */ -public class OpenBrowserWorkbenchAction implements IWorkbenchWindowActionDelegate { - /** - * OpenBrowserWorkbenchAction constructor comment. - */ - public OpenBrowserWorkbenchAction() { - super(); - } - - /** - * Disposes this action delegate. The implementor should unhook any references - * to itself so that garbage collection can occur. - */ - public void dispose() { - // do nothing - } - - /** - * Initializes this action delegate with the workbench window it will work in. - * - * @param window the window that provides the context for this delegate - */ - public void init(IWorkbenchWindow window) { - // do nothing - } - - /** - * Performs this action. - * <p> - * This method is called when the delegating action has been triggered. - * Implement this method to do the actual work. - * </p> - * - * @param action the action proxy that handles the presentation portion of the - * action - */ - public void run(IAction action) { - try { - IWorkbenchBrowserSupport browserSupport = ServerUIPlugin.getInstance().getWorkbench().getBrowserSupport(); - IWebBrowser browser = browserSupport.createBrowser(IWorkbenchBrowserSupport.LOCATION_BAR | IWorkbenchBrowserSupport.NAVIGATION_BAR, null, null, null); - browser.openURL(null); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error opening browser", e); - } - } - - /** - * Notifies this action delegate that the selection in the workbench has changed. - * <p> - * Implementers can use this opportunity to change the availability of the - * action or to modify other presentation properties. - * </p> - * - * @param action the action proxy that handles presentation portion of the action - * @param selection the current selection in the workbench - */ - public void selectionChanged(IAction action, ISelection selection) { - // do nothing - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/webbrowser/SwitchBrowserWorkbenchAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/webbrowser/SwitchBrowserWorkbenchAction.java deleted file mode 100644 index 10f0f623c..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/webbrowser/SwitchBrowserWorkbenchAction.java +++ /dev/null @@ -1,150 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.webbrowser; - -import java.util.Iterator; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.action.ActionContributionItem; -import org.eclipse.jface.action.IAction; -import org.eclipse.swt.events.MenuAdapter; -import org.eclipse.swt.events.MenuEvent; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.MenuItem; -import org.eclipse.ui.*; -import org.eclipse.ui.internal.browser.BrowserManager; -import org.eclipse.ui.internal.browser.IBrowserDescriptor; -import org.eclipse.ui.internal.browser.WebBrowserPreference; -import org.eclipse.ui.internal.browser.WebBrowserUtil; -/** - * Action to open the Web broswer. - */ -public class SwitchBrowserWorkbenchAction implements IWorkbenchWindowPulldownDelegate2 { - /** - * The menu created by this action - */ - private Menu fMenu; - - protected boolean recreateMenu = false; - - /** - * SwitchBrowserWorkbenchAction constructor comment. - */ - public SwitchBrowserWorkbenchAction() { - super(); - } - - public void dispose() { - setMenu(null); - } - - /** - * Sets this action's drop-down menu, disposing the previous menu. - * - * @param menu the new menu - */ - private void setMenu(Menu menu) { - if (fMenu != null) { - fMenu.dispose(); - } - fMenu = menu; - } - - public void init(IWorkbenchWindow window) { - // do nothing - } - - /** - * Adds the given action to the specified menu with an accelerator specified - * by the given number. - * - * @param menu the menu to add the action to - * @param action the action to add - * @param accelerator the number that should appear as an accelerator - */ - protected void addToMenu(Menu menu, IAction action, int accelerator) { - StringBuffer label= new StringBuffer(); - if (accelerator >= 0 && accelerator < 10) { - //add the numerical accelerator - label.append('&'); - label.append(accelerator); - label.append(' '); - } - label.append(action.getText()); - action.setText(label.toString()); - ActionContributionItem item= new ActionContributionItem(action); - item.fill(menu, -1); - } - - /** - * Fills the drop-down menu with favorites and launch history, - * launch shortcuts, and an action to open the launch configuration dialog. - * - * @param menu the menu to fill - */ - protected void fillMenu(Menu menu) { - int i = 0; - if (WebBrowserUtil.canUseInternalWebBrowser()) { - addToMenu(menu, new SwitchDefaultBrowserAction(null, WebBrowserPreference.getBrowserChoice() == WebBrowserPreference.INTERNAL, null), i++); - } - IBrowserDescriptor current = BrowserManager.getInstance().getCurrentWebBrowser(); - BrowserManager browserManager = BrowserManager.getInstance(); - Iterator iterator = browserManager.getWebBrowsers().iterator(); - while (iterator.hasNext()) { - IBrowserDescriptor browser = (IBrowserDescriptor) iterator.next(); - addToMenu(menu, new SwitchDefaultBrowserAction(browser, WebBrowserPreference.getBrowserChoice() != WebBrowserPreference.INTERNAL && browser.equals(current), browserManager), i++); - } - } - - /** - * Creates the menu for the action - */ - private void initMenu() { - // Add listener to repopulate the menu each time - // it is shown because of dynamic history list - fMenu.addMenuListener(new MenuAdapter() { - public void menuShown(MenuEvent e) { - //if (recreateMenu) { - Menu m = (Menu) e.widget; - MenuItem[] items = m.getItems(); - for (int i = 0; i < items.length; i++) { - items[i].dispose(); - } - fillMenu(m); - recreateMenu = false; - //} - } - }); - } - - public void selectionChanged(IAction action, ISelection selection) { - // do nothing - } - - public void run(IAction action) { - // do nothing - } - - public Menu getMenu(Menu parent) { - setMenu(new Menu(parent)); - //fillMenu(fMenu); - initMenu(); - return fMenu; - } - - public Menu getMenu(Control parent) { - setMenu(new Menu(parent)); - //fillMenu(fMenu); - initMenu(); - return fMenu; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/webbrowser/SwitchDefaultBrowserAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/webbrowser/SwitchDefaultBrowserAction.java deleted file mode 100644 index d9f8a162e..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/webbrowser/SwitchDefaultBrowserAction.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.webbrowser; - -import org.eclipse.jface.action.Action; -import org.eclipse.ui.internal.browser.BrowserManager; -import org.eclipse.ui.internal.browser.IBrowserDescriptor; -import org.eclipse.ui.internal.browser.WebBrowserPreference; -import org.eclipse.wst.server.ui.internal.Messages; -/** - * Action to open the Web browser. - */ -public class SwitchDefaultBrowserAction extends Action { - protected IBrowserDescriptor webbrowser; - protected BrowserManager browserManager; - - /** - * SwitchDefaultBrowserAction constructor comment. - * - * @param webbrowser a browser - * @param current true if this is the current browser - * @param manager the browser manager - */ - public SwitchDefaultBrowserAction(IBrowserDescriptor webbrowser, boolean current, BrowserManager manager) { - super(); - - this.webbrowser = webbrowser; - this.browserManager = manager; - if (webbrowser == null) - setText(Messages.internalWebBrowserName); - else - setText(webbrowser.getName()); - - if (current) - setChecked(true); - } - - /** - * Implementation of method defined on <code>IAction</code>. - */ - public void run() { - if (webbrowser == null) - WebBrowserPreference.setBrowserChoice(WebBrowserPreference.INTERNAL); - else { - WebBrowserPreference.setBrowserChoice(WebBrowserPreference.EXTERNAL); - browserManager.setCurrentWebBrowser(webbrowser); - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/AbstractWizard.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/AbstractWizard.java deleted file mode 100644 index 65f822eaf..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/AbstractWizard.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.wizard; - -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.ui.IWorkbench; -/** - * An abstract Wizard that contains helper methods. - */ -public abstract class AbstractWizard extends Wizard { - protected IWorkbench workbench; - protected IStructuredSelection selection; - - /** - * AbstractWizard constructor comment. - */ - public AbstractWizard() { - super(); - } - - /** - * Return the current workbench. - * - * @return the workbench - */ - public IWorkbench getWorkbench() { - return workbench; - } - - /** - * Initialize the workbench and current selection. - * - * @param newWorkbench - * @param newSelection - */ - public void init(IWorkbench newWorkbench, IStructuredSelection newSelection) { - workbench = newWorkbench; - selection = newSelection; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/ModifyModulesWizard.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/ModifyModulesWizard.java deleted file mode 100644 index 9cdc19175..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/ModifyModulesWizard.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.wizard; - -import java.util.List; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.wst.server.core.*; -import org.eclipse.wst.server.ui.internal.Messages; -import org.eclipse.wst.server.ui.internal.ServerUIPlugin; -import org.eclipse.wst.server.ui.internal.wizard.fragment.ModifyModulesWizardFragment; -import org.eclipse.wst.server.ui.wizard.WizardFragment; -/** - * A wizard used to add and remove modules. - */ -public class ModifyModulesWizard extends TaskWizard { - static class ModifyModulesWizard2 extends WizardFragment { - protected void createChildFragments(List<WizardFragment> list) { - list.add(new ModifyModulesWizardFragment(true)); - list.add(WizardTaskUtil.SaveServerFragment); - - list.add(new WizardFragment() { - public void performFinish(IProgressMonitor monitor) throws CoreException { - IServerAttributes svr = (IServerAttributes) getTaskModel().getObject(TaskModel.TASK_SERVER); - if (svr instanceof IServer) { - IServer server = (IServer) svr; - if (server.getServerState() != IServer.STATE_STOPPED && - ServerUIPlugin.getPreferences().getPublishOnAddRemoveModule()) { - IAdaptable info = null; - /*IAdaptable info = new IAdaptable() { - public Object getAdapter(Class adapter) { - if (Shell.class.equals(adapter)) - return shell; - return null; - } - };*/ - server.publish(IServer.PUBLISH_INCREMENTAL, null, info, null); - } - } - } - }); - } - } - - /** - * ModifyModulesWizard constructor. - * - * @param server a server - */ - public ModifyModulesWizard(IServer server) { - super(Messages.wizModuleWizardTitle, new ModifyModulesWizard2()); - - if (server != null) - getTaskModel().putObject(TaskModel.TASK_SERVER, server.createWorkingCopy()); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/NewRuntimeWizard.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/NewRuntimeWizard.java deleted file mode 100644 index 54a787770..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/NewRuntimeWizard.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.wizard; - -import java.util.List; - -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.wst.server.ui.internal.Messages; -import org.eclipse.wst.server.ui.internal.wizard.fragment.NewRuntimeWizardFragment; -import org.eclipse.wst.server.ui.wizard.WizardFragment; -import org.eclipse.ui.INewWizard; -import org.eclipse.ui.IWorkbench; -/** - * A wizard to create a new runtime. - */ -public class NewRuntimeWizard extends TaskWizard implements INewWizard { - /** - * NewRuntimeWizard constructor comment. - */ - public NewRuntimeWizard() { - super(Messages.wizNewRuntimeWizardTitle, new WizardFragment() { - protected void createChildFragments(List<WizardFragment> list) { - list.add(new NewRuntimeWizardFragment()); - list.add(WizardTaskUtil.SaveRuntimeFragment); - } - }); - - setForcePreviousAndNextButtons(true); - } - - public void init(IWorkbench newWorkbench, IStructuredSelection newSelection) { - // do nothing - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/NewServerWizard.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/NewServerWizard.java deleted file mode 100644 index 304dd7c38..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/NewServerWizard.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.wizard; - -import java.util.List; - -import org.eclipse.jface.viewers.IStructuredSelection; - -import org.eclipse.wst.server.core.TaskModel; -import org.eclipse.wst.server.ui.internal.Messages; -import org.eclipse.wst.server.ui.internal.wizard.fragment.ModifyModulesWizardFragment; -import org.eclipse.wst.server.ui.internal.wizard.fragment.NewServerWizardFragment; -import org.eclipse.wst.server.ui.internal.wizard.fragment.TasksWizardFragment; -import org.eclipse.wst.server.ui.wizard.WizardFragment; -import org.eclipse.ui.INewWizard; -import org.eclipse.ui.IWorkbench; -/** - * A wizard to create a new server and server configuration. - */ -public class NewServerWizard extends TaskWizard implements INewWizard { - /** - * NewServerWizard constructor comment. - */ - public NewServerWizard() { - this(null, null); - } - - public NewServerWizard(final String[] ids, final String[] values) { - super(Messages.wizNewServerWizardTitle, new WizardFragment() { - protected void createChildFragments(List<WizardFragment> list) { - list.add(new NewServerWizardFragment()); - - list.add(WizardTaskUtil.TempSaveRuntimeFragment); - list.add(WizardTaskUtil.TempSaveServerFragment); - - list.add(new ModifyModulesWizardFragment()); - list.add(new TasksWizardFragment()); - - list.add(WizardTaskUtil.SaveRuntimeFragment); - list.add(WizardTaskUtil.SaveServerFragment); - list.add(WizardTaskUtil.SaveHostnameFragment); - } - }); - - if (ids != null) { - TaskModel taskModel2 = getTaskModel(); - int size = ids.length; - for (int i = 0; i < size; i++) { - taskModel2.putObject(ids[i], values[i]); - } - } - } - - public void init(IWorkbench newWorkbench, IStructuredSelection newSelection) { - // do nothing - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/RunOnServerWizard.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/RunOnServerWizard.java deleted file mode 100644 index 7801f414f..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/RunOnServerWizard.java +++ /dev/null @@ -1,157 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.wizard; - -import org.eclipse.debug.core.ILaunchManager; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IModuleArtifact; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.TaskModel; -import org.eclipse.wst.server.core.internal.IClient; -import org.eclipse.wst.server.core.internal.ILaunchableAdapter; -import org.eclipse.wst.server.ui.internal.Messages; -import org.eclipse.wst.server.ui.internal.wizard.fragment.RunOnServerWizardFragment; -/** - * A wizard used for Run on Server. - */ -public class RunOnServerWizard extends TaskWizard { - /** - * RunOnServerWizard constructor comment. - * - * @param module a module - * @param launchMode a launch mode - * @param moduleArtifact a module artifact - */ - public RunOnServerWizard(IModule module, String launchMode, IModuleArtifact moduleArtifact) { - super(Messages.wizRunOnServerTitle, new RunOnServerWizardFragment(module, launchMode, moduleArtifact)); - - setNeedsProgressMonitor(true); - if (ILaunchManager.DEBUG_MODE.equals(launchMode)) - setWindowTitle(Messages.wizDebugOnServerTitle); - else if (ILaunchManager.PROFILE_MODE.equals(launchMode)) - setWindowTitle(Messages.wizProfileOnServerTitle); - getTaskModel().putObject(TaskModel.TASK_LAUNCH_MODE, launchMode); - } - - /** - * RunOnServerWizard constructor comment. - * - * @param server a server - * @param launchMode a launch mode - * @param moduleArtifact a module artifact - */ - public RunOnServerWizard(IServer server, String launchMode, IModuleArtifact moduleArtifact) { - super(Messages.wizRunOnServerTitle, new RunOnServerWizardFragment(server, launchMode, moduleArtifact)); - - setNeedsProgressMonitor(true); - if (ILaunchManager.DEBUG_MODE.equals(launchMode)) - setWindowTitle(Messages.wizDebugOnServerTitle); - else if (ILaunchManager.PROFILE_MODE.equals(launchMode)) - setWindowTitle(Messages.wizProfileOnServerTitle); - - getTaskModel().putObject(TaskModel.TASK_SERVER, server); - getTaskModel().putObject(TaskModel.TASK_LAUNCH_MODE, launchMode); - addPages(); - } - - /** - * Return the server. - * - * @return the server - */ - public IServer getServer() { - try { - return (IServer) getTaskModel().getObject(TaskModel.TASK_SERVER); - } catch (Exception e) { - return null; - } - } - - /** - * Return if the user wants to use the server as a default. - * - * @return true if the server should be the default - */ - public boolean isPreferredServer() { - try { - Boolean b = (Boolean) getTaskModel().getObject(WizardTaskUtil.TASK_DEFAULT_SERVER); - return b.booleanValue(); - } catch (Exception e) { - return false; - } - } - - /** - * Return the selected client. - * - * @return the client - */ - public IClient getSelectedClient() { - try { - return (IClient) getTaskModel().getObject(WizardTaskUtil.TASK_CLIENT); - } catch (Exception e) { - return null; - } - } - - /** - * Return the launchable adapter. - * - * @return the adapter - */ - public ILaunchableAdapter getLaunchableAdapter() { - try { - return (ILaunchableAdapter) getTaskModel().getObject(WizardTaskUtil.TASK_LAUNCHABLE_ADAPTER); - } catch (Exception e) { - return null; - } - } - - /** - * Returns true if this wizard should be shown to the user. - * - * @return <code>true</code> if this wizard should be shown, and <code>false</code> - * otherwise - */ - public boolean shouldAppear() { - return getServer() == null || hasTasks() || hasClients(); - } - - /** - * Return <code>true</code> if this wizard has tasks. - * - * @return <code>true</code> if this wizard has tasks, and <code>false</code> - * otherwise - */ - protected boolean hasTasks() { - try { - Boolean b = (Boolean) getTaskModel().getObject(WizardTaskUtil.TASK_HAS_TASKS); - return b.booleanValue(); - } catch (Exception e) { - return false; - } - } - - /** - * Return <code>true</code> if this wizard has multiple clients to show. - * - * @return <code>true</code> if this wizard has multiple clients, and <code>false</code> - * otherwise - */ - protected boolean hasClients() { - try { - Boolean b = (Boolean) getTaskModel().getObject(WizardTaskUtil.TASK_HAS_CLIENTS); - return b.booleanValue(); - } catch (Exception e) { - return false; - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/TaskWizard.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/TaskWizard.java deleted file mode 100644 index 150d730cb..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/TaskWizard.java +++ /dev/null @@ -1,562 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.wizard; - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.resources.IWorkspaceRunnable; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.wizard.IWizard; -import org.eclipse.jface.wizard.IWizardContainer; -import org.eclipse.jface.wizard.IWizardPage; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.wst.server.core.TaskModel; -import org.eclipse.wst.server.ui.internal.EclipseUtil; -import org.eclipse.wst.server.ui.internal.ServerUIPlugin; -import org.eclipse.wst.server.ui.internal.Trace; -import org.eclipse.wst.server.ui.internal.wizard.page.WorkspaceRunnableAdapter; -import org.eclipse.wst.server.ui.wizard.WizardFragment; -/** - * A wizard used to execute tasks. - */ -public class TaskWizard implements IWizard { - private static final byte FINISH = 2; - private static final byte CANCEL = 3; - - private List<IWizardPage> pages; - private boolean addingPages; - private Map<WizardFragment, TaskWizardPage> fragmentData = new HashMap<WizardFragment, TaskWizardPage>(); - protected TaskModel taskModel; - - private IWizardContainer container = null; - - private boolean needsProgressMonitor = false; - - private boolean forcePreviousAndNextButtons = false; - - private boolean isHelpAvailable = false; - - private Image defaultImage = null; - - private RGB titleBarColor = null; - - private String windowTitle = null; - - private IDialogSettings dialogSettings = null; - - private WizardFragment rootFragment; - private WizardFragment currentFragment; - - /** - * Create a new TaskWizard with the given title and root fragment. - * - * @param title a title - * @param rootFragment a root fragment - */ - public TaskWizard(String title, WizardFragment rootFragment) { - this(title, rootFragment, null); - setWindowTitle(title); - } - - /** - * Create a new TaskWizard with the given title, root fragment, and task model. - * - * @param title a title - * @param rootFragment a root fragment - * @param taskModel a task model - */ - public TaskWizard(String title, WizardFragment rootFragment, TaskModel taskModel) { - super(); - if (title != null) - setWindowTitle(title); - this.rootFragment = rootFragment; - this.taskModel = taskModel; - if (taskModel == null) - this.taskModel = new TaskModel(); - - setNeedsProgressMonitor(true); - setForcePreviousAndNextButtons(true); - } - - public void setTaskModel(TaskModel taskModel) { - this.taskModel = taskModel; - } - - public TaskModel getTaskModel() { - return taskModel; - } - - public void setRootFragment(WizardFragment rootFragment) { - this.rootFragment = rootFragment; - } - - public WizardFragment getRootFragment() { - return rootFragment; - } - - /** - * Cancel the client selection. - * - * @return boolean - */ - public boolean performCancel() { - final List list = getAllWizardFragments(); - IRunnableWithProgress runnable = new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException { - try { - Iterator iterator = list.iterator(); - while (iterator.hasNext()) - executeTask((WizardFragment) iterator.next(), CANCEL, monitor); - } catch (CoreException ce) { - throw new InvocationTargetException(ce); - } - } - }; - - Throwable t = null; - try { - if (getContainer() != null) - getContainer().run(true, true, runnable); - else - runnable.run(new NullProgressMonitor()); - return true; - } catch (InvocationTargetException te) { - t = te.getCause(); - } catch (Exception e) { - t = e; - } - Trace.trace(Trace.SEVERE, "Error cancelling task wizard", t); - - if (t instanceof CoreException) { - EclipseUtil.openError(t.getLocalizedMessage(), ((CoreException)t).getStatus()); - } else - EclipseUtil.openError(t.getLocalizedMessage()); - - return false; - - } - - public boolean performFinish() { - if (currentFragment != null) - currentFragment.exit(); - - final WizardFragment cFragment = currentFragment; - - final List list = getAllWizardFragments(); - IWorkspaceRunnable runnable = new IWorkspaceRunnable() { - public void run(IProgressMonitor monitor) throws CoreException { - // enter & exit the remaining pages - int index = list.indexOf(cFragment); - while (index > 0 && index < list.size() - 1) { - final WizardFragment fragment = (WizardFragment) list.get(++index); - try { - Display.getDefault().syncExec(new Runnable() { - public void run() { - fragment.enter(); - fragment.exit(); - } - }); - } catch (Exception e) { - Trace.trace(Trace.WARNING, "Could not enter/exit page", e); - } - } - - if (useJob()) { - class FinishWizardJob extends Job { - public FinishWizardJob() { - super(getJobTitle()); - } - - public boolean belongsTo(Object family) { - return "org.eclipse.wst.server.ui.family".equals(family); - } - - public IStatus run(IProgressMonitor monitor2) { - try { - Iterator iterator = list.iterator(); - while (iterator.hasNext()) - executeTask((WizardFragment) iterator.next(), FINISH, monitor2); - } catch (CoreException ce) { - Trace.trace(Trace.SEVERE, "Error finishing wizard job", ce); - return new Status(IStatus.ERROR, ServerUIPlugin.PLUGIN_ID, 0, ce.getLocalizedMessage(), null); - } - return Status.OK_STATUS; - } - } - - FinishWizardJob job = new FinishWizardJob(); - job.setUser(true); - job.schedule(); - } else { - Iterator iterator = list.iterator(); - while (iterator.hasNext()) - executeTask((WizardFragment) iterator.next(), FINISH, monitor); - } - } - }; - - Throwable t = null; - try { - if (getContainer() != null) - getContainer().run(true, true, new WorkspaceRunnableAdapter(runnable)); - else - runnable.run(new NullProgressMonitor()); - return true; - } catch (InvocationTargetException te) { - Trace.trace(Trace.SEVERE, "Error finishing task wizard", te); - t = te.getCause(); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error finishing task wizard 2", e); - t = e; - } - - // TODO: show better error dialog, e.g. when Tomcat config is corrupt while doing Add/Remove - // it currently displays the error message twice - Trace.trace(Trace.WARNING, "Error completing wizard", t); - if (t instanceof CoreException) { - EclipseUtil.openError(t.getLocalizedMessage(), ((CoreException)t).getStatus()); - } else if (t instanceof NullPointerException) - EclipseUtil.openError("NullPointerException"); - else - EclipseUtil.openError(t.getLocalizedMessage()); - - return false; - } - - public void addPage(IWizardPage page) { - pages.add(page); - page.setWizard(this); - } - - protected void executeTask(WizardFragment fragment, byte type, IProgressMonitor monitor) throws CoreException { - if (fragment == null) - return; - - if (type == FINISH) - fragment.performFinish(monitor); - else if (type == CANCEL) - fragment.performCancel(monitor); - } - - protected WizardFragment getCurrentWizardFragment() { - return currentFragment; - } - - protected void switchWizardFragment(WizardFragment newFragment) { - List list = getAllWizardFragments(); - int oldIndex = list.indexOf(currentFragment); - int newIndex = list.indexOf(newFragment); - if (oldIndex == newIndex) - return; - - //safeExecuteTask(currentFragment, DEPARTURE); - if (currentFragment != null) - currentFragment.exit(); - - if (oldIndex < newIndex) - oldIndex ++; - else - oldIndex --; - - while (oldIndex != newIndex) { - WizardFragment fragment = (WizardFragment) list.get(oldIndex); - //safeExecuteTask(fragment, ARRIVAL); - //safeExecuteTask(fragment, DEPARTURE); - fragment.enter(); - fragment.exit(); - if (oldIndex < newIndex) - oldIndex ++; - else - oldIndex --; - } - - currentFragment = newFragment; - //safeExecuteTask(currentFragment, ARRIVAL); - currentFragment.enter(); - } - - private List<WizardFragment> getAllWizardFragments() { - List<WizardFragment> list = new ArrayList<WizardFragment>(); - list.add(rootFragment); - addSubWizardFragments(rootFragment, list); - - Iterator iterator = list.iterator(); - while (iterator.hasNext()) { - WizardFragment fragment = (WizardFragment) iterator.next(); - if (!taskModel.equals(fragment.getTaskModel())) - fragment.setTaskModel(taskModel); - } - return list; - } - - private void addSubWizardFragments(WizardFragment fragment, List<WizardFragment> list) { - Iterator iterator = fragment.getChildFragments().iterator(); - while (iterator.hasNext()) { - WizardFragment child = (WizardFragment) iterator.next(); - list.add(child); - addSubWizardFragments(child, list); - } - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.IWizard#addPages() - */ - public void addPages() { - if (addingPages) - return; - - try { - addingPages = true; - pages = new ArrayList<IWizardPage>(); - Iterator<WizardFragment> iterator = getAllWizardFragments().iterator(); - while (iterator.hasNext()) { - WizardFragment fragment = iterator.next(); - TaskWizardPage page = getFragmentData(fragment); - if (fragment.hasComposite()) { - if (page != null) - addPage(page); - else { - TaskWizardPage page2 = new TaskWizardPage(fragment); - fragmentData.put(fragment, page2); - addPage(page2); - } - } - } - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error adding fragments to wizard", e); - } finally { - addingPages = false; - } - } - - /*private static void updateWizardPages() { - try { - current.updatePages(); - current.getContainer().updateButtons(); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error updating wizard pages", e); - } - }*/ - - private TaskWizardPage getFragmentData(WizardFragment fragment) { - try { - TaskWizardPage page = fragmentData.get(fragment); - if (page != null) - return page; - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error getting fragment data", e); - } - - return null; - } - - protected void updatePages() { - addPages(); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.IWizard#canFinish() - */ - public boolean canFinish() { - // Default implementation is to check if all pages are complete. - for (int i= 0; i < pages.size(); i++) { - if (!(pages.get(i)).isPageComplete()) - return false; - } - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.IWizard#createPageControls(org.eclipse.swt.widgets.Composite) - */ - public void createPageControls(Composite pageContainer) { - // the default behavior is to create all the pages controls - for (int i = 0; i < pages.size(); i++){ - IWizardPage page = pages.get(i); - page.createControl(pageContainer); - } - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.IWizard#dispose() - */ - public void dispose() { - // notify pages - for (int i = 0; i < pages.size(); i++) { - pages.get(i).dispose(); - } - - // dispose of image - if (defaultImage != null) { - defaultImage.dispose(); - defaultImage = null; - } - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.IWizard#getContainer() - */ - public IWizardContainer getContainer() { - return container; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.IWizard#getDefaultPageImage() - */ - public Image getDefaultPageImage() { - return defaultImage; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.IWizard#getDialogSettings() - */ - public IDialogSettings getDialogSettings() { - return dialogSettings; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.IWizard#getNextPage(org.eclipse.jface.wizard.IWizardPage) - */ - public IWizardPage getNextPage(IWizardPage page) { - int index = pages.indexOf(page); - if (index == pages.size() - 1 || index == -1) - // last page or page not found - return null; - - return pages.get(index + 1); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.IWizard#getPage(java.lang.String) - */ - public IWizardPage getPage(String name) { - for (int i= 0; i < pages.size(); i++) { - IWizardPage page = pages.get(i); - String pageName = page.getName(); - if (pageName.equals(name)) - return page; - } - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.IWizard#getPageCount() - */ - public int getPageCount() { - return pages.size(); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.IWizard#getPages() - */ - public IWizardPage[] getPages() { - return pages.toArray(new IWizardPage[pages.size()]); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.IWizard#getPreviousPage(org.eclipse.jface.wizard.IWizardPage) - */ - public IWizardPage getPreviousPage(IWizardPage page) { - int index = pages.indexOf(page); - if (index == 0 || index == -1) - // first page or page not found - return null; - return pages.get(index - 1); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.IWizard#getStartingPage() - */ - public IWizardPage getStartingPage() { - if (pages.size() == 0) - return null; - - return pages.get(0); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.IWizard#getTitleBarColor() - */ - public RGB getTitleBarColor() { - return titleBarColor; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.IWizard#getWindowTitle() - */ - public String getWindowTitle() { - return windowTitle; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.IWizard#isHelpAvailable() - */ - public boolean isHelpAvailable() { - return isHelpAvailable; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.IWizard#needsPreviousAndNextButtons() - */ - public boolean needsPreviousAndNextButtons() { - return forcePreviousAndNextButtons || pages.size() > 1; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.IWizard#needsProgressMonitor() - */ - public boolean needsProgressMonitor() { - return needsProgressMonitor; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.wizard.IWizard#setContainer(org.eclipse.jface.wizard.IWizardContainer) - */ - public void setContainer(IWizardContainer wizardContainer) { - this.container = wizardContainer; - } - - public void setDialogSettings(IDialogSettings settings) { - dialogSettings = settings; - } - - public void setNeedsProgressMonitor(boolean b) { - needsProgressMonitor = b; - } - - public void setForcePreviousAndNextButtons(boolean b) { - forcePreviousAndNextButtons = b; - } - - public void setWindowTitle(String title) { - windowTitle = title; - } - - protected boolean useJob() { - return false; - } - - protected String getJobTitle() { - return getWindowTitle(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/TaskWizardPage.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/TaskWizardPage.java deleted file mode 100644 index dd2a2abb5..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/TaskWizardPage.java +++ /dev/null @@ -1,126 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.wizard; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.jface.dialogs.IMessageProvider; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.wizard.IWizardContainer; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.wst.server.ui.internal.Trace; -import org.eclipse.wst.server.ui.wizard.IWizardHandle; -import org.eclipse.wst.server.ui.wizard.WizardFragment; -/** - * A task wizard page. - */ -class TaskWizardPage extends WizardPage implements IWizardHandle { - protected WizardFragment fragment; - - protected boolean isCreated = false; - - public TaskWizardPage(WizardFragment fragment) { - super(fragment.toString()); - this.fragment = fragment; - } - - public void createControl(Composite parentComp) { - Composite comp = null; - try { - comp = fragment.createComposite(parentComp, this); - } catch (Exception e) { - Trace.trace(Trace.WARNING, "Could not create wizard page composite", e); - } - if (comp == null) { - comp = new Composite(parentComp, SWT.NONE); - comp.setLayout(new FillLayout(SWT.VERTICAL)); - Label label = new Label(comp, SWT.NONE); - label.setText("Internal error"); - } - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - data.widthHint = convertHorizontalDLUsToPixels(150); - comp.setLayoutData(data); - setControl(comp); - - isCreated = true; - update(); - } - - public boolean isPageComplete() { - try { - if (!fragment.isComplete()) - return false; - } catch (Exception e) { - return false; - } - return true; - } - - public boolean canFlipToNextPage() { - if (getNextPage() == null) - return false; - try { - if (!fragment.isComplete()) - return false; - } catch (Exception e) { - return false; - } - return true; - } - - public void setVisible(boolean visible) { - super.setVisible(visible); - - if (visible) { - TaskWizard wizard = (TaskWizard) getWizard(); - wizard.switchWizardFragment(fragment); - - if (getContainer().getCurrentPage() != null) - getContainer().updateButtons(); - } - } - - public void setMessage(String message, int type) { - if (type == IMessageProvider.ERROR && "".equals(message)) { - message = null; - } - super.setMessage(message, type); - WizardFragment frag = ((TaskWizard) getWizard()).getCurrentWizardFragment(); - if (!fragment.equals(frag)) - return; - getContainer().updateButtons(); - } - - public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InterruptedException, InvocationTargetException { - getWizard().getContainer().run(fork, cancelable, runnable); - } - - public void update() { - if (!isCreated) - return; - - final IWizardContainer container = getContainer(); - getShell().getDisplay().syncExec(new Runnable() { - public void run() { - fragment.updateChildFragments(); - ((TaskWizard) getWizard()).updatePages(); - - if (container.getCurrentPage() != null) - container.updateButtons(); - } - }); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/WizardTaskUtil.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/WizardTaskUtil.java deleted file mode 100644 index a473ed2d5..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/WizardTaskUtil.java +++ /dev/null @@ -1,224 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.wizard; - -import java.util.List; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.wst.server.core.*; -import org.eclipse.wst.server.core.internal.ProjectProperties; -import org.eclipse.wst.server.core.internal.Server; -import org.eclipse.wst.server.core.internal.ServerPlugin; -import org.eclipse.wst.server.core.internal.ServerWorkingCopy; -import org.eclipse.wst.server.ui.internal.EclipseUtil; -import org.eclipse.wst.server.ui.internal.ServerUIPlugin; -import org.eclipse.wst.server.ui.internal.Trace; -import org.eclipse.wst.server.ui.wizard.WizardFragment; -/** - * - */ -public class WizardTaskUtil { - public static final String TASK_LAUNCHABLE_ADAPTER = "launchableAdapter"; - public static final String TASK_LAUNCHABLE = "launchable"; - public static final String TASK_CLIENT = "client"; - public static final String TASK_CLIENTS = "clients"; - public static final String TASK_DEFAULT_SERVER = "defaultServer"; - public static final String TASK_MODE = "mode"; - public static final String TASK_HAS_TASKS = "hasTasks"; - public static final String TASK_HAS_CLIENTS = "hasClients"; - public static final String TASK_FEATURE = "feature"; - - public static final byte MODE_EXISTING = 0; - public static final byte MODE_DETECT = 1; - public static final byte MODE_MANUAL = 2; - - public static final WizardFragment SaveRuntimeFragment = new WizardFragment() { - public void performFinish(IProgressMonitor monitor) throws CoreException { - WizardTaskUtil.saveRuntime(getTaskModel(), monitor); - } - }; - - public static final WizardFragment SaveServerFragment = new WizardFragment() { - public void performFinish(IProgressMonitor monitor) throws CoreException { - WizardTaskUtil.saveServer(getTaskModel(), monitor); - } - }; - - public static final WizardFragment TempSaveRuntimeFragment = new WizardFragment() { - public void performFinish(IProgressMonitor monitor) throws CoreException { - WizardTaskUtil.tempSaveRuntime(getTaskModel(), monitor); - } - }; - - public static final WizardFragment TempSaveServerFragment = new WizardFragment() { - public void performFinish(IProgressMonitor monitor) throws CoreException { - WizardTaskUtil.tempSaveServer(getTaskModel(), monitor); - } - }; - - public static final WizardFragment SaveHostnameFragment = new WizardFragment() { - public void performFinish(IProgressMonitor monitor) throws CoreException { - try { - IServerAttributes server2 = (IServerAttributes) getTaskModel().getObject(TaskModel.TASK_SERVER); - ServerUIPlugin.getPreferences().addHostname(server2.getHost()); - } catch (Exception e) { - // ignore - } - } - }; - - private WizardTaskUtil() { - // do nothing - } - - protected static void saveRuntime(TaskModel taskModel, IProgressMonitor monitor) throws CoreException { - IRuntime runtime = (IRuntime) taskModel.getObject(TaskModel.TASK_RUNTIME); - if (runtime != null && runtime instanceof IRuntimeWorkingCopy) { - IRuntimeWorkingCopy workingCopy = (IRuntimeWorkingCopy) runtime; - if (workingCopy.isDirty()) - taskModel.putObject(TaskModel.TASK_RUNTIME, workingCopy.save(false, monitor)); - } - } - - /* (non-Javadoc) - * @see org.eclipse.wst.server.ui.internal.task.ITask#doTask() - */ - protected static void saveServer(TaskModel taskModel, IProgressMonitor monitor) throws CoreException { - IServer server = (IServer) taskModel.getObject(TaskModel.TASK_SERVER); - if (server != null && server instanceof IServerWorkingCopy) { - IServerWorkingCopy workingCopy = (IServerWorkingCopy) server; - if (workingCopy.isDirty()) { - IFile file = ((Server)workingCopy).getFile(); - if (file != null) { - IProject project = file.getProject(); - - if (!file.getProject().exists()) - EclipseUtil.createNewServerProject(null, project.getName(), null, monitor); - - ProjectProperties pp = ServerPlugin.getProjectProperties(project); - if (!pp.isServerProject()) - pp.setServerProject(true, monitor); - } - taskModel.putObject(TaskModel.TASK_SERVER, workingCopy.save(false, monitor)); - } - } - } - - protected static void tempSaveRuntime(TaskModel taskModel, IProgressMonitor monitor) throws CoreException { - IRuntime runtime = (IRuntime) taskModel.getObject(TaskModel.TASK_RUNTIME); - if (runtime != null && runtime instanceof IRuntimeWorkingCopy) { - IRuntimeWorkingCopy workingCopy = (IRuntimeWorkingCopy) runtime; - if (!workingCopy.isDirty()) - return; - - runtime = workingCopy.save(false, monitor); - taskModel.putObject(TaskModel.TASK_RUNTIME, runtime.createWorkingCopy()); - } - } - - protected static void tempSaveServer(TaskModel taskModel, IProgressMonitor monitor) throws CoreException { - IServer server = (IServer) taskModel.getObject(TaskModel.TASK_SERVER); - if (server != null && server instanceof IServerWorkingCopy) { - IServerWorkingCopy workingCopy = (IServerWorkingCopy) server; - if (!workingCopy.isDirty()) - return; - - IFile file = ((Server)workingCopy).getFile(); - if (file != null) { - IProject project = file.getProject(); - - if (!file.getProject().exists()) - EclipseUtil.createNewServerProject(null, project.getName(), null, monitor); - - ProjectProperties pp = ServerPlugin.getProjectProperties(project); - if (!pp.isServerProject()) - pp.setServerProject(true, monitor); - } - IRuntime runtime = workingCopy.getRuntime(); - - server = workingCopy.save(false, monitor); - workingCopy = server.createWorkingCopy(); - - workingCopy.setRuntime(runtime); - if (workingCopy.getServerType().hasServerConfiguration()) - ((ServerWorkingCopy)workingCopy).importRuntimeConfiguration(runtime, null); - - taskModel.putObject(TaskModel.TASK_SERVER, workingCopy); - } - } - - public static void addModule(IModule module, TaskModel taskModel, IProgressMonitor monitor) throws CoreException { - if (module == null) - return; - - IServer server = (IServer) taskModel.getObject(TaskModel.TASK_SERVER); - IModule parentModule = null; - try { - IModule[] parents = server.getRootModules(module, monitor); - if (parents != null && parents.length > 0) - parentModule = parents[0]; - } catch (Exception e) { - Trace.trace(Trace.WARNING, "Could not find parent module", e); - } - - if (parentModule == null) { - // use the original module since no parent module is available - parentModule = module; - } - - IModule[] modules = server.getModules(); - int size = modules.length; - for (int i = 0; i < size; i++) { - if (parentModule.equals(modules[i])) - return; - } - - IServerWorkingCopy workingCopy = server.createWorkingCopy(); - workingCopy.modifyModules(new IModule[] { parentModule }, new IModule[0], monitor); - taskModel.putObject(TaskModel.TASK_SERVER, workingCopy.save(false, monitor)); - } - - public static void modifyModules(List<IModule> add, List<IModule> remove, TaskModel taskModel, IProgressMonitor monitor) throws CoreException { - if ((add == null || add.isEmpty()) && (remove == null || remove.isEmpty())) - return; - - IServerWorkingCopy workingCopy = (IServerWorkingCopy) taskModel.getObject(TaskModel.TASK_SERVER); - - // modify modules - IModule[] remove2 = new IModule[0]; - if (remove != null) { - remove2 = new IModule[remove.size()]; - remove.toArray(remove2); - } - - IModule[] add2 = new IModule[0]; - if (add != null) { - add2 = new IModule[add.size()]; - add.toArray(add2); - } - - IFile file = ((Server)workingCopy).getFile(); - if (file != null) { - IProject project = file.getProject(); - - if (!file.getProject().exists()) - EclipseUtil.createNewServerProject(null, project.getName(), null, monitor); - - ProjectProperties pp = ServerPlugin.getProjectProperties(project); - if (!pp.isServerProject()) - pp.setServerProject(true, monitor); - } - - workingCopy.modifyModules(add2, remove2, monitor); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/LicenseWizardFragment.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/LicenseWizardFragment.java deleted file mode 100644 index 3555b420d..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/LicenseWizardFragment.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.wizard.fragment; - -import org.eclipse.swt.widgets.Composite; -import org.eclipse.wst.server.ui.internal.ImageResource; -import org.eclipse.wst.server.ui.internal.Messages; -import org.eclipse.wst.server.ui.internal.wizard.page.LicenseComposite; -import org.eclipse.wst.server.ui.wizard.WizardFragment; -import org.eclipse.wst.server.ui.wizard.IWizardHandle; -/** - * - */ -public class LicenseWizardFragment extends WizardFragment { - public static final String LICENSE = "license"; - public static final String LICENSE_NONE = "none"; - public static final String LICENSE_UNKNOWN = "unknown"; - public static final String LICENSE_ACCEPT = "accept"; - public static final String LICENSE_SERVER = "license_server"; - - protected LicenseComposite comp; - - public LicenseWizardFragment() { - // do nothing - } - - public void enter() { - if (comp != null) - comp.updateLicense(); - } - - public boolean hasComposite() { - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.server.ui.internal.task.WizardTask#getWizardPage() - */ - public Composite createComposite(Composite parent, IWizardHandle wizard) { - comp = new LicenseComposite(parent, getTaskModel(), wizard); - - wizard.setTitle(Messages.wizLicenseTitle); - wizard.setDescription(Messages.wizLicenseDescription); - wizard.setImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_WIZBAN_NEW_SERVER)); - return comp; - } - - public boolean isComplete() { - try { - Boolean b = (Boolean) getTaskModel().getObject(LicenseWizardFragment.LICENSE_ACCEPT); - if (b != null && b.booleanValue()) - return true; - } catch (Exception e) { - // ignore - } - return false; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/ModifyModulesWizardFragment.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/ModifyModulesWizardFragment.java deleted file mode 100644 index 498555d76..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/ModifyModulesWizardFragment.java +++ /dev/null @@ -1,135 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.wizard.fragment; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.wst.server.core.*; -import org.eclipse.wst.server.core.internal.IModuleVisitor; -import org.eclipse.wst.server.core.internal.Server; -import org.eclipse.wst.server.ui.internal.ServerUIPlugin; -import org.eclipse.wst.server.ui.internal.Trace; -import org.eclipse.wst.server.ui.internal.wizard.WizardTaskUtil; -import org.eclipse.wst.server.ui.internal.wizard.page.ModifyModulesComposite; -import org.eclipse.wst.server.ui.wizard.IWizardHandle; -import org.eclipse.wst.server.ui.wizard.WizardFragment; -/** - * - */ -public class ModifyModulesWizardFragment extends WizardFragment { - protected ModifyModulesComposite comp; - - protected IModule module; - protected boolean showPublishOption; - - public ModifyModulesWizardFragment() { - // do nothing - } - - public ModifyModulesWizardFragment(boolean showPublishOption) { - this.showPublishOption = showPublishOption; - } - - public ModifyModulesWizardFragment(IModule module) { - this.module = module; - } - - public boolean hasComposite() { - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.server.ui.internal.task.WizardTask#getWizardPage() - */ - public Composite createComposite(Composite parent, IWizardHandle handle) { - comp = new ModifyModulesComposite(parent, handle, module, showPublishOption); - return comp; - } - - public void setTaskModel(TaskModel taskModel) { - super.setTaskModel(taskModel); - if (comp != null) - comp.setTaskModel(taskModel); - } - - public List getChildFragments() { - updateModules(); - return super.getChildFragments(); - } - - public void enter() { - updateModules(); - } - - protected void updateModules() { - if (comp != null) { - IServerAttributes server = (IServerAttributes) getTaskModel().getObject(TaskModel.TASK_SERVER); - comp.setTaskModel(getTaskModel()); - comp.setServer(server); - } else if (module != null) { - TaskModel taskModel = getTaskModel(); - if (taskModel == null) - return; - IServerWorkingCopy server = (IServerWorkingCopy) taskModel.getObject(TaskModel.TASK_SERVER); - if (server == null) { - taskModel.putObject(TaskModel.TASK_MODULES, null); - return; - } - - final List<IModule[]> moduleList = new ArrayList<IModule[]>(); - ((Server) server).visit(new IModuleVisitor() { - public boolean visit(IModule[] module2) { - moduleList.add(module2); - return true; - } - }, null); - - // add module - IModule parent = null; - try { - IModule[] parents = server.getRootModules(module, null); - List<IModule> list = new ArrayList<IModule>(); - - if (parents != null && parents.length > 0) { - parent = parents[0]; - list.add(parent); - } - // TODO - get parent modules correct - if (!moduleList.contains(module)) { - moduleList.add(new IModule[] { module }); - } - } catch (Exception e) { - Trace.trace(Trace.WARNING, "Could not find parent module", e); - } - - taskModel.putObject(TaskModel.TASK_MODULES, moduleList); - } - } - - public boolean isComplete() { - if (comp != null) - return comp.isComplete(); - - return true; - } - - public void performFinish(IProgressMonitor monitor) throws CoreException { - if (comp != null) { - WizardTaskUtil.modifyModules(comp.getModulesToAdd(), comp.getModulesToRemove(), getTaskModel(), monitor); - if (showPublishOption) - ServerUIPlugin.getPreferences().setPublishOnAddRemoveModule(comp.shouldPublishImmediately()); - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewRuntimeWizardFragment.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewRuntimeWizardFragment.java deleted file mode 100644 index 273d1ed90..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewRuntimeWizardFragment.java +++ /dev/null @@ -1,124 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.wizard.fragment; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.wst.server.core.IRuntimeWorkingCopy; -import org.eclipse.wst.server.core.IServerWorkingCopy; -import org.eclipse.wst.server.core.TaskModel; -import org.eclipse.wst.server.core.internal.ServerWorkingCopy; -import org.eclipse.wst.server.ui.internal.ServerUIPlugin; -import org.eclipse.wst.server.ui.internal.wizard.WizardTaskUtil; -import org.eclipse.wst.server.ui.internal.wizard.page.NewRuntimeComposite; -import org.eclipse.wst.server.ui.wizard.WizardFragment; -import org.eclipse.wst.server.ui.wizard.IWizardHandle; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.swt.widgets.Composite; -/** - * - */ -public class NewRuntimeWizardFragment extends WizardFragment { - // filter by type/version - protected String type; - protected String version; - - // filter by partial runtime type id - protected String runtimeTypeId; - - protected Map<String, WizardFragment> fragmentMap = new HashMap<String, WizardFragment>(); - - public NewRuntimeWizardFragment() { - // do nothing - } - - public NewRuntimeWizardFragment(String type, String version, String runtimeTypeId) { - this.type = type; - this.version = version; - this.runtimeTypeId = runtimeTypeId; - } - - public boolean hasComposite() { - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.server.ui.internal.task.WizardTask#getWizardPage() - */ - public Composite createComposite(Composite parent, IWizardHandle wizard) { - return new NewRuntimeComposite(parent, wizard, getTaskModel(), type, version, runtimeTypeId); - } - - public List getChildFragments() { - List<WizardFragment> listImpl = new ArrayList<WizardFragment>(); - createChildFragments(listImpl); - return listImpl; - } - - protected void createChildFragments(List<WizardFragment> list) { - if (getTaskModel() == null) - return; - - IRuntimeWorkingCopy runtime = (IRuntimeWorkingCopy) getTaskModel().getObject(TaskModel.TASK_RUNTIME); - if (runtime == null) - return; - - WizardFragment sub = getWizardFragment(runtime.getRuntimeType().getId()); - if (sub != null) - list.add(sub); - - IServerWorkingCopy server = (IServerWorkingCopy) getTaskModel().getObject(TaskModel.TASK_SERVER); - if (server != null) { - if (server.getServerType().hasServerConfiguration() && server instanceof ServerWorkingCopy) { - ServerWorkingCopy swc = (ServerWorkingCopy) server; - try { - if (runtime.getLocation() != null && !runtime.getLocation().isEmpty()) - swc.importRuntimeConfiguration(runtime, null); - } catch (CoreException ce) { - // ignore - } - } - - list.add(new WizardFragment() { - public void enter() { - IRuntimeWorkingCopy runtime2 = (IRuntimeWorkingCopy) getTaskModel().getObject(TaskModel.TASK_RUNTIME); - IServerWorkingCopy server2 = (IServerWorkingCopy) getTaskModel().getObject(TaskModel.TASK_SERVER); - server2.setRuntime(runtime2); - } - }); - - sub = getWizardFragment(server.getServerType().getId()); - if (sub != null) - list.add(sub); - - list.add(WizardTaskUtil.SaveServerFragment); - } - } - - protected WizardFragment getWizardFragment(String typeId) { - try { - WizardFragment fragment = fragmentMap.get(typeId); - if (fragment != null) - return fragment; - } catch (Exception e) { - // ignore - } - - WizardFragment fragment = ServerUIPlugin.getWizardFragment(typeId); - if (fragment != null) - fragmentMap.put(typeId, fragment); - return fragment; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewServerWizardFragment.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewServerWizardFragment.java deleted file mode 100644 index 0b0694ef2..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewServerWizardFragment.java +++ /dev/null @@ -1,152 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.wizard.fragment; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.wst.server.core.*; -import org.eclipse.wst.server.core.internal.ServerWorkingCopy; -import org.eclipse.wst.server.ui.internal.ServerUIPlugin; -import org.eclipse.wst.server.ui.internal.wizard.WizardTaskUtil; -import org.eclipse.wst.server.ui.internal.wizard.page.NewServerComposite; -import org.eclipse.wst.server.ui.wizard.WizardFragment; -import org.eclipse.wst.server.ui.wizard.IWizardHandle; -/** - * - */ -public class NewServerWizardFragment extends WizardFragment { - public static final byte MODE_EXISTING = WizardTaskUtil.MODE_EXISTING; - public static final byte MODE_DETECT = WizardTaskUtil.MODE_DETECT; - public static final byte MODE_MANUAL = WizardTaskUtil.MODE_MANUAL; - - protected IModule module; - protected IModuleType moduleType; - protected String serverTypeId; - - protected Map<String, WizardFragment> fragmentMap = new HashMap<String, WizardFragment>(); - protected IPath runtimeLocation = null; - - public NewServerWizardFragment() { - // do nothing - } - - public NewServerWizardFragment(IModuleType moduleType, String serverTypeId) { - this.moduleType = moduleType; - this.serverTypeId = serverTypeId; - } - - public NewServerWizardFragment(IModule module) { - this.module = module; - } - - public boolean hasComposite() { - return true; - } - - public void enter() { - super.enter(); - } - - /* (non-Javadoc) - * @see org.eclipse.wst.server.ui.internal.task.WizardTask#getWizardPage() - */ - public Composite createComposite(Composite parent, IWizardHandle wizard) { - String launchMode = (String) getTaskModel().getObject(TaskModel.TASK_LAUNCH_MODE); - NewServerComposite comp = null; - if (moduleType != null || serverTypeId != null) - comp = new NewServerComposite(parent, wizard, moduleType, serverTypeId, launchMode); - else - comp = new NewServerComposite(parent, wizard, module, launchMode); - if (getTaskModel() != null) - comp.setTaskModel(getTaskModel()); - return comp; - } - - protected WizardFragment getWizardFragment(String typeId) { - try { - WizardFragment fragment = fragmentMap.get(typeId); - if (fragment != null) - return fragment; - } catch (Exception e) { - // ignore - } - - WizardFragment fragment = ServerUIPlugin.getWizardFragment(typeId); - if (fragment != null) - fragmentMap.put(typeId, fragment); - return fragment; - } - - public List getChildFragments() { - List<WizardFragment> listImpl = new ArrayList<WizardFragment>(); - createChildFragments(listImpl); - return listImpl; - } - - protected void createChildFragments(List<WizardFragment> list) { - if (getTaskModel() == null) - return; - - Byte b = (Byte) getTaskModel().getObject(WizardTaskUtil.TASK_MODE); - if (b != null && b.byteValue() == MODE_MANUAL) { - IRuntime runtime = (IRuntime) getTaskModel().getObject(TaskModel.TASK_RUNTIME); - if (runtime != null && runtime instanceof IRuntimeWorkingCopy) { - WizardFragment sub = getWizardFragment(runtime.getRuntimeType().getId()); - if (sub != null) - list.add(sub); - } - - IServerAttributes server = (IServerAttributes) getTaskModel().getObject(TaskModel.TASK_SERVER); - if (server != null) { - if (server.getServerType().hasServerConfiguration() && server instanceof ServerWorkingCopy) { - ServerWorkingCopy swc = (ServerWorkingCopy) server; - if (runtime != null && runtime.getLocation() != null && !runtime.getLocation().isEmpty()) { - if (runtimeLocation == null || !runtimeLocation.equals(runtime.getLocation())) - try { - swc.importRuntimeConfiguration(runtime, null); - } catch (CoreException ce) { - // ignore - } - runtimeLocation = runtime.getLocation(); - } else - runtimeLocation = null; - } - WizardFragment sub = getWizardFragment(server.getServerType().getId()); - if (sub != null) - list.add(sub); - } - } else if (b != null && b.byteValue() == MODE_EXISTING) { - /*if (comp != null) { - IServer server = comp.getServer(); - if (server != null) - list.add(new TasksWizardFragment()); - }*/ - } - } - - public boolean isComplete() { - return getServer() != null; - } - - private IServerWorkingCopy getServer() { - try { - return (IServerWorkingCopy) getTaskModel().getObject(TaskModel.TASK_SERVER); - } catch (Exception e) { - return null; - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/OptionalClientWizardFragment.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/OptionalClientWizardFragment.java deleted file mode 100644 index 95952653a..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/OptionalClientWizardFragment.java +++ /dev/null @@ -1,121 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.wizard.fragment; - -import java.util.List; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.wst.server.core.IModuleArtifact; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.TaskModel; -import org.eclipse.wst.server.core.internal.IClient; -import org.eclipse.wst.server.ui.internal.EclipseUtil; -import org.eclipse.wst.server.ui.internal.ServerUIPlugin; -import org.eclipse.wst.server.ui.internal.wizard.WizardTaskUtil; -import org.eclipse.wst.server.ui.wizard.WizardFragment; -/** - * A fragment used to select a client. - */ -public class OptionalClientWizardFragment extends WizardFragment { - protected IClient[] clients; - - protected IModuleArtifact moduleArtifact; - protected IServer lastServer; - protected Object lastLaunchable; - - public OptionalClientWizardFragment(IModuleArtifact moduleArtifact) { - super(); - this.moduleArtifact = moduleArtifact; - } - - protected void createChildFragments(List<WizardFragment> list) { - if (clients != null && clients.length > 1) - list.add(new SelectClientWizardFragment()); - } - - protected void updateClients() { - if (getTaskModel() == null) - return; - - try { - IServer server = (IServer) getTaskModel().getObject(TaskModel.TASK_SERVER); - - if (server == null) { - getTaskModel().putObject(WizardTaskUtil.TASK_LAUNCHABLE_ADAPTER, null); - getTaskModel().putObject(WizardTaskUtil.TASK_LAUNCHABLE, null); - getTaskModel().putObject(WizardTaskUtil.TASK_CLIENTS, null); - getTaskModel().putObject(WizardTaskUtil.TASK_HAS_CLIENTS, new Boolean(false)); - return; - } - - //if (lastServer == null) - // return; - - // get the launchable adapter and module object - Object launchable = null; - try { - Object[] obj = ServerUIPlugin.getLaunchableAdapter(server, moduleArtifact); - getTaskModel().putObject(WizardTaskUtil.TASK_LAUNCHABLE_ADAPTER, obj[0]); - getTaskModel().putObject(WizardTaskUtil.TASK_LAUNCHABLE, obj[1]); - launchable = obj[1]; - } catch (CoreException ce) { - getTaskModel().putObject(WizardTaskUtil.TASK_LAUNCHABLE_ADAPTER, null); - getTaskModel().putObject(WizardTaskUtil.TASK_LAUNCHABLE, null); - getTaskModel().putObject(WizardTaskUtil.TASK_CLIENTS, null); - getTaskModel().putObject(WizardTaskUtil.TASK_HAS_CLIENTS, new Boolean(false)); - EclipseUtil.openError(null, ce.getStatus()); - return; - } - - // stop here if the server and launchable haven't changed - if (lastServer != null && lastServer.equals(server)) { - if (lastLaunchable == null && launchable == null) - return; - if (lastLaunchable != null && lastLaunchable.equals(launchable)) { - return; - } - } - lastServer = server; - lastLaunchable = launchable; - - String launchMode = (String) getTaskModel().getObject(TaskModel.TASK_LAUNCH_MODE); - clients = ServerUIPlugin.getClients(server, launchable, launchMode); - - getTaskModel().putObject(WizardTaskUtil.TASK_CLIENTS, null); - getTaskModel().putObject(WizardTaskUtil.TASK_HAS_CLIENTS, new Boolean(false)); - if (clients != null) { - if (clients.length > 1) { - getTaskModel().putObject(WizardTaskUtil.TASK_CLIENTS, clients); - getTaskModel().putObject(WizardTaskUtil.TASK_HAS_CLIENTS, new Boolean(true)); - } else - getTaskModel().putObject(WizardTaskUtil.TASK_CLIENT, clients[0]); - } - - updateChildFragments(); - } catch (Exception e) { - // ignore - } - } - - public void enter() { - updateClients(); - } - - public List getChildFragments() { - updateClients(); - return super.getChildFragments(); - } - - public void setTaskModel(TaskModel taskModel) { - super.setTaskModel(taskModel); - updateClients(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/RunOnServerWizardFragment.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/RunOnServerWizardFragment.java deleted file mode 100644 index b2fcf7a3a..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/RunOnServerWizardFragment.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.wizard.fragment; - -import java.util.List; - -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IModuleArtifact; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.ui.internal.wizard.WizardTaskUtil; -import org.eclipse.wst.server.ui.wizard.WizardFragment; -/** - * A fragment used for the Run on Server wizard. - */ -public class RunOnServerWizardFragment extends WizardFragment { - protected IServer server; - protected IModule module; - protected IModuleArtifact moduleArtifact; - - /** - * Create the Run on Server wizard with all pages. - * - * @param module - * @param launchMode - * @param moduleArtifact - */ - public RunOnServerWizardFragment(IModule module, String launchMode, IModuleArtifact moduleArtifact) { - super(); - this.module = module; - this.moduleArtifact = moduleArtifact; - } - - /** - * Create the Run on Server wizard with a default server. - * - * @param server a server - * @param launchMode - * @param moduleArtifact - */ - public RunOnServerWizardFragment(IServer server, String launchMode, IModuleArtifact moduleArtifact) { - super(); - this.server = server; - this.moduleArtifact = moduleArtifact; - } - - protected void createChildFragments(List<WizardFragment> list) { - if (server == null) { - list.add(new NewServerWizardFragment(module)); - - list.add(WizardTaskUtil.TempSaveRuntimeFragment); - list.add(WizardTaskUtil.TempSaveServerFragment); - - list.add(new ModifyModulesWizardFragment(module)); - } - - list.add(new TasksWizardFragment()); - - list.add(WizardTaskUtil.SaveRuntimeFragment); - list.add(WizardTaskUtil.SaveServerFragment); - if (server == null) - list.add(WizardTaskUtil.SaveHostnameFragment); - - list.add(new OptionalClientWizardFragment(moduleArtifact)); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/SelectClientWizardFragment.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/SelectClientWizardFragment.java deleted file mode 100644 index f27eb7505..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/SelectClientWizardFragment.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.wizard.fragment; - -import org.eclipse.swt.widgets.Composite; -import org.eclipse.wst.server.core.internal.IClient; -import org.eclipse.wst.server.ui.internal.wizard.WizardTaskUtil; -import org.eclipse.wst.server.ui.internal.wizard.page.SelectClientComposite; -import org.eclipse.wst.server.ui.wizard.WizardFragment; -import org.eclipse.wst.server.ui.wizard.IWizardHandle; -/** - * A fragment used to select a client. - */ -public class SelectClientWizardFragment extends WizardFragment { - public SelectClientWizardFragment() { - super(); - } - - public boolean hasComposite() { - return true; - } - - public Composite createComposite(Composite parent, IWizardHandle wizard) { - return new SelectClientComposite(parent, wizard, getTaskModel()); - } - - public boolean isComplete() { - try { - IClient[] clients = (IClient[]) getTaskModel().getObject(WizardTaskUtil.TASK_CLIENTS); - if (clients == null || clients.length < 2) - return true; - } catch (Exception e) { - return true; - } - - return getTaskModel().getObject(WizardTaskUtil.TASK_CLIENT) != null; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/SubTasksWizardFragment.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/SubTasksWizardFragment.java deleted file mode 100644 index df4a1e3db..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/SubTasksWizardFragment.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.wizard.fragment; - -import java.util.List; - -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.wst.server.ui.internal.wizard.page.TasksComposite; -import org.eclipse.wst.server.ui.wizard.IWizardHandle; -import org.eclipse.wst.server.ui.wizard.WizardFragment; -/** - * - */ -public class SubTasksWizardFragment extends WizardFragment { - protected TasksComposite comp; - - protected List tasks; - - public SubTasksWizardFragment() { - // do nothing - } - - public void enter() { - updateTasks(tasks); - - if (comp != null) - comp.createControl(); - } - - public void updateTasks(List newTasks) { - tasks = newTasks; - if (comp != null) - Display.getDefault().syncExec(new Runnable() { - public void run() { - if (comp != null && !comp.isDisposed()) - comp.setTasks(tasks); - } - }); - } - - public boolean hasComposite() { - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.server.ui.internal.task.WizardTask#getWizardPage() - */ - public Composite createComposite(Composite parent, IWizardHandle wizard) { - comp = new TasksComposite(parent, wizard); - return comp; - } -} diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/TasksWizardFragment.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/TasksWizardFragment.java deleted file mode 100644 index 5bc5f47d8..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/TasksWizardFragment.java +++ /dev/null @@ -1,305 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.wizard.fragment; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.wst.server.core.*; -import org.eclipse.wst.server.core.internal.*; -import org.eclipse.wst.server.core.model.PublishOperation; -import org.eclipse.wst.server.ui.internal.editor.IOrdered; -import org.eclipse.wst.server.ui.internal.wizard.WizardTaskUtil; -import org.eclipse.wst.server.ui.wizard.WizardFragment; -/** - * - */ -public class TasksWizardFragment extends WizardFragment { - private static final int TASKS_PER_PAGE = 5; - - public class TaskInfo implements IOrdered { - public int kind; - public String id; - public PublishOperation task2; - - private static final String DEFAULT = "default:"; - - public boolean isSelected() { - if (id == null) - return false; - - if (selectedTaskMap.containsKey(id)) - return (selectedTaskMap.get(id)).booleanValue(); - - if (selectedTaskMap.containsKey(DEFAULT + id)) - return (selectedTaskMap.get(DEFAULT + id)).booleanValue(); - - return false; - } - - public void setDefaultSelected(boolean sel) { - selectedTaskMap.put(DEFAULT + getId(), new Boolean(sel)); - } - - public boolean getDefaultSelected() { - return (selectedTaskMap.get(DEFAULT + id)).booleanValue(); - } - - public void setSelected(boolean sel) { - selectedTaskMap.put(getId(), new Boolean(sel)); - } - - public int getOrder() { - return task2.getOrder(); - } - - protected String getId() { - return id; - } - - public boolean equals(Object obj) { - if (!(obj instanceof TaskInfo)) - return false; - - TaskInfo ti = (TaskInfo) obj; - if (kind != ti.kind) - return false; - - if (id == null || !id.equals(ti.id)) - return false; - - if (task2 == null && ti.task2 != null) - return false; - - if (task2 != null && ti.task2 == null) - return false; - - try { - if (task2 != null && ti.task2 != null) { - if (task2.getKind() != ti.task2.getKind()) - return false; - if (task2.getOrder() != ti.task2.getOrder()) - return false; - if (!task2.getLabel().equals(ti.task2.getLabel())) - return false; - if (!task2.getDescription().equals(ti.task2.getDescription())) - return false; - } - } catch (Exception e) { - // ignore - } - return true; - } - } - - protected List<TaskInfo> tasks; - protected boolean hasOptionalTasks; - protected boolean hasPreferredTasks; - - protected Map<String, Boolean> selectedTaskMap = new HashMap<String, Boolean>(); - - public TasksWizardFragment() { - // do nothing - } - - protected void createChildFragments(List<WizardFragment> list) { - if (tasks == null || tasks.isEmpty()) - return; - - int size = tasks.size(); - int pages = (size - 1) / TASKS_PER_PAGE + 1; - for (int i = 0; i < pages; i++) { - SubTasksWizardFragment fragment = new SubTasksWizardFragment(); - List list2 = tasks.subList(TASKS_PER_PAGE * i, Math.min(size, TASKS_PER_PAGE * (i+1))); - fragment.updateTasks(list2); - list.add(fragment); - } - } - - public void enter() { - updateTasks(); - } - - public List getChildFragments() { - updateTasks(); - return super.getChildFragments(); - } - - public void setTaskModel(TaskModel taskModel) { - super.setTaskModel(taskModel); - updateTasks(); - } - - public void updateTasks() { - if (getTaskModel() == null) { - tasks = null; - return; - } - - IServerAttributes server = (IServerAttributes) getTaskModel().getObject(TaskModel.TASK_SERVER); - List modules = (List) getTaskModel().getObject(TaskModel.TASK_MODULES); - - if (server != null && modules == null) { - final List<IModule[]> moduleList = new ArrayList<IModule[]>(); - ((Server) server).visit(new IModuleVisitor() { - public boolean visit(IModule[] module2) { - moduleList.add(module2); - return true; - } - }, null); - - modules = moduleList; - } - - if (server != null && modules != null) { - hasOptionalTasks = false; - hasPreferredTasks = false; - List<TaskInfo> taskList = new ArrayList<TaskInfo>(5); - createTasks(taskList, server, modules); - - if (tasks == null || !tasks.equals(taskList)) { - tasks = taskList; - updateChildFragments(); - - boolean b = hasOptionalTasks || hasPreferredTasks; - getTaskModel().putObject(WizardTaskUtil.TASK_HAS_TASKS, new Boolean(b)); - } - } - } - - protected void createTasks(List<TaskInfo> taskList, IServerAttributes server, List modules) { - if (server == null) - return; - - List<String> enabledTasks = ((Server)server).getEnabledOptionalPublishOperationIds(); - List<String> disabledTasks = ((Server)server).getDisabledPreferredPublishOperationIds(); - PublishOperation[] tasks2 = ((Server)server).getAllTasks(modules); - for (int j = 0; j < tasks2.length; j++) { - int kind = tasks2[j].getKind(); - String id = ((Server)server).getPublishOperationId(tasks2[j]); - if (kind == PublishOperation.OPTIONAL || kind == PublishOperation.PREFERRED) - hasOptionalTasks = true; - if (kind == PublishOperation.PREFERRED) - hasPreferredTasks = true; - tasks2[j].setTaskModel(getTaskModel()); - - boolean selected = true; - if (kind == PublishOperation.OPTIONAL) { - if (!enabledTasks.contains(id)) - selected = false; - } else if (kind == PublishOperation.PREFERRED) { - if (disabledTasks.contains(id)) - selected = false; - } - taskList.add(getServerTask(server, tasks2[j], selected)); - } - } - - public TaskInfo getServerTask(IServerAttributes server, PublishOperation task2, boolean selected) { - TaskInfo sti = new TaskInfo(); - sti.task2 = task2; - sti.kind = task2.getKind(); - sti.id = ((Server)server).getPublishOperationId(task2); - sti.setDefaultSelected(selected); - - return sti; - } - - /** - * @see WizardFragment#performFinish(IProgressMonitor) - */ - public void performFinish(IProgressMonitor monitor) throws CoreException { - if (!hasOptionalTasks) - return; - - if (tasks == null || tasks.isEmpty()) - return; - - TaskModel taskModel = getTaskModel(); - IServer server = (IServer)taskModel.getObject(TaskModel.TASK_SERVER); - if (server == null) - return; - - boolean createdWC = false; - ServerWorkingCopy wc = null; - if (server instanceof ServerWorkingCopy) - wc = (ServerWorkingCopy)server; - else { - wc = (ServerWorkingCopy)server.createWorkingCopy(); - createdWC = true; - } - - // compare lists - List<String> disabled = new ArrayList<String>(); - List<String> enabled = new ArrayList<String>(); - Iterator iterator = tasks.iterator(); - while (iterator.hasNext()) { - TaskInfo task = (TaskInfo)iterator.next(); - if (PublishOperation.REQUIRED == task.kind) - continue; - - String id = wc.getPublishOperationId(task.task2); - if (PublishOperation.PREFERRED == task.kind) { - if (!task.isSelected()) - disabled.add(id); - } else if (PublishOperation.OPTIONAL == task.kind) { - if (task.isSelected()) - enabled.add(id); - } - } - - List<String> curDisabled = wc.getDisabledPreferredPublishOperationIds(); - List<String> curEnabled = wc.getEnabledOptionalPublishOperationIds(); - - boolean different = false; - if (curEnabled.size() != enabled.size() || curDisabled.size() != disabled.size()) { - different = true; - } else { - for (String id : curDisabled) { - if (!disabled.contains(id)) - different = true; - } - for (String id : curEnabled) { - if (!enabled.contains(id)) - different = true; - } - } - - if (different) { - wc.resetPreferredPublishOperations(); - wc.resetOptionalPublishOperations(); - - Iterator<TaskInfo> iterator2 = tasks.iterator(); - while (iterator2.hasNext()) { - TaskInfo task = iterator2.next(); - if (PublishOperation.REQUIRED == task.kind) - continue; - - if (PublishOperation.PREFERRED == task.kind) { - if (!task.isSelected()) - wc.disablePreferredPublishOperations(task.task2); - } else if (PublishOperation.OPTIONAL == task.kind) { - if (task.isSelected()) - wc.enableOptionalPublishOperations(task.task2); - } - } - } - - if (createdWC && wc.isDirty()) - wc.save(true, monitor); - monitor.done(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/FixedTableLayout.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/FixedTableLayout.java deleted file mode 100644 index b579320b7..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/FixedTableLayout.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.wizard.page; - -//import java.util.ArrayList; -//import java.util.List; - -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Layout; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -/** - * - */ -public class FixedTableLayout extends Layout { - //private List columns = new ArrayList(); - - /*public void addColumnData(Integer data) { - columns.add(data); - }*/ - - /* (non-Javadoc) - * @see org.eclipse.swt.widgets.Layout#computeSize(org.eclipse.swt.widgets.Composite, int, int, boolean) - */ - protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) { - Table table = (Table) composite; - Point result = table.computeSize(wHint, hHint, flushCache); - return result; - } - - /* (non-Javadoc) - * @see org.eclipse.swt.widgets.Layout#layout(org.eclipse.swt.widgets.Composite, boolean) - */ - protected void layout(Composite composite, boolean flushCache) { - Table table = (Table) composite; - TableColumn[] tableColumns = table.getColumns(); - int width = table.getClientArea().width - 10; - - tableColumns[0].setWidth(width); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/HostnameComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/HostnameComposite.java deleted file mode 100644 index 0804b1cb0..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/HostnameComposite.java +++ /dev/null @@ -1,133 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.wizard.page; - -import java.util.List; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.fieldassist.AutoCompleteField; -import org.eclipse.jface.fieldassist.ControlDecoration; -import org.eclipse.jface.fieldassist.FieldDecoration; -import org.eclipse.jface.fieldassist.FieldDecorationRegistry; -import org.eclipse.jface.fieldassist.TextContentAdapter; - -import org.eclipse.wst.server.ui.internal.Messages; -import org.eclipse.wst.server.ui.internal.SWTUtil; -import org.eclipse.wst.server.ui.internal.ServerUIPlugin; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.FocusEvent; -import org.eclipse.swt.events.FocusListener; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; -/** - * A composite used to select a hostname. - */ -public class HostnameComposite extends Composite { - private static final String LOCALHOST = "localhost"; - protected String host; - protected IHostnameSelectionListener listener; - - protected Text hostname; - - public interface IHostnameSelectionListener { - public void hostnameSelected(String host); - } - - /** - * Create a new HostnameComposite. - * - * @param parent a parent composite - * @param listener2 a hostname selection listener - */ - public HostnameComposite(Composite parent, IHostnameSelectionListener listener2) { - super(parent, SWT.NONE); - this.listener = listener2; - - createControl(); - } - - /** - * Creates the UI of the page. - */ - protected void createControl() { - GridLayout layout = new GridLayout(); - layout.horizontalSpacing = SWTUtil.convertHorizontalDLUsToPixels(this, 4); - layout.verticalSpacing = SWTUtil.convertVerticalDLUsToPixels(this, 4); - layout.marginWidth = 0; - layout.marginHeight = 0; - layout.numColumns = 3; - setLayout(layout); - //WorkbenchHelp.setHelp(this, ContextIds.SELECT_CLIENT_WIZARD); - - Label label = new Label(this, SWT.WRAP); - label.setText(Messages.hostname); - label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); - - hostname = new Text(this, SWT.BORDER); - hostname.setText(LOCALHOST); - final ControlDecoration hostnameDecoration = new ControlDecoration(hostname, SWT.TOP | SWT.LEAD); - GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER); - data.horizontalSpan = 2; - hostname.setLayoutData(data); - - hostname.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - hostnameChanged(hostname.getText()); - } - }); - - FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault(); - FieldDecoration fd = registry.getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL); - hostnameDecoration.setImage(fd.getImage()); - hostnameDecoration.setDescriptionText(fd.getDescription()); - - hostname.addFocusListener(new FocusListener() { - public void focusGained(FocusEvent e) { - hostnameDecoration.show(); - } - - public void focusLost(FocusEvent e) { - hostnameDecoration.hide(); - } - }); - - List<String> hosts = ServerUIPlugin.getPreferences().getHostnames(); - String[] hosts2 = hosts.toArray(new String[hosts.size()]); - new AutoCompleteField(hostname, new TextContentAdapter(), hosts2); - - Dialog.applyDialogFont(this); - } - - protected void hostnameChanged(String newHost) { - if (newHost == null) - return; - - if (newHost.equals(host)) - return; - - host = newHost; - listener.hostnameSelected(host); - } - - public String getHostname() { - return host; - } - - public void setHostname(String newHostname) { - hostname.setText(newHostname); - } -} diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/LicenseComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/LicenseComposite.java deleted file mode 100644 index 399acbd97..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/LicenseComposite.java +++ /dev/null @@ -1,135 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.wizard.page; - -import org.eclipse.jface.dialogs.Dialog; - -import org.eclipse.wst.server.core.TaskModel; -import org.eclipse.wst.server.ui.internal.Messages; -import org.eclipse.wst.server.ui.internal.wizard.fragment.LicenseWizardFragment; -import org.eclipse.wst.server.ui.wizard.IWizardHandle; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Layout; -import org.eclipse.swt.widgets.Text; -/** - * A composite used to accept a license. - */ -public class LicenseComposite extends Composite { - class LicenseLayout extends Layout { - private static final int INDENT = 15; - private static final int SPACING = 5; - - protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) { - if (wHint < 200) - wHint = 200; - if (hHint < 300) - hHint = 300; - return new Point(wHint, hHint); - } - - protected void layout(Composite composite, boolean flushCache) { - Control[] children = composite.getChildren(); - Point p1 = children[1].computeSize(SWT.DEFAULT, SWT.DEFAULT, flushCache); - Point p2 = children[2].computeSize(SWT.DEFAULT, SWT.DEFAULT, flushCache); - - Rectangle r = composite.getClientArea(); - - children[2].setBounds(r.x + INDENT, r.y + r.height - p2.y, r.width - INDENT, p2.y); - children[1].setBounds(r.x + INDENT, r.y + r.height - p2.y - p1.y - SPACING, r.width - INDENT, p1.y); - children[0].setBounds(r.x, r.y, r.width, r.height - p1.y - p2.y - SPACING * 3); - } - } - - protected TaskModel taskModel; - protected IWizardHandle wizard; - protected Text licenseText; - protected Button accept; - protected Button decline; - protected boolean accepted; - - /** - * Create a new LicenseComposite. - * - * @param parent a parent composite - * @param taskModel a task model - * @param wizard the wizard this composite is contained in - */ - public LicenseComposite(Composite parent, TaskModel taskModel, IWizardHandle wizard) { - super(parent, SWT.NONE); - this.taskModel = taskModel; - this.wizard = wizard; - - createControl(); - } - - /** - * Creates the UI of the page. - */ - protected void createControl() { - setLayout(new LicenseLayout()); - - licenseText = new Text(this, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.READ_ONLY | SWT.WRAP); - licenseText.setBackground(licenseText.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); - - accept = new Button(this, SWT.RADIO); - accept.setText(Messages.wizLicenseAccept); - accept.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - accepted = accept.getSelection(); - taskModel.putObject(LicenseWizardFragment.LICENSE_ACCEPT, new Boolean(accepted)); - wizard.update(); - } - }); - - decline = new Button(this, SWT.RADIO); - decline.setText(Messages.wizLicenseDecline); - - updateLicense(); - Dialog.applyDialogFont(this); - } - - public void updateLicense() { - String license = (String) taskModel.getObject(LicenseWizardFragment.LICENSE); - if (license == null) - license = LicenseWizardFragment.LICENSE_UNKNOWN; - - Object acc = taskModel.getObject(LicenseWizardFragment.LICENSE_ACCEPT); - if (acc == null) { - accepted = false; - accept.setSelection(false); - decline.setSelection(false); - } - - if (LicenseWizardFragment.LICENSE_NONE.equals(license)) { - licenseText.setText(Messages.wizLicenseNone); - accept.setEnabled(false); - decline.setEnabled(false); - accepted = true; - } else if (LicenseWizardFragment.LICENSE_UNKNOWN.equals(license)) { - licenseText.setText(Messages.wizLicenseNone); - accept.setEnabled(true); - decline.setEnabled(true); - } else { - licenseText.setText(license); - accept.setEnabled(true); - decline.setEnabled(true); - } - taskModel.putObject(LicenseWizardFragment.LICENSE_ACCEPT, new Boolean(accepted)); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/ModifyModulesComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/ModifyModulesComposite.java deleted file mode 100644 index 454ad8b51..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/ModifyModulesComposite.java +++ /dev/null @@ -1,946 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.wizard.page; - -import java.util.*; -import java.util.List; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IMessageProvider; -import org.eclipse.jface.viewers.*; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.server.core.*; -import org.eclipse.wst.server.ui.ServerUICore; -import org.eclipse.wst.server.ui.internal.*; -import org.eclipse.wst.server.ui.internal.view.servers.ModuleServer; -import org.eclipse.wst.server.ui.wizard.IWizardHandle; -/** - * A wizard page used to add and remove modules. - */ -public class ModifyModulesComposite extends Composite { - public static final String TASK_REFRESH_MODULES = "refresh-modules"; - - private static final String ROOT = "root"; - protected static Color color; - protected static Font font; - - protected IWizardHandle wizard; - - protected IServerAttributes server; - protected IRuntime runtime; - protected boolean runtimeDirty; - protected Object refreshModules; - protected boolean showPublishOption; - protected boolean publishImmediately; - - protected Map<ChildModuleMapKey, IModule[]> childModuleMap = new HashMap<ChildModuleMapKey, IModule[]>(); - protected Map<IModule, IModule[]> parentModuleMap = new HashMap<IModule, IModule[]>(); - - // original modules on the server - protected List<IModule> originalModules = new ArrayList<IModule>(); - - // modules available to be added to the server - protected List<IModule> modules = new ArrayList<IModule>(); - - // current modules on the server - protected List<IModule> deployed = new ArrayList<IModule>(); - - protected TreeViewer availableTreeViewer; - protected TreeViewer deployedTreeViewer; - - protected Button add, addAll; - protected Button remove, removeAll; - - protected TaskModel taskModel; - - // a module that must be kept on the server - protected IModule requiredModule; - protected boolean isComplete = true; - - // the parent modules of the above modules. at least one of these modules - // must be kept on the server - protected IModule[] requiredModules; - - protected Map<IModule, IStatus> errorMap; - - abstract class TreeContentProvider implements ITreeContentProvider { - public void dispose() { - // do nothing - } - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - // do nothing - } - - public Object[] getChildren(Object parentElement) { - ModuleServer ms = (ModuleServer) parentElement; - IModule[] parent = ms.module; - IModule[] children = childModuleMap.get(new ChildModuleMapKey(parent)); - - List<ModuleServer> list = new ArrayList<ModuleServer>(); - if (children != null) { - int size = children.length; - for (int i = 0; i < size; i++) { - IModule child = children[i]; - - parentModuleMap.put(child, parent); - - int size2 = parent.length; - IModule[] module2 = new IModule[size2 + 1]; - System.arraycopy(parent, 0, module2, 0, size2); - module2[size2] = child; - list.add(new ModuleServer(null, module2)); - } - } - return list.toArray(); - } - - public Object getParent(Object element) { - ModuleServer ms = (ModuleServer) element; - IModule[] child = ms.module; - IModule[] modules2 = parentModuleMap.get(child); - if (modules2 == null) - return null; - return new ModuleServer(null, modules2); - } - - public boolean hasChildren(Object element) { - ModuleServer ms = (ModuleServer) element; - IModule[] parent = ms.module; - IModule[] children = childModuleMap.get(new ChildModuleMapKey(parent)); - return (children != null && children.length > 0); - } - } - - class AvailableContentProvider extends TreeContentProvider { - public Object[] getElements(Object inputElement) { - List<ModuleServer> list = new ArrayList<ModuleServer>(); - Iterator iterator = modules.iterator(); - while (iterator.hasNext()) { - IModule module = (IModule) iterator.next(); - list.add(new ModuleServer(null, new IModule[] { module })); - } - return list.toArray(); - } - } - - class DeployedContentProvider extends TreeContentProvider { - public Object[] getElements(Object inputElement) { - List<ModuleServer> list = new ArrayList<ModuleServer>(); - Iterator iterator = deployed.iterator(); - while (iterator.hasNext()) { - IModule module = (IModule) iterator.next(); - list.add(new ModuleServer(null, new IModule[] { module })); - } - return list.toArray(); - } - } - - /** - * The key element for the child module map - * ChildMapModuleKey - */ - protected class ChildModuleMapKey { - protected IModule[] moduleTree; - - protected ChildModuleMapKey(IModule curModule) { - if (curModule != null) { - moduleTree = new IModule[] { curModule }; - } - } - - protected ChildModuleMapKey(IModule[] curModuleTree) { - moduleTree = curModuleTree; - } - - public boolean equals(Object obj) { - if (obj == this) // same object - return true; - - if (!(obj instanceof ChildModuleMapKey)) - return false; - - IModule[] curCompareModule = ((ChildModuleMapKey) obj).moduleTree; - if (curCompareModule == moduleTree) { - // the module tree is the same - return true; - } else if (moduleTree == null || curCompareModule == null || moduleTree.length != curCompareModule.length){ - return false; - } else { - // compare each module - for (int i = 0; i < curCompareModule.length; i++) { - if (!curCompareModule[i].equals(moduleTree[i])) - return false; - } - return true; - } - } - - public int hashCode() { - // force the same hash code on all the instances to makes sure the - // equals(Object) method is being used for comparing the objects - return 12345; - } - } - - /** - * Create a new ModifyModulesComposite. - * - * @param parent a parent composite - * @param wizard a wizard - * @param module the module that is being added - */ - public ModifyModulesComposite(Composite parent, IWizardHandle wizard, IModule module) { - super(parent, SWT.NONE); - this.wizard = wizard; - requiredModule = module; - - wizard.setTitle(Messages.wizModuleTitle); - wizard.setDescription(Messages.wizModuleDescription); - wizard.setImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_WIZBAN_SELECT_SERVER)); - - createControl(); - } - - /** - * Create a new ModifyModulesComposite. - * - * @param parent a parent composite - * @param wizard a wizard - * @param module the module that is being added - * @param showPublishOption show the publishing options - */ - public ModifyModulesComposite(Composite parent, IWizardHandle wizard, IModule module, boolean showPublishOption) { - super(parent, SWT.NONE); - this.wizard = wizard; - requiredModule = module; - this.showPublishOption = showPublishOption; - - wizard.setTitle(Messages.wizModuleTitle); - wizard.setDescription(Messages.wizModuleDescription); - wizard.setImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_WIZBAN_SELECT_SERVER)); - - createControl(); - } - - public void setServer(IServerAttributes server) { - if (isVisible()) - return; - - // see bug 185875, 205869 - if (refreshModules == taskModel.getObject(TASK_REFRESH_MODULES) && server == this.server) { - if (server == null) - return; - if (runtime == server.getRuntime()) { - if (runtime == null) - return; - if (runtime instanceof IRuntimeWorkingCopy) { - IRuntimeWorkingCopy wc = (IRuntimeWorkingCopy) runtime; - if (wc.isDirty() == runtimeDirty) - return; - } else - return; - } - } - - refreshModules = taskModel.getObject(TASK_REFRESH_MODULES); - this.server = server; - if (server == null) - runtime = null; - else - runtime = server.getRuntime(); - runtimeDirty = false; - if (runtime != null) { - if (runtime instanceof IRuntimeWorkingCopy) { - IRuntimeWorkingCopy wc = (IRuntimeWorkingCopy) runtime; - if (wc.isDirty()) - runtimeDirty = true; - } - } - - originalModules = new ArrayList<IModule>(); - deployed = new ArrayList<IModule>(); - modules = new ArrayList<IModule>(); - - childModuleMap = new HashMap<ChildModuleMapKey, IModule[]>(); - - if (server == null) - return; - - System.setProperty("J2EEcache", "" + Math.random()); - - // get currently deployed modules - IModule[] currentModules = server.getModules(); - if (currentModules != null) { - int size = currentModules.length; - for (int i = 0; i < size; i++) { - originalModules.add(currentModules[i]); - deployed.add(currentModules[i]); - } - } - - // add new module - requiredModules = null; - errorMap = new HashMap<IModule, IStatus>(); - if (requiredModule != null) { - try { - IModule[] parents = server.getRootModules(requiredModule, null); - if (parents != null && parents.length > 0) - requiredModules = parents; - else - requiredModules = new IModule[] { requiredModule }; - } catch (CoreException ce) { - // ignore - //errorMap.put(newModule, ce.getStatus()); - Trace.trace(Trace.INFO, "A possible server implementation error", ce); - } catch (Exception e) { - Trace.trace(Trace.WARNING, "Could not find root module", e); - } - } - if (requiredModules != null && !deployed.contains(requiredModules[0])) - deployed.add(requiredModules[0]); - - // get remaining modules - IModule[] modules2 = ServerUtil.getModules(server.getServerType().getRuntimeType().getModuleTypes()); - if (modules2 != null) { - int size = modules2.length; - for (int i = 0; i < size; i++) { - IModule module = modules2[i]; - if (!deployed.contains(module)) { - try { - IModule[] parents = server.getRootModules(module, null); - if (parents != null) { - int size2 = parents.length; - for (int j = 0; j < size2; j++) { - if (parents[j].equals(module)) { - IStatus status = server.canModifyModules(new IModule[] { module }, null, null); - if (status != null && !status.isOK()) - errorMap.put(module, status); - modules.add(module); - } - } - } - } catch (CoreException ce) { - errorMap.put(module, ce.getStatus()); - modules.add(module); - } - } - } - } - - // build child map - Iterator iterator = deployed.iterator(); - while (iterator.hasNext()) { - IModule module = (IModule) iterator.next(); - try { - IModule[] children = server.getChildModules(new IModule[] { module }, null); - if (children != null && children.length > 0) - childModuleMap.put(new ChildModuleMapKey(module), children); - } catch (Exception e) { - // ignore - } - } - - iterator = modules.iterator(); - while (iterator.hasNext()) { - IModule module = (IModule) iterator.next(); - try { - IModule[] children = server.getChildModules(new IModule[] { module }, null); - if (children != null && children.length > 0) - childModuleMap.put(new ChildModuleMapKey(module), children); - } catch (Exception e) { - // ignore - } - } - - // get children recursively one level - // put child elements into a different list to avoid concurrent modifications - Iterator<ChildModuleMapKey> iterator2 = childModuleMap.keySet().iterator(); - List<ChildModuleMapKey> list = new ArrayList<ChildModuleMapKey>(); - while (iterator2.hasNext()) { - list.add(iterator2.next()); - } - - iterator = list.iterator(); - while (iterator.hasNext()) { - ChildModuleMapKey key = (ChildModuleMapKey) iterator.next(); - IModule[] children0 = childModuleMap.get(key); - if (children0 != null) { - int size = children0.length; - for (int i = 0; i < size; i++) { - int size2 = key.moduleTree.length; - IModule[] module2 = new IModule[size2 + 1]; - System.arraycopy(key.moduleTree, 0, module2, 0, size2); - module2[size2] = children0[i]; - - try { - IModule[] children = server.getChildModules(module2, null); - if (children != null && children.length > 0) - childModuleMap.put(new ChildModuleMapKey(module2), children); - } catch (Exception e) { - // ignore - } - } - } - } - - System.setProperty("J2EEcache", ""); - - updateTaskModel(); - } - - public void setVisible(boolean b) { - if (b) { - Display.getDefault().syncExec(new Runnable() { - public void run() { - if (availableTreeViewer == null || availableTreeViewer.getControl().isDisposed()) - return; - try { // update trees if we can - availableTreeViewer.refresh(); - deployedTreeViewer.refresh(); - setEnablement(); - } catch (Exception e) { - // ignore - } - } - }); - } - super.setVisible(b); - } - - public void setTaskModel(TaskModel model) { - this.taskModel = model; - } - - /** - * Creates the UI of the page. - */ - protected void createControl() { - GridLayout layout = new GridLayout(); - layout.horizontalSpacing = SWTUtil.convertHorizontalDLUsToPixels(this, 4); - layout.verticalSpacing = SWTUtil.convertVerticalDLUsToPixels(this, 4); - layout.numColumns = 3; - setLayout(layout); - setFont(getParent().getFont()); - PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ContextIds.MODIFY_MODULES_COMPOSITE); - - Display display = getDisplay(); - color = display.getSystemColor(SWT.COLOR_DARK_GRAY); - FontData[] fd = getFont().getFontData(); - int size2 = fd.length; - for (int i = 0; i < size2; i++) - fd[i].setStyle(SWT.ITALIC); - font = new Font(display, fd); - addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - font.dispose(); - } - }); - - Label label = new Label(this, SWT.NONE); - GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING); - data.horizontalSpan = 3; - label.setLayoutData(data); - label.setText(Messages.wizModuleMessage); - - label = new Label(this, SWT.NONE); - label.setText(Messages.wizModuleAvailableList); - - label = new Label(this, SWT.NONE); - label.setText(""); - - label = new Label(this, SWT.NONE); - label.setText(Messages.wizModuleDeployedList); - - Tree availableTree = new Tree(this, SWT.BORDER | SWT.MULTI); - data = new GridData(GridData.FILL_BOTH); - data.heightHint = 200; - data.widthHint = 150; - availableTree.setLayoutData(data); - - availableTreeViewer = new TreeViewer(availableTree); - ILabelProvider labelProvider = ServerUICore.getLabelProvider(); - labelProvider.addListener(new ILabelProviderListener() { - public void labelProviderChanged(LabelProviderChangedEvent event) { - Object[] obj = event.getElements(); - if (obj == null) - availableTreeViewer.refresh(true); - else { - obj = ServerUIPlugin.adaptLabelChangeObjects(obj); - int size = obj.length; - for (int i = 0; i < size; i++) - availableTreeViewer.refresh(obj[i], true); - } - } - }); - availableTreeViewer.setLabelProvider(labelProvider); - availableTreeViewer.setContentProvider(new AvailableContentProvider()); - availableTreeViewer.setComparator(new ViewerComparator() { - public int compare(Viewer viewer, Object e1, Object e2) { - if (e1 instanceof ModuleServer && e2 instanceof ModuleServer) { - ModuleServer s1 = (ModuleServer) e1; - ModuleServer s2 = (ModuleServer) e2; - return (s1.module[s1.module.length - 1].getName().compareToIgnoreCase(s2.module[s2.module.length - 1].getName())); - } - - return super.compare(viewer, e1, e2); - } - }); - availableTreeViewer.setInput(ROOT); - - availableTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - setEnablement(); - } - }); - availableTreeViewer.addDoubleClickListener(new IDoubleClickListener() { - public void doubleClick(DoubleClickEvent event) { - setEnablement(); - if (add.isEnabled()) - add(false); - } - }); - - // slosh buttons - Composite comp = new Composite(this, SWT.NONE); - data = new GridData(GridData.FILL_BOTH); - data.widthHint = 120; - comp.setLayoutData(data); - - layout = new GridLayout(); - layout.marginWidth = 5; - layout.marginHeight = 25; - layout.verticalSpacing = 20; - comp.setLayout(layout); - - add = new Button(comp, SWT.PUSH); - add.setText(Messages.wizModuleAdd); - add.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - add.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - add(false); - } - }); - - remove = new Button(comp, SWT.PUSH); - remove.setText(Messages.wizModuleRemove); - remove.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - remove.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - remove(false); - } - }); - - label = new Label(comp, SWT.NONE); - label.setText(""); - - addAll = new Button(comp, SWT.PUSH); - addAll.setText(Messages.wizModuleAddAll); - addAll.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - addAll.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - add(true); - } - }); - - removeAll = new Button(comp, SWT.PUSH); - removeAll.setText(Messages.wizModuleRemoveAll); - removeAll.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - removeAll.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - remove(true); - } - }); - - Tree deployedTree = new Tree(this, SWT.BORDER | SWT.MULTI); - data = new GridData(GridData.FILL_BOTH); - data.widthHint = 150; - deployedTree.setLayoutData(data); - - deployedTreeViewer = new TreeViewer(deployedTree) { - public void doUpdateItem(Widget widget, Object element, boolean fullMap) { - if (widget instanceof TreeItem && color != null) { - TreeItem item = (TreeItem) widget; - if (element instanceof ModuleServer) { - ModuleServer ms = (ModuleServer) element; - IModule m = ms.module[ms.module.length-1]; - if (m.isExternal()) - item.setForeground(color); - else - item.setForeground(null); - if (!(server instanceof IServer) || ((IServer)server).getModulePublishState(ms.module) != IServer.PUBLISH_STATE_NONE) - item.setFont(font); - else - item.setFont(null); - } - } - super.doUpdateItem(widget, element, fullMap); - } - }; - labelProvider = ServerUICore.getLabelProvider(); - labelProvider.addListener(new ILabelProviderListener() { - public void labelProviderChanged(LabelProviderChangedEvent event) { - Object[] obj = event.getElements(); - if (obj == null) - deployedTreeViewer.refresh(true); - else { - int size = obj.length; - for (int i = 0; i < size; i++) - deployedTreeViewer.refresh(obj[i], true); - } - } - }); - deployedTreeViewer.setLabelProvider(labelProvider); - deployedTreeViewer.setContentProvider(new DeployedContentProvider()); - deployedTreeViewer.setComparator(new ViewerComparator() { - public int compare(Viewer viewer, Object e1, Object e2) { - if (e1 instanceof ModuleServer && e2 instanceof ModuleServer) { - ModuleServer s1 = (ModuleServer) e1; - ModuleServer s2 = (ModuleServer) e2; - return (s1.module[s1.module.length - 1].getName().compareToIgnoreCase(s2.module[s2.module.length - 1].getName())); - } - - return super.compare(viewer, e1, e2); - } - }); - deployedTreeViewer.setInput(ROOT); - - deployedTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - setEnablement(); - } - }); - deployedTreeViewer.addDoubleClickListener(new IDoubleClickListener() { - public void doubleClick(DoubleClickEvent event) { - setEnablement(); - if (remove.isEnabled()) - remove(false); - } - }); - - if (showPublishOption) { - final Button publish = new Button(this, SWT.CHECK); - publish.setText(Messages.wizModulePublishImmediately); - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 3; - publish.setLayoutData(data); - - publishImmediately = ServerUIPlugin.getPreferences().getPublishOnAddRemoveModule(); - publish.setSelection(publishImmediately); - publish.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - publishImmediately = publish.getSelection(); - } - }); - } - - setEnablement(); - availableTree.setFocus(); - - Dialog.applyDialogFont(this); - } - - protected ModuleServer[] getAvailableSelection() { - IStructuredSelection sel = (IStructuredSelection) availableTreeViewer.getSelection(); - if (sel.isEmpty()) - return new ModuleServer[0]; - - ModuleServer [] mss = new ModuleServer[sel.size()]; - System.arraycopy(sel.toArray(), 0, mss, 0, sel.size()); - return mss; - } - - protected ModuleServer[] getDeployedSelection() { - IStructuredSelection sel = (IStructuredSelection) deployedTreeViewer.getSelection(); - if (sel.isEmpty()) - return new ModuleServer[0]; - - ModuleServer [] mss = new ModuleServer[sel.size()]; - System.arraycopy(sel.toArray(), 0, mss, 0, sel.size()); - return mss; - } - - protected static IModule getModule(ModuleServer ms) { - if (ms == null) - return null; - IModule[] modules2 = ms.module; - return modules2[modules2.length - 1]; - } - - protected static IModule[] getModules(ModuleServer[] ms) { - if (ms == null) - return null; - IModule[] modules2 = new IModule[ms.length]; - for (int i = 0; i < ms.length; i++) - modules2[i] = getModule(ms[i]); - - return modules2; - } - - protected void setEnablement() { - wizard.setMessage(null, IMessageProvider.NONE); - - int count = 0; - if (requiredModules != null) { - // count how many of requiredModules are deployed - int size = requiredModules.length; - for (int i = 0; i < size; i++) { - if (deployed.contains(requiredModules[i])) - count++; - } - } - - // give error if there are more than one possible required modules and none are - // added to the server - isComplete = true; - if (requiredModules != null && requiredModules.length > 1 && count == 0) { - String s = ""; - int size = requiredModules.length; - for (int i = 0; i < size; i++) { - if (i > 0) - s += " | "; - s += requiredModules[i].getName(); - } - wizard.setMessage(NLS.bind(Messages.wizModuleRequiredModules, s), IMessageProvider.ERROR); - isComplete = false; - } - - // selection specific messages - ModuleServer[] ms = getAvailableSelection(); - if (ms == null || ms.length == 0) { - add.setEnabled(false); - } else { - boolean enabled = false; - // iterate through selection, if we find at least ONE module that can't be added, exit the loop - for (int i = 0; i < ms.length; i++) { - IModule module = getModule(ms[i]); - if (module != null) { - try { - IStatus status = errorMap.get(module); - if (modules.contains(module)) { - if (status == null ) - enabled = true; - else if (status.getSeverity() == IStatus.ERROR) { - // this module can't be added because has errors, exit the loop - enabled = false; - wizard.setMessage(status.getMessage(), IMessageProvider.ERROR); - break; - } else if (status.getSeverity() == IStatus.WARNING){ - enabled = true; - wizard.setMessage(status.getMessage(), IMessageProvider.WARNING); - } - else if (status.getSeverity() == IStatus.INFO){ - enabled = true; - wizard.setMessage(status.getMessage(), IMessageProvider.INFORMATION); - } - } - else{ - // at least ONE module from the selection can't be added, exit the loop - enabled = false; - break; - } - } catch (Exception e) { - Trace.trace(Trace.INFO,"Unable to handle error map for module:" + module); - } - } - } - add.setEnabled(enabled); - } - addAll.setEnabled(modules.size() > 0); - - ms = getDeployedSelection(); - if (ms == null || ms.length == 0) { - remove.setEnabled(false); - } else { - boolean enabled = false; - // iterate through selection, if we find at least ONE module that can't be added, exit the loop - for (int i = 0; i < ms.length; i++) { - IModule module = getModule(ms[i]); - if (module != null && deployed.contains(module)) { - // provide error about removing required single module - // required modules can't be removed - if (requiredModules != null){ - if (requiredModules.length == 1 && requiredModules[0].equals(module)) { - // this is a required module and can't be removed, exit the loop - wizard.setMessage(NLS.bind(Messages.wizModuleRequiredModule, module.getName()), IMessageProvider.ERROR); - enabled = false; - break; - } - } - else - enabled = true; - } - else{ - // this module is not found in the 'deployed' array, the module might be a child - // at least ONE module from the selection can't be removed, exit the loop - enabled = false; - break; - } - } - remove.setEnabled(enabled); - } - - if (requiredModules == null) - removeAll.setEnabled(deployed.size() > 0); - else - removeAll.setEnabled(deployed.size() > 1); - } - - protected void add(boolean all) { - if (all) { - IModule[] modules2 = new IModule[modules.size()]; - modules.toArray(modules2); - moveAll(modules2, true); - } else - moveAll(getModules(getAvailableSelection()), true); - updateTaskModel(); - } - - protected void remove(boolean all) { - if (all) { - // pick one of the required modules to keep - IModule keep = null; - if (requiredModules != null) { - int size2 = requiredModules.length; - for (int i = 0; i < size2; i++) { - if (keep == null && deployed.contains(requiredModules[i])) - keep = requiredModules[i]; - } - } - - List<IModule> list = new ArrayList<IModule>(); - list.addAll(deployed); - list.remove(keep); - - IModule[] modules2 = new IModule[list.size()]; - list.toArray(modules2); - - moveAll(modules2, false); - } else - moveAll(getModules(getDeployedSelection()), false); - updateTaskModel(); - } - - protected void moveAll(IModule[] mods, boolean add2) { - int size = mods.length; - List<IModule> list = new ArrayList<IModule>(); - for (int i = 0; i < size; i++) { - IStatus status = errorMap.get(mods[i]); - - if (status == null && !list.contains(mods[i])) - list.add(mods[i]); - } - - Iterator iterator = list.iterator(); - while (iterator.hasNext()) { - IModule module = (IModule) iterator.next(); - ModuleServer ms = new ModuleServer(null, new IModule[] { module }); - if (add2) { - modules.remove(module); - deployed.add(module); - availableTreeViewer.remove(ms); - deployedTreeViewer.add(ROOT, ms); - } else { - modules.add(module); - deployed.remove(module); - availableTreeViewer.add(ROOT, ms); - deployedTreeViewer.remove(ms); - } - } - - setEnablement(); - } - - protected void updateTaskModel() { - if (taskModel == null) - return; - - taskModel.putObject(TaskModel.TASK_MODULES, getModuleMap()); - wizard.update(); - } - - public List<IModule> getModulesToRemove() { - List<IModule> list = new ArrayList<IModule>(); - Iterator iterator = originalModules.iterator(); - while (iterator.hasNext()) { - IModule module = (IModule) iterator.next(); - if (!deployed.contains(module)) - list.add(module); - } - return list; - } - - public List<IModule> getModulesToAdd() { - List<IModule> list = new ArrayList<IModule>(); - Iterator iterator = deployed.iterator(); - while (iterator.hasNext()) { - IModule module = (IModule) iterator.next(); - if (!originalModules.contains(module)) - list.add(module); - } - return list; - } - - private void addChildMap(List<IModule[]> map, IModule[] parents, IModule[] children) { - if (children == null) - return; - - int size = children.length; - for (int i = 0; i < size; i++) { - IModule module = children[i]; - - int size2 = parents.length; - IModule[] modules2 = new IModule[size2 + 1]; - System.arraycopy(parents, 0, modules2, 0, size2); - modules2[size2] = module; - map.add(modules2); - - IModule[] children2 = childModuleMap.get(new ChildModuleMapKey(module)); - if (children2 != null) - addChildMap(map, modules2, children2); - } - } - - public List getModuleMap() { - final List<IModule[]> map = new ArrayList<IModule[]>(); - - Iterator iterator = deployed.iterator(); - while (iterator.hasNext()) { - IModule module = (IModule) iterator.next(); - IModule[] moduleTree = new IModule[] { module }; - map.add(moduleTree); - IModule[] children = childModuleMap.get(new ChildModuleMapKey(module)); - if (children != null) - addChildMap(map, moduleTree, children); - } - - return map; - } - - public boolean isComplete() { - return isComplete; - } - - public boolean shouldPublishImmediately() { - return publishImmediately; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewDetectServerComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewDetectServerComposite.java deleted file mode 100644 index 93dddab53..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewDetectServerComposite.java +++ /dev/null @@ -1,223 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.wizard.page; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jface.viewers.*; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.IServerAttributes; -import org.eclipse.wst.server.core.IServerWorkingCopy; -import org.eclipse.wst.server.ui.internal.SWTUtil; -import org.eclipse.wst.server.ui.internal.viewers.BaseContentProvider; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -/** - * A wizard page used to detect a server. - */ -public class NewDetectServerComposite extends Composite { - protected String host; - - protected IServerWorkingCopy server; - protected IServerSelectionListener listener; - - protected List servers = new ArrayList(); - - protected Button detect; - protected Table table; - protected TableViewer tableViewer; - protected Label hostLabel; - - public interface IServerSelectionListener { - public void serverSelected(IServerAttributes server); - } - - public class ServerContentProvider extends BaseContentProvider { - public Object[] getElements(Object inputElement) { - return servers.toArray(); - } - } - - public class ServerLabelProvider implements ITableLabelProvider { - public void addListener(ILabelProviderListener listener2) { - // do nothing - } - - public void dispose() { - // do nothing - } - - public Image getColumnImage(Object element, int columnIndex) { - return null; - } - - public String getColumnText(Object element, int columnIndex) { - IServer server2 = (IServer) element; - if (columnIndex == 0) - return server2.getName(); - else if (columnIndex == 0) - return "n/a"; - return null; - } - - public boolean isLabelProperty(Object element, String property) { - return false; - } - - public void removeListener(ILabelProviderListener listener2) { - // do nothing - } - } - - /** - * Create a new NewDetectServerComposite. - * - * @param parent a parent composite - * @param listener2 a server selection listener - */ - public NewDetectServerComposite(Composite parent, IServerSelectionListener listener2) { - super(parent, SWT.NONE); - this.listener = listener2; - - createControl(); - } - - protected Label createHeadingLabel(Composite parent, String text, int span) { - Label label = createLabel(parent, text, span, true, false); - label.setFont(JFaceResources.getBannerFont()); - return label; - } - - protected Label createLabel(Composite parent, String text, int span, boolean alignTop, boolean indent) { - Label label = new Label(parent, SWT.WRAP); - label.setText(text); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER); - if (alignTop) - data.verticalAlignment = GridData.BEGINNING; - data.horizontalSpan = span; - if (indent) - data.horizontalIndent = 10; - label.setLayoutData(data); - return label; - } - - /** - * Creates the UI of the page. - */ - protected void createControl() { - GridLayout layout = new GridLayout(); - layout.horizontalSpacing = SWTUtil.convertHorizontalDLUsToPixels(this, 4); - layout.verticalSpacing = SWTUtil.convertVerticalDLUsToPixels(this, 4); - layout.marginWidth = 0; - layout.marginHeight = 0; - layout.numColumns = 2; - setLayout(layout); - //WorkbenchHelp.setHelp(this, ContextIds.SELECT_CLIENT_WIZARD); - - createHeadingLabel(this, "Select the Server", 2); - - table = new Table(this, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE); - GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL); - data.heightHint = 60; - data.widthHint = 50; - data.horizontalSpan = 2; - data.horizontalIndent = 10; - table.setLayoutData(data); - - TableLayout tableLayout = new TableLayout(); - table.setHeaderVisible(true); - - tableLayout.addColumnData(new ColumnWeightData(50, 100, true)); - TableColumn col = new TableColumn(table, SWT.NONE); - col.setText("Server"); - - tableLayout.addColumnData(new ColumnWeightData(40, 80, true)); - TableColumn col2 = new TableColumn(table, SWT.NONE); - col2.setText("Status"); - - table.setLayout(tableLayout); - - tableViewer = new TableViewer(table); - tableViewer.setContentProvider(new ServerContentProvider()); - tableViewer.setLabelProvider(new ServerLabelProvider()); - tableViewer.setColumnProperties(new String[] {"name", "status"}); - tableViewer.setInput("root"); - - String date = "<now>"; - hostLabel = createLabel(this, "Last detected servers on " + host + " at " + date + ":", 1, false, true); - - detect = SWTUtil.createButton(this, "Refresh"); - detect.setEnabled(false); - data = (GridData) detect.getLayoutData(); - data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_END; - - // listeners - detect.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - // do nothing - } - }); - - tableViewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - IStructuredSelection sel = (IStructuredSelection) event.getSelection(); - Object obj = sel.getFirstElement(); - IServerWorkingCopy newServer = null; - if (obj instanceof IServerWorkingCopy) - newServer = (IServerWorkingCopy) obj; - - if ((newServer == null && server != null) || (newServer != null && !newServer.equals(server))) { - server = newServer; - listener.serverSelected(server); - } - } - }); - - setHost(null); - - Dialog.applyDialogFont(this); - } - - public String getHost() { - return host; - } - - public void setHost(String host) { - this.host = host; - servers = new ArrayList(); - tableViewer.refresh(); - if (host != null) { - hostLabel.setText("Detected servers on " + host + ":"); - detect.setEnabled(true); - table.setEnabled(true); - } else { - hostLabel.setText("No host selected"); - detect.setEnabled(false); - table.setEnabled(false); - } - } - - public IServerWorkingCopy getServer() { - return server; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewManualServerComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewManualServerComposite.java deleted file mode 100644 index bef11fa9e..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewManualServerComposite.java +++ /dev/null @@ -1,604 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2009 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.server.ui.internal.wizard.page; - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.ToolBarManager; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IMessageProvider; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.preference.PreferenceDialog; -import org.eclipse.jface.window.Window; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Link; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.PreferencesUtil; -import org.eclipse.ui.help.IWorkbenchHelpSystem; -import org.eclipse.wst.server.core.*; -import org.eclipse.wst.server.core.internal.ServerWorkingCopy; -import org.eclipse.wst.server.core.util.SocketUtil; -import org.eclipse.wst.server.ui.internal.*; -import org.eclipse.wst.server.ui.internal.viewers.ServerTypeComposite; -import org.eclipse.wst.server.ui.internal.wizard.TaskWizard; -import org.eclipse.wst.server.ui.internal.wizard.WizardTaskUtil; -import org.eclipse.wst.server.ui.wizard.WizardFragment; -/** - * Wizard page used to create a server and configuration at the same time. - */ -public class NewManualServerComposite extends Composite { - public interface ServerSelectionListener { - public void serverSelected(IServerAttributes server); - public void runtimeSelected(IRuntime runtime); - } - - public interface IWizardHandle2 { - public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InterruptedException, InvocationTargetException; - public void update(); - public void setMessage(String newMessage, int newType); - } - protected IWizardHandle2 wizard; - - protected ServerTypeComposite serverTypeComposite; - - protected Label runtimeLabel; - protected Combo runtimeCombo; - protected Link configureRuntimes; - protected Link addRuntime; - protected IRuntime[] runtimes; - protected IRuntime newRuntime; - - protected Text serverName; - protected String defaultServerName; - protected boolean serverNameModified; - protected boolean updatingServerName; - protected ToolBarManager serverNameToolBar; - - protected IRuntime runtime; - protected IServerWorkingCopy server; - protected ServerSelectionListener listener; - - protected String host; - - protected IModuleType moduleType; - protected IModule module; - protected String serverTypeId; - protected boolean includeIncompatible; - - protected ServerCreationCache cache = new ServerCreationCache(); - - /** - * Creates a new server and server configuration. If the initial - * resource selection contains exactly one container resource then it will be - * used as the default container resource. - * - * @param parent a parent composite - * @param wizard a wizard handle - * @param moduleType a module type - * @param module an optional module - * @param serverTypeId a server type id, or null - * @param includeIncompatible true to include incompatible servers that support similar module types - * @param listener a server selection listener - */ - public NewManualServerComposite(Composite parent, IWizardHandle2 wizard, IModuleType moduleType, IModule module, String serverTypeId, boolean includeIncompatible, ServerSelectionListener listener) { - super(parent, SWT.NONE); - this.wizard = wizard; - this.listener = listener; - - this.moduleType = moduleType; - this.module = module; - this.serverTypeId = serverTypeId; - this.includeIncompatible = includeIncompatible; - - createControl(); - wizard.setMessage("", IMessageProvider.ERROR); //$NON-NLS-1$ - } - - /** - * Returns this page's initial visual components. - */ - protected void createControl() { - // top level group - GridLayout layout = new GridLayout(); - layout.numColumns = 3; - layout.horizontalSpacing = SWTUtil.convertHorizontalDLUsToPixels(this, 4); - layout.verticalSpacing = SWTUtil.convertVerticalDLUsToPixels(this, 4); - layout.marginWidth = 0; - layout.marginHeight = 0; - setLayout(layout); - - this.setFont(getParent().getFont()); - IWorkbenchHelpSystem whs = PlatformUI.getWorkbench().getHelpSystem(); - whs.setHelp(this, ContextIds.NEW_SERVER_WIZARD); - - serverTypeComposite = new ServerTypeComposite(this, moduleType, serverTypeId, new ServerTypeComposite.ServerTypeSelectionListener() { - public void serverTypeSelected(IServerType type2) { - handleTypeSelection(type2); - //WizardUtil.defaultSelect(parent, CreateServerWizardPage.this); - } - }); - serverTypeComposite.setIncludeIncompatibleVersions(includeIncompatible); - GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL); - data.horizontalSpan = 3; - serverTypeComposite.setLayoutData(data); - whs.setHelp(serverTypeComposite, ContextIds.NEW_SERVER_TYPE); - - Label serverNameLabel = new Label(this, SWT.NONE); - serverNameLabel.setText(Messages.serverName); - - serverName = new Text(this, SWT.SINGLE | SWT.BORDER | SWT.CANCEL); - data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - if ((serverName.getStyle() & SWT.CANCEL) != 0) - data.horizontalSpan = 2; - serverName.setLayoutData(data); - - if (server != null) - serverName.setText(server.getName()); - - serverName.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - if (updatingServerName) - return; - - String name = serverName.getText(); - if (server != null) { - server.setName(name); - IRuntime runtime2 = server.getRuntime(); - if (runtime2 != null && runtime2 instanceof IRuntimeWorkingCopy) { - IRuntimeWorkingCopy rwc = (IRuntimeWorkingCopy) runtime2; - rwc.setName(name); - } - } - - if (serverNameModified) - return; - - serverNameModified = true; - if (serverNameToolBar != null) - serverNameToolBar.getControl().setVisible(true); - } - }); - - if ((serverName.getStyle() & SWT.CANCEL) == 0) { - serverNameToolBar = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL); - serverNameToolBar.createControl(this); - - IAction resetDefaultAction = new Action("", IAction.AS_PUSH_BUTTON) {//$NON-NLS-1$ - public void run() { - ((ServerWorkingCopy)server).setDefaults(null); - serverName.setText(server.getName()); - serverNameModified = false; - if (serverNameToolBar != null) - serverNameToolBar.getControl().setVisible(false); - } - }; - - resetDefaultAction.setToolTipText(Messages.serverNameDefault); - resetDefaultAction.setImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_ETOOL_RESET_DEFAULT)); - resetDefaultAction.setDisabledImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_DTOOL_RESET_DEFAULT)); - - serverNameToolBar.add(resetDefaultAction); - serverNameToolBar.update(false); - serverNameToolBar.getControl().setVisible(false); - } - - runtimeLabel = new Label(this, SWT.NONE); - runtimeLabel.setText(Messages.wizNewServerRuntime); - - runtimeCombo = new Combo(this, SWT.READ_ONLY); - runtimeCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - runtimeCombo.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - try { - setRuntime(runtimes[runtimeCombo.getSelectionIndex()]); - } catch (Exception ex) { - // ignore - } - } - public void widgetDefaultSelected(SelectionEvent e) { - widgetSelected(e); - } - }); - - addRuntime = new Link(this, SWT.NONE); - addRuntime.setText("<a>" + Messages.addRuntime + "</a>"); - addRuntime.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); - addRuntime.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - IServerType serverType = serverTypeComposite.getSelectedServerType(); - showRuntimeWizard(serverType); - } - }); - - configureRuntimes = new Link(this, SWT.NONE); - configureRuntimes.setText("<a>" + Messages.configureRuntimes + "</a>"); - data = new GridData(GridData.HORIZONTAL_ALIGN_END); - data.horizontalSpan = 3; - configureRuntimes.setLayoutData(data); - configureRuntimes.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - if (showPreferencePage()) { - runtime = null; - IServerType serverType = serverTypeComposite.getSelectedServerType(); - updateRuntimeCombo(serverType); - } - } - }); - Dialog.applyDialogFont(this); - } - - protected boolean showPreferencePage() { - String id = "org.eclipse.wst.server.ui.preferencePage"; - String id2 = "org.eclipse.wst.server.ui.runtime.preferencePage"; - final PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getShell(), id2, new String[] { id, id2 }, null); - return (dialog.open() == Window.OK); - } - - protected int showRuntimeWizard(IServerType serverType) { - WizardFragment fragment = null; - TaskModel taskModel = new TaskModel(); - IRuntimeType runtimeType = serverType.getRuntimeType(); - final WizardFragment fragment2 = ServerUIPlugin.getWizardFragment(runtimeType.getId()); - if (fragment2 == null) - return Window.CANCEL; - - try { - IRuntimeWorkingCopy runtimeWorkingCopy = runtimeType.createRuntime(null, null); - taskModel.putObject(TaskModel.TASK_RUNTIME, runtimeWorkingCopy); - } catch (CoreException ce) { - Trace.trace(Trace.SEVERE, "Error creating runtime", ce); - return Window.CANCEL; - } - fragment = new WizardFragment() { - protected void createChildFragments(List<WizardFragment> list) { - list.add(fragment2); - list.add(WizardTaskUtil.SaveRuntimeFragment); - } - }; - TaskWizard wizard2 = new TaskWizard(Messages.wizNewRuntimeWizardTitle, fragment, taskModel); - wizard2.setForcePreviousAndNextButtons(true); - WizardDialog dialog = new WizardDialog(getShell(), wizard2); - int returnValue = dialog.open(); - if (returnValue != Window.CANCEL) { - updateRuntimeCombo(serverType); - IRuntime rt = (IRuntime)taskModel.getObject(TaskModel.TASK_RUNTIME); - if (rt != null && rt.getName() != null && runtimeCombo.indexOf(rt.getName()) != -1) { - setRuntime(rt); - runtimeCombo.select(runtimeCombo.indexOf(rt.getName())); - } - } - return returnValue; - } - - public void setHost(String host) { - this.host = host; - if (serverTypeComposite == null) - return; - - boolean changed = false; - if (host == null) { - changed = serverTypeComposite.setHost(true); - } else if (SocketUtil.isLocalhost(host)) - changed = serverTypeComposite.setHost(true); - else - changed = serverTypeComposite.setHost(false); - - if (changed) - handleTypeSelection(serverTypeComposite.getSelectedServerType()); - else if (server != null) { - server.setHost(host); - if (!serverNameModified) { - updatingServerName = true; - ((ServerWorkingCopy)server).setDefaults(null); - serverName.setText(server.getName()); - updatingServerName = false; - } - } - } - - /** - * Load a server of the given type. - */ - protected void loadServerImpl(IServerType serverType) { - server = null; - - if (serverType == null) - return; - - boolean isLocalhost = SocketUtil.isLocalhost(host); - - server = cache.getCachedServer(serverType, isLocalhost); - if (server != null) { - server.setHost(host); - ((ServerWorkingCopy)server).setDefaults(null); - runtime = server.getRuntime(); - listener.runtimeSelected(runtime); - return; - } - - try { - // try to create runtime first - IRuntime run = null; - if (serverType.hasRuntime()) { - runtime = null; - updateRuntimes(serverType, isLocalhost); - run = getDefaultRuntime(); - } - server = cache.createServer(serverType, run, isLocalhost, null); - if (server != null) { - server.setHost(host); - - if (serverType.hasRuntime() && server.getRuntime() == null) { - runtime = null; - updateRuntimes(serverType, isLocalhost); - setRuntime(getDefaultRuntime()); - - if (server.getServerType() != null && server.getServerType().hasServerConfiguration() && !runtime.getLocation().isEmpty()) - ((ServerWorkingCopy)server).importRuntimeConfiguration(runtime, null); - } - - ((ServerWorkingCopy)server).setDefaults(null); - } - } catch (CoreException ce) { - Trace.trace(Trace.SEVERE, "Error creating server", ce); - server = null; - runtime = null; - wizard.setMessage(ce.getLocalizedMessage(), IMessageProvider.ERROR); - } - - if (server == null) - wizard.setMessage(Messages.wizErrorServerCreationError, IMessageProvider.ERROR); - } - - /** - * Pick the first non-stub runtime first. Otherwise, just pick the first runtime. - * - * @return the default runtime - */ - protected IRuntime getDefaultRuntime() { - if (runtimes == null || runtimes.length == 0) - return null; - - if (runtimes != null) { - int size = runtimes.length; - for (int i = 0; i < size; i++) { - if (!runtimes[i].isStub()) - return runtimes[i]; - } - } - return runtimes[0]; - } - - protected void updateRuntimes(IServerType serverType, boolean isLocalhost) { - if (serverType == null) - return; - - IRuntimeType runtimeType = serverType.getRuntimeType(); - runtimes = ServerUIPlugin.getRuntimes(runtimeType); - newRuntime = null; - - if (runtimes != null) { - List<IRuntime> runtimes2 = new ArrayList<IRuntime>(); - int size = runtimes.length; - for (int i = 0; i < size; i++) { - IRuntime runtime2 = runtimes[i]; - if (isLocalhost || !runtime2.isStub()) - runtimes2.add(runtime2); - } - runtimes = new IRuntime[runtimes2.size()]; - runtimes2.toArray(runtimes); - if (runtimes.length > 0) - return; - } - - // create a new runtime - try { - IRuntimeWorkingCopy runtimeWC = runtimeType.createRuntime(null, null); - runtimes = new IRuntime[1]; - runtimes[0] = runtimeWC; - newRuntime = runtimeWC; - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Couldn't create runtime", e); //$NON-NLS-1$ - } - } - - protected void updateRuntimeCombo(IServerType serverType) { - if (serverType == null || !serverType.hasRuntime() || server == null) { - if (runtimeLabel != null) { - runtimeLabel.setEnabled(false); - runtimeCombo.setItems(new String[0]); - runtimeCombo.setEnabled(false); - runtimeLabel.setVisible(false); - runtimeCombo.setVisible(false); - configureRuntimes.setEnabled(false); - configureRuntimes.setVisible(false); - addRuntime.setEnabled(false); - addRuntime.setVisible(false); - } - runtimes = new IRuntime[0]; - setRuntime(null); - return; - } - - updateRuntimes(serverType, !SocketUtil.isLocalhost(server.getHost())); - - int size = runtimes.length; - String[] items = new String[size]; - for (int i = 0; i < size; i++) { - if (runtimes[i].equals(newRuntime)) - items[i] = Messages.wizNewServerRuntimeCreate; - else - items[i] = runtimes[i].getName(); - } - - if (runtime == null) - setRuntime(getDefaultRuntime()); - - if (runtimeCombo != null) { - runtimeCombo.setItems(items); - if (runtimes.length > 0) { - int sel = -1; - for (int i = 0; i < size; i++) { - if (runtimes[i].equals(runtime)) - sel = i; - } - if (sel < 0) { - sel = 0; - } - - runtimeCombo.select(sel); - setRuntime(runtimes[0]); - } - - IRuntimeType runtimeType = serverType.getRuntimeType(); - boolean showRuntime = ServerUIPlugin.getRuntimes(runtimeType).length >=1; - runtimeCombo.setEnabled(showRuntime); - runtimeLabel.setEnabled(showRuntime); - configureRuntimes.setEnabled(showRuntime); - addRuntime.setEnabled(showRuntime); - runtimeLabel.setVisible(showRuntime); - runtimeCombo.setVisible(showRuntime); - configureRuntimes.setVisible(showRuntime); - addRuntime.setVisible(showRuntime); - } - } - - protected void setRuntime(IRuntime runtime2) { - runtime = runtime2; - if (server != null) { - server.setRuntime(runtime); - ((ServerWorkingCopy)server).setDefaults(null); - if (!serverNameModified) { - updatingServerName = true; - serverName.setText(server.getName()); - updatingServerName = false; - } - } - listener.runtimeSelected(runtime); - } - - /** - * Handle the server type selection. - */ - protected void handleTypeSelection(IServerType serverType) { - boolean wrong = false; - if (serverType != null && moduleType != null) { - IRuntimeType runtimeType = serverType.getRuntimeType(); - if (!ServerUtil.isSupportedModule(runtimeType.getModuleTypes(), moduleType)) { - serverType = null; - wrong = true; - //wizard.setMessage("Not the right spec level2", IMessageProvider.ERROR); - } - } - - if (wrong) { - server = null; - runtime = null; - wizard.setMessage(NLS.bind(Messages.errorVersionLevel, new Object[] { moduleType.getName(), moduleType.getVersion() }), IMessageProvider.ERROR); - } else if (serverType == null) { - server = null; - runtime = null; - wizard.setMessage("", IMessageProvider.ERROR); //$NON-NLS-1$ - } else { - wizard.setMessage(null, IMessageProvider.NONE); - loadServerImpl(serverType); - if (server != null && module != null) { - IStatus status = NewServerComposite.isSupportedModule(server, module); - if (status != null) { - if (status.getSeverity() == IStatus.ERROR) - wizard.setMessage(status.getMessage(), IMessageProvider.ERROR); - else if (status.getSeverity() == IStatus.WARNING) - wizard.setMessage(status.getMessage(), IMessageProvider.WARNING); - else if (status.getSeverity() == IStatus.INFO) - wizard.setMessage(status.getMessage(), IMessageProvider.INFORMATION); - server = null; - } - } - } - - if (serverName != null && !serverNameModified) { - updatingServerName = true; - if (server == null) - serverName.setText(""); - else - serverName.setText(server.getName()); - updatingServerName = false; - } - - updateRuntimeCombo(serverType); - if (serverName != null) { - if (server == null) { - serverName.setEditable(false); - serverNameToolBar.getControl().setVisible(false); - } else { - serverName.setEditable(true); - serverNameToolBar.getControl().setVisible(serverNameModified); - } - } - listener.serverSelected(server); - wizard.update(); - } - - public void setVisible(boolean visible) { - super.setVisible(visible); - - if (visible) { - /*if (defaultServerFactory != null) { - tree.setSelection(new TreeItem[] { defaultServerFactory }); - tree.showItem(tree.getItems()[0]); - }*/ - // force the focus to initially validate the fields - handleTypeSelection(null); - } - - Control[] c = getChildren(); - if (c != null) { - int size = c.length; - for (int i = 0; i < size; i++) - if (c[i] != null && c[i] instanceof ServerTypeComposite) - c[i].setVisible(visible); - } - if (visible) - handleTypeSelection(serverTypeComposite.getSelectedServerType()); - } - - public void refresh() { - serverTypeComposite.refresh(); - } - - public IRuntime getRuntime() { - return runtime; - } - - public IServerWorkingCopy getServer() { - return server; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewRuntimeComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewRuntimeComposite.java deleted file mode 100644 index 2251d7746..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewRuntimeComposite.java +++ /dev/null @@ -1,203 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2009 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.server.ui.internal.wizard.page; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.help.IWorkbenchHelpSystem; -import org.eclipse.wst.server.core.*; -import org.eclipse.wst.server.ui.internal.ContextIds; -import org.eclipse.wst.server.ui.internal.ImageResource; -import org.eclipse.wst.server.ui.internal.Messages; -import org.eclipse.wst.server.ui.internal.SWTUtil; -import org.eclipse.wst.server.ui.internal.ServerUIPlugin; -import org.eclipse.wst.server.ui.internal.Trace; -import org.eclipse.wst.server.ui.internal.viewers.RuntimeTypeComposite; -import org.eclipse.wst.server.ui.wizard.IWizardHandle; -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.swt.widgets.Control; -import org.eclipse.swt.widgets.Tree; -/** - * - */ -public class NewRuntimeComposite extends Composite { - protected Tree tree; - protected TreeViewer treeViewer; - protected Button createServer; - - protected IRuntimeWorkingCopy runtime; - - // cache of created runtimes and servers - protected Map<IRuntimeType, IRuntimeWorkingCopy> cache = new HashMap<IRuntimeType, IRuntimeWorkingCopy>(); - protected Map<IRuntime, IServerWorkingCopy> serverCache = new HashMap<IRuntime, IServerWorkingCopy>(); - - protected TaskModel taskModel; - protected IWizardHandle wizard; - - protected String type; - protected String version; - protected String runtimeTypeId; - protected IServerType serverType; - - public NewRuntimeComposite(Composite parent, IWizardHandle wizard, TaskModel tm, String type, String version, String runtimeTypeId) { - super(parent, SWT.NONE); - - this.wizard = wizard; - this.taskModel = tm; - this.type = type; - this.version = version; - this.runtimeTypeId = runtimeTypeId; - - createControl(); - - wizard.setTitle(Messages.wizNewRuntimeTitle); - wizard.setDescription(Messages.wizNewRuntimeDescription); - wizard.setImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_WIZBAN_NEW_RUNTIME)); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) - */ - public void createControl() { - //initializeDialogUnits(parent); - GridLayout layout = new GridLayout(); - layout.horizontalSpacing = SWTUtil.convertHorizontalDLUsToPixels(this, 4); - layout.verticalSpacing = SWTUtil.convertVerticalDLUsToPixels(this, 4); - setLayout(layout); - IWorkbenchHelpSystem whs = PlatformUI.getWorkbench().getHelpSystem(); - whs.setHelp(this, ContextIds.NEW_RUNTIME_WIZARD); - - final RuntimeTypeComposite comp = new RuntimeTypeComposite(this, true, new RuntimeTypeComposite.RuntimeTypeSelectionListener() { - public void runtimeTypeSelected(IRuntimeType runtimeType) { - handleSelection(runtimeType); - } - }, type, version, runtimeTypeId); - GridData data = new GridData(GridData.FILL_BOTH); - data.heightHint = 300; - comp.setLayoutData(data); - - createServer = new Button(this, SWT.CHECK); - createServer.setText(Messages.wizNewRuntimeCreateServer); - createServer.setSelection(ServerUIPlugin.getPreferences().getCreateServerWithRuntime()); - createServer.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - handleServer(); - ServerUIPlugin.getPreferences().setCreateServerWithRuntime(createServer.getSelection()); - } - }); - } - - protected void handleSelection(IRuntimeType runtimeType) { - if (runtimeType == null) - runtime = null; - else { - try { - runtime = null; - runtime = cache.get(runtimeType); - } catch (Exception e) { - // ignore - } - if (runtime == null) { - try { - runtime = runtimeType.createRuntime(null, null); - if (runtime != null) - cache.put(runtimeType, runtime); - } catch (Exception e) { - // ignore - } - } - } - serverType = getCompatibleServerType(runtimeType); - handleServer(); - } - - protected void handleServer() { - boolean option = false; - if (serverType != null && serverType.hasRuntime()) - option = true; - createServer.setVisible(option); - - if (option && createServer.getSelection()) { - IServerWorkingCopy server = getServer(); - taskModel.putObject(TaskModel.TASK_SERVER, server); - } else - taskModel.putObject(TaskModel.TASK_SERVER, null); - - taskModel.putObject(TaskModel.TASK_RUNTIME, runtime); - wizard.update(); - } - - protected static IServerType getCompatibleServerType(IRuntimeType runtimeType) { - List<IServerType> list = new ArrayList<IServerType>(); - IServerType[] serverTypes = ServerCore.getServerTypes(); - int size = serverTypes.length; - for (int i = 0; i < size; i++) { - IRuntimeType rt = serverTypes[i].getRuntimeType(); - if (rt != null && rt.equals(runtimeType)) - list.add(serverTypes[i]); - } - if (list.size() == 1) - return list.get(0); - return null; - } - - /** - * Get a server of the given type. - */ - protected IServerWorkingCopy getServer() { - if (serverType == null || runtime == null || !serverType.hasRuntime()) - return null; - - IServerWorkingCopy server = serverCache.get(runtime); - if (server != null) - return server; - - try { - server = serverType.createServer(null, null, runtime, null); - if (server != null) { - serverCache.put(runtime, server); - return server; - } - } catch (CoreException ce) { - Trace.trace(Trace.SEVERE, "Error creating server", ce); - } - - return null; - } - - public IRuntimeWorkingCopy getRuntime() { - return runtime; - } - - public void setVisible(boolean visible) { - super.setVisible(visible); - - Control[] c = getChildren(); - if (c != null) { - int size = c.length; - for (int i = 0; i < size; i++) - if (c[i] != null) - c[i].setVisible(visible); - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewServerComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewServerComposite.java deleted file mode 100644 index a61b4cf2b..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewServerComposite.java +++ /dev/null @@ -1,543 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.wizard.page; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.debug.core.ILaunchManager; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IMessageProvider; -import org.eclipse.jface.operation.IRunnableWithProgress; - -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.StackLayout; -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.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.help.IWorkbenchHelpSystem; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IModuleType; -import org.eclipse.wst.server.core.IRuntime; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.IServerAttributes; -import org.eclipse.wst.server.core.IServerType; -import org.eclipse.wst.server.core.IServerWorkingCopy; -import org.eclipse.wst.server.core.TaskModel; -import org.eclipse.wst.server.core.ServerCore; -import org.eclipse.wst.server.core.ServerUtil; -import org.eclipse.wst.server.ui.internal.*; -import org.eclipse.wst.server.ui.internal.viewers.ServerComposite; -import org.eclipse.wst.server.ui.internal.wizard.WizardTaskUtil; -import org.eclipse.wst.server.ui.wizard.IWizardHandle; -/** - * A wizard page used to select a server. - */ -public class NewServerComposite extends Composite { - protected IWizardHandle wizard; - protected TaskModel taskModel; - protected IModule module; - protected IModuleType moduleType; - protected String serverTypeId; - protected String launchMode; - - protected static final byte MODE_EXISTING = WizardTaskUtil.MODE_EXISTING; - protected static final byte MODE_DETECT = WizardTaskUtil.MODE_DETECT; - protected static final byte MODE_MANUAL = WizardTaskUtil.MODE_MANUAL; - protected byte mode; - - protected Composite detectComp2; - protected NewDetectServerComposite detectComp; - protected HostnameComposite detectHostComp; - protected Composite manualComp2; - protected NewManualServerComposite manualComp; - protected HostnameComposite manualHostComp; - protected ServerComposite existingComp; - - protected Composite stack; - protected StackLayout stackLayout; - - protected String lastHostname; - - protected IServerWorkingCopy existingWC; - - /** - * Create a new NewServerComposite. - * - * @param parent a parent composite - * @param wizard a wizard handle - * @param moduleType a module type, or null - * @param serverTypeId a server type id, or null - * @param launchMode a launch mode - */ - public NewServerComposite(Composite parent, IWizardHandle wizard, IModuleType moduleType, String serverTypeId, String launchMode) { - super(parent, SWT.NONE); - this.wizard = wizard; - this.moduleType = moduleType; - this.serverTypeId = serverTypeId; - this.launchMode = launchMode; - - wizard.setTitle(Messages.wizNewServerTitle); - wizard.setDescription(Messages.wizNewServerDescription); - wizard.setImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_WIZBAN_NEW_SERVER)); - - createControl(); - } - - /** - * Create a new NewServerComposite. - * - * @param parent a parent composite - * @param wizard a wizard handle - * @param module a module - * @param launchMode a launch mode - */ - public NewServerComposite(Composite parent, IWizardHandle wizard, IModule module, String launchMode) { - super(parent, SWT.NONE); - this.wizard = wizard; - this.module = module; - this.launchMode = launchMode; - - wizard.setTitle(Messages.wizNewServerTitle); - wizard.setDescription(Messages.wizNewServerDescription); - wizard.setImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_WIZBAN_NEW_SERVER)); - - createControl(); - } - - protected Label createLabel(Composite parent, String text, int span) { - Label label = new Label(parent, SWT.WRAP); - label.setText(text); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING); - data.horizontalSpan = span; - label.setLayoutData(data); - return label; - } - - protected Label createLabel(Composite parent, String text) { - return createLabel(parent, text, 1); - } - - protected Button createRadioButton(Composite parent, String text, int span) { - Button button = new Button(parent, SWT.RADIO); - button.setText(text); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING); - data.horizontalSpan = span; - data.horizontalIndent = 10; - button.setLayoutData(data); - return button; - } - - protected Text createText(Composite parent, String text2, int span) { - Text text = new Text(parent, SWT.NONE); - text.setText(text2); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING); - data.horizontalSpan = span; - text.setLayoutData(data); - return text; - } - - /** - * Creates the UI of the page. - */ - protected void createControl() { - GridLayout layout = new GridLayout(); - layout.horizontalSpacing = SWTUtil.convertHorizontalDLUsToPixels(this, 4); - layout.verticalSpacing = SWTUtil.convertVerticalDLUsToPixels(this, 4); - setLayout(layout); - IWorkbenchHelpSystem whs = PlatformUI.getWorkbench().getHelpSystem(); - whs.setHelp(this, ContextIds.NEW_SERVER_WIZARD); - - if (module != null) { - if (ILaunchManager.DEBUG_MODE.equals(launchMode)) - wizard.setTitle(Messages.wizDebugOnServerTitle); - else if (ILaunchManager.PROFILE_MODE.equals(launchMode)) - wizard.setTitle(Messages.wizProfileOnServerTitle); - else - wizard.setTitle(Messages.wizRunOnServerTitle); - wizard.setDescription(Messages.wizNewServerRunOnServerDescription); - createLabel(this, Messages.wizNewServerSelect, 1); - } - - Button existing = null; - if (module != null) { - final Button predefined = createRadioButton(this, Messages.wizNewServerExisting, 1); - predefined.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - if (predefined.getSelection()) - toggleMode(MODE_EXISTING); - } - }); - existing = predefined; - } - - /*final Button auto = createRadioButton(this, Messages.wizNewServerDetect"), 1); - auto.setEnabled(false); - auto.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - if (auto.getSelection()) - toggleMode(MODE_DETECT); - } - });*/ - - Button manual = null; - if (module != null) { - final Button manualButton = createRadioButton(this, Messages.wizNewServerManual, 1); - manualButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - if (manualButton.getSelection()) - toggleMode(MODE_MANUAL); - } - }); - manual = manualButton; - } - - stack = new Composite(this, SWT.NONE); - GridData data = new GridData(GridData.FILL_BOTH); - stack.setLayoutData(data); - stackLayout = new StackLayout(); - stackLayout.marginHeight = 0; - stackLayout.marginWidth = 0; - stack.setLayout(stackLayout); - - if (module != null) - createExistingComposite(stack); - createAutoComposite(stack); - createManualComposite(stack); - - if (existingComp != null && existing != null) { - if (isExistingServer()) { - mode = MODE_EXISTING; - stackLayout.topControl = existingComp; - existing.setSelection(true); - } else { - mode = MODE_MANUAL; - stackLayout.topControl = manualComp2; - manualComp.setVisible(true); - if (manual != null) - manual.setSelection(true); - existing.setEnabled(false); - existingComp.setEnabled(false); - } - } else { - mode = MODE_MANUAL; - stackLayout.topControl = manualComp2; - manualComp.setVisible(true); - if (manual != null) - manual.setSelection(true); - } - - if (module != null) { - // preferred server button - final Button pref = new Button(this, SWT.CHECK | SWT.WRAP); - pref.setText(Messages.wizSelectServerPreferred); - data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_END); - pref.setLayoutData(data); - pref.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - taskModel.putObject(WizardTaskUtil.TASK_DEFAULT_SERVER, new Boolean(pref.getSelection())); - } - }); - PlatformUI.getWorkbench().getHelpSystem().setHelp(pref, ContextIds.SELECT_SERVER_PREFERENCE); - } - - Dialog.applyDialogFont(this); - } - - protected void toggleMode(byte newMode) { - if (!isVisible()) - return; - - if (newMode == mode) - return; - - mode = newMode; - wizard.setMessage(null, IMessageProvider.NONE); - - if (mode == MODE_EXISTING) { - stackLayout.topControl = existingComp; - existingComp.setSelection(existingComp.getSelectedServer()); - } else if (mode == MODE_DETECT) { - stackLayout.topControl = detectComp2; - detectComp.setVisible(true); - } else { - stackLayout.topControl = manualComp2; - manualComp.setVisible(true); - } - stack.layout(); - if (taskModel != null) { - taskModel.putObject(WizardTaskUtil.TASK_MODE, new Byte(mode)); - updateTaskModel(); - } - } - - protected HostnameComposite createHostComposite(Composite comp) { - HostnameComposite hostComp = new HostnameComposite(comp, new HostnameComposite.IHostnameSelectionListener() { - public void hostnameSelected(String host) { - lastHostname = host; - if (detectComp != null) - detectComp.setHost(host); - if (manualComp != null) - manualComp.setHost(host); - } - }); - - if (lastHostname != null) - hostComp.setHostname(lastHostname); - - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 3; - hostComp.setLayoutData(data); - return hostComp; - } - - protected void createAutoComposite(Composite comp) { - detectComp2 = new Composite(comp, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.horizontalSpacing = SWTUtil.convertHorizontalDLUsToPixels(this, 4); - layout.verticalSpacing = SWTUtil.convertVerticalDLUsToPixels(this, 4); - layout.marginWidth = 0; - layout.marginHeight = 0; - layout.numColumns = 1; - detectComp2.setLayout(layout); - - detectHostComp = createHostComposite(detectComp2); - - detectComp = new NewDetectServerComposite(detectComp2, new NewDetectServerComposite.IServerSelectionListener() { - public void serverSelected(IServerAttributes server) { - // do nothing - } - }); - - if (lastHostname != null) - detectComp.setHost(lastHostname); - else - detectComp.setHost("localhost"); - GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL); - data.horizontalSpan = 3; - data.heightHint = 150; - detectComp.setLayoutData(data); - } - - protected void createExistingComposite(Composite comp) { - existingComp = new ServerComposite(comp, new ServerComposite.ServerSelectionListener() { - public void serverSelected(IServer server) { - wizard.setMessage(null, IMessageProvider.NONE); - - // check for compatibility - if (server != null && module != null) { - IStatus status = isSupportedModule(server, module); - if (status != null) { - if (status.getSeverity() == IStatus.ERROR) - wizard.setMessage(status.getMessage(), IMessageProvider.ERROR); - else if (status.getSeverity() == IStatus.WARNING) - wizard.setMessage(status.getMessage(), IMessageProvider.WARNING); - else if (status.getSeverity() == IStatus.INFO) - wizard.setMessage(status.getMessage(), IMessageProvider.INFORMATION); - server = null; - } - } - - if (existingWC != null) { - if (server != null && server.equals(existingWC.getOriginal())) - return; - existingWC = null; - } - if (server != null) - existingWC = server.createWorkingCopy(); - updateTaskModel(); - } - }, module, launchMode); - existingComp.setIncludeIncompatibleVersions(true); - GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL); - data.horizontalSpan = 3; - data.heightHint = 150; - existingComp.setLayoutData(data); - } - - /** - * Returns the status of whether the given module could be added to the server. - * - * @param server a server - * @param module a module - * @return an IStatus representing the error or warning, or null if there are no problems - */ - protected static IStatus isSupportedModule(IServerAttributes server, IModule module) { - if (server != null && module != null) { - IServerType serverType = server.getServerType(); - IModuleType mt = module.getModuleType(); - if (!ServerUtil.isSupportedModule(serverType.getRuntimeType().getModuleTypes(), mt)) { - String type = mt.getName(); - return new Status(IStatus.ERROR, ServerUIPlugin.PLUGIN_ID, NLS.bind(Messages.errorVersionLevel, new Object[] { type, mt.getVersion() })); - } - - IModule[] rootModules = null; - try { - rootModules = server.getRootModules(module, null); - } catch (CoreException ce) { - return ce.getStatus(); - } catch (Exception e) { - Trace.trace(Trace.WARNING, "Could not find root module", e); - } - if (rootModules != null) { - if (rootModules.length == 0) - return new Status(IStatus.ERROR, ServerUIPlugin.PLUGIN_ID, Messages.errorRootModule); - - int size = rootModules.length; - IStatus status = null; - boolean found = false; - for (int i = 0; i < size; i++) { - try { - if (server != null) - status = server.canModifyModules(new IModule[] {rootModules[i]}, null, null); - if (status != null && status.isOK()) - found = true; - } catch (Exception e) { - Trace.trace(Trace.WARNING, "Could not find root module", e); - } - } - if (!found && status != null) - return status; - } - } - return null; - } - - protected boolean isExistingServer() { - if (module == null || launchMode == null) - return false; - - IServer[] servers = ServerCore.getServers(); - if (servers != null) { - int size = servers.length; - for (int i = 0; i < size; i++) { - IModuleType mt = module.getModuleType(); - if (ServerUIPlugin.isCompatibleWithLaunchMode(servers[i], launchMode) && - ServerUtil.isSupportedModule(servers[i].getServerType().getRuntimeType().getModuleTypes(), mt)) - return true; - } - } - return false; - } - - protected void createManualComposite(Composite comp) { - manualComp2 = new Composite(comp, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.horizontalSpacing = SWTUtil.convertHorizontalDLUsToPixels(this, 4); - layout.verticalSpacing = SWTUtil.convertVerticalDLUsToPixels(this, 4); - layout.marginWidth = 0; - layout.marginHeight = 0; - layout.numColumns = 1; - manualComp2.setLayout(layout); - manualComp2.setLayoutData(new GridData(GridData.FILL_BOTH)); - - manualHostComp = createHostComposite(manualComp2); - IModuleType mt = moduleType; - boolean includeIncompatible = true; - if (moduleType != null) - includeIncompatible = false; - - if (module != null) - mt = module.getModuleType(); - - manualComp = new NewManualServerComposite(manualComp2, new NewManualServerComposite.IWizardHandle2() { - public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InterruptedException, InvocationTargetException { - wizard.run(fork, cancelable, runnable); - } - public void update() { - wizard.update(); - } - public void setMessage(String newMessage, int newType) { - wizard.setMessage(newMessage, newType); - } - }, mt, module, serverTypeId, includeIncompatible, new NewManualServerComposite.ServerSelectionListener() { - public void serverSelected(IServerAttributes server) { - updateTaskModel(); - } - public void runtimeSelected(IRuntime runtime) { - updateTaskModel(); - } - }); - - if (lastHostname != null) - manualComp.setHost(lastHostname); - else - manualComp.setHost("localhost"); - - GridData data = new GridData(GridData.FILL_BOTH); - data.horizontalSpan = 3; - data.heightHint = 325; - manualComp.setLayoutData(data); - } - - protected void updateTaskModel() { - if (taskModel != null) { - IServerWorkingCopy server = getServer(); - if (server != null) { - taskModel.putObject(TaskModel.TASK_SERVER, server); - taskModel.putObject(TaskModel.TASK_RUNTIME, server.getRuntime()); - } else { - taskModel.putObject(TaskModel.TASK_SERVER, null); - taskModel.putObject(TaskModel.TASK_RUNTIME, null); - } - } - wizard.update(); - } - - public void setTaskModel(TaskModel model) { - taskModel = model; - taskModel.putObject(WizardTaskUtil.TASK_MODE, new Byte(mode)); - updateTaskModel(); - } - - public IServerWorkingCopy getServer() { - if (mode == MODE_EXISTING) - return existingWC; //existingComp.getSelectedServer(); - else if (mode == MODE_DETECT) - return detectComp.getServer(); - else - return manualComp.getServer(); - } - - public IRuntime getRuntime() { - if (mode == MODE_EXISTING) { - IServer server = existingComp.getSelectedServer(); - if (server != null) - return server.getRuntime(); - return null; - } else if (mode == MODE_DETECT) - return null; - else - return manualComp.getRuntime(); - } - - public void setVisible(boolean visible) { - super.setVisible(visible); - - Control[] c = getChildren(); - if (c != null) { - int size = c.length; - for (int i = 0; i < size; i++) - if (c[i] != null) - c[i].setVisible(visible); - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/SelectClientComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/SelectClientComposite.java deleted file mode 100644 index c6828e582..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/SelectClientComposite.java +++ /dev/null @@ -1,155 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.wizard.page; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IMessageProvider; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.wst.server.core.TaskModel; -import org.eclipse.wst.server.core.internal.IClient; -import org.eclipse.wst.server.ui.ServerUICore; -import org.eclipse.wst.server.ui.internal.*; -import org.eclipse.wst.server.ui.internal.wizard.WizardTaskUtil; -import org.eclipse.wst.server.ui.wizard.IWizardHandle; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableItem; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.help.IWorkbenchHelpSystem; -/** - * A wizard page used to select a server client. - */ -public class SelectClientComposite extends Composite { - protected IWizardHandle wizard; - protected TaskModel taskModel; - - // the list of elements to select from - protected IClient[] clients; - - // the currently selected element - protected IClient selectedClient; - - // the table containing the elements - protected Table elementTable; - - // the description of the selected client - protected Label description; - - /** - * Create a new SelectClientComposite. - * - * @param parent a parent composite - * @param wizard a wizard handle - * @param taskModel a task model - */ - public SelectClientComposite(Composite parent, IWizardHandle wizard, TaskModel taskModel) { - super(parent, SWT.NONE); - this.wizard = wizard; - this.taskModel = taskModel; - try { - clients = (IClient[]) taskModel.getObject(WizardTaskUtil.TASK_CLIENTS); - } catch (Exception e) { - // ignore - } - - wizard.setTitle(Messages.wizSelectClientTitle); - wizard.setDescription(Messages.wizSelectClientDescription); - wizard.setImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_WIZBAN_SELECT_SERVER_CLIENT)); - - createControl(); - } - - /** - * Creates the UI of the page. - */ - protected void createControl() { - GridLayout layout = new GridLayout(); - layout.horizontalSpacing = SWTUtil.convertHorizontalDLUsToPixels(this, 4); - layout.verticalSpacing = SWTUtil.convertVerticalDLUsToPixels(this, 4); - setLayout(layout); - - IWorkbenchHelpSystem whs = PlatformUI.getWorkbench().getHelpSystem(); - whs.setHelp(this, ContextIds.SELECT_CLIENT_WIZARD); - - Label label = new Label(this, SWT.WRAP); - label.setText(Messages.wizSelectClientMessage); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING); - label.setLayoutData(data); - - elementTable = new Table(this, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); - data = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL); - data.heightHint = 80; - data.horizontalIndent = 20; - elementTable.setLayoutData(data); - elementTable.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - handleSelection(); - } - public void widgetDefaultSelected(SelectionEvent e) { - handleSelection(); - //TODO: WizardUtil.defaultSelect(getWizard(), SelectClientWizardPage.this); - } - }); - whs.setHelp(elementTable, ContextIds.SELECT_CLIENT); - - if (clients != null) { - ILabelProvider labelProvider = ServerUICore.getLabelProvider(); - int size = clients.length; - for (int i = 0; i < size; i++) { - TableItem item = new TableItem(elementTable, SWT.NONE); - item.setText(0, labelProvider.getText(clients[i])); - item.setImage(0, labelProvider.getImage(clients[i])); - item.setData(clients[i]); - } - labelProvider.dispose(); - } - - description = new Label(this, SWT.WRAP); - description.setText(""); - data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING); - data.heightHint = 70; - description.setLayoutData(data); - - Dialog.applyDialogFont(this); - } - - /** - * Handle the selection of a client. - */ - protected void handleSelection() { - int index = elementTable.getSelectionIndex(); - if (index < 0) - selectedClient = null; - else - selectedClient = clients[index]; - - taskModel.putObject(WizardTaskUtil.TASK_CLIENT, selectedClient); - if (selectedClient != null) - wizard.setMessage(null, IMessageProvider.NONE); - else - wizard.setMessage("", IMessageProvider.ERROR); - - String desc = null; - if (selectedClient != null) - desc = selectedClient.getDescription(); - if (desc == null) - desc = ""; - description.setText(desc); - - wizard.update(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/ServerCreationCache.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/ServerCreationCache.java deleted file mode 100644 index 430e38cf8..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/ServerCreationCache.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.wizard.page; - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; - -import org.eclipse.wst.server.core.IRuntime; -import org.eclipse.wst.server.core.IServerType; -import org.eclipse.wst.server.core.IServerWorkingCopy; -/** - * A helper class used to cache the creation of servers. - */ -public class ServerCreationCache { - protected Map<String, IServerWorkingCopy> cache; - - /** - * ServerCreationCache constructor comment. - */ - public ServerCreationCache() { - super(); - cache = new HashMap<String, IServerWorkingCopy>(); - } - - /** - * Return the key to use for the given server type. - * - * @param type the server type - * @param isLocalhost true if the server is local - * @return the key - */ - private String getKey(IServerType type, boolean isLocalhost) { - return type.getId() + "|" + isLocalhost + "|"; - } - - /** - * Create a new server and put it in the cache. - * - * @param type the server type - * @param runtime a runtime, or null - * @param isLocalhost true if the server is local - * @param monitor a progress monitor - * @return a server working copy - * @throws CoreException if anything goes wrong - */ - public IServerWorkingCopy createServer(IServerType type, IRuntime runtime, boolean isLocalhost, IProgressMonitor monitor) throws CoreException { - IServerWorkingCopy server = type.createServer(null, null, runtime, monitor); - cache.put(getKey(type, isLocalhost), server); - return server; - } - - /** - * Returns a previously cached server, if one exists - * - * @param type the server type - * @param isLocalhost true if the server is local - * @return a working copy - */ - public IServerWorkingCopy getCachedServer(IServerType type, boolean isLocalhost) { - try { - IServerWorkingCopy server = cache.get(getKey(type, isLocalhost)); - if (server != null) - return server; - } catch (Exception e) { - // ignore - } - - return null; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/TasksComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/TasksComposite.java deleted file mode 100644 index ef81b4f90..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/TasksComposite.java +++ /dev/null @@ -1,143 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.wizard.page; - -import java.util.List; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.wst.server.core.model.PublishOperation; -import org.eclipse.wst.server.ui.internal.ContextIds; -import org.eclipse.wst.server.ui.internal.ImageResource; -import org.eclipse.wst.server.ui.internal.Messages; -import org.eclipse.wst.server.ui.internal.SWTUtil; -import org.eclipse.wst.server.ui.internal.Trace; -import org.eclipse.wst.server.ui.internal.wizard.fragment.TasksWizardFragment; -import org.eclipse.wst.server.ui.wizard.IWizardHandle; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.ScrolledComposite; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.ui.PlatformUI; -/** - * A wizard page used to select server and module tasks. - */ -public class TasksComposite extends ScrolledComposite { - protected IWizardHandle wizard; - - // the list of elements to select from - protected List tasks; - - protected boolean created; - - /** - * Create a new TasksComposite. - * - * @param parent a parent composite - * @param wizard a wizard handle - */ - public TasksComposite(Composite parent, IWizardHandle wizard) { - super(parent, SWT.H_SCROLL | SWT.V_SCROLL); - this.wizard = wizard; - - wizard.setTitle(Messages.wizTaskTitle); - wizard.setDescription(Messages.wizTaskDescription); - wizard.setImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_WIZBAN_SELECT_SERVER)); - - //createControl(); - } - - public void setTasks(List tasks) { - this.tasks = tasks; - - Control[] children = getChildren(); - if (children != null) { - int size = children.length; - for (int i = 0; i < size; i++) { - children[i].dispose(); - } - } - - created = false; - } - - /** - * Creates the UI of the page. - */ - public void createControl() { - if (created) - return; - - setLayoutData(new GridData(GridData.FILL_BOTH)); - - Composite comp = new Composite(this, SWT.NONE); - setContent(comp); - TasksLayout layout = new TasksLayout(SWTUtil.convertVerticalDLUsToPixels(this, 4)); - comp.setLayout(layout); - comp.setLayoutData(new GridData(GridData.FILL_BOTH)); - PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ContextIds.SELECT_TASK_WIZARD); - - int size = 0; - if (tasks != null) - size = tasks.size(); - - for (int i = 0; i < size; i++) { - Object obj = tasks.get(i); - final TasksWizardFragment.TaskInfo sti = (TasksWizardFragment.TaskInfo) obj; - final Button checkbox = new Button(comp, SWT.CHECK | SWT.WRAP); - String label = sti.task2.getLabel(); - if (label != null) - checkbox.setText(label); - else - checkbox.setText(Messages.elementUnknownName); - - checkbox.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent event) { - sti.setSelected(checkbox.getSelection()); - } - public void widgetDefaultSelected(SelectionEvent event) { - sti.setSelected(checkbox.getSelection()); - } - }); - - Label description = new Label(comp, SWT.WRAP); - String desc = sti.task2.getDescription(); - if (desc != null) - description.setText(desc); - else - description.setText(Messages.elementUnknownName); - - if (sti.kind == PublishOperation.REQUIRED) { - checkbox.setSelection(true); - checkbox.setEnabled(false); - description.setEnabled(false); - } else - checkbox.setSelection(sti.isSelected()); - } - - if (size == 0) - Trace.trace(Trace.SEVERE, "Task composite appeared with no tasks!"); - - Dialog.applyDialogFont(this); - - setExpandHorizontal(true); - setExpandVertical(true); - - setMinSize(comp.computeSize(SWT.DEFAULT, SWT.DEFAULT)); - layout(true, true); - - created = true; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/TasksLayout.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/TasksLayout.java deleted file mode 100644 index bd4d45cdf..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/TasksLayout.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.wizard.page; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Layout; -/** - * - */ -public class TasksLayout extends Layout { - private int verticalSpacing; - - public TasksLayout(int verticalSpacing) { - this.verticalSpacing = verticalSpacing; - } - - /* (non-Javadoc) - * @see org.eclipse.swt.widgets.Layout#computeSize(org.eclipse.swt.widgets.Composite, int, int, boolean) - */ - protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) { - //return new Point(wHint, hHint); - Control[] children = composite.getChildren(); - - int y = 5; - if (children != null) { - int size = children.length; - for (int i = 0; i < size; i++) { - if (i % 2 == 0) { - int h = children[i].computeSize(wHint, SWT.DEFAULT).y; - y += h + verticalSpacing / 2; - } else { - int h = Math.max(45, children[i].computeSize(wHint, SWT.DEFAULT).y); - y += h + verticalSpacing; - } - } - } - return new Point(200, y); // + verticalSpacing); - } - - /* (non-Javadoc) - * @see org.eclipse.swt.widgets.Layout#layout(org.eclipse.swt.widgets.Composite, boolean) - */ - protected void layout(Composite composite, boolean flushCache) { - Control[] children = composite.getChildren(); - Rectangle r = composite.getClientArea(); - - int y = r.y + 5; - if (children != null) { - int size = children.length; - for (int i = 0; i < size; i++) { - if (i % 2 == 0) { - int h = children[i].computeSize(r.width - 10, SWT.DEFAULT).y; - children[i].setBounds(r.x + 5, y, r.width - 10, h); - y += h + verticalSpacing / 2; - } else { - int h = Math.max(45, children[i].computeSize(r.width - 25, SWT.DEFAULT).y); - children[i].setBounds(r.x + 20, y, r.width - 25, h); - y += h + verticalSpacing; - } - } - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/WorkspaceRunnableAdapter.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/WorkspaceRunnableAdapter.java deleted file mode 100644 index e80519d33..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/WorkspaceRunnableAdapter.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.internal.wizard.page; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.resources.IWorkspaceRunnable; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.operation.IRunnableWithProgress; -/** - * IRunnableWithProgressAdapter to allow it to run an IWorkspaceRunnable. - */ -public class WorkspaceRunnableAdapter implements IRunnableWithProgress { - private IWorkspaceRunnable workspaceRunnable; - - public WorkspaceRunnableAdapter(IWorkspaceRunnable runnable) { - workspaceRunnable = runnable; - } - - /* - * @see IRunnableWithProgress#run(IProgressMonitor) - */ - public void run(IProgressMonitor monitor) throws InvocationTargetException { - try { - ResourcesPlugin.getWorkspace().run(workspaceRunnable, monitor); - } catch (CoreException e) { - throw new InvocationTargetException(e); - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/package.html b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/package.html deleted file mode 100644 index 3babaea24..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/package.html +++ /dev/null @@ -1,38 +0,0 @@ -<html> -<head> -<META http-equiv="Content-Type" content="text/html; charset=UTF-8"> -<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> -<link rel="stylesheet" href="../../../../../..//apistyles.css" type="text/css"> -<title>WTP API overview</title> -</head> -<body> -<p>The server tools UI.</p> -<table width="500"> -<tr> -<td> -<p>ServerUICore is the main entry-point for the API. From here, clients -can get the wizard pages for a particular server type, get a label -provider for all server types, or launch Run on Server directly.</p> -</td> -</tr> -</table> -<table width="500"> -<tr> -<td> -<p>ServerUIUtil provides utility methods. Currently, this is limited to -launching the server runtime wizard and editing an existing server -runtime.</p> -</td> -</tr> -</table> -<table width="500"> -<tr> -<td> -<p>ServerLaunchConfigurationTab is a generic server tools tab that can -be used in launch configuration tab groups for a server launch. It shows -information about the server to the user.</p> -</td> -</tr> -</table> -</body> -</html> diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/package.xml b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/package.xml deleted file mode 100644 index 873e26402..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/package.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<html> -<head> - <!-- Escape to the root of your source folder --> - <meta - name="root" - content="../../../../../../" /> - <title>WTP API overview</title> -</head> - -<body> - -<abstract>The server tools UI.</abstract> - -<p>ServerUICore is the main entry-point for the API. From here, clients -can get the wizard pages for a particular server type, get a label -provider for all server types, or launch Run on Server directly.</p> - -<p>ServerUIUtil provides utility methods. Currently, this is limited to -launching the server runtime wizard and editing an existing server -runtime.</p> - -<p>ServerLaunchConfigurationTab is a generic server tools tab that can -be used in launch configuration tab groups for a server launch. It shows -information about the server to the user.</p> - -</body> -</html>
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/wizard/IWizardHandle.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/wizard/IWizardHandle.java deleted file mode 100644 index 85c9752a8..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/wizard/IWizardHandle.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.wizard; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.jface.dialogs.IMessageProvider; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.resource.ImageDescriptor; -/** - * A wizard handle. - * - * @since 1.0 - */ -public interface IWizardHandle extends IMessageProvider { - /** - * Updates the wizard error messages and buttons. - */ - public void update(); - - /** - * Sets the title of this wizard page. - * - * @param title the title of the wizard page - */ - public void setTitle(String title); - - /** - * The page's description. - * - * @param desc the page's description - */ - public void setDescription(String desc); - - /** - * The page's image descriptor. - * - * @param image the page's image descriptor - */ - public void setImageDescriptor(ImageDescriptor image); - - /** - * Set an error or warning message. - * - * @param newMessage the new message - * @param newType the new type, from IStatus - */ - public void setMessage(String newMessage, int newType); - - /** - * Execute a runnable within the context of the wizard. This will typically - * disable the wizard while the runnable is running, and provide a progress - * monitor for the user. - * - * @param fork true if a separate thread should be used - * @param cancelable true if it should be cancelable - * @param runnable the runnable - * @throws InterruptedException thrown if it is interrupted - * @throws InvocationTargetException thrown if there is an error - */ - public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InterruptedException, InvocationTargetException; -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/wizard/WizardFragment.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/wizard/WizardFragment.java deleted file mode 100644 index 130f8e939..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/wizard/WizardFragment.java +++ /dev/null @@ -1,222 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.ui.wizard; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.swt.widgets.Composite; - -import org.eclipse.wst.server.core.TaskModel; -/** - * A wizard fragment is a node within a wizard that provides a completely - * extendable wizard flow by supporting a flexible tree structure for the - * pages. As the user walks pages through the wizard, they are actually - * traversing the nodes of a tree, and each node can add or remove children - * at any time. - * - * Each node may be non-UI (useful for injecting behaviour into the tree) - * or contain a single wizard page (@see hasComposite() and - * createComposite(Composite, IWizardHandle)). The node may also have - * children (@see getChildFragments(), which should be updated or refreshed - * whenever the updateChildFragments() method is called by another node to - * let this node know that it's state may have changed. - * - * This implementation uses a createChildFragments() method to allow the - * fragment to add it's children into the tree. Note that this method may - * be called multiple times as the tree is updated and it must return the - * same instance of any children that have previously been returned. - * - * @since 1.0 - */ -public abstract class WizardFragment { - private TaskModel taskModel; - private boolean isComplete = true; - private List<WizardFragment> listImpl; - - /** - * Returns <code>true</code> if this fragment has an associated UI, - * and <code>false</code> otherwise. - * - * @return true if the fragment has a composite - */ - public boolean hasComposite() { - return false; - } - - /** - * Creates the composite associated with this fragment. - * This method is only called when hasComposite() returns true. - * - * @param parent a parent composite - * @param handle a wizard handle - * @return the created composite - */ - public Composite createComposite(Composite parent, IWizardHandle handle) { - return null; - } - - /** - * Sets the wizard task model. - * <p> - * A task model is shared by all fragments in the wizard and is used to share - * data. It contains information about the overall task flow and allows - * fragments to store and retrieve data. Its usage allows multiple fragments - * to be chained together and share data from the output of one fragment to - * the input of another. - * </p> - * - * @param taskModel the task model - * @see #getTaskModel() - */ - public void setTaskModel(TaskModel taskModel) { - this.taskModel = taskModel; - } - - /** - * Returns the wizard task model. - * - * @return the task model - * @see #setTaskModel(TaskModel) - */ - public TaskModel getTaskModel() { - return taskModel; - } - - /** - * Called when the wizard that this fragment belongs to has traversed - * into this wizard fragment. It is called to give the fragment the - * opportunity to initialize any values shown in the composite or - * update the task model. - * <p> - * When finish is pressed, the current fragment is exit()ed, and then - * performFinish() is called on all of the fragments in the tree. - * enter() and exit() are not called on the remaining fragments. - * </p> - */ - public void enter() { - // do nothing - } - - /** - * Called when the wizard that this fragment belongs to has traversed - * out of this wizard fragment. It is called to give the fragment the - * opportunity to save any values entered into the composite or - * update the task model. - * <p> - * When finish is pressed, the current fragment is exit()ed, and then - * performFinish() is called on all of the fragments in the tree. - * enter() and exit() are not called on the remaining fragments. - * </p> - */ - public void exit() { - // do nothing - } - - /** - * Called when the wizard that this fragment belongs to is finished. - * After exit()ing the current page, all fragment's performFinish() - * methods are called in order. - * <p> - * This method is not called on the UI thread and must not access the - * composite. Not only might the user never have accessed the fragment's - * composite, but this method may be called asynchronously on a job - * once the wizard has closed. - * </p> - * - * @param monitor a progress monitor, or <code>null</code> if progress - * reporting and cancellation are not desired - * @throws CoreException if something goes wrong - */ - public void performFinish(IProgressMonitor monitor) throws CoreException { - // do nothing - } - - /** - * Called when the wizard that this fragment belongs to is canceled. - * After exit()ing the current page, all fragment's performCancel() - * methods are called in order. - * <p> - * This method is not called on the UI thread and must not access the - * composite. Not only might the user never have accessed the fragment's - * composite, but this method may be called asynchronously on a job - * once the wizard has closed. - * </p> - * - * @param monitor a progress monitor, or <code>null</code> if progress - * reporting and cancellation are not desired - * @throws CoreException if something goes wrong - */ - public void performCancel(IProgressMonitor monitor) throws CoreException { - // do nothing - } - - /** - * Returns the child fragments. Child fragments come directly after this fragment - * in the wizard flow. - * - * @return a list of child fragments - */ - public List getChildFragments() { - if (listImpl == null) { - listImpl = new ArrayList<WizardFragment>(); - createChildFragments(listImpl); - } - return listImpl; - } - - /** - * Called to give the fragment a chance to update it's child fragments in - * response to other changes within the wizard or task model. - */ - public void updateChildFragments() { - listImpl = null; - } - - /** - * This method is called by the implementation of getChildFragments() to - * allow this fragment to add it's children. This method must cache and - * return the same instance of any child fragment created. If new - * instances are created each time the wizard is updated, the enablement - * state and the flow of the wizard will be incorrect. - * - * @param list a list to add the child fragments to - */ - protected void createChildFragments(List<WizardFragment> list) { - // do nothing - } - - /** - * Returns true if this fragment is complete (can finish). If it is - * complete the user will be allowed to go to the next fragment or - * finish the wizard. If the fragment is not complete, the Next button - * will be disabled. If the fragment is complete but another fragment - * is not complete, the Finish button will not be enabled. - * - * @return <code>true</code> if the fragment is complete, and - * <code>false</code> otherwise - */ - public boolean isComplete() { - return isComplete; - } - - /** - * Set the isComplete state. - * - * @param complete <code>true</code> if the fragment is complete, and - * <code>false</code> otherwise - */ - protected void setComplete(boolean complete) { - this.isComplete = complete; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/wizard/package.html b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/wizard/package.html deleted file mode 100644 index 29657b709..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/wizard/package.html +++ /dev/null @@ -1,22 +0,0 @@ -<html> -<head> -<META http-equiv="Content-Type" content="text/html; charset=UTF-8"> -<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> -<link rel="stylesheet" href="../../../../../..//apistyles.css" type="text/css"> -<title>WTP API overview</title> -</head> -<body> -<p>Wizard and task support for the server tools UI.</p> -<table width="500"> -<tr> -<td> -<p>WizardFragment is extended to provide a subtree of wizard pages or tasks -that can be inserted into a larger wizard flow. TaskWizard is the standard -wizard that knows how to handle WizardFragments and display them in order -within a single wizard. It uses the TaskWizardPages to display the wizard -fragment's composites within the wizard.</p> -</td> -</tr> -</table> -</body> -</html> diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/wizard/package.xml b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/wizard/package.xml deleted file mode 100644 index 9043333d5..000000000 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/wizard/package.xml +++ /dev/null @@ -1,22 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<html> -<head> - <!-- Escape to the root of your source folder --> - <meta - name="root" - content="../../../../../../" /> - <title>WTP API overview</title> -</head> - -<body> - -<abstract>Wizard and task support for the server tools UI.</abstract> - -<p>WizardFragment is extended to provide a subtree of wizard pages or tasks -that can be inserted into a larger wizard flow. TaskWizard is the standard -wizard that knows how to handle WizardFragments and display them in order -within a single wizard. It uses the TaskWizardPages to display the wizard -fragment's composites within the wizard.</p> - -</body> -</html>
\ No newline at end of file |