Example #1
0
  public static void stateLabelManagerDialog() {
    // build popup
    StateLabelManager.popupDialog =
        new JDialog(QueryManager.getEditor(), "State Label Manager", true);
    StateLabelManager.popupDialog.setMinimumSize(new Dimension(730, 450));
    Container contentPane = StateLabelManager.popupDialog.getContentPane();
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS));
    contentPane.add(StateLabelManager.getStateLabelManagementPanel(true));
    contentPane.add(StateLabelManager.getStatesAssignmentManagerPanel());
    JPanel okButtonPanel = new JPanel();
    okButtonPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
    JButton okButton = new JButton("OK");
    StateLabelManager.popupDialog.getRootPane().setDefaultButton(okButton);
    ActionListener okButtonListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            StateLabelManager.clearAll();
            StateLabelManager.popupDialog.dispose();
          }
        };
    okButton.addActionListener(okButtonListener);
    okButtonPanel.add(okButton);
    contentPane.add(okButtonPanel);

    // take care of popup closing
    StateLabelManager.popupDialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    StateLabelManager.popupDialog.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(final WindowEvent we) {
            StateLabelManager.clearAll();
            StateLabelManager.popupDialog.dispose();
          }
        });

    // load in the latest info
    StateLabelManager.update();

    // show popup
    StateLabelManager.popupDialog.pack();
    StateLabelManager.popupDialog.setLocationRelativeTo(null);
    StateLabelManager.popupDialog.setVisible(true);
  }
Example #2
0
  /**
   * This method launches a popup that enables the assignment of a state label to a States node
   *
   * @param nodeInput
   */
  public static void stateLabelAssignmentDialog(final StatesNode nodeInput) {
    // update our local copy of the node object. Need this to be able to
    // refer to the node from the ActionListeners
    StateLabelManager.node = nodeInput;

    // build popup
    StateLabelManager.popupDialog =
        new JDialog(QueryManager.getEditor(), "State Label Assignment", true);
    StateLabelManager.popupDialog.setMinimumSize(new Dimension(730, 450));
    Container contentPane = StateLabelManager.popupDialog.getContentPane();
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS));
    contentPane.add(StateLabelManager.getStateLabelManagementPanel(false));
    contentPane.add(StateLabelManager.getStatesAssignmentManagerPanel());
    String[] buttonNames = {"OK", "Cancel"};
    ActionListener okButtonListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            if (StateLabelManager.currentStateLabel != null) {
              if (StateLabelManager.stateLabelHasStateGroupAssigned()) {
                // assign state label to node
                StateLabelManager.node.setStateLabel(StateLabelManager.currentStateLabel);
                StateLabelManager.node.setNodeLabel(StateLabelManager.currentStateLabel);

                if (MacroManager.getEditor() == null)
                  QueryManager.getData().updateNode(StateLabelManager.node);
                else MacroManager.getEditor().updateNode(StateLabelManager.node);

                StateLabelManager.clearAll();
                StateLabelManager.popupDialog.dispose();
              } else {
                JOptionPane.showMessageDialog(
                    QueryManager.getEditor().getContentPane(),
                    "Please ensure that the state label you have selected refers to \n"
                        + "at least one state group before trying to assign the label to \n"
                        + "the States node.",
                    "Warning",
                    JOptionPane.ERROR_MESSAGE);
              }
            } else {
              JOptionPane.showMessageDialog(
                  QueryManager.getEditor().getContentPane(),
                  "Please select a state label from the dropdown menu \n"
                      + "that you wish to assign to the node.",
                  "Warning",
                  JOptionPane.ERROR_MESSAGE);
            }
          }
        };
    ActionListener cancelButtonListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            StateLabelManager.clearAll();
            StateLabelManager.popupDialog.dispose();
          }
        };
    ActionListener[] buttonListeners = {okButtonListener, cancelButtonListener};
    contentPane.add(new ButtonBar(buttonNames, buttonListeners));

    // take care of popup closing
    StateLabelManager.popupDialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    StateLabelManager.popupDialog.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(final WindowEvent we) {
            StateLabelManager.clearAll();
            StateLabelManager.popupDialog.dispose();
          }
        });

    // load in the latest info
    StateLabelManager.update();

    // show popup
    StateLabelManager.popupDialog.pack();
    StateLabelManager.popupDialog.setLocationRelativeTo(null);
    StateLabelManager.popupDialog.setVisible(true);
  }