Skip to content

Commit 1ac161e

Browse files
committed
Add help for connecting HDinsigh by using SSH into Spark Debug
Signed-off-by: Zhang Wei <[email protected]>
1 parent 057235f commit 1ac161e

File tree

2 files changed

+72
-2
lines changed

2 files changed

+72
-2
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/hdinsight/spark/ui/SparkSubmissionAdvancedConfigDialog.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,19 @@
2222

2323
package com.microsoft.azure.hdinsight.spark.ui;
2424

25+
import com.intellij.icons.AllIcons;
26+
import com.intellij.ide.BrowserUtil;
2527
import com.intellij.openapi.fileChooser.FileChooser;
2628
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
2729
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
30+
import com.intellij.openapi.ui.popup.IconButton;
2831
import com.intellij.openapi.vfs.VirtualFile;
2932
import com.intellij.ui.DocumentAdapter;
33+
import com.intellij.ui.InplaceButton;
3034
import com.intellij.util.ui.JBUI;
3135
import com.microsoft.azure.hdinsight.common.CallBack;
3236
import com.microsoft.azure.hdinsight.common.ClusterManagerEx;
37+
import com.microsoft.azure.hdinsight.common.Docs;
3338
import com.microsoft.azure.hdinsight.sdk.cluster.IClusterDetail;
3439
import com.microsoft.azure.hdinsight.sdk.common.HDIException;
3540
import com.microsoft.azure.hdinsight.spark.common.SparkBatchDebugSession;
@@ -45,6 +50,7 @@
4550
import javax.swing.event.DocumentListener;
4651
import java.awt.*;
4752
import java.io.File;
53+
import java.util.Locale;
4854
import java.util.concurrent.TimeUnit;
4955

5056
import static com.microsoft.azure.hdinsight.spark.common.SparkSubmitAdvancedConfigModel.SSHAuthType.UseKeyFile;
@@ -62,6 +68,10 @@ public class SparkSubmissionAdvancedConfigDialog extends JDialog{
6268
this.advancedConfigModel = advancedConfigModel;
6369

6470
this.updateCallBack = updateCallBack;
71+
72+
// FIXME!!! Since the Intellij has no locale setting, just set en-us here.
73+
this.helpUrl = new Docs(Locale.US).getDocUrlByTopic(Docs.TOPIC_CONNECT_HADOOP_LINUX_USING_SSH);
74+
6575
this.sshCheckSubject = PublishSubject.create();
6676
this.inputListener = new DocumentAdapter() {
6777
@Override
@@ -118,6 +128,7 @@ public SparkSubmitAdvancedConfigModel getAdvancedConfigModel() {
118128

119129
private SparkSubmitModel submitModel;
120130
private SparkSubmitAdvancedConfigModel advancedConfigModel;
131+
private String helpUrl;
121132

122133
private final int margin = 12;
123134

@@ -135,6 +146,9 @@ public SparkSubmitAdvancedConfigModel getAdvancedConfigModel() {
135146
JButton cancelButton;
136147
BackgroundTaskIndicator checkSshCertIndicator;
137148
DocumentListener inputListener;
149+
IconButton helpButton;
150+
JPanel helpPanel;
151+
JPanel operationPanel;
138152

139153
private PublishSubject<String> sshCheckSubject;
140154
private Subscription sshCheckSubscription;
@@ -228,7 +242,7 @@ private void addMainPanel() {
228242
}
229243

230244
private void addOperationPanel() {
231-
JPanel operationPanel = new JPanel();
245+
operationPanel = new JPanel();
232246
operationPanel.setLayout(new FlowLayout());
233247

234248
okButton = new JButton("Ok");
@@ -239,8 +253,16 @@ private void addOperationPanel() {
239253

240254
getRootPane().setDefaultButton(cancelButton);
241255

256+
helpPanel = new JPanel();
257+
helpPanel.setLayout(new BoxLayout(helpPanel, BoxLayout.LINE_AXIS));
258+
259+
helpButton = new IconButton("Help about connection to HDInsight using SSH", AllIcons.Actions.Help);
242260
checkSshCertIndicator = new BackgroundTaskIndicator("Verify SSH Authentication...");
243-
add(checkSshCertIndicator,
261+
262+
helpPanel.add(new InplaceButton(helpButton, e -> BrowserUtil.browse(this.helpUrl)));
263+
helpPanel.add(checkSshCertIndicator);
264+
265+
add(helpPanel,
244266
new GridBagConstraints(0, ++displayLayoutCurrentRow,
245267
0, 1,
246268
1, 0,
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright (c) Microsoft Corporation
3+
* <p/>
4+
* All rights reserved.
5+
* <p/>
6+
* MIT License
7+
* <p/>
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
9+
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
10+
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
11+
* to permit persons to whom the Software is furnished to do so, subject to the following conditions:
12+
* <p/>
13+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of
14+
* the Software.
15+
* <p/>
16+
* THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
17+
* THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
*/
21+
22+
package com.microsoft.azure.hdinsight.common;
23+
24+
import java.util.Formatter;
25+
import java.util.Locale;
26+
27+
public class Docs {
28+
private static final String DOC_URL_PATTERN = "https://docs.microsoft.com/%s-%s/azure/hdinsight/%s";
29+
30+
static public final String TOPIC_CONNECT_HADOOP_LINUX_USING_SSH = "hdinsight-hadoop-linux-use-ssh-unix";
31+
32+
private Locale locale;
33+
34+
public Docs(Locale locale) {
35+
this.locale = locale;
36+
}
37+
38+
public String getDocUrlByTopic(String topic) {
39+
StringBuilder sb = new StringBuilder();
40+
Formatter formatter = new Formatter(sb, this.locale);
41+
42+
return formatter.format(DOC_URL_PATTERN,
43+
this.locale.getLanguage().toLowerCase(),
44+
this.locale.getCountry().toLowerCase(),
45+
topic)
46+
.toString();
47+
}
48+
}

0 commit comments

Comments
 (0)