use of com.microsoft.tooling.msservices.serviceexplorer.NodeActionEvent in project azure-tools-for-java by Microsoft.
the class QueueFileEditor method createVirtualNode.
private FileEditorVirtualNode<EditorPart> createVirtualNode(final String name) {
final FileEditorVirtualNode<EditorPart> node = new FileEditorVirtualNode<EditorPart>(this, name);
node.addAction(REFRESH, new NodeActionListener() {
@Override
protected void actionPerformed(NodeActionEvent e) throws AzureCmdException {
fillGrid();
}
});
node.addAction(DEQUEUE, new NodeActionListener() {
@Override
protected void actionPerformed(NodeActionEvent e) throws AzureCmdException {
dequeueFirstMessage();
}
});
node.addAction(ADD, new NodeActionListener() {
@Override
protected void actionPerformed(NodeActionEvent e) throws AzureCmdException {
QueueMessageForm queueMessageForm = new QueueMessageForm(PluginUtil.getParentShell(), storageAccount, queue);
queueMessageForm.setOnAddedMessage(new Runnable() {
@Override
public void run() {
fillGrid();
}
});
queueMessageForm.open();
}
});
node.addAction(CLEAR_QUEUE, new NodeActionListener() {
@Override
protected void actionPerformed(NodeActionEvent e) throws AzureCmdException {
boolean optionDialog = DefaultLoader.getUIHelper().showConfirmation("Are you sure you want to clear the queue \"" + queue.getName() + "\"?", "Service explorer", new String[] { "Yes", "No" }, null);
if (optionDialog) {
DefaultLoader.getIdeHelper().runInBackground(null, "Clearing queue messages", false, true, "Clearing queue messages", new Runnable() {
public void run() {
/*try {
StorageClientSDKManager.getManager().clearQueue(storageAccount, queue);
DefaultLoader.getIdeHelper().invokeLater(new Runnable() {
@Override
public void run() {
fillGrid();
}
});
} catch (AzureCmdException e) {
DefaultLoader.getUIHelper().showException("Error clearing queue messages", e, "Service Explorer", false, true);
}*/
}
});
}
}
});
node.addAction(OPEN, new NodeActionListener() {
@Override
protected void actionPerformed(NodeActionEvent e) throws AzureCmdException {
viewMessageText();
}
});
return node;
}
use of com.microsoft.tooling.msservices.serviceexplorer.NodeActionEvent in project azure-tools-for-java by Microsoft.
the class HDInsightHelperImpl method createAddNewHDInsightReaderClusterAction.
@NotNull
@Override
public NodeActionListener createAddNewHDInsightReaderClusterAction(@NotNull final HDInsightRootModule module, @NotNull final ClusterDetail clusterDetail) {
return new NodeActionListener() {
@Override
protected void actionPerformed(final NodeActionEvent nodeActionEvent) {
final AddNewHDInsightReaderClusterForm linkClusterForm = new AddNewHDInsightReaderClusterForm((Project) module.getProject(), module, clusterDetail);
linkClusterForm.show();
}
};
}
use of com.microsoft.tooling.msservices.serviceexplorer.NodeActionEvent in project azure-tools-for-java by Microsoft.
the class ClusterNode method loadActions.
@Override
protected void loadActions() {
super.loadActions();
addAction("Open Spark History UI", new NodeActionListener() {
@Override
protected void actionPerformed(NodeActionEvent e) {
String sparkHistoryUrl = clusterDetail.isEmulator() ? ((EmulatorClusterDetail) clusterDetail).getSparkHistoryEndpoint() : String.format("https://%s.azurehdinsight.net/sparkhistory", clusterDetail.getName());
openUrlLink(sparkHistoryUrl);
}
});
addAction("Open Cluster Management Portal(Ambari)", new NodeActionListener() {
@Override
protected void actionPerformed(NodeActionEvent e) {
String ambariUrl = clusterDetail.isEmulator() ? ((EmulatorClusterDetail) clusterDetail).getAmbariEndpoint() : String.format(CommonConstant.DEFAULT_CLUSTER_ENDPOINT, clusterDetail.getName());
openUrlLink(ambariUrl);
}
});
if (clusterDetail instanceof ClusterDetail) {
addAction("Open Jupyter Notebook", new NodeActionListener() {
@Override
protected void actionPerformed(NodeActionEvent e) {
String jupyterUrl = String.format("https://%s.azurehdinsight.net/jupyter/tree", clusterDetail.getName());
openUrlLink(jupyterUrl);
}
});
addAction("Open Azure Management Portal", new NodeActionListener() {
@Override
protected void actionPerformed(NodeActionEvent e) {
String resourceGroupName = clusterDetail.getResourceGroup();
if (resourceGroupName != null) {
String webPortHttpLink = String.format("https://portal.azure.com/#resource/subscriptions/%s/resourcegroups/%s/providers/Microsoft.HDInsight/clusters/%s", clusterDetail.getSubscription().getSubscriptionId(), resourceGroupName, clusterDetail.getName());
openUrlLink(webPortHttpLink);
} else {
DefaultLoader.getUIHelper().showError("Failed to get resource group name.", "HDInsight Explorer");
}
}
});
}
if (clusterDetail instanceof HDInsightAdditionalClusterDetail) {
addAction("Unlink", new NodeActionListener() {
@Override
protected void actionPerformed(NodeActionEvent e) {
boolean choice = DefaultLoader.getUIHelper().showConfirmation("Do you really want to unlink the HDInsight cluster?", "Unlink HDInsight Cluster", new String[] { "Yes", "No" }, null);
if (choice) {
ClusterManagerEx.getInstance().removeHDInsightAdditionalCluster((HDInsightAdditionalClusterDetail) clusterDetail);
((HDInsightRootModule) getParent()).refreshWithoutAsync();
}
}
});
}
if (clusterDetail instanceof EmulatorClusterDetail) {
addAction("Unlink", new NodeActionListener() {
@Override
protected void actionPerformed(NodeActionEvent e) {
boolean choice = DefaultLoader.getUIHelper().showConfirmation("Do you really want to unlink the Emulator cluster?", "Unlink HDInsight Cluster", new String[] { "Yes", "No" }, null);
if (choice) {
ClusterManagerEx.getInstance().removeEmulatorCluster((EmulatorClusterDetail) clusterDetail);
((HDInsightRootModule) getParent()).refreshWithoutAsync();
}
}
});
}
}
use of com.microsoft.tooling.msservices.serviceexplorer.NodeActionEvent in project azure-tools-for-java by Microsoft.
the class FunctionNode method loadActions.
@Override
protected void loadActions() {
addAction("Trigger Function", new WrappedTelemetryNodeActionListener(FUNCTION, TRIGGER_FUNCTION, new NodeActionListener() {
@Override
@AzureOperation(name = "function|trigger.start", type = AzureOperation.Type.ACTION)
protected void actionPerformed(NodeActionEvent e) {
final AzureString title = AzureOperationBundle.title("function|trigger.start");
AzureTaskManager.getInstance().runInBackground(new AzureTask<>(getProject(), title, false, () -> trigger()));
}
}));
// todo: find whether there is sdk to enable/disable trigger
}
use of com.microsoft.tooling.msservices.serviceexplorer.NodeActionEvent in project azure-tools-for-java by Microsoft.
the class ExternalStorageNode method refreshItems.
@Override
protected void refreshItems() throws AzureCmdException {
if (storageAccount.getPrimaryKey().isEmpty()) {
try {
NodeActionListener listener = node2Actions.get(this.getClass()).get(0).getConstructor().newInstance();
listener.actionPerformedAsync(new NodeActionEvent(new NodeAction(this, this.getName()))).get();
} catch (Throwable t) {
throw new AzureCmdException("Error opening external storage", t);
}
} else {
fillChildren();
}
}
Aggregations