Skip to content

Commit 1abee8e

Browse files
eharris369GitHub Enterprise
authored andcommitted
Merge pull request #216 from eharris/215-addOpenOverviewAction
Issue #215: Add open project overview action
2 parents 453cc80 + 439d35b commit 1abee8e

File tree

7 files changed

+104
-1
lines changed

7 files changed

+104
-1
lines changed

dev/com.ibm.microclimate.core/src/com/ibm/microclimate/core/internal/connection/MicroclimateConnection.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,10 @@ public URL getAppMonitorURL(MicroclimateApplication app) {
521521
return getAppViewURL(app, MCConstants.VIEW_MONITOR);
522522
}
523523

524+
public URL getAppOverviewURL(MicroclimateApplication app) {
525+
return getAppViewURL(app, MCConstants.VIEW_OVERVIEW);
526+
}
527+
524528
public URL getAppViewURL(MicroclimateApplication app, String view) {
525529
try {
526530
URI uri = baseUrl;

dev/com.ibm.microclimate.ui/plugin.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ ACTION_RESTART_DEBUG_MODE=Restart in &Debug Mode
2727
ACTION_ENABLE_DISABLE_AUTO_BUILD=Disable &Auto Build
2828
ACTION_OPEN_MICROCLIMATE_UI=Open Microclimate &UI
2929
ACTION_OPEN_APP_MONITOR=Open Application &Monitor
30+
ACTION_OPEN_APP_OVERVIEW=Open Project O&verview
3031

3132
PREFS_PARENT_PAGE_NAME=Microclimate
3233
PREFS_CONNECTION_PAGE_NAME=Microclimate Connections

dev/com.ibm.microclimate.ui/plugin.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@
120120
menubarPath="group.open"
121121
label="%ACTION_CONTAINER_SHELL"
122122
class="com.ibm.microclimate.ui.internal.actions.ContainerShellAction"/>
123+
<action
124+
id="com.ibm.microclimate.ui.openAppOverview"
125+
enablesFor="1"
126+
menubarPath="group.open"
127+
label="%ACTION_OPEN_APP_OVERVIEW"
128+
class="com.ibm.microclimate.ui.internal.actions.OpenAppOverviewAction"/>
123129
<action
124130
id="com.ibm.microclimate.ui.openAppMonitor"
125131
enablesFor="1"

dev/com.ibm.microclimate.ui/src/com/ibm/microclimate/ui/internal/actions/OpenAppMonitorAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import com.ibm.microclimate.ui.internal.messages.Messages;
3131

3232
/**
33-
* Action to open the application in a browser.
33+
* Action to open the application monitor in a browser.
3434
*/
3535
public class OpenAppMonitorAction implements IObjectActionDelegate {
3636

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*******************************************************************************
2+
* IBM Confidential
3+
* OCO Source Materials
4+
* (C) Copyright IBM Corp. 2018 All Rights Reserved.
5+
* The source code for this program is not published or otherwise
6+
* divested of its trade secrets, irrespective of what has
7+
* been deposited with the U.S. Copyright Office.
8+
*******************************************************************************/
9+
10+
package com.ibm.microclimate.ui.internal.actions;
11+
12+
import java.net.URL;
13+
14+
import org.eclipse.jface.action.IAction;
15+
import org.eclipse.jface.viewers.ISelection;
16+
import org.eclipse.jface.viewers.IStructuredSelection;
17+
import org.eclipse.osgi.util.NLS;
18+
import org.eclipse.ui.IObjectActionDelegate;
19+
import org.eclipse.ui.IWorkbenchPart;
20+
import org.eclipse.ui.PartInitException;
21+
import org.eclipse.ui.PlatformUI;
22+
import org.eclipse.ui.browser.IWebBrowser;
23+
import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
24+
25+
import com.ibm.microclimate.core.internal.MCLogger;
26+
import com.ibm.microclimate.core.internal.MicroclimateApplication;
27+
import com.ibm.microclimate.core.internal.constants.MCConstants;
28+
import com.ibm.microclimate.ui.internal.messages.Messages;
29+
30+
/**
31+
* Action to open the application overview in a browser.
32+
*/
33+
public class OpenAppOverviewAction implements IObjectActionDelegate {
34+
35+
protected MicroclimateApplication app;
36+
37+
@Override
38+
public void selectionChanged(IAction action, ISelection selection) {
39+
if (!(selection instanceof IStructuredSelection)) {
40+
action.setEnabled(false);
41+
return;
42+
}
43+
44+
IStructuredSelection sel = (IStructuredSelection) selection;
45+
if (sel.size() == 1) {
46+
Object obj = sel.getFirstElement();
47+
if (obj instanceof MicroclimateApplication) {
48+
app = (MicroclimateApplication) obj;
49+
action.setEnabled(true);
50+
return;
51+
}
52+
}
53+
action.setEnabled(false);
54+
}
55+
56+
@Override
57+
public void run(IAction action) {
58+
if (app == null) {
59+
// should not be possible
60+
MCLogger.logError("OpenAppOverviewAction ran but no Microclimate application was selected");
61+
return;
62+
}
63+
64+
URL url = app.mcConnection.getAppOverviewURL(app);
65+
if (url == null) {
66+
// this should not happen
67+
MCLogger.logError("OpenAppOverviewAction ran but the url was null");
68+
return;
69+
}
70+
71+
// Use the app's ID as the browser ID so that if this is called again on the same app,
72+
// the browser will be re-used
73+
74+
try {
75+
IWorkbenchBrowserSupport browserSupport = PlatformUI.getWorkbench().getBrowserSupport();
76+
IWebBrowser browser = browserSupport
77+
.createBrowser(IWorkbenchBrowserSupport.NAVIGATION_BAR | IWorkbenchBrowserSupport.LOCATION_BAR,
78+
app.projectID + "_" + MCConstants.VIEW_OVERVIEW, app.name, NLS.bind(Messages.BrowserTooltipAppOverview, app.name));
79+
80+
browser.openURL(url);
81+
} catch (PartInitException e) {
82+
MCLogger.logError("Error opening the app overview in browser", e); //$NON-NLS-1$
83+
}
84+
}
85+
86+
@Override
87+
public void setActivePart(IAction arg0, IWorkbenchPart arg1) {
88+
// nothing
89+
}
90+
}

dev/com.ibm.microclimate.ui/src/com/ibm/microclimate/ui/internal/messages/Messages.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public class Messages extends NLS {
8282

8383
public static String BrowserTooltipApp;
8484
public static String BrowserTooltipAppMonitor;
85+
public static String BrowserTooltipAppOverview;
8586

8687
static {
8788
// initialize resource bundle

dev/com.ibm.microclimate.ui/src/com/ibm/microclimate/ui/internal/messages/messages.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,4 @@ ProjectOpenError=An error occurred while trying to open the {0} project
7575

7676
BrowserTooltipApp=Microclimate Project: {0}
7777
BrowserTooltipAppMonitor=Application Monitor: {0}
78+
BrowserTooltipAppOverview=Project Overview: {0}

0 commit comments

Comments
 (0)