Exemplo 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;
  }
Exemplo n.º 2
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;
  }