Ejemplo n.º 1
0
 ViewCoherence(Frame owner, XYSeriesCollection data, TimeInterval timeInterval) {
   super(owner, "Coherence", true);
   this.data = data;
   this.timeInterval = timeInterval;
   Object[] options = {"Close", "Print", "Export GRAPH"};
   // Create the JOptionPane.
   optionPane =
       new JOptionPane(
           createChartPanel(filterData(data)),
           JOptionPane.PLAIN_MESSAGE,
           JOptionPane.CLOSED_OPTION,
           null,
           options,
           options[0]);
   // Make this dialog display it.
   setContentPane(optionPane);
   optionPane.addPropertyChangeListener(this);
   setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
   addWindowListener(
       new WindowAdapter() {
         @Override
         public void windowClosing(WindowEvent we) {
           /*
            * Instead of directly closing the window, we're going to change
            * the JOptionPane's value property.
            */
           optionPane.setValue("Close");
         }
       });
   pack();
   setLocationRelativeTo(owner);
   setVisible(true);
 }
Ejemplo n.º 2
0
  userDialog(ApplicationFrame frame, Graphic gr) {
    super(frame, "Precizati intervalul...", true);
    parentFrame = frame;
    graphic = gr;

    left = new JTextField(10);
    right = new JTextField(10);
    error = new JTextField(10);

    Object[] optionPaneComponent = {text1, left, text2, right, text3, error};
    Object[] optionPaneButtons = {button1, button2};

    optionPane =
        new JOptionPane(
            optionPaneComponent,
            JOptionPane.QUESTION_MESSAGE,
            JOptionPane.YES_NO_OPTION,
            null,
            optionPaneButtons,
            optionPaneButtons[0]);

    setContentPane(optionPane);
    pack();

    optionPane.addPropertyChangeListener(this);

    setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
    setResizable(false);
  }
Ejemplo n.º 3
0
  private void addInputListener() {
    optionPane.addPropertyChangeListener(
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent e) {
            String prop = e.getPropertyName();
            if (isVisible()
                && (e.getSource() == optionPane)
                && (prop.equals(JOptionPane.VALUE_PROPERTY)
                    || prop.equals(JOptionPane.INPUT_VALUE_PROPERTY))) {
              Object value = optionPane.getValue();

              if (value == JOptionPane.UNINITIALIZED_VALUE) {
                // ignore reset
                return;
              }
              // Reset the JOptionPane's value.
              // If you don't do this, then if the user
              // presses the same button next time, no
              // property change event will be fired.
              optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE);

              if (value.equals(btnString1)) {
                typedText = textField.getText();
                try {
                  nodeKey = new Integer(Integer.parseInt(typedText));
                  // System.err.println( "AskNodeByKey key " + typedText);
                  if (!isNodeKeyValid(nodeKey)) {
                    JOptionPane.showMessageDialog(
                        PlanWorks.planWorks,
                        "Sorry, \"" + nodeKey.toString() + "\" " + "is not a valid key.",
                        "Invalid Key",
                        JOptionPane.ERROR_MESSAGE);
                  } else {
                    // we're done; dismiss the dialog
                    setVisible(false);
                  }
                } catch (NumberFormatException except) {
                  // text was invalid
                  textField.selectAll();
                  JOptionPane.showMessageDialog(
                      PlanWorks.planWorks,
                      "Sorry, \""
                          + typedText
                          + "\" "
                          + "isn't a valid response.\n"
                          + "Please enter a intger number",
                      "Invalid value for key",
                      JOptionPane.ERROR_MESSAGE);
                  nodeKey = null;
                }
              } else { // user closed dialog or clicked cancel
                nodeKey = null;
                setVisible(false);
              }
            }
          }
        });
  } // end addInputListener
Ejemplo n.º 4
0
 /**
  * @param owner parent frame
  * @param data list of arrays - double raw data for selected traces and time ranges
  * @param channelNames list of trace names
  * @param sampleRate sample rate of all traces (should be same)
  */
 public ViewCorrelation(
     Frame owner,
     List<double[]> data,
     List<String> channelNames,
     double sampleRate,
     TimeInterval ti) {
   super(owner, "Correlation", true);
   this.data = data;
   Object[] options = {"Close", "Print"};
   if (data.size() == 2) {
     seriesName = "Correlation " + channelNames.get(0) + "-" + channelNames.get(1);
   } else {
     seriesName = "Autocorrelation " + channelNames.get(0);
   }
   this.sampleRate = sampleRate;
   // Create the JOptionPane.
   optionPane =
       new JOptionPane(
           createChartPanel(filterData(data), ti),
           JOptionPane.PLAIN_MESSAGE,
           JOptionPane.CLOSED_OPTION,
           null,
           options,
           options[0]);
   // Make this dialog display it.
   setContentPane(optionPane);
   optionPane.addPropertyChangeListener(this);
   setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
   addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent we) {
           /*
            * Instead of directly closing the window, we're going to change the JOptionPane's
            * value property.
            */
           optionPane.setValue("Close");
         }
       });
   pack();
   setLocationRelativeTo(owner);
   setVisible(true);
 }
Ejemplo n.º 5
0
 public void init() {
   jop.addPropertyChangeListener(
       new PropertyChangeListener() {
         public void propertyChange(PropertyChangeEvent evt) {
           jta.append("用户改变了选择,老选项为:" + evt.getOldValue() + "\n新选项为:" + evt.getNewValue() + "!\n");
         }
       });
   bn.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           jop.createDialog(jf, "测试对话框").setVisible(true);
           jta.append(jop.getValue() + "\n");
         }
       });
   jf.add(new JScrollPane(jta));
   JPanel jp = new JPanel();
   jp.add(bn);
   jf.add(jp, BorderLayout.SOUTH);
   jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   jf.pack();
   jf.setVisible(true);
 }
Ejemplo n.º 6
0
  /**
   * Displays the VCard for an individual.
   *
   * @param vCard the users vcard.
   * @param parent the parent component, used for location.
   */
  public void viewFullProfile(final VCard vCard, JComponent parent) {
    final JTabbedPane tabbedPane = new JTabbedPane();

    // Initialize Panels
    personalPanel = new PersonalPanel();
    personalPanel.allowEditing(false);
    personalPanel.showJID(false);

    //        tabbedPane.addTab(Res.getString("tab.personal"), personalPanel);

    businessPanel = new BusinessPanel();
    businessPanel.allowEditing(false);
    tabbedPane.addTab(Res.getString("tab.business"), businessPanel);

    homePanel = new HomePanel();
    homePanel.allowEditing(false);
    //        tabbedPane.addTab(Res.getString("tab.home"), homePanel);

    avatarPanel = new AvatarPanel();
    avatarPanel.allowEditing(false);
    tabbedPane.addTab(Res.getString("tab.avatar"), avatarPanel);

    //        employeePanel = new EmployeePanel();
    //        employeePanel.allowEditing(false);
    //        tabbedPane.addTab("Pracownicy", employeePanel);

    String employeeOf = vCard.getField("employeeOf");
    if (vCard.getJabberId()
        == SparkManager.getUserManager()
            .getJIDFromDisplayName(SparkManager.getUserManager().getNickname())) {
      if ((employeeOf == null || employeeOf.isEmpty())) {
        employeeListPanel = new EmployeeListPanel();
        tabbedPane.addTab(Res.getString("tab.home"), homePanel);
        tabbedPane.addTab(Res.getString("tab.business"), businessPanel);
        tabbedPane.addTab("Pracownicy", employeeListPanel);
        employee = false;
      } else {

      }
    }

    // Build the UI
    buildUI(vCard);

    final JOptionPane pane;
    final JDialog dlg;

    TitlePanel titlePanel;

    ImageIcon icon = VCardManager.getAvatarIcon(vCard);
    if (icon == null) {
      icon = SparkRes.getImageIcon(SparkRes.BLANK_24x24);
    }

    // Create the title panel for this dialog
    titlePanel = new TitlePanel(Res.getString("title.profile.information"), "", icon, true);

    // Construct main panel w/ layout.
    final JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());
    mainPanel.add(titlePanel, BorderLayout.NORTH);

    // The user should only be able to close this dialog.
    Object[] options = {Res.getString("close")};
    pane =
        new JOptionPane(
            tabbedPane,
            JOptionPane.PLAIN_MESSAGE,
            JOptionPane.OK_CANCEL_OPTION,
            null,
            options,
            options[0]);

    mainPanel.add(pane, BorderLayout.CENTER);

    JOptionPane p = new JOptionPane();
    dlg = p.createDialog(parent, Res.getString("title.profile.information"));
    dlg.setModal(false);

    dlg.pack();
    dlg.setSize(600, 400);
    dlg.setResizable(true);
    dlg.setContentPane(mainPanel);
    dlg.setLocationRelativeTo(parent);

    PropertyChangeListener changeListener =
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent e) {
            Object o = pane.getValue();
            if (o instanceof Integer) {
              pane.removePropertyChangeListener(this);
              dlg.dispose();
              return;
            }

            String value = (String) pane.getValue();
            if (Res.getString("close").equals(value)) {
              pane.removePropertyChangeListener(this);
              dlg.dispose();
            }
          }
        };

    pane.addPropertyChangeListener(changeListener);

    dlg.setVisible(true);
    dlg.toFront();
    dlg.requestFocus();

    personalPanel.focus();
  }
Ejemplo n.º 7
0
 protected void installListeners() {
   if ((propertyChangeListener = createPropertyChangeListener()) != null) {
     optionPane.addPropertyChangeListener(propertyChangeListener);
   }
 }
Ejemplo n.º 8
0
  /** Creates the reusable dialog. */
  public iRuleDialog(Frame aFrame, MainGuiWindow parent) {
    super(aFrame, true);
    mainGuiWindow = parent;

    setTitle("New iRule");

    textField1 = new JTextField(10);
    textField2 = new JTextField(10);

    // Create an array of the text and components to be displayed.
    String msgString1 = "What was Dr. SEUSS's real last name?";
    String msgString2 = "(The answer is \"" + magicWord + "\".)";
    String msgString3 = "Some more text";
    String msgString4 = "nuthin";

    Object[] array1 = {msgString1, msgString2, textField1};
    Object[] array2 = {msgString2, msgString3, textField2};

    Object[] options = {btnString1, btnString2};

    JTextField xField = new JTextField(5);
    JTextField yField = new JTextField(5);

    frame = new JFrame();
    frame.setBounds(100, 100, 450, 300);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().setLayout(new BorderLayout(0, 0));

    panel_1 = new JPanel();
    frame.getContentPane().add(panel_1);
    panel_1.setLayout(new BorderLayout(10, 10));

    panel = new JPanel();
    panel_1.add(panel);
    GridBagLayout gbl_panel = new GridBagLayout();
    gbl_panel.columnWidths = new int[] {31, 152, 31, 160, 0};
    gbl_panel.rowHeights = new int[] {31, 14, 31, 20, 20, 0};
    gbl_panel.columnWeights = new double[] {0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
    gbl_panel.rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
    panel.setLayout(gbl_panel);

    //		JLabel lblNewiRule = new JLabel("New iRule");
    //		GridBagConstraints gbc_lblNewiRule = new GridBagConstraints();
    //		gbc_lblNewiRule.anchor = GridBagConstraints.NORTH;
    //		gbc_lblNewiRule.fill = GridBagConstraints.HORIZONTAL;
    //		gbc_lblNewiRule.insets = new Insets(0, 0, 5, 0);
    //		gbc_lblNewiRule.gridwidth = 3;
    //		gbc_lblNewiRule.gridx = 1;
    //		gbc_lblNewiRule.gridy = 1;
    //		panel.add(lblNewiRule, gbc_lblNewiRule);

    JLabel lblRuleName = new JLabel("New iRule Name");
    lblRuleName.setToolTipText("The short name of the iRule");
    GridBagConstraints gbc_lblRuleName = new GridBagConstraints();
    gbc_lblRuleName.fill = GridBagConstraints.HORIZONTAL;
    gbc_lblRuleName.insets = new Insets(0, 0, 5, 5);
    gbc_lblRuleName.gridx = 1;
    gbc_lblRuleName.gridy = 3;
    panel.add(lblRuleName, gbc_lblRuleName);

    txtNewiRuleName = new JTextField();
    txtNewiRuleName.setText("new_rule");
    txtNewiRuleName.setName("iRuleNameTextbox");
    GridBagConstraints gbc_txtNewiRuleName = new GridBagConstraints();
    gbc_txtNewiRuleName.anchor = GridBagConstraints.NORTH;
    gbc_txtNewiRuleName.fill = GridBagConstraints.HORIZONTAL;
    gbc_txtNewiRuleName.insets = new Insets(0, 0, 5, 0);
    gbc_txtNewiRuleName.gridx = 3;
    gbc_txtNewiRuleName.gridy = 3;
    panel.add(txtNewiRuleName, gbc_txtNewiRuleName);
    txtNewiRuleName.setColumns(10);

    // TODO: Make this contain asterisks
    // TODO: Potentially add a shoulder surfing replace display text as you type with asterisks.
    // TODO: Make sure not to write asterisks to the password variable stored in preferences
    lblPartition = new JLabel("Partition");
    lblPartition.setToolTipText("The administrative partition  to place in. We assume /Common");
    GridBagConstraints gbc_lblPartition = new GridBagConstraints();
    gbc_lblPartition.fill = GridBagConstraints.HORIZONTAL;
    gbc_lblPartition.insets = new Insets(0, 0, 0, 5);
    gbc_lblPartition.gridx = 1;
    gbc_lblPartition.gridy = 4;
    panel.add(lblPartition, gbc_lblPartition);

    txtNewiRulePartition = new JTextField();
    txtNewiRulePartition.setText("/Common");
    GridBagConstraints gbc_txtNewiRulePartition = new GridBagConstraints();
    gbc_txtNewiRulePartition.anchor = GridBagConstraints.NORTH;
    gbc_txtNewiRulePartition.fill = GridBagConstraints.HORIZONTAL;
    gbc_txtNewiRulePartition.gridx = 3;
    gbc_txtNewiRulePartition.gridy = 4;
    panel.add(txtNewiRulePartition, gbc_txtNewiRulePartition);
    txtNewiRulePartition.setColumns(10);

    optionPane =
        new JOptionPane(
            array1,
            JOptionPane.QUESTION_MESSAGE,
            JOptionPane.YES_NO_OPTION,
            null,
            options,
            options[0]);

    // Make this dialog display it.
    setContentPane(optionPane); // Testing the real quick multi option one

    // Handle window closing correctly.
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent we) {
            /*
             * Instead of directly closing the window,
             * we're going to change the JOptionPane's
             * value property.
             */
            optionPane.setValue(new Integer(JOptionPane.CLOSED_OPTION));
          }
        });

    // Ensure the text field always gets the first focus.
    addComponentListener(
        new ComponentAdapter() {
          public void componentShown(ComponentEvent ce) {
            textField1.requestFocusInWindow();
          }
        });

    // Register an event handler that puts the text into the option pane.
    textField1.addActionListener(this);

    // Register an event handler that reacts to option pane state changes.
    optionPane.addPropertyChangeListener(this);
  }
Ejemplo n.º 9
0
  public PlateInputDialog(JFrame parentFrame) {
    ParentFrame = parentFrame;
    int width = 330;
    int height = 300;
    setTitle("Input Model_Plate Information");
    setSize(width, height);
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    setLocation((int) (d.width / 2f) - width / 2, (int) (d.height / 2f) - height / 2);

    numPlatesTextField.setText("" + numPlates);
    // Getting date information
    numPlatesTextField.setBorder(BorderFactory.createTitledBorder("Number of Plates"));

    // Setting up the RaidioButtons for pixel saving selections
    JRadioButton r0 = new JRadioButton("384 wells");
    r0.setSelected(true);
    r0.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            numRows = 16;
            numCols = 24;
          }
        });
    JRadioButton r1 = new JRadioButton("96 wells");
    r1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            numRows = 8;
            numCols = 12;
          }
        });
    JRadioButton r2 = new JRadioButton("24 wells");
    r2.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            numRows = 4;
            numCols = 6;
          }
        });
    JRadioButton r3 = new JRadioButton("12 wells");
    r3.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            numRows = 3;
            numCols = 4;
          }
        });
    JRadioButton r4 = new JRadioButton("6 wells");
    r4.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            numRows = 2;
            numCols = 3;
          }
        });
    JRadioButton r5 = new JRadioButton("Movie");
    r5.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            numRows = -1;
            numCols = -1;
          }
        });
    // Group the radio buttons.
    ButtonGroup group = new ButtonGroup();
    group.add(r0);
    group.add(r1);
    group.add(r2);
    group.add(r3);
    group.add(r4);
    group.add(r5);

    JPanel radioPanel = new JPanel();
    radioPanel.setLayout(new GridLayout(7, 1));
    radioPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
    radioPanel.add(new JLabel("Wells/Model_Plate:"));
    radioPanel.add(r0);
    radioPanel.add(r1);
    radioPanel.add(r2);
    radioPanel.add(r3);
    radioPanel.add(r4);
    radioPanel.add(r5);

    r1.setSelected(true);
    numRows = 8;
    numCols = 12;

    Object[] array = {numPlatesTextField, radioPanel};
    // Create an array specifying the number of dialog buttons
    // and their text.
    Object[] options = {btnString1, btnString2};

    // Create the JOptionPane.
    optionPane =
        new JOptionPane(
            array,
            JOptionPane.QUESTION_MESSAGE,
            JOptionPane.YES_NO_OPTION,
            null,
            options,
            options[0]);

    // Make this dialog display it.
    setContentPane(optionPane);

    // Handle window closing correctly.
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent we) {
            optionPane.setValue(new Integer(JOptionPane.CLOSED_OPTION));
          }
        });

    // Ensure the text field always gets the first focus.
    addComponentListener(
        new ComponentAdapter() {
          public void componentShown(ComponentEvent ce) {
            numPlatesTextField.requestFocusInWindow();
          }
        });

    // Register an event handler that puts the text into the option pane.
    numPlatesTextField.addActionListener(this);

    // Register an event handler that reacts to option pane state changes.
    optionPane.addPropertyChangeListener(this);
    setVisible(true);
  }
Ejemplo n.º 10
0
  private static JSheet createSheet(final JOptionPane pane, Component parentComponent, int style) {
    Window window = getWindowForComponent(parentComponent);
    final JSheet sheet;
    if (window instanceof Frame) {
      sheet = new JSheet((Frame) window);
    } else {
      sheet = new JSheet((Dialog) window);
    }

    JComponent contentPane = (JComponent) sheet.getContentPane();
    contentPane.setLayout(new BorderLayout());

    if (isNativeSheetSupported()) {
      contentPane.setBorder(new EmptyBorder(12, 0, 0, 0));
    }

    contentPane.add(pane, BorderLayout.CENTER);
    sheet.setResizable(false);
    sheet.addWindowListener(
        new WindowAdapter() {

          private boolean gotFocus = false;

          @Override
          public void windowClosing(WindowEvent we) {
            pane.setValue(null);
          }

          @Override
          public void windowClosed(WindowEvent we) {
            if (pane.getValue() == JOptionPane.UNINITIALIZED_VALUE) {
              sheet.fireOptionSelected(pane);
            }
          }

          @Override
          public void windowGainedFocus(WindowEvent we) {
            // Once window gets focus, set initial focus
            if (!gotFocus) {
              // Ugly dirty hack: JOptionPane.selectInitialValue() is protected.
              // So we call directly into the UI. This may cause mayhem,
              // because we override the encapsulation.
              // pane.selectInitialValue();
              OptionPaneUI ui = pane.getUI();
              if (ui != null) {
                ui.selectInitialValue(pane);
              }
              gotFocus = true;
            }
          }
        });
    sheet.addComponentListener(
        new ComponentAdapter() {

          @Override
          public void componentShown(ComponentEvent ce) {
            // reset value to ensure closing works properly
            pane.setValue(JOptionPane.UNINITIALIZED_VALUE);
          }
        });
    pane.addPropertyChangeListener(
        new PropertyChangeListener() {

          public void propertyChange(PropertyChangeEvent event) {
            // Let the defaultCloseOperation handle the closing
            // if the user closed the window without selecting a button
            // (newValue = null in that case).  Otherwise, close the sheet.
            if (sheet.isVisible()
                && event.getSource() == pane
                && (event.getPropertyName().equals(JOptionPane.VALUE_PROPERTY))
                && event.getNewValue() != null
                && event.getNewValue() != JOptionPane.UNINITIALIZED_VALUE) {
              sheet.setVisible(false);
              sheet.fireOptionSelected(pane);
            }
          }
        });
    sheet.pack();
    return sheet;
  }
  public ThresholdingBoundsInputDialog_BatchRun(Model_Well[] wells) {
    int width = 350;
    int height = 480;
    setTitle("Input");
    setSize(width, height);
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    setLocation((int) (d.width / 2f) - width / 2, (int) (d.height / 2f) - height / 2);
    setModal(true);

    /** Features comboBox */
    ArrayList<String> list = new ArrayList<String>();
    String[] channelNames = models.Model_Main.getModel().getTheChannelNames();
    int len = channelNames.length;

    for (int i = 0; i < len; i++) list.add(channelNames[i]);

    Object[] obX = new Object[list.size()];
    if (list.size() > 0) for (int i = 0; i < list.size(); i++) obX[i] = list.get(i);
    channelBox_nuc = new JComboBox(obX);

    Object[] obX2 = new Object[list.size()];
    if (list.size() > 0) for (int i = 0; i < list.size(); i++) obX2[i] = list.get(i);
    channelBox_cyto = new JComboBox(obX2);

    TheWells = wells;
    textField = new JTextField[4];
    textField[0] = new JTextField(6); // Nuc bound
    textField[1] = new JTextField(6); // Cell bound
    textField[2] = new JTextField(6); // Back bound

    // Setting up the RaidioButtons for pixel saving selections
    JRadioButton r0 = new JRadioButton("Bounding Box");
    r0.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            CoordsToSave = 0;
          }
        });
    JRadioButton r1 = new JRadioButton("Centroid");
    r1.setSelected(true);
    r1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            CoordsToSave = 1;
          }
        });
    JRadioButton r2 = new JRadioButton("Outlines");
    r2.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            CoordsToSave = 2;
          }
        });
    JRadioButton r3 = new JRadioButton("Everything");
    r3.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            CoordsToSave = 3;
          }
        });
    // Group the radio buttons.
    ButtonGroup group = new ButtonGroup();
    group.add(r1);
    group.add(r0);
    group.add(r2);
    // group.add(r3);
    CoordsToSave = 1;
    JPanel radioPanel = new JPanel();
    radioPanel.setLayout(new GridLayout(4, 1));
    radioPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
    radioPanel.add(new JLabel("Coordinates for HDF Storage:"));
    radioPanel.add(r1);
    radioPanel.add(r0);
    radioPanel.add(r2);

    //
    // Loading parameters if common (pset!=null)
    //
    // models.Model_Main.getModel().getCytoplasmAnnulusCheckBox().setSelected(false);
    models.Model_Main.getModel().getGUI().getLoadCellsImmediatelyCheckBox().setSelected(false);
    textField[2].setText("0");

    models.Model_Main.getModel().getGUI().getLoadCellsImmediatelyCheckBox().setSelected(false);

    Model_ParameterSet pset = Model_ParameterSet.doWellsHaveSameParameterSet(wells);

    if (pset != null) {
      if (pset.exists("Thresh_Nuc_ChannelName")) {
        // nucBoundChannel
        int num = channelBox_nuc.getItemCount();
        for (int i = 0; i < num; i++) {
          String name = (String) channelBox_nuc.getItemAt(i);
          String par = pset.getParameter_String("Thresh_Nuc_ChannelName");
          if (par != null && name.equalsIgnoreCase(par)) channelBox_nuc.setSelectedIndex(i);
        }
      }
      if (pset.exists("Thresh_Cyt_ChannelName")) {
        // cytoBoundChannel
        int num = channelBox_cyto.getItemCount();
        for (int i = 0; i < num; i++) {
          String name = (String) channelBox_cyto.getItemAt(i);
          if (name.equalsIgnoreCase(pset.getParameter_String("Thresh_Cyt_ChannelName")))
            channelBox_cyto.setSelectedIndex(i);
        }
      }

      models.Model_Main.getModel().getGUI().getLoadCellsImmediatelyCheckBox().setSelected(false);

      if (pset.exists("Thresh_Nuc_Value"))
        textField[0].setText("" + pset.getParameter_float("Thresh_Nuc_Value"));
      if (pset.exists("Thresh_Cyt_Value"))
        textField[1].setText("" + pset.getParameter_float("Thresh_Cyt_Value"));
      if (pset.exists("Thresh_Bkgd_Value"))
        textField[2].setText("" + pset.getParameter_float("Thresh_Bkgd_Value"));
      if (pset.exists("CoordsToSaveToHDF")) {
        String co = pset.getParameter_String("CoordsToSaveToHDF");
        if (co != null) {
          if (co.equalsIgnoreCase("BoundingBox")) r0.setSelected(true);
          if (co.equalsIgnoreCase("Centroid")) r1.setSelected(true);
          if (co.equalsIgnoreCase("Outlines")) r2.setSelected(true);
        }
      }
    }

    // Create an array of the text and components to be displayed.
    String[] mess = new String[5];
    mess[0] = "Nucleus Thresholding Channel";
    mess[1] = "Nucleus Boundary Threshold";
    mess[2] = "Cytoplasm Thresholding Channel";
    mess[3] = "Cytoplasm Boundary Threshold";
    mess[4] = "Background Threshold";

    Object[] array = {
      mess[0],
      channelBox_nuc,
      mess[1],
      textField[0],
      mess[2],
      channelBox_cyto,
      mess[3],
      textField[1],
      mess[4],
      textField[2],
      new JLabel("   "),
      radioPanel
    };

    // Create an array specifying the number of dialog buttons
    // and their text.
    Object[] options = {btnString1, btnString2};

    // Create the JOptionPane.
    optionPane =
        new JOptionPane(
            array,
            JOptionPane.QUESTION_MESSAGE,
            JOptionPane.YES_NO_OPTION,
            null,
            options,
            options[0]);

    // Make this dialog display it.
    setContentPane(optionPane);

    // Handle window closing correctly.
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent we) {
            optionPane.setValue(new Integer(JOptionPane.CLOSED_OPTION));
          }
        });

    // Ensure the text field always gets the first focus.
    addComponentListener(
        new ComponentAdapter() {
          public void componentShown(ComponentEvent ce) {
            textField[0].requestFocusInWindow();
          }
        });

    // Register an event handler that puts the text into the option pane.
    textField[0].addActionListener(this);

    // Register an event handler that reacts to option pane state changes.
    optionPane.addPropertyChangeListener(this);
    setVisible(true);
  }
Ejemplo n.º 12
0
  public void showConfirmControlDesktopDialog(final String remoteUserName, String remoteNickName)
      throws Exception {

    Object object = confirmDialogMap.get(remoteUserName);
    if (object == null) {
      final JDialog jDialog = new JDialog(ViewManager.getComponent(MainFrame.class), false);
      jDialog.addWindowListener(
          new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent e) {
              jDialog.dispose();
              confirmDialogMap.remove(remoteUserName);
            }
          });

      final JOptionPane jOptionPane =
          new JOptionPane(
              remoteNickName + "(" + remoteUserName + ")" + "  申请控制,是否允许?",
              JOptionPane.QUESTION_MESSAGE,
              JOptionPane.YES_NO_OPTION);
      jDialog.setContentPane(jOptionPane);
      jDialog.setTitle("信息提示");
      jOptionPane.addPropertyChangeListener(
          new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
              String propertyName = evt.getPropertyName();
              if (jDialog.isVisible()
                  && evt.getSource() == jOptionPane
                  && propertyName.equals(JOptionPane.VALUE_PROPERTY)) {
                if (evt.getNewValue().equals(JOptionPane.YES_OPTION)) {
                  try {
                    // 找出正在控制的控制端
                    MemberListPanel memberListPanel =
                        ViewManager.getComponent(MemberListPanel.class);
                    DefaultListModel model =
                        (DefaultListModel) memberListPanel.getMemberList().getModel();
                    for (int i = 0; i < model.size(); i++) {
                      MemberListItem item = (MemberListItem) model.get(i);
                      if (item.getShareDesktopState()
                          == Constants.MEMBER_STATUS_SHAREDESKTOP_CONTROL) {
                        services
                            .getScreenShareService()
                            .notAgreeControlDesktop(item.getData().getName());
                      }
                    }
                    services.getScreenShareService().agreeControlDesktop(remoteUserName);
                  } catch (Exception e1) {
                    log.error("showConfirmControlDesktopDialog", e1);
                  }
                  confirmDialogMap.remove(remoteUserName);
                  jDialog.dispose();
                } else if (evt.getNewValue().equals(JOptionPane.NO_OPTION)) {
                  confirmDialogMap.remove(remoteUserName);
                  jDialog.dispose();
                }
              }
            }
          });
      jDialog.pack();
      FadeWindow fadeWindow = new FadeWindow(jDialog);
      //        	fadeWindow.startRuning();
      fadeWindow.setPosistionInRightBottom();
      fadeWindow.setWindowOpacity(1.0f);
      fadeWindow.setVisible(true);
      //        	fadeWindow.startFadeIn();
      confirmDialogMap.put(remoteUserName, remoteUserName);
    }
  }
Ejemplo n.º 13
0
  // 被动关闭
  public void stopDesktopView(String remoteUserName) throws Exception {
    log.info("stopDesktopView");
    VncViewer viewer = viewerMap.get("vncview_" + remoteUserName);
    if (viewer == null) {
      return;
    }
    viewer.setCustomProperty("IsDestroy", "true");
    viewer.setEnabled(false);
    viewer.disconnect();
    viewer.destroy(); // dispose!

    VncViewPanel viewPanel = null;
    MaxVncPanelWindow maxVncPanelWindow = ViewManager.getComponent(MaxVncPanelWindow.class);
    DockingLayoutMeetingPanel dockingLayoutMeetingPanel =
        ViewManager.getComponent(DockingLayoutMeetingPanel.class);
    View findInViewMap = dockingLayoutMeetingPanel.findInViewMap("vncview_" + remoteUserName);
    if (maxVncPanelWindow.isVisible()) {
      viewPanel = maxVncPanelWindow.getVncViewPanel();
    } else {
      if (findInViewMap != null) {
        viewPanel = (VncViewPanel) findInViewMap.getComponent();
      }
    }

    if (viewPanel != null && viewPanel.isConnected()) {
      final JDialog jDialog = new JDialog(ViewManager.getComponent(MainFrame.class), false);
      jDialog.addWindowListener(
          new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent e) {
              jDialog.dispose();
            }
          });

      final JOptionPane jOptionPane =
          new JOptionPane("远程桌面 " + remoteUserName + " 的连接已经断开", JOptionPane.INFORMATION_MESSAGE);
      jDialog.setContentPane(jOptionPane);
      jDialog.setTitle("信息提示");
      jOptionPane.addPropertyChangeListener(
          new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
              String propertyName = evt.getPropertyName();
              //    				System.out.println(propertyName+" , "+evt.getSource());
              if (jDialog.isVisible()
                  && evt.getSource() == jOptionPane
                  && propertyName.equals(JOptionPane.VALUE_PROPERTY)) {
                //    					jDialog.setVisible(false);
                jDialog.dispose();
              }
            }
          });
      jDialog.pack();
      FadeWindow fadeWindow = new FadeWindow(jDialog);
      fadeWindow.setVisible(true);
      fadeWindow.setPosistionInRightBottom();
      fadeWindow.startFadeIn();
    }
    maxVncPanelWindow.setVncViewPanel(null);
    maxVncPanelWindow.dispose();
    dockingLayoutMeetingPanel.removePanel("vncview_" + remoteUserName);
    viewerMap.put("vncview_" + remoteUserName, null);
    ShareFileServerUtil.getInstance()
        .startScreenShareToOneClientCallBack(
            DataUtil.getLoginInfo().getConfno(),
            remoteUserName,
            DataUtil.getLoginInfo().getUsername(),
            "DESKTOP_STOPVIWE",
            "-1");
    log.debug("stopDesktopView End");
  }
Ejemplo n.º 14
0
  public TableInputDialog(Frame parent, String title, boolean bModal) {
    super(parent, title, bModal);
    final JTextField jtxfRows = new JTextField(3);
    final JTextField jtxfCols = new JTextField(3);
    final JTextField jtxfBorder = new JTextField(3);
    final JTextField jtxfSpace = new JTextField(3);
    final JTextField jtxfPad = new JTextField(3);
    final Object[] buttonLabels = {
      Translatrix.getTranslationString("DialogAccept"),
      Translatrix.getTranslationString("DialogCancel")
    };
    Object[] panelContents = {
      Translatrix.getTranslationString("TableRows"), jtxfRows,
      Translatrix.getTranslationString("TableColumns"), jtxfCols,
      Translatrix.getTranslationString("TableBorder"), jtxfBorder,
      Translatrix.getTranslationString("TableCellSpacing"), jtxfSpace,
      Translatrix.getTranslationString("TableCellPadding"), jtxfPad
    };
    jOptionPane =
        new JOptionPane(
            panelContents,
            JOptionPane.QUESTION_MESSAGE,
            JOptionPane.OK_CANCEL_OPTION,
            null,
            buttonLabels,
            buttonLabels[0]);

    setContentPane(jOptionPane);
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);

    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent we) {
            jOptionPane.setValue(new Integer(JOptionPane.CLOSED_OPTION));
          }
        });

    jOptionPane.addPropertyChangeListener(
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent e) {
            String prop = e.getPropertyName();
            if (isVisible()
                && (e.getSource() == jOptionPane)
                && (prop.equals(JOptionPane.VALUE_PROPERTY)
                    || prop.equals(JOptionPane.INPUT_VALUE_PROPERTY))) {
              Object value = jOptionPane.getValue();
              if (value == JOptionPane.UNINITIALIZED_VALUE) {
                return;
              }
              jOptionPane.setValue(JOptionPane.UNINITIALIZED_VALUE);
              if (value.equals(buttonLabels[0])) {
                inputRows = jtxfRows.getText();
                inputCols = jtxfCols.getText();
                inputBorder = jtxfBorder.getText();
                inputSpace = jtxfSpace.getText();
                inputPad = jtxfPad.getText();
                setVisible(false);
              } else {
                inputRows = "";
                inputCols = "";
                inputBorder = "";
                inputSpace = "";
                inputPad = "";
                setVisible(false);
              }
            }
          }
        });
    this.pack();
  }
Ejemplo n.º 15
0
  /**
   * Displays a users profile.
   *
   * @param jid the jid of the user.
   * @param vcard the users vcard.
   * @param parent the parent component, used for location handling.
   */
  public void displayProfile(final String jid, VCard vcard, JComponent parent) {
    VCardViewer viewer = new VCardViewer(jid);

    final JFrame dlg = new JFrame(Res.getString("title.view.profile.for", jid));

    avatarLabel = new JLabel();
    avatarLabel.setHorizontalAlignment(JButton.RIGHT);
    avatarLabel.setBorder(BorderFactory.createBevelBorder(0, Color.white, Color.lightGray));

    // The user should only be able to close this dialog.
    Object[] options = {Res.getString("button.view.profile"), Res.getString("close")};
    final JOptionPane pane =
        new JOptionPane(
            viewer,
            JOptionPane.PLAIN_MESSAGE,
            JOptionPane.OK_CANCEL_OPTION,
            null,
            options,
            options[0]);

    //  mainPanel.add(pane, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
    // GridBagConstraints.BOTH, new Insets(0, 5, 5, 5), 0, 0));

    dlg.setIconImage(SparkRes.getImageIcon(SparkRes.PROFILE_IMAGE_16x16).getImage());

    dlg.pack();
    dlg.setSize(350, 250);
    dlg.setResizable(true);
    dlg.setContentPane(pane);
    dlg.setLocationRelativeTo(parent);

    PropertyChangeListener changeListener =
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent e) {
            if (pane.getValue() instanceof Integer) {
              pane.removePropertyChangeListener(this);
              dlg.dispose();
              return;
            }
            String value = (String) pane.getValue();
            if (Res.getString("close").equals(value)) {
              pane.removePropertyChangeListener(this);
              dlg.dispose();
            } else if (Res.getString("button.view.profile").equals(value)) {
              pane.setValue(JOptionPane.UNINITIALIZED_VALUE);
              SparkManager.getVCardManager().viewFullProfile(jid, pane);
            }
          }
        };

    pane.addPropertyChangeListener(changeListener);

    dlg.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent keyEvent) {
            if (keyEvent.getKeyChar() == KeyEvent.VK_ESCAPE) {
              dlg.dispose();
            }
          }
        });

    dlg.setVisible(true);
    dlg.toFront();
    dlg.requestFocus();
  }
  protected boolean exportApplicationPrompt() throws IOException, SketchException {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.add(Box.createVerticalStrut(6));

    // Box panel = Box.createVerticalBox();

    // Box labelBox = Box.createHorizontalBox();
    //    String msg = "<html>Click Export to Application to create a standalone, " +
    //      "double-clickable application for the selected plaforms.";

    //    String msg = "Export to Application creates a standalone, \n" +
    //      "double-clickable application for the selected plaforms.";
    String line1 = "Export to Application creates double-clickable,";
    String line2 = "standalone applications for the selected plaforms.";
    JLabel label1 = new JLabel(line1, SwingConstants.CENTER);
    JLabel label2 = new JLabel(line2, SwingConstants.CENTER);
    label1.setAlignmentX(Component.LEFT_ALIGNMENT);
    label2.setAlignmentX(Component.LEFT_ALIGNMENT);
    //    label1.setAlignmentX();
    //    label2.setAlignmentX(0);
    panel.add(label1);
    panel.add(label2);
    int wide = label2.getPreferredSize().width;
    panel.add(Box.createVerticalStrut(12));

    final JCheckBox windowsButton = new JCheckBox("Windows");
    // windowsButton.setMnemonic(KeyEvent.VK_W);
    windowsButton.setSelected(Preferences.getBoolean("export.application.platform.windows"));
    windowsButton.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            Preferences.setBoolean(
                "export.application.platform.windows", windowsButton.isSelected());
          }
        });

    final JCheckBox macosxButton = new JCheckBox("Mac OS X");
    // macosxButton.setMnemonic(KeyEvent.VK_M);
    macosxButton.setSelected(Preferences.getBoolean("export.application.platform.macosx"));
    macosxButton.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            Preferences.setBoolean("export.application.platform.macosx", macosxButton.isSelected());
          }
        });

    final JCheckBox linuxButton = new JCheckBox("Linux");
    // linuxButton.setMnemonic(KeyEvent.VK_L);
    linuxButton.setSelected(Preferences.getBoolean("export.application.platform.linux"));
    linuxButton.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            Preferences.setBoolean("export.application.platform.linux", linuxButton.isSelected());
          }
        });

    JPanel platformPanel = new JPanel();
    // platformPanel.setLayout(new BoxLayout(platformPanel, BoxLayout.X_AXIS));
    platformPanel.add(windowsButton);
    platformPanel.add(Box.createHorizontalStrut(6));
    platformPanel.add(macosxButton);
    platformPanel.add(Box.createHorizontalStrut(6));
    platformPanel.add(linuxButton);
    platformPanel.setBorder(new TitledBorder("Platforms"));
    // Dimension goodIdea = new Dimension(wide, platformPanel.getPreferredSize().height);
    // platformPanel.setMaximumSize(goodIdea);
    wide = Math.max(wide, platformPanel.getPreferredSize().width);
    platformPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    panel.add(platformPanel);

    //  Box indentPanel = Box.createHorizontalBox();
    //  indentPanel.add(Box.createHorizontalStrut(new JCheckBox().getPreferredSize().width));
    final JCheckBox showStopButton = new JCheckBox("Show a Stop button");
    // showStopButton.setMnemonic(KeyEvent.VK_S);
    showStopButton.setSelected(Preferences.getBoolean("export.application.stop"));
    showStopButton.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            Preferences.setBoolean("export.application.stop", showStopButton.isSelected());
          }
        });
    showStopButton.setEnabled(Preferences.getBoolean("export.application.fullscreen"));
    showStopButton.setBorder(new EmptyBorder(3, 13, 6, 13));
    //  indentPanel.add(showStopButton);
    //  indentPanel.setAlignmentX(Component.LEFT_ALIGNMENT);

    final JCheckBox fullScreenButton = new JCheckBox("Full Screen (Present mode)");
    // fullscreenButton.setMnemonic(KeyEvent.VK_F);
    fullScreenButton.setSelected(Preferences.getBoolean("export.application.fullscreen"));
    fullScreenButton.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            boolean sal = fullScreenButton.isSelected();
            Preferences.setBoolean("export.application.fullscreen", sal);
            showStopButton.setEnabled(sal);
          }
        });
    fullScreenButton.setBorder(new EmptyBorder(3, 13, 3, 13));

    JPanel optionPanel = new JPanel();
    optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.Y_AXIS));
    optionPanel.add(fullScreenButton);
    optionPanel.add(showStopButton);
    //    optionPanel.add(indentPanel);
    optionPanel.setBorder(new TitledBorder("Options"));
    wide = Math.max(wide, platformPanel.getPreferredSize().width);
    // goodIdea = new Dimension(wide, optionPanel.getPreferredSize().height);
    optionPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    // optionPanel.setMaximumSize(goodIdea);
    panel.add(optionPanel);

    Dimension good;
    // label1, label2, platformPanel, optionPanel
    good = new Dimension(wide, label1.getPreferredSize().height);
    label1.setMaximumSize(good);
    good = new Dimension(wide, label2.getPreferredSize().height);
    label2.setMaximumSize(good);
    good = new Dimension(wide, platformPanel.getPreferredSize().height);
    platformPanel.setMaximumSize(good);
    good = new Dimension(wide, optionPanel.getPreferredSize().height);
    optionPanel.setMaximumSize(good);

    //    JPanel actionPanel = new JPanel();
    //    optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.X_AXIS));
    //    optionPanel.add(Box.createHorizontalGlue());

    //    final JDialog frame = new JDialog(editor, "Export to Application");

    //    JButton cancelButton = new JButton("Cancel");
    //    cancelButton.addActionListener(new ActionListener() {
    //      public void actionPerformed(ActionEvent e) {
    //        frame.dispose();
    //        return false;
    //      }
    //    });

    // Add the buttons in platform-specific order
    //    if (PApplet.platform == PConstants.MACOSX) {
    //      optionPanel.add(cancelButton);
    //      optionPanel.add(exportButton);
    //    } else {
    //      optionPanel.add(exportButton);
    //      optionPanel.add(cancelButton);
    //    }
    String[] options = {"Export", "Cancel"};
    final JOptionPane optionPane =
        new JOptionPane(
            panel,
            JOptionPane.PLAIN_MESSAGE,
            // JOptionPane.QUESTION_MESSAGE,
            JOptionPane.YES_NO_OPTION,
            null,
            options,
            options[0]);

    final JDialog dialog = new JDialog(this, "Export Options", true);
    dialog.setContentPane(optionPane);

    optionPane.addPropertyChangeListener(
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent e) {
            String prop = e.getPropertyName();

            if (dialog.isVisible()
                && (e.getSource() == optionPane)
                && (prop.equals(JOptionPane.VALUE_PROPERTY))) {
              // If you were going to check something
              // before closing the window, you'd do
              // it here.
              dialog.setVisible(false);
            }
          }
        });
    dialog.pack();
    dialog.setResizable(false);

    Rectangle bounds = getBounds();
    dialog.setLocation(
        bounds.x + (bounds.width - dialog.getSize().width) / 2,
        bounds.y + (bounds.height - dialog.getSize().height) / 2);
    dialog.setVisible(true);

    Object value = optionPane.getValue();
    if (value.equals(options[0])) {
      return jmode.handleExportApplication(sketch);
    } else if (value.equals(options[1]) || value.equals(new Integer(-1))) {
      // closed window by hitting Cancel or ESC
      statusNotice("Export to Application canceled.");
    }
    return false;
  }
Ejemplo n.º 17
0
  /**
   * Shows dialog and wait for answer. Returns next dialog, or null if it there is no next dialog.
   */
  public final ConfigDialog showDialog() {
    /* making non modal dialog */
    dialogGate = new CountDownLatch(1);
    dialogPanel = null; /* TODO: disabled caching because back button
                               wouldn't work with
                               dialogPanel.setContentPane(optionPane) method
                               it would work with optionPane.createDialog...
                               but that causes lockups with old javas and
                               gnome. */
    if (dialogPanel == null) {
      final ImageIcon[] icons = getIcons();
      MyButton defaultButtonClass = null;
      final List<JComponent> allOptions = new ArrayList<JComponent>(additionalOptions);
      if (skipButtonEnabled()) {
        skipButton = new JCheckBox(Tools.getString("Dialog.ConfigDialog.SkipButton"));
        skipButton.setEnabled(false);
        skipButton.setBackground(Tools.getDefaultColor("ConfigDialog.Background.Light"));
        skipButton.addItemListener(skipButtonListener());
        allOptions.add(skipButton);
      }
      final String[] buttons = buttons();
      /* populate buttonToObjectMap */
      for (int i = 0; i < buttons.length; i++) {
        options[i] = new MyButton(buttons[i], icons[i]);
        options[i].setBackgroundColor(Tools.getDefaultColor("ConfigDialog.Button"));
        allOptions.add(options[i]);
        buttonToObjectMap.put(buttons[i], options[i]);
        if (buttons[i].equals(defaultButton())) {
          defaultButtonClass = options[i];
        }
      }
      /* create option pane */
      final JPanel b = body();
      final MyButton dbc = defaultButtonClass;
      Tools.invokeAndWait(
          new Runnable() {
            public void run() {
              optionPane =
                  new JOptionPane(
                      b,
                      getMessageType(),
                      JOptionPane.DEFAULT_OPTION,
                      icon(),
                      allOptions.toArray(new JComponent[allOptions.size()]),
                      dbc);
              optionPane.setPreferredSize(new Dimension(dialogWidth(), dialogHeight()));
              optionPane.setMaximumSize(new Dimension(dialogWidth(), dialogHeight()));
              optionPane.setMinimumSize(new Dimension(dialogWidth(), dialogHeight()));

              optionPane.setBackground(Tools.getDefaultColor("ConfigDialog.Background.Dark"));
              final Container mainFrame = Tools.getGUIData().getMainFrame();
              if (mainFrame instanceof JApplet) {
                final JFrame noframe = new JFrame();
                dialogPanel = new JDialog(noframe);
                dialogPanel.setContentPane(optionPane);
              } else {
                dialogPanel = new JDialog((JFrame) mainFrame);
                dialogPanel.setContentPane(optionPane);
              }
              dialogPanel.setModal(false);
              dialogPanel.setResizable(true);
            }
          });
      /* set location like the previous dialog */
    }
    /* add action listeners */
    final Map<MyButton, OptionPaneActionListener> optionPaneActionListeners =
        new HashMap<MyButton, OptionPaneActionListener>();
    for (final MyButton o : options) {
      final OptionPaneActionListener ol = new OptionPaneActionListener();
      optionPaneActionListeners.put(o, ol);
      o.addActionListener(ol);
    }

    final PropertyChangeListener propertyChangeListener =
        new PropertyChangeListener() {
          @Override
          public void propertyChange(final PropertyChangeEvent evt) {
            if (JOptionPane.VALUE_PROPERTY.equals(evt.getPropertyName())
                && !"uninitializedValue".equals(evt.getNewValue())) {
              optionPaneAnswer = optionPane.getValue();
              dialogGate.countDown();
            }
          }
        };
    optionPane.addPropertyChangeListener(propertyChangeListener);
    initDialog();
    Tools.invokeAndWait(
        new Runnable() {
          public void run() {
            dialogPanel.setPreferredSize(new Dimension(dialogWidth(), dialogHeight()));
            dialogPanel.setMaximumSize(new Dimension(dialogWidth(), dialogHeight()));
            dialogPanel.setMinimumSize(new Dimension(dialogWidth(), dialogHeight()));
            dialogPanel.setLocationRelativeTo(Tools.getGUIData().getMainFrame());
            dialogPanel.setVisible(true);
          }
        });
    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            dialogPanel.setLocationRelativeTo(Tools.getGUIData().getMainFrameContentPane());
            /* although the location was set before, it is set again as a
             * workaround for gray dialogs with nothing in it, that appear
             * in some comination of Java and compiz. */
          }
        });
    initDialogAfterVisible();
    try {
      dialogGate.await();
    } catch (InterruptedException ignored) {
      Thread.currentThread().interrupt();
    }

    if (optionPaneAnswer instanceof String) {
      setPressedButton((String) optionPaneAnswer);
    } else {
      setPressedButton(cancelButton());
    }
    optionPane.removePropertyChangeListener(propertyChangeListener);
    /* remove action listeners */
    for (final MyButton o : options) {
      o.removeActionListener(optionPaneActionListeners.get(o));
    }
    dialogPanel.dispose();
    return checkAnswer();
  }
Ejemplo n.º 18
0
  public ZScoreFilterDialog() {
    int width = 270;
    int height = 300;
    setTitle("Z-Score Filter");
    setSize(width, height);
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    setLocation((int) (d.width / 2f) - width / 2, (int) (d.height / 2f) - height / 2);
    setModal(true);
    zScore_channel = "All";
    zScore_threshold = 1;

    /** Features comboBox */
    ArrayList<String> list = new ArrayList<String>();
    String[] channelNames = models.Model_Main.getModel().getTheChannelNames();
    int len = channelNames.length;
    for (int i = 0; i < len; i++) list.add(channelNames[i]);
    list.add("All");

    Object[] obX = new Object[list.size()];
    if (list.size() > 0) for (int i = 0; i < list.size(); i++) obX[i] = list.get(i);
    channelBox = new JComboBox(obX);

    textField = new JTextField[1];
    textField[0] = new JTextField(6); // Z-score cutoff
    textField[0].setText("2");

    // Setting up the RaidioButtons for pixel saving selections
    JRadioButton r0 = new JRadioButton(">");
    r0.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            Operater = ">";
          }
        });
    JRadioButton r1 = new JRadioButton("<");
    r1.setSelected(true);
    r1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            Operater = "<";
          }
        });
    JRadioButton r2 = new JRadioButton("< and >");
    r2.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            Operater = "<>";
          }
        });

    // Group the radio buttons.
    ButtonGroup group = new ButtonGroup();
    r0.setSelected(true);
    group.add(r0);
    group.add(r1);
    group.add(r2);
    JPanel radioPanel = new JPanel();
    radioPanel.setLayout(new GridLayout(3, 0));
    radioPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
    radioPanel.add(r0);
    radioPanel.add(r1);
    radioPanel.add(r2);

    // Create an array of the text and components to be displayed.
    String[] mess = new String[3];
    mess[0] = "Channels to Search:";
    mess[1] = "Z-Score Threshold:";
    mess[2] = "Search Criteria:";

    Object[] array = {mess[0], channelBox, mess[1], textField[0], mess[2], radioPanel};

    // Create an array specifying the number of dialog buttons
    // and their text.
    Object[] options = {btnString1, btnString2};

    // Create the JOptionPane.
    optionPane =
        new JOptionPane(
            array,
            JOptionPane.QUESTION_MESSAGE,
            JOptionPane.YES_NO_OPTION,
            null,
            options,
            options[0]);

    // Make this dialog display it.
    setContentPane(optionPane);

    // Handle window closing correctly.
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent we) {
            optionPane.setValue(new Integer(JOptionPane.CLOSED_OPTION));
          }
        });

    // Ensure the text field always gets the first focus.
    addComponentListener(
        new ComponentAdapter() {
          public void componentShown(ComponentEvent ce) {
            textField[0].requestFocusInWindow();
          }
        });

    // Register an event handler that puts the text into the option pane.
    textField[0].addActionListener(this);

    // Register an event handler that reacts to option pane state changes.
    optionPane.addPropertyChangeListener(this);
    setVisible(true);
  }