private void init() {
    JPanel quickSearchPanel = new JPanel(new FlowLayout(FlowLayout.LEADING));

    final TreeModel treeModel = explorer.getTreeModel();
    final QuickTreeFilterField field =
        new QuickTreeFilterField(treeModel) {
          protected FilterableTreeModel createDisplayTreeModel(TreeModel treeModel) {
            return new FilterableTreeModel(treeModel) {
              @Override
              protected void configureListModelWrapper(ListModelWrapper wrapper, Object node) {

                if (node instanceof DefaultMutableTreeNode) {
                  // ImageFileExplorer.LazyNode inode = (ImageFileExplorer.LazyNode) node;
                  DefaultMutableTreeNode inode = (DefaultMutableTreeNode) node;
                  boolean expanded = explorer.getJTree().isExpanded(new TreePath(inode.getPath()));
                  if (inode.isLeaf() || expanded) {
                    super.configureListModelWrapper(wrapper, node);
                  }
                }
              }
            };
          }
        };

    field.setSearchingDelay(200);
    quickSearchPanel.add(field);

    JPanel treePanel = new JPanel(new BorderLayout(2, 2));

    field.setTree(explorer.getJTree());
    SearchableUtils.installSearchable(field.getTree());

    JTree tree = field.getTree();
    tree.setModel(field.getDisplayTreeModel());
    DataTipManager.get().register(tree);

    treePanel.add(explorer.getComponent());

    mainPanel.add(treePanel);
    mainPanel.add(quickSearchPanel, BorderLayout.BEFORE_FIRST_LINE);

    EventBus.subscribeStrongly(
        DataSourceStatusEvent.class,
        new EventSubscriber<DataSourceStatusEvent>() {
          @Override
          public void onEvent(DataSourceStatusEvent event) {
            explorer.getJTree().repaint();
          }
        });

    mainPanel.putClientProperty(IActionProvider.KEY, this);
  }
Пример #2
0
  private void initComponents() {
    nameText.setComponentPopupMenu(TextFieldPopupMenu.INSTANCE);
    titleText.setComponentPopupMenu(TextFieldPopupMenu.INSTANCE);
    gameVersionText.setComponentPopupMenu(TextFieldPopupMenu.INSTANCE);
    launchFlagsArea.setComponentPopupMenu(TextFieldPopupMenu.INSTANCE);
    userFilesIncludeArea.setComponentPopupMenu(TextFieldPopupMenu.INSTANCE);

    launchFlagsArea.setFont(nameText.getFont());
    userFilesIncludeArea.setFont(nameText.getFont());
    userFilesExcludeArea.setFont(nameText.getFont());

    JTabbedPane tabbedPane = new JTabbedPane();

    JPanel container = new JPanel();
    container.setLayout(new MigLayout("fill, insets dialog"));

    tabbedPane.addTab("Modpack", null, createMainPanel());
    tabbedPane.addTab("Launch", null, createLaunchPanel());
    tabbedPane.addTab("User Files", null, createUserFilesPanel());
    tabbedPane.addTab("Optional Features", null, createFeaturesPanel());

    container.add(tabbedPane, "span, grow, gapbottom unrel");

    JButton saveButton = new JButton("Save");
    JButton cancelButton = new JButton("Cancel");

    container.add(saveButton, "tag ok, span, split 2, sizegroup bttn");
    container.add(cancelButton, "tag cancel, sizegroup bttn");

    getRootPane().setDefaultButton(saveButton);
    getRootPane()
        .registerKeyboardAction(
            event -> cancelButton.doClick(),
            KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
            JComponent.WHEN_IN_FOCUSED_WINDOW);

    add(container, BorderLayout.CENTER);

    saveButton.addActionListener(
        e -> {
          if (nameText.getText().trim().isEmpty()) {
            SwingHelper.showErrorDialog(
                BuilderConfigDialog.this, "The 'Name' field cannot be empty.", "Input Error");
            return;
          }

          if (gameVersionText.getText().trim().isEmpty()) {
            SwingHelper.showErrorDialog(
                BuilderConfigDialog.this,
                "The 'Game Version' field must be a Minecraft version.",
                "Input Error");
            return;
          }

          copyTo();
          saved = true;
          dispose();
        });

    cancelButton.addActionListener(e -> dispose());

    TableSearchable tableSearchable = SearchableUtils.installSearchable(featuresTable);
    tableSearchable.setMainIndex(-1);
  }