Search in sources :

Example 6 with NodeActionEvent

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;
}
Also used : AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException) NodeActionListener(com.microsoft.tooling.msservices.serviceexplorer.NodeActionListener) NodeActionEvent(com.microsoft.tooling.msservices.serviceexplorer.NodeActionEvent) QueueMessageForm(com.microsoft.azuretools.azureexplorer.forms.QueueMessageForm) EditorPart(org.eclipse.ui.part.EditorPart)

Example 7 with NodeActionEvent

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();
        }
    };
}
Also used : NodeActionListener(com.microsoft.tooling.msservices.serviceexplorer.NodeActionListener) NodeActionEvent(com.microsoft.tooling.msservices.serviceexplorer.NodeActionEvent) AddNewHDInsightReaderClusterForm(com.microsoft.azure.hdinsight.serverexplore.ui.AddNewHDInsightReaderClusterForm) NotNull(com.microsoft.azuretools.azurecommons.helpers.NotNull)

Example 8 with NodeActionEvent

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();
                }
            }
        });
    }
}
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 NodeActionEvent

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
}
Also used : WrappedTelemetryNodeActionListener(com.microsoft.tooling.msservices.serviceexplorer.WrappedTelemetryNodeActionListener) WrappedTelemetryNodeActionListener(com.microsoft.tooling.msservices.serviceexplorer.WrappedTelemetryNodeActionListener) NodeActionListener(com.microsoft.tooling.msservices.serviceexplorer.NodeActionListener) NodeActionEvent(com.microsoft.tooling.msservices.serviceexplorer.NodeActionEvent) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString)

Example 10 with NodeActionEvent

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();
    }
}
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)14 NodeActionListener (com.microsoft.tooling.msservices.serviceexplorer.NodeActionListener)14 AzureCmdException (com.microsoft.azuretools.azurecommons.helpers.AzureCmdException)3 EditorPart (org.eclipse.ui.part.EditorPart)3 NotNull (com.microsoft.azuretools.azurecommons.helpers.NotNull)2 WrappedTelemetryNodeActionListener (com.microsoft.tooling.msservices.serviceexplorer.WrappedTelemetryNodeActionListener)2 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 AddNewHDInsightReaderClusterForm (com.microsoft.azure.hdinsight.serverexplore.ui.AddNewHDInsightReaderClusterForm)1 Azure (com.microsoft.azure.toolkit.lib.Azure)1 AzureString (com.microsoft.azure.toolkit.lib.common.bundle.AzureString)1 ResourceGroup (com.microsoft.azure.toolkit.lib.common.model.ResourceGroup)1 AzureTaskManager (com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager)1 AzureTelemetry (com.microsoft.azure.toolkit.lib.common.telemetry.AzureTelemetry)1 AzureGroup (com.microsoft.azure.toolkit.lib.resource.AzureGroup)1 StorageAccountConfig (com.microsoft.azure.toolkit.lib.storage.model.StorageAccountConfig)1 AzureStorageAccount (com.microsoft.azure.toolkit.lib.storage.service.AzureStorageAccount)1 StorageAccount (com.microsoft.azure.toolkit.lib.storage.service.StorageAccount)1