Exemplo n.º 1
0
 @Override
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() == okButton) {
     if (original != null) {
       original.restoreState(config);
     }
     dialog.setVisible(false);
   } else if (e.getSource() == cancelButton) {
     dialog.setVisible(false);
   }
 }
Exemplo n.º 2
0
 public char[] askPassword() {
   char[] password = null;
   final JDialog dlg = new JDialog(frm, "Password", true);
   final JPasswordField jpf = new JPasswordField(15);
   final JButton[] btns = {new JButton("Enter"), new JButton("Cancel")};
   for (int i = 0; i < btns.length; i++) {
     btns[i].addActionListener(
         new ActionListener() {
           public void actionPerformed(ActionEvent e) {
             dlg.setVisible(false);
           }
         });
   }
   Object[] prts = new Object[] {"Please input a password:"******"Invalid password, passwords must be " + PASSWORD_MIN + " characters long");
     System.exit(1);
   }
   return password;
 }
  /* (non-Javadoc)
   * @see uk.nhs.cfh.dsp.srth.desktop.appservice.error.ErrorLoggerServiceListener#errorThrown(org.jdesktop.swingx.error.ErrorInfo)
   */
  public void errorThrown(ErrorInfo errorInfo) {
    // set LNF first to avoid component UI errors
    LookAndFeelUtils.setDefaultLNF();

    errorPane.setErrorInfo(errorInfo);
    errorDialog.setVisible(true);
  }
  /* (non-Javadoc)
   * @see org.jdesktop.swingx.error.ErrorReporter#reportError(org.jdesktop.swingx.error.ErrorInfo)
   */
  public void reportError(final ErrorInfo errorInfo) {

    SubmitErrorReportTask task = new SubmitErrorReportTask(errorInfo);
    task.execute();
    // dispose errorPanel
    errorDialog.setVisible(false);
  }
Exemplo n.º 5
0
 @Override
 public void actionPerformed(ActionEvent actionEvent) {
   Dimension all = parent.getSize();
   Dimension d = dialog.getSize();
   dialog.setLocation((all.width - d.width) / 2, (all.height - d.height) / 2);
   dialog.setVisible(true);
 }
Exemplo n.º 6
0
  static void tell(String question, String btnText) {
    final JDialog d = new JDialog();
    d.setLocationRelativeTo(null);
    JPanel bpane = new JPanel(new FlowLayout());
    JLabel l = new JLabel(question);

    JPanel cp = (JPanel) d.getContentPane();

    cp.setLayout(new FlowLayout());
    cp.add(l, BorderLayout.CENTER);
    cp.add(bpane, BorderLayout.SOUTH);

    JButton b1 = new JButton("OK");
    bpane.add(b1);

    d.pack();

    d.setVisible(true);

    b1.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            ans = ((JButton) e.getSource()).getText();
            d.dispose();
          }
        });
  }
  /**
   * @param editor
   * @param idDialog
   * @param dialog
   * @param title
   */
  public static void setDialogVisible(
      @Nullable Editor editor, String idDialog, JDialog dialog, String title) {
    Point location = null;

    if (editor != null) {
      Point caretLocation = editor.visualPositionToXY(editor.getCaretModel().getVisualPosition());
      SwingUtilities.convertPointToScreen(caretLocation, editor.getComponent());

      String[] position = UtilsPreferences.getDialogPosition(idDialog).split("x");
      if (!(position[0].equals("0") && position[1].equals("0"))) {
        location = new Point(Integer.parseInt(position[0]), Integer.parseInt(position[1]));
      }
    }

    if (location == null) {
      // Center to screen
      dialog.setLocationRelativeTo(null);
    } else {
      dialog.setLocation(location.x, location.y);
    }

    dialog.setTitle(title);
    dialog.pack();
    dialog.setVisible(true);
  }
Exemplo n.º 8
0
  public JDialog showProgressDialog(
      JDialog parent, String title, String message, boolean includeCancelButton) {
    fileSearchCancelled = false;
    final JDialog prog;
    JProgressBar bar = new JProgressBar(SwingConstants.HORIZONTAL);
    JButton cancel = new JButton(Globals.lang("Cancel"));
    cancel.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent event) {
            fileSearchCancelled = true;
            ((JButton) event.getSource()).setEnabled(false);
          }
        });
    prog = new JDialog(parent, title, false);
    bar.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    bar.setIndeterminate(true);
    if (includeCancelButton) {
      prog.add(cancel, BorderLayout.SOUTH);
    }
    prog.add(new JLabel(message), BorderLayout.NORTH);
    prog.add(bar, BorderLayout.CENTER);
    prog.pack();
    prog.setLocationRelativeTo(null); // parent);
    // SwingUtilities.invokeLater(new Runnable() {
    //    public void run() {
    prog.setVisible(true);
    //    }
    // });
    return prog;
  }
Exemplo n.º 9
0
  public void showTaskDialog(final Task selectedValue) {

    final JDialog taskForm =
        new JDialog(this, "Create new task", Dialog.ModalityType.APPLICATION_MODAL);
    JPanel content = new JPanel(new GridLayout(3, 1));
    final JPanel namePanel = new JPanel(new FlowLayout());
    namePanel.add(new JLabel("Name:"));
    final JTextField taskName =
        new JTextField(selectedValue == null ? "" : selectedValue.getName(), 30);
    namePanel.add(taskName);
    content.add(namePanel);

    final JPanel descPanel = new JPanel(new FlowLayout());
    descPanel.add(new JLabel("Description:"));
    final JTextArea taskDesc =
        new JTextArea(selectedValue == null ? "" : selectedValue.getDescription(), 5, 30);
    descPanel.add(taskDesc);
    content.add(descPanel);

    JPanel btnPanel = new JPanel(new FlowLayout());

    JButton cancel = new JButton("Cancel");
    cancel.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            taskForm.dispose();
          }
        });
    btnPanel.add(cancel);

    JButton save = new JButton("Save");
    save.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (selectedValue == null) {
              Task task = new Task(taskName.getText());
              task.setDescription(taskDesc.getText());
              logger.info("Create task: " + task);
              controller.addTask(task);
            } else {
              selectedValue.setName(taskName.getText());
              selectedValue.setDescription(taskDesc.getText());
              logger.info("Update task: " + selectedValue);
              controller.editTask(selectedValue);
            }
            taskForm.dispose();
          }
        });
    btnPanel.add(save);

    content.add(btnPanel);

    taskForm.getContentPane().add(content);
    taskForm.setLocationRelativeTo(null);
    taskForm.pack();
    taskForm.setVisible(true);
  }
 /**
  * Common event handling code - can handle desirable actions (such as buttons being clicked) and
  * undesirable actions (the window being closed) all in a common location.
  *
  * @param command a String representing the action that occurred.
  */
 private void processCommand(String command) {
   dialog.setVisible(false);
   if (CONNECT.equals(command)) {
     options.setValue(JOptionPane.OK_OPTION);
   } else {
     options.setValue(JOptionPane.CANCEL_OPTION);
   }
 }
Exemplo n.º 11
0
  /**
   * shows a color chooser dialog
   *
   * @param initialColor the initial Color set when the color-chooser is shown
   * @return the selected color or <code>null</code> if the user opted out
   */
  public Color showColorChooserDialog(Color initialColor) {

    setColor(initialColor);
    SVGColorTracker ok = new SVGColorTracker(this);
    JDialog dialog = createDialog(Editor.getParent(), "", true, this, ok, null);
    dialog.setVisible(true);

    return ok.getColor();
  }
Exemplo n.º 12
0
  public void edit(Evaluator evaluator, JFrame parent) {
    if (!(evaluator instanceof Evaluator)) {
      return; // error?
    }

    // create an editor dialog box
    JDialog editor = new Editor(parent, (Evaluator) evaluator);
    editor.setVisible(true);
  }
Exemplo n.º 13
0
  public void setVisible(boolean bShow) {
    if (bShow) {
      if (CSH_Util.haveTopic(dialogTitle)) setHelpEnabled(true);
      else setHelpEnabled(false);

      enableControlPanel();
    }
    VPopupManager.addRemovePopup(this, bShow);
    super.setVisible(bShow);
  }
Exemplo n.º 14
0
  public int showDialog() {
    panel = new JPanel(new GridBagLayout());

    double lower = Double.NEGATIVE_INFINITY;
    double upper = Double.POSITIVE_INFINITY;

    if (parameter.isZeroOne) {
      lower = 0.0;
      upper = 1.0;
    } else if (parameter.isNonNegative) {
      lower = 0.0;
    }

    panel = new JPanel(new GridBagLayout());

    setupComponents();

    JOptionPane optionPane =
        new JOptionPane(
            panel, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, null, null);
    optionPane.setBorder(new EmptyBorder(12, 12, 12, 12));

    final JDialog dialog = optionPane.createDialog(frame, "Linked Parameter Setup");

    priorSettingsPanel.setDialog(dialog);
    priorSettingsPanel.setParameter(parameter);

    if (OSType.isMac()) {
      dialog.setMinimumSize(new Dimension(dialog.getBounds().width, 300));
    } else {
      Toolkit tk = Toolkit.getDefaultToolkit();
      Dimension d = tk.getScreenSize();
      if (d.height < 700 && panel.getHeight() > 450) {
        dialog.setSize(new Dimension(panel.getWidth() + 100, 550));
      } else {
        // setSize because optionsPanel is shrunk in dialog
        dialog.setSize(new Dimension(panel.getWidth() + 100, panel.getHeight() + 100));
      }

      //            System.out.println("panel width = " + panel.getWidth());
      //            System.out.println("panel height = " + panel.getHeight());
    }

    dialog.pack();
    dialog.setResizable(true);
    dialog.setVisible(true);

    int result = JOptionPane.CANCEL_OPTION;
    Integer value = (Integer) optionPane.getValue();
    if (value != null && value != -1) {
      result = value;
    }

    return result;
  }
 /**
  * Method used by the SystemIO class to get interactive user input requested by a running MIPS
  * program (e.g. syscall #5 to read an integer). SystemIO knows whether simulator is being run at
  * command line by the user, or by the GUI. If run at command line, it gets input from System.in
  * rather than here.
  *
  * <p>This is an overloaded method. This version, with the String parameter, is used to get input
  * from a popup dialog.
  *
  * @param prompt Prompt to display to the user.
  * @return User input.
  */
 public String getInputString(String prompt) {
   String input;
   JOptionPane pane =
       new JOptionPane(prompt, JOptionPane.QUESTION_MESSAGE, JOptionPane.DEFAULT_OPTION);
   pane.setWantsInput(true);
   JDialog dialog = pane.createDialog(Globals.getGui(), "MIPS Keyboard Input");
   dialog.setVisible(true);
   input = (String) pane.getInputValue();
   this.postRunMessage(Globals.userInputAlert + input + "\n");
   return input;
 }
Exemplo n.º 16
0
  public void setVisible(boolean flag) {
    Rectangle rc = m_mainframe.getBounds();
    Rectangle rcthis = getBounds();
    setBounds(
        (int) (rc.getWidth() - rcthis.getWidth()) / 2 + rc.x,
        (int) (rc.getHeight() - rcthis.getHeight()) / 2 + rc.y,
        (int) rcthis.getWidth(),
        (int) rcthis.getHeight());

    super.setVisible(flag);
  }
Exemplo n.º 17
0
  /** Close me */
  public void close() {
    if (dialog != null) {
      dialog.setVisible(false);
      if (dialog.isModal()) {
        dialog.setModal(false);
      }
    }

    if (frame != null) {
      frame.setVisible(false);
    }
  }
Exemplo n.º 18
0
 public void show() {
   if (!myRequestFocus) {
     myDialog.setFocusableWindowState(false);
   }
   myDialog.setVisible(true);
   SwingUtilities.invokeLater(
       new Runnable() {
         public void run() {
           myDialog.setFocusableWindowState(true);
         }
       });
 }
Exemplo n.º 19
0
  public DatePicker(JFrame parent) {
    d = new JDialog();
    d.setModal(true);
    String[] header = {"Sun", "Mon", "Tue", "Wed", "Thur", "Fri", "Sat"};
    JPanel p1 = new JPanel(new GridLayout(7, 7));
    p1.setPreferredSize(new Dimension(430, 120));

    for (int x = 0; x < button.length; x++) {
      final int selection = x;
      button[x] = new JButton();
      button[x].setFocusPainted(false);
      button[x].setBackground(Color.white);
      if (x > 6)
        button[x].addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent ae) {
                day = button[selection].getActionCommand();
                d.dispose();
              }
            });
      if (x < 7) {
        button[x].setText(header[x]);
        button[x].setForeground(Color.red);
      }
      p1.add(button[x]);
    }
    JPanel p2 = new JPanel(new GridLayout(1, 3));
    JButton previous = new JButton("<< Previous");
    previous.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            month--;
            displayDate();
          }
        });
    p2.add(previous);
    p2.add(l);
    JButton next = new JButton("Next >>");
    next.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            month++;
            displayDate();
          }
        });
    p2.add(next);
    d.add(p1, BorderLayout.CENTER);
    d.add(p2, BorderLayout.SOUTH);
    d.pack();
    d.setLocationRelativeTo(parent);
    displayDate();
    d.setVisible(true);
  }
 public void hideDialog(JDialog dialog, Project project) {
   if (project == null) {
     dialog.dispose();
   } else {
     IdeFrameImpl frame = getFrame(project);
     if (frame.isActive()) {
       dialog.dispose();
     } else {
       queueForDisposal(dialog, project);
       dialog.setVisible(false);
     }
   }
 }
Exemplo n.º 21
0
  public int showDialog() {

    options = new OptionsPanel(6, 6);

    options.addComponent(autoScaleCheck);

    JPanel panel = new JPanel();
    panel.setLayout(new FlowLayout());
    panel.add(fromLabel);
    panel.add(fromNumberField);
    panel.add(toLabel);
    panel.add(toNumberField);
    options.addComponent(panel);

    JPanel panel1 = new JPanel();
    panel1.setLayout(new FlowLayout());
    panel1.add(new JLabel("Width from:"));
    panel1.add(fromWidthField);
    panel1.add(new JLabel("to:"));
    panel1.add(toWidthField);
    options.addComponent(panel1);

    JOptionPane optionPane =
        new JOptionPane(
            options, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, null, null);
    optionPane.setBorder(new EmptyBorder(12, 12, 12, 12));

    final JDialog dialog = optionPane.createDialog(frame, "Setup colour range");
    dialog.pack();

    autoScaleCheck.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            boolean enabled = !autoScaleCheck.isSelected();
            fromLabel.setEnabled(enabled);
            fromNumberField.setEnabled(enabled);
            toLabel.setEnabled(enabled);
            toNumberField.setEnabled(enabled);
          }
        });

    dialog.setVisible(true);

    int result = JOptionPane.CANCEL_OPTION;
    Integer value = (Integer) optionPane.getValue();
    if (value != null && value.intValue() != -1) {
      result = value.intValue();
    }

    return result;
  }
Exemplo n.º 22
0
  /* (non-Javadoc)
   * @see uk.nhs.cfh.dsp.srth.desktop.appservice.error.ErrorLoggerServiceListener#errorThrown(java.lang.Object, java.lang.String, java.lang.Throwable)
   */
  public void errorThrown(Object source, String errorMessage, Throwable cause, Level level) {

    // set LNF first to avoid component UI errors
    LookAndFeelUtils.setDefaultLNF();
    errorPane.setErrorInfo(
        new ErrorInfo(
            "Error",
            errorMessage,
            cause.fillInStackTrace().getMessage(),
            "",
            cause,
            level,
            new HashMap<String, String>(0)));
    errorDialog.setVisible(true);
  }
Exemplo n.º 23
0
 public void actionPerformed(ActionEvent evt) {
   JDialog parent = GUIUtilities.getParentDialog(ColorWellButton.this);
   JDialog dialog;
   if (parent != null) {
     dialog = new ColorPickerDialog(parent, jEdit.getProperty("colorChooser.title"), true);
   } else {
     dialog =
         new ColorPickerDialog(
             JOptionPane.getFrameForComponent(ColorWellButton.this),
             jEdit.getProperty("colorChooser.title"),
             true);
   }
   dialog.pack();
   dialog.setVisible(true);
 }
Exemplo n.º 24
0
  /**
   * Open me
   *
   * @param modal _more_
   */
  public void show(boolean modal) {
    if (!windowOk()) {
      return;
    }
    if (dialog != null) {
      dialog.setModal(modal);
      dialog.setVisible(true);
    }
    if (frame != null) {
      frame.setVisible(true);
    }

    if (window != null) {
      GuiUtils.showWidget(window);
    }
  }
Exemplo n.º 25
0
  public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equals("New Game")) {
      newGame();
    }

    if (e.getActionCommand().equals("Exit Game")) {
      exit();
    }
    if (e.getActionCommand().equals("About")) {
      JDialog f = new JDialog();
      f.add(new JLabel(new ImageIcon("splash_applet.jpg")));
      f.setSize(660, 520);
      f.setLocationRelativeTo(this);
      f.setVisible(true);
    }
  }
Exemplo n.º 26
0
 /** Create and show the gui */
 public void showDialog() {
   if (dialog == null) {
     JFrame parentFrame = persistenceManager.getIdv().getIdvUIManager().getFrame();
     dialog = new JDialog(parentFrame, "Loading Bundle");
     if (dialogTitle != null) {
       dialog.setTitle("Loading Bundle: " + dialogTitle);
     }
     dialog.getContentPane().add(contents);
   }
   dialog.pack();
   Point center = GuiUtils.getLocation(null);
   if (persistenceManager.getIdv().okToShowWindows()) {
     dialog.setLocation(20, 20);
     dialog.setVisible(true);
   }
 }
  public void show() {
    if (pst.isEmbeddedView()) {
      return;
    }

    TimeObserver time = new TimeObserver("Show Dialog");
    time.empezar();
    JDialog dlg = (JDialog) parentContainer;

    time.terminar();

    if (dialogFixture == null) {
      dlg.setModal(true);
      dlg.setVisible(true);
    }
  }
Exemplo n.º 28
0
  /**
   * Opens a dialog that asks the user if they want to make a virtual entry a non virtual entry. If
   * the user clicks 'Yes' the 'change class' dialog opens.
   */
  public void doVirtualEntryDisplay() {
    virtualEntryDialog = new JDialog(owner, CBIntText.get("Virtual Entry"), true);

    CBButton btnYes =
        new CBButton(CBIntText.get("Yes"), CBIntText.get("Click yes to make a Virtual Entry."));
    CBButton btnNo =
        new CBButton(
            CBIntText.get("No"),
            CBIntText.get("Click no to cancel without making a Virtual Entry."));

    // TE: layout stuff...
    Container pane = virtualEntryDialog.getContentPane();
    pane.setLayout(new BorderLayout());
    CBPanel panel1 = new CBPanel();
    CBPanel panel2 = new CBPanel();
    CBPanel panel3 = new CBPanel();

    panel1.add(
        new JLabel(
            CBIntText.get(
                "This entry is a Virtual Entry.  Are you sure you want to give this entry an object class?")));
    panel2.add(btnYes);
    panel2.add(btnNo);

    panel3.makeWide();
    panel3.addln(panel1);
    panel3.addln(panel2);

    pane.add(panel3);

    btnYes.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            processVirtualEntry();
          }
        });

    btnNo.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            shutVirtualEntryDialog();
          }
        });
    virtualEntryDialog.setSize(475, 125);
    CBUtility.center(virtualEntryDialog, owner);
    virtualEntryDialog.setVisible(true);
  }
Exemplo n.º 29
0
  public static Map[] showOpenMapDialog(final JFrame owner) throws IOException {
    final JFileChooser ch = new JFileChooser();
    if (config.getFile("mapLastOpenDir") != null) {
      ch.setCurrentDirectory(config.getFile("mapLastOpenDir"));
    }
    ch.setDialogType(JFileChooser.OPEN_DIALOG);
    ch.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    if (ch.showOpenDialog(MainFrame.getInstance()) != JFileChooser.APPROVE_OPTION) {
      return null;
    }
    final File dir = ch.getSelectedFile();
    config.set("mapLastOpenDir", dir);
    final String[] maps = dir.list(FILTER_TILES);
    for (int i = 0; i < maps.length; ++i) {
      maps[i] = maps[i].substring(0, maps[i].length() - MapIO.EXT_TILE.length());
    }
    final JDialog dialog = new JDialog(owner, Lang.getMsg("gui.chooser"));
    dialog.setModal(true);
    dialog.setLocationRelativeTo(null);
    dialog.setLayout(new BorderLayout());

    final JList list = new JList(maps);
    final JButton btn = new JButton(Lang.getMsg("gui.chooser.Ok"));

    btn.addActionListener(
        new AbstractAction() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            if (list.getSelectedValue() != null) {
              dialog.setVisible(false);
            }
          }
        });

    dialog.add(new JScrollPane(list), BorderLayout.CENTER);
    dialog.add(btn, BorderLayout.SOUTH);
    dialog.pack();
    dialog.setVisible(true);
    dialog.dispose();

    Map[] loadedMaps = new Map[list.getSelectedIndices().length];
    for (int i = 0; i < list.getSelectedIndices().length; i++) {
      loadedMaps[i] = MapIO.loadMap(dir.getPath(), (String) list.getSelectedValues()[i]);
    }
    return loadedMaps;
  }
Exemplo n.º 30
0
  public static PlatePanel createPanelDialog(
      Plate plate, HeatMapModel heatmapModel, Window ownerDialog) {
    JDialog jDialog = new JDialog(ownerDialog);

    jDialog.setTitle("PlateViewer: " + plate.getBarcode());
    Random posJitter = new Random();
    jDialog.setBounds(200 + posJitter.nextInt(100), 200 + posJitter.nextInt(100), 700, 500);

    jDialog.setLayout(new BorderLayout());

    PlatePanel platePanel = new PlatePanel(plate, heatmapModel);
    jDialog.add(platePanel, BorderLayout.CENTER);

    jDialog.setVisible(true);

    return platePanel;
  }