Skip to content

Commit 606f322

Browse files
authored
Make info icon focusable and show info when focused (#3525)
* Make info icon focusable and show info when focused * Remove unused import
1 parent 5239860 commit 606f322

File tree

2 files changed

+62
-15
lines changed

2 files changed

+62
-15
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/intellij/runner/webapp/webappconfig/slimui/WebAppSlimSettingPanel.form

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@
2121
<properties/>
2222
<border type="none"/>
2323
<children>
24-
<grid id="304dd" binding="pnlSlotCheckBox" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
25-
<margin top="0" left="0" bottom="0" right="0"/>
24+
<grid id="304dd" binding="pnlSlotCheckBox" layout-manager="FormLayout">
25+
<rowspec value="center:d:grow"/>
26+
<colspec value="fill:max(d;4px):noGrow"/>
27+
<colspec value="left:4dlu:noGrow"/>
28+
<colspec value="fill:max(d;4px):noGrow"/>
2629
<constraints>
2730
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
2831
</constraints>
@@ -31,7 +34,8 @@
3134
<children>
3235
<component id="2e7a1" class="javax.swing.JCheckBox" binding="chkDeployToSlot">
3336
<constraints>
34-
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="9" fill="0" indent="0" use-parent-layout="false"/>
37+
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
38+
<forms/>
3539
</constraints>
3640
<properties>
3741
<alignmentX value="0.5"/>
@@ -44,16 +48,16 @@
4448
<text value="Deploy To Slot"/>
4549
</properties>
4650
</component>
47-
<hspacer id="34f68">
48-
<constraints>
49-
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
50-
</constraints>
51-
</hspacer>
52-
<component id="e06ef" class="javax.swing.JLabel" binding="lblSlotHover" custom-create="true">
51+
<component id="3d0cf" class="javax.swing.JButton" binding="btnSlotHover">
5352
<constraints>
54-
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
53+
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false">
54+
<preferred-size width="20" height="20"/>
55+
</grid>
56+
<forms/>
5557
</constraints>
5658
<properties>
59+
<borderPainted value="false"/>
60+
<contentAreaFilled value="false"/>
5761
<text value=""/>
5862
</properties>
5963
</component>

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/intellij/runner/webapp/webappconfig/slimui/WebAppSlimSettingPanel.java

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.microsoft.intellij.runner.webapp.webappconfig.slimui;
22

33
import com.intellij.icons.AllIcons;
4+
import com.intellij.ide.IdeTooltipManager;
45
import com.intellij.openapi.project.Project;
56
import com.intellij.openapi.util.Comparing;
67
import com.intellij.packaging.artifacts.Artifact;
@@ -22,25 +23,36 @@
2223
import org.jetbrains.annotations.NotNull;
2324
import org.jetbrains.idea.maven.model.MavenConstants;
2425
import org.jetbrains.idea.maven.project.MavenProject;
26+
import rx.Observable;
27+
import rx.Subscription;
28+
import rx.schedulers.Schedulers;
2529

2630
import javax.swing.ButtonGroup;
2731
import javax.swing.ComboBoxEditor;
32+
import javax.swing.Icon;
33+
import javax.swing.JButton;
2834
import javax.swing.JCheckBox;
2935
import javax.swing.JComboBox;
3036
import javax.swing.JLabel;
3137
import javax.swing.JList;
3238
import javax.swing.JPanel;
3339
import javax.swing.JRadioButton;
3440
import javax.swing.JTextField;
41+
import javax.swing.SwingConstants;
3542
import java.awt.Component;
43+
import java.awt.Dimension;
44+
import java.awt.KeyboardFocusManager;
3645
import java.awt.event.ActionListener;
46+
import java.awt.event.FocusEvent;
47+
import java.awt.event.FocusListener;
48+
import java.awt.event.MouseEvent;
3749
import java.awt.event.WindowAdapter;
3850
import java.awt.event.WindowEvent;
3951
import java.text.DateFormat;
4052
import java.text.SimpleDateFormat;
41-
import java.util.ArrayList;
4253
import java.util.Date;
4354
import java.util.List;
55+
import java.util.concurrent.TimeUnit;
4456
import java.util.stream.Collectors;
4557

4658
public class WebAppSlimSettingPanel extends AzureSettingPanel<WebAppConfiguration> implements WebAppDeployMvpViewSlim {
@@ -80,9 +92,9 @@ public class WebAppSlimSettingPanel extends AzureSettingPanel<WebAppConfiguratio
8092
private JLabel lblSlotConfiguration;
8193
private HyperlinkLabel lblCreateWebApp;
8294
private JCheckBox chkOpenBrowser;
83-
private JLabel lblSlotHover;
8495
private HyperlinkLabel lblNewSlot;
8596
private JPanel pnlExistingSlot;
97+
private JButton btnSlotHover;
8698
private HideableDecorator slotDecorator;
8799

88100
// presenter
@@ -150,6 +162,40 @@ public void removeActionListener(ActionListener l) {
150162
});
151163
cbxWebApp.setEditable(true);
152164

165+
Icon informationIcon = AllIcons.General.Information;
166+
btnSlotHover.setIcon(informationIcon);
167+
btnSlotHover.setHorizontalAlignment(SwingConstants.CENTER);
168+
btnSlotHover.setPreferredSize(new Dimension(informationIcon.getIconWidth(), informationIcon.getIconHeight()));
169+
btnSlotHover.setToolTipText(DEPLOYMENT_SLOT_HOVER);
170+
btnSlotHover.addFocusListener(new FocusListener() {
171+
172+
Subscription subscription;
173+
174+
@Override
175+
public void focusGained(FocusEvent focusEvent) {
176+
btnSlotHover.setBorderPainted(true);
177+
MouseEvent phantom = new MouseEvent(btnSlotHover, MouseEvent.MOUSE_ENTERED, System.currentTimeMillis(),
178+
0, 10, 10, 0, false);
179+
IdeTooltipManager.getInstance().eventDispatched(phantom);
180+
if (subscription != null) {
181+
subscription.unsubscribe();
182+
}
183+
subscription = Observable.timer(2, TimeUnit.SECONDS)
184+
.subscribeOn(Schedulers.newThread())
185+
.subscribe(next -> {
186+
if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() == btnSlotHover) {
187+
focusGained(focusEvent);
188+
}
189+
});
190+
}
191+
192+
@Override
193+
public void focusLost(FocusEvent focusEvent) {
194+
btnSlotHover.setBorderPainted(false);
195+
IdeTooltipManager.getInstance().dispose();
196+
}
197+
});
198+
153199
cbArtifact.addActionListener(e -> artifactActionPeformed((Artifact) cbArtifact.getSelectedItem()));
154200

155201
cbArtifact.setRenderer(new ListCellRendererWrapper<Artifact>() {
@@ -391,9 +437,6 @@ private void createUIComponents() {
391437

392438
lblNewSlot = new HyperlinkLabel("No available deployment slot, click to create a new one");
393439
lblNewSlot.addHyperlinkListener(e -> rbtNewSlot.doClick());
394-
395-
lblSlotHover = new JLabel(AllIcons.General.Information);
396-
lblSlotHover.setToolTipText(DEPLOYMENT_SLOT_HOVER);
397440
}
398441

399442
private void refreshWebApps(boolean force) {

0 commit comments

Comments
 (0)