Java 类com.intellij.ui.ClickListener 实例源码

项目:educational-plugin    文件:StudyStepicUserWidget.java   
public StudyStepicUserWidget() {
  StepicUser user = StudySettings.getInstance().getUser();
  Icon icon = user == null ? EducationalCoreIcons.StepikOff : EducationalCoreIcons.Stepik;
  myComponent = new JLabel(icon);

  new ClickListener() {
    @Override
    public boolean onClick(@NotNull MouseEvent e, int clickCount) {
      Point point = new Point(0, 0);
      StepicUserComponent component = new StepicUserComponent(StudySettings.getInstance().getUser());
      final Dimension dimension = component.getPreferredSize();
      point = new Point(point.x - dimension.width, point.y - dimension.height);
      component.showComponent(new RelativePoint(e.getComponent(), point));
      return true;
    }
  }.installOn(myComponent);
}
项目:MissingInActions    文件:CheckBoxWithColorChooser.java   
MyColorButton() {
    setMargin(new Insets(0, 0, 0, 0));
    setDefaultCapable(false);
    setFocusable(false);
    if (SystemInfo.isMac) {
        putClientProperty("JButton.buttonType", "square");
    }
    new ClickListener() {
        @Override
        public boolean onClick(@NotNull MouseEvent e, int clickCount) {
            if (myCheckbox.isSelected()) {
                final Color color = ColorChooser.chooseColor(myCheckbox, "Chose color", CheckBoxWithColorChooser.this.myColor);
                if (color != null) {
                    myColor = color;
                    MyColorButton.this.repaint();
                    if (myUpdateRunnable != null) {
                        myUpdateRunnable.run();
                    }
                }
            }
            return true;
        }
    }.installOn(this);
}
项目:intellij-ce-playground    文件:IdeStatusBarImpl.java   
private MultipleTextValuesPresentationWrapper(@NotNull final StatusBarWidget.MultipleTextValuesPresentation presentation) {
  super();
  myPresentation = presentation;

  putClientProperty(UIUtil.CENTER_TOOLTIP_DEFAULT, Boolean.TRUE);
  setToolTipText(presentation.getTooltipText());
  new ClickListener() {
    @Override
    public boolean onClick(@NotNull MouseEvent e, int clickCount) {
      final ListPopup popup = myPresentation.getPopupStep();
      if (popup == null) return false;
      final Dimension dimension = popup.getContent().getPreferredSize();
      final Point at = new Point(0, -dimension.height);
      popup.show(new RelativePoint(e.getComponent(), at));
      return true;
    }
  }.installOn(this);


  setOpaque(false);
}
项目:intellij-ce-playground    文件:Advertiser.java   
public Advertiser() {
  myNextLabel = new JLabel(">>");
  myNextLabel.setFont(adFont().deriveFont(
    ContainerUtil.<TextAttribute, Object>immutableMapBuilder().put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON).build()));
  myNextLabel.setForeground(JBColor.blue);
  new ClickListener() {
    @Override
    public boolean onClick(@NotNull MouseEvent e, int clickCount) {
      myCurrentItem++;
      updateAdvertisements();
      return true;
    }
  }.installOn(myNextLabel);

  myNextLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

  GridBag gb = new GridBag();
  myComponent.add(myTextPanel, gb.next());
  myComponent.add(myNextLabel, gb.next());
  myComponent.add(new NonOpaquePanel(), gb.next().fillCellHorizontally().weightx(1));
}
项目:intellij-ce-playground    文件:PyConfigureInterpretersLinkPanel.java   
public PyConfigureInterpretersLinkPanel(final JPanel parentPanel) {
  super(new BorderLayout());
  myConfigureLabel = new JBLabel("<html><a href=\"#\">Configure Interpreters");
  myConfigureLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
  new ClickListener() {
    @Override
    public boolean onClick(@NotNull MouseEvent e, int clickCount) {
      if (clickCount == 1) {
        Settings settings = Settings.KEY.getData(DataManager.getInstance().getDataContext(parentPanel));
        if (settings != null) {
          settings.select(settings.find(PyActiveSdkModuleConfigurable.class.getName()));
          return true;
        }
      }
      return false;
    }
  }.installOn(myConfigureLabel);

  add(myConfigureLabel, BorderLayout.CENTER);
}
项目:intellij-ce-playground    文件:LightBulbComponentImpl.java   
public LightBulbComponentImpl(@NotNull final QuickFixManager manager, @NotNull final Icon icon) {
  myManager = manager;
  myIcon = icon;

  setPreferredSize(new Dimension(icon.getIconWidth(), icon.getIconHeight()));
  final String acceleratorsText = KeymapUtil.getFirstKeyboardShortcutText(
    ActionManager.getInstance().getAction(IdeActions.ACTION_SHOW_INTENTION_ACTIONS));
  if (acceleratorsText.length() > 0) {
    setToolTipText(UIDesignerBundle.message("tooltip.press.accelerator", acceleratorsText));
  }

  new ClickListener() {
    @Override
    public boolean onClick(@NotNull MouseEvent e, int clickCount) {
      myManager.showIntentionPopup();
      return true;
    }
  }.installOn(this);
}
项目:vso-intellij    文件:FilterDropDown.java   
public FilterDropDown() {
    this.group = new DefaultActionGroup();

    this.clickListener = new ClickListener() {
        @Override
        public boolean onClick(MouseEvent event, int clickCount) {
            showDropDownMenu();
            return true;
        }
    };

    this.keyAdapter = new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent keyEvent) {
            if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER || keyEvent.getKeyCode() == KeyEvent.VK_DOWN) {
                showDropDownMenu();
            }
        }
    };
}
项目:tools-idea    文件:IdeStatusBarImpl.java   
private MultipleTextValuesPresentationWrapper(@NotNull final StatusBarWidget.MultipleTextValuesPresentation presentation) {
  super();
  myPresentation = presentation;

  putClientProperty(UIUtil.CENTER_TOOLTIP_DEFAULT, Boolean.TRUE);
  setToolTipText(presentation.getTooltipText());
  new ClickListener() {
    @Override
    public boolean onClick(MouseEvent e, int clickCount) {
      final ListPopup popup = myPresentation.getPopupStep();
      if (popup == null) return false;
      final Dimension dimension = popup.getContent().getPreferredSize();
      final Point at = new Point(0, -dimension.height);
      popup.show(new RelativePoint(e.getComponent(), at));
      return true;
    }
  }.installOn(this);


  setOpaque(false);
}
项目:tools-idea    文件:LineSeparatorPanel.java   
public LineSeparatorPanel(@NotNull final Project project) {
  super(project);

  myComponent = new TextPanel() {
    @Override
    protected void paintComponent(@NotNull final Graphics g) {
      super.paintComponent(g);
      if (myActionEnabled && getText() != null) {
        final Rectangle r = getBounds();
        final Insets insets = getInsets();
        AllIcons.Ide.Statusbar_arrows.paintIcon(this, g, r.width - insets.right - AllIcons.Ide.Statusbar_arrows.getIconWidth() - 2,
                                                r.height / 2 - AllIcons.Ide.Statusbar_arrows.getIconHeight() / 2);
      }
    }
  };

  new ClickListener() {
    @Override
    public boolean onClick(MouseEvent e, int clickCount) {
      update();
      showPopup(e);
      return true;
    }
  }.installOn(myComponent);
  myComponent.setBorder(WidgetBorder.INSTANCE);
}
项目:tools-idea    文件:EncodingPanel.java   
public EncodingPanel(@NotNull final Project project) {
  super(project);
  update = new Alarm(this);
  myComponent = new TextPanel() {
    @Override
    protected void paintComponent(@NotNull final Graphics g) {
      super.paintComponent(g);
      if (actionEnabled && getText() != null) {
        final Rectangle r = getBounds();
        final Insets insets = getInsets();
        AllIcons.Ide.Statusbar_arrows.paintIcon(this, g, r.width - insets.right - AllIcons.Ide.Statusbar_arrows.getIconWidth() - 2,
                                                r.height / 2 - AllIcons.Ide.Statusbar_arrows.getIconHeight() / 2);
      }
    }
  };

  new ClickListener() {
    @Override
    public boolean onClick(MouseEvent e, int clickCount) {
      update();
      showPopup(e);
      return true;
    }
  }.installOn(myComponent);
  myComponent.setBorder(WidgetBorder.INSTANCE);
}
项目:tools-idea    文件:TableSorter.java   
public void addMouseListenerToHeaderInTable(JTable table) {
  final TableSorter sorter = this;
  final JTable tableView = table;
  tableView.setColumnSelectionAllowed(false);
  new ClickListener() {
    @Override
    public boolean onClick(MouseEvent e, int clickCount) {
      TableColumnModel columnModel = tableView.getColumnModel();
      int viewColumn = columnModel.getColumnIndexAtX(e.getX());
      int column = tableView.convertColumnIndexToModel(viewColumn);
      if (clickCount == 1 && column != -1) {
        //System.out.println("Sorting ...");
        int shiftPressed = e.getModifiers() & InputEvent.SHIFT_MASK;
        boolean ascending = (shiftPressed == 0);
        sorter.sortByColumn(column, ascending);
        return true;
      }
      return false;
    }
  }.installOn(tableView.getTableHeader());
}
项目:tools-idea    文件:Advertiser.java   
public Advertiser() {
  myNextLabel = new JLabel(">>");
  myNextLabel.setFont(adFont().deriveFont(
    ContainerUtil.<TextAttribute, Object>immutableMapBuilder().put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON).build()));
  myNextLabel.setForeground(JBColor.blue);
  new ClickListener() {
    @Override
    public boolean onClick(MouseEvent e, int clickCount) {
      myCurrentItem++;
      updateAdvertisements();
      return true;
    }
  }.installOn(myNextLabel);

  myNextLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

  GridBag gb = new GridBag();
  myComponent.add(myTextPanel, gb.next());
  myComponent.add(myNextLabel, gb.next());
  myComponent.add(new NonOpaquePanel(), gb.next().fillCellHorizontally().weightx(1));
}
项目:tools-idea    文件:LightBulbComponentImpl.java   
public LightBulbComponentImpl(@NotNull final QuickFixManager manager, @NotNull final Icon icon) {
  myManager = manager;
  myIcon = icon;

  setPreferredSize(new Dimension(icon.getIconWidth(), icon.getIconHeight()));
  final String acceleratorsText = KeymapUtil.getFirstKeyboardShortcutText(
    ActionManager.getInstance().getAction(IdeActions.ACTION_SHOW_INTENTION_ACTIONS));
  if (acceleratorsText.length() > 0) {
    setToolTipText(UIDesignerBundle.message("tooltip.press.accelerator", acceleratorsText));
  }

  new ClickListener() {
    @Override
    public boolean onClick(MouseEvent e, int clickCount) {
      myManager.showIntentionPopup();
      return true;
    }
  }.installOn(this);
}
项目:idea-file-language    文件:FileLanguagePanel.java   
FileLanguagePanel(@NotNull final Project project) {
    super(project);

    myComponent = new TextPanel.ExtraSize() {
        @Override
        protected void paintComponent(@NotNull final Graphics g) {
            super.paintComponent(g);
            if (myActionEnabled && getText() != null) {
                final Rectangle r = getBounds();
                final Insets insets = getInsets();
                AllIcons.Ide.Statusbar_arrows.paintIcon(this, g, r.width - insets.right - AllIcons.Ide.Statusbar_arrows.getIconWidth() - 2,
                        r.height / 2 - AllIcons.Ide.Statusbar_arrows.getIconHeight() / 2);
            }
        }
    };

    new ClickListener() {
        @Override
        public boolean onClick(@NotNull MouseEvent e, int clickCount) {
            update();
            showPopup(e);
            return true;
        }
    }.installOn(myComponent);
    myComponent.setBorder(WidgetBorder.WIDE);
}
项目:consulo-ui-designer    文件:LightBulbComponentImpl.java   
public LightBulbComponentImpl(@NotNull final QuickFixManager manager, @NotNull final Icon icon) {
  myManager = manager;
  myIcon = icon;

  setPreferredSize(new Dimension(icon.getIconWidth(), icon.getIconHeight()));
  final String acceleratorsText = KeymapUtil.getFirstKeyboardShortcutText(
    ActionManager.getInstance().getAction(IdeActions.ACTION_SHOW_INTENTION_ACTIONS));
  if (acceleratorsText.length() > 0) {
    setToolTipText(UIDesignerBundle.message("tooltip.press.accelerator", acceleratorsText));
  }

  new ClickListener() {
    @Override
    public boolean onClick(MouseEvent e, int clickCount) {
      myManager.showIntentionPopup();
      return true;
    }
  }.installOn(this);
}
项目:consulo    文件:ModuleLayerWidget.java   
public ModuleLayerWidget(@Nonnull Project project) {
  super(project);

  myComponent = new TextPanel() {
    @Override
    protected void paintComponent(@Nonnull final Graphics g) {
      super.paintComponent(g);
      if (myActionEnabled && getText() != null) {
        final Rectangle r = getBounds();
        final Insets insets = getInsets();
        AllIcons.Ide.Statusbar_arrows.paintIcon(this, g, r.width - insets.right - AllIcons.Ide.Statusbar_arrows.getIconWidth() - 2,
                                                r.height / 2 - AllIcons.Ide.Statusbar_arrows.getIconHeight() / 2);
      }
    }
  };

  new ClickListener() {
    @Override
    public boolean onClick(MouseEvent e, int clickCount) {
      update();
      showPopup(e);
      return true;
    }
  }.installOn(myComponent);
  myComponent.setBorder(WidgetBorder.INSTANCE);
}
项目:consulo    文件:IdeStatusBarImpl.java   
private MultipleTextValuesPresentationWrapper(@Nonnull final StatusBarWidget.MultipleTextValuesPresentation presentation) {
  super();
  myPresentation = presentation;

  putClientProperty(UIUtil.CENTER_TOOLTIP_DEFAULT, Boolean.TRUE);
  setToolTipText(presentation.getTooltipText());
  new ClickListener() {
    @Override
    public boolean onClick(@Nonnull MouseEvent e, int clickCount) {
      final ListPopup popup = myPresentation.getPopupStep();
      if (popup == null) return false;
      final Dimension dimension = popup.getContent().getPreferredSize();
      final Point at = new Point(0, -dimension.height);
      popup.show(new RelativePoint(e.getComponent(), at));
      return true;
    }
  }.installOn(this);


  setOpaque(false);
}
项目:consulo    文件:LineSeparatorPanel.java   
public LineSeparatorPanel(@Nonnull final Project project) {
  super(project);

  myComponent = new TextPanel.ExtraSize() {
    @Override
    protected void paintComponent(@Nonnull final Graphics g) {
      super.paintComponent(g);
      if (myActionEnabled && getText() != null) {
        final Rectangle r = getBounds();
        final Insets insets = getInsets();
        Icon arrows = AllIcons.Ide.Statusbar_arrows;
        arrows.paintIcon(this, g, r.width - insets.right - arrows.getIconWidth() - 2, r.height / 2 - arrows.getIconHeight() / 2);
      }
    }
  };

  new ClickListener() {
    @Override
    public boolean onClick(@Nonnull MouseEvent e, int clickCount) {
      update();
      showPopup(e);
      return true;
    }
  }.installOn(myComponent);
  myComponent.setBorder(WidgetBorder.WIDE);
}
项目:consulo    文件:TableSorter.java   
public void addMouseListenerToHeaderInTable(JTable table) {
  final TableSorter sorter = this;
  final JTable tableView = table;
  tableView.setColumnSelectionAllowed(false);
  new ClickListener() {
    @Override
    public boolean onClick(MouseEvent e, int clickCount) {
      TableColumnModel columnModel = tableView.getColumnModel();
      int viewColumn = columnModel.getColumnIndexAtX(e.getX());
      int column = tableView.convertColumnIndexToModel(viewColumn);
      if (clickCount == 1 && column != -1) {
        //System.out.println("Sorting ...");
        int shiftPressed = e.getModifiers() & InputEvent.SHIFT_MASK;
        boolean ascending = (shiftPressed == 0);
        sorter.sortByColumn(column, ascending);
        return true;
      }
      return false;
    }
  }.installOn(tableView.getTableHeader());
}
项目:consulo    文件:Advertiser.java   
public Advertiser() {
  myNextLabel = new JLabel(">>");
  myNextLabel.setFont(adFont().deriveFont(
    ContainerUtil.<TextAttribute, Object>immutableMapBuilder().put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON).build()));
  myNextLabel.setForeground(JBColor.blue);
  new ClickListener() {
    @Override
    public boolean onClick(MouseEvent e, int clickCount) {
      myCurrentItem++;
      updateAdvertisements();
      return true;
    }
  }.installOn(myNextLabel);

  myNextLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

  GridBag gb = new GridBag();
  myComponent.add(myTextPanel, gb.next());
  myComponent.add(myNextLabel, gb.next());
  myComponent.add(new NonOpaquePanel(), gb.next().fillCellHorizontally().weightx(1));
}
项目:jfrog-idea-plugin    文件:FilterButton.java   
private void showPopupMenuOnClick() {
    new ClickListener() {
        @Override
        public boolean onClick(@NotNull MouseEvent event, int clickCount) {
            showPopupMenu();
            return true;
        }
    }.installOn(myNameLabel);
}
项目:intellij-ce-playground    文件:VcsLogPopupComponent.java   
private void showPopupMenuOnClick() {
  new ClickListener() {
    @Override
    public boolean onClick(@NotNull MouseEvent event, int clickCount) {
      showPopupMenu();
      return true;
    }
  }.installOn(this);
}
项目:intellij-ce-playground    文件:OpenOrAttachDialog.java   
protected OpenOrAttachDialog(Project project, boolean hideReplace, final String title) {
  super(project);
  myHideReplace = hideReplace;
  setTitle(title);
  init();
  ClickListener listener = new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent event) {
      doOKAction();
      return true;
    }
  };
  listener.installOn(myCurrentWindowButton);
  listener.installOn(myOpenInNewWindowButton);

  final String mode = PropertiesComponent.getInstance().getValue(MODE_PROPERTY);
  if (MODE_NEW.equals(mode)) {
    myOpenInNewWindowButton.setSelected(true);
  }
  else if (mode == null || MODE_REPLACE.equals(mode) || hideReplace) {
    myCurrentWindowButton.setSelected(true);
    myAddCheckbox.setSelected(false);
  }
  else {
    myCurrentWindowButton.setSelected(true);
    myAddCheckbox.setSelected(true);
  }
  if (hideReplace) {
    myAddCheckbox.setVisible(false);
  }
  myAddCheckbox.setEnabled(myCurrentWindowButton.isSelected());
  final ActionListener listener1 = new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      myAddCheckbox.setEnabled(myCurrentWindowButton.isSelected());
    }
  };
  myCurrentWindowButton.addActionListener(listener1);
  myOpenInNewWindowButton.addActionListener(listener1);
}
项目:intellij-ce-playground    文件:LineSeparatorPanel.java   
public LineSeparatorPanel(@NotNull final Project project) {
  super(project);

  myComponent = new TextPanel.ExtraSize() {
    @Override
    protected void paintComponent(@NotNull final Graphics g) {
      super.paintComponent(g);
      if (myActionEnabled && getText() != null) {
        final Rectangle r = getBounds();
        final Insets insets = getInsets();
        Icon arrows = AllIcons.Ide.Statusbar_arrows;
        arrows.paintIcon(this, g, r.width - insets.right - arrows.getIconWidth() - 2,
                         r.height / 2 - arrows.getIconHeight() / 2);
      }
    }
  };

  new ClickListener() {
    @Override
    public boolean onClick(@NotNull MouseEvent e, int clickCount) {
      update();
      showPopup(e);
      return true;
    }
  }.installOn(myComponent);
  myComponent.setBorder(WidgetBorder.WIDE);
}
项目:intellij-ce-playground    文件:EncodingPanel.java   
public EncodingPanel(@NotNull final Project project) {
  super(project);
  update = new Alarm(this);
  myComponent = new TextPanel.ExtraSize() {
    @Override
    protected void paintComponent(@NotNull final Graphics g) {
      super.paintComponent(g);
      if (actionEnabled && getText() != null) {
        final Rectangle r = getBounds();
        final Insets insets = getInsets();
        Icon arrows = AllIcons.Ide.Statusbar_arrows;
        arrows.paintIcon(this, g, r.width - insets.right - arrows.getIconWidth() - 2,
                         r.height / 2 - arrows.getIconHeight() / 2);
      }
    }
  };

  new ClickListener() {
    @Override
    public boolean onClick(@NotNull MouseEvent e, int clickCount) {
      update();
      showPopup(e);
      return true;
    }
  }.installOn(myComponent);
  myComponent.setBorder(WidgetBorder.WIDE);
}
项目:intellij-ce-playground    文件:TabbedContentTabLabel.java   
public TabbedContentTabLabel(TabbedContent content, TabContentLayout layout) {
  super(content, layout);
  myContent = content;
  new ClickListener() {
    @Override
    public boolean onClick(@NotNull MouseEvent event, int clickCount) {
      showPopup();
      return true;
    }
  }.installOn(this);
}
项目:intellij-ce-playground    文件:AbstractCustomizeWizardStep.java   
protected static JPanel createBigButtonPanel(LayoutManager layout, final JToggleButton anchorButton, final Runnable action) {
  final JPanel panel = new JPanel(layout) {
    @Override
    public Color getBackground() {
      return anchorButton.isSelected() ? getSelectionBackground() : super.getBackground();
    }
  };
  panel.setOpaque(anchorButton.isSelected());
  new ClickListener() {
    @Override
    public boolean onClick(@NotNull MouseEvent event, int clickCount) {
      anchorButton.setSelected(true);
      return true;
    }
  }.installOn(panel);
  anchorButton.addItemListener(new ItemListener() {
    boolean curState = anchorButton.isSelected();
    @Override
    public void itemStateChanged(ItemEvent e) {
      if (e.getStateChange() == ItemEvent.SELECTED && curState != anchorButton.isSelected()) {
        action.run();
      }
      curState = anchorButton.isSelected();
      panel.setOpaque(curState);
      panel.repaint();
    }
  });
  return panel;
}
项目:intellij-ce-playground    文件:IdeNotificationArea.java   
public IdeNotificationArea() {
  UISettings.getInstance().addUISettingsListener(new UISettingsListener() {
    @Override
    public void uiSettingsChanged(UISettings source) {
      updateStatus();
    }
  }, this);
  new ClickListener() {
    @Override
    public boolean onClick(@NotNull MouseEvent e, int clickCount) {
      EventLog.toggleLog(getProject(), null);
      return true;
    }
  }.installOn(this);

  ApplicationManager.getApplication().getMessageBus().connect(this).subscribe(LogModel.LOG_MODEL_CHANGED, new Runnable() {
    @Override
    public void run() {
      ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
          updateStatus();
        }
      });
    }
  });
}
项目:intellij-ce-playground    文件:IdeFatalErrorsIcon.java   
public IdeFatalErrorsIcon(ActionListener aListener) {
  myListener = aListener;
  setBorder(BorderFactory.createEmptyBorder(0, 1, 0, 1));

  new ClickListener() {
    @Override
    public boolean onClick(@NotNull MouseEvent e, int clickCount) {
      if (myState != State.NoErrors) {
        myListener.actionPerformed(null);
        return true;
      }
      return false;
    }
  }.installOn(this);

  myIcon = new LayeredIcon(AllIcons.Ide.FatalError, AllIcons.Ide.FatalError_read, AllIcons.Ide.EmptyFatalError) {
    @Override
    public synchronized void paintIcon(Component c, Graphics g, int x, int y) {
      super.paintIcon(c, g, x, y);
    }

    @Override
    public synchronized void setLayerEnabled(int layer, boolean enabled) {
      super.setLayerEnabled(layer, enabled);
    }
  };
  setIcon(myIcon);
}
项目:intellij-ce-playground    文件:TextFieldAction.java   
@Override
public JComponent createCustomComponent(Presentation presentation) {
  // honestly borrowed from SearchTextField

  final JPanel panel = new JPanel(new BorderLayout());
  final JLabel label = new JLabel(myIcon);
  label.setOpaque(true);
  label.setBackground(myField.getBackground());
  myField.setOpaque(true);
  panel.add(myField, BorderLayout.WEST);
  panel.add(label, BorderLayout.EAST);
  myField.setToolTipText(myDescription);
  label.setToolTipText(myDescription);
  final Border originalBorder;
  if (SystemInfo.isMac) {
    originalBorder = BorderFactory.createLoweredBevelBorder();
  }
  else {
    originalBorder = myField.getBorder();
  }

  panel.setBorder(new CompoundBorder(IdeBorderFactory.createEmptyBorder(4, 0, 4, 0), originalBorder));

  myField.setOpaque(true);
  myField.setBorder(IdeBorderFactory.createEmptyBorder(0, 5, 0, 5));

  new ClickListener() {
    @Override
    public boolean onClick(@NotNull MouseEvent e, int clickCount) {
      actionPerformed(null);
      return true;
    }
  }.installOn(label);

  return panel;
}
项目:intellij-ce-playground    文件:XDebuggerEditorBase.java   
protected XDebuggerEditorBase(final Project project,
                              @NotNull XDebuggerEditorsProvider debuggerEditorsProvider,
                              @NotNull EvaluationMode mode,
                              @Nullable @NonNls String historyId,
                              final @Nullable XSourcePosition sourcePosition) {
  myProject = project;
  myDebuggerEditorsProvider = debuggerEditorsProvider;
  myMode = mode;
  myHistoryId = historyId;
  mySourcePosition = sourcePosition;

  myChooseFactory.setToolTipText(XDebuggerBundle.message("xdebugger.evaluate.language.hint"));
  myChooseFactory.setBorder(JBUI.Borders.empty(0, 3, 0, 3));
  new ClickListener() {
    @Override
    public boolean onClick(@NotNull MouseEvent e, int clickCount) {
      ListPopup oldPopup = SoftReference.dereference(myPopup);
      if (oldPopup != null && !oldPopup.isDisposed()) {
        oldPopup.cancel();
        myPopup = null;
        return true;
      }
      ListPopup popup = createLanguagePopup();
      popup.showUnderneathOf(myChooseFactory);
      myPopup = new WeakReference<ListPopup>(popup);
      return true;
    }
  }.installOn(myChooseFactory);
}
项目:intellij-ce-playground    文件:TagsPanel.java   
public TagsPanel(final String popupTitle) {
  super(new BorderLayout());
  add(myTextLabel, BorderLayout.CENTER);
  add(myMoreLabel, BorderLayout.EAST);

  new ClickListener() {
    @Override
    public boolean onClick(@NotNull MouseEvent e, int clickCount) {
      showTags();
      return true;
    }
  }.installOn(myMoreLabel);

  myPopupTitle = popupTitle;
}
项目:tools-idea    文件:DebuggerEditorImpl.java   
public DebuggerEditorImpl(Project project, PsiElement context, String recentsId, final CodeFragmentFactory factory) {
  myProject = project;
  myContext = context;
  myRecentsId = recentsId;
  PsiManager.getInstance(project).addPsiTreeChangeListener(myPsiListener);
  setFactory(factory);
  myInitialFactory = true;

  setFocusable(false);

  myChooseFactory.setToolTipText("Click to change the language");
  myChooseFactory.setBorder(new EmptyBorder(0, 3, 0, 3));
  new ClickListener() {
    @Override
    public boolean onClick(MouseEvent e, int clickCount) {
      ListPopup oldPopup = myPopup != null ? myPopup.get() : null;
      if (oldPopup != null && !oldPopup.isDisposed()) {
        oldPopup.cancel();
        myPopup = null;
        return true;
      }

      if (myContext == null) {
        return true;
      }

      ListPopup popup = createLanguagePopup();
      popup.showUnderneathOf(myChooseFactory);
      myPopup = new WeakReference<ListPopup>(popup);
      return true;
    }
  }.installOn(myChooseFactory);
}
项目:tools-idea    文件:StatusText.java   
public StatusText() {
  myClickListener = new ClickListener() {
    @Override
    public boolean onClick(MouseEvent e, int clickCount) {
      if (e.getButton() == MouseEvent.BUTTON1 && clickCount == 1) {
        ActionListener actionListener = findActionListenerAt(e.getPoint());
        if (actionListener != null) {
          actionListener.actionPerformed(new ActionEvent(this, 0, ""));
          return true;
        }
      }
      return false;
    }
  };

  myMouseMotionListener = new MouseAdapter() {
    @Override
    public void mouseMoved(final MouseEvent e) {
      if (findActionListenerAt(e.getPoint()) != null) {
        myMouseTarget.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
      }
      else {
        myMouseTarget.setCursor(Cursor.getDefaultCursor());
      }
    }
  };

  myComponent.setOpaque(false);
  myComponent.setFont(UIUtil.getLabelFont());
  setText(DEFAULT_EMPTY_TEXT, DEFAULT_ATTRIBUTES);
  myIsDefaultText = true;
}
项目:tools-idea    文件:OpenOrAttachDialog.java   
protected OpenOrAttachDialog(Project project, boolean hideReplace, final String title) {
  super(project);
  myHideReplace = hideReplace;
  setTitle(title);
  init();
  ClickListener listener = new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent event) {
      doOKAction();
      return true;
    }
  };
  listener.installOn(myCurrentWindowButton);
  listener.installOn(myOpenInNewWindowButton);

  final String mode = PropertiesComponent.getInstance().getValue(MODE_PROPERTY);
  if (MODE_NEW.equals(mode)) {
    myOpenInNewWindowButton.setSelected(true);
  }
  else if (mode == null || MODE_REPLACE.equals(mode) || hideReplace) {
    myCurrentWindowButton.setSelected(true);
    myAddCheckbox.setSelected(false);
  }
  else {
    myCurrentWindowButton.setSelected(true);
    myAddCheckbox.setSelected(true);
  }
  if (hideReplace) {
    myAddCheckbox.setVisible(false);
  }
  myAddCheckbox.setEnabled(myCurrentWindowButton.isSelected());
  final ActionListener listener1 = new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      myAddCheckbox.setEnabled(myCurrentWindowButton.isSelected());
    }
  };
  myCurrentWindowButton.addActionListener(listener1);
  myOpenInNewWindowButton.addActionListener(listener1);
}
项目:tools-idea    文件:IdeNotificationArea.java   
public IdeNotificationArea() {
  Disposer.register(this, myLogAlarm);
  UISettings.getInstance().addUISettingsListener(new UISettingsListener() {
    @Override
    public void uiSettingsChanged(UISettings source) {
      updateStatus();
    }
  }, this);
  new ClickListener() {
    @Override
    public boolean onClick(MouseEvent e, int clickCount) {
      EventLog.toggleLog(getProject());
      return true;
    }
  }.installOn(this);

  ApplicationManager.getApplication().getMessageBus().connect().subscribe(LogModel.LOG_MODEL_CHANGED, new Runnable() {
    @Override
    public void run() {
      ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
          updateStatus();
        }
      });
    }
  });
}
项目:tools-idea    文件:IdeFatalErrorsIcon.java   
public IdeFatalErrorsIcon(ActionListener aListener) {
  myListener = aListener;
  setBorder(BorderFactory.createEmptyBorder(0, 1, 0, 1));

  new ClickListener() {
    @Override
    public boolean onClick(MouseEvent e, int clickCount) {
      if (myState != State.NoErrors) {
        myListener.actionPerformed(null);
        return true;
      }
      return false;
    }
  }.installOn(this);

  myIcon = new LayeredIcon(AllIcons.Ide.FatalError, AllIcons.Ide.FatalError_read, AllIcons.Ide.EmptyFatalError) {
    @Override
    public synchronized void paintIcon(Component c, Graphics g, int x, int y) {
      super.paintIcon(c, g, x, y);
    }

    @Override
    public synchronized void setLayerEnabled(int layer, boolean enabled) {
      super.setLayerEnabled(layer, enabled);
    }
  };
  setIcon(myIcon);
}
项目:tools-idea    文件:TextFieldAction.java   
public JComponent createCustomComponent(Presentation presentation) {
  // honestly borrowed from SearchTextField

  final JPanel panel = new JPanel(new BorderLayout());
  final JLabel label = new JLabel(myIcon);
  label.setOpaque(true);
  label.setBackground(myField.getBackground());
  myField.setOpaque(true);
  panel.add(myField, BorderLayout.WEST);
  panel.add(label, BorderLayout.EAST);
  myField.setToolTipText(myDescription);
  label.setToolTipText(myDescription);
  final Border originalBorder;
  if (SystemInfo.isMac) {
    originalBorder = BorderFactory.createLoweredBevelBorder();
  }
  else {
    originalBorder = myField.getBorder();
  }

  panel.setBorder(new CompoundBorder(IdeBorderFactory.createEmptyBorder(4, 0, 4, 0), originalBorder));

  myField.setOpaque(true);
  myField.setBorder(IdeBorderFactory.createEmptyBorder(0, 5, 0, 5));

  new ClickListener() {
    @Override
    public boolean onClick(MouseEvent e, int clickCount) {
      actionPerformed(null);
      return true;
    }
  }.installOn(label);

  return panel;
}
项目:tools-idea    文件:TagsPanel.java   
public TagsPanel(final String popupTitle) {
  super(new BorderLayout());
  add(myTextLabel, BorderLayout.CENTER);
  add(myMoreLabel, BorderLayout.EAST);

  new ClickListener() {
    @Override
    public boolean onClick(MouseEvent e, int clickCount) {
      showTags();
      return true;
    }
  }.installOn(myMoreLabel);

  myPopupTitle = popupTitle;
}
项目:consulo    文件:VcsLogPopupComponent.java   
private void showPopupMenuOnClick() {
  new ClickListener() {
    @Override
    public boolean onClick(@Nonnull MouseEvent event, int clickCount) {
      showPopupMenu();
      return true;
    }
  }.installOn(this);
}