コード例 #1
0
  @Nullable
  @Override
  protected JComponent createCenterPanel() {
    myPanel.setSplitterProportionKey(getClass().getName() + "ModelTreeSplitter");
    myTree = new ModelDifferenceDialog.ModelDifferenceTree();
    myPanel.setFirstComponent(ScrollPaneFactory.createScrollPane(myTree));
    myPanel.setSecondComponent(myNoRootPanel);

    myGoToNeighbourRootActions = new ModelDifferenceDialog.MyGoToNeighbourRootActions();
    myGoToNeighbourRootActions
        .previous()
        .registerCustomShortcutSet(GoToNeighbourRootActions.PREV_ROOT_SHORTCUT, myComponent);
    myGoToNeighbourRootActions
        .next()
        .registerCustomShortcutSet(GoToNeighbourRootActions.NEXT_ROOT_SHORTCUT, myComponent);

    myToolbar =
        ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, myActionGroup, true);
    myToolbar.updateActionsImmediately();

    myComponent.add(myToolbar.getComponent(), BorderLayout.NORTH);
    myComponent.add(myPanel, BorderLayout.CENTER);
    myComponent.add(myStatusBar, BorderLayout.SOUTH);

    Dimension size = DimensionService.getInstance().getSize(getDimensionServiceKey());
    if (size == null) {
      myComponent.setPreferredSize(new Dimension(500, 700));
    }

    return myComponent;
  }
コード例 #2
0
  @Override
  protected void createTool() {
    myHierarchyTree = createHierarchyTree(false);
    myOccurenceNavigator =
        new OccurenceNavigatorSupport(myHierarchyTree) {
          @Nullable
          @Override
          protected Navigatable createDescriptorForNode(DefaultMutableTreeNode node) {
            if (!(node instanceof HierarchyTreeNode)) {
              return null;
            }

            SNodeReference ptr = ((HierarchyTreeNode) node).getNodeReference();

            Navigatable n = new NodeNavigatable(getMPSProject(), ptr);
            return (n.canNavigate() ? n : null);
          }

          @Override
          public String getPreviousOccurenceActionName() {
            return UsageViewBundle.message("action.previous.occurrence");
          }

          @Override
          public String getNextOccurenceActionName() {
            return UsageViewBundle.message("action.next.occurrence");
          }
        };
    myHierarchyTree.setRootVisible(true);
    this.myComponent = new AbstractHierarchyView.RootPanel();
    myScrollPane = ScrollPaneFactory.createScrollPane(myHierarchyTree, true);
    myComponent.setContent(myScrollPane);
    showItemInHierarchy(null);
    createControlPanel();
  }
コード例 #3
0
  public VariablesPanel(Project project, DebuggerStateManager stateManager, Disposable parent) {
    super(project, stateManager);

    setBorder(null);

    final FrameVariablesTree frameTree = getFrameTree();

    myCards = new JPanel(new CardLayout());
    myCards.add(frameTree, TREE);

    myXTree = new MyXVariablesView(project);
    registerDisposable(myXTree);
    myCards.add(myXTree.getTree(), X_TREE);

    JScrollPane pane = ScrollPaneFactory.createScrollPane(myCards);
    pane.getVerticalScrollBar().setUnitIncrement(10);
    add(pane, BorderLayout.CENTER);
    registerDisposable(
        DebuggerAction.installEditAction(frameTree, DebuggerActions.EDIT_NODE_SOURCE));

    overrideShortcut(frameTree, DebuggerActions.COPY_VALUE, CommonShortcuts.getCopy());
    overrideShortcut(
        frameTree,
        DebuggerActions.SET_VALUE,
        new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0)));

    new ValueNodeDnD(myTree, parent);
  }
コード例 #4
0
  public LayoutTreeComponent(
      ArtifactEditorImpl artifactsEditor,
      ComplexElementSubstitutionParameters substitutionParameters,
      ArtifactEditorContext context,
      Artifact originalArtifact,
      boolean sortElements) {
    myArtifactsEditor = artifactsEditor;
    mySubstitutionParameters = substitutionParameters;
    myContext = context;
    myOriginalArtifact = originalArtifact;
    mySortElements = sortElements;
    myTree = new LayoutTree(myArtifactsEditor);
    myTreeStructure = new LayoutTreeStructure();
    myBuilder = new LayoutTreeBuilder();
    Disposer.register(this, myTree);
    Disposer.register(this, myBuilder);

    myTree.addTreeSelectionListener(
        new TreeSelectionListener() {
          @Override
          public void valueChanged(TreeSelectionEvent e) {
            updatePropertiesPanel(false);
          }
        });
    createPropertiesPanel();
    myTreePanel = new JPanel(new BorderLayout());
    myTreePanel.add(ScrollPaneFactory.createScrollPane(myTree), BorderLayout.CENTER);
    myTreePanel.add(myPropertiesPanelWrapper, BorderLayout.SOUTH);
    if (!ApplicationManager.getApplication().isUnitTestMode()) {
      DnDManager.getInstance().registerTarget(this, myTree);
    }
  }
コード例 #5
0
  private void layoutPanel() {
    if (myUsagePreviewPanel != null) {
      Disposer.dispose(myUsagePreviewPanel);
    }
    removeAll();
    JScrollPane pane = ScrollPaneFactory.createScrollPane(myTree);

    if (isPreview()) {
      pane.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT | SideBorder.RIGHT));

      boolean vertical =
          myToolWindow.getAnchor() == ToolWindowAnchor.LEFT
              || myToolWindow.getAnchor() == ToolWindowAnchor.RIGHT;
      Splitter splitter =
          new Splitter(
              vertical, UsageViewSettings.getInstance().PREVIEW_USAGES_SPLITTER_PROPORTIONS);
      splitter.setFirstComponent(pane);
      myUsagePreviewPanel = new UsagePreviewPanel(myProject, new UsageViewPresentation());
      myUsagePreviewPanel.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT));

      Disposer.register(this, myUsagePreviewPanel);
      splitter.setSecondComponent(myUsagePreviewPanel);
      add(splitter, BorderLayout.CENTER);
    } else {
      pane.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT));
      add(pane, BorderLayout.CENTER);
    }

    add(createToolbar().getComponent(), BorderLayout.WEST);

    myTree.getParent().setBackground(UIManager.getColor("Tree.background"));

    revalidate();
  }
コード例 #6
0
  public ViewFilesPanel(
      FileTypeManager fileTypeManager, ActionManager actionManager, IDEFacade facade) {
    super(new BorderLayout(2, 2));
    setOpaque(false);

    myFileTypeManager = fileTypeManager;
    myIdeFacade = facade;
    myShowReadOnly = Pico.getOptions().isSet(SHOW_READ_ONLY_KEY, true);

    myTree =
        new KirTree() {
          protected void onEnter() {
            super.onEnter();
            if (myOpenFileAction.isEnabled()) {
              myOpenFileAction.actionPerformed(null);
            }
          }
        };
    IDEAFacade.installIdeaTreeActions(myTree);
    add(ScrollPaneFactory.createScrollPane(myTree));
    add(createActionsToolbar(actionManager), BorderLayout.NORTH);

    IDEAFacade.installPopupMenu(createActionGroup(), myTree, actionManager);

    myTree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode()));
    setMinimumSize(new Dimension(200, 0));
  }
コード例 #7
0
  public HierarchyBrowserBaseEx(@NotNull Project project, @NotNull PsiElement element) {
    super(project);

    setHierarchyBase(element);

    myCardLayout = new CardLayout();
    myTreePanel = new JPanel(myCardLayout);

    createTrees(myType2TreeMap);

    final HierarchyBrowserManager.State state =
        HierarchyBrowserManager.getInstance(project).getState();
    for (String type : myType2TreeMap.keySet()) {
      myType2ScopeMap.put(type, state.SCOPE != null ? state.SCOPE : SCOPE_ALL);
    }

    final Enumeration<String> keys = myType2TreeMap.keys();
    while (keys.hasMoreElements()) {
      final String key = keys.nextElement();
      final JTree tree = myType2TreeMap.get(key);
      myOccurrenceNavigators.put(
          key,
          new OccurenceNavigatorSupport(tree) {
            @Override
            @Nullable
            protected Navigatable createDescriptorForNode(DefaultMutableTreeNode node) {
              final HierarchyNodeDescriptor descriptor = getDescriptor(node);
              if (descriptor == null) return null;
              PsiElement psiElement = getOpenFileElementFromDescriptor(descriptor);
              if (psiElement == null || !psiElement.isValid()) return null;
              final VirtualFile virtualFile = psiElement.getContainingFile().getVirtualFile();
              if (virtualFile == null) return null;
              return new OpenFileDescriptor(
                  psiElement.getProject(), virtualFile, psiElement.getTextOffset());
            }

            @Override
            public String getNextOccurenceActionName() {
              return getNextOccurenceActionNameImpl();
            }

            @Override
            public String getPreviousOccurenceActionName() {
              return getPrevOccurenceActionNameImpl();
            }
          });
      myTreePanel.add(ScrollPaneFactory.createScrollPane(tree), key);
    }

    final JPanel legendPanel = createLegendPanel();
    final JPanel contentPanel;
    if (legendPanel != null) {
      contentPanel = new JPanel(new BorderLayout());
      contentPanel.add(myTreePanel, BorderLayout.CENTER);
      contentPanel.add(legendPanel, BorderLayout.SOUTH);
    } else {
      contentPanel = myTreePanel;
    }
    buildUi(createToolbar(getActionPlace(), HELP_ID).getComponent(), contentPanel);
  }
コード例 #8
0
  private void setupCentralPanel() {
    myCentralPanel.removeAll();
    if (myUsagePreviewPanel != null) {
      Disposer.dispose(myUsagePreviewPanel);
      myUsagePreviewPanel = null;
    }
    JScrollPane pane = ScrollPaneFactory.createScrollPane(myTree);

    if (UsageViewSettings.getInstance().IS_PREVIEW_USAGES) {
      Splitter splitter =
          new Splitter(false, UsageViewSettings.getInstance().PREVIEW_USAGES_SPLITTER_PROPORTIONS);
      pane.putClientProperty(UIUtil.KEEP_BORDER_SIDES, SideBorder.RIGHT);

      splitter.setFirstComponent(pane);
      myUsagePreviewPanel = new UsagePreviewPanel(myProject);
      myUsagePreviewPanel.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT));
      Disposer.register(this, myUsagePreviewPanel);
      splitter.setSecondComponent(myUsagePreviewPanel);
      myCentralPanel.add(splitter, BorderLayout.CENTER);
    } else {
      myCentralPanel.add(pane, BorderLayout.CENTER);
    }
    myCentralPanel.add(myButtonPanel, BorderLayout.SOUTH);

    myRootPanel.revalidate();
  }
コード例 #9
0
 private JComponent createTreeComponent(JComponent toolbar, JComponent tree) {
   UnitTestViewComponent.MyTreePanel treePanel =
       new UnitTestViewComponent.MyTreePanel(new BorderLayout());
   JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(tree);
   treePanel.add(scrollPane, BorderLayout.CENTER);
   treePanel.add(toolbar, BorderLayout.NORTH);
   return treePanel;
 }
コード例 #10
0
  @Override
  protected JComponent createCenterPanel() {
    final JPanel panel = new JPanel(new BorderLayout());
    JTextArea area =
        new JTextArea(
            "The imported language extends other languages.\n"
                + "It might be useful to import all or some of them.");
    area.setEditable(false);
    area.setBackground(this.getContentPane().getBackground());
    area.setBorder(BorderFactory.createEmptyBorder(5, 5, 3, 5));
    panel.add(area, BorderLayout.NORTH);

    JPanel center = new JPanel(new GridBagLayout());
    JTextArea label = new JTextArea("Select additional languages to import:");
    label.setEditable(false);
    label.setBackground(getContentPane().getBackground());
    label.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    center.add(
        label,
        new GridBagConstraints(
            0,
            GridBagConstraints.RELATIVE,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));

    myList = new JBList(myCandidates.toArray());

    myList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    myList.setSelectionInterval(0, myList.getModel().getSize() - 1);
    myList.setCellRenderer(new MyDefaultListCellRenderer());
    myList.setBorder(BorderFactory.createEtchedBorder());
    center.add(
        ScrollPaneFactory.createScrollPane(myList),
        new GridBagConstraints(
            0,
            GridBagConstraints.RELATIVE,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));

    panel.add(center, BorderLayout.CENTER);
    panel.setPreferredSize(new Dimension(400, 250));

    return panel;
  }
コード例 #11
0
 private static JScrollPane wrapInScrollPane(JPanel panel) {
   JPanel wrapper = new JPanel(new BorderLayout());
   wrapper.add(panel);
   wrapper.setBorder(IdeBorderFactory.createEmptyBorder(5));
   return ScrollPaneFactory.createScrollPane(
       wrapper,
       ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
       ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
 }
 @Override
 protected JComponent createCenterPanel() {
   final TableView<FileExtension> table = new TableView<FileExtension>(myModel);
   final Dimension preferredSize = table.getPreferredSize();
   final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(table);
   final Dimension scrollPaneSize = scrollPane.getPreferredSize();
   scrollPaneSize.width = preferredSize.width;
   scrollPane.setPreferredSize(scrollPaneSize);
   return scrollPane;
 }
コード例 #13
0
  protected ChangesBrowserBase(
      final Project project,
      @NotNull List<T> changes,
      final boolean capableOfExcludingChanges,
      final boolean highlightProblems,
      @Nullable final Runnable inclusionListener,
      ChangesBrowser.MyUseCase useCase,
      @Nullable VirtualFile toSelect,
      Class<T> clazz) {
    super(new BorderLayout());
    setFocusable(false);

    myClass = clazz;
    myDataIsDirty = false;
    myProject = project;
    myCapableOfExcludingChanges = capableOfExcludingChanges;
    myToSelect = toSelect;

    ChangeNodeDecorator decorator =
        ChangesBrowser.MyUseCase.LOCAL_CHANGES.equals(useCase)
            ? RemoteRevisionsCache.getInstance(myProject).getChangesNodeDecorator()
            : null;

    myViewer =
        new ChangesTreeList<T>(
            myProject,
            changes,
            capableOfExcludingChanges,
            highlightProblems,
            inclusionListener,
            decorator) {
          protected DefaultTreeModel buildTreeModel(
              final List<T> changes, ChangeNodeDecorator changeNodeDecorator) {
            return ChangesBrowserBase.this.buildTreeModel(
                changes, changeNodeDecorator, isShowFlatten());
          }

          protected List<T> getSelectedObjects(final ChangesBrowserNode<T> node) {
            return ChangesBrowserBase.this.getSelectedObjects(node);
          }

          @Nullable
          protected T getLeadSelectedObject(final ChangesBrowserNode node) {
            return ChangesBrowserBase.this.getLeadSelectedObject(node);
          }

          @Override
          public void setScrollPaneBorder(Border border) {
            myViewerScrollPane.setBorder(border);
          }
        };
    myViewerScrollPane = ScrollPaneFactory.createScrollPane(myViewer);
    myHeaderPanel = new JPanel(new BorderLayout());
  }
コード例 #14
0
 protected JComponent createCenterPanel() {
   JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTree);
   scrollPane.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT));
   myCenterPanel.add(CARD_STATUS, scrollPane);
   myTreeBrowser =
       new CommittedChangesTreeBrowser(myProject, Collections.<CommittedChangeList>emptyList());
   Disposer.register(this, myTreeBrowser);
   myTreeBrowser.setHelpId(getHelpId());
   myCenterPanel.add(CARD_CHANGES, myTreeBrowser);
   return myCenterPanel;
 }
コード例 #15
0
  ParameterInfoComponent(
      Object[] objects,
      Editor editor,
      @NotNull ParameterInfoHandler handler,
      boolean requestFocus) {
    super(new BorderLayout());
    myRequestFocus = requestFocus;

    if (!ApplicationManager.getApplication().isUnitTestMode()) {
      JComponent editorComponent = editor.getComponent();
      JLayeredPane layeredPane = editorComponent.getRootPane().getLayeredPane();
      myWidthLimit = layeredPane.getWidth();
    }

    NORMAL_FONT = UIUtil.getLabelFont();
    BOLD_FONT = NORMAL_FONT.deriveFont(Font.BOLD);

    myObjects = objects;

    setBackground(BACKGROUND_COLOR);

    myHandler = handler;
    myPanels = new OneElementComponent[myObjects.length];
    final JPanel panel = new JPanel(new GridBagLayout());
    for (int i = 0; i < myObjects.length; i++) {
      myPanels[i] = new OneElementComponent();
      panel.add(
          myPanels[i],
          new GridBagConstraints(
              0,
              i,
              1,
              1,
              1,
              0,
              GridBagConstraints.WEST,
              GridBagConstraints.HORIZONTAL,
              new Insets(0, 0, 0, 0),
              0,
              0));
    }
    if (myRequestFocus) {
      AccessibleContextUtil.setName(
          this, "Parameter Info. Press TAB to navigate through each element. Press ESC to close.");
    }

    final JScrollPane pane = ScrollPaneFactory.createScrollPane(panel);
    pane.setBorder(null);
    pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    add(pane, BorderLayout.CENTER);

    myCurrentParameterIndex = -1;
  }
コード例 #16
0
  @Override
  protected JScrollPane createTable() {
    AvailablePluginsTableModel model = new AvailablePluginsTableModel();
    model.setVendor(myVendorFilter);
    pluginsModel = model;
    pluginTable = new PluginTable(pluginsModel);
    pluginTable.getTableHeader().setReorderingAllowed(false);
    pluginTable.setColumnWidth(PluginManagerColumnInfo.COLUMN_DOWNLOADS, 70);
    pluginTable.setColumnWidth(PluginManagerColumnInfo.COLUMN_DATE, 80);
    pluginTable.setColumnWidth(PluginManagerColumnInfo.COLUMN_RATE, 80);

    return ScrollPaneFactory.createScrollPane(pluginTable);
  }
コード例 #17
0
  public ServersToolWindowContent(@NotNull 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 Splitter(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);
          return true;
        }
        return false;
      }
    }.installOn(myTree);
  }
コード例 #18
0
 private SelectedElementInfo(@Nullable E element) {
   myElement = element;
   if (myElement != null) {
     //noinspection unchecked
     myCurrentPanel = element.getType().createElementPropertiesPanel(myElement, myContext);
     myPropertiesPanel.removeAll();
     if (myCurrentPanel != null) {
       myPropertiesPanel.add(
           BorderLayout.CENTER,
           ScrollPaneFactory.createScrollPane(myCurrentPanel.createComponent(), true));
       myCurrentPanel.reset();
       myPropertiesPanel.revalidate();
     }
   }
 }
コード例 #19
0
  @Override
  protected JComponent createCenterPanel() {
    JPanel panel = new JPanel(new BorderLayout());

    // Toolbar

    DefaultActionGroup group = new DefaultActionGroup();

    fillToolbarActions(group);

    group.addSeparator();

    ExpandAllAction expandAllAction = new ExpandAllAction();
    expandAllAction.registerCustomShortcutSet(
        new CustomShortcutSet(
            KeymapManager.getInstance()
                .getActiveKeymap()
                .getShortcuts(IdeActions.ACTION_EXPAND_ALL)),
        myTree);
    group.add(expandAllAction);

    CollapseAllAction collapseAllAction = new CollapseAllAction();
    collapseAllAction.registerCustomShortcutSet(
        new CustomShortcutSet(
            KeymapManager.getInstance()
                .getActiveKeymap()
                .getShortcuts(IdeActions.ACTION_COLLAPSE_ALL)),
        myTree);
    group.add(collapseAllAction);

    panel.add(
        ActionManager.getInstance()
            .createActionToolbar(ActionPlaces.UNKNOWN, group, true)
            .getComponent(),
        BorderLayout.NORTH);

    // Tree
    expandFirst();
    defaultExpandTree();
    installSpeedSearch();

    JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTree);
    scrollPane.setPreferredSize(new Dimension(350, 450));
    panel.add(scrollPane, BorderLayout.CENTER);

    return panel;
  }
コード例 #20
0
  private void createErrorCard() {
    myErrorPanel = new JPanel(new BorderLayout());
    myErrorMessages =
        new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, 10, 5, true, false));
    myErrorPanel.add(myErrorMessages, BorderLayout.PAGE_START);

    myErrorStack = new JTextArea(50, 20);
    myErrorStack.setEditable(false);

    myErrorStackLayout = new CardLayout();
    myErrorStackPanel = new JPanel(myErrorStackLayout);
    myErrorStackPanel.add(new JLabel(), ERROR_NO_STACK_CARD);
    myErrorStackPanel.add(ScrollPaneFactory.createScrollPane(myErrorStack), ERROR_STACK_CARD);

    myErrorPanel.add(myErrorStackPanel, BorderLayout.CENTER);

    add(myErrorPanel, ERROR_CARD);
  }
コード例 #21
0
 public MetricsDisplay(@NotNull Project project) {
   final JTable projectMetricsTable = new JBTable();
   tables.put(MetricCategory.Project, projectMetricsTable);
   final JTable fileTypeMetricsTable = new JBTable();
   tables.put(MetricCategory.FileType, fileTypeMetricsTable);
   final JTable moduleMetricsTable = new JBTable();
   tables.put(MetricCategory.Module, moduleMetricsTable);
   final JTable packageMetricsTable = new JBTable();
   tables.put(MetricCategory.Package, packageMetricsTable);
   final JTable classMetricsTable = new JBTable();
   tables.put(MetricCategory.Class, classMetricsTable);
   final JTable interfaceMetricsTable = new JBTable();
   tables.put(MetricCategory.Interface, interfaceMetricsTable);
   final JTable methodMetricsTable = new JBTable();
   tables.put(MetricCategory.Method, methodMetricsTable);
   setupTable(projectMetricsTable, project);
   setupTable(fileTypeMetricsTable, project);
   setupTable(moduleMetricsTable, project);
   setupTable(packageMetricsTable, project);
   setupTable(classMetricsTable, project);
   setupTable(interfaceMetricsTable, project);
   setupTable(methodMetricsTable, project);
   tabbedPane.add(
       MetricsReloadedBundle.message("project.metrics"),
       ScrollPaneFactory.createScrollPane(projectMetricsTable));
   tabbedPane.add(
       MetricsReloadedBundle.message("file.type.metrics"),
       ScrollPaneFactory.createScrollPane(fileTypeMetricsTable));
   tabbedPane.add(
       MetricsReloadedBundle.message("module.metrics"),
       ScrollPaneFactory.createScrollPane(moduleMetricsTable));
   tabbedPane.add(
       MetricsReloadedBundle.message("package.metrics"),
       ScrollPaneFactory.createScrollPane(packageMetricsTable));
   tabbedPane.add(
       MetricsReloadedBundle.message("class.metrics"),
       ScrollPaneFactory.createScrollPane(classMetricsTable));
   tabbedPane.add(
       MetricsReloadedBundle.message("interface.metrics"),
       ScrollPaneFactory.createScrollPane(interfaceMetricsTable));
   tabbedPane.add(
       MetricsReloadedBundle.message("method.metrics"),
       ScrollPaneFactory.createScrollPane(methodMetricsTable));
 }
コード例 #22
0
  public ContentEntryTreeEditor(
      Project project, List<ModuleSourceRootEditHandler<?>> editHandlers) {
    myProject = project;
    myEditHandlers = editHandlers;
    myTree = new Tree();
    myTree.setRootVisible(true);
    myTree.setShowsRootHandles(true);

    myEditingActionsGroup = new DefaultActionGroup();

    TreeUtil.installActions(myTree);
    new TreeSpeedSearch(myTree);

    myTreePanel = new MyPanel(new BorderLayout());
    final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTree);
    myTreePanel.add(
        new ToolbarPanel(scrollPane, myEditingActionsGroup, TOOLBAR_PLACE), BorderLayout.CENTER);

    myTreePanel.setVisible(false);
    myDescriptor = FileChooserDescriptorFactory.createMultipleFoldersDescriptor();
    myDescriptor.setShowFileSystemRoots(false);
  }
コード例 #23
0
 public void actionPerformed(final AnActionEvent e) {
   @NonNls final String delim = "&nbsp;-&gt;&nbsp;";
   final StringBuffer buf = new StringBuffer();
   processDependencies(
       getSelectedScope(myLeftTree),
       getSelectedScope(myRightTree),
       new Processor<List<PsiFile>>() {
         public boolean process(final List<PsiFile> path) {
           if (buf.length() > 0) buf.append("<br>");
           buf.append(
               StringUtil.join(
                   path,
                   new Function<PsiFile, String>() {
                     public String fun(final PsiFile psiFile) {
                       return psiFile.getName();
                     }
                   },
                   delim));
           return true;
         }
       });
   final JEditorPane pane =
       new JEditorPane(UIUtil.HTML_MIME, "<html>" + buf.toString() + "</html>");
   pane.setForeground(Color.black);
   pane.setBackground(HintUtil.INFORMATION_COLOR);
   pane.setOpaque(true);
   final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(pane);
   final Dimension dimension = pane.getPreferredSize();
   scrollPane.setMinimumSize(new Dimension(dimension.width, dimension.height + 20));
   scrollPane.setPreferredSize(new Dimension(dimension.width, dimension.height + 20));
   JBPopupFactory.getInstance()
       .createComponentPopupBuilder(scrollPane, pane)
       .setTitle("Dependencies")
       .setMovable(true)
       .createPopup()
       .showInBestPositionFor(e.getDataContext());
 }
コード例 #24
0
ファイル: WizardPopup.java プロジェクト: ngoanhtan/consulo
    private static Dimension computeNotBiggerDimension(
        Dimension ofContent, final Point locationOnScreen) {
      int resultHeight =
          ofContent.height > MAX_SIZE.height + 50 ? MAX_SIZE.height : ofContent.height;
      if (locationOnScreen != null) {
        final Rectangle r = ScreenUtil.getScreenRectangle(locationOnScreen);
        resultHeight =
            ofContent.height > r.height - (r.height / 4)
                ? r.height - (r.height / 4)
                : ofContent.height;
      }

      int resultWidth = ofContent.width > MAX_SIZE.width ? MAX_SIZE.width : ofContent.width;

      if (ofContent.height > MAX_SIZE.height) {
        resultWidth +=
            ScrollPaneFactory.createScrollPane()
                .getVerticalScrollBar()
                .getPreferredSize()
                .getWidth();
      }

      return new Dimension(resultWidth, resultHeight);
    }
コード例 #25
0
  public static Pair<JPanel, JBList> createActionGroupPanel(
      ActionGroup action, final JComponent parent, final Runnable backAction) {
    JPanel actionsListPanel = new JPanel(new BorderLayout());
    actionsListPanel.setBackground(getProjectsBackground());
    final JBList list = new JBList(action.getChildren(null));
    list.setBackground(getProjectsBackground());
    list.installCellRenderer(
        new NotNullFunction<AnAction, JComponent>() {
          final JLabel label = new JLabel();

          {
            label.setBorder(JBUI.Borders.empty(3, 7));
          }

          @NotNull
          @Override
          public JComponent fun(AnAction action) {
            label.setText(action.getTemplatePresentation().getText());
            Icon icon = action.getTemplatePresentation().getIcon();
            label.setIcon(icon);
            return label;
          }
        });
    JScrollPane pane = ScrollPaneFactory.createScrollPane(list, true);
    pane.setBackground(getProjectsBackground());
    actionsListPanel.add(pane, BorderLayout.CENTER);
    if (backAction != null) {
      final JLabel back = new JLabel(AllIcons.Actions.Back);
      back.setBorder(JBUI.Borders.empty(3, 7, 10, 7));
      back.setHorizontalAlignment(SwingConstants.LEFT);
      new ClickListener() {
        @Override
        public boolean onClick(@NotNull MouseEvent event, int clickCount) {
          backAction.run();
          return true;
        }
      }.installOn(back);
      actionsListPanel.add(back, BorderLayout.SOUTH);
    }
    final Ref<Component> selected = Ref.create();
    final JPanel main = new JPanel(new BorderLayout());
    main.add(actionsListPanel, BorderLayout.WEST);

    ListSelectionListener selectionListener =
        new ListSelectionListener() {
          @Override
          public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting()) {
              // Update when a change has been finalized.
              // For instance, selecting an element with mouse fires two consecutive
              // ListSelectionEvent events.
              return;
            }
            if (!selected.isNull()) {
              main.remove(selected.get());
            }
            Object value = list.getSelectedValue();
            if (value instanceof AbstractActionWithPanel) {
              JPanel panel = ((AbstractActionWithPanel) value).createPanel();
              panel.setBorder(JBUI.Borders.empty(7, 10));
              selected.set(panel);
              main.add(selected.get());

              for (JButton button : UIUtil.findComponentsOfType(main, JButton.class)) {
                if (button.getClientProperty(DialogWrapper.DEFAULT_ACTION) == Boolean.TRUE) {
                  parent.getRootPane().setDefaultButton(button);
                  break;
                }
              }

              main.revalidate();
              main.repaint();
            }
          }
        };
    list.addListSelectionListener(selectionListener);
    if (backAction != null) {
      new AnAction() {
        @Override
        public void actionPerformed(@NotNull AnActionEvent e) {
          backAction.run();
        }
      }.registerCustomShortcutSet(KeyEvent.VK_ESCAPE, 0, main);
    }
    return Pair.create(main, list);
  }
コード例 #26
0
  public JComponent createCenterPanel() {
    List<FileStructureFilter> fileStructureFilters = new ArrayList<FileStructureFilter>();
    List<FileStructureNodeProvider> fileStructureNodeProviders =
        new ArrayList<FileStructureNodeProvider>();
    if (myTreeActionsOwner != null) {
      for (Filter filter : myBaseTreeModel.getFilters()) {
        if (filter instanceof FileStructureFilter) {
          final FileStructureFilter fsFilter = (FileStructureFilter) filter;
          myTreeActionsOwner.setActionIncluded(fsFilter, true);
          fileStructureFilters.add(fsFilter);
        }
      }

      if (myBaseTreeModel instanceof ProvidingTreeModel) {
        for (NodeProvider provider : ((ProvidingTreeModel) myBaseTreeModel).getNodeProviders()) {
          if (provider instanceof FileStructureNodeProvider) {
            fileStructureNodeProviders.add((FileStructureNodeProvider) provider);
          }
        }
      }
    }
    final JPanel panel = new JPanel(new BorderLayout());
    JPanel comboPanel = new JPanel(new GridLayout(0, 2, 0, 0));

    final Shortcut[] F4 =
        ActionManager.getInstance()
            .getAction(IdeActions.ACTION_EDIT_SOURCE)
            .getShortcutSet()
            .getShortcuts();
    final Shortcut[] ENTER = CustomShortcutSet.fromString("ENTER").getShortcuts();
    final CustomShortcutSet shortcutSet = new CustomShortcutSet(ArrayUtil.mergeArrays(F4, ENTER));
    new AnAction() {
      public void actionPerformed(AnActionEvent e) {
        final boolean succeeded = navigateSelectedElement();
        if (succeeded) {
          unregisterCustomShortcutSet(panel);
        }
      }
    }.registerCustomShortcutSet(shortcutSet, panel);

    new AnAction() {
      public void actionPerformed(AnActionEvent e) {
        if (mySpeedSearch != null && mySpeedSearch.isPopupActive()) {
          mySpeedSearch.hidePopup();
        } else {
          myPopup.cancel();
        }
      }
    }.registerCustomShortcutSet(CustomShortcutSet.fromString("ESCAPE"), myTree);

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

    for (FileStructureFilter filter : fileStructureFilters) {
      addCheckbox(comboPanel, filter);
    }

    for (FileStructureNodeProvider provider : fileStructureNodeProviders) {
      addCheckbox(comboPanel, provider);
    }
    myPreferredWidth = Math.max(comboPanel.getPreferredSize().width, 350);
    panel.add(comboPanel, BorderLayout.NORTH);
    JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myAbstractTreeBuilder.getTree());
    scrollPane.setBorder(IdeBorderFactory.createBorder(SideBorder.TOP | SideBorder.BOTTOM));
    panel.add(scrollPane, BorderLayout.CENTER);
    panel.add(createSouthPanel(), BorderLayout.SOUTH);
    DataManager.registerDataProvider(
        panel,
        new DataProvider() {
          @Override
          public Object getData(@NonNls String dataId) {
            if (PlatformDataKeys.PROJECT.is(dataId)) {
              return myProject;
            }
            if (LangDataKeys.PSI_ELEMENT.is(dataId)) {
              final Object node =
                  ContainerUtil.getFirstItem(myAbstractTreeBuilder.getSelectedElements());
              if (!(node instanceof FilteringTreeStructure.FilteringNode)) return null;
              return getPsi((FilteringTreeStructure.FilteringNode) node);
            }
            if (LangDataKeys.POSITION_ADJUSTER_POPUP.is(dataId)) {
              return myPopup;
            }
            if (PlatformDataKeys.TREE_EXPANDER.is(dataId)) {
              return myTreeExpander;
            }
            return null;
          }
        });

    return panel;
  }
コード例 #27
0
  public ScopeEditorPanel(Project project, final NamedScopesHolder holder) {
    myProject = project;
    myHolder = holder;

    myPackageTree = new Tree(new RootNode(project));

    myButtonsPanel.add(createActionsPanel());

    myTreePanel.setLayout(new BorderLayout());
    myTreePanel.add(ScrollPaneFactory.createScrollPane(myPackageTree), BorderLayout.CENTER);

    myTreeToolbar.setLayout(new BorderLayout());
    myTreeToolbar.add(createTreeToolbar(), BorderLayout.WEST);

    myTreeExpansionMonitor = PackageTreeExpansionMonitor.install(myPackageTree, myProject);

    myTreeMarker =
        new Marker() {
          public boolean isMarked(VirtualFile file) {
            return myCurrentScope != null
                && (myCurrentScope instanceof PackageSetBase
                    ? ((PackageSetBase) myCurrentScope).contains(file, myHolder)
                    : myCurrentScope.contains(PackageSetBase.getPsiFile(file, myHolder), myHolder));
          }
        };

    myPatternField.setDialogCaption("Pattern");
    myPatternField
        .getDocument()
        .addDocumentListener(
            new DocumentAdapter() {
              public void textChanged(DocumentEvent event) {
                onTextChange();
              }
            });

    myPatternField
        .getTextField()
        .addCaretListener(
            new CaretListener() {
              public void caretUpdate(CaretEvent e) {
                myCaretPosition = e.getDot();
                updateCaretPositionText();
              }
            });

    myPatternField
        .getTextField()
        .addFocusListener(
            new FocusListener() {
              public void focusGained(FocusEvent e) {
                if (myErrorMessage != null) {
                  myPositionPanel.setVisible(true);
                  myPanel.revalidate();
                }
              }

              public void focusLost(FocusEvent e) {
                myPositionPanel.setVisible(false);
                myPanel.revalidate();
              }
            });

    initTree(myPackageTree);
    new UiNotifyConnector(
        myPanel,
        new Activatable() {
          @Override
          public void showNotify() {}

          @Override
          public void hideNotify() {
            cancelCurrentProgress();
          }
        });
    myPartiallyIncluded.setBackground(MyTreeCellRenderer.PARTIAL_INCLUDED);
    myRecursivelyIncluded.setBackground(MyTreeCellRenderer.WHOLE_INCLUDED);
  }
コード例 #28
0
  public RegistryUi() {
    myContent.setLayout(new BorderLayout(UIUtil.DEFAULT_HGAP, UIUtil.DEFAULT_VGAP));

    myModel = new MyTableModel();
    myTable = new JBTable(myModel);
    myTable.setCellSelectionEnabled(true);
    myTable.setEnableAntialiasing(true);
    final MyRenderer r = new MyRenderer();

    final TableColumn c0 = myTable.getColumnModel().getColumn(0);
    c0.setCellRenderer(r);
    c0.setMaxWidth(RESTART_ICON.getIconWidth() + 12);
    c0.setMinWidth(RESTART_ICON.getIconWidth() + 12);
    c0.setHeaderValue(null);

    final TableColumn c1 = myTable.getColumnModel().getColumn(1);
    c1.setCellRenderer(r);
    c1.setHeaderValue("Key");

    final TableColumn c2 = myTable.getColumnModel().getColumn(2);
    c2.setCellRenderer(r);
    c2.setHeaderValue("Value");
    c2.setCellEditor(new MyEditor());
    myTable.setStriped(true);

    myDescriptionLabel = new JTextArea(3, 50);
    myDescriptionLabel.setEditable(false);
    final JScrollPane label = ScrollPaneFactory.createScrollPane(myDescriptionLabel);
    final JPanel descriptionPanel = new JPanel(new BorderLayout());
    descriptionPanel.add(label, BorderLayout.CENTER);
    descriptionPanel.setBorder(
        IdeBorderFactory.createTitledBorder("Description", false, false, true));

    myContent.add(ScrollPaneFactory.createScrollPane(myTable), BorderLayout.CENTER);
    myContent.add(descriptionPanel, BorderLayout.SOUTH);

    myTable
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent e) {
                if (e.getValueIsAdjusting()) return;

                final int selected = myTable.getSelectedRow();
                if (selected != -1) {
                  final RegistryValue value = myModel.getRegistryValue(selected);
                  String desc = value.getDescription();
                  if (value.isRestartRequired()) {
                    String required = "Requires IDE restart.";
                    if (desc.endsWith(".")) {
                      desc += required;
                    } else {
                      desc += (". " + required);
                    }
                  }
                  myDescriptionLabel.setText(desc);
                } else {
                  myDescriptionLabel.setText(null);
                }
              }
            });

    myRestoreDefaultsAction = new RestoreDefaultsAction();

    final DefaultActionGroup tbGroup = new DefaultActionGroup();
    tbGroup.add(new EditAction());
    tbGroup.add(new RevertAction());

    final ActionToolbar tb =
        ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, tbGroup, true);
    tb.setTargetComponent(myTable);

    myContent.add(tb.getComponent(), BorderLayout.NORTH);
    new TableSpeedSearch(myTable).setComparator(new SpeedSearchComparator(false));
  }
コード例 #29
0
  protected JComponent createCenterPanel() {
    JPanel panel = new MyPanel();

    myUiUpdater = new MergingUpdateQueue("FileChooserUpdater", 200, false, panel);
    Disposer.register(myDisposable, myUiUpdater);
    new UiNotifyConnector(panel, myUiUpdater);

    panel.setBorder(JBUI.Borders.empty());

    createTree();

    final DefaultActionGroup group = createActionGroup();
    ActionToolbar toolBar =
        ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true);
    toolBar.setTargetComponent(panel);

    final JPanel toolbarPanel = new JPanel(new BorderLayout());
    toolbarPanel.add(toolBar.getComponent(), BorderLayout.CENTER);

    myTextFieldAction =
        new TextFieldAction() {
          public void linkSelected(final LinkLabel aSource, final Object aLinkData) {
            toggleShowTextField();
          }
        };
    toolbarPanel.add(myTextFieldAction, BorderLayout.EAST);

    myPathTextFieldWrapper = new JPanel(new BorderLayout());
    myPathTextFieldWrapper.setBorder(JBUI.Borders.emptyBottom(2));
    myPathTextField =
        new FileTextFieldImpl.Vfs(
            FileChooserFactoryImpl.getMacroMap(),
            getDisposable(),
            new LocalFsFinder.FileChooserFilter(myChooserDescriptor, myFileSystemTree)) {
          protected void onTextChanged(final String newValue) {
            myUiUpdater.cancelAllUpdates();
            updateTreeFromPath(newValue);
          }
        };
    Disposer.register(myDisposable, myPathTextField);
    myPathTextFieldWrapper.add(myPathTextField.getField(), BorderLayout.CENTER);
    if (getRecentFiles().length > 0) {
      myPathTextFieldWrapper.add(createHistoryButton(), BorderLayout.EAST);
    }

    myNorthPanel = new JPanel(new BorderLayout());
    myNorthPanel.add(toolbarPanel, BorderLayout.NORTH);

    updateTextFieldShowing();

    panel.add(myNorthPanel, BorderLayout.NORTH);

    registerMouseListener(group);

    JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myFileSystemTree.getTree());
    // scrollPane.setBorder(BorderFactory.createLineBorder(new Color(148, 154, 156)));
    panel.add(scrollPane, BorderLayout.CENTER);
    panel.setPreferredSize(JBUI.size(400));

    panel.add(
        new JLabel(
            "<html><center><small><font color=gray>Drag and drop a file into the space above to quickly locate it in the tree.</font></small></center></html>",
            SwingConstants.CENTER),
        BorderLayout.SOUTH);

    ApplicationManager.getApplication()
        .getMessageBus()
        .connect(getDisposable())
        .subscribe(
            ApplicationActivationListener.TOPIC,
            new ApplicationActivationListener.Adapter() {
              @Override
              public void applicationActivated(IdeFrame ideFrame) {
                ((SaveAndSyncHandlerImpl) SaveAndSyncHandler.getInstance())
                    .maybeRefresh(ModalityState.current());
              }
            });

    return panel;
  }
コード例 #30
-1
  private void updateViewerForSelection() {
    if (myAllContents.isEmpty()) return;
    String fullString = getSelectedText();

    if (myViewer != null) {
      EditorFactory.getInstance().releaseEditor(myViewer);
    }

    if (myUseIdeaEditor) {
      myViewer = createIdeaEditor(fullString);
      JComponent component = myViewer.getComponent();
      component.setPreferredSize(JBUI.size(300, 500));
      mySplitter.setSecondComponent(component);
    } else {
      final JTextArea textArea = new JTextArea(fullString);
      textArea.setRows(3);
      textArea.setWrapStyleWord(true);
      textArea.setLineWrap(true);
      textArea.setSelectionStart(0);
      textArea.setSelectionEnd(textArea.getText().length());
      textArea.setEditable(false);
      mySplitter.setSecondComponent(ScrollPaneFactory.createScrollPane(textArea));
    }
    mySplitter.revalidate();
  }