Search in sources :

Example 6 with NodeActionListener

use of com.microsoft.tooling.msservices.serviceexplorer.NodeActionListener in project azure-tools-for-java by Microsoft.

the class QueueFileEditor method createFileEditorVirtualNode.

private FileEditorVirtualNode createFileEditorVirtualNode(final String name) {
    FileEditorVirtualNode fileEditorVirtualNode = new FileEditorVirtualNode(this, name);
    fileEditorVirtualNode.addAction(REFRESH, new NodeActionListener() {

        @Override
        protected void actionPerformed(NodeActionEvent e) {
            fillGrid();
        }
    });
    fileEditorVirtualNode.addAction(DEQUEUE, new NodeActionListener() {

        @Override
        protected void actionPerformed(NodeActionEvent e) {
            dequeueFirstMessage();
        }
    });
    fileEditorVirtualNode.addAction(ADD_MESSAGE, new NodeActionListener() {

        @Override
        protected void actionPerformed(NodeActionEvent e) {
            QueueMessageForm queueMessageForm = new QueueMessageForm(project);
            queueMessageForm.setQueue(queue);
            queueMessageForm.setStorageAccount(storageAccount);
            queueMessageForm.setOnAddedMessage(new Runnable() {

                @Override
                public void run() {
                    fillGrid();
                }
            });
            queueMessageForm.show();
        }
    });
    fileEditorVirtualNode.addAction(CLEAR_QUEUE, new NodeActionListener() {

        @Override
        protected void actionPerformed(NodeActionEvent e) {
            int optionDialog = JOptionPane.showOptionDialog(null, "Are you sure you want to clear the queue \"" + queue.getName() + "\"?", "Azure Explorer", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { "Yes", "No" }, null);
            if (optionDialog == JOptionPane.YES_OPTION) {
                ProgressManager.getInstance().run(new Task.Backgroundable(project, "Clearing queue messages", false) {

                    @Override
                    public void run(@NotNull ProgressIndicator progressIndicator) {
                    /* try {

                                StorageClientSDKManager.getManager().clearQueue(storageAccount, queue);

                                ApplicationManager.getApplication().invokeLater(new Runnable() {
                                    @Override
                                    public void run() {
                                        fillGrid();
                                    }
                                });
                            } catch (AzureCmdException e) {
                                String msg = "An error occurred while attempting to clear queue messages." + "\n" + String.format(message("webappExpMsg"), e.getMessage());
                                PluginUtil.displayErrorDialogAndLog(message("errTtl"), msg, e);
                            }*/
                    }
                });
            }
        }
    });
    fileEditorVirtualNode.addAction(OPEN, new NodeActionListener() {

        @Override
        protected void actionPerformed(NodeActionEvent e) {
            viewMessageText();
        }
    });
    return fileEditorVirtualNode;
}
Also used : ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) NodeActionListener(com.microsoft.tooling.msservices.serviceexplorer.NodeActionListener) NodeActionEvent(com.microsoft.tooling.msservices.serviceexplorer.NodeActionEvent) QueueMessageForm(com.microsoft.intellij.forms.QueueMessageForm) NotNull(org.jetbrains.annotations.NotNull)

Example 7 with NodeActionListener

use of com.microsoft.tooling.msservices.serviceexplorer.NodeActionListener in project azure-tools-for-java by Microsoft.

the class TableFileEditor method createFileEditorVirtualNode.

private FileEditorVirtualNode createFileEditorVirtualNode(final String name) {
    FileEditorVirtualNode fileEditorVirtualNode = new FileEditorVirtualNode(this, name);
    fileEditorVirtualNode.addAction(EDIT, new NodeActionListener() {

        @Override
        protected void actionPerformed(NodeActionEvent e) {
            editEntity();
        }
    });
    fileEditorVirtualNode.addAction(DELETE, new NodeActionListener() {

        @Override
        protected void actionPerformed(NodeActionEvent e) {
            deleteSelection();
        }
    });
    fileEditorVirtualNode.addAction(QUERY, new NodeActionListener() {

        @Override
        protected void actionPerformed(NodeActionEvent e) {
            fillGrid();
        }
    });
    fileEditorVirtualNode.addAction(QUERY_DESIGNER, new NodeActionListener() {

        @Override
        protected void actionPerformed(NodeActionEvent e) {
            final TablesQueryDesigner form = new TablesQueryDesigner(project);
            form.setOnFinish(new Runnable() {

                @Override
                public void run() {
                    queryTextField.setText(form.getQueryText());
                }
            });
            form.show();
        }
    });
    fileEditorVirtualNode.addAction(NEW_ENTITY, new NodeActionListener() {

        @Override
        protected void actionPerformed(NodeActionEvent e) {
            final TableEntityForm form = new TableEntityForm(project);
            form.setTableName(table.getName());
            form.setStorageAccount(storageAccount);
            form.setTableEntity(null);
            form.setTableEntityList(tableEntities);
            form.setTitle("Add Entity");
            form.setOnFinish(new Runnable() {

                @Override
                public void run() {
                    tableEntities.add(form.getTableEntity());
                    refreshGrid();
                }
            });
            form.show();
        }
    });
    return fileEditorVirtualNode;
}
Also used : TableEntityForm(com.microsoft.intellij.forms.TableEntityForm) TablesQueryDesigner(com.microsoft.intellij.forms.TablesQueryDesigner) NodeActionListener(com.microsoft.tooling.msservices.serviceexplorer.NodeActionListener) NodeActionEvent(com.microsoft.tooling.msservices.serviceexplorer.NodeActionEvent)

Example 8 with NodeActionListener

use of com.microsoft.tooling.msservices.serviceexplorer.NodeActionListener 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();
                }
            }
        });
    }
}
Also used : EmulatorClusterDetail(com.microsoft.azure.hdinsight.sdk.cluster.EmulatorClusterDetail) HDInsightAdditionalClusterDetail(com.microsoft.azure.hdinsight.sdk.cluster.HDInsightAdditionalClusterDetail) EmulatorClusterDetail(com.microsoft.azure.hdinsight.sdk.cluster.EmulatorClusterDetail) HDInsightAdditionalClusterDetail(com.microsoft.azure.hdinsight.sdk.cluster.HDInsightAdditionalClusterDetail) ClusterDetail(com.microsoft.azure.hdinsight.sdk.cluster.ClusterDetail) IClusterDetail(com.microsoft.azure.hdinsight.sdk.cluster.IClusterDetail) NodeActionListener(com.microsoft.tooling.msservices.serviceexplorer.NodeActionListener) NodeActionEvent(com.microsoft.tooling.msservices.serviceexplorer.NodeActionEvent)

Example 9 with NodeActionListener

use of com.microsoft.tooling.msservices.serviceexplorer.NodeActionListener in project azure-tools-for-java by Microsoft.

the class TableFileEditor method createVirtualNode.

private FileEditorVirtualNode<EditorPart> createVirtualNode(final String name) {
    final FileEditorVirtualNode<EditorPart> node = new FileEditorVirtualNode<EditorPart>(this, name);
    node.addAction(DELETE, new NodeActionListener() {

        @Override
        protected void actionPerformed(NodeActionEvent e) throws AzureCmdException {
            deleteSelection();
        }
    });
    node.addAction(REFRESH, new NodeActionListener() {

        @Override
        protected void actionPerformed(NodeActionEvent e) throws AzureCmdException {
            fillGrid();
        }
    });
    return node;
}
Also used : AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException) NodeActionListener(com.microsoft.tooling.msservices.serviceexplorer.NodeActionListener) NodeActionEvent(com.microsoft.tooling.msservices.serviceexplorer.NodeActionEvent) EditorPart(org.eclipse.ui.part.EditorPart)

Example 10 with NodeActionListener

use of com.microsoft.tooling.msservices.serviceexplorer.NodeActionListener 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();
    }
}
Also used : NodeAction(com.microsoft.tooling.msservices.serviceexplorer.NodeAction) AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException) NodeActionListener(com.microsoft.tooling.msservices.serviceexplorer.NodeActionListener) NodeActionEvent(com.microsoft.tooling.msservices.serviceexplorer.NodeActionEvent)

Aggregations

NodeActionEvent (com.microsoft.tooling.msservices.serviceexplorer.NodeActionEvent)10 NodeActionListener (com.microsoft.tooling.msservices.serviceexplorer.NodeActionListener)10 AzureCmdException (com.microsoft.azuretools.azurecommons.helpers.AzureCmdException)5 EditorPart (org.eclipse.ui.part.EditorPart)3 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 ClusterDetail (com.microsoft.azure.hdinsight.sdk.cluster.ClusterDetail)1 EmulatorClusterDetail (com.microsoft.azure.hdinsight.sdk.cluster.EmulatorClusterDetail)1 HDInsightAdditionalClusterDetail (com.microsoft.azure.hdinsight.sdk.cluster.HDInsightAdditionalClusterDetail)1 IClusterDetail (com.microsoft.azure.hdinsight.sdk.cluster.IClusterDetail)1 HDInsightRootModuleImpl (com.microsoft.azure.hdinsight.serverexplore.HDInsightRootModuleImpl)1 QueueMessageForm (com.microsoft.azuretools.azureexplorer.forms.QueueMessageForm)1 QueueMessageForm (com.microsoft.intellij.forms.QueueMessageForm)1 TableEntityForm (com.microsoft.intellij.forms.TableEntityForm)1 TablesQueryDesigner (com.microsoft.intellij.forms.TablesQueryDesigner)1 NodeAction (com.microsoft.tooling.msservices.serviceexplorer.NodeAction)1 NotNull (org.jetbrains.annotations.NotNull)1