|
1 | 1 | package com.microsoft.intellij.runner.webapp.webappconfig.slimui; |
2 | 2 |
|
3 | 3 | import com.intellij.icons.AllIcons; |
| 4 | +import com.intellij.ide.IdeTooltipManager; |
4 | 5 | import com.intellij.openapi.project.Project; |
5 | 6 | import com.intellij.openapi.util.Comparing; |
6 | 7 | import com.intellij.packaging.artifacts.Artifact; |
|
22 | 23 | import org.jetbrains.annotations.NotNull; |
23 | 24 | import org.jetbrains.idea.maven.model.MavenConstants; |
24 | 25 | import org.jetbrains.idea.maven.project.MavenProject; |
| 26 | +import rx.Observable; |
| 27 | +import rx.Subscription; |
| 28 | +import rx.schedulers.Schedulers; |
25 | 29 |
|
26 | 30 | import javax.swing.ButtonGroup; |
27 | 31 | import javax.swing.ComboBoxEditor; |
| 32 | +import javax.swing.Icon; |
| 33 | +import javax.swing.JButton; |
28 | 34 | import javax.swing.JCheckBox; |
29 | 35 | import javax.swing.JComboBox; |
30 | 36 | import javax.swing.JLabel; |
31 | 37 | import javax.swing.JList; |
32 | 38 | import javax.swing.JPanel; |
33 | 39 | import javax.swing.JRadioButton; |
34 | 40 | import javax.swing.JTextField; |
| 41 | +import javax.swing.SwingConstants; |
35 | 42 | import java.awt.Component; |
| 43 | +import java.awt.Dimension; |
| 44 | +import java.awt.KeyboardFocusManager; |
36 | 45 | import java.awt.event.ActionListener; |
| 46 | +import java.awt.event.FocusEvent; |
| 47 | +import java.awt.event.FocusListener; |
| 48 | +import java.awt.event.MouseEvent; |
37 | 49 | import java.awt.event.WindowAdapter; |
38 | 50 | import java.awt.event.WindowEvent; |
39 | 51 | import java.text.DateFormat; |
40 | 52 | import java.text.SimpleDateFormat; |
41 | | -import java.util.ArrayList; |
42 | 53 | import java.util.Date; |
43 | 54 | import java.util.List; |
| 55 | +import java.util.concurrent.TimeUnit; |
44 | 56 | import java.util.stream.Collectors; |
45 | 57 |
|
46 | 58 | public class WebAppSlimSettingPanel extends AzureSettingPanel<WebAppConfiguration> implements WebAppDeployMvpViewSlim { |
@@ -80,9 +92,9 @@ public class WebAppSlimSettingPanel extends AzureSettingPanel<WebAppConfiguratio |
80 | 92 | private JLabel lblSlotConfiguration; |
81 | 93 | private HyperlinkLabel lblCreateWebApp; |
82 | 94 | private JCheckBox chkOpenBrowser; |
83 | | - private JLabel lblSlotHover; |
84 | 95 | private HyperlinkLabel lblNewSlot; |
85 | 96 | private JPanel pnlExistingSlot; |
| 97 | + private JButton btnSlotHover; |
86 | 98 | private HideableDecorator slotDecorator; |
87 | 99 |
|
88 | 100 | // presenter |
@@ -150,6 +162,40 @@ public void removeActionListener(ActionListener l) { |
150 | 162 | }); |
151 | 163 | cbxWebApp.setEditable(true); |
152 | 164 |
|
| 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 | + |
153 | 199 | cbArtifact.addActionListener(e -> artifactActionPeformed((Artifact) cbArtifact.getSelectedItem())); |
154 | 200 |
|
155 | 201 | cbArtifact.setRenderer(new ListCellRendererWrapper<Artifact>() { |
@@ -391,9 +437,6 @@ private void createUIComponents() { |
391 | 437 |
|
392 | 438 | lblNewSlot = new HyperlinkLabel("No available deployment slot, click to create a new one"); |
393 | 439 | lblNewSlot.addHyperlinkListener(e -> rbtNewSlot.doClick()); |
394 | | - |
395 | | - lblSlotHover = new JLabel(AllIcons.General.Information); |
396 | | - lblSlotHover.setToolTipText(DEPLOYMENT_SLOT_HOVER); |
397 | 440 | } |
398 | 441 |
|
399 | 442 | private void refreshWebApps(boolean force) { |
|
0 commit comments