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

项目:intellij-ce-playground    文件:DebuggerAction.java   
public static Disposable installEditAction(final JTree tree, String actionName) {
  final DoubleClickListener listener = new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      if (tree.getPathForLocation(e.getX(), e.getY()) == null) return false;
      DataContext dataContext = DataManager.getInstance().getDataContext(tree);
      GotoFrameSourceAction.doAction(dataContext);
      return true;
    }
  };
  listener.installOn(tree);

  final AnAction action = ActionManager.getInstance().getAction(actionName);
  action.registerCustomShortcutSet(CommonShortcuts.getEditSource(), tree);

  return new Disposable() {
    public void dispose() {
      listener.uninstall(tree);
      action.unregisterCustomShortcutSet(tree);
    }
  };
}
项目:intellij-ce-playground    文件:SimpleFieldChooser.java   
@Override
protected JComponent createCenterPanel() {
  final DefaultListModel model = new DefaultListModel ();
  for (PsiField member : myFields) {
    model.addElement(member);
  }
  myList = new JBList(model);
  myList.setCellRenderer(new MyListCellRenderer());
  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      if (myList.getSelectedValues().length > 0) {
        doOKAction();
        return true;
      }
      return false;
    }
  }.installOn(myList);

  myList.setPreferredSize(JBUI.size(300, 400));
  return myList;
}
项目:intellij-ce-playground    文件:ConvertToInstanceMethodDialog.java   
@Override
protected JList createTargetVariableChooser() {
  final JList variableChooser = super.createTargetVariableChooser();
  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      Point point = e.getPoint();
      int index = variableChooser.locationToIndex(point);
      if (index == -1) return false;
      if (!variableChooser.getCellBounds(index, index).contains(point)) return false;
      doRefactorAction();
      return true;
    }
  }.installOn(variableChooser);
  return variableChooser;
}
项目:intellij-ce-playground    文件:JdkChooserPanel.java   
private static Sdk showDialog(final Project project, String title, final Component parent, Sdk jdkToSelect) {
  final JdkChooserPanel jdkChooserPanel = new JdkChooserPanel(project);
  jdkChooserPanel.fillList(null, null);
  final MyDialog dialog = jdkChooserPanel.new MyDialog(parent);
  if (title != null) {
    dialog.setTitle(title);
  }
  if (jdkToSelect != null) {
    jdkChooserPanel.selectJdk(jdkToSelect);
  }
  else {
    ScrollingUtil.ensureSelectionExists(jdkChooserPanel.myList);
  }
  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      dialog.clickDefaultButton();
      return true;
    }
  }.installOn(jdkChooserPanel.myList);
  return dialog.showAndGet() ? jdkChooserPanel.getChosenJdk() : null;
}
项目:intellij-ce-playground    文件:ChooseActionsDialog.java   
public ChooseActionsDialog(Component parent, Keymap keymap, QuickList[] quicklists) {
  super(parent, true);
  myKeymap = keymap;
  myQuicklists = quicklists;

  myActionsTree = new ActionsTree();
  myActionsTree.reset(keymap, quicklists);
  myActionsTree.getTree().getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);

  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      doOKAction();
      return true;
    }
  }.installOn(myActionsTree.getTree());


  myTreeExpansionMonitor = TreeExpansionMonitor.install(myActionsTree.getTree());

  setTitle("Add Actions to Quick List");
  init();
}
项目:intellij-ce-playground    文件:CreateTaskFileDialog.java   
@Nullable
@Override
protected JComponent createCenterPanel() {
  myList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  myList.setCellRenderer(new FileTypeRenderer());

  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      doOKAction();
      return true;
    }
  }.installOn(myList);

  CCLanguageManager manager = CCUtils.getStudyLanguageManager(myCourse);
  if (manager != null) {
    String extension = manager.getDefaultTaskFileExtension();
    ScrollingUtil.selectItem(myList, FileTypeManager.getInstance().getFileTypeByExtension(extension != null ? extension : "txt"));
  }
  return myPanel;
}
项目:tools-idea    文件:DebuggerAction.java   
public static Disposable installEditAction(final JTree tree, String actionName) {
  final DoubleClickListener listener = new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      if (tree.getPathForLocation(e.getX(), e.getY()) == null) return false;
      DataContext dataContext = DataManager.getInstance().getDataContext(tree);
      GotoFrameSourceAction.doAction(dataContext);
      return true;
    }
  };
  listener.installOn(tree);

  final AnAction action = ActionManager.getInstance().getAction(actionName);
  action.registerCustomShortcutSet(CommonShortcuts.getEditSource(), tree);

  return new Disposable() {
    public void dispose() {
      listener.uninstall(tree);
      action.unregisterCustomShortcutSet(tree);
    }
  };
}
项目:tools-idea    文件:SimpleFieldChooser.java   
@Override
protected JComponent createCenterPanel() {
  final DefaultListModel model = new DefaultListModel ();
  for (PsiField member : myFields) {
    model.addElement(member);
  }
  myList = new JBList(model);
  myList.setCellRenderer(new MyListCellRenderer());
  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      if (myList.getSelectedValues().length > 0) {
        doOKAction();
        return true;
      }
      return false;
    }
  }.installOn(myList);

  myList.setPreferredSize(new Dimension(300, 400));
  return myList;
}
项目:tools-idea    文件:ConvertToInstanceMethodDialog.java   
@Override
protected JList createTargetVariableChooser() {
  final JList variableChooser = super.createTargetVariableChooser();
  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      Point point = e.getPoint();
      int index = variableChooser.locationToIndex(point);
      if (index == -1) return false;
      if (!variableChooser.getCellBounds(index, index).contains(point)) return false;
      doRefactorAction();
      return true;
    }
  }.installOn(variableChooser);
  return variableChooser;
}
项目:tools-idea    文件:JdkChooserPanel.java   
private static Sdk showDialog(final Project project, String title, final Component parent, Sdk jdkToSelect) {
  final JdkChooserPanel jdkChooserPanel = new JdkChooserPanel(project);
  jdkChooserPanel.fillList(null, null);
  final MyDialog dialog = jdkChooserPanel.new MyDialog(parent);
  if (title != null) {
    dialog.setTitle(title);
  }
  if (jdkToSelect != null) {
    jdkChooserPanel.selectJdk(jdkToSelect);
  } else {
    ListScrollingUtil.ensureSelectionExists(jdkChooserPanel.myList);
  }
  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      dialog.clickDefaultButton();
      return true;
    }
  }.installOn(jdkChooserPanel.myList);
  dialog.show();
  return dialog.isOK() ? jdkChooserPanel.getChosenJdk() : null;
}
项目:tools-idea    文件:ChooseActionsDialog.java   
public ChooseActionsDialog(Component parent, Keymap keymap, QuickList[] quicklists) {
  super(parent, true);
  myKeymap = keymap;
  myQuicklists = quicklists;

  myActionsTree = new ActionsTree();
  myActionsTree.reset(keymap, quicklists);
  myActionsTree.getTree().getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);

  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      doOKAction();
      return true;
    }
  }.installOn(myActionsTree.getTree());


  myTreeExpansionMonitor = TreeExpansionMonitor.install(myActionsTree.getTree());

  setTitle("Add Actions to Quick List");
  init();
}
项目:intellij-plugin-v4    文件:LiteralChooser.java   
@Nullable
    @Override
    protected JComponent createCenterPanel() {
        JPanel panel = new JPanel(new BorderLayout());
        new DoubleClickListener() {
            @Override
            protected boolean onDoubleClick(MouseEvent e) {
                if (tree.getPathForLocation(e.getX(), e.getY()) != null) {
                    doOKAction();
                    return true;
                }
                return false;
            }
        }.installOn(tree);

        TreeUtil.installActions(tree);
        JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(tree);
//      scrollPane.setPreferredSize(new Dimension(350, 450));
        panel.add(scrollPane, BorderLayout.CENTER);

        return panel;
    }
项目:consulo    文件:FileTypeChooser.java   
@Override
protected JComponent createCenterPanel() {
  myTitleLabel.setText(FileTypesBundle.message("filetype.chooser.prompt", myFileName));

  myList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  myList.setCellRenderer(new FileTypeRenderer());

  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      doOKAction();
      return true;
    }
  }.installOn(myList);

  myList.getSelectionModel().addListSelectionListener(e -> updateButtonsState());

  ScrollingUtil.selectItem(myList, PlainTextFileType.INSTANCE);

  return myPanel;
}
项目:consulo    文件:ChooseActionsDialog.java   
public ChooseActionsDialog(Component parent, Keymap keymap, QuickList[] quicklists) {
  super(parent, true);
  myKeymap = keymap;
  myQuicklists = quicklists;

  myActionsTree = new ActionsTree();
  myActionsTree.reset(keymap, quicklists);
  myActionsTree.getTree().getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);

  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      doOKAction();
      return true;
    }
  }.installOn(myActionsTree.getTree());


  myTreeExpansionMonitor = TreeExpansionMonitor.install(myActionsTree.getTree());

  setTitle("Add Actions to Quick List");
  init();
}
项目:consulo-java    文件:SimpleFieldChooser.java   
@Override
protected JComponent createCenterPanel() {
  final DefaultListModel model = new DefaultListModel ();
  for (PsiField member : myFields) {
    model.addElement(member);
  }
  myList = new JBList(model);
  myList.setCellRenderer(new MyListCellRenderer());
  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      if (myList.getSelectedValues().length > 0) {
        doOKAction();
        return true;
      }
      return false;
    }
  }.installOn(myList);

  myList.setPreferredSize(new Dimension(300, 400));
  return myList;
}
项目:consulo-java    文件:ConvertToInstanceMethodDialog.java   
@Override
protected JList createTargetVariableChooser() {
  final JList variableChooser = super.createTargetVariableChooser();
  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      Point point = e.getPoint();
      int index = variableChooser.locationToIndex(point);
      if (index == -1) return false;
      if (!variableChooser.getCellBounds(index, index).contains(point)) return false;
      doRefactorAction();
      return true;
    }
  }.installOn(variableChooser);
  return variableChooser;
}
项目:intellij-ce-playground    文件:GetJPDADialog.java   
protected JComponent createCenterPanel() {
  final JPanel _panel1 = new JPanel(new BorderLayout());

  JPanel _panel2 = new JPanel(new BorderLayout());
  _panel2.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
  //"Debug libraries are missig from JDK home.\nIn order for debugger to start, the libraries should be installed.\nPlease visit http://java.sun.com/products/jpda"
  JLabel label1 = new JLabel(DebuggerBundle.message("label.get.jpda.dialog.prompt"));
  //label1.setForeground(Color.black);
  JLabel label2 = new JLabel(JPDA_URL);
  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      BrowserUtil.browse(JPDA_URL);
      return true;
    }
  }.installOn(label2);
  label2.setForeground(JBColor.BLUE.darker());
  label2.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
  _panel2.add(new JLabel(DebuggerBundle.message("label.get.jpda.dialog.error.description")), BorderLayout.NORTH);
  _panel2.add(label1, BorderLayout.WEST);
  _panel2.add(label2, BorderLayout.EAST);
  _panel1.add(_panel2, BorderLayout.NORTH);

  JPanel content = new JPanel(new GridLayout(2, 1, 10, 10));

  _panel1.add(content, BorderLayout.CENTER);
  return _panel1;
}
项目:intellij-ce-playground    文件:EditSourceOnDoubleClickHandler.java   
public static void install(final TreeTable treeTable) {
  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      if (ModalityState.current().dominates(ModalityState.NON_MODAL)) return false;
      if (treeTable.getTree().getPathForLocation(e.getX(), e.getY()) == null) return false;
      DataContext dataContext = DataManager.getInstance().getDataContext(treeTable);
      Project project = CommonDataKeys.PROJECT.getData(dataContext);
      if (project == null) return false;
      OpenSourceUtil.openSourcesFrom(dataContext, true);
      return true;
    }
  }.installOn(treeTable);
}
项目:intellij-ce-playground    文件:EditSourceOnDoubleClickHandler.java   
public static void install(final JTable table) {
  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      if (ModalityState.current().dominates(ModalityState.NON_MODAL)) return false;
      if (table.columnAtPoint(e.getPoint()) < 0) return false;
      if (table.rowAtPoint(e.getPoint()) < 0) return false;
      DataContext dataContext = DataManager.getInstance().getDataContext(table);
      Project project = CommonDataKeys.PROJECT.getData(dataContext);
      if (project == null) return false;
      OpenSourceUtil.openSourcesFrom(dataContext, true);
      return true;
    }
  }.installOn(table);
}
项目:intellij-ce-playground    文件:EditSourceOnDoubleClickHandler.java   
public static void install(final JList list, final Runnable whenPerformed) {
  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      Point point = e.getPoint();
      int index = list.locationToIndex(point);
      if (index == -1) return false;
      if (!list.getCellBounds(index, index).contains(point)) return false;
      DataContext dataContext = DataManager.getInstance().getDataContext(list);
      OpenSourceUtil.openSourcesFrom(dataContext, true);
      whenPerformed.run();
      return true;
    }
  }.installOn(list);
}
项目:intellij-ce-playground    文件:StatisticsPanel.java   
public StatisticsPanel(final Project project, final TestFrameworkRunningModel model) {
  myProject = project;
  myTableModel = new StatisticsTableModel();
  myStatisticsTableView.setModelAndUpdateColumns(myTableModel);
  myFrameworkRunningModel = model;

  final Runnable gotoSuiteOrParentAction = createGotoSuiteOrParentAction();
  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      gotoSuiteOrParentAction.run();
      return true;
    }
  }.installOn(myStatisticsTableView);

  // Fire selection changed and move focus on SHIFT+ENTER
  final KeyStroke shiftEnterKey = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_MASK);
  SMRunnerUtil.registerAsAction(shiftEnterKey, "select-test-proxy-in-test-view",
                          new Runnable() {
                            public void run() {
                              showSelectedProxyInTestsTree();
                            }
                          },
                          myStatisticsTableView);

  // Expand selected or go to parent on ENTER
  final KeyStroke enterKey = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
  SMRunnerUtil.registerAsAction(enterKey, "go-to-selected-suite-or-parent",
                          gotoSuiteOrParentAction,
                          myStatisticsTableView);
  // Contex menu in Table
  PopupHandler.installPopupHandler(myStatisticsTableView, IdeActions.GROUP_TESTTREE_POPUP, ActionPlaces.TESTTREE_VIEW_POPUP);
  // set this statistic tab as dataprovider for test's table view
  DataManager.registerDataProvider(myStatisticsTableView, 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    文件:ChooseClassDialog.java   
public ChooseClassDialog(Module module, String title, boolean includeAll, String... classes) {
  super(module.getProject());

  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      if (myList.getSelectedValue() != null) {
        close(OK_EXIT_CODE);
        return true;
      }
      return false;
    }
  }.installOn(myList);

  DefaultListModel model = new DefaultListModel();
  findClasses(module, includeAll, model, classes);
  myList.setModel(model);
  myList.setCellRenderer(new DefaultPsiElementCellRenderer());

  ListSelectionModel selectionModel = myList.getSelectionModel();
  selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  selectionModel.addListSelectionListener(this);

  new ListSpeedSearch(myList) {
    @Override
    protected boolean isMatchingElement(Object element, String pattern) {
      PsiClass psiClass = (PsiClass)element;
      return compare(psiClass.getName(), pattern) || compare(psiClass.getQualifiedName(), pattern);
    }
  };

  setTitle(title);
  setOKActionEnabled(false);

  init();

  Dimension size = myComponent.getPreferredSize();
  size.height = myList.getPreferredSize().height + 20;
  myComponent.setPreferredSize(size);
}
项目:intellij-ce-playground    文件:TestNGResults.java   
public TestNGResults(final JComponent component,
                     final TestNGConfiguration configuration,
                     final TestNGConsoleView console) {
  super(component, console.getConsole().createConsoleActions(), console.getProperties(),
        TESTNG_SPLITTER_PROPERTY, 0.5f);
  this.configuration = configuration;
  this.project = configuration.getProject();

  model = new TestNGResultsTableModel(project);
  resultsTable = new TableView(model);
  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      final Object result = resultsTable.getSelectedObject();
      if (result instanceof TestResultMessage) {
        final String testClass = ((TestResultMessage)result).getTestClass();
        final PsiClass psiClass = ClassUtil.findPsiClass(PsiManager.getInstance(project), testClass);
        if (psiClass != null) {
          final String method = ((TestResultMessage)result).getMethod();
          if (method != null) {
            final PsiMethod[] psiMethods = psiClass.findMethodsByName(method, false);
            if (psiMethods.length > 0) {
              psiMethods[0].navigate(true);
            }
          }
          psiClass.navigate(true);
          return true;
        }
      }
      return false;
    }
  }.installOn(resultsTable);

  rootNode = new TreeRootNode();
  console.getUnboundOutput().addChild(rootNode);
}
项目:tools-idea    文件:GetJPDADialog.java   
protected JComponent createCenterPanel() {
  final JPanel _panel1 = new JPanel(new BorderLayout());

  JPanel _panel2 = new JPanel(new BorderLayout());
  _panel2.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
  //"Debug libraries are missig from JDK home.\nIn order for debugger to start, the libraries should be installed.\nPlease visit http://java.sun.com/products/jpda"
  JLabel label1 = new JLabel(DebuggerBundle.message("label.get.jpda.dialog.prompt"));
  //label1.setForeground(Color.black);
  JLabel label2 = new JLabel(JPDA_URL);
  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      BrowserUtil.launchBrowser(JPDA_URL);
      return true;
    }
  }.installOn(label2);
  label2.setForeground(JBColor.BLUE.darker());
  label2.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
  _panel2.add(new JLabel(DebuggerBundle.message("label.get.jpda.dialog.error.description")), BorderLayout.NORTH);
  _panel2.add(label1, BorderLayout.WEST);
  _panel2.add(label2, BorderLayout.EAST);
  _panel1.add(_panel2, BorderLayout.NORTH);

  JPanel content = new JPanel(new GridLayout(2, 1, 10, 10));

  _panel1.add(content, BorderLayout.CENTER);
  return _panel1;
}
项目:tools-idea    文件:EditSourceOnDoubleClickHandler.java   
public static void install(final TreeTable treeTable) {
  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      if (ModalityState.current().dominates(ModalityState.NON_MODAL)) return false;
      if (treeTable.getTree().getPathForLocation(e.getX(), e.getY()) == null) return false;
      DataContext dataContext = DataManager.getInstance().getDataContext(treeTable);
      Project project = PlatformDataKeys.PROJECT.getData(dataContext);
      if (project == null) return false;
      OpenSourceUtil.openSourcesFrom(dataContext, true);
      return true;
    }
  }.installOn(treeTable);
}
项目:tools-idea    文件:EditSourceOnDoubleClickHandler.java   
public static void install(final JTable table) {
  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      if (ModalityState.current().dominates(ModalityState.NON_MODAL)) return false;
      if (table.columnAtPoint(e.getPoint()) < 0) return false;
      if (table.rowAtPoint(e.getPoint()) < 0) return false;
      DataContext dataContext = DataManager.getInstance().getDataContext(table);
      Project project = PlatformDataKeys.PROJECT.getData(dataContext);
      if (project == null) return false;
      OpenSourceUtil.openSourcesFrom(dataContext, true);
      return true;
    }
  }.installOn(table);
}
项目:tools-idea    文件:EditSourceOnDoubleClickHandler.java   
public static void install(final JList list, final Runnable whenPerformed) {
  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      Point point = e.getPoint();
      int index = list.locationToIndex(point);
      if (index == -1) return false;
      if (!list.getCellBounds(index, index).contains(point)) return false;
      DataContext dataContext = DataManager.getInstance().getDataContext(list);
      OpenSourceUtil.openSourcesFrom(dataContext, true);
      whenPerformed.run();
      return true;
    }
  }.installOn(list);
}
项目:tools-idea    文件:StatisticsPanel.java   
public StatisticsPanel(final Project project, final TestFrameworkRunningModel model) {
  myProject = project;
  myTableModel = new StatisticsTableModel();
  myStatisticsTableView.setModelAndUpdateColumns(myTableModel);
  myFrameworkRunningModel = model;

  final Runnable gotoSuiteOrParentAction = createGotoSuiteOrParentAction();
  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      gotoSuiteOrParentAction.run();
      return true;
    }
  }.installOn(myStatisticsTableView);

  // Fire selection changed and move focus on SHIFT+ENTER
  final KeyStroke shiftEnterKey = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_MASK);
  SMRunnerUtil.registerAsAction(shiftEnterKey, "select-test-proxy-in-test-view",
                          new Runnable() {
                            public void run() {
                              showSelectedProxyInTestsTree();
                            }
                          },
                          myStatisticsTableView);

  // Expand selected or go to parent on ENTER
  final KeyStroke enterKey = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
  SMRunnerUtil.registerAsAction(enterKey, "go-to-selected-suite-or-parent",
                          gotoSuiteOrParentAction,
                          myStatisticsTableView);
  // Contex menu in Table
  PopupHandler.installPopupHandler(myStatisticsTableView, IdeActions.GROUP_TESTTREE_POPUP, ActionPlaces.TESTTREE_VIEW_POPUP);
  // set this statistic tab as dataprovider for test's table view
  DataManager.registerDataProvider(myStatisticsTableView, this);
}
项目: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    文件:TestNGResults.java   
public TestNGResults(final JComponent component,
                     final TestNGConfiguration configuration,
                     final TestNGConsoleView console,
                     final ExecutionEnvironment environment) {
  super(component, console.getConsole().createConsoleActions(), console.getProperties(),
        environment, TESTNG_SPLITTER_PROPERTY, 0.5f);
  this.project = configuration.getProject();

  model = new TestNGResultsTableModel(project);
  resultsTable = new TableView(model);
  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      final Object result = resultsTable.getSelectedObject();
      if (result instanceof TestResultMessage) {
        final String testClass = ((TestResultMessage)result).getTestClass();
        final PsiClass psiClass = ClassUtil.findPsiClass(PsiManager.getInstance(project), testClass);
        if (psiClass != null) {
          final String method = ((TestResultMessage)result).getMethod();
          if (method != null) {
            final PsiMethod[] psiMethods = psiClass.findMethodsByName(method, false);
            if (psiMethods.length > 0) {
              psiMethods[0].navigate(true);
            }
          }
          psiClass.navigate(true);
          return true;
        }
      }
      return false;
    }
  }.installOn(resultsTable);

  rootNode = new TreeRootNode();
  console.getUnboundOutput().addChild(rootNode);
}
项目:consulo    文件:StatisticsPanel.java   
public StatisticsPanel(final Project project, final TestFrameworkRunningModel model) {
  myProject = project;
  myTableModel = new StatisticsTableModel();
  myStatisticsTableView.setModelAndUpdateColumns(myTableModel);
  myFrameworkRunningModel = model;

  final Runnable gotoSuiteOrParentAction = createGotoSuiteOrParentAction();
  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      gotoSuiteOrParentAction.run();
      return true;
    }
  }.installOn(myStatisticsTableView);

  // Fire selection changed and move focus on SHIFT+ENTER
  final KeyStroke shiftEnterKey = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_MASK);
  SMRunnerUtil.registerAsAction(shiftEnterKey, "select-test-proxy-in-test-view",
                          new Runnable() {
                            public void run() {
                              showSelectedProxyInTestsTree();
                            }
                          },
                          myStatisticsTableView);

  // Expand selected or go to parent on ENTER
  final KeyStroke enterKey = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
  SMRunnerUtil.registerAsAction(enterKey, "go-to-selected-suite-or-parent",
                          gotoSuiteOrParentAction,
                          myStatisticsTableView);
  // Contex menu in Table
  PopupHandler.installPopupHandler(myStatisticsTableView, IdeActions.GROUP_TESTTREE_POPUP, ActionPlaces.TESTTREE_VIEW_POPUP);
  // set this statistic tab as dataprovider for test's table view
  DataManager.registerDataProvider(myStatisticsTableView, this);
}
项目:consulo    文件:EditSourceOnDoubleClickHandler.java   
public static void install(final TreeTable treeTable) {
  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      if (ModalityState.current().dominates(ModalityState.NON_MODAL)) return false;
      if (treeTable.getTree().getPathForLocation(e.getX(), e.getY()) == null) return false;
      DataContext dataContext = DataManager.getInstance().getDataContext(treeTable);
      Project project = dataContext.getData(CommonDataKeys.PROJECT);
      if (project == null) return false;
      OpenSourceUtil.openSourcesFrom(dataContext, true);
      return true;
    }
  }.installOn(treeTable);
}
项目:consulo    文件:EditSourceOnDoubleClickHandler.java   
public static void install(final JTable table) {
  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      if (ModalityState.current().dominates(ModalityState.NON_MODAL)) return false;
      if (table.columnAtPoint(e.getPoint()) < 0) return false;
      if (table.rowAtPoint(e.getPoint()) < 0) return false;
      DataContext dataContext = DataManager.getInstance().getDataContext(table);
      Project project = dataContext.getData(CommonDataKeys.PROJECT);
      if (project == null) return false;
      OpenSourceUtil.openSourcesFrom(dataContext, true);
      return true;
    }
  }.installOn(table);
}
项目:consulo    文件:EditSourceOnDoubleClickHandler.java   
public static void install(final JList list, final Runnable whenPerformed) {
  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      Point point = e.getPoint();
      int index = list.locationToIndex(point);
      if (index == -1) return false;
      if (!list.getCellBounds(index, index).contains(point)) return false;
      DataContext dataContext = DataManager.getInstance().getDataContext(list);
      OpenSourceUtil.openSourcesFrom(dataContext, true);
      whenPerformed.run();
      return true;
    }
  }.installOn(list);
}
项目:consulo-java    文件:MethodListDlg.java   
public MethodListDlg(final PsiClass psiClass, final Condition<PsiMethod> filter, final JComponent parent)
{
    super(parent, false);
    myClass = psiClass;
    createList(psiClass.getAllMethods(), filter);
    myWholePanel.add(ScrollPaneFactory.createScrollPane(myList));
    myList.setCellRenderer(new ColoredListCellRenderer()
    {
        protected void customizeCellRenderer(@NotNull final JList list, final Object value, final int index, final boolean selected, final boolean hasFocus)
        {
            final PsiMethod psiMethod = (PsiMethod) value;
            append(PsiFormatUtil.formatMethod(psiMethod, PsiSubstitutor.EMPTY, PsiFormatUtil.SHOW_NAME, 0), StructureNodeRenderer.applyDeprecation(psiMethod, SimpleTextAttributes
                    .REGULAR_ATTRIBUTES));
            final PsiClass containingClass = psiMethod.getContainingClass();
            if(!myClass.equals(containingClass))
            {
                append(" (" + containingClass.getQualifiedName() + ")", StructureNodeRenderer.applyDeprecation(containingClass, SimpleTextAttributes.GRAY_ATTRIBUTES));
            }
        }
    });
    myList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    new DoubleClickListener()
    {
        @Override
        protected boolean onDoubleClick(MouseEvent e)
        {
            MethodListDlg.this.close(OK_EXIT_CODE);
            return true;
        }
    }.installOn(myList);

    ScrollingUtil.ensureSelectionExists(myList);
    TreeUIHelper.getInstance().installListSpeedSearch(myList);
    setTitle(ExecutionBundle.message("choose.test.method.dialog.title"));
    init();
}
项目:consulo-java    文件:DebuggerAction.java   
public static Disposable installEditAction(final JTree tree, String actionName)
{
    final DoubleClickListener listener = new DoubleClickListener()
    {
        @Override
        protected boolean onDoubleClick(MouseEvent e)
        {
            if(tree.getPathForLocation(e.getX(), e.getY()) == null)
            {
                return false;
            }
            DataContext dataContext = DataManager.getInstance().getDataContext(tree);
            GotoFrameSourceAction.doAction(dataContext);
            return true;
        }
    };
    listener.installOn(tree);

    final AnAction action = ActionManager.getInstance().getAction(actionName);
    action.registerCustomShortcutSet(CommonShortcuts.getEditSource(), tree);

    return new Disposable()
    {
        public void dispose()
        {
            listener.uninstall(tree);
            action.unregisterCustomShortcutSet(tree);
        }
    };
}
项目:consulo-java    文件:GetJPDADialog.java   
protected JComponent createCenterPanel() {
  final JPanel _panel1 = new JPanel(new BorderLayout());

  JPanel _panel2 = new JPanel(new BorderLayout());
  _panel2.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
  //"Debug libraries are missig from JDK home.\nIn order for debugger to start, the libraries should be installed.\nPlease visit http://java.sun.com/products/jpda"
  JLabel label1 = new JLabel(DebuggerBundle.message("label.get.jpda.dialog.prompt"));
  //label1.setForeground(Color.black);
  JLabel label2 = new JLabel(JPDA_URL);
  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      BrowserUtil.browse(JPDA_URL);
      return true;
    }
  }.installOn(label2);
  label2.setForeground(JBColor.BLUE.darker());
  label2.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
  _panel2.add(new JLabel(DebuggerBundle.message("label.get.jpda.dialog.error.description")), BorderLayout.NORTH);
  _panel2.add(label1, BorderLayout.WEST);
  _panel2.add(label2, BorderLayout.EAST);
  _panel1.add(_panel2, BorderLayout.NORTH);

  JPanel content = new JPanel(new GridLayout(2, 1, 10, 10));

  _panel1.add(content, BorderLayout.CENTER);
  return _panel1;
}
项目:consulo    文件:ServersToolWindowContent.java   
public ServersToolWindowContent(@Nonnull Project project) {
  super(new BorderLayout());
  myProject = project;

  myTreeModel = new DefaultTreeModel(new DefaultMutableTreeNode());
  myTree = new Tree(myTreeModel);
  myTree.setRootVisible(false);

  myTree.setShowsRootHandles(true);
  myTree.setCellRenderer(new NodeRenderer());
  myTree.setLineStyleAngled();

  getMainPanel().add(createToolbar(), BorderLayout.WEST);
  Splitter splitter = new OnePixelSplitter(false, 0.3f);
  splitter.setFirstComponent(ScrollPaneFactory.createScrollPane(myTree, SideBorder.LEFT));
  myPropertiesPanelLayout = new CardLayout();
  myPropertiesPanel = new JPanel(myPropertiesPanelLayout);
  myMessageLabel = new JLabel(EMPTY_SELECTION_MESSAGE, SwingConstants.CENTER);
  myPropertiesPanel.add(MESSAGE_CARD, new Wrapper(myMessageLabel));
  splitter.setSecondComponent(myPropertiesPanel);
  getMainPanel().add(splitter, BorderLayout.CENTER);

  setupBuilder(project);

  for (RemoteServersViewContributor contributor : RemoteServersViewContributor.EP_NAME.getExtensions()) {
    contributor.setupTree(myProject, myTree, myBuilder);
  }

  myTree.addTreeSelectionListener(new TreeSelectionListener() {
    @Override
    public void valueChanged(TreeSelectionEvent e) {
      onSelectionChanged();
    }
  });
  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent event) {
      Set<ServersTreeStructure.RemoteServerNode> nodes = getSelectedRemoteServerNodes();
      if (nodes.size() == 1) {
        RemoteServer<?> server = nodes.iterator().next().getValue();
        ServerConnectionManager.getInstance().getOrCreateConnection(server).computeDeployments(EmptyRunnable.INSTANCE);
        return true;
      }
      return false;
    }
  }.installOn(myTree);
}
项目:consulo-java    文件:InstancesWindow.java   
MyInstancesView(@NotNull XDebugSession session)
{
    super(new BorderLayout(0, JBUI.scale(BORDER_LAYOUT_DEFAULT_GAP)));

    Disposer.register(InstancesWindow.this.myDisposable, this);
    final XValueMarkers<?, ?> markers = getValueMarkers(session);
    if(markers != null)
    {
        final MyActionListener listener = new MyActionListener(markers);
        ActionManager.getInstance().addAnActionListener(listener, InstancesWindow.this.myDisposable);
    }
    session.addSessionListener(myDebugSessionListener, InstancesWindow.this.myDisposable);
    final JavaDebuggerEditorsProvider editorsProvider = new JavaDebuggerEditorsProvider();

    myFilterConditionEditor = new ExpressionEditorWithHistory(myProject, myClassName, editorsProvider, InstancesWindow.this.myDisposable);

    myFilterButton.setBorder(BorderFactory.createEmptyBorder());
    final Dimension filteringButtonSize = myFilterConditionEditor.getEditorComponent().getPreferredSize();
    filteringButtonSize.width = JBUI.scale(FILTERING_BUTTON_ADDITIONAL_WIDTH) + myFilterButton.getPreferredSize().width;
    myFilterButton.setPreferredSize(filteringButtonSize);

    final JBPanel filteringPane = new JBPanel(new BorderLayout(JBUI.scale(BORDER_LAYOUT_DEFAULT_GAP), 0));
    final JBLabel sideEffectsWarning = new JBLabel("Warning: filtering may have side effects", SwingConstants.RIGHT);
    sideEffectsWarning.setBorder(JBUI.Borders.empty(1, 0, 0, 0));
    sideEffectsWarning.setComponentStyle(UIUtil.ComponentStyle.SMALL);
    sideEffectsWarning.setFontColor(UIUtil.FontColor.BRIGHTER);

    filteringPane.add(new JBLabel("Condition:"), BorderLayout.WEST);
    filteringPane.add(myFilterConditionEditor.getComponent(), BorderLayout.CENTER);
    filteringPane.add(myFilterButton, BorderLayout.EAST);
    filteringPane.add(sideEffectsWarning, BorderLayout.SOUTH);

    myProgress.addStopActionListener(this::cancelFilteringTask);

    myInstancesTree = new InstancesTree(myProject, editorsProvider, markers, this::updateInstances);

    myFilterButton.addActionListener(e ->
    {
        final String expression = myFilterConditionEditor.getExpression().getExpression();
        if(!expression.isEmpty())
        {
            myFilterConditionEditor.saveTextInHistory();
        }

        myFilterButton.setEnabled(false);
        myInstancesTree.rebuildTree(InstancesTree.RebuildPolicy.RELOAD_INSTANCES);
    });


    final StackFrameList list = new StackFrameList(myDebugProcess);

    list.addListSelectionListener(e -> list.navigateToSelectedValue(false));
    new DoubleClickListener()
    {
        @Override
        protected boolean onDoubleClick(MouseEvent event)
        {
            list.navigateToSelectedValue(true);
            return true;
        }
    }.installOn(list);

    final InstancesWithStackFrameView instancesWithStackFrame = new InstancesWithStackFrameView(session, myInstancesTree, list, myClassName);

    add(filteringPane, BorderLayout.NORTH);
    add(instancesWithStackFrame.getComponent(), BorderLayout.CENTER);

    final JComponent focusedComponent = myFilterConditionEditor.getEditorComponent();
    UiNotifyConnector.doWhenFirstShown(focusedComponent, () -> IdeFocusManager.findInstanceByComponent(focusedComponent).requestFocus(focusedComponent, true));
}