diff options
Diffstat (limited to 'plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst')
20 files changed, 0 insertions, 4032 deletions
diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/CleanWorkDirDialog.java b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/CleanWorkDirDialog.java deleted file mode 100644 index 6613b94f7..000000000 --- a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/CleanWorkDirDialog.java +++ /dev/null @@ -1,286 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 SAS Institute, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Larry Isaacs - Initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.server.tomcat.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.MultiStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.IJobChangeEvent; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.core.runtime.jobs.JobChangeAdapter; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jst.server.core.IWebModule; -import org.eclipse.jst.server.tomcat.core.internal.ITomcatWebModule; -import org.eclipse.jst.server.tomcat.core.internal.TomcatServerBehaviour; -import org.eclipse.jst.server.tomcat.core.internal.WebModule; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; -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.IServer.IOperationListener; - -/** - * Dialog to confirm deletion of the work directory for a module on a - * server, or the work directory for the entire server. Handling - * includes stopping and restarting the server if it is running at - * the time of the deletion. - * - */ -public class CleanWorkDirDialog extends Dialog { - /** - * Error code when error occurs prior to deletion - */ - public static final int ERROR_PREDELETE = 0; - - /** - * Error code when error occurs during the deletion - */ - public static final int ERROR_DURINGDELETE = 1; - - /** - * Error code when error occurs after deletion - */ - public static final int ERROR_POSTDELETE = 2; - - protected IServer server; - protected IModule module; - protected int state; - protected String mode; - protected IStatus completionStatus = Status.OK_STATUS; - - /** - * Creates a dialog instance confirm deletion of the work directory for a - * module on a server, or the work directory for the entire server. - * - * @param parentShell the parent shell, or <code>null</code> to create a - * top-level shell - * @param server server on which to delete the work directory - * @param module module whose work directory is to be deleted, or <code>null</code> if - * if these server's entire work directory is to be deleted. - */ - public CleanWorkDirDialog(Shell parentShell, IServer server, IModule module) { - super(parentShell); - - if (server == null) - throw new IllegalArgumentException(); - - this.server = server; - this.module = module; - - } - - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - newShell.setText(Messages.confirmCleanWorkDirTitle); - } - - protected Control createDialogArea(Composite parent) { - if (state < 0 || state == IServer.STATE_UNKNOWN) - captureServerState(); - - // create a composite with standard margins and spacing - Composite composite = (Composite)super.createDialogArea(parent); - // Since there are only label widgets on this page, set the help on the parent - PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, ContextIds.SERVER_CLEAN_WORK_DIR); - - Label label = new Label(composite, SWT.WRAP); - if (state == IServer.STATE_STARTING || state == IServer.STATE_STOPPING || state == IServer.STATE_UNKNOWN) { - label.setText(NLS.bind(Messages.cleanServerStateChanging, server.getName())); - } - else { - if (module != null) - label.setText(NLS.bind(Messages.cleanModuleWorkDir, module.getName(), server.getName())); - else - label.setText(NLS.bind(Messages.cleanServerWorkDir, server.getName())); - GridData data = new GridData(); - data.widthHint = 300; - label.setLayoutData(data); - - if (state == IServer.STATE_STARTED) { - label = new Label(composite, SWT.WRAP); - label.setText(Messages.cleanServerRunning); - data = new GridData(); - data.widthHint = 300; - label.setLayoutData(data); - } - } - - applyDialogFont(composite); - return composite; - } - - protected void createButtonsForButtonBar(Composite parent) { - super.createButtonsForButtonBar(parent); - - if (state < 0 || state == IServer.STATE_UNKNOWN) - captureServerState(); - - // If server is transitioning, only allow Cancel - if (state == IServer.STATE_STARTING || state == IServer.STATE_STOPPING) { - Button button = getButton(IDialogConstants.OK_ID); - if (button != null) - button.setEnabled(false); - } - } - - protected void okPressed() { - // Create job to perform the deletion - DeleteWorkDirJob job = new DeleteWorkDirJob(Messages.cleanServerTask); - job.setRule(ServerUtil.getServerSchedulingRule(server)); - - job.addJobChangeListener(new JobChangeAdapter() { - public void done(IJobChangeEvent event) { - IStatus status = event.getResult(); - if (!status.isOK()) { - String title = module != null ? Messages.errorCleanModuleTitle : Messages.errorCleanServerTitle; - String message = "Message unset"; - switch (status.getCode()) { - case CleanWorkDirDialog.ERROR_PREDELETE: - message = module != null ? - NLS.bind(Messages.errorCouldNotCleanModule, module.getName(), server.getName()) : - NLS.bind(Messages.errorCouldNotCleanServer, server.getName()); - break; - case CleanWorkDirDialog.ERROR_DURINGDELETE: - message = module != null ? - NLS.bind(Messages.errorCleanFailedModule, module.getName(), server.getName()) : - NLS.bind(Messages.errorCleanFailedServer, server.getName()); - break; - default: - message = module != null ? - NLS.bind(Messages.errorCleanNoRestartModule, module.getName()) : - NLS.bind(Messages.errorCleanNoRestartServer, server.getName()); - break; - } - TomcatUIPlugin.openError(title, message, status); - } - } - }); - - job.schedule(); - - super.okPressed(); - } - - class DeleteWorkDirJob extends Job { - /** - * @param name name for job - */ - public DeleteWorkDirJob(String name) { - super(name); - } - - /** - * @see Job#belongsTo(Object) - */ - public boolean belongsTo(Object family) { - return ServerUtil.SERVER_JOB_FAMILY.equals(family); - } - - protected IStatus run(IProgressMonitor monitor) { - // If state has changed since dialog was open, abort - if (server.getServerState() != state) { - return newErrorStatus(ERROR_PREDELETE, Messages.errorCouldNotCleanStateChange, null); - } - - IOperationListener listener = new IOperationListener() { - public void done(IStatus result) { - completionStatus = result; - } - }; - boolean restart = false; - IStatus status = Status.OK_STATUS; - // If server isn't stopped, try to stop, clean, and restart - if (state != IServer.STATE_STOPPED) { - status = server.canStop(); - if (!status.isOK()) { - return wrapErrorStatus(status, ERROR_PREDELETE, Messages.errorCouldNotCleanCantStop); - } - - server.stop(false, listener); - - if (!completionStatus.isOK()) { - return wrapErrorStatus(completionStatus, ERROR_PREDELETE, Messages.errorCouldNotCleanStopFailed); - } - if (server.getServerState() != IServer.STATE_STOPPED) { - return newErrorStatus(ERROR_PREDELETE, Messages.errorCouldNotCleanStopFailed, null); - } - restart = true; - } - - // Delete the work directory - TomcatServerBehaviour tsb = (TomcatServerBehaviour)server.loadAdapter( - TomcatServerBehaviour.class, monitor); - try { - if (module != null) { - IWebModule webModule = (IWebModule)module.loadAdapter(IWebModule.class, null); - if (webModule != null) { - ITomcatWebModule tcWebModule = new WebModule(webModule.getContextRoot(), "", "", true); - status = tsb.cleanContextWorkDir(tcWebModule, null); - } - else { - return newErrorStatus(ERROR_DURINGDELETE, - restart ? Messages.errorCantIdentifyWebAppWasRunning : Messages.errorCantIdentifyWebApp, null); - } - } - else { - status = tsb.cleanServerWorkDir(null); - } - } catch (CoreException ce) { - status = ce.getStatus(); - } - if (!status.isOK()) { - return wrapErrorStatus(status, ERROR_DURINGDELETE, - restart ? Messages.errorErrorDuringCleanWasRunning : Messages.errorErrorDuringClean); - } - - if (restart) { - status = server.canStart(mode); - if (!status.isOK()) { - return wrapErrorStatus(status, ERROR_POSTDELETE, Messages.errorCleanCantRestart); - } - server.start(mode, listener); - if (!completionStatus.isOK()) { - return wrapErrorStatus(completionStatus, ERROR_POSTDELETE, Messages.errorCleanRestartFailed); - } - } - return status; - } - } - - private void captureServerState() { - state = server.getServerState(); - if (state != IServer.STATE_STOPPED) { - mode = server.getMode(); - } - } - - protected IStatus newErrorStatus(int errorCode, String message, Throwable throwable) { - return new Status(IStatus.ERROR, TomcatUIPlugin.PLUGIN_ID, errorCode, - message, throwable); - } - - protected IStatus wrapErrorStatus(IStatus status, int errorCode, String message) { - MultiStatus ms = new MultiStatus(TomcatUIPlugin.PLUGIN_ID, errorCode, message, null); - ms.add(status); - return ms; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/ConfigurationPropertyTester.java b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/ConfigurationPropertyTester.java deleted file mode 100644 index 892b2d071..000000000 --- a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/ConfigurationPropertyTester.java +++ /dev/null @@ -1,35 +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.jst.server.tomcat.ui.internal; - -import org.eclipse.core.expressions.PropertyTester; -import org.eclipse.jst.server.tomcat.core.internal.ITomcatServer; -import org.eclipse.jst.server.tomcat.core.internal.TomcatServer; -import org.eclipse.wst.server.core.IServerAttributes; -/** - * - */ -public class ConfigurationPropertyTester 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) { - try { - IServerAttributes server = (IServerAttributes) receiver; - TomcatServer tomcatServer = (TomcatServer) server.loadAdapter(ITomcatServer.class, null); - if (tomcatServer != null) - return tomcatServer.getServerConfiguration() != null; - } catch (Exception e) { - // ignore - } - return false; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/ContextIds.java b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/ContextIds.java deleted file mode 100644 index 4434286f5..000000000 --- a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/ContextIds.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.jst.server.tomcat.ui.internal; -/** - * Constant ids for context help. - */ -public interface ContextIds { - public static final String SERVER_EDITOR = TomcatUIPlugin.PLUGIN_ID + ".teig0000"; - public static final String SERVER_EDITOR_TEST_ENVIRONMENT = TomcatUIPlugin.PLUGIN_ID + ".teig0002"; - public static final String SERVER_EDITOR_SECURE = TomcatUIPlugin.PLUGIN_ID + ".teig0004"; - public static final String SERVER_EDITOR_DEBUG_MODE = TomcatUIPlugin.PLUGIN_ID + ".teig0006"; - - public static final String CONFIGURATION_EDITOR_WEBMODULES = TomcatUIPlugin.PLUGIN_ID + ".tecw0000"; - public static final String CONFIGURATION_EDITOR_WEBMODULES_LIST = TomcatUIPlugin.PLUGIN_ID + ".tecw0002"; - public static final String CONFIGURATION_EDITOR_WEBMODULES_ADD_PROJECT = TomcatUIPlugin.PLUGIN_ID + ".tecw0004"; - public static final String CONFIGURATION_EDITOR_WEBMODULES_ADD_EXTERNAL = TomcatUIPlugin.PLUGIN_ID + ".tecw0006"; - public static final String CONFIGURATION_EDITOR_WEBMODULES_EDIT = TomcatUIPlugin.PLUGIN_ID + ".tecw0008"; - public static final String CONFIGURATION_EDITOR_WEBMODULES_REMOVE = TomcatUIPlugin.PLUGIN_ID + ".tecw0010"; - - public static final String CONFIGURATION_EDITOR_WEBMODULE_DIALOG = TomcatUIPlugin.PLUGIN_ID + ".tdwm0000"; - public static final String CONFIGURATION_EDITOR_WEBMODULE_DIALOG_PROJECT = TomcatUIPlugin.PLUGIN_ID + ".tdpr0002"; - public static final String CONFIGURATION_EDITOR_WEBMODULE_DIALOG_PATH = TomcatUIPlugin.PLUGIN_ID + ".tdpr0004"; - public static final String CONFIGURATION_EDITOR_WEBMODULE_DIALOG_DOCBASE = TomcatUIPlugin.PLUGIN_ID + ".tdpr0006"; - public static final String CONFIGURATION_EDITOR_WEBMODULE_DIALOG_RELOAD = TomcatUIPlugin.PLUGIN_ID + ".tdpr0008"; - - public static final String CONFIGURATION_EDITOR_MAPPINGS = TomcatUIPlugin.PLUGIN_ID + ".tecm0000"; - public static final String CONFIGURATION_EDITOR_MAPPINGS_LIST = TomcatUIPlugin.PLUGIN_ID + ".tecm0002"; - public static final String CONFIGURATION_EDITOR_MAPPINGS_ADD = TomcatUIPlugin.PLUGIN_ID + ".tecm0004"; - public static final String CONFIGURATION_EDITOR_MAPPINGS_EDIT = TomcatUIPlugin.PLUGIN_ID + ".tecm0006"; - public static final String CONFIGURATION_EDITOR_MAPPINGS_REMOVE = TomcatUIPlugin.PLUGIN_ID + ".tecm0008"; - - public static final String CONFIGURATION_EDITOR_MAPPING_DIALOG = TomcatUIPlugin.PLUGIN_ID + ".tdmm0000"; - public static final String CONFIGURATION_EDITOR_MAPPING_DIALOG_TYPE = TomcatUIPlugin.PLUGIN_ID + ".tdmm0002"; - public static final String CONFIGURATION_EDITOR_MAPPING_DIALOG_EXTENSION = TomcatUIPlugin.PLUGIN_ID + ".tdmm0004"; - - public static final String CONFIGURATION_EDITOR_PORTS = TomcatUIPlugin.PLUGIN_ID + ".tecp0000"; - public static final String CONFIGURATION_EDITOR_PORTS_LIST = TomcatUIPlugin.PLUGIN_ID + ".tecp0002"; - - public static final String RUNTIME_COMPOSITE = TomcatUIPlugin.PLUGIN_ID + ".twnr0000"; - - public static final String SERVER_CLEAN_WORK_DIR = TomcatUIPlugin.PLUGIN_ID + ".tvcp0000"; -} diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/ContextPublisherDelegate.java b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/ContextPublisherDelegate.java deleted file mode 100644 index f27e513bb..000000000 --- a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/ContextPublisherDelegate.java +++ /dev/null @@ -1,110 +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.jst.server.tomcat.ui.internal; - -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.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.QualifiedName; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jst.server.core.IWebModule; -import org.eclipse.jst.server.tomcat.core.internal.TomcatConfiguration; -import org.eclipse.jst.server.tomcat.core.internal.TomcatServer; -import org.eclipse.jst.server.tomcat.core.internal.WebModule; -import org.eclipse.osgi.util.NLS; -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.TaskModel; -import org.eclipse.wst.server.core.model.PublisherDelegate; - -public class ContextPublisherDelegate extends PublisherDelegate { - private static final QualifiedName QUALIFIED_NAME = new QualifiedName(TomcatUIPlugin.PLUGIN_ID, "contextRoot"); - - public IStatus execute(int kind, IProgressMonitor monitor, IAdaptable info) throws CoreException { - // this publisher only runs when there is a UI - if (info == null) - return Status.OK_STATUS; - - final Shell shell = (Shell) info.getAdapter(Shell.class); - if (shell == null) - return Status.OK_STATUS; - - IServer server = (IServer) getTaskModel().getObject(TaskModel.TASK_SERVER); - TomcatServer tomcatServer = (TomcatServer) server.loadAdapter(TomcatServer.class, monitor); - final TomcatConfiguration configuration = tomcatServer.getTomcatConfiguration(); - - final boolean[] save = new boolean[1]; - List modules = (List) getTaskModel().getObject(TaskModel.TASK_MODULES); - int size = modules.size(); - for (int i = 0; i < size; i++) { - IModule[] module = (IModule[]) modules.get(i); - final IModule m = module[module.length - 1]; - IWebModule webModule = (IWebModule) m.loadAdapter(IWebModule.class, monitor); - final WebModule webModule2 = configuration.getWebModule(m); - if (webModule != null && webModule2 != null) { - String contextRoot = webModule.getContextRoot(); - if (contextRoot != null && !contextRoot.startsWith("/") && contextRoot.length() > 0) - contextRoot = "/" + contextRoot; - - if (!contextRoot.equals(webModule2.getPath()) && shouldPrompt(m, contextRoot)) { - final String context = contextRoot; - shell.getDisplay().syncExec(new Runnable() { - public void run() { - if (MessageDialog.openQuestion(shell, Messages.wizardTitle, NLS.bind(Messages.contextCleanup, m.getName()))) { - int index = configuration.getWebModules().indexOf(webModule2); - configuration.modifyWebModule(index, webModule2.getDocumentBase(), context, webModule2.isReloadable()); - save[0] = true; - } - } - }); - markProject(m, contextRoot); - } - } - } - if (save[0]) - tomcatServer.saveConfiguration(monitor); - - return Status.OK_STATUS; - } - - protected boolean shouldPrompt(IModule m, String contextRoot) { - IProject project = m.getProject(); - if (project == null) - return true; - - try { - String s = project.getPersistentProperty(QUALIFIED_NAME); - if (s == null) - return true; - return !contextRoot.equals(s); - } catch (CoreException ce) { - return true; - } - } - - protected void markProject(IModule m, String contextRoot) { - IProject project = m.getProject(); - if (project == null) - return; - - try { - project.setPersistentProperty(QUALIFIED_NAME, contextRoot); - } catch (CoreException ce) { - // ignore, it's ok to prompt again later - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/Messages.java b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/Messages.java deleted file mode 100644 index 32cc0aa81..000000000 --- a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/Messages.java +++ /dev/null @@ -1,123 +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.jst.server.tomcat.ui.internal; - -import org.eclipse.osgi.util.NLS; -/** - * Translated messages. - */ -public class Messages extends NLS { - public static String wizardTitle; - public static String wizardDescription; - public static String runtimeName; - public static String installDir; - public static String browse; - public static String install; - public static String selectInstallDir; - public static String installedJRE; - public static String installedJREs; - public static String runtimeDefaultJRE; - public static String editorAdd; - public static String editorEdit; - public static String editorRemove; - public static String editorBrowse; - public static String errorMissingWebModule; - public static String configurationEditorMimeMappingsSection; - public static String configurationEditorMimeMappingsDescription; - public static String configurationEditorPortsSection; - public static String configurationEditorPortsDescription; - public static String configurationEditorPortNameColumn; - public static String configurationEditorPortValueColumn; - public static String configurationEditorWebModulesPageTitle; - public static String configurationEditorWebModulesSection; - public static String configurationEditorWebModulesDescription; - public static String configurationEditorPathColumn; - public static String configurationEditorDocBaseColumn; - public static String configurationEditorProjectColumn; - public static String configurationEditorReloadColumn; - public static String configurationEditorAddProjectModule; - public static String configurationEditorAddExternalModule; - public static String configurationEditorProjectMissing; - public static String configurationEditorReloadEnabled; - public static String configurationEditorReloadDisabled; - public static String configurationEditorMimeMapppingDialogTitleEdit; - public static String configurationEditorMimeMapppingDialogTitleAdd; - public static String configurationEditorMimeMapppingDialogMimeType; - public static String configurationEditorMimeMapppingDialogMimeExtension; - public static String serverEditorLocationsSection; - public static String serverEditorLocationsDescription; - public static String serverEditorLocationsDescription2; - public static String serverEditorGeneralSection; - public static String serverEditorGeneralDescription; - public static String serverEditorServerDirMetadata; - public static String serverEditorServerDirInstall; - public static String serverEditorServerDirCustom; - public static String serverEditorSetInternalServerDirLink; - public static String serverEditorSetInternalServerDirLink2; - public static String serverEditorSetInstallServerDirLink; - public static String serverEditorSetInstallServerDirLink2; - public static String serverEditorSetDefaultDeployDirLink; - public static String serverEditorSetDefaultDeployDirLink2; - public static String serverEditorServerDir; - public static String serverEditorDeployDir; - public static String serverEditorTestEnvironment; - public static String serverEditorNoPublish; - public static String serverEditorSeparateContextFiles; - public static String serverEditorSecure; - public static String serverEditorDebugMode; - public static String serverEditorNotSupported; - public static String serverEditorDoesNotModify; - public static String serverEditorTakesControl; - public static String errorServerMustBeStopped; - public static String errorServerDirIsRoot; - public static String errorServerDirUnderRoot; - public static String errorServerDirCustomNotMetadata; - public static String errorServerDirCustomNotInstall; - public static String errorDeployDirNotSpecified; - public static String serverEditorBrowseServerMessage; - public static String serverEditorBrowseDeployMessage; - public static String configurationEditorWebModuleDialogTitleEdit; - public static String configurationEditorWebModuleDialogTitleAdd; - public static String configurationEditorWebModuleDialogProjects; - public static String configurationEditorWebModuleDialogDocumentBase; - public static String configurationEditorWebModuleDialogSelectDirectory; - public static String configurationEditorWebModuleDialogPath; - public static String configurationEditorWebModuleDialogReloadEnabled; - public static String errorDefaultDialogTitle; - public static String confirmCleanWorkDirTitle; - public static String cleanServerStateChanging; - public static String cleanModuleWorkDir; - public static String cleanServerWorkDir; - public static String cleanServerRunning; - public static String cleanServerTask; - public static String errorCleanModuleTitle; - public static String errorCleanServerTitle; - public static String errorCouldNotCleanModule; - public static String errorCouldNotCleanServer; - public static String errorCouldNotCleanStateChange; - public static String errorCouldNotCleanCantStop; - public static String errorCouldNotCleanStopFailed; - public static String errorCleanFailedModule; - public static String errorCleanFailedServer; - public static String errorCantIdentifyWebApp; - public static String errorCantIdentifyWebAppWasRunning; - public static String errorErrorDuringClean; - public static String errorErrorDuringCleanWasRunning; - public static String errorCleanNoRestartModule; - public static String errorCleanNoRestartServer; - public static String errorCleanCantRestart; - public static String errorCleanRestartFailed; - public static String contextCleanup; - - static { - NLS.initializeMessages(TomcatUIPlugin.PLUGIN_ID + ".internal.Messages", Messages.class); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/Messages.properties b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/Messages.properties deleted file mode 100644 index 67bee61db..000000000 --- a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/Messages.properties +++ /dev/null @@ -1,152 +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 -############################################################################### - -# --------------- General UI --------------- - -runtimeName=Na&me: -browse=B&rowse... -install=Download and Install... -installDir=Tomcat installation &directory: -installedJRE=&JRE: -installedJREs=&Installed JREs... -selectInstallDir=Select Tomcat installation directory. -runtimeDefaultJRE=Workbench default JRE -contextCleanup=The context root of module {0} has been modified. Do you want to update the server configuration to match? - -# New Tomcat server wizard -wizardTitle=Tomcat Server -wizardDescription=Specify the installation directory - -# --------------- Editors --------------- - -# General text used in both editors -editorRemove=Remove -editorAdd=Add... -editorEdit=Edit... -editorBrowse=Browse... - -# --- Configuration Editor --- -configurationEditorWebModulesPageTitle=Web Modules -configurationEditorWebModulesSection=Web Modules -configurationEditorWebModulesDescription=Configure the Web Modules on this server. -configurationEditorMimeMappingsSection=MIME Mappings -configurationEditorMimeMappingsDescription=Configure MIME type mappings. -configurationEditorPortsSection=Ports -configurationEditorPortsDescription=Modify the server ports. - -# Fields -configurationEditorPortNameColumn=Port Name -configurationEditorPortValueColumn=Port Number -configurationEditorPathColumn=Path -configurationEditorDocBaseColumn=Document Base -configurationEditorProjectColumn=Module -configurationEditorReloadColumn=Auto Reload -configurationEditorProjectMissing={0} missing -configurationEditorReloadEnabled=Enabled -configurationEditorReloadDisabled=Disabled -configurationEditorAddProjectModule=Add Web Module... -configurationEditorAddExternalModule=Add External Web Module... - -# Add/Edit Mime Mapping dialog -configurationEditorMimeMapppingDialogTitleEdit=Edit MIME Mapping -configurationEditorMimeMapppingDialogTitleAdd=Add MIME Mapping -configurationEditorMimeMapppingDialogMimeType=MIME &type: -configurationEditorMimeMapppingDialogMimeExtension=MIME &extension: - -# Add/Edit Web Module dialog -configurationEditorWebModuleDialogTitleEdit=Edit Web Module -configurationEditorWebModuleDialogTitleAdd=Add Web Module -configurationEditorWebModuleDialogProjects=&Modules: -configurationEditorWebModuleDialogPath=P&ath: -configurationEditorWebModuleDialogDocumentBase=&Document base: -configurationEditorWebModuleDialogReloadEnabled=Auto r&eloading enabled -configurationEditorWebModuleDialogSelectDirectory=Select the Web module directory. -errorMissingWebModule=The Web module at the following location cannot be found: {0}. - -# --- Server Editor --- -serverEditorLocationsSection=Server Locations -serverEditorLocationsDescription=Specify the server and deploy paths. Server must be published with no modules present to make changes. -serverEditorLocationsDescription2=Specify the server path (i.e. catalina.base) and deploy path. Server must be published with no modules present to make changes. -serverEditorGeneralSection=Server Options -serverEditorGeneralDescription=Enter settings for the server. - -# Link Fields -serverEditorSetInternalServerDirLink=Set server path to internally supplied location -serverEditorSetInternalServerDirLink2=Set server path to internally supplied location (currently set) -serverEditorSetInstallServerDirLink=Set server path to the location of the Tomcat installation -serverEditorSetInstallServerDirLink2=Set server path to the location of the Tomcat installation (currently set) -serverEditorSetDefaultDeployDirLink=Set deploy path to the default value -serverEditorSetDefaultDeployDirLink2=Set deploy path to the default value (currently set) - -# Fields -# Note: The argument for the following three strings will be the string for -# one of serverEditorDoesNotModify or serverEditorTakesControl or and empty string. -serverEditorServerDirMetadata=Use workspace metadata {0} -serverEditorServerDirInstall=Use Tomcat installation {0} -serverEditorServerDirCustom=Use custom location {0} -serverEditorServerDir=Server path: -serverEditorDeployDir=Deploy path: -serverEditorSecure=Enable security -# Note: The argument for the following string will be the serverEditorNotSupported string or an empty string -serverEditorDebugMode=Enable Tomcat debug logging {0} -serverEditorTestEnvironment=Run modules directly from the workspace (do not modify the Tomcat installation) -# Note: The argument for the following string will be the serverEditorNotSupported string or an empty string -serverEditorNoPublish=Serve modules without publishing {0} -serverEditorSeparateContextFiles=Publish module contexts to separate XML files {0} -errorServerDirIsRoot=The server path may not be set to the the root of your workspace. -errorServerDirUnderRoot=The server path may not be under the \"{0}\" folder of your workspace unless it is the workspace metadata location. -# Note: The argument for the following string will be the string for serverEditorServerDirMetadata with a blank string for its argument -errorServerDirCustomNotMetadata=Only the \"{0}\" selection may set the server path to the workspace metadata location. -# Note: The argument for the following string will be the string for serverEditorServerDirInstall with a blank string for its argument -errorServerDirCustomNotInstall=Only the \"{0}\" selection may set the server path to the Tomcat installation. -errorDeployDirNotSpecified=A deploy path must be specified. -serverEditorNotSupported=(not supported by this Tomcat version) -serverEditorDoesNotModify=(does not modify Tomcat installation) -serverEditorTakesControl=(takes control of Tomcat installation) -errorServerMustBeStopped=The server must be stopped before a change to the \"{0}\" setting can be saved. - -# Browse for Server dialog -serverEditorBrowseServerMessage=Select a server directory. - -# Browse for Deploy dialog -serverEditorBrowseDeployMessage=Select a deploy directory. - -# --- Clean Work Directory --- -confirmCleanWorkDirTitle=Confirm Clean -cleanServerStateChanging=The state of {0} is in transition or unknown. Try again when the server has reached a stable state. -cleanModuleWorkDir=Clean work directory for module {0} on {1}. -cleanServerWorkDir=Clean work directories for all Web applications on {0}. -cleanServerRunning=The server must be stopped to clean the work directory. Clicking OK will include stopping and restarting the server. -cleanServerTask=Cleaning server work directory... - -# --- Error Strings --- -errorDefaultDialogTitle=Tomcat Server Error - -# --- Clean Work Directory Errors --- -errorCleanModuleTitle=Clean Module Work Directory Error -errorCleanServerTitle=Clean Server Work Directory Error -errorCouldNotCleanModule=Could not clean {0} work directory on {1}. -errorCouldNotCleanServer=Could not clean work directory on {0}. -errorCouldNotCleanStateChange=Clean aborted because the server changed state after confirmation dialog was displayed. -errorCouldNotCleanCantStop="Server can not be stopped at this time. Try again when the server is stopped or can be stopped. -errorCouldNotCleanStopFailed=Server failed to stop. Try again when the server is stopped or can be stopped. - -errorCleanFailedModule=Clean failed for {0} work directory on {1}. -errorCleanFailedServer=Clean failed for work directory on {0}. -errorCantIdentifyWebApp=Selected module could not be associated with a Web application on the server. -errorCantIdentifyWebAppWasRunning=Selected module could not be associated with a Web application on the server. Server will not be restarted. -errorErrorDuringClean=An error occurred while cleaning the work directory. -errorErrorDuringCleanWasRunning=An error occurred while cleaning the work directory. Server will not be restarted. - -errorCleanNoRestartModule=Module {0} was successfully cleaned, but server is unable to restart. -errorCleanNoRestartServer=Server {0} was successfully cleaned, but is unable to restart. -errorCleanCantRestart=Server is unable to restart at this time. -errorCleanRestartFailed=Server restart was not successful or did not complete in the expected amount of time. diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/SWTUtil.java b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/SWTUtil.java deleted file mode 100644 index cbe03c563..000000000 --- a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/SWTUtil.java +++ /dev/null @@ -1,62 +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.jst.server.tomcat.ui.internal; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.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; -/** - * 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); - data.widthHint = getButtonWidthHint(b); - b.setLayoutData(data); - return b; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/TomcatLaunchConfigurationTabGroup.java b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/TomcatLaunchConfigurationTabGroup.java deleted file mode 100644 index 4c6f725a2..000000000 --- a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/TomcatLaunchConfigurationTabGroup.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.jst.server.tomcat.ui.internal; - -import org.eclipse.debug.ui.*; -import org.eclipse.debug.ui.sourcelookup.SourceLookupTab; -import org.eclipse.jdt.debug.ui.launchConfigurations.JavaArgumentsTab; -import org.eclipse.jdt.debug.ui.launchConfigurations.JavaClasspathTab; - -import org.eclipse.wst.server.ui.ServerLaunchConfigurationTab; -/** - * A debug tab group for launching Tomcat. - */ -public class TomcatLaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup { - /* - * @see ILaunchConfigurationTabGroup#createTabs(ILaunchConfigurationDialog, String) - */ - public void createTabs(ILaunchConfigurationDialog dialog, String mode) { - ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[6]; - tabs[0] = new ServerLaunchConfigurationTab(new String[] { "org.eclipse.jst.server.tomcat" }); - tabs[0].setLaunchConfigurationDialog(dialog); - tabs[1] = new JavaArgumentsTab(); - tabs[1].setLaunchConfigurationDialog(dialog); - tabs[2] = new JavaClasspathTab(); - tabs[2].setLaunchConfigurationDialog(dialog); - tabs[3] = new SourceLookupTab(); - tabs[3].setLaunchConfigurationDialog(dialog); - tabs[4] = new EnvironmentTab(); - tabs[4].setLaunchConfigurationDialog(dialog); - tabs[5] = new CommonTab(); - tabs[5].setLaunchConfigurationDialog(dialog); - setTabs(tabs); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/TomcatRuntimeComposite.java b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/TomcatRuntimeComposite.java deleted file mode 100644 index 9df213b31..000000000 --- a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/TomcatRuntimeComposite.java +++ /dev/null @@ -1,346 +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.jst.server.tomcat.ui.internal; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.jdt.launching.IVMInstall; -import org.eclipse.jdt.launching.IVMInstallType; -import org.eclipse.jdt.launching.JavaRuntime; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IMessageProvider; -import org.eclipse.jface.preference.IPreferenceNode; -import org.eclipse.jface.preference.PreferenceDialog; -import org.eclipse.jface.preference.PreferenceManager; -import org.eclipse.jface.window.Window; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.jst.server.tomcat.core.internal.ITomcatRuntimeWorkingCopy; -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.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.DirectoryDialog; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.PlatformUI; - -import org.eclipse.wst.server.core.IRuntimeWorkingCopy; -import org.eclipse.wst.server.core.TaskModel; -import org.eclipse.wst.server.core.internal.IInstallableRuntime; -import org.eclipse.wst.server.core.internal.ServerPlugin; -import org.eclipse.wst.server.ui.internal.wizard.TaskWizard; -import org.eclipse.wst.server.ui.internal.wizard.fragment.LicenseWizardFragment; -import org.eclipse.wst.server.ui.wizard.IWizardHandle; -import org.eclipse.wst.server.ui.wizard.WizardFragment; -/** - * Wizard page to set the server install directory. - */ -public class TomcatRuntimeComposite extends Composite { - protected IRuntimeWorkingCopy runtimeWC; - protected ITomcatRuntimeWorkingCopy runtime; - - protected IWizardHandle wizard; - - protected Text installDir; - protected Text name; - protected Combo combo; - protected List installedJREs; - protected String[] jreNames; - protected IInstallableRuntime ir; - protected Label installLabel; - protected Button install; - - /** - * TomcatRuntimeWizardPage constructor comment. - * - * @param parent the parent composite - * @param wizard the wizard handle - */ - protected TomcatRuntimeComposite(Composite parent, IWizardHandle wizard) { - super(parent, SWT.NONE); - this.wizard = wizard; - - wizard.setTitle(Messages.wizardTitle); - wizard.setDescription(Messages.wizardDescription); - wizard.setImageDescriptor(TomcatUIPlugin.getImageDescriptor(TomcatUIPlugin.IMG_WIZ_TOMCAT)); - - createControl(); - } - - protected void setRuntime(IRuntimeWorkingCopy newRuntime) { - if (newRuntime == null) { - runtimeWC = null; - runtime = null; - } else { - runtimeWC = newRuntime; - runtime = (ITomcatRuntimeWorkingCopy) newRuntime.loadAdapter(ITomcatRuntimeWorkingCopy.class, null); - } - - if (runtimeWC == null) { - ir = null; - install.setEnabled(false); - installLabel.setText(""); - } else { - ir = ServerPlugin.findInstallableRuntime(runtimeWC.getRuntimeType().getId()); - install.setEnabled(true); - installLabel.setText(ir.getName()); - } - - init(); - validate(); - } - - /** - * Provide a wizard page to change the Tomcat installation directory. - */ - protected void createControl() { - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - setLayout(layout); - setLayoutData(new GridData(GridData.FILL_BOTH)); - PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ContextIds.RUNTIME_COMPOSITE); - - Label label = new Label(this, SWT.NONE); - label.setText(Messages.runtimeName); - GridData data = new GridData(); - data.horizontalSpan = 2; - label.setLayoutData(data); - - name = new Text(this, SWT.BORDER); - data = new GridData(GridData.FILL_HORIZONTAL); - name.setLayoutData(data); - name.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - runtimeWC.setName(name.getText()); - validate(); - } - }); - - label = new Label(this, SWT.NONE); - label.setText(Messages.installDir); - data = new GridData(); - data.horizontalSpan = 2; - label.setLayoutData(data); - - installDir = new Text(this, SWT.BORDER); - data = new GridData(GridData.FILL_HORIZONTAL); - installDir.setLayoutData(data); - installDir.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - runtimeWC.setLocation(new Path(installDir.getText())); - validate(); - } - }); - - Button browse = SWTUtil.createButton(this, Messages.browse); - browse.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent se) { - DirectoryDialog dialog = new DirectoryDialog(TomcatRuntimeComposite.this.getShell()); - dialog.setMessage(Messages.selectInstallDir); - dialog.setFilterPath(installDir.getText()); - String selectedDirectory = dialog.open(); - if (selectedDirectory != null) - installDir.setText(selectedDirectory); - } - }); - - installLabel = new Label(this, SWT.RIGHT); - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalIndent = 10; - installLabel.setLayoutData(data); - - install = SWTUtil.createButton(this, Messages.install); - install.setEnabled(false); - install.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent se) { - String license = null; - try { - license = ir.getLicense(new NullProgressMonitor()); - } catch (CoreException e) { - Trace.trace(Trace.SEVERE, "Error getting license", e); - } - TaskModel taskModel = new TaskModel(); - taskModel.putObject(LicenseWizardFragment.LICENSE, license); - TaskWizard wizard2 = new TaskWizard(Messages.install, new WizardFragment() { - protected void createChildFragments(List list) { - list.add(new LicenseWizardFragment()); - } - }, taskModel); - - WizardDialog dialog2 = new WizardDialog(getShell(), wizard2); - if (dialog2.open() == Window.CANCEL) - return; - - - DirectoryDialog dialog = new DirectoryDialog(TomcatRuntimeComposite.this.getShell()); - dialog.setMessage(Messages.selectInstallDir); - dialog.setFilterPath(installDir.getText()); - String selectedDirectory = dialog.open(); - if (selectedDirectory != null) { - ir.install(new Path(selectedDirectory)); - installDir.setText(selectedDirectory); - } - } - }); - - updateJREs(); - - // JDK location - label = new Label(this, SWT.NONE); - label.setText(Messages.installedJRE); - data = new GridData(); - data.horizontalSpan = 2; - label.setLayoutData(data); - - combo = new Combo(this, SWT.DROP_DOWN | SWT.READ_ONLY); - combo.setItems(jreNames); - data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - combo.setLayoutData(data); - - combo.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - int sel = combo.getSelectionIndex(); - IVMInstall vmInstall = null; - if (sel > 0) - vmInstall = (IVMInstall) installedJREs.get(sel - 1); - - runtime.setVMInstall(vmInstall); - validate(); - } - - public void widgetDefaultSelected(SelectionEvent e) { - widgetSelected(e); - } - }); - - Button button = SWTUtil.createButton(this, Messages.installedJREs); - button.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - String currentVM = combo.getText(); - if (showPreferencePage()) { - updateJREs(); - combo.setItems(jreNames); - combo.setText(currentVM); - if (combo.getSelectionIndex() == -1) - combo.select(0); - validate(); - } - } - }); - - init(); - validate(); - - Dialog.applyDialogFont(this); - - name.forceFocus(); - } - - protected void updateJREs() { - // get all installed JVMs - installedJREs = new ArrayList(); - IVMInstallType[] vmInstallTypes = JavaRuntime.getVMInstallTypes(); - int size = vmInstallTypes.length; - for (int i = 0; i < size; i++) { - IVMInstall[] vmInstalls = vmInstallTypes[i].getVMInstalls(); - int size2 = vmInstalls.length; - for (int j = 0; j < size2; j++) { - installedJREs.add(vmInstalls[j]); - } - } - - // get names - size = installedJREs.size(); - jreNames = new String[size+1]; - jreNames[0] = Messages.runtimeDefaultJRE; - for (int i = 0; i < size; i++) { - IVMInstall vmInstall = (IVMInstall) installedJREs.get(i); - jreNames[i+1] = vmInstall.getName(); - } - } - - protected boolean showPreferencePage() { - String id = "org.eclipse.jdt.debug.ui.preferences.VMPreferencePage"; - - // should be using the following API, but it only allows a single preference page instance. - // see bug 168211 for details - //PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getShell(), id, new String[] { id }, null); - //return (dialog.open() == Window.OK); - - PreferenceManager manager = PlatformUI.getWorkbench().getPreferenceManager(); - IPreferenceNode node = manager.find("org.eclipse.jdt.ui.preferences.JavaBasePreferencePage").findSubNode(id); - PreferenceManager manager2 = new PreferenceManager(); - manager2.addToRoot(node); - PreferenceDialog dialog = new PreferenceDialog(getShell(), manager2); - dialog.create(); - return (dialog.open() == Window.OK); - } - - protected void init() { - if (name == null || runtime == null) - return; - - if (runtimeWC.getName() != null) - name.setText(runtimeWC.getName()); - else - name.setText(""); - - if (runtimeWC.getLocation() != null) - installDir.setText(runtimeWC.getLocation().toOSString()); - else - installDir.setText(""); - - // set selection - if (runtime.isUsingDefaultJRE()) - combo.select(0); - else { - boolean found = false; - int size = installedJREs.size(); - for (int i = 0; i < size; i++) { - IVMInstall vmInstall = (IVMInstall) installedJREs.get(i); - if (vmInstall.equals(runtime.getVMInstall())) { - combo.select(i + 1); - found = true; - } - } - if (!found) - combo.select(0); - } - } - - protected void validate() { - if (runtime == null) { - wizard.setMessage("", IMessageProvider.ERROR); - return; - } - - IStatus status = runtimeWC.validate(null); - if (status == null || status.isOK()) - wizard.setMessage(null, IMessageProvider.NONE); - else if (status.getSeverity() == IStatus.WARNING) - wizard.setMessage(status.getMessage(), IMessageProvider.WARNING); - else - wizard.setMessage(status.getMessage(), IMessageProvider.ERROR); - wizard.update(); - } -} diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/TomcatRuntimeWizardFragment.java b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/TomcatRuntimeWizardFragment.java deleted file mode 100644 index 57fd3605f..000000000 --- a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/TomcatRuntimeWizardFragment.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.jst.server.tomcat.ui.internal; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jst.server.tomcat.core.internal.TomcatPlugin; -import org.eclipse.swt.widgets.Composite; - -import org.eclipse.wst.server.core.IRuntimeWorkingCopy; -import org.eclipse.wst.server.core.TaskModel; -import org.eclipse.wst.server.ui.wizard.IWizardHandle; -import org.eclipse.wst.server.ui.wizard.WizardFragment; -/** - * - */ -public class TomcatRuntimeWizardFragment extends WizardFragment { - protected TomcatRuntimeComposite comp; - - public TomcatRuntimeWizardFragment() { - // do nothing - } - - public boolean hasComposite() { - return true; - } - - public boolean isComplete() { - IRuntimeWorkingCopy runtime = (IRuntimeWorkingCopy) getTaskModel().getObject(TaskModel.TASK_RUNTIME); - - if (runtime == null) - return false; - IStatus status = runtime.validate(null); - return (status == null || status.getSeverity() != IStatus.ERROR); - } - - /* (non-Javadoc) - * @see org.eclipse.wst.server.ui.task.WizardFragment#createComposite() - */ - public Composite createComposite(Composite parent, IWizardHandle wizard) { - comp = new TomcatRuntimeComposite(parent, wizard); - return comp; - } - - public void enter() { - if (comp != null) { - IRuntimeWorkingCopy runtime = (IRuntimeWorkingCopy) getTaskModel().getObject(TaskModel.TASK_RUNTIME); - comp.setRuntime(runtime); - } - } - - public void exit() { - IRuntimeWorkingCopy runtime = (IRuntimeWorkingCopy) getTaskModel().getObject(TaskModel.TASK_RUNTIME); - IPath path = runtime.getLocation(); - if (runtime.validate(null).getSeverity() != IStatus.ERROR) - TomcatPlugin.setPreference("location" + runtime.getRuntimeType().getId(), path.toString()); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/TomcatUIPlugin.java b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/TomcatUIPlugin.java deleted file mode 100644 index 7ba3bdcdf..000000000 --- a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/TomcatUIPlugin.java +++ /dev/null @@ -1,177 +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.jst.server.tomcat.ui.internal; - -import java.net.URL; -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.ImageRegistry; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.plugin.AbstractUIPlugin; -/** - * The actual Tomcat plugin. It allows the rest of the classes - * to load images and get a handle to the desktop. - */ -public class TomcatUIPlugin extends AbstractUIPlugin { - protected static TomcatUIPlugin singleton; - - protected Map imageDescriptors = new HashMap(); - - // base url for icons - private static URL ICON_BASE_URL; - - private static final String URL_OBJ = "obj16/"; - private static final String URL_WIZBAN = "wizban/"; - - public static final String PLUGIN_ID = "org.eclipse.jst.server.tomcat.ui"; - - public static final String IMG_WIZ_TOMCAT = "wizTomcat"; - - public static final String IMG_WEB_MODULE = "webModule"; - public static final String IMG_MIME_MAPPING = "mimeMapping"; - public static final String IMG_MIME_EXTENSION = "mimeExtension"; - public static final String IMG_PORT = "port"; - public static final String IMG_PROJECT_MISSING = "projectMissing"; - - public static final String PREF_TOMCAT32_INSTALL_DIR = "tomcat32install"; - public static final String PREF_TOMCAT40_INSTALL_DIR = "tomcat40install"; - public static final String PREF_TOMCAT41_INSTALL_DIR = "tomcat41install"; - public static final String PREF_TOMCAT50_INSTALL_DIR = "tomcat50install"; - public static final String PREF_JDK_INSTALL_DIR = "jdkinstall"; - - /** - * TomcatUIPlugin constructor comment. - */ - public TomcatUIPlugin() { - super(); - singleton = this; - } - - protected ImageRegistry createImageRegistry() { - ImageRegistry registry = new ImageRegistry(); - - registerImage(registry, IMG_WIZ_TOMCAT, URL_WIZBAN + "tomcat_wiz.png"); - - registerImage(registry, IMG_WEB_MODULE, URL_OBJ + "web_module.gif"); - registerImage(registry, IMG_MIME_MAPPING, URL_OBJ + "mime_mapping.gif"); - registerImage(registry, IMG_MIME_EXTENSION, URL_OBJ + "mime_extension.gif"); - registerImage(registry, IMG_PORT, URL_OBJ + "port.gif"); - registerImage(registry, IMG_PROJECT_MISSING, URL_OBJ + "project_missing.gif"); - - return registry; - } - - /** - * Return the image with the given key from the image registry. - * @param key java.lang.String - * @return org.eclipse.jface.parts.IImage - */ - public static Image getImage(String key) { - return getInstance().getImageRegistry().get(key); - } - - /** - * Return the image with the given key from the image registry. - * @param key java.lang.String - * @return org.eclipse.jface.parts.IImage - */ - public static ImageDescriptor getImageDescriptor(String key) { - try { - getInstance().getImageRegistry(); - return (ImageDescriptor) getInstance().imageDescriptors.get(key); - } catch (Exception e) { - return null; - } - } - - /** - * Returns the singleton instance of this plugin. - * @return org.eclipse.jst.server.tomcat.internal.TomcatUIPlugin - */ - public static TomcatUIPlugin getInstance() { - return singleton; - } - - /** - * Convenience method for logging. - * - * @param status org.eclipse.core.runtime.IStatus - */ - public static void log(IStatus status) { - getInstance().getLog().log(status); - } - - /** - * Convenience method to get a Display. 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; - } - - /** - * Convenience method to display an error dialog. - * - * @param title title for the dialog or null for default title - * @param message primary message to display - * @param status reason for the error - */ - public static void openError(final String title, final String message, final IStatus status) { - Display.getDefault().asyncExec(new Runnable() { - public void run() { - Shell shell = getShell(); - ErrorDialog.openError(shell, - title != null ? title : Messages.errorDefaultDialogTitle, - message, status); - } - }); - } - /** - * Convenience method to get a shell - * - * @return Shell - */ - public static Shell getShell() { - return getStandardDisplay().getActiveShell(); - } - - /** - * Register an image with the registry. - * @param key java.lang.String - * @param partialURL java.lang.String - */ - private void registerImage(ImageRegistry registry, String key, String partialURL) { - if (ICON_BASE_URL == null) { - String pathSuffix = "icons/"; - ICON_BASE_URL = singleton.getBundle().getEntry(pathSuffix); - } - - try { - ImageDescriptor id = ImageDescriptor.createFromURL(new URL(ICON_BASE_URL, partialURL)); - registry.put(key, id); - imageDescriptors.put(key, id); - } catch (Exception e) { - Trace.trace(Trace.WARNING, "Error registering image", e); - } - } -} diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/Trace.java b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/Trace.java deleted file mode 100644 index f57a875a0..000000000 --- a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/Trace.java +++ /dev/null @@ -1,54 +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.jst.server.tomcat.ui.internal; -/** - * Helper class to route trace output. - */ -public class Trace { - public static final byte CONFIG = 0; - public static final byte WARNING = 1; - public static final byte SEVERE = 2; - public static final byte FINEST = 3; - public static final byte FINER = 4; - - /** - * Trace constructor comment. - */ - private Trace() { - super(); - } - - /** - * Trace the given text. - * - * @param level the trace level - * @param s a message - */ - public static void trace(byte level, String s) { - Trace.trace(level, s, null); - } - - /** - * Trace the given message and exception. - * - * @param level the trace level - * @param s a message - * @param t a throwable - */ - public static void trace(byte level, String s, Throwable t) { - if (!TomcatUIPlugin.getInstance().isDebugging()) - return; - - System.out.println(TomcatUIPlugin.PLUGIN_ID + " " + s); - if (t != null) - t.printStackTrace(); - } -} diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/actions/CleanWorkDirAction.java b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/actions/CleanWorkDirAction.java deleted file mode 100644 index 7ea36ce29..000000000 --- a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/actions/CleanWorkDirAction.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 SAS Institute, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Larry Isaacs - Initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.server.tomcat.ui.internal.actions; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jst.server.tomcat.ui.internal.CleanWorkDirDialog; -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.ui.IServerModule; - -/** - * Action to delete Tomcat server work directories - */ -public class CleanWorkDirAction implements IObjectActionDelegate { - private IWorkbenchPart targetPart; - private IServer selectedServer; - private IModule selectedModule; - - /** - * Constructor for Action1. - */ - public CleanWorkDirAction() { - super(); - } - - /** - * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart) - */ - public void setActivePart(IAction action, IWorkbenchPart targetPart) { - this.targetPart = targetPart; - } - - /** - * @see org.eclipse.ui.IActionDelegate#run(IAction) - */ - public void run(IAction action) { - CleanWorkDirDialog dlg = new CleanWorkDirDialog(targetPart.getSite().getShell(), selectedServer, selectedModule); - dlg.open(); - } - - /** - * @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection) - */ - public void selectionChanged(IAction action, ISelection selection) { - selectedServer = null; - selectedModule = null; - if (!selection.isEmpty()) { - if (selection instanceof IStructuredSelection) { - Object obj = ((IStructuredSelection)selection).getFirstElement(); - if (obj instanceof IServer) { - selectedServer = (IServer)obj; - } - else if (obj instanceof IServerModule) { - IServerModule sm = (IServerModule)obj; - IModule [] module = sm.getModule(); - selectedModule = module[module.length - 1]; - if (selectedModule != null) - selectedServer = sm.getServer(); - } - } - } - } -} diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ConfigurationMimeEditorSection.java b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ConfigurationMimeEditorSection.java deleted file mode 100644 index 5e97b1029..000000000 --- a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ConfigurationMimeEditorSection.java +++ /dev/null @@ -1,419 +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.jst.server.tomcat.ui.internal.editor; - -import java.beans.*; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.wst.server.ui.editor.*; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.layout.*; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Tree; -import org.eclipse.swt.widgets.TreeItem; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jst.server.tomcat.core.internal.MimeMapping; -import org.eclipse.jst.server.tomcat.core.internal.TomcatConfiguration; -import org.eclipse.jst.server.tomcat.core.internal.TomcatServer; -import org.eclipse.jst.server.tomcat.core.internal.command.*; -import org.eclipse.jst.server.tomcat.ui.internal.ContextIds; -import org.eclipse.jst.server.tomcat.ui.internal.Messages; -import org.eclipse.jst.server.tomcat.ui.internal.TomcatUIPlugin; -import org.eclipse.ui.*; -import org.eclipse.ui.forms.widgets.ExpandableComposite; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.forms.widgets.Section; -import org.eclipse.ui.help.IWorkbenchHelpSystem; -/** - * Tomcat configuration mime editor section. - */ -public class ConfigurationMimeEditorSection extends ServerEditorSection { - protected TomcatConfiguration tomcatConfiguration; - - protected boolean updating; - - protected PropertyChangeListener listener; - - protected Tree mimeTypes; - protected int index = -1; - protected List mappings; - protected Button add; - protected Button remove; - protected Button edit; - - /** - * ConfigurationMimeEditorSection constructor comment. - */ - public ConfigurationMimeEditorSection() { - super(); - } - - /** - * - */ - protected void addChangeListener() { - listener = new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - if (TomcatConfiguration.ADD_MAPPING_PROPERTY.equals(event.getPropertyName())) { - Integer in = (Integer) event.getOldValue(); - MimeMapping mapping = (MimeMapping) event.getNewValue(); - addMimeMapping(in.intValue(), mapping); - } else if (TomcatConfiguration.REMOVE_MAPPING_PROPERTY.equals(event.getPropertyName())) { - Integer in = (Integer) event.getNewValue(); - removeMimeMapping(in.intValue()); - } else if (TomcatConfiguration.MODIFY_MAPPING_PROPERTY.equals(event.getPropertyName())) { - Integer in = (Integer) event.getOldValue(); - MimeMapping mapping = (MimeMapping) event.getNewValue(); - modifyMimeMapping(in.intValue(), mapping); - } - } - }; - tomcatConfiguration.addPropertyChangeListener(listener); - } - - public void createSection(Composite parent) { - super.createSection(parent); - - FormToolkit toolkit = getFormToolkit(parent.getDisplay()); - - Section section = toolkit.createSection(parent, ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR - | Section.DESCRIPTION | ExpandableComposite.FOCUS_TITLE); - section.setText(Messages.configurationEditorMimeMappingsSection); - section.setDescription(Messages.configurationEditorMimeMappingsDescription); - 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); - GridData data = new GridData(GridData.FILL_BOTH); - composite.setLayoutData(data); - IWorkbenchHelpSystem whs = PlatformUI.getWorkbench().getHelpSystem(); - whs.setHelp(composite, ContextIds.CONFIGURATION_EDITOR_MAPPINGS); - toolkit.paintBordersFor(composite); - section.setClient(composite); - - mimeTypes = toolkit.createTree(composite, SWT.V_SCROLL | SWT.SINGLE | SWT.H_SCROLL); - data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL); - data.heightHint = 200; - mimeTypes.setLayoutData(data); - whs.setHelp(mimeTypes, ContextIds.CONFIGURATION_EDITOR_MAPPINGS_LIST); - - // add listener to the table - mimeTypes.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - selectMimeMapping(); - } - }); - - Composite buttonComp = toolkit.createComposite(composite); - layout = new GridLayout(); - layout.marginHeight = 0; - layout.marginWidth = 0; - buttonComp.setLayout(layout); - buttonComp.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL)); - - add = toolkit.createButton(buttonComp, Messages.editorAdd, SWT.PUSH); - add.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); - - add.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - MimeMappingDialog dialog = new MimeMappingDialog(getShell()); - dialog.open(); - if (dialog.getReturnCode() == IDialogConstants.OK_ID) { - execute(new AddMimeMappingCommand(tomcatConfiguration, dialog.getMimeMapping())); - } - } - }); - whs.setHelp(add, ContextIds.CONFIGURATION_EDITOR_MAPPINGS_ADD); - - edit = toolkit.createButton(buttonComp, Messages.editorEdit, SWT.PUSH); - edit.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); - edit.setEnabled(false); - - edit.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - if (index < 0) - return; - MimeMappingDialog dialog = new MimeMappingDialog(getShell(), (MimeMapping) tomcatConfiguration.getMimeMappings().get(index)); - dialog.open(); - if (dialog.getReturnCode() == IDialogConstants.OK_ID) { - execute(new ModifyMimeMappingCommand(tomcatConfiguration, index, dialog.getMimeMapping())); - } - } - }); - whs.setHelp(edit, ContextIds.CONFIGURATION_EDITOR_MAPPINGS_EDIT); - - remove = toolkit.createButton(buttonComp, Messages.editorRemove, SWT.PUSH); - remove.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); - remove.setEnabled(false); - - remove.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - if (index < 0) - return; - execute(new RemoveMimeMappingCommand(tomcatConfiguration, index)); - index = -1; - edit.setEnabled(false); - remove.setEnabled(false); - } - }); - whs.setHelp(remove, ContextIds.CONFIGURATION_EDITOR_MAPPINGS_REMOVE); - - initialize(); - } - - public void dispose() { - if (tomcatConfiguration != null) - tomcatConfiguration.removePropertyChangeListener(listener); - } - - public void init(IEditorSite site, IEditorInput input) { - super.init(site, input); - - TomcatServer ts = (TomcatServer) server.getAdapter(TomcatServer.class); - try { - tomcatConfiguration = ts.getTomcatConfiguration(); - } catch (Exception e) { - // ignore - } - addChangeListener(); - initialize(); - } - - /** - * Initialize the fields in this editor. - */ - protected void initialize() { - if (mimeTypes == null) - return; - - mimeTypes.removeAll(); - - mappings = tomcatConfiguration.getMimeMappings(); - - // sort mappings - int size = mappings.size(); - int[] map = new int[size]; - for (int i = 0; i < size; i++) - map[i] = i; - - for (int i = 0; i < size - 1; i++) { - for (int j = i + 1; j < size; j++) { - MimeMapping mappingA = (MimeMapping) mappings.get(map[i]); - MimeMapping mappingB = (MimeMapping) mappings.get(map[j]); - if (mappingA.getMimeType().compareTo(mappingB.getMimeType()) > 0 || - ((mappingA.getMimeType().equals(mappingB.getMimeType())) && - mappingA.getExtension().compareTo(mappingB.getExtension()) > 0)) { - int temp = map[i]; - map[i] = map[j]; - map[j] = temp; - } - } - } - - // display them - Map hash = new HashMap(); - - for (int i = 0; i < size; i++) { - MimeMapping mapping = (MimeMapping) mappings.get(map[i]); - // get parent node - TreeItem parent = (TreeItem) hash.get(mapping.getMimeType()); - if (parent == null) { - parent = new TreeItem(mimeTypes, SWT.NONE); - parent.setText(mapping.getMimeType()); - parent.setImage(TomcatUIPlugin.getImage(TomcatUIPlugin.IMG_MIME_MAPPING)); - hash.put(mapping.getMimeType(), parent); - } - - // add node - TreeItem item = new TreeItem(parent, SWT.NONE); - item.setText(mapping.getExtension()); - item.setImage(TomcatUIPlugin.getImage(TomcatUIPlugin.IMG_MIME_EXTENSION)); - item.setData(new Integer(map[i])); - } - - if (readOnly) { - add.setEnabled(false); - edit.setEnabled(false); - remove.setEnabled(false); - } else { - add.setEnabled(true); - selectMimeMapping(); - } - } - - /** - * Add a mime mapping. - * - * @param index2 - * @param map - */ - protected void addMimeMapping(int index2, MimeMapping map) { - mappings.add(index2, map); - - // correct all index numbers - int size = mimeTypes.getItemCount(); - TreeItem[] parents = mimeTypes.getItems(); - for (int i = 0; i < size; i++) { - TreeItem parent = parents[i]; - - int size2 = parent.getItemCount(); - TreeItem[] children = parent.getItems(); - for (int j = 0; j < size2; j++) { - Integer in = (Integer) children[j].getData(); - if (in.intValue() >= index2) - children[j].setData(new Integer(in.intValue() + 1)); - } - } - - // check if there is a parent. If so, just add a new child - for (int i = 0; i < size; i++) { - TreeItem parent = parents[i]; - if (parent.getText().equals(map.getMimeType())) { - TreeItem item = new TreeItem(parent, SWT.NONE); - item.setText(map.getExtension()); - item.setImage(TomcatUIPlugin.getImage(TomcatUIPlugin.IMG_MIME_EXTENSION)); - item.setData(new Integer(index2)); - mimeTypes.showItem(item); - return; - } - } - - // if not, add a new parent and child to the end - TreeItem parent = new TreeItem(mimeTypes, SWT.NONE); - parent.setText(map.getMimeType()); - parent.setImage(TomcatUIPlugin.getImage(TomcatUIPlugin.IMG_MIME_MAPPING)); - - TreeItem item = new TreeItem(parent, SWT.NONE); - item.setText(map.getExtension()); - item.setImage(TomcatUIPlugin.getImage(TomcatUIPlugin.IMG_MIME_EXTENSION)); - item.setData(new Integer(index2)); - mimeTypes.showItem(item); - } - - /** - * - * @param index2 - * @param map - */ - protected void modifyMimeMapping(int index2, MimeMapping map) { - MimeMapping oldMap = (MimeMapping) mappings.get(index2); - mappings.set(index2, map); - - int size = mimeTypes.getItemCount(); - TreeItem[] parents = mimeTypes.getItems(); - - if (oldMap.getMimeType().equals(map.getMimeType())) { - for (int i = 0; i < size; i++) { - TreeItem parent = parents[i]; - - if (parent.getText().equals(map.getMimeType())) { - int size2 = parent.getItemCount(); - TreeItem[] children = parent.getItems(); - for (int j = 0; j < size2; j++) { - Integer in = (Integer) children[j].getData(); - if (in.intValue() == index2) { - children[j].setText(map.getExtension()); - children[j].setData(new Integer(index2)); - mimeTypes.showItem(children[j]); - return; - } - } - } - } - return; - } - - // otherwise, let's try a remove and an add - removeMimeMapping(index2); - addMimeMapping(index2, map); - } - - /** - * Remove the mime mapping at the given index. - * - * @param index2 - */ - protected void removeMimeMapping(int index2) { - mappings.remove(index2); - - // remove item - int size = mimeTypes.getItemCount(); - TreeItem[] parents = mimeTypes.getItems(); - for (int i = 0; i < size; i++) { - TreeItem parent = parents[i]; - - int size2 = parent.getItemCount(); - TreeItem[] children = parent.getItems(); - for (int j = 0; j < size2; j++) { - Integer in = (Integer) children[j].getData(); - if (in.intValue() == index2) { - children[j].dispose(); - if (size2 == 1) - parent.dispose(); - i += size; - j += size2; - } - } - } - - // correct all index numbers - size = mimeTypes.getItemCount(); - parents = mimeTypes.getItems(); - for (int i = 0; i < size; i++) { - TreeItem parent = parents[i]; - - int size2 = parent.getItemCount(); - TreeItem[] children = parent.getItems(); - for (int j = 0; j < size2; j++) { - Integer in = (Integer) children[j].getData(); - if (in.intValue() > index2) - children[j].setData(new Integer(in.intValue() - 1)); - } - } - } - - /** - * - */ - protected void selectMimeMapping() { - if (readOnly) - return; - - try { - TreeItem item = mimeTypes.getSelection()[0]; - Integer in = (Integer) item.getData(); - if (in == null) { - index = -1; - remove.setEnabled(false); - edit.setEnabled(false); - return; - } - index = in.intValue(); - - remove.setEnabled(true); - edit.setEnabled(true); - } catch (Exception e) { - index = -1; - remove.setEnabled(false); - edit.setEnabled(false); - } - } -} diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ConfigurationPortEditorSection.java b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ConfigurationPortEditorSection.java deleted file mode 100644 index fbbf464db..000000000 --- a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ConfigurationPortEditorSection.java +++ /dev/null @@ -1,248 +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.jst.server.tomcat.ui.internal.editor; - -import java.beans.*; -import java.util.Iterator; - -import org.eclipse.wst.server.core.ServerPort; -import org.eclipse.wst.server.ui.editor.*; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; -import org.eclipse.swt.layout.*; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Item; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.TableItem; -import org.eclipse.jface.viewers.*; -import org.eclipse.jst.server.tomcat.core.internal.TomcatConfiguration; -import org.eclipse.jst.server.tomcat.core.internal.TomcatServer; -import org.eclipse.jst.server.tomcat.core.internal.command.*; -import org.eclipse.jst.server.tomcat.ui.internal.ContextIds; -import org.eclipse.jst.server.tomcat.ui.internal.Messages; -import org.eclipse.jst.server.tomcat.ui.internal.TomcatUIPlugin; -import org.eclipse.ui.*; -import org.eclipse.ui.forms.widgets.ExpandableComposite; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.forms.widgets.Section; -import org.eclipse.ui.help.IWorkbenchHelpSystem; -/** - * Tomcat configuration port editor page. - */ -public class ConfigurationPortEditorSection extends ServerEditorSection { - protected TomcatConfiguration tomcatConfiguration; - - protected boolean updating; - - protected Table ports; - protected TableViewer viewer; - - protected PropertyChangeListener listener; - - /** - * ConfigurationPortEditorSection constructor comment. - */ - public ConfigurationPortEditorSection() { - super(); - } - - /** - * - */ - protected void addChangeListener() { - listener = new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - if (TomcatConfiguration.MODIFY_PORT_PROPERTY.equals(event.getPropertyName())) { - String id = (String) event.getOldValue(); - Integer i = (Integer) event.getNewValue(); - changePortNumber(id, i.intValue()); - } - } - }; - tomcatConfiguration.addPropertyChangeListener(listener); - } - - /** - * - * @param id java.lang.String - * @param port int - */ - protected void changePortNumber(String id, int port) { - TableItem[] items = ports.getItems(); - int size = items.length; - for (int i = 0; i < size; i++) { - ServerPort sp = (ServerPort) items[i].getData(); - if (sp.getId().equals(id)) { - items[i].setData(new ServerPort(id, sp.getName(), port, sp.getProtocol())); - items[i].setText(1, port + ""); - /*if (i == selection) { - selectPort(); - }*/ - return; - } - } - } - - /** - * Creates the SWT controls for this workbench part. - * - * @param parent the parent control - */ - public void createSection(Composite parent) { - super.createSection(parent); - FormToolkit toolkit = getFormToolkit(parent.getDisplay()); - - Section section = toolkit.createSection(parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED - | ExpandableComposite.TITLE_BAR | Section.DESCRIPTION | ExpandableComposite.FOCUS_TITLE); - section.setText(Messages.configurationEditorPortsSection); - section.setDescription(Messages.configurationEditorPortsDescription); - section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL)); - - // ports - Composite composite = toolkit.createComposite(section); - GridLayout layout = new GridLayout(); - layout.marginHeight = 8; - layout.marginWidth = 8; - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.FILL_HORIZONTAL)); - IWorkbenchHelpSystem whs = PlatformUI.getWorkbench().getHelpSystem(); - whs.setHelp(composite, ContextIds.CONFIGURATION_EDITOR_PORTS); - toolkit.paintBordersFor(composite); - section.setClient(composite); - - ports = toolkit.createTable(composite, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION); - ports.setHeaderVisible(true); - ports.setLinesVisible(true); - whs.setHelp(ports, ContextIds.CONFIGURATION_EDITOR_PORTS_LIST); - - TableLayout tableLayout = new TableLayout(); - - TableColumn col = new TableColumn(ports, SWT.NONE); - col.setText(Messages.configurationEditorPortNameColumn); - ColumnWeightData colData = new ColumnWeightData(15, 150, true); - tableLayout.addColumnData(colData); - - col = new TableColumn(ports, SWT.NONE); - col.setText(Messages.configurationEditorPortValueColumn); - colData = new ColumnWeightData(8, 80, true); - tableLayout.addColumnData(colData); - - GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL); - data.widthHint = 230; - data.heightHint = 100; - ports.setLayoutData(data); - ports.setLayout(tableLayout); - - viewer = new TableViewer(ports); - viewer.setColumnProperties(new String[] {"name", "port"}); - - initialize(); - } - - protected void setupPortEditors() { - viewer.setCellEditors(new CellEditor[] {null, new TextCellEditor(ports)}); - - ICellModifier cellModifier = new ICellModifier() { - public Object getValue(Object element, String property) { - ServerPort sp = (ServerPort) element; - if (sp.getPort() < 0) - return "-"; - return sp.getPort() + ""; - } - - public boolean canModify(Object element, String property) { - if ("port".equals(property)) - return true; - - return false; - } - - public void modify(Object element, String property, Object value) { - try { - Item item = (Item) element; - ServerPort sp = (ServerPort) item.getData(); - int port = Integer.parseInt((String) value); - execute(new ModifyPortCommand(tomcatConfiguration, sp.getId(), port)); - } catch (Exception ex) { - // ignore - } - } - }; - viewer.setCellModifier(cellModifier); - - // preselect second column (Windows-only) - String os = System.getProperty("os.name"); - if (os != null && os.toLowerCase().indexOf("win") >= 0) { - ports.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - try { - int n = ports.getSelectionIndex(); - viewer.editElement(ports.getItem(n).getData(), 1); - } catch (Exception e) { - // ignore - } - } - }); - } - } - - public void dispose() { - if (tomcatConfiguration != null) - tomcatConfiguration.removePropertyChangeListener(listener); - } - - /* (non-Javadoc) - * Initializes the editor part with a site and input. - */ - public void init(IEditorSite site, IEditorInput input) { - super.init(site, input); - - TomcatServer ts = (TomcatServer) server.getAdapter(TomcatServer.class); - try { - tomcatConfiguration = ts.getTomcatConfiguration(); - } catch (Exception e) { - // ignore - } - addChangeListener(); - initialize(); - } - - /** - * Initialize the fields in this editor. - */ - protected void initialize() { - if (ports == null) - return; - - ports.removeAll(); - - Iterator iterator = tomcatConfiguration.getServerPorts().iterator(); - while (iterator.hasNext()) { - ServerPort port = (ServerPort) iterator.next(); - TableItem item = new TableItem(ports, SWT.NONE); - String portStr = "-"; - if (port.getPort() >= 0) - portStr = port.getPort() + ""; - String[] s = new String[] {port.getName(), portStr}; - item.setText(s); - item.setImage(TomcatUIPlugin.getImage(TomcatUIPlugin.IMG_PORT)); - item.setData(port); - } - - if (readOnly) { - viewer.setCellEditors(new CellEditor[] {null, null}); - viewer.setCellModifier(null); - } else { - setupPortEditors(); - } - } -} diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ConfigurationWebModuleEditorPart.java b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ConfigurationWebModuleEditorPart.java deleted file mode 100644 index 2507f2a8a..000000000 --- a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ConfigurationWebModuleEditorPart.java +++ /dev/null @@ -1,434 +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.jst.server.tomcat.ui.internal.editor; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.io.File; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jst.server.core.IWebModule; -import org.eclipse.jst.server.tomcat.core.internal.ITomcatServerWorkingCopy; -import org.eclipse.jst.server.tomcat.core.internal.TomcatConfiguration; -import org.eclipse.jst.server.tomcat.core.internal.TomcatServer; -import org.eclipse.jst.server.tomcat.core.internal.WebModule; -import org.eclipse.jst.server.tomcat.core.internal.command.AddModuleCommand; -import org.eclipse.jst.server.tomcat.core.internal.command.AddWebModuleCommand; -import org.eclipse.jst.server.tomcat.core.internal.command.ModifyWebModuleCommand; -import org.eclipse.jst.server.tomcat.core.internal.command.RemoveModuleCommand; -import org.eclipse.jst.server.tomcat.core.internal.command.RemoveWebModuleCommand; -import org.eclipse.jst.server.tomcat.ui.internal.ContextIds; -import org.eclipse.jst.server.tomcat.ui.internal.Messages; -import org.eclipse.jst.server.tomcat.ui.internal.TomcatUIPlugin; -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.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.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.TableItem; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorSite; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.forms.widgets.ExpandableComposite; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.forms.widgets.ScrolledForm; -import org.eclipse.ui.forms.widgets.Section; -import org.eclipse.ui.help.IWorkbenchHelpSystem; - -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.ServerUtil; -import org.eclipse.wst.server.ui.ServerUICore; -import org.eclipse.wst.server.ui.editor.ServerEditorPart; -/** - * Tomcat configuration web module editor page. - */ -public class ConfigurationWebModuleEditorPart extends ServerEditorPart { - protected ITomcatServerWorkingCopy server2; - protected TomcatConfiguration configuration; - - protected Table webAppTable; - protected int selection = -1; - protected Button addProject; - protected Button addExtProject; - protected Button remove; - protected Button edit; - - protected PropertyChangeListener listener; - - /** - * ConfigurationWebModuleEditorPart constructor comment. - */ - public ConfigurationWebModuleEditorPart() { - super(); - } - - /** - * - */ - protected void addChangeListener() { - listener = new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - if (TomcatConfiguration.MODIFY_WEB_MODULE_PROPERTY.equals(event.getPropertyName())) { - initialize(); - } else if (TomcatConfiguration.ADD_WEB_MODULE_PROPERTY.equals(event.getPropertyName())) { - initialize(); - } else if (TomcatConfiguration.REMOVE_WEB_MODULE_PROPERTY.equals(event.getPropertyName())) { - initialize(); - } - } - }; - configuration.addPropertyChangeListener(listener); - } - - /** - * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) - */ - public void createPartControl(Composite parent) { - FormToolkit toolkit = getFormToolkit(parent.getDisplay()); - - ScrolledForm form = toolkit.createScrolledForm(parent); - toolkit.decorateFormHeading(form.getForm()); - form.setText(Messages.configurationEditorWebModulesPageTitle); - form.setImage(TomcatUIPlugin.getImage(TomcatUIPlugin.IMG_WEB_MODULE)); - GridLayout layout = new GridLayout(); - layout.marginTop = 6; - layout.marginLeft = 6; - form.getBody().setLayout(layout); - - Section section = toolkit.createSection(form.getBody(), ExpandableComposite.TITLE_BAR | Section.DESCRIPTION); - section.setText(Messages.configurationEditorWebModulesSection); - section.setDescription(Messages.configurationEditorWebModulesDescription); - section.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Composite composite = toolkit.createComposite(section); - 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_BOTH)); - IWorkbenchHelpSystem whs = PlatformUI.getWorkbench().getHelpSystem(); - whs.setHelp(composite, ContextIds.CONFIGURATION_EDITOR_WEBMODULES); - toolkit.paintBordersFor(composite); - section.setClient(composite); - - webAppTable = toolkit.createTable(composite, SWT.V_SCROLL | SWT.SINGLE | SWT.FULL_SELECTION); - webAppTable.setHeaderVisible(true); - webAppTable.setLinesVisible(true); - whs.setHelp(webAppTable, ContextIds.CONFIGURATION_EDITOR_WEBMODULES_LIST); - //toolkit.paintBordersFor(webAppTable); - - TableLayout tableLayout = new TableLayout(); - - TableColumn col = new TableColumn(webAppTable, SWT.NONE); - col.setText(Messages.configurationEditorPathColumn); - ColumnWeightData colData = new ColumnWeightData(8, 85, true); - tableLayout.addColumnData(colData); - - TableColumn col2 = new TableColumn(webAppTable, SWT.NONE); - col2.setText(Messages.configurationEditorDocBaseColumn); - colData = new ColumnWeightData(13, 135, true); - tableLayout.addColumnData(colData); - - TableColumn col3 = new TableColumn(webAppTable, SWT.NONE); - col3.setText(Messages.configurationEditorProjectColumn); - colData = new ColumnWeightData(8, 85, true); - tableLayout.addColumnData(colData); - - TableColumn col4 = new TableColumn(webAppTable, SWT.NONE); - col4.setText(Messages.configurationEditorReloadColumn); - colData = new ColumnWeightData(7, 75, true); - tableLayout.addColumnData(colData); - - webAppTable.setLayout(tableLayout); - - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.widthHint = 450; - data.heightHint = 120; - webAppTable.setLayoutData(data); - webAppTable.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - selectWebApp(); - } - }); - - Composite rightPanel = toolkit.createComposite(composite); - layout = new GridLayout(); - layout.marginHeight = 0; - layout.marginWidth = 0; - rightPanel.setLayout(layout); - data = new GridData(); - rightPanel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING)); - //toolkit.paintBordersFor(rightPanel); - - // buttons still to add: - // add project, add external module, remove module - addProject = toolkit.createButton(rightPanel, Messages.configurationEditorAddProjectModule, SWT.PUSH); - data = new GridData(GridData.FILL_HORIZONTAL); - addProject.setLayoutData(data); - whs.setHelp(addProject, ContextIds.CONFIGURATION_EDITOR_WEBMODULES_ADD_PROJECT); - - // disable the add project module button if there are no - // web projects in the workbench - if (!canAddWebModule()) - addProject.setEnabled(false); - else { - addProject.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - WebModuleDialog dialog = new WebModuleDialog(getEditorSite().getShell(), getServer(), server2, configuration, true); - dialog.open(); - if (dialog.getReturnCode() == IDialogConstants.OK_ID) { - execute(new AddModuleCommand(getServer(), dialog.module4)); - } - } - }); - } - - addExtProject = toolkit.createButton(rightPanel, Messages.configurationEditorAddExternalModule, SWT.PUSH); - data = new GridData(GridData.FILL_HORIZONTAL); - addExtProject.setLayoutData(data); - addExtProject.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - WebModuleDialog dialog = new WebModuleDialog(getEditorSite().getShell(), getServer(), server2, configuration, false); - dialog.open(); - if (dialog.getReturnCode() == IDialogConstants.OK_ID) { - execute(new AddWebModuleCommand(configuration, dialog.getWebModule())); - } - } - }); - whs.setHelp(addExtProject, ContextIds.CONFIGURATION_EDITOR_WEBMODULES_ADD_EXTERNAL); - - edit = toolkit.createButton(rightPanel, Messages.editorEdit, SWT.PUSH); - data = new GridData(GridData.FILL_HORIZONTAL); - edit.setLayoutData(data); - edit.setEnabled(false); - edit.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - if (selection < 0) - return; - WebModule module = (WebModule) configuration.getWebModules().get(selection); - WebModuleDialog dialog = new WebModuleDialog(getEditorSite().getShell(), getServer(), server2, configuration, module); - dialog.open(); - if (dialog.getReturnCode() == IDialogConstants.OK_ID) { - execute(new ModifyWebModuleCommand(configuration, selection, dialog.getWebModule())); - } - } - }); - whs.setHelp(edit, ContextIds.CONFIGURATION_EDITOR_WEBMODULES_EDIT); - - remove = toolkit.createButton(rightPanel, Messages.editorRemove, SWT.PUSH); - data = new GridData(GridData.FILL_HORIZONTAL); - remove.setLayoutData(data); - remove.setEnabled(false); - remove.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - if (selection < 0) - return; - TableItem item = webAppTable.getItem(selection); - if (item.getData() != null) { - IModule module = (IModule) item.getData(); - execute(new RemoveModuleCommand(getServer(), module)); - } else { - execute(new RemoveWebModuleCommand(configuration, selection)); - } - remove.setEnabled(false); - edit.setEnabled(false); - selection = -1; - } - }); - whs.setHelp(remove, ContextIds.CONFIGURATION_EDITOR_WEBMODULES_REMOVE); - - form.setContent(section); - form.reflow(true); - - initialize(); - } - - protected boolean canAddWebModule() { - IModule[] modules = ServerUtil.getModules(server.getServerType().getRuntimeType().getModuleTypes()); - if (modules != null) { - int size = modules.length; - for (int i = 0; i < size; i++) { - IWebModule webModule = (IWebModule) modules[i].loadAdapter(IWebModule.class, null); - if (webModule != null) { - IStatus status = server.canModifyModules(new IModule[] { modules[i] }, null, null); - if (status != null && status.isOK()) - return true; - } - } - } - return false; - } - - public void dispose() { - super.dispose(); - - if (configuration != null) - configuration.removePropertyChangeListener(listener); - } - - /* (non-Javadoc) - * Initializes the editor part with a site and input. - */ - public void init(IEditorSite site, IEditorInput input) { - super.init(site, input); - - TomcatServer ts = (TomcatServer) server.loadAdapter(TomcatServer.class, null); - try { - configuration = ts.getTomcatConfiguration(); - } catch (Exception e) { - // ignore - } - if (configuration != null) - addChangeListener(); - - if (server != null) - server2 = (ITomcatServerWorkingCopy) server.loadAdapter(ITomcatServerWorkingCopy.class, null); - - initialize(); - } - - /** - * - */ - protected void initialize() { - if (webAppTable == null) - return; - - webAppTable.removeAll(); - setErrorMessage(null); - - ILabelProvider labelProvider = ServerUICore.getLabelProvider(); - List list = configuration.getWebModules(); - Iterator iterator = list.iterator(); - while (iterator.hasNext()) { - WebModule module = (WebModule) iterator.next(); - TableItem item = new TableItem(webAppTable, SWT.NONE); - - String memento = module.getMemento(); - String projectName = ""; - Image projectImage = null; - if (memento != null && memento.length() > 0) { - projectName = NLS.bind(Messages.configurationEditorProjectMissing, new String[] {memento}); - projectImage = TomcatUIPlugin.getImage(TomcatUIPlugin.IMG_PROJECT_MISSING); - IModule module2 = ServerUtil.getModule(memento); - if (module2 != null) { - projectName = labelProvider.getText(module2); - projectImage = labelProvider.getImage(module2); - item.setData(module2); - } - } - - String reload = module.isReloadable() ? Messages.configurationEditorReloadEnabled : Messages.configurationEditorReloadDisabled; - String[] s = new String[] {module.getPath(), module.getDocumentBase(), projectName, reload}; - item.setText(s); - item.setImage(0, TomcatUIPlugin.getImage(TomcatUIPlugin.IMG_WEB_MODULE)); - if (projectImage != null) - item.setImage(2, projectImage); - - if (!isDocumentBaseValid(module.getDocumentBase())) { - item.setImage(1, TomcatUIPlugin.getImage(TomcatUIPlugin.IMG_PROJECT_MISSING)); - setErrorMessage(NLS.bind(Messages.errorMissingWebModule, module.getDocumentBase())); - } - } - labelProvider = null; - - if (readOnly) { - addProject.setEnabled(false); - addExtProject.setEnabled(false); - edit.setEnabled(false); - remove.setEnabled(false); - } else { - addProject.setEnabled(canAddWebModule()); - addExtProject.setEnabled(true); - } - } - - /** - * - */ - protected void selectWebApp() { - if (readOnly) - return; - - try { - selection = webAppTable.getSelectionIndex(); - remove.setEnabled(true); - edit.setEnabled(true); - } catch (Exception e) { - selection = -1; - remove.setEnabled(false); - edit.setEnabled(false); - } - } - - protected boolean isDocumentBaseValid(String s) { - if (s == null || s.length() < 2) - return true; - - // check absolute path - File f = new File(s); - if (f.exists()) - return true; - - // check workspace - try { - if (ResourcesPlugin.getWorkspace().getRoot().getProject(s).exists()) - return true; - } catch (Exception e) { - // bad path - } - - if (s.startsWith(configuration.getDocBasePrefix())) { - try { - String t = s.substring(configuration.getDocBasePrefix().length()); - if (ResourcesPlugin.getWorkspace().getRoot().getProject(t).exists()) - return true; - } catch (Exception e) { - // bad path - } - } - - // check server relative path - try { - f = server.getRuntime().getLocation().append(s).toFile(); - if (f.exists()) - return true; - } catch (Exception e) { - // bad path - } - - return false; - } - - /* - * @see IWorkbenchPart#setFocus() - */ - public void setFocus() { - if (webAppTable != null) - webAppTable.setFocus(); - } -} diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/MimeMappingDialog.java b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/MimeMappingDialog.java deleted file mode 100644 index cf65ff871..000000000 --- a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/MimeMappingDialog.java +++ /dev/null @@ -1,155 +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.jst.server.tomcat.ui.internal.editor; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jst.server.tomcat.core.internal.MimeMapping; -import org.eclipse.jst.server.tomcat.ui.internal.ContextIds; -import org.eclipse.jst.server.tomcat.ui.internal.Messages; -import org.eclipse.jst.server.tomcat.ui.internal.TomcatUIPlugin; -import org.eclipse.swt.SWT; -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.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.help.IWorkbenchHelpSystem; -/** - * Dialog to add or modify mime mappings. - */ -public class MimeMappingDialog extends Dialog { - protected MimeMapping map; - protected boolean isEdit; - - /** - * MimeMappingDialog constructor comment. - * @param parentShell org.eclipse.swt.widgets.Shell - */ - public MimeMappingDialog(Shell parentShell) { - this(parentShell, new MimeMapping("", "")); - isEdit = false; - } - - /** - * MimeMappingDialog constructor. - * - * @param parentShell a shell - * @param map a mime mapping - */ - public MimeMappingDialog(Shell parentShell, MimeMapping map) { - super(parentShell); - this.map = map; - isEdit = true; - } - - /** - * - */ - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - newShell.setImage(TomcatUIPlugin.getImage(TomcatUIPlugin.IMG_MIME_MAPPING)); - if (isEdit) - newShell.setText(Messages.configurationEditorMimeMapppingDialogTitleEdit); - else - newShell.setText(Messages.configurationEditorMimeMapppingDialogTitleAdd); - } - - /** - * Creates and returns the contents of the upper part - * of this dialog (above the button bar). - * <p> - * The <code>Dialog</code> implementation of this framework method - * creates and returns a new <code>Composite</code> with - * standard margins and spacing. Subclasses should override. - * </p> - * - * @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.numColumns = 2; - 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()); - IWorkbenchHelpSystem whs = PlatformUI.getWorkbench().getHelpSystem(); - whs.setHelp(composite, ContextIds.CONFIGURATION_EDITOR_MAPPING_DIALOG); - - new Label(composite, SWT.NONE).setText(Messages.configurationEditorMimeMapppingDialogMimeType); - final Text type = new Text(composite, SWT.BORDER); - GridData data = new GridData(); - data.widthHint = 150; - type.setLayoutData(data); - type.setText(map.getMimeType()); - type.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - map = new MimeMapping(map.getExtension(), type.getText()); - validate(); - } - }); - whs.setHelp(type, ContextIds.CONFIGURATION_EDITOR_MAPPING_DIALOG_TYPE); - - new Label(composite, SWT.NONE).setText(Messages.configurationEditorMimeMapppingDialogMimeExtension); - final Text extension = new Text(composite, SWT.BORDER); - data = new GridData(); - data.widthHint = 150; - extension.setLayoutData(data); - extension.setText(map.getExtension()); - extension.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - map = new MimeMapping(extension.getText(), map.getMimeType()); - validate(); - } - }); - whs.setHelp(extension, ContextIds.CONFIGURATION_EDITOR_MAPPING_DIALOG_EXTENSION); - - Dialog.applyDialogFont(composite); - - return composite; - } - - protected Control createButtonBar(Composite parent) { - Control control = super.createButtonBar(parent); - validate(); - - return control; - } - - protected void validate() { - boolean ok = true; - if (map.getExtension() == null || map.getExtension().length() < 1) - ok = false; - if (map.getMimeType() == null || map.getMimeType().length() < 1) - ok = false; - getButton(IDialogConstants.OK_ID).setEnabled(ok); - } - - /** - * Return the mime mapping. - * - * @return org.eclipse.jst.server.tomcat.MimeMapping - */ - public MimeMapping getMimeMapping() { - return map; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ServerGeneralEditorSection.java b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ServerGeneralEditorSection.java deleted file mode 100644 index 36d296555..000000000 --- a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ServerGeneralEditorSection.java +++ /dev/null @@ -1,307 +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.jst.server.tomcat.ui.internal.editor; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jst.server.tomcat.core.internal.ITomcatServer; -import org.eclipse.jst.server.tomcat.core.internal.ITomcatVersionHandler; -import org.eclipse.jst.server.tomcat.core.internal.TomcatServer; -import org.eclipse.jst.server.tomcat.core.internal.command.SetDebugModeCommand; -import org.eclipse.jst.server.tomcat.core.internal.command.SetSecureCommand; -import org.eclipse.jst.server.tomcat.core.internal.command.SetSaveSeparateContextFilesCommand; -import org.eclipse.jst.server.tomcat.core.internal.command.SetServeModulesWithoutPublishCommand; -import org.eclipse.jst.server.tomcat.ui.internal.ContextIds; -import org.eclipse.jst.server.tomcat.ui.internal.Messages; -import org.eclipse.jst.server.tomcat.ui.internal.TomcatUIPlugin; -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.ui.IEditorInput; -import org.eclipse.ui.IEditorSite; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.forms.widgets.ExpandableComposite; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.forms.widgets.Section; -import org.eclipse.ui.help.IWorkbenchHelpSystem; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.internal.PublishServerJob; -import org.eclipse.wst.server.ui.editor.ServerEditorSection; -/** - * Tomcat server general editor page. - */ -public class ServerGeneralEditorSection extends ServerEditorSection { - protected TomcatServer tomcatServer; - - protected Button secure; - protected Button debug; - protected Button noPublish; - protected Button separateContextFiles; - protected boolean updating; - - protected PropertyChangeListener listener; - - protected boolean noPublishChanged; - protected boolean separateContextFilesChanged; - - /** - * ServerGeneralEditorPart constructor comment. - */ - public ServerGeneralEditorSection() { - // do nothing - } - - /** - * - */ - protected void addChangeListener() { - listener = new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - if (updating) - return; - updating = true; - if (TomcatServer.PROPERTY_SECURE.equals(event.getPropertyName())) { - Boolean b = (Boolean) event.getNewValue(); - ServerGeneralEditorSection.this.secure.setSelection(b.booleanValue()); - } else if (TomcatServer.PROPERTY_DEBUG.equals(event.getPropertyName())) { - Boolean b = (Boolean) event.getNewValue(); - ServerGeneralEditorSection.this.debug.setSelection(b.booleanValue()); - } else if (ITomcatServer.PROPERTY_SERVE_MODULES_WITHOUT_PUBLISH.equals(event.getPropertyName())) { - Boolean b = (Boolean) event.getNewValue(); - ServerGeneralEditorSection.this.noPublish.setSelection(b.booleanValue()); - // Indicate this setting has changed - noPublishChanged = true; - } else if (ITomcatServer.PROPERTY_SAVE_SEPARATE_CONTEXT_FILES.equals(event.getPropertyName())) { - Boolean b = (Boolean) event.getNewValue(); - ServerGeneralEditorSection.this.separateContextFiles.setSelection(b.booleanValue()); - // Indicate this setting has changed - separateContextFilesChanged = true; - } - updating = false; - } - }; - server.addPropertyChangeListener(listener); - } - - /** - * Creates the SWT controls for this workbench part. - * - * @param parent the parent control - */ - public void createSection(Composite parent) { - super.createSection(parent); - FormToolkit toolkit = getFormToolkit(parent.getDisplay()); - - Section section = toolkit.createSection(parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED - | ExpandableComposite.TITLE_BAR | Section.DESCRIPTION | ExpandableComposite.FOCUS_TITLE); - section.setText(Messages.serverEditorGeneralSection); - section.setDescription(Messages.serverEditorGeneralDescription); - 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 = 15; - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL)); - IWorkbenchHelpSystem whs = PlatformUI.getWorkbench().getHelpSystem(); - whs.setHelp(composite, ContextIds.SERVER_EDITOR); - toolkit.paintBordersFor(composite); - section.setClient(composite); - - // serve modules without publish - noPublish = toolkit.createButton(composite, NLS.bind(Messages.serverEditorNoPublish, ""), SWT.CHECK); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - data.horizontalSpan = 3; - noPublish.setLayoutData(data); - noPublish.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent se) { - if (updating) - return; - updating = true; - execute(new SetServeModulesWithoutPublishCommand(tomcatServer, noPublish.getSelection())); - // Indicate this setting has changed - noPublishChanged = true; - updating = false; - } - }); - // TODO Address help -// whs.setHelp(noPublish, ContextIds.SERVER_EDITOR_SECURE); - - // save separate context XML files - separateContextFiles = toolkit.createButton(composite, NLS.bind(Messages.serverEditorSeparateContextFiles, ""), SWT.CHECK); - data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - data.horizontalSpan = 3; - separateContextFiles.setLayoutData(data); - separateContextFiles.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent se) { - if (updating) - return; - updating = true; - execute(new SetSaveSeparateContextFilesCommand(tomcatServer, separateContextFiles.getSelection())); - // Indicate this setting has changed - separateContextFilesChanged = true; - updating = false; - } - }); - // TODO Address help -// whs.setHelp(separateContextFiles, ContextIds.SERVER_EDITOR_SECURE); - - // security - secure = toolkit.createButton(composite, Messages.serverEditorSecure, SWT.CHECK); - data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - data.horizontalSpan = 3; - secure.setLayoutData(data); - secure.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent se) { - if (updating) - return; - updating = true; - execute(new SetSecureCommand(tomcatServer, secure.getSelection())); - updating = false; - } - }); - whs.setHelp(secure, ContextIds.SERVER_EDITOR_SECURE); - - // debug mode - debug = toolkit.createButton(composite, NLS.bind(Messages.serverEditorDebugMode, ""), SWT.CHECK); - data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - data.horizontalSpan = 3; - debug.setLayoutData(data); - debug.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent se) { - if (updating) - return; - updating = true; - execute(new SetDebugModeCommand(tomcatServer, debug.getSelection())); - updating = false; - } - }); - whs.setHelp(debug, ContextIds.SERVER_EDITOR_DEBUG_MODE); - - initialize(); - } - - /** - * @see ServerEditorSection#dispose() - */ - public void dispose() { - if (server != null) - server.removePropertyChangeListener(listener); - } - - /** - * @see ServerEditorSection#init(IEditorSite, IEditorInput) - */ - public void init(IEditorSite site, IEditorInput input) { - super.init(site, input); - - if (server != null) { - tomcatServer = (TomcatServer) server.loadAdapter(TomcatServer.class, null); - addChangeListener(); - } - initialize(); - } - - /** - * Initialize the fields in this editor. - */ - protected void initialize() { - if (secure == null || tomcatServer == null) - return; - updating = true; - ITomcatVersionHandler tvh = tomcatServer.getTomcatVersionHandler(); - - boolean supported = tvh.supportsServeModulesWithoutPublish(); - String label = NLS.bind(Messages.serverEditorNoPublish, - supported ? "" : Messages.serverEditorNotSupported); - noPublish.setText(label); - noPublish.setSelection(tomcatServer.isServeModulesWithoutPublish()); - if (readOnly || !supported) - noPublish.setEnabled(false); - else - noPublish.setEnabled(true); - - supported = tvh.supportsSeparateContextFiles(); - label = NLS.bind(Messages.serverEditorSeparateContextFiles, - supported ? "" : Messages.serverEditorNotSupported); - separateContextFiles.setText(label); - separateContextFiles.setSelection(tomcatServer.isSaveSeparateContextFiles()); - if (readOnly || !supported) - separateContextFiles.setEnabled(false); - else - separateContextFiles.setEnabled(true); - - secure.setSelection(tomcatServer.isSecure()); - - supported = tvh.supportsDebugArgument(); - label = NLS.bind(Messages.serverEditorDebugMode, - supported ? "" : Messages.serverEditorNotSupported); - debug.setText(label); - if (readOnly || !supported) - debug.setEnabled(false); - else { - debug.setEnabled(true); - debug.setSelection(tomcatServer.isDebug()); - } - - if (readOnly) - secure.setEnabled(false); - else - secure.setEnabled(true); - - updating = false; - } - - /** - * @see ServerEditorSection#getSaveStatus() - */ - public IStatus[] getSaveStatus() { - // If serve modules without publishing has changed, request clean publish to be safe - if (noPublishChanged) { - // If server is running, abort the save since clean publish won't succeed - if (tomcatServer.getServer().getServerState() != IServer.STATE_STOPPED) { - return new IStatus [] { - new Status(IStatus.ERROR, TomcatUIPlugin.PLUGIN_ID, - NLS.bind(Messages.errorServerMustBeStopped, - NLS.bind(Messages.serverEditorNoPublish, "").trim())) - }; - } - // Force a clean publish - PublishServerJob publishJob = new PublishServerJob(tomcatServer.getServer(), IServer.PUBLISH_CLEAN, false); - publishJob.schedule(); - noPublishChanged = false; - } - if (separateContextFilesChanged) { - // If server is running, abort the save since contexts will be moving - if (tomcatServer.getServer().getServerState() != IServer.STATE_STOPPED) { - return new IStatus [] { - new Status(IStatus.ERROR, TomcatUIPlugin.PLUGIN_ID, - NLS.bind(Messages.errorServerMustBeStopped, - NLS.bind(Messages.serverEditorSeparateContextFiles, "").trim())) - }; - } - } - // use default implementation to return success - return super.getSaveStatus(); - } -} diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ServerLocationEditorSection.java b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ServerLocationEditorSection.java deleted file mode 100644 index b5d2787b5..000000000 --- a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ServerLocationEditorSection.java +++ /dev/null @@ -1,600 +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.jst.server.tomcat.ui.internal.editor; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; - -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Status; -import org.eclipse.jst.server.tomcat.core.internal.ITomcatServer; -import org.eclipse.jst.server.tomcat.core.internal.ITomcatServerWorkingCopy; -import org.eclipse.jst.server.tomcat.core.internal.TomcatServer; -import org.eclipse.jst.server.tomcat.core.internal.command.SetDeployDirectoryCommand; -import org.eclipse.jst.server.tomcat.core.internal.command.SetInstanceDirectoryCommand; -import org.eclipse.jst.server.tomcat.core.internal.command.SetTestEnvironmentCommand; -import org.eclipse.jst.server.tomcat.ui.internal.ContextIds; -import org.eclipse.jst.server.tomcat.ui.internal.Messages; -import org.eclipse.jst.server.tomcat.ui.internal.TomcatUIPlugin; -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.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.DirectoryDialog; -import org.eclipse.swt.widgets.Label; -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.forms.IFormColors; -import org.eclipse.ui.forms.events.HyperlinkAdapter; -import org.eclipse.ui.forms.events.HyperlinkEvent; -import org.eclipse.ui.forms.widgets.ExpandableComposite; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.forms.widgets.Hyperlink; -import org.eclipse.ui.forms.widgets.Section; -import org.eclipse.ui.help.IWorkbenchHelpSystem; -import org.eclipse.wst.server.core.IPublishListener; -import org.eclipse.wst.server.core.IRuntime; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.util.PublishAdapter; -import org.eclipse.wst.server.ui.editor.ServerEditorSection; -/** - * Tomcat server general editor page. - */ -public class ServerLocationEditorSection extends ServerEditorSection { - protected Section section; - protected TomcatServer tomcatServer; - - protected Hyperlink setDefaultDeployDir; - - protected boolean defaultDeployDirIsSet; - - protected Button serverDirMetadata; - protected Button serverDirInstall; - protected Button serverDirCustom; - - protected Text serverDir; - protected Button serverDirBrowse; - protected Text deployDir; - protected Button deployDirBrowse; - protected boolean updating; - - protected PropertyChangeListener listener; - protected IPublishListener publishListener; - protected IPath workspacePath; - protected IPath defaultDeployPath; - - protected boolean allowRestrictedEditing; - protected IPath tempDirPath; - protected IPath installDirPath; - - // Avoid hardcoding this at some point - private final static String METADATADIR = ".metadata"; - /** - * ServerGeneralEditorPart constructor comment. - */ - public ServerLocationEditorSection() { - // do nothing - } - - /** - * Add listeners to detect undo changes and publishing of the server. - */ - protected void addChangeListeners() { - listener = new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - if (updating) - return; - updating = true; - if (ITomcatServer.PROPERTY_INSTANCE_DIR.equals(event.getPropertyName()) - || ITomcatServer.PROPERTY_TEST_ENVIRONMENT.equals(event.getPropertyName())) { - updateServerDirButtons(); - updateServerDirFields(); - validate(); - } - else if (ITomcatServer.PROPERTY_DEPLOY_DIR.equals(event.getPropertyName())) { - String s = (String) event.getNewValue(); - ServerLocationEditorSection.this.deployDir.setText(s); - updateDefaultDeployLink(); - validate(); - } - updating = false; - } - }; - server.addPropertyChangeListener(listener); - - publishListener = new PublishAdapter() { - public void publishFinished(IServer server2, IStatus status) { - boolean flag = false; - if (status.isOK() && server2.getModules().length == 0) - flag = true; - if (flag != allowRestrictedEditing) { - allowRestrictedEditing = flag; - // Update the state of the fields - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - public void run() { - boolean customServerDir = false; - if (!ServerLocationEditorSection.this.serverDirCustom.isDisposed()) - customServerDir = ServerLocationEditorSection.this.serverDirCustom.getSelection(); - if (!ServerLocationEditorSection.this.serverDirMetadata.isDisposed()) - ServerLocationEditorSection.this.serverDirMetadata.setEnabled(allowRestrictedEditing); - if (!ServerLocationEditorSection.this.serverDirInstall.isDisposed()) - ServerLocationEditorSection.this.serverDirInstall.setEnabled(allowRestrictedEditing); - if (!ServerLocationEditorSection.this.serverDirCustom.isDisposed()) - ServerLocationEditorSection.this.serverDirCustom.setEnabled(allowRestrictedEditing); - if (!ServerLocationEditorSection.this.serverDir.isDisposed()) - ServerLocationEditorSection.this.serverDir.setEnabled(allowRestrictedEditing && customServerDir); - if (!ServerLocationEditorSection.this.serverDirBrowse.isDisposed()) - ServerLocationEditorSection.this.serverDirBrowse.setEnabled(allowRestrictedEditing && customServerDir); - if (!ServerLocationEditorSection.this.setDefaultDeployDir.isDisposed()) - ServerLocationEditorSection.this.setDefaultDeployDir.setEnabled(allowRestrictedEditing); - if (!ServerLocationEditorSection.this.deployDir.isDisposed()) - ServerLocationEditorSection.this.deployDir.setEnabled(allowRestrictedEditing); - if (!ServerLocationEditorSection.this.deployDirBrowse.isDisposed()) - ServerLocationEditorSection.this.deployDirBrowse.setEnabled(allowRestrictedEditing); - } - }); - } - } - }; - server.getOriginal().addPublishListener(publishListener); - } - - /** - * Creates the SWT controls for this workbench part. - * - * @param parent the parent control - */ - public void createSection(Composite parent) { - super.createSection(parent); - FormToolkit toolkit = getFormToolkit(parent.getDisplay()); - - section = toolkit.createSection(parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED - | ExpandableComposite.TITLE_BAR | Section.DESCRIPTION | ExpandableComposite.FOCUS_TITLE); - section.setText(Messages.serverEditorLocationsSection); - section.setDescription(Messages.serverEditorLocationsDescription); - 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 = 15; - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL)); - IWorkbenchHelpSystem whs = PlatformUI.getWorkbench().getHelpSystem(); - whs.setHelp(composite, ContextIds.SERVER_EDITOR); - whs.setHelp(section, ContextIds.SERVER_EDITOR); - toolkit.paintBordersFor(composite); - section.setClient(composite); - - serverDirMetadata = toolkit.createButton(composite, - NLS.bind(Messages.serverEditorServerDirMetadata, Messages.serverEditorDoesNotModify), SWT.RADIO); - GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false); - data.horizontalSpan = 3; - serverDirMetadata.setLayoutData(data); - serverDirMetadata.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - if (updating || !serverDirMetadata.getSelection()) - return; - updating = true; - execute(new SetTestEnvironmentCommand(tomcatServer, true)); - updateServerDirFields(); - updating = false; - validate(); - } - }); - - serverDirInstall = toolkit.createButton(composite, - NLS.bind(Messages.serverEditorServerDirInstall, Messages.serverEditorTakesControl), SWT.RADIO); - data = new GridData(SWT.FILL, SWT.CENTER, true, false); - data.horizontalSpan = 3; - serverDirInstall.setLayoutData(data); - serverDirInstall.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - if (updating || !serverDirInstall.getSelection()) - return; - updating = true; - execute(new SetTestEnvironmentCommand(tomcatServer, false)); - updateServerDirFields(); - updating = false; - validate(); - } - }); - - serverDirCustom = toolkit.createButton(composite, - NLS.bind(Messages.serverEditorServerDirCustom, Messages.serverEditorDoesNotModify), SWT.RADIO); - data = new GridData(SWT.FILL, SWT.CENTER, true, false); - data.horizontalSpan = 3; - serverDirCustom.setLayoutData(data); - serverDirCustom.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - if (updating || !serverDirCustom.getSelection()) - return; - updating = true; - execute(new SetTestEnvironmentCommand(tomcatServer, true)); - updateServerDirFields(); - updating = false; - validate(); - } - }); - - // server directory - Label label = createLabel(toolkit, composite, Messages.serverEditorServerDir); - data = new GridData(SWT.BEGINNING, SWT.CENTER, false, false); - label.setLayoutData(data); - - serverDir = toolkit.createText(composite, null, SWT.SINGLE); - data = new GridData(SWT.FILL, SWT.CENTER, true, false); - serverDir.setLayoutData(data); - serverDir.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - if (updating) - return; - updating = true; - execute(new SetInstanceDirectoryCommand(tomcatServer, getServerDir())); - updating = false; - validate(); - } - }); - - serverDirBrowse = toolkit.createButton(composite, Messages.editorBrowse, SWT.PUSH); - serverDirBrowse.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent se) { - DirectoryDialog dialog = new DirectoryDialog(serverDir.getShell()); - dialog.setMessage(Messages.serverEditorBrowseDeployMessage); - dialog.setFilterPath(serverDir.getText()); - String selectedDirectory = dialog.open(); - if (selectedDirectory != null && !selectedDirectory.equals(serverDir.getText())) { - updating = true; - // Make relative if relative to the workspace - IPath path = new Path(selectedDirectory); - if (workspacePath.isPrefixOf(path)) { - int cnt = path.matchingFirstSegments(workspacePath); - path = path.removeFirstSegments(cnt).setDevice(null); - selectedDirectory = path.toOSString(); - } - execute(new SetInstanceDirectoryCommand(tomcatServer, selectedDirectory)); - updateServerDirButtons(); - updateServerDirFields(); - updating = false; - validate(); - } - } - }); - serverDirBrowse.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); - - // deployment directory link - setDefaultDeployDir = toolkit.createHyperlink(composite, - NLS.bind(Messages.serverEditorSetDefaultDeployDirLink, ""), SWT.WRAP); - setDefaultDeployDir.addHyperlinkListener(new HyperlinkAdapter() { - public void linkActivated(HyperlinkEvent e) { - updating = true; - execute(new SetDeployDirectoryCommand(tomcatServer, ITomcatServerWorkingCopy.DEFAULT_DEPLOYDIR)); - deployDir.setText(ITomcatServerWorkingCopy.DEFAULT_DEPLOYDIR); - updateDefaultDeployLink(); - updating = false; - validate(); - } - }); - data = new GridData(SWT.FILL, SWT.CENTER, true, false); - data.horizontalSpan = 3; - setDefaultDeployDir.setLayoutData(data); - - // deployment directory - label = createLabel(toolkit, composite, Messages.serverEditorDeployDir); - data = new GridData(SWT.BEGINNING, SWT.CENTER, false, false); - label.setLayoutData(data); - - deployDir = toolkit.createText(composite, null); - data = new GridData(SWT.FILL, SWT.CENTER, true, false); - deployDir.setLayoutData(data); - deployDir.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - if (updating) - return; - updating = true; - execute(new SetDeployDirectoryCommand(tomcatServer, deployDir.getText().trim())); - updateDefaultDeployLink(); - updating = false; - validate(); - } - }); - - deployDirBrowse = toolkit.createButton(composite, Messages.editorBrowse, SWT.PUSH); - deployDirBrowse.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent se) { - DirectoryDialog dialog = new DirectoryDialog(deployDir.getShell()); - dialog.setMessage(Messages.serverEditorBrowseDeployMessage); - dialog.setFilterPath(deployDir.getText()); - String selectedDirectory = dialog.open(); - if (selectedDirectory != null && !selectedDirectory.equals(deployDir.getText())) { - updating = true; - execute(new SetDeployDirectoryCommand(tomcatServer, selectedDirectory)); - deployDir.setText(selectedDirectory); - updating = false; - validate(); - } - } - }); - deployDirBrowse.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); - - initialize(); - } - - protected Label createLabel(FormToolkit toolkit, Composite parent, String text) { - Label label = toolkit.createLabel(parent, text); - label.setForeground(toolkit.getColors().getColor(IFormColors.TITLE)); - return label; - } - - /** - * @see ServerEditorSection#dispose() - */ - public void dispose() { - if (server != null) { - server.removePropertyChangeListener(listener); - if (server.getOriginal() != null) - server.getOriginal().removePublishListener(publishListener); - } - } - - /** - * @see ServerEditorSection#init(IEditorSite, IEditorInput) - */ - public void init(IEditorSite site, IEditorInput input) { - super.init(site, input); - - // Cache workspace and default deploy paths - IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - workspacePath = root.getLocation(); - defaultDeployPath = new Path(ITomcatServerWorkingCopy.DEFAULT_DEPLOYDIR); - - if (server != null) { - tomcatServer = (TomcatServer) server.loadAdapter(TomcatServer.class, null); - addChangeListeners(); - } - initialize(); - } - - /** - * Initialize the fields in this editor. - */ - protected void initialize() { - if (serverDir== null || tomcatServer == null) - return; - updating = true; - - IRuntime runtime = server.getRuntime(); - // If not Tomcat 3.2, update description to mention catalina.base - if (runtime != null && runtime.getRuntimeType().getId().indexOf("32") < 0) - section.setDescription(Messages.serverEditorLocationsDescription2); - if (runtime != null) - installDirPath = runtime.getLocation(); - - // determine if editing of locations is allowed - allowRestrictedEditing = false; - IPath basePath = tomcatServer.getRuntimeBaseDirectory(); - if (!readOnly) { - // If server has not been published, or server is published with no modules, allow editing - // TODO Find better way to determine if server hasn't been published - if ((basePath != null && !basePath.append("conf").toFile().exists()) - || (server.getOriginal().getServerPublishState() == IServer.PUBLISH_STATE_NONE - && server.getOriginal().getModules().length == 0)) { - allowRestrictedEditing = true; - } - } - - // Update server related fields - updateServerDirButtons(); - updateServerDirFields(); - - serverDirMetadata.setEnabled(allowRestrictedEditing); - serverDirInstall.setEnabled(allowRestrictedEditing); - serverDirCustom.setEnabled(allowRestrictedEditing); - - // Update deployment related fields - updateDefaultDeployLink(); - - deployDir.setText(tomcatServer.getDeployDirectory()); - - setDefaultDeployDir.setEnabled(allowRestrictedEditing); - deployDir.setEnabled(allowRestrictedEditing); - deployDirBrowse.setEnabled(allowRestrictedEditing); - - updating = false; - validate(); - } - - protected String getServerDir() { - String dir = null; - if (serverDir != null) { - dir = serverDir.getText().trim(); - IPath path = new Path(dir); - // Adjust if the temp dir is known and has been entered - if (tempDirPath != null && tempDirPath.equals(path)) - dir = null; - // If under the workspace, make relative - else if (workspacePath.isPrefixOf(path)) { - int cnt = path.matchingFirstSegments(workspacePath); - path = path.removeFirstSegments(cnt).setDevice(null); - dir = path.toOSString(); - } - } - return dir; - } - - protected void updateServerDirButtons() { - if (tomcatServer.getInstanceDirectory() == null) { - IPath path = tomcatServer.getRuntimeBaseDirectory(); - if (path.equals(installDirPath)) { - serverDirInstall.setSelection(true); - serverDirMetadata.setSelection(false); - serverDirCustom.setSelection(false); - } - else { - serverDirMetadata.setSelection(true); - serverDirInstall.setSelection(false); - serverDirCustom.setSelection(false); - } - } - else { - serverDirCustom.setSelection(true); - serverDirMetadata.setSelection(false); - serverDirInstall.setSelection(false); - } - } - - protected void updateServerDirFields() { - updateServerDir(); - boolean customServerDir = serverDirCustom.getSelection(); - serverDir.setEnabled(allowRestrictedEditing && customServerDir); - serverDirBrowse.setEnabled(allowRestrictedEditing && customServerDir); - } - - protected void updateServerDir() { - IPath path = tomcatServer.getRuntimeBaseDirectory(); - if (workspacePath.isPrefixOf(path)) { - int cnt = path.matchingFirstSegments(workspacePath); - path = path.removeFirstSegments(cnt).setDevice(null); - serverDir.setText(path.toOSString()); - // cache the relative temp dir path if that is what we have - if (tempDirPath == null) { - if (tomcatServer.isTestEnvironment() && tomcatServer.getInstanceDirectory() == null) - tempDirPath = path; - } - } - else - serverDir.setText(path.toOSString()); - } - - protected void updateDefaultDeployLink() { - boolean newState = defaultDeployPath.equals(new Path(tomcatServer.getDeployDirectory())); - if (newState != defaultDeployDirIsSet) { - setDefaultDeployDir.setText( - newState ? Messages.serverEditorSetDefaultDeployDirLink2 - : Messages.serverEditorSetDefaultDeployDirLink); - defaultDeployDirIsSet = newState; - } - } - - /** - * @see ServerEditorSection#getSaveStatus() - */ - public IStatus[] getSaveStatus() { - if (tomcatServer != null) { - // Check the instance directory - String dir = tomcatServer.getInstanceDirectory(); - if (dir != null) { - IPath path = new Path(dir); - // Must not be the same as the workspace location - if (dir.length() == 0 || workspacePath.equals(path)) { - return new IStatus [] { - new Status(IStatus.ERROR, TomcatUIPlugin.PLUGIN_ID, Messages.errorServerDirIsRoot)}; - } - // User specified value may not be under the ".metadata" folder of the workspace - else if (workspacePath.isPrefixOf(path) - || (!path.isAbsolute() && METADATADIR.equals(path.segment(0)))) { - int cnt = path.matchingFirstSegments(workspacePath); - if (METADATADIR.equals(path.segment(cnt))) { - return new IStatus [] { - new Status(IStatus.ERROR, TomcatUIPlugin.PLUGIN_ID, NLS.bind(Messages.errorServerDirUnderRoot, METADATADIR))}; - } - } - else if (installDirPath.equals(path)) - return new IStatus [] { - new Status(IStatus.ERROR, TomcatUIPlugin.PLUGIN_ID, - NLS.bind(Messages.errorServerDirCustomNotInstall, - NLS.bind(Messages.serverEditorServerDirInstall, "").trim()))}; - } - else { - IPath path = tomcatServer.getRuntimeBaseDirectory(); - // If non-custom instance dir is not the install and metadata isn't the selection, return error - if (!path.equals(installDirPath) && !serverDirMetadata.getSelection()) { - return new IStatus [] { - new Status(IStatus.ERROR, TomcatUIPlugin.PLUGIN_ID, - NLS.bind(Messages.errorServerDirCustomNotMetadata, - NLS.bind(Messages.serverEditorServerDirMetadata, "").trim()))}; - } - } - - // Check the deployment directory - dir = tomcatServer.getDeployDirectory(); - // Deploy directory must be set - if (dir == null || dir.length() == 0) { - return new IStatus [] { - new Status(IStatus.ERROR, TomcatUIPlugin.PLUGIN_ID, Messages.errorDeployDirNotSpecified)}; - } - } - // use default implementation to return success - return super.getSaveStatus(); - } - - protected void validate() { - if (tomcatServer != null) { - // Validate instance directory - String dir = tomcatServer.getInstanceDirectory(); - if (dir != null) { - IPath path = new Path(dir); - // Must not be the same as the workspace location - if (dir.length() == 0 || workspacePath.equals(path)) { - setErrorMessage(Messages.errorServerDirIsRoot); - return; - } - // User specified value may not be under the ".metadata" folder of the workspace - else if (workspacePath.isPrefixOf(path) - || (!path.isAbsolute() && METADATADIR.equals(path.segment(0)))) { - int cnt = path.matchingFirstSegments(workspacePath); - if (METADATADIR.equals(path.segment(cnt))) { - setErrorMessage(NLS.bind(Messages.errorServerDirUnderRoot, METADATADIR)); - return; - } - } - else if (installDirPath.equals(path)) { - setErrorMessage(NLS.bind(Messages.errorServerDirCustomNotInstall, - NLS.bind(Messages.serverEditorServerDirInstall, "").trim())); - return; - } - } - else { - IPath path = tomcatServer.getRuntimeBaseDirectory(); - // If non-custom instance dir is not the install and metadata isn't the selection, return error - if (!path.equals(installDirPath) && !serverDirMetadata.getSelection()) { - setErrorMessage(NLS.bind(Messages.errorServerDirCustomNotMetadata, - NLS.bind(Messages.serverEditorServerDirMetadata, "").trim())); - } - } - - // Check the deployment directory - dir = tomcatServer.getDeployDirectory(); - // Deploy directory must be set - if (dir == null || dir.length() == 0) { - setErrorMessage(Messages.errorDeployDirNotSpecified); - return; - } - } - // All is okay, clear any previous error - setErrorMessage(null); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/WebModuleDialog.java b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/WebModuleDialog.java deleted file mode 100644 index fda0aad00..000000000 --- a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/WebModuleDialog.java +++ /dev/null @@ -1,291 +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.jst.server.tomcat.ui.internal.editor; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jst.server.core.IWebModule; -import org.eclipse.jst.server.tomcat.core.internal.ITomcatConfiguration; -import org.eclipse.jst.server.tomcat.core.internal.ITomcatServer; -import org.eclipse.jst.server.tomcat.core.internal.WebModule; -import org.eclipse.jst.server.tomcat.ui.internal.ContextIds; -import org.eclipse.jst.server.tomcat.ui.internal.Messages; -import org.eclipse.jst.server.tomcat.ui.internal.Trace; -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.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.swt.widgets.Shell; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableItem; -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.IServerAttributes; -import org.eclipse.wst.server.core.ServerUtil; -import org.eclipse.wst.server.ui.ServerUICore; -/** - * Dialog to add or modify web modules. - */ -public class WebModuleDialog extends Dialog { - protected IModule module4; - protected WebModule module; - protected boolean isEdit; - protected boolean isProject; - protected Text docBase; - protected IServerAttributes server2; - protected ITomcatServer server; - protected ITomcatConfiguration config; - - protected Table projTable; - - /** - * WebModuleDialog constructor comment. - * - * @param parentShell a shell - * @param server2 a server - * @param server a Tomcat server - * @param config a Tomcat server configuration - * @param module a module - */ - public WebModuleDialog(Shell parentShell, IServerAttributes server2, ITomcatServer server, ITomcatConfiguration config, WebModule module) { - super(parentShell); - this.module = module; - this.server2 = server2; - this.server = server; - this.config = config; - isEdit = true; - } - - /** - * WebModuleDialog constructor comment. - * - * @param parentShell a shell - * @param server2 a server - * @param server a Tomcat server - * @param config a Tomcat server configuration - * @param isProject true if it is a project - */ - public WebModuleDialog(Shell parentShell, IServerAttributes server2, ITomcatServer server, ITomcatConfiguration config, boolean isProject) { - this(parentShell, server2, server, config, new WebModule("/", "", null, true)); - isEdit = false; - this.isProject = isProject; - } - - /** - * - */ - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - if (isEdit) - newShell.setText(Messages.configurationEditorWebModuleDialogTitleEdit); - else - newShell.setText(Messages.configurationEditorWebModuleDialogTitleAdd); - } - - /** - * Creates and returns the contents of the upper part - * of this dialog (above the button bar). - * <p> - * The <code>Dialog</code> implementation of this framework method - * creates and returns a new <code>Composite</code> with - * standard margins and spacing. Subclasses should override. - * </p> - * - * @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.numColumns = 3; - 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()); - IWorkbenchHelpSystem whs = PlatformUI.getWorkbench().getHelpSystem(); - whs.setHelp(composite, ContextIds.CONFIGURATION_EDITOR_WEBMODULE_DIALOG); - // add project field if we are adding a project - if (!isEdit && isProject) { - Label l = new Label(composite, SWT.NONE); - l.setText(Messages.configurationEditorWebModuleDialogProjects); - GridData data = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); - l.setLayoutData(data); - - projTable = new Table(composite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE); - data = new GridData(); - data.widthHint = 150; - data.heightHint = 75; - projTable.setLayoutData(data); - whs.setHelp(projTable, ContextIds.CONFIGURATION_EDITOR_WEBMODULE_DIALOG_PROJECT); - - // fill table with web module projects - ILabelProvider labelProvider = ServerUICore.getLabelProvider(); - IModule[] modules = ServerUtil.getModules(server2.getServerType().getRuntimeType().getModuleTypes()); - if (modules != null) { - int size = modules.length; - for (int i = 0; i < size; i++) { - IModule module3 = modules[i]; - if ("jst.web".equals(module3.getModuleType().getId())) { - IStatus status = server2.canModifyModules(new IModule[] { module3 }, null, null); - if (status != null && status.isOK()) { - TableItem item = new TableItem(projTable, SWT.NONE); - item.setText(0, labelProvider.getText(module3)); - item.setImage(0, labelProvider.getImage(module3)); - item.setData(module3); - } - } - } - } - labelProvider.dispose(); - new Label(composite, SWT.NONE).setText(" "); - } - - new Label(composite, SWT.NONE).setText(Messages.configurationEditorWebModuleDialogDocumentBase); - docBase = new Text(composite, SWT.BORDER); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - docBase.setLayoutData(data); - docBase.setText(module.getDocumentBase()); - whs.setHelp(docBase, ContextIds.CONFIGURATION_EDITOR_WEBMODULE_DIALOG_DOCBASE); - - // disable document base for project modules - if (isProject || (module.getMemento() != null && module.getMemento().length() > 0)) - docBase.setEditable(false); - else { - docBase.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - module = new WebModule(module.getPath(), docBase.getText(), module.getMemento(), module.isReloadable()); - validate(); - } - }); - } - - if (isEdit || isProject) - new Label(composite, SWT.NONE).setText(" "); - else { - Button browse = new Button(composite, SWT.NONE); - browse.setText(Messages.browse); - browse.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent se) { - try { - DirectoryDialog dialog = new DirectoryDialog(getShell()); - dialog.setMessage(Messages.configurationEditorWebModuleDialogSelectDirectory); - String selectedDirectory = dialog.open(); - if (selectedDirectory != null) - docBase.setText(selectedDirectory); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error browsing", e); - } - } - }); - } - - // path (context-root) - new Label(composite, SWT.NONE).setText(Messages.configurationEditorWebModuleDialogPath); - final Text path = new Text(composite, SWT.BORDER); - data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - data.widthHint = 150; - path.setLayoutData(data); - path.setText(module.getPath()); - /*if (module.getMemento() != null && module.getMemento().length() > 0) - path.setEditable(false); - else*/ - path.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - module = new WebModule(path.getText(), module.getDocumentBase(), module.getMemento(), module.isReloadable()); - } - }); - whs.setHelp(path, ContextIds.CONFIGURATION_EDITOR_WEBMODULE_DIALOG_PATH); - - new Label(composite, SWT.NONE).setText(""); - - if (!isProject) { - // auto reload - new Label(composite, SWT.NONE).setText(""); - final Button reloadable = new Button(composite, SWT.CHECK); - reloadable.setText(Messages.configurationEditorWebModuleDialogReloadEnabled); - data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - reloadable.setLayoutData(data); - reloadable.setSelection(module.isReloadable()); - reloadable.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - module = new WebModule(module.getPath(), module.getDocumentBase(), module.getMemento(), reloadable.getSelection()); - } - }); - whs.setHelp(reloadable, ContextIds.CONFIGURATION_EDITOR_WEBMODULE_DIALOG_RELOAD); - } - - if (!isEdit && isProject) { - projTable.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - try { - IModule module3 = (IModule) projTable.getSelection()[0].getData(); - IWebModule module2 = (IWebModule) module3.loadAdapter(IWebModule.class, null); - String contextRoot = module2.getContextRoot(); - if (contextRoot != null && !contextRoot.startsWith("/") && contextRoot.length() > 0) - contextRoot = "/" + contextRoot; - module = new WebModule(contextRoot, module3.getName(), module3.getId(), module.isReloadable()); - docBase.setText(module3.getName()); - path.setText(contextRoot); - module4 = module3; - } catch (Exception e) { - // ignore - } - validate(); - } - }); - new Label(composite, SWT.NONE).setText(""); - } - - Dialog.applyDialogFont(composite); - return composite; - } - - protected Control createButtonBar(Composite parent) { - Control control = super.createButtonBar(parent); - validate(); - - return control; - } - - protected void validate() { - boolean ok = true; - if (module.getDocumentBase() == null || module.getDocumentBase().length() < 1) - ok = false; - - getButton(IDialogConstants.OK_ID).setEnabled(ok); - } - - /** - * Return the mime mapping. - * - * @return org.eclipse.jst.server.tomcat.WebModule - */ - public WebModule getWebModule() { - return module; - } -} |