Author: rob.stryker(a)jboss.com
Date: 2012-01-13 02:11:12 -0500 (Fri, 13 Jan 2012)
New Revision: 37808
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServer.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DelegatingServerBehavior.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServer.java
trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JMXProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/UIUtil.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/XPathDialogs.java
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/util/ServerModelUtilities.java
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EGitUtils.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressBehaviour.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressBehaviourDelegate.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressMessages.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressPublishMethod.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/expressMessages.properties
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/console/ConsoleUtils.java
Log:
A sloppy mix of JBIDE-10580 and JBIDE-10527 and JBIDE-10544
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DelegatingServerBehavior.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DelegatingServerBehavior.java 2012-01-13
01:23:53 UTC (rev 37807)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DelegatingServerBehavior.java 2012-01-13
07:11:12 UTC (rev 37808)
@@ -16,6 +16,7 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
@@ -26,11 +27,11 @@
import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublishMethod;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublishMethodType;
+import org.jboss.ide.eclipse.as.core.server.internal.BehaviourModel.Behaviour;
import org.jboss.ide.eclipse.as.core.server.internal.BehaviourModel.BehaviourImpl;
import
org.jboss.ide.eclipse.as.core.server.internal.launch.DelegatingStartLaunchConfiguration;
import
org.jboss.ide.eclipse.as.core.server.xpl.PublishCopyUtil.IPublishCopyCallbackHandler;
import org.jboss.ide.eclipse.as.core.util.DeploymentPreferenceLoader;
-import org.jboss.ide.eclipse.as.core.util.LaunchCommandPreferences;
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
import org.jboss.ide.eclipse.as.wtp.core.util.ServerModelUtilities;
@@ -54,12 +55,16 @@
if( id.equals(lastModeId) && delegate != null &&
delegate.getBehaviourTypeId().equals(id))
return delegate;
- BehaviourImpl impl =
BehaviourModel.getModel().getBehaviour(getServer().getServerType().getId()).getImpl(id);
- IJBossBehaviourDelegate d = impl.createBehaviourDelegate();
- d.setActualBehaviour(this);
- lastModeId = id;
- delegate = d;
- return delegate;
+ Behaviour b =
BehaviourModel.getModel().getBehaviour(getServer().getServerType().getId());
+ BehaviourImpl impl = b.getImpl(id);
+ if( impl != null ) {
+ IJBossBehaviourDelegate d = impl.createBehaviourDelegate();
+ d.setActualBehaviour(this);
+ lastModeId = id;
+ delegate = d;
+ return delegate;
+ }
+ return null;
}
public void stop(boolean force) {
@@ -148,7 +153,9 @@
}
protected IStatus canChangeState(String launchMode) {
- return getDelegate().canChangeState(launchMode);
+ if( getDelegate() != null )
+ return getDelegate().canChangeState(launchMode);
+ return Status.CANCEL_STATUS;
}
public boolean canRestartModule(IModule[] module){
@@ -176,6 +183,7 @@
@Override
public void dispose() {
- getDelegate().dispose();
+ if( getDelegate() != null )
+ getDelegate().dispose();
}
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServer.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServer.java 2012-01-13
01:23:53 UTC (rev 37807)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServer.java 2012-01-13
07:11:12 UTC (rev 37808)
@@ -10,17 +10,13 @@
******************************************************************************/
package org.jboss.ide.eclipse.as.core.server.internal;
-import java.util.ArrayList;
-
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IRuntime;
-import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.IServerWorkingCopy;
import org.eclipse.wst.server.core.ServerPort;
import org.eclipse.wst.server.core.model.ServerDelegate;
@@ -66,8 +62,8 @@
public IModule[] getRootModules(IModule module) throws CoreException {
IStatus status = canModifyModules(new IModule[] { module }, null);
if (status != null && !status.isOK())
- throw new CoreException(status);;
- IModule[] parents = doGetParentModules(module);
+ throw new CoreException(status);
+ IModule[] parents = ServerModelUtilities.getParentModules(getServer(), module);
if(parents.length>0)
return parents;
return new IModule[] { module };
@@ -77,23 +73,6 @@
return ServerModelUtilities.getChildModules(module);
}
- private IModule[] doGetParentModules(IModule module) {
- // get all supported modules
- IModule[] supported =
- org.eclipse.wst.server.core.ServerUtil.getModules(
- getServer().getServerType().getRuntimeType().getModuleTypes());
- ArrayList<IModule> list = new ArrayList<IModule>();
-
- for( int i = 0; i < supported.length; i++ ) {
- IModule[] childs = ServerModelUtilities.getChildModules(supported[i]);
- for (int j = 0; j < childs.length; j++) {
- if(childs[j].equals(module))
- list.add(supported[i]);
- }
- }
- return list.toArray(new IModule[list.size()]);
- }
-
public ServerPort[] getServerPorts() {
return new ServerPort[0];
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JMXProvider.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JMXProvider.java 2012-01-13
01:23:53 UTC (rev 37807)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.jmx.integration/src/org/jboss/ide/eclipse/as/jmx/integration/JMXProvider.java 2012-01-13
07:11:12 UTC (rev 37808)
@@ -23,9 +23,7 @@
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.navigator.CommonActionProvider;
@@ -38,9 +36,9 @@
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.ui.internal.view.servers.AbstractServerAction;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
-import org.jboss.ide.eclipse.as.core.util.ServerConverter;
import org.jboss.ide.eclipse.as.core.util.ServerUtil;
import org.jboss.ide.eclipse.as.ui.JBossServerUISharedImages;
+import org.jboss.ide.eclipse.as.ui.UIUtil;
import org.jboss.tools.jmx.core.ExtensionManager;
import org.jboss.tools.jmx.core.IConnectionWrapper;
import org.jboss.tools.jmx.ui.internal.views.navigator.JMXNavigator;
@@ -113,36 +111,30 @@
}
public void perform(final IServer server) {
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow() ;
- if (window != null) {
- IWorkbenchPage page = window.getActivePage();
- if (page != null) {
- IWorkbenchPart part = page.findView(JMXNavigator.VIEW_ID);
- if (part == null) {
- try {
- part = page.showView(JMXNavigator.VIEW_ID);
- } catch (PartInitException e) {
+ IWorkbenchPart part = null;
+ try {
+ part = UIUtil.bringViewToFront(JMXNavigator.VIEW_ID);
+ } catch(PartInitException pie) {
+ // TODO trace or error
+ }
+
+ if( part != null ) {
+ final JMXNavigator view = (JMXNavigator) part.getAdapter(JMXNavigator.class);
+ if (view != null) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ JBossServerConnectionProvider provider =
+ (JBossServerConnectionProvider)ExtensionManager.getProvider(
+ JBossServerConnectionProvider.PROVIDER_ID);
+ IConnectionWrapper connection = provider.getConnection(server);
+ if( connection != null ) {
+ view.getCommonViewer().collapseAll();
+ ISelection sel = new StructuredSelection(new Object[] { connection });
+ view.getCommonViewer().setSelection(sel, true);
+ view.getCommonViewer().expandToLevel(connection, 2);
+ }
}
- } else /* if( part != null ) */ {
- final JMXNavigator view = (JMXNavigator) part.getAdapter(JMXNavigator.class);
- if (view != null) {
- view.setFocus();
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- JBossServerConnectionProvider provider =
- (JBossServerConnectionProvider)ExtensionManager.getProvider(
- JBossServerConnectionProvider.PROVIDER_ID);
- IConnectionWrapper connection = provider.getConnection(server);
- if( connection != null ) {
- view.getCommonViewer().collapseAll();
- ISelection sel = new StructuredSelection(new Object[] { connection });
- view.getCommonViewer().setSelection(sel, true);
- view.getCommonViewer().expandToLevel(connection, 2);
- }
- }
- });
- }
- }
+ });
}
}
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/UIUtil.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/UIUtil.java 2012-01-13
01:23:53 UTC (rev 37807)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/UIUtil.java 2012-01-13
07:11:12 UTC (rev 37808)
@@ -13,6 +13,11 @@
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
public class UIUtil {
@@ -46,4 +51,24 @@
Object leftStart, int leftOffset, Object rightStart, int rightOffset) {
return createFormData2(topStart, topOffset, bottomStart, bottomOffset, leftStart,
leftOffset, rightStart, rightOffset);
}
+
+ public static final IWorkbenchPart bringViewToFront(String viewId) throws
PartInitException {
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow() ;
+ IWorkbenchPart part = null;
+ if (window != null) {
+ IWorkbenchPage page = window.getActivePage();
+ if (page != null) {
+ part = page.findView(viewId);
+ if (part == null) {
+ part = page.showView(viewId);
+ } else /* if( part != null ) */ {
+ if (part != null) {
+ page.activate(part);
+ part.setFocus();
+ }
+ }
+ }
+ }
+ return part;
+ }
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/XPathDialogs.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/XPathDialogs.java 2012-01-13
01:23:53 UTC (rev 37807)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/XPathDialogs.java 2012-01-13
07:11:12 UTC (rev 37808)
@@ -374,9 +374,6 @@
final String attText = attributeText.getText();
final String filePattern = filesetText.getText();
String directory = baseDirText.getText();
- if( !new Path(directory).isAbsolute()) {
- directory = server.getRuntime().getLocation().append(directory).toString();
- }
directory = directory.replace("${jboss_config_dir}", //$NON-NLS-1$
"${jboss_config_dir:" + server.getName() + "}"); //$NON-NLS-1$
//$NON-NLS-2$
directory = directory.replace("${jboss_config}", //$NON-NLS-1$
@@ -386,6 +383,9 @@
directory = engine.performStringSubstitution(directory, true,
true, StringVariableManager.getDefault());
} catch( CoreException ce ) {}
+ if( !new Path(directory).isAbsolute()) {
+ directory = server.getRuntime().getLocation().append(directory).toString();
+ }
final String directory2 = directory;
IRunnableWithProgress op = new IRunnableWithProgress() {
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/util/ServerModelUtilities.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/util/ServerModelUtilities.java 2012-01-13
01:23:53 UTC (rev 37807)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/util/ServerModelUtilities.java 2012-01-13
07:11:12 UTC (rev 37808)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Red Hat, Inc.
+ * Copyright (c) 2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
@@ -21,7 +21,25 @@
import org.jboss.ide.eclipse.as.wtp.core.modules.IJBTModule;
public class ServerModelUtilities {
+
+ public static IModule[] getParentModules(IServer server, IModule module) {
+ // get all supported modules
+ IModule[] supported =
+ org.eclipse.wst.server.core.ServerUtil.getModules(
+ server.getServerType().getRuntimeType().getModuleTypes());
+ ArrayList<IModule> list = new ArrayList<IModule>();
+
+ for( int i = 0; i < supported.length; i++ ) {
+ IModule[] childs = ServerModelUtilities.getChildModules(supported[i]);
+ for (int j = 0; j < childs.length; j++) {
+ if(childs[j].equals(module))
+ list.add(supported[i]);
+ }
+ }
+ return list.toArray(new IModule[list.size()]);
+ }
+
public static ArrayList<IModule[]> getShallowChildren(IServer server, IModule[]
root) {
ArrayList<IModule[]> list = new ArrayList<IModule[]>();
IModule[] children = server.getChildModules(root, new NullProgressMonitor());
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EGitUtils.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EGitUtils.java 2012-01-13
01:23:53 UTC (rev 37807)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.egit.core/src/org/jboss/tools/openshift/egit/core/EGitUtils.java 2012-01-13
07:11:12 UTC (rev 37808)
@@ -37,6 +37,7 @@
import org.eclipse.egit.core.op.FetchOperation;
import org.eclipse.egit.core.op.MergeOperation;
import org.eclipse.egit.core.op.PushOperation;
+import org.eclipse.egit.core.op.PushOperationResult;
import org.eclipse.egit.core.op.PushOperationSpecification;
import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.egit.ui.UIText;
@@ -54,6 +55,7 @@
import org.eclipse.jgit.lib.StoredConfig;
import org.eclipse.jgit.lib.UserConfig;
import org.eclipse.jgit.merge.MergeStrategy;
+import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.transport.FetchResult;
import org.eclipse.jgit.transport.RefSpec;
import org.eclipse.jgit.transport.RemoteConfig;
@@ -294,17 +296,17 @@
*
* @see #connect(IProject, Repository)
*/
- private static void commit(IProject project, String commitMessage, IProgressMonitor
monitor) throws CoreException {
+ private static RevCommit commit(IProject project, String commitMessage, IProgressMonitor
monitor) throws CoreException {
Repository repository = getRepository(project);
Assert.isLegal(repository != null, "Cannot commit project to repository. ");
- commit(project, commitMessage, repository, monitor);
+ return commit(project, commitMessage, repository, monitor);
}
- public static void commit(IProject project, IProgressMonitor monitor) throws
CoreException {
- commit(project, "Commit from JBoss Tools", monitor);
+ public static RevCommit commit(IProject project, IProgressMonitor monitor) throws
CoreException {
+ return commit(project, "Commit from JBoss Tools", monitor);
}
- private static void commit(IProject project, String commitMessage, Repository
repository, IProgressMonitor monitor)
+ private static RevCommit commit(IProject project, String commitMessage, Repository
repository, IProgressMonitor monitor)
throws CoreException {
Assert.isLegal(project != null, "Could not commit project. No project
provided");
Assert.isLegal(
@@ -326,6 +328,7 @@
op.setCommitAll(true);
op.setRepository(repository);
op.execute(monitor);
+ return op.getCommit();
}
/**
@@ -339,9 +342,9 @@
* @throws CoreException
* core exception is thrown if the push could not be executed
*/
- public static void push(Repository repository, IProgressMonitor monitor)
+ public static PushOperationResult push(Repository repository, IProgressMonitor monitor)
throws CoreException {
- push(repository, getRemoteConfig(repository), monitor);
+ return push(repository, getRemoteConfig(repository), false, monitor);
}
/**
@@ -356,32 +359,30 @@
* @see #getAllRemoteConfigs(Repository)
* @see RemoteConfig#getName()
*/
- public static void push(String remote, Repository repository, IProgressMonitor monitor)
+ public static PushOperationResult push(String remote, Repository repository,
IProgressMonitor monitor)
throws CoreException {
- try {
- RemoteConfig remoteConfig = getRemoteConfig(remote, repository);
- if (remoteConfig == null) {
- throw new CoreException(createStatus(null,
- "Repository \"{0}\" has no remote repository with the name
\"{1}\"",
- repository.toString(), remote));
- }
- createPushOperation(remoteConfig, repository).run(monitor);
- } catch (CoreException e) {
- throw e;
- } catch (Exception e) {
- throw new CoreException(createStatus(e, "Could not push repo {0}",
repository.toString()));
- }
+ RemoteConfig remoteConfig = getRemoteConfig(remote, repository);
+ return push(repository, remoteConfig, false, monitor);
}
- private static void push(Repository repository, RemoteConfig remoteConfig,
IProgressMonitor monitor)
+ public static PushOperationResult pushForce(String remote, Repository repository,
IProgressMonitor monitor)
throws CoreException {
+ RemoteConfig remoteConfig = getRemoteConfig(remote, repository);
+ return push(repository, remoteConfig, true, monitor);
+ }
+
+ private static PushOperationResult push(Repository repository, RemoteConfig
remoteConfig,
+ boolean force, IProgressMonitor monitor) throws CoreException {
try {
if (remoteConfig == null) {
throw new CoreException(createStatus(null, "Repository \"{0}\" has no
remote repository configured",
repository.toString()));
}
- createPushOperation(remoteConfig, repository).run(monitor);
+ PushOperation op = createPushOperation(remoteConfig, repository, force);
+ op.run(monitor);
+ PushOperationResult result = op.getOperationResult();
+ return result;
} catch (CoreException e) {
throw e;
} catch (Exception e) {
@@ -398,7 +399,12 @@
private static PushOperation createPushOperation(RemoteConfig remoteConfig, Repository
repository)
throws CoreException {
-
+ return createPushOperation(remoteConfig, repository, false);
+ }
+
+ private static PushOperation createPushOperation(RemoteConfig remoteConfig, Repository
repository, boolean force)
+ throws CoreException {
+
PushOperationSpecification spec = new PushOperationSpecification();
List<URIish> pushToUris = getPushURIs(remoteConfig);
List<RefSpec> pushRefSpecs = getPushRefSpecs(remoteConfig);
@@ -407,6 +413,8 @@
// return new PushOperation(repository, spec, false, PUSH_TIMEOUT);
// TODO: fix pushoperation to really use the spec (currently seems like
// it does not work so we push everything to the remote)
+
+ // TODO ensure the 'force' is respected
return new PushOperation(repository, remoteConfig.getName(), false, PUSH_TIMEOUT);
}
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF 2012-01-13
01:23:53 UTC (rev 37807)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF 2012-01-13
07:11:12 UTC (rev 37808)
@@ -35,7 +35,8 @@
org.eclipse.ui.navigator;bundle-version="3.5.100",
org.eclipse.ui.console;bundle-version="3.5.100",
org.eclipse.core.expressions;bundle-version="3.4.300",
- org.eclipse.wst.common.modulecore;bundle-version="1.2.101"
+ org.eclipse.wst.common.modulecore;bundle-version="1.2.101",
+ org.jboss.ide.eclipse.as.wtp.core;bundle-version="2.3.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: org.jboss.tools.common.databinding,
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml 2012-01-13
01:23:53 UTC (rev 37807)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml 2012-01-13
07:11:12 UTC (rev 37808)
@@ -63,7 +63,7 @@
point="org.eclipse.wst.server.core.serverTypes">
<serverType
behaviourClass="org.jboss.tools.openshift.express.internal.core.behaviour.ExpressBehaviour"
- class="org.jboss.ide.eclipse.as.core.server.internal.JBossServer"
+
class="org.jboss.tools.openshift.express.internal.core.behaviour.ExpressServer"
name="%openshift.express.name"
description="%openshift.express.description"
hasConfiguration="false"
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressBehaviour.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressBehaviour.java 2012-01-13
01:23:53 UTC (rev 37807)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressBehaviour.java 2012-01-13
07:11:12 UTC (rev 37808)
@@ -32,4 +32,10 @@
public IAdaptable getPublishAdaptableInfo() {
return publishAdaptableInfo;
}
+
+ @Override
+ public boolean canRestartModule(IModule[] module){
+ return false;
+ }
+
}
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressBehaviourDelegate.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressBehaviourDelegate.java 2012-01-13
01:23:53 UTC (rev 37807)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressBehaviourDelegate.java 2012-01-13
07:11:12 UTC (rev 37808)
@@ -13,12 +13,12 @@
import org.jboss.ide.eclipse.as.core.server.internal.AbstractBehaviourDelegate;
public class ExpressBehaviourDelegate extends AbstractBehaviourDelegate {
-
+ public static final String OPENSHIFT_ID = "openshift";
public ExpressBehaviourDelegate() {
}
@Override
public String getBehaviourTypeId() {
- return "openshift";
+ return OPENSHIFT_ID;
}
}
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressMessages.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressMessages.java 2012-01-13
01:23:53 UTC (rev 37807)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressMessages.java 2012-01-13
07:11:12 UTC (rev 37808)
@@ -13,5 +13,8 @@
public static String requestCommitAndPushMsg;
public static String requestPushTitle;
public static String requestPushMsg;
+ public static String cannotModifyModules;
+ public static String shareProjectTitle;
+ public static String shareProjectMessage;
}
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressPublishMethod.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressPublishMethod.java 2012-01-13
01:23:53 UTC (rev 37807)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressPublishMethod.java 2012-01-13
07:11:12 UTC (rev 37808)
@@ -19,6 +19,7 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.egit.core.op.PushOperationResult;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.osgi.util.NLS;
@@ -26,13 +27,16 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.internal.ui.wizards.ConfigureProjectWizard;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.internal.navigator.filters.CoreExpressionFilter;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.model.ServerBehaviourDelegate;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublishMethod;
+import org.jboss.ide.eclipse.as.core.server.IServerAlreadyStartedHandler;
import org.jboss.ide.eclipse.as.core.server.internal.DeployableServerBehavior;
import
org.jboss.ide.eclipse.as.core.server.xpl.PublishCopyUtil.IPublishCopyCallbackHandler;
import org.jboss.tools.openshift.egit.core.EGitUtils;
+import org.jboss.tools.openshift.express.internal.ui.console.ConsoleUtils;
public class ExpressPublishMethod implements IJBossServerPublishMethod {
@@ -95,29 +99,47 @@
}
int changed = EGitUtils.countCommitableChanges(p, behaviour.getServer(), new
NullProgressMonitor() );
- if( changed != 0 && requestCommitAndPushApproval(module, changed)) {
- monitor.beginTask("Publishing " + p.getName(), 200);
- EGitUtils.commit(p, new SubProgressMonitor(monitor, 100));
- EGitUtils.push(EGitUtils.getRepository(p), new SubProgressMonitor(monitor, 100));
- monitor.done();
- return IServer.PUBLISH_STATE_NONE;
- } else if( changed == 0 && requestPushApproval(module)) {
- monitor.beginTask("Publishing " + p.getName(), 100);
- String remoteName =
behaviour.getServer().getAttribute(ExpressServerUtils.ATTRIBUTE_REMOTE_NAME,
- ExpressServerUtils.ATTRIBUTE_REMOTE_NAME_DEFAULT);
- EGitUtils.push(remoteName, EGitUtils.getRepository(p), new SubProgressMonitor(monitor,
100));
- monitor.done();
- return IServer.PUBLISH_STATE_NONE;
+ String remoteName =
behaviour.getServer().getAttribute(ExpressServerUtils.ATTRIBUTE_REMOTE_NAME,
+ ExpressServerUtils.ATTRIBUTE_REMOTE_NAME_DEFAULT);
+ PushOperationResult result = null;
+ boolean committed = false;
+ try {
+ if( changed != 0 && requestCommitAndPushApproval(module, changed)) {
+ monitor.beginTask("Publishing " + p.getName(), 300);
+ EGitUtils.commit(p, new SubProgressMonitor(monitor, 100));
+ committed = true;
+ }
+
+ if( committed || (changed == 0 && requestPushApproval(module))) {
+ if( !committed )
+ monitor.beginTask("Publishing " + p.getName(), 200);
+ result = EGitUtils.push(remoteName, EGitUtils.getRepository(p), new
SubProgressMonitor(monitor, 100));
+ monitor.done();
+ }
+ } catch(CoreException ce) {
+ // Comes if either commit or push has failed
+ try {
+ result = EGitUtils.pushForce(remoteName, repository, new SubProgressMonitor(monitor,
100));
+ monitor.done();
+ } catch(CoreException ce2) {
+ // even the push force failed, and we don't have a valid result to check :(
+ // can only throw it i guess
+ throw ce2;
+ }
}
- return state;
+
+ if( result != null ) {
+ ConsoleUtils.appendGitPushToConsole(behaviour.getServer(), result);
+ }
+
+ return IServer.PUBLISH_STATE_NONE;
}
private void shareProjects(final IProject[] projects) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
- String msg = "There are " + projects.length + " projects that are not
connected to any git repository. " +
- "Would you like to share them now?";
- String title = "Share projects?";
+ String msg = ExpressMessages.bind(ExpressMessages.shareProjectMessage,
projects.length);
+ String title = ExpressMessages.shareProjectTitle;
boolean approved = requestApproval(msg, title);
if( approved ) {
ConfigureProjectWizard.shareProjects(
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServer.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServer.java
(rev 0)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServer.java 2012-01-13
07:11:12 UTC (rev 37808)
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat Inc..
+ * 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 Incorporated - initial API and implementation
+ *******************************************************************************/
+package org.jboss.tools.openshift.express.internal.core.behaviour;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.model.ServerDelegate;
+import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
+import org.jboss.ide.eclipse.as.wtp.core.util.ServerModelUtilities;
+import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
+
+public class ExpressServer extends ServerDelegate {
+ public void setDefaults(IProgressMonitor monitor) {
+ super.setDefaults(monitor);
+ setAttribute(IDeployableServer.SERVER_MODE, ExpressBehaviourDelegate.OPENSHIFT_ID);
+ }
+
+ public IStatus canModifyModules(IModule[] add, IModule[] remove) {
+ // safety
+ add = add == null ? new IModule[0] : add;
+ remove = remove == null ? new IModule[0] : remove;
+
+ // Can only add a module if the server has zero, and even then, can only add 1.
+ IModule[] mods = getServer().getModules();
+ boolean canModify = mods.length == 0 && add.length == 1;
+ canModify &= remove.length == 0;
+ return canModify ? Status.OK_STATUS : new Status(IStatus.ERROR,
+ OpenShiftUIActivator.PLUGIN_ID, ExpressMessages.cannotModifyModules);
+ }
+
+ public IModule[] getRootModules(IModule module) throws CoreException {
+ IStatus status = canModifyModules(new IModule[] { module }, null);
+ if (status != null && !status.isOK())
+ throw new CoreException(status);
+ IModule[] parents = ServerModelUtilities.getParentModules(getServer(), module);
+ if(parents.length>0)
+ return parents;
+ return new IModule[] { module };
+ }
+
+ public IModule[] getChildModules(IModule[] module) {
+ return ServerModelUtilities.getChildModules(module);
+ }
+
+ public void modifyModules(IModule[] add, IModule[] remove,
+ IProgressMonitor monitor) throws CoreException {
+ }
+
+}
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/expressMessages.properties
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/expressMessages.properties 2012-01-13
01:23:53 UTC (rev 37807)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/expressMessages.properties 2012-01-13
07:11:12 UTC (rev 37808)
@@ -2,3 +2,6 @@
requestCommitAndPushMsg=There are {0} local changes in "{1}". Do you want to
publish to OpenShift by commiting the changes and pushing its Git repository?
requestPushTitle=Publish {0}?
requestPushMsg=The are no local changes in "{0}". Do you want to publish to
OpenShift by pushing its Git repository?
+cannotModifyModules=Openshift Express servers cannot be modified.
+shareProjectTitle=Share projects?
+shareProjectMessage="There are {0} projects that are not connected to any git
repository. Would you like to share them now?
\ No newline at end of file
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/console/ConsoleUtils.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/console/ConsoleUtils.java 2012-01-13
01:23:53 UTC (rev 37807)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/console/ConsoleUtils.java 2012-01-13
07:11:12 UTC (rev 37808)
@@ -10,11 +10,17 @@
******************************************************************************/
package org.jboss.tools.openshift.express.internal.ui.console;
-import org.eclipse.ui.IWorkbenchPage;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.eclipse.egit.core.op.PushOperationResult;
+import org.eclipse.egit.ui.UIText;
+import org.eclipse.jgit.transport.RemoteRefUpdate;
+import org.eclipse.jgit.transport.URIish;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.console.ConsolePlugin;
import org.eclipse.ui.console.IConsole;
import org.eclipse.ui.console.IConsoleConstants;
@@ -22,6 +28,9 @@
import org.eclipse.ui.console.IConsoleManager;
import org.eclipse.ui.console.IConsoleView;
import org.eclipse.ui.console.MessageConsole;
+import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.as.ui.UIUtil;
+import org.jboss.tools.openshift.express.internal.core.behaviour.ExpressServerUtils;
import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
/**
@@ -89,28 +98,98 @@
* @param console the console to display
*/
public static void displayConsoleView(IConsole console) {
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window != null) {
- IWorkbenchPage page = window.getActivePage();
- if (page != null) {
- IWorkbenchPart part = page.findView(IConsoleConstants.ID_CONSOLE_VIEW);
- if (part == null) {
- try {
- part = page.showView(IConsoleConstants.ID_CONSOLE_VIEW);
- } catch (PartInitException e) {
- Logger.warn("Could not open console view", e);
- }
- }
- if (part != null) {
- page.activate(part);
- IConsoleView view = (IConsoleView) part.getAdapter(IConsoleView.class);
- if (view != null) {
- view.setFocus();
- view.display(console);
- }
- }
+ IWorkbenchPart part = null;
+ try {
+ part = UIUtil.bringViewToFront(IConsoleConstants.ID_CONSOLE_VIEW);
+ } catch (PartInitException e) {
+ Logger.warn("Could not open console view", e);
+ }
+
+ if (part != null) {
+ IConsoleView view = (IConsoleView) part.getAdapter(IConsoleView.class);
+ if (view != null) {
+ view.display(console);
}
}
}
+
+ public static void appendGitPushToConsole(IServer server, PushOperationResult result) {
+ appendToConsole(server, getPushResultAsString(result));
+ }
+
+ private static final String EMPTY_STRING = ""; //$NON-NLS-1
+ private static final String SPACE = " "; //$NON-NLS-1$
+ private static final String NL = "\n";//$NON-NLS-1$
+
+ private static String getPushResultAsString(PushOperationResult pushOperationResult) {
+ StringBuilder result = new StringBuilder(EMPTY_STRING);
+ result.append(getPushErrors(pushOperationResult));
+ result.append(NL);
+ Set<URIish> uris = pushOperationResult.getURIs();
+ Iterator<URIish> i = uris.iterator();
+ while(i.hasNext()) {
+ URIish uri = i.next();
+ for (RemoteRefUpdate update :
pushOperationResult.getPushResult(uri).getRemoteUpdates()) {
+ result.append(getOneResultAsString(pushOperationResult, uri, update));
+ }
+ }
+ return result.toString();
+ }
+
+ private static String getOneResultAsString(PushOperationResult pushOperationResult,
+ URIish uri, RemoteRefUpdate update) {
+ StringBuilder result = new StringBuilder(EMPTY_STRING);
+ result.append(UIText.PushResultTable_repository);
+ result.append(SPACE);
+ result.append(uri.toString());
+ result.append(Text.DELIMITER);
+ result.append(Text.DELIMITER);
+ String message = update.getMessage();
+ if (message != null)
+ result.append(message).append(Text.DELIMITER);
+ StringBuilder messagesBuffer = new StringBuilder(pushOperationResult
+ .getPushResult(uri).getMessages());
+ trim(messagesBuffer);
+ if (messagesBuffer.length() > 0)
+ result.append(messagesBuffer).append(Text.DELIMITER);
+ trim(result);
+ return result.toString();
+ }
+ private static void trim(StringBuilder s) {
+ // remove leading line breaks
+ while (s.length() > 0 && (s.charAt(0) == '\n' || s.charAt(0) ==
'\r'))
+ s.deleteCharAt(0);
+ // remove trailing line breaks
+ while (s.length() > 0
+ && (s.charAt(s.length() - 1) == '\n' || s
+ .charAt(s.length() - 1) == '\r'))
+ s.deleteCharAt(s.length() - 1);
+ }
+
+ private static String getPushErrors(PushOperationResult result) {
+ StringBuilder messages = new StringBuilder();
+ for (URIish uri : result.getURIs()) {
+ String errorMessage = result.getErrorMessage(uri);
+ if (errorMessage != null && errorMessage.length() > 0) {
+ if (messages.length() > 0)
+ messages.append(System.getProperty("line.separator")); //$NON-NLS-1$
+ messages.append(errorMessage);
+ }
+ }
+ return messages.toString();
+ }
+
+
+ public static void appendToConsole(IServer server, String message ) {
+ if (ExpressServerUtils.isOpenShiftRuntime(server)) {
+ final MessageConsole console = ConsoleUtils.findMessageConsole(server.getId());
+ console.newMessageStream().print(message);
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ ConsoleUtils.displayConsoleView(console);
+ }
+ });
+ }
+ }
}