-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JBIDE-18827] added start/stop to application/server context menu
- Loading branch information
Showing
13 changed files
with
449 additions
and
68 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+216 Bytes
plugins/org.jboss.tools.openshift.express.ui/icons/terminatedlaunch_obj.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...src/org/jboss/tools/openshift/express/internal/ui/command/AbstractApplicationHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2014 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, | ||
* and is available at http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
******************************************************************************/ | ||
package org.jboss.tools.openshift.express.internal.ui.command; | ||
|
||
import org.eclipse.core.commands.AbstractHandler; | ||
import org.eclipse.core.commands.ExecutionEvent; | ||
import org.eclipse.core.commands.ExecutionException; | ||
import org.eclipse.core.runtime.IStatus; | ||
import org.eclipse.osgi.util.NLS; | ||
import org.eclipse.swt.widgets.Shell; | ||
import org.eclipse.ui.handlers.HandlerUtil; | ||
import org.eclipse.wst.server.core.IServer; | ||
import org.jboss.tools.openshift.express.internal.core.server.OpenShiftServerUtils; | ||
import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator; | ||
import org.jboss.tools.openshift.express.internal.ui.job.LoadApplicationJob; | ||
import org.jboss.tools.openshift.express.internal.ui.utils.UIUtils; | ||
|
||
import com.openshift.client.IApplication; | ||
import com.openshift.internal.client.utils.StringUtils; | ||
|
||
/** | ||
* @author Andre Dietisheim | ||
*/ | ||
public abstract class AbstractApplicationHandler extends AbstractHandler { | ||
|
||
public Object execute(final ExecutionEvent event) throws ExecutionException { | ||
IApplication application = UIUtils.getFirstElement(HandlerUtil.getCurrentSelection(event), IApplication.class); | ||
Shell shell = HandlerUtil.getActiveShell(event); | ||
if (application != null) { | ||
return execute(application, shell); | ||
} else { | ||
IServer server = UIUtils.getFirstElement(HandlerUtil.getCurrentSelection(event), IServer.class); | ||
if (server == null) { | ||
return OpenShiftUIActivator.createCancelStatus(NLS.bind("Could not {0}: server adapter not found.", getOperationName())); | ||
} | ||
return execute(server, shell); | ||
} | ||
} | ||
|
||
protected IStatus execute(IServer server, Shell shell) { | ||
String applicationName = OpenShiftServerUtils.getApplicationName(server); | ||
if (StringUtils.isEmpty(applicationName)) { | ||
return OpenShiftUIActivator.createCancelStatus(NLS.bind( | ||
"Could not {0} application: application for server adapter {1} not found.", | ||
getOperationName(), | ||
server.getName())); | ||
} | ||
return execute(new LoadApplicationJob(server), shell); | ||
} | ||
|
||
protected abstract IStatus execute(IApplication application, Shell shell); | ||
|
||
protected abstract IStatus execute(LoadApplicationJob loadApplicationJob, Shell shell); | ||
|
||
protected abstract String getOperationName(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...ui/src/org/jboss/tools/openshift/express/internal/ui/command/StartApplicationHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2014 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, | ||
* and is available at http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
******************************************************************************/ | ||
package org.jboss.tools.openshift.express.internal.ui.command; | ||
|
||
import org.eclipse.core.runtime.IStatus; | ||
import org.eclipse.core.runtime.Status; | ||
import org.eclipse.swt.widgets.Shell; | ||
import org.jboss.tools.openshift.express.internal.core.util.JobChainBuilder; | ||
import org.jboss.tools.openshift.express.internal.ui.job.LoadApplicationJob; | ||
import org.jboss.tools.openshift.express.internal.ui.job.StartApplicationJob; | ||
|
||
import com.openshift.client.IApplication; | ||
|
||
/** | ||
* @author Andre Dietisheim | ||
*/ | ||
public class StartApplicationHandler extends AbstractApplicationHandler { | ||
|
||
@Override | ||
protected IStatus execute(IApplication application, Shell shell) { | ||
new StartApplicationJob(application).schedule(); | ||
return Status.OK_STATUS; | ||
} | ||
|
||
@Override | ||
protected IStatus execute(LoadApplicationJob job, Shell shell) { | ||
new JobChainBuilder(job) | ||
.runWhenSuccessfullyDone(new StartApplicationJob(job)).schedule(); | ||
return Status.OK_STATUS; | ||
} | ||
|
||
@Override | ||
protected String getOperationName() { | ||
return "start application"; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
....ui/src/org/jboss/tools/openshift/express/internal/ui/command/StopApplicationHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2014 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, | ||
* and is available at http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
******************************************************************************/ | ||
package org.jboss.tools.openshift.express.internal.ui.command; | ||
|
||
import org.eclipse.core.runtime.IStatus; | ||
import org.eclipse.core.runtime.Status; | ||
import org.eclipse.swt.widgets.Shell; | ||
import org.jboss.tools.openshift.express.internal.core.util.JobChainBuilder; | ||
import org.jboss.tools.openshift.express.internal.ui.job.LoadApplicationJob; | ||
import org.jboss.tools.openshift.express.internal.ui.job.StopApplicationJob; | ||
|
||
import com.openshift.client.IApplication; | ||
|
||
/** | ||
* @author Andre Dietisheim | ||
*/ | ||
public class StopApplicationHandler extends AbstractApplicationHandler { | ||
|
||
@Override | ||
protected IStatus execute(IApplication application, Shell shell) { | ||
new StopApplicationJob(application).schedule(); | ||
return Status.OK_STATUS; | ||
} | ||
|
||
@Override | ||
protected IStatus execute(LoadApplicationJob job, Shell shell) { | ||
new JobChainBuilder(job) | ||
.runWhenSuccessfullyDone(new StopApplicationJob(job)).schedule(); | ||
return Status.OK_STATUS; | ||
} | ||
|
||
@Override | ||
protected String getOperationName() { | ||
return "stop application"; | ||
} | ||
} |
Oops, something went wrong.