Author: rob.stryker(a)jboss.com
Date: 2010-01-14 21:51:30 -0500 (Thu, 14 Jan 2010)
New Revision: 19762
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/commands/
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/commands/FullPublishCommandHandler.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/META-INF/MANIFEST.MF
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/plugin.xml
Log:
JBIDE-3767 - partially complete but definitely usable, no UI at all. (better than ugly
UI)
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/META-INF/MANIFEST.MF 2010-01-15
02:47:43 UTC (rev 19761)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/META-INF/MANIFEST.MF 2010-01-15
02:51:30 UTC (rev 19762)
@@ -25,7 +25,8 @@
org.eclipse.wst.server.core;bundle-version="1.1.101",
org.eclipse.wst.common.emfworkbench.integration;bundle-version="1.1.300",
org.eclipse.emf.ecore;bundle-version="2.5.0",
- org.jboss.ide.eclipse.as.wtp.core;bundle-version="1.0.0"
+ org.jboss.ide.eclipse.as.wtp.core;bundle-version="1.0.0",
+ org.eclipse.debug.ui;bundle-version="3.5.1";resolution:=optional
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: JBoss by Red Hat
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/plugin.xml 2010-01-15 02:47:43 UTC
(rev 19761)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/plugin.xml 2010-01-15 02:51:30 UTC
(rev 19762)
@@ -96,4 +96,21 @@
weight="5">
</provider>
</extension>
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+
defaultHandler="org.jboss.ide.eclipse.as.wtp.ui.commands.FullPublishCommandHandler"
+ id="org.jboss.ide.eclipse.as.wtp.ui.fullPublishCommand"
+ name="Full Publish">
+ </command>
+ </extension>
+ <extension
+ point="org.eclipse.ui.bindings">
+ <key
+ commandId="org.jboss.ide.eclipse.as.wtp.ui.fullPublishCommand"
+ contextId="org.eclipse.ui.contexts.window"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+ sequence="M1+M2+M">
+ </key>
+ </extension>
</plugin>
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/commands/FullPublishCommandHandler.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/commands/FullPublishCommandHandler.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/commands/FullPublishCommandHandler.java 2010-01-15
02:51:30 UTC (rev 19762)
@@ -0,0 +1,112 @@
+/*************************************************************************************
+ * Copyright (c) 2008-2009 JBoss by Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.ide.eclipse.as.wtp.ui.commands;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.commands.IHandlerListener;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.debug.internal.ui.stringsubstitution.SelectedResourceManager;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IModuleArtifact;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.ServerCore;
+import org.eclipse.wst.server.core.internal.PublishServerJob;
+import org.eclipse.wst.server.core.internal.Server;
+import org.eclipse.wst.server.core.internal.ServerPlugin;
+import org.jboss.ide.eclipse.as.wtp.core.util.ServerModelUtilities;
+
+public class FullPublishCommandHandler implements IHandler {
+
+ public void addHandlerListener(IHandlerListener handlerListener) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void dispose() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ // go around in a circle to avoid plugin dependence on debug.ui
+ IResource resource = SelectedResourceManager.getDefault().getSelectedResource();
+ IModule module = getModule(resource);
+ Server server = (Server)getServer(module);
+ if( module != null && server != null ) {
+ IModule[] module2 = new IModule[]{module};
+ server.setModulePublishState(module2, IServer.PUBLISH_STATE_FULL);
+ ArrayList<IModule[]> allChildren = ServerModelUtilities.getDeepChildren(server,
module2);
+ for( int j = 0; j < allChildren.size(); j++ ) {
+ server.setModulePublishState((IModule[])allChildren.get(j),
IServer.PUBLISH_STATE_FULL);
+ }
+ }
+ new PublishServerJob(server, IServer.PUBLISH_INCREMENTAL, true).schedule();
+ return null;
+ }
+
+ public IServer getServer(IModule module) {
+ IServer toRepublish = null;
+ if( module != null ) {
+ IServer[] servers = ServerCore.getServers();
+ ArrayList<IServer> matched = new ArrayList<IServer>();
+ for( int i = 0; i < servers.length; i++ ) {
+ boolean found = false;
+ IModule[] deployed = servers[i].getModules();
+ for( int j = 0; j < deployed.length && !found; j++ )
+ if( deployed[j].getId().equals(module.getId()))
+ found = true;
+ if( found )
+ matched.add(servers[i]);
+ }
+
+ if( matched.size() == 0 || matched.size() > 1 ) {
+ // TODO show a dialog to choose the server
+ toRepublish = matched.get(0);
+ } else
+ toRepublish = matched.get(0);
+ }
+ return toRepublish;
+ }
+
+ protected IModule getModule(IResource resource) {
+ IModule module = null;
+ if (resource != null) {
+ IModuleArtifact[] moduleArtifacts = ServerPlugin.getModuleArtifacts(resource);
+ IModuleArtifact moduleArtifact = null;
+ if (moduleArtifacts != null && moduleArtifacts.length > 0)
+ moduleArtifact = moduleArtifacts[0];
+
+ if (moduleArtifact != null)
+ module = moduleArtifact.getModule();
+
+ }
+ return module;
+ }
+
+ public boolean isEnabled() {
+ IResource resource = SelectedResourceManager.getDefault().getSelectedResource();
+ IModule module = getModule(resource);
+ return module != null;
+ }
+
+ public boolean isHandled() {
+ return true;
+ }
+
+ public void removeHandlerListener(IHandlerListener handlerListener) {
+ // TODO Auto-generated method stub
+ }
+
+}