ToolAdaptersManagementDialog(AppContext appContext, String title, String helpID) {
   super(appContext.getApplicationWindow(), title, 0, helpID);
   this.appContext = appContext;
   JPanel contentPanel = createContentPanel();
   setContent(contentPanel);
   super.getJDialog().setMinimumSize(contentPanel.getPreferredSize());
 }
  private JPanel createContentPanel() {
    // compute content and other buttons
    SpringLayout springLayout = new SpringLayout();
    JPanel panel = new JPanel(springLayout);
    int panelHeight = 0;
    JTable propertiesPanel = createPropertiesPanel();
    panelHeight += propertiesPanel.getPreferredSize().getHeight();
    panel.add(propertiesPanel);
    panelHeight += 10;
    panel.add(Box.createVerticalStrut(10));
    JScrollPane scrollPane = new JScrollPane(createAdaptersPanel());
    panelHeight += scrollPane.getPreferredSize().getHeight();
    panel.add(scrollPane);
    panelHeight += 10;
    panel.add(Box.createVerticalStrut(10));
    JPanel buttonsPanel = createButtonsPanel();
    panelHeight += buttonsPanel.getPreferredSize().getHeight();
    panel.add(buttonsPanel);

    springLayout.putConstraint(
        SpringLayout.NORTH, panel, DEFAULT_PADDING, SpringLayout.NORTH, propertiesPanel);
    springLayout.putConstraint(
        SpringLayout.WEST, panel, DEFAULT_PADDING, SpringLayout.WEST, propertiesPanel);
    springLayout.putConstraint(
        SpringLayout.EAST, panel, DEFAULT_PADDING, SpringLayout.EAST, propertiesPanel);
    springLayout.putConstraint(
        SpringLayout.NORTH, scrollPane, DEFAULT_PADDING, SpringLayout.SOUTH, propertiesPanel);
    springLayout.putConstraint(
        SpringLayout.WEST, panel, DEFAULT_PADDING, SpringLayout.WEST, scrollPane);
    springLayout.putConstraint(
        SpringLayout.EAST, panel, DEFAULT_PADDING, SpringLayout.EAST, scrollPane);
    springLayout.putConstraint(
        SpringLayout.NORTH, scrollPane, DEFAULT_PADDING, SpringLayout.SOUTH, buttonsPanel);
    springLayout.putConstraint(
        SpringLayout.WEST, panel, DEFAULT_PADDING, SpringLayout.WEST, buttonsPanel);
    springLayout.putConstraint(
        SpringLayout.EAST, panel, DEFAULT_PADDING, SpringLayout.EAST, buttonsPanel);

    panel.setPreferredSize(
        new Dimension(
            CHECK_COLUMN_WIDTH + LABEL_COLUMN_WIDTH + COLUMN_WIDTH - 32,
            panelHeight + DEFAULT_PADDING));
    makeCompactGrid(panel, 5, 1, 0, 0, 0, 0);
    return panel;
  }
  private JPanel createButtonsPanel() {
    JPanel panel = new JPanel(new SpringLayout());

    /** New adapter button */
    panel.add(
        createButton(
            "New",
            TangoIcons.actions_document_new(TangoIcons.Res.R22),
            Bundle.ToolTipNewOperator_Text(),
            e -> {
              ToolAdapterOperatorDescriptor newOperatorSpi =
                  new ToolAdapterOperatorDescriptor(
                      ToolAdapterConstants.OPERATOR_NAMESPACE + "NewOperator",
                      ToolAdapterOp.class,
                      "NewOperator",
                      null,
                      null,
                      null,
                      null,
                      null,
                      null);
              ToolAdapterEditorDialog dialog =
                  new ToolAdapterEditorDialog(appContext, newOperatorSpi, true);
              dialog.show();
              refreshContent();
            }));
    /** Duplicate adapter button */
    panel.add(
        createButton(
            "Copy",
            TangoIcons.actions_edit_copy(TangoIcons.Res.R22),
            Bundle.ToolTipCopyOperator_Text(),
            e -> {
              ToolAdapterOperatorDescriptor operatorDesc = requestSelection();
              if (operatorDesc != null) {
                String opName = operatorDesc.getName();
                int newNameIndex = 0;
                while (GPF.getDefaultInstance().getOperatorSpiRegistry().getOperatorSpi(opName)
                    != null) {
                  newNameIndex++;
                  opName =
                      operatorDesc.getName()
                          + ToolAdapterConstants.OPERATOR_GENERATED_NAME_SEPARATOR
                          + newNameIndex;
                }
                ToolAdapterEditorDialog dialog =
                    new ToolAdapterEditorDialog(appContext, operatorDesc, newNameIndex);
                dialog.show();
                refreshContent();
              }
            }));
    /** Edit adapter button */
    panel.add(
        createButton(
            "Edit",
            TangoIcons.apps_accessories_text_editor(TangoIcons.Res.R22),
            Bundle.ToolTipEditOperator_Text(),
            e -> {
              ToolAdapterOperatorDescriptor operatorDesc = requestSelection();
              if (operatorDesc != null) {
                ToolAdapterEditorDialog dialog =
                    new ToolAdapterEditorDialog(appContext, operatorDesc, false);
                dialog.show();
                refreshContent();
              }
            }));
    /** Delete adapter button */
    panel.add(
        createButton(
            "Delete",
            TangoIcons.actions_edit_clear(TangoIcons.Res.R22),
            Bundle.ToolTipDeleteOperator_Text(),
            e -> {
              ToolAdapterOperatorDescriptor operatorDescriptor = requestSelection();
              if (operatorDescriptor != null) {
                if (SnapDialogs.Answer.YES
                    == SnapDialogs.requestDecision(
                        Bundle.MessageConfirmRemoval_TitleText(),
                        Bundle.MessageConfirmRemoval_Text(),
                        true,
                        Bundle.MessageConfirmRemovalDontAsk_Text())) {
                  if (operatorDescriptor.isFromPackage()) {
                    SnapDialogs.showWarning(
                        String.format(
                            Bundle.MessagePackageModules_Text(), operatorDescriptor.getName()));
                  } else {
                    ToolAdapterActionRegistrar.removeOperatorMenu(operatorDescriptor);
                    ToolAdapterIO.removeOperator(operatorDescriptor);
                  }
                  refreshContent();
                }
              }
            }));
    /** Execute adapter button */
    panel.add(
        createButton(
            "Run",
            TangoIcons.actions_media_playback_start(TangoIcons.Res.R22),
            Bundle.ToolTipExecuteOperator_Text(),
            e -> {
              ToolAdapterOperatorDescriptor operatorDesc = requestSelection();
              if (operatorDesc != null) {
                // close();
                final ToolAdapterExecutionDialog operatorDialog =
                    new ToolAdapterExecutionDialog(
                        operatorDesc, appContext, operatorDesc.getLabel());
                operatorDialog.show();
              }
            }));

    makeCompactGrid(panel, 1, 5, 0, 0, DEFAULT_PADDING, DEFAULT_PADDING);

    return panel;
  }