diff options
author | ndai | 2006-02-01 21:04:23 +0000 |
---|---|---|
committer | ndai | 2006-02-01 21:04:23 +0000 |
commit | 11898560d4e760ce28c82280b86accd7cc1c0eed (patch) | |
tree | 6d2165c1264bfdd2f899fee9d98dc47a6b3b2519 /plugins/org.eclipse.jst.server.generic.ui/src/org | |
parent | 288d94afc7055eb1083d55c05c560de250aa2fc9 (diff) | |
download | webtools.servertools-20060201.tar.gz webtools.servertools-20060201.tar.xz webtools.servertools-20060201.zip |
This commit was manufactured by cvs2svn to create tag 'v20060201'.v20060201
Diffstat (limited to 'plugins/org.eclipse.jst.server.generic.ui/src/org')
15 files changed, 0 insertions, 1377 deletions
diff --git a/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/GenericLaunchConfigurationTabGroup.java b/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/GenericLaunchConfigurationTabGroup.java deleted file mode 100644 index 5ec5c5514..000000000 --- a/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/GenericLaunchConfigurationTabGroup.java +++ /dev/null @@ -1,74 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2005 Eteration A.S. and Gorkem Ercan. All rights reserved. This program and the - * accompanying materials are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Gorkem Ercan - initial API and implementation - * - **************************************************************************************************/ -package org.eclipse.jst.server.generic.ui.internal; - -import java.util.ArrayList; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup; -import org.eclipse.debug.ui.CommonTab; -import org.eclipse.debug.ui.EnvironmentTab; -import org.eclipse.debug.ui.ILaunchConfigurationDialog; -import org.eclipse.debug.ui.ILaunchConfigurationTab; -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.jdt.debug.ui.launchConfigurations.JavaJRETab; -import org.eclipse.jst.server.generic.internal.core.util.ExtensionPointUtil; -import org.eclipse.wst.server.core.IServerType; -import org.eclipse.wst.server.core.ServerCore; -import org.eclipse.wst.server.ui.ServerLaunchConfigurationTab; - - -public class GenericLaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup{ - /** - * @see org.eclipse.debug.ui.ILaunchConfigurationTabGroup ILaunchConfigurationTabGroup#createTabs(ILaunchConfigurationDialog, String) - */ - public void createTabs(ILaunchConfigurationDialog dialog, String mode) { - ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[7]; - tabs[0] = new ServerLaunchConfigurationTab(getTypeIds()); - 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 JavaJRETab(); - tabs[5].setLaunchConfigurationDialog(dialog); - tabs[6] = new CommonTab(); - tabs[6].setLaunchConfigurationDialog(dialog); - setTabs(tabs); - } - - private String[] getTypeIds() { - ArrayList list = new ArrayList(); - IExtension[] extensions= ExtensionPointUtil.getGenericServerDefinitionExtensions(); - for (int i = 0; extensions!=null && i < extensions.length; i++) { - IExtension extension = extensions[i]; - IConfigurationElement[] elements = ExtensionPointUtil.getConfigurationElements(extension); - for (int j = 0; j < elements.length; j++) { - IConfigurationElement element = elements[j]; - String genericRuntimeID = element.getAttribute("id"); - IServerType[] serverTypes = ServerCore.getServerTypes(); - for (int k = 0; k < serverTypes.length; k++) { - if(serverTypes[k].hasRuntime() && serverTypes[k].getRuntimeType().getId().equals(genericRuntimeID)) - list.add(serverTypes[k].getId()); - } - } - } - return (String[])list.toArray(new String[list.size()]); - } - - -} diff --git a/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/GenericServerComposite.java b/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/GenericServerComposite.java deleted file mode 100644 index 699369bd6..000000000 --- a/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/GenericServerComposite.java +++ /dev/null @@ -1,34 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2005 Eteration A.S. and Gorkem Ercan. All rights reserved. This program and the - * accompanying materials are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Gorkem Ercan - initial API and implementation - * - **************************************************************************************************/ -package org.eclipse.jst.server.generic.ui.internal; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; - -public class GenericServerComposite extends Composite { - - private GenericServerCompositeDecorator[] fDecorators; - public GenericServerComposite(Composite parent, GenericServerCompositeDecorator[] decorators) { - super(parent, SWT.NONE); - fDecorators = decorators; - GridLayout layout =new GridLayout(3,false); - setLayout(layout); - setLayoutData(new GridData(GridData.FILL_BOTH)); - createControl(); - } - - private void createControl(){ - for (int i = 0; fDecorators!= null && i < fDecorators.length; i++) { - fDecorators[i].decorate(this); - } - } -} diff --git a/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/GenericServerCompositeDecorator.java b/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/GenericServerCompositeDecorator.java deleted file mode 100644 index 232f356d5..000000000 --- a/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/GenericServerCompositeDecorator.java +++ /dev/null @@ -1,31 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2005 Eteration A.S. and Gorkem Ercan. All rights reserved. This program and the - * accompanying materials are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Gorkem Ercan - initial API and implementation - * - **************************************************************************************************/ -package org.eclipse.jst.server.generic.ui.internal; - - -/** - * - * @author Gorkem Ercan - */ -public interface GenericServerCompositeDecorator -{ - /** - * - * @param composite - */ - public abstract void decorate(GenericServerComposite composite); - /** - * Called if all the fields are valid. This gives subclasses opportunity to - * validate and take necessary actions. - * - * @return - */ - public abstract boolean validate(); -} diff --git a/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/GenericServerRuntimeWizardFragment.java b/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/GenericServerRuntimeWizardFragment.java deleted file mode 100644 index d9c9f4fed..000000000 --- a/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/GenericServerRuntimeWizardFragment.java +++ /dev/null @@ -1,166 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2005 Eteration A.S. and Gorkem Ercan. All rights reserved. This program and the - * accompanying materials are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Gorkem Ercan - initial API and implementation - * - **************************************************************************************************/ -package org.eclipse.jst.server.generic.ui.internal; - -import java.util.Map; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.jst.server.generic.core.internal.GenericServerRuntime; -import org.eclipse.jst.server.generic.servertype.definition.ServerRuntime; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.wst.server.core.IRuntime; -import org.eclipse.wst.server.core.IRuntimeType; -import org.eclipse.wst.server.core.IRuntimeWorkingCopy; -import org.eclipse.wst.server.core.ServerCore; -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.core.model.RuntimeDelegate; -import org.eclipse.wst.server.ui.wizard.IWizardHandle; - -/** - * A serverDefinitionType aware wizard for defining runtimes. - * - * @author Gorkem Ercan - */ -public class GenericServerRuntimeWizardFragment extends ServerDefinitionTypeAwareWizardFragment { - - private GenericServerCompositeDecorator[] fDecorators; - - - /** - * Constructor - */ - public GenericServerRuntimeWizardFragment() { - super(); - } - /* (non-Javadoc) - * @see org.eclipse.wst.server.ui.wizard.IWizardFragment#isComplete() - */ - public boolean isComplete() { - RuntimeDelegate runtime = getRuntimeDelegate(); - if (runtime == null) - return false; - IStatus status = runtime.validate(); - return (status != null && status.isOK()); - } - - public void createContent(Composite parent, IWizardHandle handle) { - Map properties= null; - ServerRuntime definition=null; - if(getRuntimeDelegate()!=null){ - properties = getRuntimeDelegate().getServerInstanceProperties(); - definition = getServerTypeDefinition(getServerDefinitionId(),properties); - } - IInstallableRuntime ir = ServerPlugin.findInstallableRuntime(getRuntimeDelegate().getRuntime().getRuntimeType().getId()); - if (ir!= null){ - fDecorators= new GenericServerCompositeDecorator[3]; - fDecorators[0]= new JRESelectDecorator(getRuntimeDelegate()); - fDecorators[1]= new ServerTypeDefinitionRuntimeDecorator(definition,properties,getWizard(),getRuntimeDelegate()); - fDecorators[2]= new InstallableRuntimeDecorator(getRuntimeDelegate()); - } - else{ - fDecorators= new GenericServerCompositeDecorator[2]; - fDecorators[0]= new JRESelectDecorator(getRuntimeDelegate()); - fDecorators[1]= new ServerTypeDefinitionRuntimeDecorator(definition,properties,getWizard(),getRuntimeDelegate()); - } - - new GenericServerComposite(parent,fDecorators); - } - - - private String getServerDefinitionId(){ - String currentDefinition= null; - if(getRuntimeDelegate()!=null) - currentDefinition = getRuntimeDelegate().getRuntime().getRuntimeType().getId(); - if(currentDefinition!= null && currentDefinition.length()>0) - { - return currentDefinition; - } - return null; - } - - - - /* (non-Javadoc) - * @see org.eclipse.wst.server.ui.wizard.IWizardFragment#enter() - */ - public void enter() { - if(getRuntimeDelegate()!=null) - getRuntimeDelegate().getRuntimeWorkingCopy().setName(createName()); - - for (int i = 0; i < fDecorators.length; i++) { - if(fDecorators[i].validate()) - return; - } - } - - public void exit() { - //validate to save latest values - for (int i = 0; i < fDecorators.length; i++) { - if(fDecorators[i].validate()) - return; - } - } - - - private String createName() - { - RuntimeDelegate dl = getRuntimeDelegate(); - IRuntimeType runtimeType = dl.getRuntime().getRuntimeType(); - String name = GenericServerUIMessages.bind(GenericServerUIMessages.runtimeName,runtimeType.getName()); - IRuntime[] list = ServerCore.getRuntimes(); - int suffix = 1; - String suffixName=name; - for(int i=0;i<list.length;i++) - { - if((list[i].getName().equals(name)|| list[i].getName().equals(suffixName))&& !list[i].equals(dl.getRuntime())) - suffix++; - suffixName= name+" "+suffix; - } - - if(suffix>1) - return suffixName; - return name; - } - - private GenericServerRuntime getRuntimeDelegate(){ - IRuntimeWorkingCopy wc = (IRuntimeWorkingCopy) getTaskModel().getObject(TaskModel.TASK_RUNTIME); - if (wc == null) - return null; - return (GenericServerRuntime) wc.loadAdapter(GenericServerRuntime.class, new NullProgressMonitor()); - } - /* (non-Javadoc) - * @see org.eclipse.jst.server.generic.internal.ui.ServerDefinitionTypeAwareWizardFragment#description() - */ - public String description() { - String rName = getRuntimeName(); - if(rName == null || rName.length()<1) - rName="Generic"; - return GenericServerUIMessages.bind(GenericServerUIMessages.runtimeWizardDescription,rName); - } - /* (non-Javadoc) - * @see org.eclipse.jst.server.generic.internal.ui.ServerDefinitionTypeAwareWizardFragment#title() - */ - public String title() { - String rName = getRuntimeName(); - if(rName == null || rName.length()<1) - rName="Generic"; - return GenericServerUIMessages.bind(GenericServerUIMessages.runtimeWizardTitle,rName); - } - - private String getRuntimeName() - { - if(getRuntimeDelegate()!=null && getRuntimeDelegate().getRuntime()!=null) - return getRuntimeDelegate().getRuntime().getName(); - return null; - } - -} diff --git a/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/GenericServerUIMessages.java b/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/GenericServerUIMessages.java deleted file mode 100644 index be0866ab0..000000000 --- a/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/GenericServerUIMessages.java +++ /dev/null @@ -1,41 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2005 Eteration A.S. and Gorkem Ercan. All rights reserved. This program and the - * accompanying materials are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Gorkem Ercan - initial API and implementation - * - **************************************************************************************************/ -package org.eclipse.jst.server.generic.ui.internal; - -import org.eclipse.osgi.util.NLS; - -/** - * Helper class to get messages - * - * @author Gorkem Ercan - */ -public class GenericServerUIMessages extends NLS{ - - private static final String RESOURCE_BUNDLE= "org.eclipse.jst.server.generic.ui.internal.GenericServerUIMessages";//$NON-NLS-1$ - public static String serverTypeGroup_label_browse; - public static String runtimeName; - public static String runtimeWizardDescription; - public static String runtimeWizardTitle; - public static String serverName; - public static String serverWizardDescription; - public static String serverWizardTitle; - public static String installed_jre_link; - public static String jre_select_label; - public static String defaultJRE; - public static String invalidPath; - public static String installServerButton; - public static String installationDirectory; - - static{ - NLS.initializeMessages(RESOURCE_BUNDLE, GenericServerUIMessages.class); - } - - -} diff --git a/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/GenericServerUIMessages.properties b/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/GenericServerUIMessages.properties deleted file mode 100644 index 32c952297..000000000 --- a/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/GenericServerUIMessages.properties +++ /dev/null @@ -1,22 +0,0 @@ -################################################################################################## -# Copyright (c) 2005 Eteration A.S. and Gorkem Ercan. All rights reserved. This program and the -# accompanying materials are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: Gorkem Ercan - initial API and implementation -# -################################################################################################### -serverWizardTitle=New {0} Server -serverWizardDescription=Create a new {0} server -runtimeWizardTitle=New {0} Runtime -runtimeWizardDescription=Define a new {0} runtime -serverTypeGroup_label_browse=Browse... -serverName = {0} -runtimeName= {0} -installed_jre_link = You can use <a>Installed JRE preferences</a> to create a new JRE -installServerButton=Install Server -installationDirectory=Select installation directory -jre_select_label= &JRE: -defaultJRE = Default JRE -invalidPath = {0} is not valid
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/GenericServerWizardFragment.java b/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/GenericServerWizardFragment.java deleted file mode 100644 index 91003b2dd..000000000 --- a/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/GenericServerWizardFragment.java +++ /dev/null @@ -1,148 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2005 Eteration A.S. and Gorkem Ercan. All rights reserved. This program and the - * accompanying materials are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Gorkem Ercan - initial API and implementation - * - **************************************************************************************************/ -package org.eclipse.jst.server.generic.ui.internal; - -import java.util.Map; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.jst.server.generic.core.internal.GenericServer; -import org.eclipse.jst.server.generic.core.internal.GenericServerRuntime; -import org.eclipse.jst.server.generic.servertype.definition.ServerRuntime; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.wst.server.core.IRuntime; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.IServerWorkingCopy; -import org.eclipse.wst.server.core.ServerCore; -import org.eclipse.wst.server.core.TaskModel; -import org.eclipse.wst.server.ui.wizard.IWizardHandle; -/** - * - * - * @author Gorkem Ercan - */ -public class GenericServerWizardFragment extends ServerDefinitionTypeAwareWizardFragment -{ - private GenericServerCompositeDecorator[] fDecorators; - - /** - * - */ - public boolean isComplete() { - - ServerRuntime serverRuntime = getServerTypeDefinitionFor(getServer()); - if(serverRuntime==null) - return false; - - IServerWorkingCopy server = getServer(); - GenericServer dl= (GenericServer)server.loadAdapter(GenericServer.class,null); - - IStatus status = dl.validate(); - return (status != null && status.isOK()); - - } - - public void createContent(Composite parent, IWizardHandle handle){ - IServerWorkingCopy server = getServer(); - GenericServer dl= (GenericServer)server.loadAdapter(GenericServer.class,null); - ServerRuntime definition = getServerTypeDefinitionFor(server); - fDecorators = new GenericServerCompositeDecorator[1]; - fDecorators[0]=new ServerTypeDefinitionServerDecorator(definition,null,getWizard(),dl); - new GenericServerComposite(parent,fDecorators); - - } - /** - * @param server - * @return - */ - private ServerRuntime getServerTypeDefinitionFor(IServerWorkingCopy server) { - GenericServerRuntime runtime = (GenericServerRuntime)server.getRuntime().getAdapter(GenericServerRuntime.class); - if(runtime==null){ - IRuntime wc = (IRuntime)getTaskModel().getObject(TaskModel.TASK_RUNTIME); - runtime= (GenericServerRuntime)wc.getAdapter(GenericServerRuntime.class); - if(runtime==null) - runtime= (GenericServerRuntime)wc.loadAdapter(GenericServerRuntime.class,new NullProgressMonitor()); - } - String id = runtime.getRuntime().getRuntimeType().getId(); - if(id==null){ - return null; - } - Map runtimeProperties = runtime.getServerInstanceProperties(); - ServerRuntime definition = getServerTypeDefinition(id,runtimeProperties); - return definition; - } - - /** - * @return - */ - private IServerWorkingCopy getServer() { - IServerWorkingCopy server = (IServerWorkingCopy)getTaskModel().getObject(TaskModel.TASK_SERVER); - return server; - } - - private boolean isNameInUse(String name){ - IServer[] servers =ServerCore.getServers(); - for (int i = 0; i < servers.length; i++) { - if(!servers[i].equals(getServer().getOriginal()) && (servers[i].getName().equals(name) )) - return true; - } - return false; - } - - private String createName(){ - String name = GenericServerUIMessages.bind(GenericServerUIMessages.serverName,getServerTypeDefinitionFor(getServer()).getName()); - int suffix=1; - String suffixName =name; - while(isNameInUse(suffixName)){ - suffixName = name+" "+suffix; - suffix++; - } - return suffixName; - } - public void enter() { - getServer().setName(createName()); - for (int i = 0; i < fDecorators.length; i++) { - if(fDecorators[i].validate()) - return; - } - } - public void exit() { - //validate needed to save the latest values. - for (int i = 0; i < fDecorators.length; i++) { - if(fDecorators[i].validate()) - return; - } - } - /* (non-Javadoc) - * @see org.eclipse.jst.server.generic.internal.ui.ServerDefinitionTypeAwareWizardFragment#description() - */ - public String description() { - String sName = getServerName(); - if(sName==null || sName.length()<1) - sName="Generic"; - return GenericServerUIMessages.bind(GenericServerUIMessages.serverWizardDescription,sName); - } - - private String getServerName() - { - if(getServer()!=null && getServer().getRuntime()!=null) - return getServer().getRuntime().getRuntimeType().getName(); - return null; - } - /* (non-Javadoc) - * @see org.eclipse.jst.server.generic.internal.ui.ServerDefinitionTypeAwareWizardFragment#title() - */ - public String title() { - String sName= getServerName(); - if(sName==null || sName.length()<1) - sName="Generic"; - return GenericServerUIMessages.bind(GenericServerUIMessages.serverWizardTitle,sName); - } -} diff --git a/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/GenericUiPlugin.java b/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/GenericUiPlugin.java deleted file mode 100644 index fff5a81ce..000000000 --- a/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/GenericUiPlugin.java +++ /dev/null @@ -1,93 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2005 Eteration A.S. and Gorkem Ercan. All rights reserved. This program and the - * accompanying materials are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Gorkem Ercan - initial API and implementation - * - **************************************************************************************************/ -package org.eclipse.jst.server.generic.ui.internal; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.ImageRegistry; -import org.eclipse.ui.plugin.*; -import org.osgi.framework.BundleContext; -import java.util.*; - -/** - * The main plugin class to be used in the desktop. - * - * @author Gorkem Ercan - */ -public class GenericUiPlugin extends AbstractUIPlugin { - - public static final String WIZBAN_IMAGE = "genericlogo"; - //The shared instance. - private static GenericUiPlugin plugin; - //Resource bundle. - private ResourceBundle resourceBundle; - - /** - * The constructor. - */ - public GenericUiPlugin() { - super(); - plugin = this; - try { - resourceBundle = ResourceBundle.getBundle("org.eclipse.jst.server.generic.ui.GenericUiPluginResources"); - } catch (MissingResourceException x) { - resourceBundle = null; - } - } - - /** - * This method is called upon plug-in activation - */ - public void start(BundleContext context) throws Exception { - super.start(context); - } - - /** - * This method is called when the plug-in is stopped - */ - public void stop(BundleContext context) throws Exception { - super.stop(context); - } - - /** - * Returns the shared instance. - */ - public static GenericUiPlugin getDefault() { - return plugin; - } - - /** - * Returns the string from the plugin's resource bundle, - * or 'key' if not found. - */ - public static String getResourceString(String key) { - ResourceBundle bundle = GenericUiPlugin.getDefault().getResourceBundle(); - try { - return (bundle != null) ? bundle.getString(key) : key; - } catch (MissingResourceException e) { - return key; - } - } - - protected ImageRegistry createImageRegistry() { - ImageRegistry registry = new ImageRegistry(); - ImageDescriptor desc = ImageDescriptor.createFromURL(getDefault().getBundle().getEntry("/icons/wizban/new_server_wiz.gif")); - registry.put(WIZBAN_IMAGE,desc); - return registry; - } - public ImageDescriptor imageDescriptor(String key){ - return getImageRegistry().getDescriptor(key); - } - /** - * Returns the plugin's resource bundle, - */ - public ResourceBundle getResourceBundle() { - return resourceBundle; - } -} diff --git a/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/InstallableRuntimeDecorator.java b/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/InstallableRuntimeDecorator.java deleted file mode 100644 index c72352925..000000000 --- a/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/InstallableRuntimeDecorator.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.eclipse.jst.server.generic.ui.internal; - -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.jst.server.generic.core.internal.GenericServerRuntime; -import org.eclipse.jst.server.generic.core.internal.Trace; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.DirectoryDialog; -import org.eclipse.wst.server.core.internal.IInstallableRuntime; -import org.eclipse.wst.server.core.internal.ServerPlugin; - -public class InstallableRuntimeDecorator implements - GenericServerCompositeDecorator { - - private GenericServerRuntime fRuntime; - - public InstallableRuntimeDecorator(GenericServerRuntime runtime) { - fRuntime = runtime; - } - - public void decorate(final GenericServerComposite composite) { - final IInstallableRuntime ir = ServerPlugin - .findInstallableRuntime(fRuntime.getRuntime().getRuntimeType() - .getId()); - - Button install = SWTUtil.createButton(composite, GenericServerUIMessages.installServerButton); - install.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent se) { - DirectoryDialog dialog = new DirectoryDialog(composite - .getShell()); - dialog.setMessage(GenericServerUIMessages.installationDirectory); - String selectedDirectory = dialog.open(); - if (selectedDirectory != null) { - try { - ir.install(new Path(selectedDirectory), - new NullProgressMonitor()); - } catch (Exception e) { - Trace - .trace(Trace.SEVERE, - "Error installing runtime", e); //$NON-NLS-1$ - } - - } - } - }); - } - - public boolean validate() { - return false; - } - -} diff --git a/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/JRESelectDecorator.java b/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/JRESelectDecorator.java deleted file mode 100644 index e54bbf1d7..000000000 --- a/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/JRESelectDecorator.java +++ /dev/null @@ -1,140 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2005 Eteration A.S. and Gorkem Ercan. All rights reserved. This program and the - * accompanying materials are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Gorkem Ercan - initial API and implementation - * - **************************************************************************************************/ -package org.eclipse.jst.server.generic.ui.internal; - -import java.util.ArrayList; -import java.util.List; -import org.eclipse.jdt.launching.IVMInstall; -import org.eclipse.jdt.launching.IVMInstallType; -import org.eclipse.jdt.launching.JavaRuntime; -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.jst.server.generic.core.internal.GenericServerRuntime; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.BusyIndicator; -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.widgets.Combo; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Link; -import org.eclipse.ui.PlatformUI; - - -public class JRESelectDecorator implements GenericServerCompositeDecorator { - private List installedJREs; - private String[] jreNames; - private GenericServerRuntime fRuntime; - public JRESelectDecorator(GenericServerRuntime runtime){ - super(); - fRuntime = runtime; - } - - public void decorate(final GenericServerComposite composite) { - updateJREs(); - Link link = new Link(composite,SWT.NONE); - link.setLayoutData(new GridData(SWT.FILL,SWT.NONE,true,false,3,1)); - link.setText(GenericServerUIMessages.installed_jre_link); - - Label label = new Label(composite, SWT.NONE); - label.setText(GenericServerUIMessages.jre_select_label); - - final Combo combo = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY); - combo.setItems(jreNames); - GridData data = new GridData(SWT.FILL,SWT.NONE,false,false,2,1); - - 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); - - fRuntime.setVMInstall(vmInstall); - validate(); - } - - public void widgetDefaultSelected(SelectionEvent e) { - widgetSelected(e); - } - }); - - link.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - String currentVM = combo.getText(); - if (showPreferencePage(composite)) { - updateJREs(); - combo.setItems(jreNames); - combo.setText(currentVM); - if (combo.getSelectionIndex() == -1) - combo.select(0); - } - } - }); - - if (fRuntime!=null){ - if(fRuntime.isUsingDefaultJRE()){ - combo.select(0); - }else{ - combo.setText(fRuntime.getVMInstall().getName()); - } - } - } - - - protected boolean showPreferencePage(GenericServerComposite composite) { - PreferenceManager manager = PlatformUI.getWorkbench().getPreferenceManager(); - IPreferenceNode node = manager.find("org.eclipse.jdt.ui.preferences.JavaBasePreferencePage").findSubNode("org.eclipse.jdt.debug.ui.preferences.VMPreferencePage"); - PreferenceManager manager2 = new PreferenceManager(); - manager2.addToRoot(node); - final PreferenceDialog dialog = new PreferenceDialog(composite.getShell(), manager2); - final boolean[] result = new boolean[] { false }; - BusyIndicator.showWhile(composite.getDisplay(), new Runnable() { - public void run() { - dialog.create(); - if (dialog.open() == Window.OK) - result[0] = true; - } - }); - return result[0]; - } - - protected void updateJREs() { - 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]); - } - } - - size = installedJREs.size(); - jreNames = new String[size+1]; - jreNames[0] = GenericServerUIMessages.defaultJRE; - for (int i = 0; i < size; i++) { - IVMInstall vmInstall = (IVMInstall) installedJREs.get(i); - jreNames[i+1] = vmInstall.getName(); - } - } - - - - public boolean validate() { - return false; - } -} diff --git a/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/SWTUtil.java b/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/SWTUtil.java deleted file mode 100644 index 4964138d1..000000000 --- a/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/SWTUtil.java +++ /dev/null @@ -1,88 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2005 Eteration A.S. and Gorkem Ercan. All rights reserved. This program and the - * accompanying materials are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Gorkem Ercan - initial API and implementation - * - **************************************************************************************************/ -package org.eclipse.jst.server.generic.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. - * Copied from org.eclipse.wst.server.ui.internal. - */ -public class SWTUtil { - private static FontMetrics fontMetrics; - - protected static void initializeDialogUnits(Control testControl) { - // Compute and store a font metric - GC gc = new GC(testControl); - gc.setFont(JFaceResources.getDialogFont()); - fontMetrics = gc.getFontMetrics(); - gc.dispose(); - } - - /** - * Returns a width hint for a button control. - */ - protected static int getButtonWidthHint(Button button) { - int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH); - return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); - } - - /** - * Create a new button with the standard size. - * - * @param comp the component to add the button to - * @param label the button label - * @return a button - */ - public static Button createButton(Composite comp, String label) { - Button b = new Button(comp, SWT.PUSH); - b.setText(label); - if (fontMetrics == null) - initializeDialogUnits(comp); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING); - data.widthHint = getButtonWidthHint(b); - b.setLayoutData(data); - return b; - } - - /** - * Convert DLUs to pixels. - * - * @param comp a component - * @param x pixels - * @return dlus - */ - public static int convertHorizontalDLUsToPixels(Composite comp, int x) { - if (fontMetrics == null) - initializeDialogUnits(comp); - return Dialog.convertHorizontalDLUsToPixels(fontMetrics, x); - } - - /** - * Convert DLUs to pixels. - * - * @param comp a component - * @param y pixels - * @return dlus - */ - public static int convertVerticalDLUsToPixels(Composite comp, int y) { - if (fontMetrics == null) - initializeDialogUnits(comp); - return Dialog.convertVerticalDLUsToPixels(fontMetrics, y); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/ServerDefinitionTypeAwareWizardFragment.java b/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/ServerDefinitionTypeAwareWizardFragment.java deleted file mode 100644 index 1a910d17c..000000000 --- a/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/ServerDefinitionTypeAwareWizardFragment.java +++ /dev/null @@ -1,80 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2005 Eteration A.S. and Gorkem Ercan. All rights reserved. This program and the - * accompanying materials are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Gorkem Ercan - initial API and implementation - * - **************************************************************************************************/ -package org.eclipse.jst.server.generic.ui.internal; - -import java.util.Map; - -import org.eclipse.jst.server.generic.core.internal.CorePlugin; -import org.eclipse.jst.server.generic.servertype.definition.ServerRuntime; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.wst.server.ui.wizard.IWizardHandle; -import org.eclipse.wst.server.ui.wizard.WizardFragment; - -/** - * A wizard fragment that provides support for serverdef files. - * - * @author Gorkem Ercan - */ -public abstract class ServerDefinitionTypeAwareWizardFragment extends WizardFragment { - - private IWizardHandle fWizard; - - public boolean hasComposite() { - return true; - } - - public Composite createComposite(Composite parent, IWizardHandle handle) { - - this.fWizard = handle; - Composite container = new Composite(parent, SWT.NONE); - GridLayout grid = new GridLayout(1,false); - grid.marginWidth=0; - container.setLayout(grid); - container.setLayoutData(new GridData(GridData.FILL_BOTH)); - handle.setImageDescriptor(GenericUiPlugin.getDefault().imageDescriptor(GenericUiPlugin.WIZBAN_IMAGE)); - handle.setTitle(title()); - handle.setDescription(description()); - createContent(container,handle); - return container; - } - public IWizardHandle getWizard(){ - return fWizard; - } - /** - * Returns the description to be displayed on the wizard head. - * @return - */ - public abstract String description(); - /** - * Returns the title of the wizard. - * @return - */ - public abstract String title(); - /** - * Create the real content - * @param parent - * @param handle - */ - public abstract void createContent(Composite parent, IWizardHandle handle); - - /** - * Retuns the ServerRuntime. - * @param definitionID - * @param properties - * @return - */ - protected ServerRuntime getServerTypeDefinition(String definitionID, Map properties) - { - return CorePlugin.getDefault().getServerTypeDefinitionManager().getServerRuntimeDefinition(definitionID,properties); - } -} diff --git a/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/ServerTypeDefinitionDecorator.java b/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/ServerTypeDefinitionDecorator.java deleted file mode 100644 index 02865cfcf..000000000 --- a/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/ServerTypeDefinitionDecorator.java +++ /dev/null @@ -1,303 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2005 Eteration A.S. and Gorkem Ercan. All rights reserved. This program and the - * accompanying materials are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Gorkem Ercan - initial API and implementation - * - **************************************************************************************************/ -package org.eclipse.jst.server.generic.ui.internal; - -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.StringTokenizer; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IMessageProvider; -import org.eclipse.jst.server.generic.servertype.definition.Property; -import org.eclipse.jst.server.generic.servertype.definition.ServerRuntime; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.DirectoryDialog; -import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; -import org.eclipse.jst.server.generic.ui.internal.SWTUtil; -import org.eclipse.wst.server.ui.wizard.IWizardHandle; -/** - * Provides the UI objects for gathering user information - * for server properties. - * - * @author Gorkem Ercan - */ -public abstract class ServerTypeDefinitionDecorator implements GenericServerCompositeDecorator { - - protected static final String CONTEXT_RUNTIME = Property.CONTEXT_RUNTIME; - protected static final String CONTEXT_SERVER = Property.CONTEXT_SERVER; - private ServerRuntime fDefinition; - private Map fProperties; - private String fContext; - private String fLastMessage = null; - protected IWizardHandle fWizard; - private List fPropertyControls= new ArrayList(); - - private final class PathModifyListener implements ModifyListener { - public void modifyText(ModifyEvent e) { - String path = ((Text) e.widget).getText(); - if(!pathExist(path)){ - fLastMessage = GenericServerUIMessages.bind(GenericServerUIMessages.invalidPath,path); - fWizard.setMessage(fLastMessage,IMessageProvider.ERROR); - }else{ - if(fLastMessage!=null && fLastMessage.equals(fWizard.getMessage())){ - fLastMessage=null; - fWizard.setMessage(null,IMessageProvider.NONE); - } - validate(); - } - } - private boolean pathExist(String path){ - File f = new File(path); - return f.exists(); - } - } - - - public ServerTypeDefinitionDecorator(ServerRuntime definition, Map initialProperties, String context, IWizardHandle handle) { - super(); - fDefinition = definition; - fProperties = initialProperties; - fContext = context; - fWizard = handle; - } - - public void decorate(GenericServerComposite composite) { - - List properties =null; - if(fDefinition==null){ - properties= new ArrayList(0); - } - else{ - properties= fDefinition.getProperty(); - } - for (int i = 0; i < properties.size(); i++) { - Property property = (Property) properties.get(i); - if (this.fContext.equals(property.getContext())) - createPropertyControl(composite, property); - } - Dialog.applyDialogFont(composite); - } - - - private void createPropertyControl(Composite parent, Property property){ - if( Property.TYPE_DIRECTORY.equals(property.getType())) { - Text path = createLabeledPath(property.getLabel(),getPropertyValue(property),parent); - path.setData(property); - registerControl(path); - } else if( Property.TYPE_FILE.equals(property.getType())) { - Text file = createLabeledFile(property.getLabel(),getPropertyValue(property),parent); - file.setData(property); - registerControl(file); - } else if( Property.TYPE_TEXT.equals(property.getType())) { - Text str = createLabeledText(property.getLabel(),getPropertyValue(property),parent); - str.setData(property); - registerControl(str); - } else if( Property.TYPE_BOOLEAN.equals(property.getType())) { - Button bool =createLabeledCheck(property.getLabel(),("true".equals( getPropertyValue(property))), parent); - bool.setData(property); - registerControl(bool); - }else if(Property.TYPE_SELECT.equals(property.getType())) { - Combo combo = createLabeledCombo(parent, property); - combo.setData(property); - registerControl(combo); - } - else { - Text defaultText= createLabeledText(property.getLabel(),getPropertyValue(property),parent); - defaultText.setData(property); - registerControl(defaultText); - } - } - - private Combo createLabeledCombo(Composite defPanel, Property property) { - - GridData gridData; - Label label = new Label(defPanel, SWT.WRAP); - gridData = new GridData(); - label.setLayoutData(gridData); - label.setText(property.getLabel()); - - Combo combo = new Combo(defPanel,SWT.READ_ONLY); - gridData = new GridData(GridData.FILL_HORIZONTAL - | GridData.GRAB_HORIZONTAL); - gridData.horizontalSpan = 2; - combo.setLayoutData(gridData); - - StringTokenizer tokenizer = new StringTokenizer(property.getDefault(),","); - while(tokenizer.hasMoreTokens()){ - combo.add(tokenizer.nextToken()); - } - if(combo.getItemCount()>0) - combo.select(0); - return combo; - } - private void registerControl(Control control) - { - fPropertyControls.add(control); - } - private Button createLabeledCheck(String title, boolean value, Composite defPanel) { - GridData gridData; - Label label = new Label(defPanel, SWT.WRAP); - gridData = new GridData(); - label.setLayoutData(gridData); - label.setText(title); - - Button fButton = new Button(defPanel, SWT.CHECK); - - gridData = new GridData(GridData.FILL_HORIZONTAL - | GridData.GRAB_HORIZONTAL); - gridData.horizontalSpan = 2; - fButton.setLayoutData(gridData); - fButton.setSelection(value); - fButton.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - - } - - public void widgetDefaultSelected(SelectionEvent e) { - - } - }); - - return fButton; - } - private Text createLabeledFile(String title, String value,final Composite defPanel) { - GridData gridData; - Label label = new Label(defPanel, SWT.WRAP); - gridData = new GridData(); - label.setLayoutData(gridData); - label.setText(title); - - final Text text = new Text(defPanel, SWT.SHADOW_IN | SWT.BORDER); - gridData = new GridData(GridData.FILL_HORIZONTAL - | GridData.GRAB_HORIZONTAL); - gridData.horizontalSpan = 1; - text.setLayoutData(gridData); - text.setText(value); - text.addModifyListener(new PathModifyListener()); - Button fButton = SWTUtil.createButton(defPanel,GenericServerUIMessages.serverTypeGroup_label_browse); - - fButton.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - FileDialog dlg = new FileDialog(defPanel.getShell()); - dlg.setFileName(text.getText().replace('\\','/')); - String res = dlg.open(); - if (res != null) { - text.setText(res.replace('\\','/')); - - } - } - - public void widgetDefaultSelected(SelectionEvent e) { - widgetSelected(e); - } - - }); - - return text; - } - - private Text createLabeledPath(String title, String value, - final Composite parent) { - GridData gridData; - Label label = new Label(parent, SWT.WRAP); - gridData = new GridData(); - label.setLayoutData(gridData); - label.setText(title); - - final Text text = new Text(parent, SWT.SHADOW_IN | SWT.BORDER); - gridData = new GridData(GridData.FILL_HORIZONTAL); - gridData.horizontalSpan = 1; - text.setLayoutData(gridData); - text.setText(value); - text.addModifyListener(new PathModifyListener()); - Button fButton = SWTUtil.createButton(parent,GenericServerUIMessages.serverTypeGroup_label_browse); - fButton.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - DirectoryDialog dlg = new DirectoryDialog(parent.getShell()); - dlg.setFilterPath(text.getText().replace('\\','/')); - String res = dlg.open(); - if (res != null) { - text.setText(res.replace('\\','/')); - - } - } - - public void widgetDefaultSelected(SelectionEvent e) { - widgetSelected(e); - } - - }); - return text; - } - private Text createLabeledText(String title, String value, - Composite defPanel) { - GridData gridData; - Label label = new Label(defPanel, SWT.WRAP); - gridData = new GridData(); - label.setLayoutData(gridData); - label.setText(title); - - Text text = new Text(defPanel, SWT.SHADOW_IN | SWT.BORDER); - gridData = new GridData(GridData.FILL_HORIZONTAL - | GridData.GRAB_HORIZONTAL); - gridData.horizontalSpan = 2; - text.setLayoutData(gridData); - text.setText(value); - - return text; - } - private String getPropertyValue(Property property) - { - String value = property.getDefault(); - if(fProperties!=null && fProperties.isEmpty()==false) - value=(String)fProperties.get(property.getId()); - return value; - } - - - - /** - * Returns the property name/value pairs. - * @return - */ - public Map getValues(){ - Map propertyMap = new HashMap(); - for(int i=0; i<fPropertyControls.size();i++){ - Property prop = (Property)((Control)fPropertyControls.get(i)).getData(); - if(fPropertyControls.get(i)instanceof Button){ - Button button = (Button)fPropertyControls.get(i); - propertyMap.put(prop.getId(),Boolean.toString(button.getSelection())); - } - else if(fPropertyControls.get(i) instanceof Combo){ - Combo combo = (Combo)fPropertyControls.get(i); - int index = combo.getSelectionIndex(); - propertyMap.put(prop.getId(),combo.getItem(index)); - }else{ - Text text = (Text)fPropertyControls.get(i); - propertyMap.put(prop.getId(),text.getText()); - } - } - return propertyMap; - } -} diff --git a/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/ServerTypeDefinitionRuntimeDecorator.java b/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/ServerTypeDefinitionRuntimeDecorator.java deleted file mode 100644 index 50cedca0e..000000000 --- a/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/ServerTypeDefinitionRuntimeDecorator.java +++ /dev/null @@ -1,53 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2005 Eteration A.S. and Gorkem Ercan. All rights reserved. This program and the - * accompanying materials are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Gorkem Ercan - initial API and implementation - * - **************************************************************************************************/ -package org.eclipse.jst.server.generic.ui.internal; - -import java.util.Map; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.jface.dialogs.IMessageProvider; -import org.eclipse.jst.server.generic.core.internal.GenericServerRuntime; -import org.eclipse.jst.server.generic.servertype.definition.ServerRuntime; -import org.eclipse.wst.server.ui.wizard.IWizardHandle; - -public class ServerTypeDefinitionRuntimeDecorator extends ServerTypeDefinitionDecorator { - - private GenericServerRuntime fRuntime; - public ServerTypeDefinitionRuntimeDecorator(ServerRuntime definition, Map initialProperties, IWizardHandle wizard, GenericServerRuntime runtime) { - super(definition, initialProperties,CONTEXT_RUNTIME,wizard); - fRuntime=runtime; - } - - public boolean validate(){ - - if(fRuntime==null) - return false; - fRuntime.setServerDefinitionId(fRuntime.getRuntime().getRuntimeType().getId()); - fRuntime.setServerInstanceProperties(getValues()); - - IStatus status = fRuntime.validate(); - - if (status == null || status.isOK()){ - - fWizard.setMessage(null, IMessageProvider.NONE); - fWizard.update(); - String wDir = fRuntime.getServerTypeDefinition().getResolver().resolveProperties(fRuntime.getServerTypeDefinition().getStart().getWorkingDirectory()); - fRuntime.getRuntimeWorkingCopy().setLocation(new Path(wDir)); - - return false; - }else - { - fWizard.setMessage(status.getMessage(), IMessageProvider.ERROR); - fWizard.update(); - return true; - } - } -} diff --git a/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/ServerTypeDefinitionServerDecorator.java b/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/ServerTypeDefinitionServerDecorator.java deleted file mode 100644 index 727c258ed..000000000 --- a/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/ServerTypeDefinitionServerDecorator.java +++ /dev/null @@ -1,50 +0,0 @@ -/*************************************************************************************************** - * Copyright (c) 2005 Eteration A.S. and Gorkem Ercan. All rights reserved. This program and the - * accompanying materials are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Gorkem Ercan - initial API and implementation - * - **************************************************************************************************/ -package org.eclipse.jst.server.generic.ui.internal; - -import java.util.Map; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.dialogs.IMessageProvider; -import org.eclipse.jst.server.generic.core.internal.GenericServer; -import org.eclipse.jst.server.generic.servertype.definition.ServerRuntime; -import org.eclipse.wst.server.ui.wizard.IWizardHandle; -/** - * Server properties decorator. - * @author Gorkem Ercan - */ -public class ServerTypeDefinitionServerDecorator extends - ServerTypeDefinitionDecorator { - - private GenericServer fServer; - public ServerTypeDefinitionServerDecorator(ServerRuntime definition, Map initialProperties,IWizardHandle wizard,GenericServer server) { - super(definition, initialProperties,CONTEXT_SERVER, wizard); - fServer=server; - } - - public boolean validate() { - if(fServer!=null) - fServer.setServerInstanceProperties(getValues()); - IStatus status = fServer.validate(); - if(status==null || status.isOK()) - { - fWizard.setMessage(null, IMessageProvider.NONE); - fWizard.update(); - } - else - { - fWizard.setMessage(status.getMessage(), IMessageProvider.ERROR); - fWizard.update(); - return true; - } - return false; - } - -} |