Skip to content

Commit e211075

Browse files
authored
Enable groups in right click menu of Azure explorer (#4833)
1 parent 6ac8b97 commit e211075

File tree

5 files changed

+108
-40
lines changed

5 files changed

+108
-40
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/intellij/serviceexplorer/azure/springcloud/SpringCloudStreamingLogsAction.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import com.microsoft.intellij.util.PluginUtil;
3636
import com.microsoft.tooling.msservices.components.DefaultLoader;
3737
import com.microsoft.tooling.msservices.helpers.Name;
38+
import com.microsoft.tooling.msservices.serviceexplorer.Groupable;
3839
import com.microsoft.tooling.msservices.serviceexplorer.NodeActionEvent;
3940
import com.microsoft.tooling.msservices.serviceexplorer.NodeActionListener;
4041
import com.microsoft.tooling.msservices.serviceexplorer.azure.springcloud.SpringCloudAppNode;
@@ -103,4 +104,9 @@ private void showLogStreamingDialog(List<DeploymentInstance> instances) {
103104
}
104105
});
105106
}
107+
108+
@Override
109+
public int getGroup() {
110+
return Groupable.DIAGNOSTIC_GROUP;
111+
}
106112
}

Utils/azure-explorer-common/src/com/microsoft/tooling/msservices/serviceexplorer/azure/arm/ResourceManagementNode.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@
2929
import com.microsoft.azuretools.telemetry.TelemetryConstants;
3030
import com.microsoft.azuretools.telemetrywrapper.EventUtil;
3131
import com.microsoft.tooling.msservices.components.DefaultLoader;
32+
import com.microsoft.tooling.msservices.serviceexplorer.Groupable;
3233
import com.microsoft.tooling.msservices.serviceexplorer.Node;
3334
import com.microsoft.tooling.msservices.serviceexplorer.NodeActionEvent;
3435
import com.microsoft.tooling.msservices.serviceexplorer.RefreshableNode;
36+
import com.microsoft.tooling.msservices.serviceexplorer.Sortable;
3537
import com.microsoft.tooling.msservices.serviceexplorer.azure.AzureNodeActionPromptListener;
3638
import com.microsoft.tooling.msservices.serviceexplorer.azure.arm.deployments.DeploymentNode;
3739

@@ -41,8 +43,7 @@ public class ResourceManagementNode extends RefreshableNode implements ResourceM
4143

4244
private static final String ICON_RESOURCE_MANAGEMENT = "arm_resourcegroup.png";
4345
private static final String ACTION_DELETE = "Delete";
44-
private static final String DELETE_RESOURCE_GROUP_PROMPT_MESSAGE = "This operation will delete the Resource "
45-
+ "Group: %s. Are you sure you want to continue?";
46+
private static final String DELETE_RESOURCE_GROUP_PROMPT_MESSAGE = "This operation will delete the Resource Group: %s. Are you sure you want to continue?";
4647
private static final String DELETE_RESOURCE_GROUP_PROGRESS_MESSAGE = "Deleting Resource Group";
4748
private final ResourceManagementNodePresenter rmNodePresenter;
4849
private final String sid;
@@ -84,10 +85,10 @@ public void removeNode(String sid, String id, Node node) {
8485
rmNodePresenter.onDeleteDeployment(sid, id);
8586
removeDirectChildNode(node);
8687
}), (e) -> {
87-
DefaultLoader.getUIHelper()
88-
.showException("An error occurred while attempting to delete the resource group ",
89-
e, "Azure Services Explorer - Error Deleting Resource Group", false, true);
90-
});
88+
DefaultLoader.getUIHelper()
89+
.showException("An error occurred while attempting to delete the resource group ",
90+
e, "Azure Services Explorer - Error Deleting Resource Group", false, true);
91+
});
9192
}
9293

9394
public String getSid() {
@@ -112,6 +113,16 @@ protected void azureNodeAction(NodeActionEvent e) {
112113
@Override
113114
protected void onSubscriptionsChanged(NodeActionEvent e) {
114115
}
116+
117+
@Override
118+
public int getPriority() {
119+
return Sortable.LOW_PRIORITY;
120+
}
121+
122+
@Override
123+
public int getGroup() {
124+
return Groupable.MAINTENANCE_GROUP;
125+
}
115126
}
116127

117128
}

Utils/azure-explorer-common/src/com/microsoft/tooling/msservices/serviceexplorer/azure/rediscache/RedisCacheNode.java

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,29 @@
2222

2323
package com.microsoft.tooling.msservices.serviceexplorer.azure.rediscache;
2424

25-
import static com.microsoft.azuretools.telemetry.TelemetryConstants.DELETE_REDIS;
26-
import static com.microsoft.azuretools.telemetry.TelemetryConstants.REDIS;
27-
import static com.microsoft.azuretools.telemetry.TelemetryConstants.REDIS_OPEN_BROWSER;
28-
import static com.microsoft.azuretools.telemetry.TelemetryConstants.REDIS_OPEN_EXPLORER;
29-
import static com.microsoft.azuretools.telemetry.TelemetryConstants.REDIS_READPROP;
30-
31-
import com.microsoft.tooling.msservices.serviceexplorer.WrappedTelemetryNodeActionListener;
32-
import java.util.HashMap;
33-
import java.util.Map;
34-
3525
import com.microsoft.azuretools.authmanage.AuthMethodManager;
3626
import com.microsoft.azuretools.azurecommons.helpers.AzureCmdException;
3727
import com.microsoft.azuretools.core.mvp.ui.base.NodeContent;
3828
import com.microsoft.azuretools.telemetry.AppInsightsConstants;
3929
import com.microsoft.azuretools.telemetry.TelemetryProperties;
4030
import com.microsoft.tooling.msservices.components.DefaultLoader;
31+
import com.microsoft.tooling.msservices.serviceexplorer.Groupable;
4132
import com.microsoft.tooling.msservices.serviceexplorer.Node;
4233
import com.microsoft.tooling.msservices.serviceexplorer.NodeActionEvent;
4334
import com.microsoft.tooling.msservices.serviceexplorer.NodeActionListener;
35+
import com.microsoft.tooling.msservices.serviceexplorer.Sortable;
36+
import com.microsoft.tooling.msservices.serviceexplorer.WrappedTelemetryNodeActionListener;
4437
import com.microsoft.tooling.msservices.serviceexplorer.azure.AzureNodeActionPromptListener;
4538

39+
import java.util.HashMap;
40+
import java.util.Map;
41+
42+
import static com.microsoft.azuretools.telemetry.TelemetryConstants.DELETE_REDIS;
43+
import static com.microsoft.azuretools.telemetry.TelemetryConstants.REDIS;
44+
import static com.microsoft.azuretools.telemetry.TelemetryConstants.REDIS_OPEN_BROWSER;
45+
import static com.microsoft.azuretools.telemetry.TelemetryConstants.REDIS_OPEN_EXPLORER;
46+
import static com.microsoft.azuretools.telemetry.TelemetryConstants.REDIS_READPROP;
47+
4648
public class RedisCacheNode extends Node implements TelemetryProperties {
4749

4850
public static final String TYPE = "Microsoft.Cache/Redis";
@@ -64,8 +66,8 @@ public class RedisCacheNode extends Node implements TelemetryProperties {
6466
private static final String OPEN_EXPLORER = "Open Redis Explorer";
6567

6668
// string format
67-
private static final String DELETE_CONFIRM_DIALOG_FORMAT = "This operation will delete redis cache: %s."
68-
+ "\nAre you sure you want to continue?";
69+
private static final String DELETE_CONFIRM_DIALOG_FORMAT = "This operation will delete redis cache: %s." +
70+
"\nAre you sure you want to continue?";
6971
private static final String DELETE_CONFIRM_TITLE = "Deleting Redis Cache";
7072
private static final String AZURE_PORTAL_LINK_FORMAT = "%s/#resource/%s/overview";
7173

@@ -80,8 +82,8 @@ public class RedisCacheNode extends Node implements TelemetryProperties {
8082
* The basic information object for the node
8183
*/
8284
public RedisCacheNode(Node parent, String subscriptionId, NodeContent content) {
83-
super(subscriptionId + content.getName(), content.getProvisionState().equals(CREATING_STATE)
84-
? String.format(CREATING_REDIS_NAME_FORMAT, content.getName(), CREATING_STATE)
85+
super(subscriptionId + content.getName(), content.getProvisionState().equals(CREATING_STATE) ?
86+
String.format(CREATING_REDIS_NAME_FORMAT, content.getName(), CREATING_STATE)
8587
: content.getName(), parent, REDISCACHE_ICON_PATH, true);
8688
this.name = content.getName();
8789
this.resourceId = content.getId();
@@ -125,6 +127,16 @@ protected String getServiceName(NodeActionEvent event) {
125127
protected String getOperationName(NodeActionEvent event) {
126128
return DELETE_REDIS;
127129
}
130+
131+
@Override
132+
public int getPriority() {
133+
return Sortable.LOW_PRIORITY;
134+
}
135+
136+
@Override
137+
public int getGroup() {
138+
return Groupable.MAINTENANCE_GROUP;
139+
}
128140
}
129141

130142
// Open in browser action class

Utils/azure-explorer-common/src/com/microsoft/tooling/msservices/serviceexplorer/azure/springcloud/SpringCloudAppNode.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,7 @@
4141

4242
public class SpringCloudAppNode extends Node implements SpringCloudAppNodeView {
4343
private static final Logger LOGGER = Logger.getLogger(SpringCloudAppNodeView.class.getName());
44-
private static final String DELETE_APP_PROMPT_MESSAGE = "This operation will delete the Spring Cloud App: %s.\n"
45-
+ "Are you sure you want to continue?";
46-
private static final String FAILED_TO_DELETE_APP = "Failed to delete Spring Cloud App: %s";
47-
private static final String ERROR_DELETING_APP = "Azure Services Explorer - Error Deleting Spring Cloud App";
48-
private static final String FAILED_TO_START_APP = "Failed to start Spring Cloud App: %s";
49-
private static final String FAILED_TO_RESTART_APP = "Failed to restart Spring Cloud App: %s";
50-
private static final String FAILED_TO_STOP_APP = "Failed to stop Spring Cloud App: %s";
44+
private static final String DELETE_APP_PROMPT_MESSAGE = "This operation will delete the Spring Cloud App: %s. Are you sure you want to continue?";
5145
private static final String DELETE_APP_PROGRESS_MESSAGE = "Deleting Spring Cloud App";
5246

5347
private static final String ACTION_START = "Start";
@@ -121,12 +115,12 @@ public String getSubscriptionId() {
121115
@Override
122116
protected void loadActions() {
123117
addAction(ACTION_START, new WrappedTelemetryNodeActionListener(SPRING_CLOUD, START_SPRING_CLOUD_APP,
124-
createBackgroundActionListener("Starting", () -> startSpringCloudApp())));
118+
createBackgroundActionListener("Starting", () -> startSpringCloudApp()), Groupable.MAINTENANCE_GROUP, Sortable.HIGH_PRIORITY));
125119
addAction(ACTION_STOP, new WrappedTelemetryNodeActionListener(SPRING_CLOUD, STOP_SPRING_CLOUD_APP,
126-
createBackgroundActionListener("Stopping", () -> stopSpringCloudApp())));
120+
createBackgroundActionListener("Stopping", () -> stopSpringCloudApp()), Groupable.MAINTENANCE_GROUP, Sortable.HIGH_PRIORITY));
127121

128122
addAction(ACTION_RESTART, new WrappedTelemetryNodeActionListener(SPRING_CLOUD, RESTART_SPRING_CLOUD_APP,
129-
createBackgroundActionListener("Restarting", () -> restartSpringCloudApp())));
123+
createBackgroundActionListener("Restarting", () -> restartSpringCloudApp()), Groupable.MAINTENANCE_GROUP));
130124

131125
addAction(ACTION_DELETE, new DeleteSpringCloudAppAction());
132126

@@ -142,9 +136,7 @@ protected void actionPerformed(NodeActionEvent e) {
142136
if (StringUtils.isNotEmpty(app.properties().url())) {
143137
DefaultLoader.getUIHelper().openInBrowser(app.properties().url());
144138
} else {
145-
DefaultLoader.getUIHelper().showInfo(SpringCloudAppNode.this,
146-
"Public url is not available for app: "
147-
+ app.name());
139+
DefaultLoader.getUIHelper().showInfo(SpringCloudAppNode.this, "Public url is not available for app: " + app.name());
148140
}
149141
}
150142
}));
@@ -226,7 +218,7 @@ private void fillData(AppResourceInner newApp, DeploymentResourceInner deploy) {
226218
private class DeleteSpringCloudAppAction extends AzureNodeActionPromptListener {
227219
DeleteSpringCloudAppAction() {
228220
super(SpringCloudAppNode.this, String.format(DELETE_APP_PROMPT_MESSAGE, SpringCloudIdHelper.getAppName(SpringCloudAppNode.this.id)),
229-
DELETE_APP_PROGRESS_MESSAGE);
221+
DELETE_APP_PROGRESS_MESSAGE);
230222
}
231223

232224
@Override
@@ -247,5 +239,15 @@ protected String getServiceName(NodeActionEvent event) {
247239
protected String getOperationName(NodeActionEvent event) {
248240
return DELETE_SPRING_CLOUD_APP;
249241
}
242+
243+
@Override
244+
public int getPriority() {
245+
return Sortable.LOW_PRIORITY;
246+
}
247+
248+
@Override
249+
public int getGroup() {
250+
return Groupable.MAINTENANCE_GROUP;
251+
}
250252
}
251253
}

Utils/azure-explorer-common/src/com/microsoft/tooling/msservices/serviceexplorer/azure/vmarm/VMNode.java

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@
2222

2323
package com.microsoft.tooling.msservices.serviceexplorer.azure.vmarm;
2424

25-
import static com.microsoft.azuretools.telemetry.TelemetryConstants.DELETE_VM;
26-
import static com.microsoft.azuretools.telemetry.TelemetryConstants.RESTART_VM;
27-
import static com.microsoft.azuretools.telemetry.TelemetryConstants.SHUTDOWN_VM;
28-
import static com.microsoft.azuretools.telemetry.TelemetryConstants.START_VM;
29-
import static com.microsoft.azuretools.telemetry.TelemetryConstants.VM;
30-
3125
import com.microsoft.azure.CloudException;
3226
import com.microsoft.azure.management.compute.InstanceViewStatus;
3327
import com.microsoft.azure.management.compute.VirtualMachine;
@@ -38,16 +32,24 @@
3832
import com.microsoft.azuretools.telemetry.AppInsightsConstants;
3933
import com.microsoft.azuretools.telemetry.TelemetryProperties;
4034
import com.microsoft.tooling.msservices.components.DefaultLoader;
35+
import com.microsoft.tooling.msservices.serviceexplorer.Groupable;
4136
import com.microsoft.tooling.msservices.serviceexplorer.Node;
4237
import com.microsoft.tooling.msservices.serviceexplorer.NodeAction;
4338
import com.microsoft.tooling.msservices.serviceexplorer.NodeActionEvent;
4439
import com.microsoft.tooling.msservices.serviceexplorer.RefreshableNode;
40+
import com.microsoft.tooling.msservices.serviceexplorer.Sortable;
4541
import com.microsoft.tooling.msservices.serviceexplorer.azure.AzureNodeActionPromptListener;
4642

4743
import java.util.HashMap;
4844
import java.util.List;
4945
import java.util.Map;
5046

47+
import static com.microsoft.azuretools.telemetry.TelemetryConstants.DELETE_VM;
48+
import static com.microsoft.azuretools.telemetry.TelemetryConstants.RESTART_VM;
49+
import static com.microsoft.azuretools.telemetry.TelemetryConstants.SHUTDOWN_VM;
50+
import static com.microsoft.azuretools.telemetry.TelemetryConstants.START_VM;
51+
import static com.microsoft.azuretools.telemetry.TelemetryConstants.VM;
52+
5153
public class VMNode extends RefreshableNode implements TelemetryProperties {
5254
private static String RUNNING_STATUS = "PowerState/running";
5355
private static String STOPPED = "stopped";
@@ -101,6 +103,16 @@ protected String getServiceName(NodeActionEvent event) {
101103
protected String getOperationName(NodeActionEvent event) {
102104
return DELETE_VM;
103105
}
106+
107+
@Override
108+
public int getPriority() {
109+
return Sortable.LOW_PRIORITY;
110+
}
111+
112+
@Override
113+
public int getGroup() {
114+
return Groupable.MAINTENANCE_GROUP;
115+
}
104116
}
105117

106118
public class RestartVMAction extends AzureNodeActionPromptListener {
@@ -130,6 +142,11 @@ protected String getServiceName(NodeActionEvent event) {
130142
protected String getOperationName(NodeActionEvent event) {
131143
return RESTART_VM;
132144
}
145+
146+
@Override
147+
public int getGroup() {
148+
return Groupable.MAINTENANCE_GROUP;
149+
}
133150
}
134151

135152
public class StartVMAction extends AzureNodeActionPromptListener {
@@ -159,6 +176,16 @@ protected String getServiceName(NodeActionEvent event) {
159176
protected String getOperationName(NodeActionEvent event) {
160177
return START_VM;
161178
}
179+
180+
@Override
181+
public int getPriority() {
182+
return Sortable.HIGH_PRIORITY;
183+
}
184+
185+
@Override
186+
public int getGroup() {
187+
return Groupable.MAINTENANCE_GROUP;
188+
}
162189
}
163190

164191
public class ShutdownVMAction extends AzureNodeActionPromptListener {
@@ -189,6 +216,16 @@ protected String getServiceName(NodeActionEvent event) {
189216
protected String getOperationName(NodeActionEvent event) {
190217
return SHUTDOWN_VM;
191218
}
219+
220+
@Override
221+
public int getPriority() {
222+
return Sortable.HIGH_PRIORITY;
223+
}
224+
225+
@Override
226+
public int getGroup() {
227+
return Groupable.MAINTENANCE_GROUP;
228+
}
192229
}
193230

194231
private static final String WAIT_ICON_PATH = "VirtualMachineUpdating_16.png";

0 commit comments

Comments
 (0)