示例#1
0
  public LicenseDialog(Component parent) {
    setTitle("Licensing information");

    pnlButtons.add(bttnOk);

    cbLang.addItem("English");
    cbLang.addItem("Eesti");

    FlowLayout fl = new FlowLayout();
    fl.setAlignment(FlowLayout.LEFT);

    pnlHeader.setLayout(fl);

    pnlHeader.add(lblLang);
    pnlHeader.add(cbLang);

    pnlMain.setLayout(new BorderLayout());
    pnlMain.add(pnlHeader, BorderLayout.NORTH);
    pnlMain.add(scrollPane, BorderLayout.CENTER);
    pnlMain.add(pnlButtons, BorderLayout.SOUTH);

    taLicenseText.setText(getLicenseText());
    taLicenseText.setCaretPosition(0);
    taLicenseText.setLineWrap(true);
    taLicenseText.setEditable(false);
    taLicenseText.setWrapStyleWord(true);

    getContentPane().add(pnlMain);
    setPreferredSize(new Dimension(500, 600));
    setLocationRelativeTo(parent);

    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    bttnOk.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            if (evt.getSource() == bttnOk) {
              dispose();
            }
          } // end actionPerformed
        }); // end bttnOk Action Listener

    cbLang.addItemListener(
        new ItemListener() {
          public void itemStateChanged(final ItemEvent event) {
            if (event.getSource() == cbLang
                && event.getStateChange() == ItemEvent.SELECTED
                && cbLang.getItemCount() > 0) {
              taLicenseText.setText(getLicenseText());
              taLicenseText.setCaretPosition(0);
            }
          }
        }); // end cbLang item listener

    pack();
    setVisible(true);
  } // PortPropertiesDialog
示例#2
0
  public Component getCustomOptionComponent() {

    /* DEPTH */
    final JSpinner jspnMaxDepth = new JSpinner(new SpinnerNumberModel(s_maxDepth + 1, 1, 100, 1));
    jspnMaxDepth.addChangeListener(
        new ChangeListener() {

          public void stateChanged(ChangeEvent e) {
            Integer value = (Integer) ((JSpinner) e.getSource()).getValue();
            s_maxDepth = value - 1;

            logger.debug("maxDepth " + (s_maxDepth + 1));
          }
        });
    final JRadioButton jrbMaxDepth = new JRadioButton("Depth");
    final JLabel lblMaxDepth = new JLabel("Depth: ");

    final JPanel jpMaxDepthSub =
        new JPanel() {
          @Override
          public void setEnabled(boolean b) {
            super.setEnabled(b);
            jspnMaxDepth.setEnabled(b);
            lblMaxDepth.setEnabled(b);
          }
        };
    jpMaxDepthSub.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 0));
    jpMaxDepthSub.add(lblMaxDepth);
    jpMaxDepthSub.add(jspnMaxDepth);

    ///
    final JPanel jpMaxDepth =
        new JPanel() {
          @Override
          public void setEnabled(boolean b) {
            super.setEnabled(b);
            jrbMaxDepth.setEnabled(b);
            jpMaxDepthSub.setEnabled(b);
          }
        };

    jpMaxDepth.setLayout(new BoxLayout(jpMaxDepth, BoxLayout.Y_AXIS));

    jpMaxDepth.add(GuiUtil.addComponentAsFlow(jrbMaxDepth, FlowLayout.LEFT));
    jpMaxDepth.add(GuiUtil.addComponentAsFlow(jpMaxDepthSub, FlowLayout.RIGHT));

    /* REPETITION */
    final JSpinner jspnMaxRept = new JSpinner(new SpinnerNumberModel(s_maxRept, 1, 100, 1));
    jspnMaxRept.addChangeListener(
        new ChangeListener() {

          public void stateChanged(ChangeEvent e) {
            s_maxRept = (Integer) ((JSpinner) e.getSource()).getValue();

            logger.debug("maxRept " + s_maxRept);
          }
        });

    final JRadioButton jrbMaxRept = new JRadioButton("Repetition");

    final JLabel lblMaxRept = new JLabel("Count: ");

    final JPanel jpMaxReptSub =
        new JPanel() {
          @Override
          public void setEnabled(boolean b) {
            super.setEnabled(b);
            jspnMaxRept.setEnabled(b);
            lblMaxRept.setEnabled(b);
          }
        };
    jpMaxReptSub.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 0));
    jpMaxReptSub.add(lblMaxRept);
    jpMaxReptSub.add(jspnMaxRept);

    final JPanel jpMaxRept =
        new JPanel() {
          @Override
          public void setEnabled(boolean b) {
            super.setEnabled(b);
            jrbMaxRept.setEnabled(b);
            jpMaxReptSub.setEnabled(b);
          }
        };
    jpMaxRept.setLayout(new BoxLayout(jpMaxRept, BoxLayout.Y_AXIS));

    jpMaxRept.add(GuiUtil.addComponentAsFlow(jrbMaxRept, FlowLayout.LEFT));
    jpMaxRept.add(GuiUtil.addComponentAsFlow(jpMaxReptSub, FlowLayout.RIGHT));

    ///////////////////////////////////////
    final JLabel lbl = new JLabel("Limit search by:", SwingConstants.LEFT);

    final JPanel panel =
        new JPanel() {
          @Override
          public void setEnabled(boolean b) {
            super.setEnabled(b);
            lbl.setEnabled(b);
            jpMaxDepth.setEnabled(b);
            jpMaxRept.setEnabled(b);
          }

          @Override
          public void setVisible(boolean b) {
            super.setVisible(b);
            final JPanel p = this;
            //                SwingUtilities.invokeLater( new Runnable() {
            //                    public void run() {
            Window win = SwingUtilities.getWindowAncestor(p);
            System.err.println(win);
            if (win != null) {
              System.err.println("packing");
              win.pack();
            }
            //                    }
            //                } );
          }
        };
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 0));
    panel.add(GuiUtil.addComponentAsFlow(lbl, FlowLayout.LEFT));
    panel.add(jpMaxDepth);
    panel.add(jpMaxRept);

    ButtonGroup bg = new ButtonGroup();
    bg.add(jrbMaxDepth);
    bg.add(jrbMaxRept);

    /* CHECKBOX */
    final JCheckBox chboxRepeat =
        new JCheckBox("Allow subtask recursive repetition", s_isSubtaskRepetitionAllowed);

    chboxRepeat.addChangeListener(
        new ChangeListener() {

          public void stateChanged(ChangeEvent e) {
            if (s_isSubtaskRepetitionAllowed == chboxRepeat.isSelected()) return;

            s_isSubtaskRepetitionAllowed = chboxRepeat.isSelected();
            panel.setVisible(s_isSubtaskRepetitionAllowed);

            logger.debug("m_isSubtaskRepetitionAllowed " + s_isSubtaskRepetitionAllowed);
          }
        });

    panel.setVisible(s_isSubtaskRepetitionAllowed);

    final JCheckBox chboxIncremental = new JCheckBox("Incremental", s_isIncremental);
    chboxIncremental.setToolTipText("Incremental depth-first search");

    chboxIncremental.addChangeListener(
        new ChangeListener() {

          public void stateChanged(ChangeEvent e) {

            if (s_isIncremental == chboxIncremental.isSelected()) return;

            s_isIncremental = chboxIncremental.isSelected();

            logger.debug("isIncremental " + s_isIncremental);
          }
        });

    final JCheckBox chboxOptimize =
        new JCheckBox("Disable optimization in subtasks", s_disableOptimizationInSubtasks);
    chboxOptimize.setToolTipText("Use for debugging purposes");

    chboxOptimize.addChangeListener(
        new ChangeListener() {

          public void stateChanged(ChangeEvent e) {

            if (s_disableOptimizationInSubtasks == chboxOptimize.isSelected()) return;

            s_disableOptimizationInSubtasks = chboxOptimize.isSelected();

            logger.debug("disableOptimizationInSubtasks " + s_disableOptimizationInSubtasks);
          }
        });

    JPanel container1 = new JPanel();
    container1.setLayout(new BoxLayout(container1, BoxLayout.Y_AXIS));
    container1.setBorder(BorderFactory.createTitledBorder("Planning settings"));
    container1.add(GuiUtil.addComponentAsFlow(chboxOptimize, FlowLayout.LEFT));
    container1.add(GuiUtil.addComponentAsFlow(chboxIncremental, FlowLayout.LEFT));
    container1.add(GuiUtil.addComponentAsFlow(chboxRepeat, FlowLayout.LEFT));
    container1.add(GuiUtil.addComponentAsFlow(panel, FlowLayout.LEFT));

    JPanel container2 = new JPanel(new GridLayout(2, 0));
    container2.setBorder(BorderFactory.createTitledBorder("Logging options"));

    final JCheckBox linear = new JCheckBox("Detailed linear planning", isLinearLoggingOn());
    linear.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            setLinearLoggingOn(linear.isSelected());
          }
        });
    container2.add(linear);
    final JCheckBox subtask = new JCheckBox("Detailed subtask planning", isSubtaskLoggingOn());
    subtask.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            setSubtaskLoggingOn(subtask.isSelected());
          }
        });
    container2.add(subtask);

    JPanel main = new JPanel();
    main.setLayout(new BoxLayout(main, BoxLayout.Y_AXIS));
    main.add(container1);
    main.add(container2);

    return main;
  }