Author: rob.stryker(a)jboss.com
Date: 2009-01-22 08:52:15 -0500 (Thu, 22 Jan 2009)
New Revision: 13185
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServerActionProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServerContentProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServerDecorator.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServerLabelProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServersDropAdapter.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServersView.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServersViewDropAdapterAssistant.java
Removed:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerActionProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerContentProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerDecorator.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerLabelProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServersDropAdapter.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServersView.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServersViewDropAdapterAssistant.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/ModuleActionProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
Log:
package renamed and headers added
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/ModuleActionProvider.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/ModuleActionProvider.java 2009-01-22
11:01:21 UTC (rev 13184)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/ModuleActionProvider.java 2009-01-22
13:52:15 UTC (rev 13185)
@@ -36,7 +36,7 @@
import org.jboss.ide.eclipse.as.ui.JBossServerUISharedImages;
import org.jboss.ide.eclipse.as.ui.Messages;
import org.jboss.ide.eclipse.as.ui.actions.ExploreUtils;
-import org.jboss.tools.as.wst.server.ui.ServerActionProvider;
+import org.jboss.tools.as.wst.server.ui.xpl.ServerActionProvider;
public class ModuleActionProvider extends CommonActionProvider {
private Action deleteModuleAction, fullPublishModuleAction,
incrementalPublishModuleAction;
Deleted:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerActionProvider.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerActionProvider.java 2009-01-22
11:01:21 UTC (rev 13184)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerActionProvider.java 2009-01-22
13:52:15 UTC (rev 13185)
@@ -1,322 +0,0 @@
-package org.jboss.tools.as.wst.server.ui;
-
-import java.util.Iterator;
-
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IContributionManager;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.bindings.TriggerSequence;
-import org.eclipse.jface.viewers.IOpenListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.OpenEvent;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.keys.IBindingService;
-import org.eclipse.ui.navigator.CommonActionProvider;
-import org.eclipse.ui.navigator.CommonViewer;
-import org.eclipse.ui.navigator.ICommonActionExtensionSite;
-import org.eclipse.ui.navigator.ICommonViewerSite;
-import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
-import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.ServerPort;
-import org.eclipse.wst.server.core.model.ServerDelegate;
-import org.eclipse.wst.server.ui.internal.Messages;
-import org.eclipse.wst.server.ui.internal.ServerUIPlugin;
-import org.eclipse.wst.server.ui.internal.Trace;
-import org.eclipse.wst.server.ui.internal.actions.NewServerWizardAction;
-import org.eclipse.wst.server.ui.internal.view.servers.CopyAction;
-import org.eclipse.wst.server.ui.internal.view.servers.DeleteAction;
-import org.eclipse.wst.server.ui.internal.view.servers.ModuleServer;
-import org.eclipse.wst.server.ui.internal.view.servers.ModuleSloshAction;
-import org.eclipse.wst.server.ui.internal.view.servers.MonitorServerPortAction;
-import org.eclipse.wst.server.ui.internal.view.servers.OpenAction;
-import org.eclipse.wst.server.ui.internal.view.servers.PasteAction;
-import org.eclipse.wst.server.ui.internal.view.servers.PropertiesAction;
-import org.eclipse.wst.server.ui.internal.view.servers.PublishAction;
-import org.eclipse.wst.server.ui.internal.view.servers.PublishCleanAction;
-import org.eclipse.wst.server.ui.internal.view.servers.RemoveModuleAction;
-import org.eclipse.wst.server.ui.internal.view.servers.RenameAction;
-import org.eclipse.wst.server.ui.internal.view.servers.RestartModuleAction;
-import org.eclipse.wst.server.ui.internal.view.servers.ShowInConsoleAction;
-import org.eclipse.wst.server.ui.internal.view.servers.ShowInDebugAction;
-import org.eclipse.wst.server.ui.internal.view.servers.StartAction;
-import org.eclipse.wst.server.ui.internal.view.servers.StartModuleAction;
-import org.eclipse.wst.server.ui.internal.view.servers.StopAction;
-import org.eclipse.wst.server.ui.internal.view.servers.StopModuleAction;
-import org.jboss.ide.eclipse.as.ui.actions.ExploreAction;
-
-public class ServerActionProvider extends CommonActionProvider {
- public static final String NEW_MENU_ID =
"org.jboss.tools.as.wst.server.ui.internal.cnf.newMenuId";
- public static final String SHOW_IN_MENU_ID =
"org.jboss.tools.as.wst.server.ui.internal.cnf.showInMenuId";
- public static final String TOP_SECTION_START_SEPARATOR =
"org.jboss.tools.as.wst.server.ui.internal.cnf.topSectionStart";
- public static final String TOP_SECTION_END_SEPARATOR =
"org.jboss.tools.as.wst.server.ui.internal.cnf.topSectionEnd";
- public static final String EDIT_SECTION_START_SEPARATOR =
"org.jboss.tools.as.wst.server.ui.internal.cnfeditSectionStart";
- public static final String EDIT_SECTION_END_SEPARATOR =
"org.jboss.tools.as.wst.server.ui.internal.cnf.editSectionEnd";
- public static final String CONTROL_SERVER_SECTION_START_SEPARATOR =
"org.jboss.tools.as.wst.server.ui.internal.cnf.controlServerSectionStart";
- public static final String CONTROL_SERVER_SECTION_END_SEPARATOR =
"org.jboss.tools.as.wst.server.ui.internal.cnf.controlServerSectionEnd";
- public static final String SERVER_ERATA_SECTION_START_SEPARATOR =
"org.jboss.tools.as.wst.server.ui.internal.cnf.serverErataSectionStart";
- public static final String SERVER_ERATA_SECTION_END_SEPARATOR =
"org.jboss.tools.as.wst.server.ui.internal.cnf.serverErataSectionEnd";
- public static final String CONTROL_MODULE_SECTION_START_SEPARATOR =
"org.jboss.tools.as.wst.server.ui.internal.cnf.controlModuleSectionStart";
- public static final String CONTROL_MODULE_SECTION_END_SEPARATOR =
"org.jboss.tools.as.wst.server.ui.internal.cnf.controlModuleSectionEnd";
-
- private ICommonActionExtensionSite actionSite;
- private Clipboard clipboard;
- public ServerActionProvider() {
- super();
- }
-
- public void init(ICommonActionExtensionSite aSite) {
- super.init(aSite);
- this.actionSite = aSite;
- ICommonViewerSite site = aSite.getViewSite();
- if( site instanceof ICommonViewerWorkbenchSite ) {
- StructuredViewer v = aSite.getStructuredViewer();
- if( v instanceof CommonViewer ) {
- CommonViewer cv = (CommonViewer)v;
- ICommonViewerWorkbenchSite wsSite = (ICommonViewerWorkbenchSite)site;
- addListeners(cv);
- makeServerActions(cv, wsSite.getSelectionProvider());
- }
- }
- }
-
-
- // actions on a server
- protected Action[] actions;
- protected Action actionModifyModules;
- protected Action openAction, showInConsoleAction, showInDebugAction, propertiesAction,
monitorPropertiesAction;
- protected Action copyAction, pasteAction, deleteAction, renameAction;
- protected Action noneAction = new Action(Messages.dialogMonitorNone) {
- // dummy action
- };
-
- private void addListeners(CommonViewer tableViewer) {
- tableViewer.addOpenListener(new IOpenListener() {
- public void open(OpenEvent event) {
- try {
- IStructuredSelection sel = (IStructuredSelection) event.getSelection();
- Object data = sel.getFirstElement();
- if (!(data instanceof IServer))
- return;
- IServer server = (IServer) data;
- ServerUIPlugin.editServer(server);
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Could not open server", e);
- }
- }
- });
- }
-
- private void makeServerActions(CommonViewer tableViewer, ISelectionProvider provider) {
- clipboard = new Clipboard(tableViewer.getTree().getDisplay());
- Shell shell = tableViewer.getTree().getShell();
-
- actions = new Action[7];
- // create the start actions
- actions[0] = new StartAction(shell, provider, ILaunchManager.DEBUG_MODE);
- actions[1] = new StartAction(shell, provider, ILaunchManager.RUN_MODE);
- actions[2] = new StartAction(shell, provider, ILaunchManager.PROFILE_MODE);
-
- // create the stop action
- actions[3] = new StopAction(shell, provider);
-
- // create the publish actions
- actions[4] = new PublishAction(shell, provider);
- actions[5] = new PublishCleanAction(shell, provider);
- actions[6] = new ExploreAction(shell,provider);
-
- // create the open action
- openAction = new OpenAction(provider);
-
-// // create copy, paste, and delete actions
- pasteAction = new PasteAction(shell, provider, clipboard);
- copyAction = new CopyAction(provider, clipboard, pasteAction);
- deleteAction = new DeleteAction(shell, provider);
- renameAction = new RenameAction(shell, tableViewer, provider);
-
- // create the other actions
- actionModifyModules = new ModuleSloshAction(shell, provider);
- showInConsoleAction = new ShowInConsoleAction(provider);
- showInDebugAction = new ShowInDebugAction(provider);
-
- // create the properties action
- propertiesAction = new PropertiesAction(shell, provider);
- monitorPropertiesAction = new PropertiesAction(shell,
"org.eclipse.wst.server.ui.properties.monitor", provider);
- }
-
- public void fillActionBars(IActionBars actionBars) {
- actionBars.setGlobalActionHandler("org.eclipse.wst.server.debug",
actions[0]);
- actionBars.setGlobalActionHandler("org.eclipse.wst.server.run", actions[1]);
- actionBars.setGlobalActionHandler("org.eclipse.wst.server.stop",
actions[3]);
- actionBars.setGlobalActionHandler("org.eclipse.wst.server.publish",
actions[4]);
- actionBars.setGlobalActionHandler("org.eclipse.ui.navigator.Open",
openAction);
- actionBars.setGlobalActionHandler(ActionFactory.PROPERTIES.getId(), propertiesAction);
- actionBars.updateActionBars();
- actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyAction);
- actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), pasteAction);
- actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), deleteAction);
- actionBars.setGlobalActionHandler(ActionFactory.RENAME.getId(), renameAction);
-
- IContributionManager cm = actionBars.getToolBarManager();
- cm.removeAll();
-
- for (int i = 0; i < actions.length - 1; i++)
- cm.add(actions[i]);
- }
-
- public void fillContextMenu(IMenuManager menu) {
- ICommonViewerSite site = actionSite.getViewSite();
- IStructuredSelection selection = null;
- Shell shell = actionSite.getViewSite().getShell();
- if( site instanceof ICommonViewerWorkbenchSite ) {
- ICommonViewerWorkbenchSite wsSite = (ICommonViewerWorkbenchSite)site;
- selection = (IStructuredSelection) wsSite.getSelectionProvider().getSelection();
- }
-
- IServer server = null;
- IModule[] module = null;
- if (selection != null && !selection.isEmpty()) {
- Iterator iterator = selection.iterator();
- Object obj = iterator.next();
- if (obj instanceof IServer)
- server = (IServer) obj;
- if (obj instanceof ModuleServer) {
- ModuleServer ms = (ModuleServer) obj;
- server = ms.server;
- module = ms.module;
- }
- if (iterator.hasNext()) {
- server = null;
- module = null;
- }
- }
-
- menu.add(invisibleSeparator(TOP_SECTION_START_SEPARATOR));
- addTopSection(menu, server, module);
- menu.add(invisibleSeparator(TOP_SECTION_END_SEPARATOR));
- menu.add(new Separator());
-
- if (server != null && module == null) {
- menu.add(invisibleSeparator(EDIT_SECTION_START_SEPARATOR));
- menu.add(copyAction);
- menu.add(pasteAction);
- menu.add(deleteAction);
- menu.add(renameAction);
- menu.add(invisibleSeparator(EDIT_SECTION_END_SEPARATOR));
-
- menu.add(new Separator());
-
- menu.add(invisibleSeparator(CONTROL_SERVER_SECTION_START_SEPARATOR));
- for (int i = 0; i < actions.length; i++)
- menu.add(actions[i]);
- menu.add(invisibleSeparator(CONTROL_SERVER_SECTION_END_SEPARATOR));
-
- menu.add(new Separator());
-
- menu.add(invisibleSeparator(SERVER_ERATA_SECTION_START_SEPARATOR));
- menu.add(actionModifyModules);
- addMonitor(server, menu, shell);
- menu.add(invisibleSeparator(SERVER_ERATA_SECTION_END_SEPARATOR));
- menu.add(new Separator());
- menu.add(propertiesAction);
-
- } else if (server != null && module != null) {
-
- menu.add(invisibleSeparator(CONTROL_MODULE_SECTION_START_SEPARATOR));
- menu.add(new StartModuleAction(server, module));
- menu.add(new StopModuleAction(server, module));
- menu.add(new RestartModuleAction(server, module));
- if(module.length == 1) {
- menu.add(new RemoveModuleAction(shell, server, module[0]));
- }
- menu.add(invisibleSeparator(CONTROL_MODULE_SECTION_END_SEPARATOR));
- }
-
- menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
- menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS+"-end"));
- }
-
- protected void addTopSection(IMenuManager menu, IServer server, IModule[] module) {
- MenuManager newMenu = new MenuManager(Messages.actionNew, NEW_MENU_ID);
- IAction newServerAction = new NewServerWizardAction();
- newServerAction.setText(Messages.actionNewServer);
- newMenu.add(newServerAction);
- menu.add(newMenu);
-
- // open action
- if (server != null && module == null) {
- menu.add(openAction);
-
- String text = Messages.actionShowIn;
- final IWorkbench workbench = PlatformUI.getWorkbench();
- final IBindingService bindingService = (IBindingService) workbench
- .getAdapter(IBindingService.class);
- final TriggerSequence[] activeBindings = bindingService
- .getActiveBindingsFor("org.eclipse.ui.navigate.showInQuickMenu");
- if (activeBindings.length > 0) {
- text += "\t" + activeBindings[0].format();
- }
-
- MenuManager showInMenu = new MenuManager(text,
"org.eclipse.ui.navigate.showInQuickMenu");
- showInMenu.add(showInConsoleAction);
- showInMenu.add(showInDebugAction);
- menu.add(showInMenu);
- }
- }
-
- protected void addMonitor(IServer server, IMenuManager menu, Shell shell) {
-
- if (server.getServerType() != null) {
- final MenuManager menuManager = new MenuManager(Messages.actionMonitor);
-
- final IServer server2 = server;
- final Shell shell2 = shell;
- menuManager.addMenuListener(new IMenuListener() {
- public void menuAboutToShow(IMenuManager manager) {
- menuManager.removeAll();
- if (server2.getAdapter(ServerDelegate.class) != null) {
- ServerPort[] ports = server2.getServerPorts(null);
- if (ports != null) {
- int size = ports.length;
- for (int i = 0; i < size; i++) {
- if (!ports[i].isAdvanced())
- menuManager.add(new MonitorServerPortAction(shell2, server2, ports[i]));
- }
- }
- }
-
- if (menuManager.isEmpty())
- menuManager.add(noneAction);
-
- menuManager.add(new Separator());
- menuManager.add(monitorPropertiesAction);
- }
- });
-
- // add an initial menu item so that the menu appears correctly
- noneAction.setEnabled(false);
- menuManager.add(noneAction);
- menu.add(menuManager);
- }
- }
-
-
- private Separator invisibleSeparator(String s) {
- Separator sep = new Separator(s);
- sep.setVisible(false);
- return sep;
- }
-}
Deleted:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerContentProvider.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerContentProvider.java 2009-01-22
11:01:21 UTC (rev 13184)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerContentProvider.java 2009-01-22
13:52:15 UTC (rev 13185)
@@ -1,352 +0,0 @@
-package org.jboss.tools.as.wst.server.ui;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.IPublishListener;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.IServerLifecycleListener;
-import org.eclipse.wst.server.core.IServerListener;
-import org.eclipse.wst.server.core.ServerCore;
-import org.eclipse.wst.server.core.ServerEvent;
-import org.eclipse.wst.server.core.internal.Server;
-import org.eclipse.wst.server.core.internal.UpdateServerJob;
-import org.eclipse.wst.server.core.util.PublishAdapter;
-import org.eclipse.wst.server.ui.internal.Messages;
-import org.eclipse.wst.server.ui.internal.Trace;
-import org.eclipse.wst.server.ui.internal.view.servers.ModuleServer;
-import org.eclipse.wst.server.ui.internal.viewers.BaseContentProvider;
-
-public class ServerContentProvider extends BaseContentProvider implements
ITreeContentProvider {
- public static Object INITIALIZING = new Object();
- protected IServerLifecycleListener serverResourceListener;
- protected IPublishListener publishListener;
- protected IServerListener serverListener;
-
- // servers that are currently publishing and starting
- protected static Set<String> publishing = new HashSet<String>(4);
- protected static Set<String> starting = new HashSet<String>(4);
- protected boolean animationActive = false;
- protected boolean stopAnimation = false;
- protected boolean initialized = false;
-
-
- private StructuredViewer viewer;
-
- public ServerContentProvider() {
- addListeners();
- }
-
- public Object[] getElements(Object element) {
- if( !initialized ) {
- deferInitialization();
- return new Object[] {INITIALIZING};
- }
-
- List<IServer> list = new ArrayList<IServer>();
- IServer[] servers = ServerCore.getServers();
- if (servers != null) {
- int size = servers.length;
- for (int i = 0; i < size; i++) {
- if (!((Server)servers[i]).isPrivate())
- list.add(servers[i]);
- }
- }
- return list.toArray();
- }
-
- public Object[] getChildren(Object element) {
- if (element instanceof ModuleServer) {
- ModuleServer ms = (ModuleServer) element;
- try {
- IModule[] children = ms.server.getChildModules(ms.module, null);
- int size = children.length;
- ModuleServer[] ms2 = new ModuleServer[size];
- for (int i = 0; i < size; i++) {
- int size2 = ms.module.length;
- IModule[] module = new IModule[size2 + 1];
- System.arraycopy(ms.module, 0, module, 0, size2);
- module[size2] = children[i];
- ms2[i] = new ModuleServer(ms.server, module);
- }
- return ms2;
- } catch (Exception e) {
- return null;
- }
- }
-
- IServer server = (IServer) element;
- IModule[] modules = server.getModules();
- int size = modules.length;
- ModuleServer[] ms = new ModuleServer[size];
- for (int i = 0; i < size; i++) {
- ms[i] = new ModuleServer(server, new IModule[] { modules[i] });
- }
- return ms;
- }
-
- public Object getParent(Object element) {
- if (element instanceof ModuleServer) {
- ModuleServer ms = (ModuleServer) element;
- return ms.server;
- }
- return null;
- }
-
- public boolean hasChildren(Object element) {
- if (element instanceof ModuleServer) {
- // Check if the module server has child modules.
- ModuleServer curModuleServer = (ModuleServer)element;
- IServer curServer = curModuleServer.server;
- IModule[] curModule = curModuleServer.module;
- if (curServer != null && curModule != null) {
- IModule[] curChildModule = curServer.getChildModules(curModule, null);
- if (curChildModule != null && curChildModule.length > 0)
- return true;
-
- return false;
- }
-
- return false;
- }
- if( element instanceof IServer ) {
- return ((IServer) element).getModules().length > 0;
- }
- return false;
- }
-
- public void inputChanged(Viewer aViewer, Object oldInput, Object newInput) {
- viewer = (StructuredViewer) aViewer;
- }
-
- public void dispose() {
- // remove all listeners!
- ServerCore.removeServerLifecycleListener(serverResourceListener);
- IServer[] servers = ServerCore.getServers();
- for( int i = 0;i < servers.length; i++ ) {
- servers[i].removePublishListener(publishListener);
- servers[i].removeServerListener(serverListener);
- }
- }
-
-
-
- // Listeners and refreshing the viewer
- protected void addListeners() {
- serverResourceListener = new IServerLifecycleListener() {
- public void serverAdded(IServer server) {
- refreshServer(null);
- server.addServerListener(serverListener);
- ((Server) server).addPublishListener(publishListener);
- }
- public void serverChanged(IServer server) {
- refreshServer(server);
- }
- public void serverRemoved(IServer server) {
- refreshServer(null);
- server.removeServerListener(serverListener);
- ((Server) server).removePublishListener(publishListener);
- }
- };
- ServerCore.addServerLifecycleListener(serverResourceListener);
-
- publishListener = new PublishAdapter() {
- public void publishStarted(IServer server) {
- handlePublishChange(server, true);
- }
-
- public void publishFinished(IServer server, IStatus status) {
- handlePublishChange(server, false);
- }
- };
-
- serverListener = new IServerListener() {
- public void serverChanged(ServerEvent event) {
- if (event == null)
- return;
-
- int eventKind = event.getKind();
- IServer server = event.getServer();
- if ((eventKind & ServerEvent.SERVER_CHANGE) != 0) {
- // server change event
- if ((eventKind & ServerEvent.STATE_CHANGE) != 0) {
- refreshServer(server, true);
- int state = event.getState();
- String id = server.getId();
- if (state == IServer.STATE_STARTING || state == IServer.STATE_STOPPING) {
- boolean startThread = false;
- synchronized (starting) {
- if (!starting.contains(id)) {
- if (starting.isEmpty())
- startThread = true;
- starting.add(id);
- }
- }
- if (startThread)
- startThread();
- } else {
- boolean stopThread = false;
- synchronized (starting) {
- if (starting.contains(id)) {
- starting.remove(id);
- if (starting.isEmpty())
- stopThread = true;
- }
- }
- if (stopThread)
- stopThread();
- }
- } else
- refreshServer(server);
- } else if ((eventKind & ServerEvent.MODULE_CHANGE) != 0) {
- // module change event
- if ((eventKind & ServerEvent.STATE_CHANGE) != 0 || (eventKind &
ServerEvent.PUBLISH_STATE_CHANGE) != 0) {
- refreshServer(server);
- }
- }
- }
- };
-
- // add listeners to servers
- IServer[] servers = ServerCore.getServers();
- if (servers != null) {
- int size = servers.length;
- for (int i = 0; i < size; i++) {
- servers[i].addServerListener(serverListener);
- ((Server) servers[i]).addPublishListener(publishListener);
- }
- }
- }
-
- protected void deferInitialization() {
- Job job = new Job(Messages.jobInitializingServersView) {
- public IStatus run(IProgressMonitor monitor) {
- IServer[] servers = ServerCore.getServers();
- int size = servers.length;
- for (int i = 0; i < size; i++) {
- ((Server)servers[i]).getAllModules().iterator();
- }
-
- for (int i = 0; i < size; i++) {
- IServer server = servers[i];
- if (server.getServerType() != null && server.getServerState() ==
IServer.STATE_UNKNOWN) {
- UpdateServerJob job2 = new UpdateServerJob(server);
- job2.schedule();
- }
- }
- initialized = true;
- refreshServer(null);
- return Status.OK_STATUS;
- }
- };
-
- job.setSystem(true);
- job.setPriority(Job.SHORT);
- job.schedule();
- }
-
- protected void updateServerLabel(final IServer server) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- try {
- if( viewer != null && !viewer.getControl().isDisposed()) {
- viewer.update(server, null);
- ServerDecorator.getDefault().redecorate(server);
- }
- } catch (Exception e) {
- // ignore
- }
- }
- });
- }
-
- protected void refreshServer(final IServer server) {
- refreshServer(server, false);
- }
- protected void refreshServer(final IServer server, final boolean resetSelection) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- try {
- if( viewer != null && !viewer.getControl().isDisposed()) {
- viewer.refresh(server);
- if( resetSelection ) {
- ISelection sel = viewer.getSelection();
- viewer.setSelection(sel);
- }
- ServerDecorator.getDefault().redecorate(server);
- }
- } catch (Exception e) {
- // ignore
- }
- }
- });
- }
-
- protected void handlePublishChange(IServer server, boolean isPublishing) {
- String serverId = server.getId();
- if (isPublishing)
- publishing.add(serverId);
- else
- publishing.remove(serverId);
-
- refreshServer(server);
- }
-
-
- protected void startThread() {
- if (animationActive)
- return;
-
- stopAnimation = false;
-
- final Display display = viewer == null ? Display.getDefault() :
viewer.getControl().getDisplay();
- final int SLEEP = 200;
- final Runnable[] animator = new Runnable[1];
- animator[0] = new Runnable() {
- public void run() {
- if (!stopAnimation) {
- try {
- int size = 0;
- String[] servers;
- synchronized (starting) {
- size = starting.size();
- servers = new String[size];
- starting.toArray(servers);
- }
-
- for (int i = 0; i < size; i++) {
- IServer server = ServerCore.findServer(servers[i]);
- if (server != null ) {
- ServerDecorator.animate();
- updateServerLabel(server);
- }
- }
- } catch (Exception e) {
- Trace.trace(Trace.FINEST, "Error in Servers view animation", e);
- }
- display.timerExec(SLEEP, animator[0]);
- }
- }
- };
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- display.timerExec(SLEEP, animator[0]);
- }
- });
- }
-
- protected void stopThread() {
- stopAnimation = true;
- }}
Deleted:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerDecorator.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerDecorator.java 2009-01-22
11:01:21 UTC (rev 13184)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerDecorator.java 2009-01-22
13:52:15 UTC (rev 13185)
@@ -1,196 +0,0 @@
-package org.jboss.tools.as.wst.server.ui;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.viewers.IDecoration;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ILightweightLabelDecorator;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.LabelProviderChangedEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.IServerType;
-import org.eclipse.wst.server.core.internal.Server;
-import org.eclipse.wst.server.ui.ServerUICore;
-import org.eclipse.wst.server.ui.internal.ImageResource;
-import org.eclipse.wst.server.ui.internal.Messages;
-import org.eclipse.wst.server.ui.internal.ServerUIPlugin;
-import org.eclipse.wst.server.ui.internal.provisional.UIDecoratorManager;
-import org.eclipse.wst.server.ui.internal.view.servers.ModuleServer;
-
-public class ServerDecorator extends LabelProvider implements ILightweightLabelDecorator
{
-
- public static final String[] syncState = new String[] {
- Messages.viewSyncOkay,
- Messages.viewSyncRestart,
- Messages.viewSyncPublish,
- Messages.viewSyncRestartPublish,
- Messages.viewSyncPublishing};
-
- public static final String[] syncStateUnmanaged = new String[] {
- Messages.viewSyncOkay2,
- Messages.viewSyncRestart2,
- Messages.viewSyncPublish2,
- Messages.viewSyncRestartPublish2,
- Messages.viewSyncPublishing2};
-
- public static final String[] modulePublishState = new String[] {
- "",
- Messages.viewSyncOkay,
- Messages.viewSyncPublish,
- Messages.viewSyncPublish};
-
- private static ServerDecorator instance;
- public static ServerDecorator getDefault() {
- return instance;
- }
-
- private static int count = 0;
- public static void animate() {
- count = (count + 1)%3;
- }
- public static int getCount() {
- return count;
- }
-
- public ServerDecorator() {
- instance = this;
- }
-
- public void decorate(Object element, IDecoration decoration) {
- if( element instanceof IServer ) {
- String state = getServerStateLabel((IServer)element);
- String status = getServerStatusLabel((IServer)element);
- decoration.addSuffix(combine(state, status));
- } else if( element instanceof ModuleServer ) {
- String state = getModuleStateText((ModuleServer)element);
- String status = getModuleStatusText((ModuleServer)element);
- decoration.addSuffix(combine(state, status));
- }
- }
-
- protected String combine(String state, String status) {
- if(isEmpty(state) && isEmpty(status))
- return "";
- if( isEmpty(state))
- return " [" + status + "]";
- if( isEmpty(status))
- return " [" + state + "]";
- return " [" + state + ", " + status + "]";
- }
-
- protected boolean isEmpty(String s) {
- return (s == null || "".equals(s));
- }
-
- public void redecorate(IServer server) {
- fireLabelProviderChanged(new LabelProviderChangedEvent(this));
- }
-
-
-
- /*
- * Utility methods
- */
- public static Image getServerImage(IServer server) {
- return server == null ? null :
- server.getServerType() == null ? null :
- ImageResource.getImage(server.getServerType().getId());
- }
-
- public static String getServerStateLabel(IServer server) {
- return server == null ? null :
- server.getServerType() == null ? null :
- getStateLabel(server.getServerType(), server.getServerState(), server.getMode());
- }
-
- public static String getStateLabel(IServerType serverType, int state, String mode) {
- return serverType == null ? null :
- UIDecoratorManager.getUIDecorator(serverType).getStateLabel(state, mode, count);
- }
-
- public static String getServerStatusLabel(IServer server) {
- IStatus status = ((Server) server).getServerStatus();
- if (status != null)
- return status.getMessage();
-
- if (server.getServerType() == null)
- return "";
-
- if (server.getServerState() == IServer.STATE_UNKNOWN)
- return "";
-
- String serverId = server.getId();
- if (ServerContentProvider.publishing.contains(serverId))
- return ServerDecorator.syncState[4];
-
- // republish
- int i = 0;
- if (server.shouldPublish()) {
- if (((Server)server).isPublishUnknown())
- return "";
- i += 2;
- }
-
- if (server.shouldRestart())
- i = 1;
-
- return syncState[i];
- }
-
- public static Image getServerStateImage(IServer server) {
- return server == null ? null :
- getStateImage(server.getServerType(), server.getServerState(), server.getMode());
- }
-
- public static Image getStateImage(IServerType serverType, int state, String mode) {
- return serverType == null ? null :
- UIDecoratorManager.getUIDecorator(serverType).getStateImage(state, mode, getCount());
- }
-
- public static String getModuleText(ModuleServer ms ) {
- if (ms == null || ms.module == null)
- return "";
- int size = ms.module.length;
- return ms.module[size - 1].getName();
- }
-
- public static Image getModuleImage(ModuleServer ms) {
- if( ms != null ) {
- ILabelProvider labelProvider = ServerUICore.getLabelProvider();
- Image image = labelProvider.getImage(ms.module[ms.module.length - 1]);
- labelProvider.dispose();
- return image;
- }
- return null;
- }
-
- public static String getModuleStateText(ModuleServer ms) {
- return "";
- }
-
- public static String getModuleStatusText(ModuleServer ms) {
- if( ms != null && ms.server != null && ms.module != null ) {
- IStatus status = ((Server) ms.server).getModuleStatus(ms.module);
- if (status != null)
- return status.getMessage();
-
- return modulePublishState[ms.server.getModulePublishState(ms.module)];
- }
- return "";
- }
-
- public static Image getModuleStatusImage(ModuleServer ms) {
- IStatus status = ((Server) ms.server).getModuleStatus(ms.module);
- if (status != null) {
- ISharedImages sharedImages =
ServerUIPlugin.getInstance().getWorkbench().getSharedImages();
- if (status.getSeverity() == IStatus.ERROR)
- return sharedImages.getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
- else if (status.getSeverity() == IStatus.WARNING)
- return sharedImages.getImage(ISharedImages.IMG_OBJS_WARN_TSK);
- else if (status.getSeverity() == IStatus.INFO)
- return sharedImages.getImage(ISharedImages.IMG_OBJS_INFO_TSK);
- }
- return null;
- }
-}
Deleted:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerLabelProvider.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerLabelProvider.java 2009-01-22
11:01:21 UTC (rev 13184)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerLabelProvider.java 2009-01-22
13:52:15 UTC (rev 13185)
@@ -1,78 +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.jboss.tools.as.wst.server.ui;
-
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.ui.ServerUICore;
-import org.eclipse.wst.server.ui.internal.ImageResource;
-import org.eclipse.wst.server.ui.internal.Messages;
-import org.eclipse.wst.server.ui.internal.view.servers.ModuleServer;
-/**
- * Server table label provider.
- */
-public class ServerLabelProvider extends LabelProvider {
-
- /**
- * ServerTableLabelProvider constructor comment.
- */
- public ServerLabelProvider() {
- super();
- }
-
- public String getText(Object element) {
- if (element instanceof ModuleServer) {
- ModuleServer ms = (ModuleServer) element;
- if (ms.module == null)
- return "";
- int size = ms.module.length;
- String name = ms.module[size - 1].getName();
- return name;
- }
-
- if( element instanceof IServer ) {
- IServer server = (IServer) element;
- return notNull(server.getName());
- }
-
- if( element == ServerContentProvider.INITIALIZING)
- return Messages.viewInitializing;
-
- return "-";
- }
- public Image getImage(Object element) {
- Image image = null;
- if (element instanceof ModuleServer) {
- ModuleServer ms = (ModuleServer) element;
- ILabelProvider labelProvider = ServerUICore.getLabelProvider();
- image = labelProvider.getImage(ms.module[ms.module.length - 1]);
- labelProvider.dispose();
- } else if( element instanceof IServer ) {
- IServer server = (IServer) element;
- if (server.getServerType() != null) {
- image = ImageResource.getImage(server.getServerType().getId());
- }
- }
- return image;
- }
-
- protected String notNull(String s) {
- if (s == null)
- return "";
- return s;
- }
-
- public boolean isLabelProperty(Object element, String property) {
- return false;
- }
-}
\ No newline at end of file
Deleted:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServersDropAdapter.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServersDropAdapter.java 2009-01-22
11:01:21 UTC (rev 13184)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServersDropAdapter.java 2009-01-22
13:52:15 UTC (rev 13185)
@@ -1,321 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- *
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * ken.ryall(a)nokia.com - 157506 drop from external sources does not work on Linux/Mac
- *******************************************************************************/
-package org.jboss.tools.as.wst.server.ui;
-
-import java.util.HashMap;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.util.LocalSelectionTransfer;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DropTargetEvent;
-import org.eclipse.swt.dnd.FileTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.dnd.TransferData;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Item;
-import org.eclipse.ui.internal.navigator.NavigatorPlugin;
-import org.eclipse.ui.internal.navigator.dnd.CommonDropAdapterDescriptor;
-import org.eclipse.ui.internal.navigator.dnd.CommonDropDescriptorManager;
-import org.eclipse.ui.internal.navigator.dnd.NavigatorPluginDropAction;
-import org.eclipse.ui.navigator.CommonDragAdapter;
-import org.eclipse.ui.navigator.CommonDragAdapterAssistant;
-import org.eclipse.ui.navigator.CommonDropAdapterAssistant;
-import org.eclipse.ui.navigator.CommonViewer;
-import org.eclipse.ui.navigator.INavigatorContentService;
-import org.eclipse.ui.navigator.INavigatorDnDService;
-import org.eclipse.ui.part.PluginDropAdapter;
-import org.eclipse.ui.part.PluginTransfer;
-
-/*
- * THIS CLASS IS A CLONE of CommonDropAdapter.
- * It is necessary because dragged items must be acceptable children.
- * Stupid restriction
- *
- * I use a delegate and push all methods to the delegate,
- * even the ones I override.
- *
- *
https://bugs.eclipse.org/bugs/show_bug.cgi?id=261606
- *
- * Maybe one day they'll fix that ;)
- */
-
-/**
- * Provides an implementation of {@link PluginDropAdapter} which uses the
- * extensions provided by the associated {@link INavigatorContentService}.
- *
- * <p>
- * Clients should not need to create an instance of this class unless they are
- * creating their own custom viewer. Otherwise, {@link CommonViewer} configures
- * its drop adapter automatically.
- * </p>
- *
- *
- * @see INavigatorDnDService
- * @see CommonDragAdapter
- * @see CommonDragAdapterAssistant
- * @see CommonDropAdapterAssistant
- * @see CommonViewer
- * @since 3.2
- */
-public final class ServersDropAdapter extends PluginDropAdapter {
- private static final Transfer[] SUPPORTED_DROP_TRANSFERS = new Transfer[] {
- LocalSelectionTransfer.getTransfer(), FileTransfer.getInstance(),
- PluginTransfer.getInstance() };
- private final INavigatorContentService contentService;
- private final INavigatorDnDService dndService;
-
- public ServersDropAdapter(INavigatorContentService aContentService,
- StructuredViewer aStructuredViewer) {
- super(aStructuredViewer);
- contentService = aContentService;
- dndService = contentService.getDnDService();
- }
-
- public Transfer[] getSupportedDropTransfers() {
- return SUPPORTED_DROP_TRANSFERS;
- }
-
- public void dragEnter(DropTargetEvent event) {
- super.dragEnter(event);
-
- for (int i = 0; i < event.dataTypes.length; i++) {
- if (LocalSelectionTransfer.getTransfer().isSupportedType(
- event.dataTypes[i])) {
- event.currentDataType = event.dataTypes[i];
- return;
- }
- }
-
- for (int i = 0; i < event.dataTypes.length; i++) {
- if (FileTransfer.getInstance().isSupportedType(event.dataTypes[i])) {
- event.currentDataType = event.dataTypes[i];
- event.detail = DND.DROP_COPY;
- return;
- }
- }
-
- for (int i = 0; i < event.dataTypes.length; i++) {
- if (PluginTransfer.getInstance()
- .isSupportedType(event.dataTypes[i])) {
- event.currentDataType = event.dataTypes[i];
- return;
- }
- }
-
- event.detail = DND.DROP_NONE;
-
- }
-
- public void dragLeave(DropTargetEvent event) {
- super.dragLeave(event);
- if (LocalSelectionTransfer.getTransfer().isSupportedType(
- event.currentDataType)) {
- event.data = NavigatorPluginDropAction
- .createTransferData(contentService);
- }
- }
-
- /*
- * Changed from CommonDropAdapter to extract the findCommonDropAdapterAssistant section
- * since I do not like the impl in dnd service
- */
- public void drop(DropTargetEvent event) {
- // Must validate the drop here because on some platforms (Linux, Mac) the event
- // is not populated with the correct currentDataType until the drop actually
- // happens, and validateDrop sets the currentTransfer based on that. The
- // call to validateDrop in dragAccept is too early.
- validateDrop(getCurrentTarget(), getCurrentOperation(), event.currentDataType);
- if (PluginTransfer.getInstance().isSupportedType(event.currentDataType)) {
- super.drop(event);
- } else {
-
- Object target = getCurrentTarget() != null ?
- getCurrentTarget() : getViewer().getInput();
-
- CommonDropAdapterAssistant[] assistants =
- findCommonDropAdapterAssistants(target, getCurrentTransfer());
- IStatus valid = null;
- for (int i = 0; i < assistants.length; i++) {
- try {
- valid = assistants[i].validateDrop(getCurrentTarget(),
- getCurrentOperation(), getCurrentTransfer());
- if (valid != null && valid.isOK()) {
- assistants[i].handleDrop(null, event,
- getCurrentTarget());
- event.detail = DND.DROP_NONE;
- return;
- }
- } catch (Throwable t) {
- NavigatorPlugin.logError(0, t.getMessage(), t);
- }
- }
- event.detail = DND.DROP_NONE;
- }
- }
-
- /*
- * Changed from CommonDropAdapter to extract the findCommonDropAdapterAssistant section
- * since I do not like the impl in dnd service
- */
- public boolean validateDrop(Object aDropTarget, int theDropOperation,
- TransferData theTransferData) {
- boolean result = false;
- IStatus valid = null;
- if (super.validateDrop(aDropTarget, theDropOperation, theTransferData)) {
- result = true;
- } else {
- Object target = aDropTarget != null ? aDropTarget : getViewer().getInput();
- CommonDropAdapterAssistant[] assistants =
- findCommonDropAdapterAssistants(target,
- theTransferData);
- for (int i = 0; i < assistants.length; i++) {
- try {
- valid = assistants[i].validateDrop(target,
- theDropOperation, theTransferData);
- } catch (Throwable t) {
- NavigatorPlugin.logError(0, t.getMessage(), t);
- }
- if (valid != null && valid.isOK()) {
- result = true;
- break;
- }
- }
- }
- setScrollExpandEnabled(true);
- return result;
-
- }
-
- public Rectangle getBounds(Item item) {
- return super.getBounds(item);
- }
-
- public int getCurrentLocation() {
- return super.getCurrentLocation();
- }
-
- public int getCurrentOperation() {
- return super.getCurrentOperation();
- }
-
- public Object getCurrentTarget() {
- return super.getCurrentTarget();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.part.PluginDropAdapter#getCurrentTransfer()
- */
- public TransferData getCurrentTransfer() {
- return super.getCurrentTransfer();
- }
-
- /**
- * Returns the position of the given event's coordinates relative to its target.
- * The position is determined to be before, after, or on the item, based on
- * some threshold value.
- *
- * @param event the event
- * @return one of the <code>LOCATION_* </code>constants defined in this
class
- */
- protected int determineLocation(DropTargetEvent event) {
- if (!(event.item instanceof Item)) {
- return LOCATION_NONE;
- }
- return LOCATION_ON;
- }
-
-
- private CommonDropAdapterAssistant[] findCommonDropAdapterAssistants(
- Object aDropTarget, TransferData theTransferType) {
- CommonDropAdapterAssistant[] result =
- findCommonDropAdapterAssistants2(aDropTarget, theTransferType);
- return result;
- }
-
-
-
- /*
- * Stolen from DND Service
- */
-
- private static final CommonDropAdapterAssistant[] NO_ASSISTANTS = new
CommonDropAdapterAssistant[0];
- private final Map dropAssistants = new HashMap();
-
- public CommonDropAdapterAssistant[] findCommonDropAdapterAssistants2(
- Object aDropTarget, TransferData aTransferType) {
-
- // TODO Make sure descriptors are sorted by priority
- CommonDropAdapterDescriptor[] descriptors = CommonDropDescriptorManager
- .getInstance().findCommonDropAdapterAssistants(aDropTarget,
- contentService);
-
- if (descriptors.length == 0) {
- return NO_ASSISTANTS;
- }
- if (LocalSelectionTransfer.getTransfer().isSupportedType(aTransferType)
- && LocalSelectionTransfer.getTransfer().getSelection() instanceof
IStructuredSelection) {
- return getAssistants(descriptors);
- }
- return getAssistantsByTransferData(descriptors, aTransferType);
- }
-
- private CommonDropAdapterAssistant[] getAssistants(CommonDropAdapterDescriptor[]
descriptors) {
- Set assistants = new LinkedHashSet();
- for (int i = 0; i < descriptors.length; i++) {
- assistants.add(getAssistant(descriptors[i]));
- }
- return (CommonDropAdapterAssistant[]) assistants
- .toArray(new CommonDropAdapterAssistant[assistants.size()]);
- }
-
- private CommonDropAdapterAssistant[] getAssistantsByTransferData(
- CommonDropAdapterDescriptor[] descriptors,
- TransferData aTransferType) {
-
- Set assistants = new LinkedHashSet();
- for (int i = 0; i < descriptors.length; i++) {
- CommonDropAdapterAssistant asst = getAssistant(descriptors[i]);
- if (asst.isSupportedType(aTransferType)) {
- assistants.add(asst);
- }
- }
- return (CommonDropAdapterAssistant[]) assistants
- .toArray(new CommonDropAdapterAssistant[assistants.size()]);
-
- }
-
- private CommonDropAdapterAssistant getAssistant(
- CommonDropAdapterDescriptor descriptor) {
- CommonDropAdapterAssistant asst = (CommonDropAdapterAssistant) dropAssistants
- .get(descriptor);
- if (asst != null) {
- return asst;
- }
- synchronized (dropAssistants) {
- asst = (CommonDropAdapterAssistant) dropAssistants.get(descriptor);
- if (asst == null) {
- dropAssistants.put(descriptor, (asst = descriptor
- .createDropAssistant()));
- asst.init(contentService);
- }
- }
- return asst;
- }
-
-}
Deleted:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServersView.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServersView.java 2009-01-22
11:01:21 UTC (rev 13184)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServersView.java 2009-01-22
13:52:15 UTC (rev 13185)
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- *
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.jboss.tools.as.wst.server.ui;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.navigator.CommonDragAdapter;
-import org.eclipse.ui.navigator.CommonDropAdapter;
-import org.eclipse.ui.navigator.CommonNavigator;
-import org.eclipse.ui.navigator.CommonViewer;
-/**
- * A view of servers, their modules, and status.
- */
-public class ServersView extends CommonNavigator {
-
- /**
- * ServersView constructor comment.
- */
- public ServersView() {
- super();
- }
-
- /*
- * Stuff that shouldn't even be here but CNF is kinda lame
- * Must override currently to overcome the bug below:
- *
- *
https://bugs.eclipse.org/bugs/show_bug.cgi?id=261606
- */
- private IMemento memento;
-
- public void init(IViewSite aSite, IMemento aMemento)
- throws PartInitException {
- this.memento = memento;
- super.init(aSite, aMemento);
- }
-
- protected CommonViewer createCommonViewer(Composite aParent) {
- CommonViewer aViewer = new CommonViewerExtension(getViewSite().getId(), aParent,
- SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
- initListeners(aViewer);
- aViewer.getNavigatorContentService().restoreState(memento);
- return aViewer;
- }
-
-
- public class CommonViewerExtension extends CommonViewer {
- public CommonViewerExtension(String aViewerId, Composite aParent, int aStyle) {
- super(aViewerId, aParent, aStyle);
- }
-
- protected void initDragAndDrop() {
- /* Handle Drag and Drop */
- int operations = DND.DROP_COPY | DND.DROP_MOVE;
-
- CommonDragAdapter dragAdapter = new CommonDragAdapter(
- getNavigatorContentService(), this);
- addDragSupport(operations, dragAdapter.getSupportedDragTransfers(),
- dragAdapter);
-
- ServersDropAdapter dropAdapter = new ServersDropAdapter(
- getNavigatorContentService(), this);
- addDropSupport(operations, dropAdapter.getSupportedDropTransfers(),
- dropAdapter);
- }
- }
-}
\ No newline at end of file
Deleted:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServersViewDropAdapterAssistant.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServersViewDropAdapterAssistant.java 2009-01-22
11:01:21 UTC (rev 13184)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServersViewDropAdapterAssistant.java 2009-01-22
13:52:15 UTC (rev 13185)
@@ -1,193 +0,0 @@
-package org.jboss.tools.as.wst.server.ui;
-
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.dnd.DropTargetEvent;
-import org.eclipse.swt.dnd.FileTransfer;
-import org.eclipse.swt.dnd.TransferData;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.activities.WorkbenchActivityHelper;
-import org.eclipse.ui.internal.Workbench;
-import org.eclipse.ui.navigator.CommonDropAdapter;
-import org.eclipse.ui.navigator.CommonDropAdapterAssistant;
-import org.eclipse.ui.part.ResourceTransfer;
-import org.eclipse.ui.views.navigator.LocalSelectionTransfer;
-import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.IModuleArtifact;
-import org.eclipse.wst.server.core.IModuleType;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.IServerWorkingCopy;
-import org.eclipse.wst.server.core.ServerUtil;
-import org.eclipse.wst.server.core.internal.ServerPlugin;
-import org.eclipse.wst.server.ui.internal.EclipseUtil;
-import org.eclipse.wst.server.ui.internal.ServerUIPlugin;
-import org.eclipse.wst.server.ui.internal.actions.RunOnServerActionDelegate;
-
-public class ServersViewDropAdapterAssistant extends CommonDropAdapterAssistant {
-
- @SuppressWarnings("unchecked") private List fElements;
-
- public ServersViewDropAdapterAssistant() {
- super();
- }
- protected void doInit() {
- }
-
- public IStatus validatePluginTransferDrop(
- IStructuredSelection aDragSelection, Object aDropTarget) {
- initializeSelection(aDragSelection);
- return internalValidate(aDropTarget, fElements);
- }
-
- public IStatus validateDrop(Object target, int operation,
- TransferData transferType) {
- if (LocalSelectionTransfer.getInstance().isSupportedType(transferType)) {
- ISelection s = LocalSelectionTransfer.getInstance().getSelection();
- initializeSelection(s);
- return internalValidate(target, fElements);
- }
- return Status.CANCEL_STATUS;
- }
-
- protected void initializeSelection(ISelection s) {
- if (fElements != null)
- return;
- if (!(s instanceof IStructuredSelection)) {
- fElements= Collections.EMPTY_LIST;
- return;
- }
- fElements = ((IStructuredSelection) s).toList();
- }
-
- @SuppressWarnings("unchecked")
- protected IStatus internalValidate(Object target, List elements) {
- if( target instanceof IServer ) {
- IServer server = (IServer)target;
- Object next;
- if( elements != null ) {
- Iterator i = elements.iterator();
- while(i.hasNext() ) {
- next = i.next();
- IModuleArtifact[] moduleArtifacts = ServerPlugin.getModuleArtifacts(next);
- if (moduleArtifacts != null && moduleArtifacts.length > 0 ) {
- for( int j = 0; j < moduleArtifacts.length; j++ ) {
- if( moduleArtifacts[j] != null && moduleArtifacts[j].getModule() != null )
{
- IModuleType[] moduleTypes =
server.getServerType().getRuntimeType().getModuleTypes();
- if (ServerUtil.isSupportedModule(moduleTypes,
moduleArtifacts[j].getModule().getModuleType())) {
- return Status.OK_STATUS;
- }
- }
- }
- }
- }
- }
- }
- clear();
- return Status.CANCEL_STATUS;
- }
-
- public IStatus handleDrop(CommonDropAdapter dropAdapter,
- DropTargetEvent dropTargetEvent, Object target) {
- return internalHandleDrop(target, fElements);
- }
-
- public IStatus handlePluginTransferDrop(
- IStructuredSelection aDragSelection, Object aDropTarget) {
- return internalHandleDrop(aDropTarget, fElements);
- }
-
- protected IStatus internalHandleDrop(Object target, List elements) {
- boolean b = false;
- if( target instanceof IServer ) {
- b = true;
- if( fElements != null ) {
- Iterator iterator = elements.iterator();
- while (iterator.hasNext()) {
- Object data2 = iterator.next();
- if (!doSel((IServer)target, data2))
- b = false;
- }
- }
- }
- clear();
- return b ? Status.OK_STATUS : Status.CANCEL_STATUS;
- }
-
- private void clear() {
- fElements = null;
- }
-
- protected boolean doSel(IServer server, Object data) {
- // check if the selection is a project (module) that we can add to the server
- IProject project = (IProject) Platform.getAdapterManager().getAdapter(data,
IProject.class);
- if (project != null) {
- IModule[] modules = ServerUtil.getModules(project);
- if (modules != null && modules.length == 1) {
- try {
- IServerWorkingCopy wc = server.createWorkingCopy();
- IModule[] parents = wc.getRootModules(modules[0], null);
- if (parents == null || parents.length == 0)
- return false;
-
- if (ServerUtil.containsModule(server, parents[0], null))
- return false;
-
- IModule[] add = new IModule[] { parents[0] };
- if (wc.canModifyModules(add, null, null).getSeverity() != IStatus.ERROR) {
- wc.modifyModules(modules, null, null);
- wc.save(false, null);
- return true;
- }
- } catch (final CoreException ce) {
- final Shell shell = Workbench.getInstance().getActiveWorkbenchWindow().getShell();
- shell.getDisplay().asyncExec(new Runnable() {
- public void run() {
- EclipseUtil.openError(shell, ce.getLocalizedMessage());
- }
- });
- return true;
- }
- }
- }
-
- // otherwise, try Run on Server
- final IServer finalServer = server;
- RunOnServerActionDelegate ros = new RunOnServerActionDelegate() {
- public IServer getServer(IModule module, IModuleArtifact moduleArtifact,
IProgressMonitor monitor) throws CoreException {
- if (!ServerUIPlugin.isCompatibleWithLaunchMode(finalServer, launchMode))
- return null;
-
- if (!ServerUtil.containsModule(finalServer, module, monitor)) {
- IServerWorkingCopy wc = finalServer.createWorkingCopy();
- try {
- ServerUtil.modifyModules(wc, new IModule[] { module }, new IModule[0], monitor);
- wc.save(false, monitor);
- } catch (CoreException ce) {
- throw ce;
- }
- }
-
- return finalServer;
- }
- };
- Action action = new Action() {
- //
- };
- ros.selectionChanged(action, new StructuredSelection(data));
-
- ros.run(action);
- return true;
- }
-}
Copied:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServerActionProvider.java
(from rev 13054,
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerActionProvider.java)
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServerActionProvider.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServerActionProvider.java 2009-01-22
13:52:15 UTC (rev 13185)
@@ -0,0 +1,333 @@
+/*******************************************************************************
+ * 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 - Base Code
+ * Red Hat - Refactor for CNF
+ *******************************************************************************/
+package org.jboss.tools.as.wst.server.ui.xpl;
+
+import java.util.Iterator;
+
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IContributionManager;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.bindings.TriggerSequence;
+import org.eclipse.jface.viewers.IOpenListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.OpenEvent;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.keys.IBindingService;
+import org.eclipse.ui.navigator.CommonActionProvider;
+import org.eclipse.ui.navigator.CommonViewer;
+import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+import org.eclipse.ui.navigator.ICommonViewerSite;
+import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.ServerPort;
+import org.eclipse.wst.server.core.model.ServerDelegate;
+import org.eclipse.wst.server.ui.internal.Messages;
+import org.eclipse.wst.server.ui.internal.ServerUIPlugin;
+import org.eclipse.wst.server.ui.internal.Trace;
+import org.eclipse.wst.server.ui.internal.actions.NewServerWizardAction;
+import org.eclipse.wst.server.ui.internal.view.servers.CopyAction;
+import org.eclipse.wst.server.ui.internal.view.servers.DeleteAction;
+import org.eclipse.wst.server.ui.internal.view.servers.ModuleServer;
+import org.eclipse.wst.server.ui.internal.view.servers.ModuleSloshAction;
+import org.eclipse.wst.server.ui.internal.view.servers.MonitorServerPortAction;
+import org.eclipse.wst.server.ui.internal.view.servers.OpenAction;
+import org.eclipse.wst.server.ui.internal.view.servers.PasteAction;
+import org.eclipse.wst.server.ui.internal.view.servers.PropertiesAction;
+import org.eclipse.wst.server.ui.internal.view.servers.PublishAction;
+import org.eclipse.wst.server.ui.internal.view.servers.PublishCleanAction;
+import org.eclipse.wst.server.ui.internal.view.servers.RemoveModuleAction;
+import org.eclipse.wst.server.ui.internal.view.servers.RenameAction;
+import org.eclipse.wst.server.ui.internal.view.servers.RestartModuleAction;
+import org.eclipse.wst.server.ui.internal.view.servers.ShowInConsoleAction;
+import org.eclipse.wst.server.ui.internal.view.servers.ShowInDebugAction;
+import org.eclipse.wst.server.ui.internal.view.servers.StartAction;
+import org.eclipse.wst.server.ui.internal.view.servers.StartModuleAction;
+import org.eclipse.wst.server.ui.internal.view.servers.StopAction;
+import org.eclipse.wst.server.ui.internal.view.servers.StopModuleAction;
+import org.jboss.ide.eclipse.as.ui.actions.ExploreAction;
+
+public class ServerActionProvider extends CommonActionProvider {
+ public static final String NEW_MENU_ID =
"org.jboss.tools.as.wst.server.ui.internal.cnf.newMenuId";
+ public static final String SHOW_IN_MENU_ID =
"org.jboss.tools.as.wst.server.ui.internal.cnf.showInMenuId";
+ public static final String TOP_SECTION_START_SEPARATOR =
"org.jboss.tools.as.wst.server.ui.internal.cnf.topSectionStart";
+ public static final String TOP_SECTION_END_SEPARATOR =
"org.jboss.tools.as.wst.server.ui.internal.cnf.topSectionEnd";
+ public static final String EDIT_SECTION_START_SEPARATOR =
"org.jboss.tools.as.wst.server.ui.internal.cnfeditSectionStart";
+ public static final String EDIT_SECTION_END_SEPARATOR =
"org.jboss.tools.as.wst.server.ui.internal.cnf.editSectionEnd";
+ public static final String CONTROL_SERVER_SECTION_START_SEPARATOR =
"org.jboss.tools.as.wst.server.ui.internal.cnf.controlServerSectionStart";
+ public static final String CONTROL_SERVER_SECTION_END_SEPARATOR =
"org.jboss.tools.as.wst.server.ui.internal.cnf.controlServerSectionEnd";
+ public static final String SERVER_ERATA_SECTION_START_SEPARATOR =
"org.jboss.tools.as.wst.server.ui.internal.cnf.serverErataSectionStart";
+ public static final String SERVER_ERATA_SECTION_END_SEPARATOR =
"org.jboss.tools.as.wst.server.ui.internal.cnf.serverErataSectionEnd";
+ public static final String CONTROL_MODULE_SECTION_START_SEPARATOR =
"org.jboss.tools.as.wst.server.ui.internal.cnf.controlModuleSectionStart";
+ public static final String CONTROL_MODULE_SECTION_END_SEPARATOR =
"org.jboss.tools.as.wst.server.ui.internal.cnf.controlModuleSectionEnd";
+
+ private ICommonActionExtensionSite actionSite;
+ private Clipboard clipboard;
+ public ServerActionProvider() {
+ super();
+ }
+
+ public void init(ICommonActionExtensionSite aSite) {
+ super.init(aSite);
+ this.actionSite = aSite;
+ ICommonViewerSite site = aSite.getViewSite();
+ if( site instanceof ICommonViewerWorkbenchSite ) {
+ StructuredViewer v = aSite.getStructuredViewer();
+ if( v instanceof CommonViewer ) {
+ CommonViewer cv = (CommonViewer)v;
+ ICommonViewerWorkbenchSite wsSite = (ICommonViewerWorkbenchSite)site;
+ addListeners(cv);
+ makeServerActions(cv, wsSite.getSelectionProvider());
+ }
+ }
+ }
+
+
+ // actions on a server
+ protected Action[] actions;
+ protected Action actionModifyModules;
+ protected Action openAction, showInConsoleAction, showInDebugAction, propertiesAction,
monitorPropertiesAction;
+ protected Action copyAction, pasteAction, deleteAction, renameAction;
+ protected Action noneAction = new Action(Messages.dialogMonitorNone) {
+ // dummy action
+ };
+
+ private void addListeners(CommonViewer tableViewer) {
+ tableViewer.addOpenListener(new IOpenListener() {
+ public void open(OpenEvent event) {
+ try {
+ IStructuredSelection sel = (IStructuredSelection) event.getSelection();
+ Object data = sel.getFirstElement();
+ if (!(data instanceof IServer))
+ return;
+ IServer server = (IServer) data;
+ ServerUIPlugin.editServer(server);
+ } catch (Exception e) {
+ Trace.trace(Trace.SEVERE, "Could not open server", e);
+ }
+ }
+ });
+ }
+
+ private void makeServerActions(CommonViewer tableViewer, ISelectionProvider provider) {
+ clipboard = new Clipboard(tableViewer.getTree().getDisplay());
+ Shell shell = tableViewer.getTree().getShell();
+
+ actions = new Action[7];
+ // create the start actions
+ actions[0] = new StartAction(shell, provider, ILaunchManager.DEBUG_MODE);
+ actions[1] = new StartAction(shell, provider, ILaunchManager.RUN_MODE);
+ actions[2] = new StartAction(shell, provider, ILaunchManager.PROFILE_MODE);
+
+ // create the stop action
+ actions[3] = new StopAction(shell, provider);
+
+ // create the publish actions
+ actions[4] = new PublishAction(shell, provider);
+ actions[5] = new PublishCleanAction(shell, provider);
+ actions[6] = new ExploreAction(shell,provider);
+
+ // create the open action
+ openAction = new OpenAction(provider);
+
+// // create copy, paste, and delete actions
+ pasteAction = new PasteAction(shell, provider, clipboard);
+ copyAction = new CopyAction(provider, clipboard, pasteAction);
+ deleteAction = new DeleteAction(shell, provider);
+ renameAction = new RenameAction(shell, tableViewer, provider);
+
+ // create the other actions
+ actionModifyModules = new ModuleSloshAction(shell, provider);
+ showInConsoleAction = new ShowInConsoleAction(provider);
+ showInDebugAction = new ShowInDebugAction(provider);
+
+ // create the properties action
+ propertiesAction = new PropertiesAction(shell, provider);
+ monitorPropertiesAction = new PropertiesAction(shell,
"org.eclipse.wst.server.ui.properties.monitor", provider);
+ }
+
+ public void fillActionBars(IActionBars actionBars) {
+ actionBars.setGlobalActionHandler("org.eclipse.wst.server.debug",
actions[0]);
+ actionBars.setGlobalActionHandler("org.eclipse.wst.server.run", actions[1]);
+ actionBars.setGlobalActionHandler("org.eclipse.wst.server.stop",
actions[3]);
+ actionBars.setGlobalActionHandler("org.eclipse.wst.server.publish",
actions[4]);
+ actionBars.setGlobalActionHandler("org.eclipse.ui.navigator.Open",
openAction);
+ actionBars.setGlobalActionHandler(ActionFactory.PROPERTIES.getId(), propertiesAction);
+ actionBars.updateActionBars();
+ actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyAction);
+ actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), pasteAction);
+ actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), deleteAction);
+ actionBars.setGlobalActionHandler(ActionFactory.RENAME.getId(), renameAction);
+
+ IContributionManager cm = actionBars.getToolBarManager();
+ cm.removeAll();
+
+ for (int i = 0; i < actions.length - 1; i++)
+ cm.add(actions[i]);
+ }
+
+ public void fillContextMenu(IMenuManager menu) {
+ ICommonViewerSite site = actionSite.getViewSite();
+ IStructuredSelection selection = null;
+ Shell shell = actionSite.getViewSite().getShell();
+ if( site instanceof ICommonViewerWorkbenchSite ) {
+ ICommonViewerWorkbenchSite wsSite = (ICommonViewerWorkbenchSite)site;
+ selection = (IStructuredSelection) wsSite.getSelectionProvider().getSelection();
+ }
+
+ IServer server = null;
+ IModule[] module = null;
+ if (selection != null && !selection.isEmpty()) {
+ Iterator iterator = selection.iterator();
+ Object obj = iterator.next();
+ if (obj instanceof IServer)
+ server = (IServer) obj;
+ if (obj instanceof ModuleServer) {
+ ModuleServer ms = (ModuleServer) obj;
+ server = ms.server;
+ module = ms.module;
+ }
+ if (iterator.hasNext()) {
+ server = null;
+ module = null;
+ }
+ }
+
+ menu.add(invisibleSeparator(TOP_SECTION_START_SEPARATOR));
+ addTopSection(menu, server, module);
+ menu.add(invisibleSeparator(TOP_SECTION_END_SEPARATOR));
+ menu.add(new Separator());
+
+ if (server != null && module == null) {
+ menu.add(invisibleSeparator(EDIT_SECTION_START_SEPARATOR));
+ menu.add(copyAction);
+ menu.add(pasteAction);
+ menu.add(deleteAction);
+ menu.add(renameAction);
+ menu.add(invisibleSeparator(EDIT_SECTION_END_SEPARATOR));
+
+ menu.add(new Separator());
+
+ menu.add(invisibleSeparator(CONTROL_SERVER_SECTION_START_SEPARATOR));
+ for (int i = 0; i < actions.length; i++)
+ menu.add(actions[i]);
+ menu.add(invisibleSeparator(CONTROL_SERVER_SECTION_END_SEPARATOR));
+
+ menu.add(new Separator());
+
+ menu.add(invisibleSeparator(SERVER_ERATA_SECTION_START_SEPARATOR));
+ menu.add(actionModifyModules);
+ addMonitor(server, menu, shell);
+ menu.add(invisibleSeparator(SERVER_ERATA_SECTION_END_SEPARATOR));
+ menu.add(new Separator());
+ menu.add(propertiesAction);
+
+ } else if (server != null && module != null) {
+
+ menu.add(invisibleSeparator(CONTROL_MODULE_SECTION_START_SEPARATOR));
+ menu.add(new StartModuleAction(server, module));
+ menu.add(new StopModuleAction(server, module));
+ menu.add(new RestartModuleAction(server, module));
+ if(module.length == 1) {
+ menu.add(new RemoveModuleAction(shell, server, module[0]));
+ }
+ menu.add(invisibleSeparator(CONTROL_MODULE_SECTION_END_SEPARATOR));
+ }
+
+ menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+ menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS+"-end"));
+ }
+
+ protected void addTopSection(IMenuManager menu, IServer server, IModule[] module) {
+ MenuManager newMenu = new MenuManager(Messages.actionNew, NEW_MENU_ID);
+ IAction newServerAction = new NewServerWizardAction();
+ newServerAction.setText(Messages.actionNewServer);
+ newMenu.add(newServerAction);
+ menu.add(newMenu);
+
+ // open action
+ if (server != null && module == null) {
+ menu.add(openAction);
+
+ String text = Messages.actionShowIn;
+ final IWorkbench workbench = PlatformUI.getWorkbench();
+ final IBindingService bindingService = (IBindingService) workbench
+ .getAdapter(IBindingService.class);
+ final TriggerSequence[] activeBindings = bindingService
+ .getActiveBindingsFor("org.eclipse.ui.navigate.showInQuickMenu");
+ if (activeBindings.length > 0) {
+ text += "\t" + activeBindings[0].format();
+ }
+
+ MenuManager showInMenu = new MenuManager(text,
"org.eclipse.ui.navigate.showInQuickMenu");
+ showInMenu.add(showInConsoleAction);
+ showInMenu.add(showInDebugAction);
+ menu.add(showInMenu);
+ }
+ }
+
+ protected void addMonitor(IServer server, IMenuManager menu, Shell shell) {
+
+ if (server.getServerType() != null) {
+ final MenuManager menuManager = new MenuManager(Messages.actionMonitor);
+
+ final IServer server2 = server;
+ final Shell shell2 = shell;
+ menuManager.addMenuListener(new IMenuListener() {
+ public void menuAboutToShow(IMenuManager manager) {
+ menuManager.removeAll();
+ if (server2.getAdapter(ServerDelegate.class) != null) {
+ ServerPort[] ports = server2.getServerPorts(null);
+ if (ports != null) {
+ int size = ports.length;
+ for (int i = 0; i < size; i++) {
+ if (!ports[i].isAdvanced())
+ menuManager.add(new MonitorServerPortAction(shell2, server2, ports[i]));
+ }
+ }
+ }
+
+ if (menuManager.isEmpty())
+ menuManager.add(noneAction);
+
+ menuManager.add(new Separator());
+ menuManager.add(monitorPropertiesAction);
+ }
+ });
+
+ // add an initial menu item so that the menu appears correctly
+ noneAction.setEnabled(false);
+ menuManager.add(noneAction);
+ menu.add(menuManager);
+ }
+ }
+
+
+ private Separator invisibleSeparator(String s) {
+ Separator sep = new Separator(s);
+ sep.setVisible(false);
+ return sep;
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServerActionProvider.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServerContentProvider.java
(from rev 13054,
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerContentProvider.java)
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServerContentProvider.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServerContentProvider.java 2009-01-22
13:52:15 UTC (rev 13185)
@@ -0,0 +1,363 @@
+/*******************************************************************************
+ * 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 - Base Code
+ * Red Hat - Refactor for CNF
+ *******************************************************************************/
+package org.jboss.tools.as.wst.server.ui.xpl;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IPublishListener;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.IServerLifecycleListener;
+import org.eclipse.wst.server.core.IServerListener;
+import org.eclipse.wst.server.core.ServerCore;
+import org.eclipse.wst.server.core.ServerEvent;
+import org.eclipse.wst.server.core.internal.Server;
+import org.eclipse.wst.server.core.internal.UpdateServerJob;
+import org.eclipse.wst.server.core.util.PublishAdapter;
+import org.eclipse.wst.server.ui.internal.Messages;
+import org.eclipse.wst.server.ui.internal.Trace;
+import org.eclipse.wst.server.ui.internal.view.servers.ModuleServer;
+import org.eclipse.wst.server.ui.internal.viewers.BaseContentProvider;
+
+public class ServerContentProvider extends BaseContentProvider implements
ITreeContentProvider {
+ public static Object INITIALIZING = new Object();
+ protected IServerLifecycleListener serverResourceListener;
+ protected IPublishListener publishListener;
+ protected IServerListener serverListener;
+
+ // servers that are currently publishing and starting
+ protected static Set<String> publishing = new HashSet<String>(4);
+ protected static Set<String> starting = new HashSet<String>(4);
+ protected boolean animationActive = false;
+ protected boolean stopAnimation = false;
+ protected boolean initialized = false;
+
+
+ private StructuredViewer viewer;
+
+ public ServerContentProvider() {
+ addListeners();
+ }
+
+ public Object[] getElements(Object element) {
+ if( !initialized ) {
+ deferInitialization();
+ return new Object[] {INITIALIZING};
+ }
+
+ List<IServer> list = new ArrayList<IServer>();
+ IServer[] servers = ServerCore.getServers();
+ if (servers != null) {
+ int size = servers.length;
+ for (int i = 0; i < size; i++) {
+ if (!((Server)servers[i]).isPrivate())
+ list.add(servers[i]);
+ }
+ }
+ return list.toArray();
+ }
+
+ public Object[] getChildren(Object element) {
+ if (element instanceof ModuleServer) {
+ ModuleServer ms = (ModuleServer) element;
+ try {
+ IModule[] children = ms.server.getChildModules(ms.module, null);
+ int size = children.length;
+ ModuleServer[] ms2 = new ModuleServer[size];
+ for (int i = 0; i < size; i++) {
+ int size2 = ms.module.length;
+ IModule[] module = new IModule[size2 + 1];
+ System.arraycopy(ms.module, 0, module, 0, size2);
+ module[size2] = children[i];
+ ms2[i] = new ModuleServer(ms.server, module);
+ }
+ return ms2;
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ IServer server = (IServer) element;
+ IModule[] modules = server.getModules();
+ int size = modules.length;
+ ModuleServer[] ms = new ModuleServer[size];
+ for (int i = 0; i < size; i++) {
+ ms[i] = new ModuleServer(server, new IModule[] { modules[i] });
+ }
+ return ms;
+ }
+
+ public Object getParent(Object element) {
+ if (element instanceof ModuleServer) {
+ ModuleServer ms = (ModuleServer) element;
+ return ms.server;
+ }
+ return null;
+ }
+
+ public boolean hasChildren(Object element) {
+ if (element instanceof ModuleServer) {
+ // Check if the module server has child modules.
+ ModuleServer curModuleServer = (ModuleServer)element;
+ IServer curServer = curModuleServer.server;
+ IModule[] curModule = curModuleServer.module;
+ if (curServer != null && curModule != null) {
+ IModule[] curChildModule = curServer.getChildModules(curModule, null);
+ if (curChildModule != null && curChildModule.length > 0)
+ return true;
+
+ return false;
+ }
+
+ return false;
+ }
+ if( element instanceof IServer ) {
+ return ((IServer) element).getModules().length > 0;
+ }
+ return false;
+ }
+
+ public void inputChanged(Viewer aViewer, Object oldInput, Object newInput) {
+ viewer = (StructuredViewer) aViewer;
+ }
+
+ public void dispose() {
+ // remove all listeners!
+ ServerCore.removeServerLifecycleListener(serverResourceListener);
+ IServer[] servers = ServerCore.getServers();
+ for( int i = 0;i < servers.length; i++ ) {
+ servers[i].removePublishListener(publishListener);
+ servers[i].removeServerListener(serverListener);
+ }
+ }
+
+
+
+ // Listeners and refreshing the viewer
+ protected void addListeners() {
+ serverResourceListener = new IServerLifecycleListener() {
+ public void serverAdded(IServer server) {
+ refreshServer(null);
+ server.addServerListener(serverListener);
+ ((Server) server).addPublishListener(publishListener);
+ }
+ public void serverChanged(IServer server) {
+ refreshServer(server);
+ }
+ public void serverRemoved(IServer server) {
+ refreshServer(null);
+ server.removeServerListener(serverListener);
+ ((Server) server).removePublishListener(publishListener);
+ }
+ };
+ ServerCore.addServerLifecycleListener(serverResourceListener);
+
+ publishListener = new PublishAdapter() {
+ public void publishStarted(IServer server) {
+ handlePublishChange(server, true);
+ }
+
+ public void publishFinished(IServer server, IStatus status) {
+ handlePublishChange(server, false);
+ }
+ };
+
+ serverListener = new IServerListener() {
+ public void serverChanged(ServerEvent event) {
+ if (event == null)
+ return;
+
+ int eventKind = event.getKind();
+ IServer server = event.getServer();
+ if ((eventKind & ServerEvent.SERVER_CHANGE) != 0) {
+ // server change event
+ if ((eventKind & ServerEvent.STATE_CHANGE) != 0) {
+ refreshServer(server, true);
+ int state = event.getState();
+ String id = server.getId();
+ if (state == IServer.STATE_STARTING || state == IServer.STATE_STOPPING) {
+ boolean startThread = false;
+ synchronized (starting) {
+ if (!starting.contains(id)) {
+ if (starting.isEmpty())
+ startThread = true;
+ starting.add(id);
+ }
+ }
+ if (startThread)
+ startThread();
+ } else {
+ boolean stopThread = false;
+ synchronized (starting) {
+ if (starting.contains(id)) {
+ starting.remove(id);
+ if (starting.isEmpty())
+ stopThread = true;
+ }
+ }
+ if (stopThread)
+ stopThread();
+ }
+ } else
+ refreshServer(server);
+ } else if ((eventKind & ServerEvent.MODULE_CHANGE) != 0) {
+ // module change event
+ if ((eventKind & ServerEvent.STATE_CHANGE) != 0 || (eventKind &
ServerEvent.PUBLISH_STATE_CHANGE) != 0) {
+ refreshServer(server);
+ }
+ }
+ }
+ };
+
+ // add listeners to servers
+ IServer[] servers = ServerCore.getServers();
+ if (servers != null) {
+ int size = servers.length;
+ for (int i = 0; i < size; i++) {
+ servers[i].addServerListener(serverListener);
+ ((Server) servers[i]).addPublishListener(publishListener);
+ }
+ }
+ }
+
+ protected void deferInitialization() {
+ Job job = new Job(Messages.jobInitializingServersView) {
+ public IStatus run(IProgressMonitor monitor) {
+ IServer[] servers = ServerCore.getServers();
+ int size = servers.length;
+ for (int i = 0; i < size; i++) {
+ ((Server)servers[i]).getAllModules().iterator();
+ }
+
+ for (int i = 0; i < size; i++) {
+ IServer server = servers[i];
+ if (server.getServerType() != null && server.getServerState() ==
IServer.STATE_UNKNOWN) {
+ UpdateServerJob job2 = new UpdateServerJob(server);
+ job2.schedule();
+ }
+ }
+ initialized = true;
+ refreshServer(null);
+ return Status.OK_STATUS;
+ }
+ };
+
+ job.setSystem(true);
+ job.setPriority(Job.SHORT);
+ job.schedule();
+ }
+
+ protected void updateServerLabel(final IServer server) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ try {
+ if( viewer != null && !viewer.getControl().isDisposed()) {
+ viewer.update(server, null);
+ ServerDecorator.getDefault().redecorate(server);
+ }
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ });
+ }
+
+ protected void refreshServer(final IServer server) {
+ refreshServer(server, false);
+ }
+ protected void refreshServer(final IServer server, final boolean resetSelection) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ try {
+ if( viewer != null && !viewer.getControl().isDisposed()) {
+ viewer.refresh(server);
+ if( resetSelection ) {
+ ISelection sel = viewer.getSelection();
+ viewer.setSelection(sel);
+ }
+ ServerDecorator.getDefault().redecorate(server);
+ }
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ });
+ }
+
+ protected void handlePublishChange(IServer server, boolean isPublishing) {
+ String serverId = server.getId();
+ if (isPublishing)
+ publishing.add(serverId);
+ else
+ publishing.remove(serverId);
+
+ refreshServer(server);
+ }
+
+
+ protected void startThread() {
+ if (animationActive)
+ return;
+
+ stopAnimation = false;
+
+ final Display display = viewer == null ? Display.getDefault() :
viewer.getControl().getDisplay();
+ final int SLEEP = 200;
+ final Runnable[] animator = new Runnable[1];
+ animator[0] = new Runnable() {
+ public void run() {
+ if (!stopAnimation) {
+ try {
+ int size = 0;
+ String[] servers;
+ synchronized (starting) {
+ size = starting.size();
+ servers = new String[size];
+ starting.toArray(servers);
+ }
+
+ for (int i = 0; i < size; i++) {
+ IServer server = ServerCore.findServer(servers[i]);
+ if (server != null ) {
+ ServerDecorator.animate();
+ updateServerLabel(server);
+ }
+ }
+ } catch (Exception e) {
+ Trace.trace(Trace.FINEST, "Error in Servers view animation", e);
+ }
+ display.timerExec(SLEEP, animator[0]);
+ }
+ }
+ };
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ display.timerExec(SLEEP, animator[0]);
+ }
+ });
+ }
+
+ protected void stopThread() {
+ stopAnimation = true;
+ }}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServerContentProvider.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServerDecorator.java
(from rev 13054,
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerDecorator.java)
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServerDecorator.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServerDecorator.java 2009-01-22
13:52:15 UTC (rev 13185)
@@ -0,0 +1,207 @@
+/*******************************************************************************
+ * 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 - Base Code
+ * Red Hat - Refactor for CNF
+ *******************************************************************************/
+package org.jboss.tools.as.wst.server.ui.xpl;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.viewers.IDecoration;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILightweightLabelDecorator;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.LabelProviderChangedEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.IServerType;
+import org.eclipse.wst.server.core.internal.Server;
+import org.eclipse.wst.server.ui.ServerUICore;
+import org.eclipse.wst.server.ui.internal.ImageResource;
+import org.eclipse.wst.server.ui.internal.Messages;
+import org.eclipse.wst.server.ui.internal.ServerUIPlugin;
+import org.eclipse.wst.server.ui.internal.provisional.UIDecoratorManager;
+import org.eclipse.wst.server.ui.internal.view.servers.ModuleServer;
+
+public class ServerDecorator extends LabelProvider implements ILightweightLabelDecorator
{
+
+ public static final String[] syncState = new String[] {
+ Messages.viewSyncOkay,
+ Messages.viewSyncRestart,
+ Messages.viewSyncPublish,
+ Messages.viewSyncRestartPublish,
+ Messages.viewSyncPublishing};
+
+ public static final String[] syncStateUnmanaged = new String[] {
+ Messages.viewSyncOkay2,
+ Messages.viewSyncRestart2,
+ Messages.viewSyncPublish2,
+ Messages.viewSyncRestartPublish2,
+ Messages.viewSyncPublishing2};
+
+ public static final String[] modulePublishState = new String[] {
+ "",
+ Messages.viewSyncOkay,
+ Messages.viewSyncPublish,
+ Messages.viewSyncPublish};
+
+ private static ServerDecorator instance;
+ public static ServerDecorator getDefault() {
+ return instance;
+ }
+
+ private static int count = 0;
+ public static void animate() {
+ count = (count + 1)%3;
+ }
+ public static int getCount() {
+ return count;
+ }
+
+ public ServerDecorator() {
+ instance = this;
+ }
+
+ public void decorate(Object element, IDecoration decoration) {
+ if( element instanceof IServer ) {
+ String state = getServerStateLabel((IServer)element);
+ String status = getServerStatusLabel((IServer)element);
+ decoration.addSuffix(combine(state, status));
+ } else if( element instanceof ModuleServer ) {
+ String state = getModuleStateText((ModuleServer)element);
+ String status = getModuleStatusText((ModuleServer)element);
+ decoration.addSuffix(combine(state, status));
+ }
+ }
+
+ protected String combine(String state, String status) {
+ if(isEmpty(state) && isEmpty(status))
+ return "";
+ if( isEmpty(state))
+ return " [" + status + "]";
+ if( isEmpty(status))
+ return " [" + state + "]";
+ return " [" + state + ", " + status + "]";
+ }
+
+ protected boolean isEmpty(String s) {
+ return (s == null || "".equals(s));
+ }
+
+ public void redecorate(IServer server) {
+ fireLabelProviderChanged(new LabelProviderChangedEvent(this));
+ }
+
+
+
+ /*
+ * Utility methods
+ */
+ public static Image getServerImage(IServer server) {
+ return server == null ? null :
+ server.getServerType() == null ? null :
+ ImageResource.getImage(server.getServerType().getId());
+ }
+
+ public static String getServerStateLabel(IServer server) {
+ return server == null ? null :
+ server.getServerType() == null ? null :
+ getStateLabel(server.getServerType(), server.getServerState(), server.getMode());
+ }
+
+ public static String getStateLabel(IServerType serverType, int state, String mode) {
+ return serverType == null ? null :
+ UIDecoratorManager.getUIDecorator(serverType).getStateLabel(state, mode, count);
+ }
+
+ public static String getServerStatusLabel(IServer server) {
+ IStatus status = ((Server) server).getServerStatus();
+ if (status != null)
+ return status.getMessage();
+
+ if (server.getServerType() == null)
+ return "";
+
+ if (server.getServerState() == IServer.STATE_UNKNOWN)
+ return "";
+
+ String serverId = server.getId();
+ if (ServerContentProvider.publishing.contains(serverId))
+ return ServerDecorator.syncState[4];
+
+ // republish
+ int i = 0;
+ if (server.shouldPublish()) {
+ if (((Server)server).isPublishUnknown())
+ return "";
+ i += 2;
+ }
+
+ if (server.shouldRestart())
+ i = 1;
+
+ return syncState[i];
+ }
+
+ public static Image getServerStateImage(IServer server) {
+ return server == null ? null :
+ getStateImage(server.getServerType(), server.getServerState(), server.getMode());
+ }
+
+ public static Image getStateImage(IServerType serverType, int state, String mode) {
+ return serverType == null ? null :
+ UIDecoratorManager.getUIDecorator(serverType).getStateImage(state, mode, getCount());
+ }
+
+ public static String getModuleText(ModuleServer ms ) {
+ if (ms == null || ms.module == null)
+ return "";
+ int size = ms.module.length;
+ return ms.module[size - 1].getName();
+ }
+
+ public static Image getModuleImage(ModuleServer ms) {
+ if( ms != null ) {
+ ILabelProvider labelProvider = ServerUICore.getLabelProvider();
+ Image image = labelProvider.getImage(ms.module[ms.module.length - 1]);
+ labelProvider.dispose();
+ return image;
+ }
+ return null;
+ }
+
+ public static String getModuleStateText(ModuleServer ms) {
+ return "";
+ }
+
+ public static String getModuleStatusText(ModuleServer ms) {
+ if( ms != null && ms.server != null && ms.module != null ) {
+ IStatus status = ((Server) ms.server).getModuleStatus(ms.module);
+ if (status != null)
+ return status.getMessage();
+
+ return modulePublishState[ms.server.getModulePublishState(ms.module)];
+ }
+ return "";
+ }
+
+ public static Image getModuleStatusImage(ModuleServer ms) {
+ IStatus status = ((Server) ms.server).getModuleStatus(ms.module);
+ if (status != null) {
+ ISharedImages sharedImages =
ServerUIPlugin.getInstance().getWorkbench().getSharedImages();
+ if (status.getSeverity() == IStatus.ERROR)
+ return sharedImages.getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
+ else if (status.getSeverity() == IStatus.WARNING)
+ return sharedImages.getImage(ISharedImages.IMG_OBJS_WARN_TSK);
+ else if (status.getSeverity() == IStatus.INFO)
+ return sharedImages.getImage(ISharedImages.IMG_OBJS_INFO_TSK);
+ }
+ return null;
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServerDecorator.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServerLabelProvider.java
(from rev 13054,
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServerLabelProvider.java)
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServerLabelProvider.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServerLabelProvider.java 2009-01-22
13:52:15 UTC (rev 13185)
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * 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 - Base Code
+ * Red Hat - Refactor for CNF
+ *******************************************************************************/
+package org.jboss.tools.as.wst.server.ui.xpl;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.ui.ServerUICore;
+import org.eclipse.wst.server.ui.internal.ImageResource;
+import org.eclipse.wst.server.ui.internal.Messages;
+import org.eclipse.wst.server.ui.internal.view.servers.ModuleServer;
+/**
+ * Server table label provider.
+ */
+public class ServerLabelProvider extends LabelProvider {
+
+ /**
+ * ServerTableLabelProvider constructor comment.
+ */
+ public ServerLabelProvider() {
+ super();
+ }
+
+ public String getText(Object element) {
+ if (element instanceof ModuleServer) {
+ ModuleServer ms = (ModuleServer) element;
+ if (ms.module == null)
+ return "";
+ int size = ms.module.length;
+ String name = ms.module[size - 1].getName();
+ return name;
+ }
+
+ if( element instanceof IServer ) {
+ IServer server = (IServer) element;
+ return notNull(server.getName());
+ }
+
+ if( element == ServerContentProvider.INITIALIZING)
+ return Messages.viewInitializing;
+
+ return "-";
+ }
+ public Image getImage(Object element) {
+ Image image = null;
+ if (element instanceof ModuleServer) {
+ ModuleServer ms = (ModuleServer) element;
+ ILabelProvider labelProvider = ServerUICore.getLabelProvider();
+ image = labelProvider.getImage(ms.module[ms.module.length - 1]);
+ labelProvider.dispose();
+ } else if( element instanceof IServer ) {
+ IServer server = (IServer) element;
+ if (server.getServerType() != null) {
+ image = ImageResource.getImage(server.getServerType().getId());
+ }
+ }
+ return image;
+ }
+
+ protected String notNull(String s) {
+ if (s == null)
+ return "";
+ return s;
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServerLabelProvider.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServersDropAdapter.java
(from rev 13180,
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServersDropAdapter.java)
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServersDropAdapter.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServersDropAdapter.java 2009-01-22
13:52:15 UTC (rev 13185)
@@ -0,0 +1,321 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * ken.ryall(a)nokia.com - 157506 drop from external sources does not work on Linux/Mac
+ *******************************************************************************/
+package org.jboss.tools.as.wst.server.ui.xpl;
+
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.util.LocalSelectionTransfer;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DropTargetEvent;
+import org.eclipse.swt.dnd.FileTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.dnd.TransferData;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Item;
+import org.eclipse.ui.internal.navigator.NavigatorPlugin;
+import org.eclipse.ui.internal.navigator.dnd.CommonDropAdapterDescriptor;
+import org.eclipse.ui.internal.navigator.dnd.CommonDropDescriptorManager;
+import org.eclipse.ui.internal.navigator.dnd.NavigatorPluginDropAction;
+import org.eclipse.ui.navigator.CommonDragAdapter;
+import org.eclipse.ui.navigator.CommonDragAdapterAssistant;
+import org.eclipse.ui.navigator.CommonDropAdapterAssistant;
+import org.eclipse.ui.navigator.CommonViewer;
+import org.eclipse.ui.navigator.INavigatorContentService;
+import org.eclipse.ui.navigator.INavigatorDnDService;
+import org.eclipse.ui.part.PluginDropAdapter;
+import org.eclipse.ui.part.PluginTransfer;
+
+/*
+ * THIS CLASS IS A CLONE of CommonDropAdapter.
+ * It is necessary because dragged items must be acceptable children.
+ * Stupid restriction
+ *
+ * I use a delegate and push all methods to the delegate,
+ * even the ones I override.
+ *
+ *
https://bugs.eclipse.org/bugs/show_bug.cgi?id=261606
+ *
+ * Maybe one day they'll fix that ;)
+ */
+
+/**
+ * Provides an implementation of {@link PluginDropAdapter} which uses the
+ * extensions provided by the associated {@link INavigatorContentService}.
+ *
+ * <p>
+ * Clients should not need to create an instance of this class unless they are
+ * creating their own custom viewer. Otherwise, {@link CommonViewer} configures
+ * its drop adapter automatically.
+ * </p>
+ *
+ *
+ * @see INavigatorDnDService
+ * @see CommonDragAdapter
+ * @see CommonDragAdapterAssistant
+ * @see CommonDropAdapterAssistant
+ * @see CommonViewer
+ * @since 3.2
+ */
+public final class ServersDropAdapter extends PluginDropAdapter {
+ private static final Transfer[] SUPPORTED_DROP_TRANSFERS = new Transfer[] {
+ LocalSelectionTransfer.getTransfer(), FileTransfer.getInstance(),
+ PluginTransfer.getInstance() };
+ private final INavigatorContentService contentService;
+ private final INavigatorDnDService dndService;
+
+ public ServersDropAdapter(INavigatorContentService aContentService,
+ StructuredViewer aStructuredViewer) {
+ super(aStructuredViewer);
+ contentService = aContentService;
+ dndService = contentService.getDnDService();
+ }
+
+ public Transfer[] getSupportedDropTransfers() {
+ return SUPPORTED_DROP_TRANSFERS;
+ }
+
+ public void dragEnter(DropTargetEvent event) {
+ super.dragEnter(event);
+
+ for (int i = 0; i < event.dataTypes.length; i++) {
+ if (LocalSelectionTransfer.getTransfer().isSupportedType(
+ event.dataTypes[i])) {
+ event.currentDataType = event.dataTypes[i];
+ return;
+ }
+ }
+
+ for (int i = 0; i < event.dataTypes.length; i++) {
+ if (FileTransfer.getInstance().isSupportedType(event.dataTypes[i])) {
+ event.currentDataType = event.dataTypes[i];
+ event.detail = DND.DROP_COPY;
+ return;
+ }
+ }
+
+ for (int i = 0; i < event.dataTypes.length; i++) {
+ if (PluginTransfer.getInstance()
+ .isSupportedType(event.dataTypes[i])) {
+ event.currentDataType = event.dataTypes[i];
+ return;
+ }
+ }
+
+ event.detail = DND.DROP_NONE;
+
+ }
+
+ public void dragLeave(DropTargetEvent event) {
+ super.dragLeave(event);
+ if (LocalSelectionTransfer.getTransfer().isSupportedType(
+ event.currentDataType)) {
+ event.data = NavigatorPluginDropAction
+ .createTransferData(contentService);
+ }
+ }
+
+ /*
+ * Changed from CommonDropAdapter to extract the findCommonDropAdapterAssistant section
+ * since I do not like the impl in dnd service
+ */
+ public void drop(DropTargetEvent event) {
+ // Must validate the drop here because on some platforms (Linux, Mac) the event
+ // is not populated with the correct currentDataType until the drop actually
+ // happens, and validateDrop sets the currentTransfer based on that. The
+ // call to validateDrop in dragAccept is too early.
+ validateDrop(getCurrentTarget(), getCurrentOperation(), event.currentDataType);
+ if (PluginTransfer.getInstance().isSupportedType(event.currentDataType)) {
+ super.drop(event);
+ } else {
+
+ Object target = getCurrentTarget() != null ?
+ getCurrentTarget() : getViewer().getInput();
+
+ CommonDropAdapterAssistant[] assistants =
+ findCommonDropAdapterAssistants(target, getCurrentTransfer());
+ IStatus valid = null;
+ for (int i = 0; i < assistants.length; i++) {
+ try {
+ valid = assistants[i].validateDrop(getCurrentTarget(),
+ getCurrentOperation(), getCurrentTransfer());
+ if (valid != null && valid.isOK()) {
+ assistants[i].handleDrop(null, event,
+ getCurrentTarget());
+ event.detail = DND.DROP_NONE;
+ return;
+ }
+ } catch (Throwable t) {
+ NavigatorPlugin.logError(0, t.getMessage(), t);
+ }
+ }
+ event.detail = DND.DROP_NONE;
+ }
+ }
+
+ /*
+ * Changed from CommonDropAdapter to extract the findCommonDropAdapterAssistant section
+ * since I do not like the impl in dnd service
+ */
+ public boolean validateDrop(Object aDropTarget, int theDropOperation,
+ TransferData theTransferData) {
+ boolean result = false;
+ IStatus valid = null;
+ if (super.validateDrop(aDropTarget, theDropOperation, theTransferData)) {
+ result = true;
+ } else {
+ Object target = aDropTarget != null ? aDropTarget : getViewer().getInput();
+ CommonDropAdapterAssistant[] assistants =
+ findCommonDropAdapterAssistants(target,
+ theTransferData);
+ for (int i = 0; i < assistants.length; i++) {
+ try {
+ valid = assistants[i].validateDrop(target,
+ theDropOperation, theTransferData);
+ } catch (Throwable t) {
+ NavigatorPlugin.logError(0, t.getMessage(), t);
+ }
+ if (valid != null && valid.isOK()) {
+ result = true;
+ break;
+ }
+ }
+ }
+ setScrollExpandEnabled(true);
+ return result;
+
+ }
+
+ public Rectangle getBounds(Item item) {
+ return super.getBounds(item);
+ }
+
+ public int getCurrentLocation() {
+ return super.getCurrentLocation();
+ }
+
+ public int getCurrentOperation() {
+ return super.getCurrentOperation();
+ }
+
+ public Object getCurrentTarget() {
+ return super.getCurrentTarget();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.part.PluginDropAdapter#getCurrentTransfer()
+ */
+ public TransferData getCurrentTransfer() {
+ return super.getCurrentTransfer();
+ }
+
+ /**
+ * Returns the position of the given event's coordinates relative to its target.
+ * The position is determined to be before, after, or on the item, based on
+ * some threshold value.
+ *
+ * @param event the event
+ * @return one of the <code>LOCATION_* </code>constants defined in this
class
+ */
+ protected int determineLocation(DropTargetEvent event) {
+ if (!(event.item instanceof Item)) {
+ return LOCATION_NONE;
+ }
+ return LOCATION_ON;
+ }
+
+
+ private CommonDropAdapterAssistant[] findCommonDropAdapterAssistants(
+ Object aDropTarget, TransferData theTransferType) {
+ CommonDropAdapterAssistant[] result =
+ findCommonDropAdapterAssistants2(aDropTarget, theTransferType);
+ return result;
+ }
+
+
+
+ /*
+ * Stolen from DND Service
+ */
+
+ private static final CommonDropAdapterAssistant[] NO_ASSISTANTS = new
CommonDropAdapterAssistant[0];
+ private final Map dropAssistants = new HashMap();
+
+ public CommonDropAdapterAssistant[] findCommonDropAdapterAssistants2(
+ Object aDropTarget, TransferData aTransferType) {
+
+ // TODO Make sure descriptors are sorted by priority
+ CommonDropAdapterDescriptor[] descriptors = CommonDropDescriptorManager
+ .getInstance().findCommonDropAdapterAssistants(aDropTarget,
+ contentService);
+
+ if (descriptors.length == 0) {
+ return NO_ASSISTANTS;
+ }
+ if (LocalSelectionTransfer.getTransfer().isSupportedType(aTransferType)
+ && LocalSelectionTransfer.getTransfer().getSelection() instanceof
IStructuredSelection) {
+ return getAssistants(descriptors);
+ }
+ return getAssistantsByTransferData(descriptors, aTransferType);
+ }
+
+ private CommonDropAdapterAssistant[] getAssistants(CommonDropAdapterDescriptor[]
descriptors) {
+ Set assistants = new LinkedHashSet();
+ for (int i = 0; i < descriptors.length; i++) {
+ assistants.add(getAssistant(descriptors[i]));
+ }
+ return (CommonDropAdapterAssistant[]) assistants
+ .toArray(new CommonDropAdapterAssistant[assistants.size()]);
+ }
+
+ private CommonDropAdapterAssistant[] getAssistantsByTransferData(
+ CommonDropAdapterDescriptor[] descriptors,
+ TransferData aTransferType) {
+
+ Set assistants = new LinkedHashSet();
+ for (int i = 0; i < descriptors.length; i++) {
+ CommonDropAdapterAssistant asst = getAssistant(descriptors[i]);
+ if (asst.isSupportedType(aTransferType)) {
+ assistants.add(asst);
+ }
+ }
+ return (CommonDropAdapterAssistant[]) assistants
+ .toArray(new CommonDropAdapterAssistant[assistants.size()]);
+
+ }
+
+ private CommonDropAdapterAssistant getAssistant(
+ CommonDropAdapterDescriptor descriptor) {
+ CommonDropAdapterAssistant asst = (CommonDropAdapterAssistant) dropAssistants
+ .get(descriptor);
+ if (asst != null) {
+ return asst;
+ }
+ synchronized (dropAssistants) {
+ asst = (CommonDropAdapterAssistant) dropAssistants.get(descriptor);
+ if (asst == null) {
+ dropAssistants.put(descriptor, (asst = descriptor
+ .createDropAssistant()));
+ asst.init(contentService);
+ }
+ }
+ return asst;
+ }
+
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServersDropAdapter.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServersView.java
(from rev 13179,
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServersView.java)
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServersView.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServersView.java 2009-01-22
13:52:15 UTC (rev 13185)
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - Code taken from Superclass
+ * Red Hat Inc - Refactor
+ *******************************************************************************/
+package org.jboss.tools.as.wst.server.ui.xpl;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.navigator.CommonDragAdapter;
+import org.eclipse.ui.navigator.CommonDropAdapter;
+import org.eclipse.ui.navigator.CommonNavigator;
+import org.eclipse.ui.navigator.CommonViewer;
+/**
+ * A view of servers, their modules, and status.
+ */
+public class ServersView extends CommonNavigator {
+
+ /**
+ * ServersView constructor comment.
+ */
+ public ServersView() {
+ super();
+ }
+
+ /*
+ * Stuff that shouldn't even be here but CNF is kinda lame
+ * Must override currently to overcome the bug below:
+ *
+ *
https://bugs.eclipse.org/bugs/show_bug.cgi?id=261606
+ */
+ private IMemento memento;
+
+ public void init(IViewSite aSite, IMemento aMemento)
+ throws PartInitException {
+ this.memento = memento;
+ super.init(aSite, aMemento);
+ }
+
+ protected CommonViewer createCommonViewer(Composite aParent) {
+ CommonViewer aViewer = new CommonViewerExtension(getViewSite().getId(), aParent,
+ SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+ initListeners(aViewer);
+ aViewer.getNavigatorContentService().restoreState(memento);
+ return aViewer;
+ }
+
+
+ public class CommonViewerExtension extends CommonViewer {
+ public CommonViewerExtension(String aViewerId, Composite aParent, int aStyle) {
+ super(aViewerId, aParent, aStyle);
+ }
+
+ protected void initDragAndDrop() {
+ /* Handle Drag and Drop */
+ int operations = DND.DROP_COPY | DND.DROP_MOVE;
+
+ CommonDragAdapter dragAdapter = new CommonDragAdapter(
+ getNavigatorContentService(), this);
+ addDragSupport(operations, dragAdapter.getSupportedDragTransfers(),
+ dragAdapter);
+
+ ServersDropAdapter dropAdapter = new ServersDropAdapter(
+ getNavigatorContentService(), this);
+ addDropSupport(operations, dropAdapter.getSupportedDropTransfers(),
+ dropAdapter);
+ }
+ }
+}
\ No newline at end of file
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServersView.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServersViewDropAdapterAssistant.java
(from rev 13179,
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/ServersViewDropAdapterAssistant.java)
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServersViewDropAdapterAssistant.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServersViewDropAdapterAssistant.java 2009-01-22
13:52:15 UTC (rev 13185)
@@ -0,0 +1,203 @@
+/*******************************************************************************
+ * 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:
+ * Red Hat - Initial Implementation
+ *******************************************************************************/
+package org.jboss.tools.as.wst.server.ui.xpl;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.dnd.DropTargetEvent;
+import org.eclipse.swt.dnd.FileTransfer;
+import org.eclipse.swt.dnd.TransferData;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.activities.WorkbenchActivityHelper;
+import org.eclipse.ui.internal.Workbench;
+import org.eclipse.ui.navigator.CommonDropAdapter;
+import org.eclipse.ui.navigator.CommonDropAdapterAssistant;
+import org.eclipse.ui.part.ResourceTransfer;
+import org.eclipse.ui.views.navigator.LocalSelectionTransfer;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IModuleArtifact;
+import org.eclipse.wst.server.core.IModuleType;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
+import org.eclipse.wst.server.core.ServerUtil;
+import org.eclipse.wst.server.core.internal.ServerPlugin;
+import org.eclipse.wst.server.ui.internal.EclipseUtil;
+import org.eclipse.wst.server.ui.internal.ServerUIPlugin;
+import org.eclipse.wst.server.ui.internal.actions.RunOnServerActionDelegate;
+
+public class ServersViewDropAdapterAssistant extends CommonDropAdapterAssistant {
+
+ @SuppressWarnings("unchecked") private List fElements;
+
+ public ServersViewDropAdapterAssistant() {
+ super();
+ }
+ protected void doInit() {
+ }
+
+ public IStatus validatePluginTransferDrop(
+ IStructuredSelection aDragSelection, Object aDropTarget) {
+ initializeSelection(aDragSelection);
+ return internalValidate(aDropTarget, fElements);
+ }
+
+ public IStatus validateDrop(Object target, int operation,
+ TransferData transferType) {
+ if (LocalSelectionTransfer.getInstance().isSupportedType(transferType)) {
+ ISelection s = LocalSelectionTransfer.getInstance().getSelection();
+ initializeSelection(s);
+ return internalValidate(target, fElements);
+ }
+ return Status.CANCEL_STATUS;
+ }
+
+ protected void initializeSelection(ISelection s) {
+ if (fElements != null)
+ return;
+ if (!(s instanceof IStructuredSelection)) {
+ fElements= Collections.EMPTY_LIST;
+ return;
+ }
+ fElements = ((IStructuredSelection) s).toList();
+ }
+
+ @SuppressWarnings("unchecked")
+ protected IStatus internalValidate(Object target, List elements) {
+ if( target instanceof IServer ) {
+ IServer server = (IServer)target;
+ Object next;
+ if( elements != null ) {
+ Iterator i = elements.iterator();
+ while(i.hasNext() ) {
+ next = i.next();
+ IModuleArtifact[] moduleArtifacts = ServerPlugin.getModuleArtifacts(next);
+ if (moduleArtifacts != null && moduleArtifacts.length > 0 ) {
+ for( int j = 0; j < moduleArtifacts.length; j++ ) {
+ if( moduleArtifacts[j] != null && moduleArtifacts[j].getModule() != null )
{
+ IModuleType[] moduleTypes =
server.getServerType().getRuntimeType().getModuleTypes();
+ if (ServerUtil.isSupportedModule(moduleTypes,
moduleArtifacts[j].getModule().getModuleType())) {
+ return Status.OK_STATUS;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ clear();
+ return Status.CANCEL_STATUS;
+ }
+
+ public IStatus handleDrop(CommonDropAdapter dropAdapter,
+ DropTargetEvent dropTargetEvent, Object target) {
+ return internalHandleDrop(target, fElements);
+ }
+
+ public IStatus handlePluginTransferDrop(
+ IStructuredSelection aDragSelection, Object aDropTarget) {
+ return internalHandleDrop(aDropTarget, fElements);
+ }
+
+ protected IStatus internalHandleDrop(Object target, List elements) {
+ boolean b = false;
+ if( target instanceof IServer ) {
+ b = true;
+ if( fElements != null ) {
+ Iterator iterator = elements.iterator();
+ while (iterator.hasNext()) {
+ Object data2 = iterator.next();
+ if (!doSel((IServer)target, data2))
+ b = false;
+ }
+ }
+ }
+ clear();
+ return b ? Status.OK_STATUS : Status.CANCEL_STATUS;
+ }
+
+ private void clear() {
+ fElements = null;
+ }
+
+ protected boolean doSel(IServer server, Object data) {
+ // check if the selection is a project (module) that we can add to the server
+ IProject project = (IProject) Platform.getAdapterManager().getAdapter(data,
IProject.class);
+ if (project != null) {
+ IModule[] modules = ServerUtil.getModules(project);
+ if (modules != null && modules.length == 1) {
+ try {
+ IServerWorkingCopy wc = server.createWorkingCopy();
+ IModule[] parents = wc.getRootModules(modules[0], null);
+ if (parents == null || parents.length == 0)
+ return false;
+
+ if (ServerUtil.containsModule(server, parents[0], null))
+ return false;
+
+ IModule[] add = new IModule[] { parents[0] };
+ if (wc.canModifyModules(add, null, null).getSeverity() != IStatus.ERROR) {
+ wc.modifyModules(modules, null, null);
+ wc.save(false, null);
+ return true;
+ }
+ } catch (final CoreException ce) {
+ final Shell shell = Workbench.getInstance().getActiveWorkbenchWindow().getShell();
+ shell.getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ EclipseUtil.openError(shell, ce.getLocalizedMessage());
+ }
+ });
+ return true;
+ }
+ }
+ }
+
+ // otherwise, try Run on Server
+ final IServer finalServer = server;
+ RunOnServerActionDelegate ros = new RunOnServerActionDelegate() {
+ public IServer getServer(IModule module, IModuleArtifact moduleArtifact,
IProgressMonitor monitor) throws CoreException {
+ if (!ServerUIPlugin.isCompatibleWithLaunchMode(finalServer, launchMode))
+ return null;
+
+ if (!ServerUtil.containsModule(finalServer, module, monitor)) {
+ IServerWorkingCopy wc = finalServer.createWorkingCopy();
+ try {
+ ServerUtil.modifyModules(wc, new IModule[] { module }, new IModule[0], monitor);
+ wc.save(false, monitor);
+ } catch (CoreException ce) {
+ throw ce;
+ }
+ }
+
+ return finalServer;
+ }
+ };
+ Action action = new Action() {
+ //
+ };
+ ros.selectionChanged(action, new StructuredSelection(data));
+
+ ros.run(action);
+ return true;
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/as/wst/server/ui/xpl/ServersViewDropAdapterAssistant.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2009-01-22 11:01:21 UTC (rev
13184)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2009-01-22 13:52:15 UTC (rev
13185)
@@ -266,7 +266,7 @@
id="org.jboss.ide.eclipse.as.ui.views.JBossServerView"
name="%ViewName_JBossServerView"
category="org.eclipse.wst.server.ui"
- class="org.jboss.tools.as.wst.server.ui.ServersView"
+ class="org.jboss.tools.as.wst.server.ui.xpl.ServersView"
icon="icons/jboss.gif"/>
<view
category="org.eclipse.wst.server.ui"
@@ -280,7 +280,7 @@
<extension point="org.eclipse.ui.decorators">
<decorator
- class="org.jboss.tools.as.wst.server.ui.ServerDecorator"
+ class="org.jboss.tools.as.wst.server.ui.xpl.ServerDecorator"
icon="icons/cview16/servers_view.gif"
id="org.jboss.tools.as.wst.server.ui.navigatorDecorator"
label="Server State Decorator"
@@ -303,10 +303,10 @@
point="org.eclipse.ui.navigator.navigatorContent">
<navigatorContent
activeByDefault="true"
-
contentProvider="org.jboss.tools.as.wst.server.ui.ServerContentProvider"
+
contentProvider="org.jboss.tools.as.wst.server.ui.xpl.ServerContentProvider"
icon="icons/cview16/servers_view.gif"
id="org.jboss.tools.as.wst.server.ui.ServersView.content.root"
- labelProvider="org.jboss.tools.as.wst.server.ui.ServerLabelProvider"
+
labelProvider="org.jboss.tools.as.wst.server.ui.xpl.ServerLabelProvider"
name="Servers View Default Content"
priority="highest">
<triggerPoints>
@@ -324,7 +324,7 @@
</instanceof>
</or></possibleChildren>
<actionProvider
- class="org.jboss.tools.as.wst.server.ui.ServerActionProvider"
+ class="org.jboss.tools.as.wst.server.ui.xpl.ServerActionProvider"
id="org.jboss.tools.as.wst.server.ui.ServersView.ServerActionProvider"
priority="highest">
<enablement>
@@ -348,7 +348,7 @@
</enablement>
</actionProvider>
<dropAssistant
-
class="org.jboss.tools.as.wst.server.ui.ServersViewDropAdapterAssistant"
+
class="org.jboss.tools.as.wst.server.ui.xpl.ServersViewDropAdapterAssistant"
id="org.jboss.tools.as.wst.server.ui.ServersView.DropAssistant">
<possibleDropTargets>
<instanceof