public JComponent createComponent() {
   myTabbedPane = new TabbedPaneWrapper(myParent);
   createConfigurableTabs();
   final JComponent component = myTabbedPane.getComponent();
   component.setPreferredSize(new Dimension(500, 400));
   return component;
 }
 protected void createConfigurableTabs() {
   for (Configurable configurable : getConfigurables()) {
     myTabbedPane.addTab(
         configurable.getDisplayName(),
         configurable.getIcon(),
         configurable.createComponent(),
         null);
   }
 }
示例#3
0
  private void createCentralComponent() {
    TabbedPaneWrapper tabbedPane = new TabbedPaneWrapper(myParentDisposable);
    MPSFacetSourcesTab mpsFacetSourcesTab = new MPSFacetSourcesTab(myContext, myParentDisposable);
    MPSFacetPathsTab mpsFacetPathsTab = new MPSFacetPathsTab(myContext);
    UsedLanguagesTable usedLanguagesTable =
        new UsedLanguagesTable() {
          @Override
          protected void doAddElements(final Set<SModuleReference> elementsToAdd) {
            super.doAddElements(elementsToAdd);
            ApplicationManager.getApplication()
                .runWriteAction(
                    () ->
                        ModuleRuntimeLibrariesImporter.importForUsedLanguages(
                            myContext, elementsToAdd));
          }
        };

    // can not make it final and init in declaration since idea forms generator does not like it and
    // put $$$setupUI$$$ call before setting the field
    myTabs = new ArrayList<>();
    myTabs.add(mpsFacetSourcesTab);
    myTabs.add(mpsFacetPathsTab);
    myTabs.add(usedLanguagesTable);

    tabbedPane.addTab(
        MPSBundle.message("facet.sources.tab.name"),
        MPSIcons.SOURCES_TAB_ICON,
        mpsFacetSourcesTab.getRootPanel(),
        null);
    tabbedPane.addTab(
        MPSBundle.message("facet.paths.tab.name"),
        MPSIcons.PATHS_TAB_ICON,
        mpsFacetPathsTab.getRootPanel(),
        null);
    tabbedPane.addTab(
        MPSBundle.message("facet.languages.tab.name"),
        MPSIcons.LANGUAGES_TAB_ICON,
        usedLanguagesTable.getRootPanel(),
        "Deprecated. Does not affect anything.");

    myCentralComponent = tabbedPane.getComponent();
  }
 @Override
 protected void doOKAction() {
   mySelectedClass = calcSelectedClass();
   if (mySelectedClass == null) return;
   if (!myClassFilter.isAccepted(mySelectedClass)) {
     Messages.showErrorDialog(
         myTabbedPane.getComponent(),
         SymbolPresentationUtil.getSymbolPresentableText(mySelectedClass) + " is not acceptable");
     return;
   }
   super.doOKAction();
 }
  @Override
  protected JComponent createCenterPanel() {
    final DefaultTreeModel model = new DefaultTreeModel(new DefaultMutableTreeNode());
    myTree = new Tree(model);

    ProjectAbstractTreeStructureBase treeStructure =
        new AbstractProjectTreeStructure(myProject) {
          @Override
          public boolean isFlattenPackages() {
            return false;
          }

          @Override
          public boolean isShowMembers() {
            return myIsShowMembers;
          }

          @Override
          public boolean isHideEmptyMiddlePackages() {
            return true;
          }

          @Override
          public boolean isAbbreviatePackageNames() {
            return false;
          }

          @Override
          public boolean isShowLibraryContents() {
            return myIsShowLibraryContents;
          }

          @Override
          public boolean isShowModules() {
            return false;
          }
        };
    myBuilder =
        new ProjectTreeBuilder(myProject, myTree, model, AlphaComparator.INSTANCE, treeStructure);

    myTree.setRootVisible(false);
    myTree.setShowsRootHandles(true);
    myTree.expandRow(0);
    myTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    myTree.setCellRenderer(new NodeRenderer());
    UIUtil.setLineStyleAngled(myTree);

    JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTree);
    scrollPane.setPreferredSize(new Dimension(500, 300));

    myTree.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (KeyEvent.VK_ENTER == e.getKeyCode()) {
              doOKAction();
            }
          }
        });

    new DoubleClickListener() {
      @Override
      protected boolean onDoubleClick(MouseEvent event) {
        TreePath path = myTree.getPathForLocation(event.getX(), event.getY());
        if (path != null && myTree.isPathSelected(path)) {
          doOKAction();
          return true;
        }
        return false;
      }
    }.installOn(myTree);

    myTree.addTreeSelectionListener(
        new TreeSelectionListener() {
          @Override
          public void valueChanged(TreeSelectionEvent e) {
            handleSelectionChanged();
          }
        });

    new TreeSpeedSearch(myTree);

    myTabbedPane = new TabbedPaneWrapper(getDisposable());

    final JPanel dummyPanel = new JPanel(new BorderLayout());
    String name = null;
    /*
        if (myInitialClass != null) {
          name = myInitialClass.getName();
        }
    */
    myGotoByNamePanel =
        new ChooseByNamePanel(
            myProject,
            createChooseByNameModel(),
            name,
            myScope.isSearchInLibraries(),
            getContext()) {

          @Override
          protected void showTextFieldPanel() {}

          @Override
          protected void close(boolean isOk) {
            super.close(isOk);

            if (isOk) {
              doOKAction();
            } else {
              doCancelAction();
            }
          }

          @NotNull
          @Override
          protected Set<Object> filter(@NotNull Set<Object> elements) {
            return doFilter(elements);
          }

          @Override
          protected void initUI(
              ChooseByNamePopupComponent.Callback callback,
              ModalityState modalityState,
              boolean allowMultipleSelection) {
            super.initUI(callback, modalityState, allowMultipleSelection);
            dummyPanel.add(myGotoByNamePanel.getPanel(), BorderLayout.CENTER);
            IdeFocusTraversalPolicy.getPreferredFocusedComponent(myGotoByNamePanel.getPanel())
                .requestFocus();
          }

          @Override
          protected void showList() {
            super.showList();
            if (myInitialClass != null && myList.getModel().getSize() > 0) {
              myList.setSelectedValue(myInitialClass, true);
              myInitialClass = null;
            }
          }

          @Override
          protected void chosenElementMightChange() {
            handleSelectionChanged();
          }
        };

    Disposer.register(myDisposable, myGotoByNamePanel);

    myTabbedPane.addTab(IdeBundle.message("tab.chooser.search.by.name"), dummyPanel);
    myTabbedPane.addTab(IdeBundle.message("tab.chooser.project"), scrollPane);

    myGotoByNamePanel.invoke(new MyCallback(), getModalityState(), false);

    myTabbedPane.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            handleSelectionChanged();
          }
        });

    return myTabbedPane.getComponent();
  }