Ejemplo n.º 1
0
  private JComponent getLibrariesTable() {
    myLibraryTableModel = new LibraryTableModel();
    final JBTable librariesTable = new JBTable(myLibraryTableModel);
    librariesTable.setTableHeader(null);
    librariesTable.setDefaultRenderer(String.class, new MyPathRenderer());
    librariesTable.setShowHorizontalLines(false);
    librariesTable.setShowVerticalLines(false);
    librariesTable.setAutoCreateRowSorter(false);
    librariesTable.setAutoscrolls(true);

    ToolbarDecorator decorator = ToolbarDecorator.createDecorator(librariesTable);
    decorator
        .setAddAction(
            new AnActionButtonRunnable() {
              @Override
              public void run(AnActionButton anActionButton) {
                List<ModelRootDescriptor> modelRoots =
                    new ArrayList<ModelRootDescriptor>(
                        myJavaModuleFacet
                            .getModule()
                            .getModuleDescriptor()
                            .getModelRootDescriptors());
                StubRootChooser stubRootChooser =
                    new StubRootChooser(
                        modelRoots,
                        (myJavaModuleFacet.getModule() instanceof Language ? true : false));
                myLibraryTableModel.addAll(stubRootChooser.compute());
              }
            })
        .setRemoveAction(
            new AnActionButtonRunnable() {
              @Override
              public void run(AnActionButton anActionButton) {
                TableUtil.removeSelectedItems(librariesTable);
                myLibraryTableModel.fireTableDataChanged();
              }
            });
    decorator.setToolbarBorder(IdeBorderFactory.createBorder());
    decorator.setPreferredSize(new Dimension(500, 100));

    JPanel table = decorator.createPanel();
    table.setBorder(
        IdeBorderFactory.createTitledBorder(
            PropertiesBundle.message("mps.properties.configurable.module.javatab.librariesborder"),
            false));
    return table;
  }
  @Nullable
  @Override
  protected JComponent createCenterPanel() {
    mySdkList = new JBList();
    //noinspection unchecked
    mySdkList.setCellRenderer(new PySdkListCellRenderer("", myModificators));
    mySdkList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    ToolbarDecorator decorator =
        ToolbarDecorator.createDecorator(mySdkList)
            .disableUpDownActions()
            .setAddAction(
                new AnActionButtonRunnable() {
                  @Override
                  public void run(AnActionButton button) {
                    addSdk(button);
                    updateOkButton();
                  }
                })
            .setEditAction(
                new AnActionButtonRunnable() {
                  @Override
                  public void run(AnActionButton button) {
                    editSdk();
                    updateOkButton();
                  }
                })
            .setRemoveAction(
                new AnActionButtonRunnable() {
                  @Override
                  public void run(AnActionButton button) {
                    removeSdk();
                    updateOkButton();
                  }
                })
            .addExtraAction(new ToggleVirtualEnvFilterButton())
            .addExtraAction(new ShowPathButton());

    decorator.setPreferredSize(new Dimension(600, 500));
    myMainPanel = decorator.createPanel();
    refreshSdkList();
    addListeners();
    return myMainPanel;
  }
Ejemplo n.º 3
0
  private JComponent getSourcePathsTable() {
    myPathsTableModel = new PathsTableModel();
    final JBTable sourcePathTable = new JBTable(myPathsTableModel);
    sourcePathTable.setTableHeader(null);
    sourcePathTable.setDefaultRenderer(String.class, new MyPathRenderer());
    sourcePathTable.setShowHorizontalLines(false);
    sourcePathTable.setShowVerticalLines(false);
    sourcePathTable.setAutoCreateRowSorter(false);
    sourcePathTable.setAutoscrolls(true);

    ToolbarDecorator decorator = ToolbarDecorator.createDecorator(sourcePathTable);
    decorator
        .setAddAction(
            new AnActionButtonRunnable() {
              @Override
              public void run(AnActionButton anActionButton) {
                myPathsTableModel.add((new PathChooser()).compute());
              }
            })
        .setRemoveAction(
            new AnActionButtonRunnable() {
              @Override
              public void run(AnActionButton anActionButton) {
                TableUtil.removeSelectedItems(sourcePathTable);
                myPathsTableModel.fireTableDataChanged();
              }
            });
    decorator.setToolbarBorder(IdeBorderFactory.createBorder());
    decorator.setPreferredSize(new Dimension(500, 100));

    JPanel table = decorator.createPanel();
    table.setBorder(
        IdeBorderFactory.createTitledBorder(
            PropertiesBundle.message("mps.properties.configurable.module.javatab.sourcepathborder"),
            false));
    return table;
  }