public int getTitleHeight(Component c) {
   int th = 21;
   int fh = getBorderInsets(c).top + getBorderInsets(c).bottom;
   if (c instanceof JDialog) {
     JDialog dialog = (JDialog) c;
     th = dialog.getSize().height - dialog.getContentPane().getSize().height - fh - 1;
     if (dialog.getJMenuBar() != null) {
       th -= dialog.getJMenuBar().getSize().height;
     }
   } else if (c instanceof JInternalFrame) {
     JInternalFrame frame = (JInternalFrame) c;
     th = frame.getSize().height - frame.getRootPane().getSize().height - fh - 1;
     if (frame.getJMenuBar() != null) {
       th -= frame.getJMenuBar().getSize().height;
     }
   } else if (c instanceof JRootPane) {
     JRootPane jp = (JRootPane) c;
     if (jp.getParent() instanceof JFrame) {
       JFrame frame = (JFrame) c.getParent();
       th = frame.getSize().height - frame.getContentPane().getSize().height - fh - 1;
       if (frame.getJMenuBar() != null) {
         th -= frame.getJMenuBar().getSize().height;
       }
     } else if (jp.getParent() instanceof JDialog) {
       JDialog dialog = (JDialog) c.getParent();
       th = dialog.getSize().height - dialog.getContentPane().getSize().height - fh - 1;
       if (dialog.getJMenuBar() != null) {
         th -= dialog.getJMenuBar().getSize().height;
       }
     }
   }
   return th;
 }
  /*
   * The following method creates the color chooser dialog box
   */
  public void createColorDialog() {
    colorDialog = new JDialog(this, new String("Choose a color"), true);
    colorDialog.getContentPane().add(createColorPicker(), BorderLayout.CENTER);

    JButton okButton = new JButton("OK");

    // This class is used to create a special ActionListener for
    //    the ok button
    class ButtonListener implements ActionListener {
      /*
       * This method is called whenever the ok button is clicked
       */
      public void actionPerformed(ActionEvent event) {
        currentChoice.changeColor(color_panel.getColor());
        currentChoice.repaint();
        fontColor = color_panel.getColor();
        colorDialog.hide();
      } // end actionPerformed method
    }
    ActionListener listener = new ButtonListener();
    okButton.addActionListener(listener);

    // Add the four font control panels to one big panel using
    //  a grid layout
    JPanel buttonPanel = new JPanel();

    buttonPanel.add(okButton);

    // Add the button panel to the content pane of the ColorDialogue
    colorDialog.getContentPane().add(buttonPanel, BorderLayout.SOUTH);

    colorDialog.pack();
  }
  @SuppressWarnings("static-access")
  public DatePicker(Observer observer, Date selecteddate, Locale locale) {
    super();
    this.locale = locale;
    register(observer);
    screen = new JDialog();
    screen.addWindowFocusListener(this);
    screen.setSize(200, 200);
    screen.setResizable(false);
    screen.setModal(true);
    screen.setUndecorated(true);
    screen.setDefaultLookAndFeelDecorated(true);
    screen.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
    screen.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    screen.getContentPane().setLayout(new BorderLayout());
    //
    calendar = new GregorianCalendar();
    setSelectedDate(selecteddate);
    Calendar c = calendar;
    if (selectedDate != null) c = selectedDate;
    updateScreen(c);
    screen.getContentPane().add(navPanel, BorderLayout.NORTH);

    screen.setTitle(getString("program.title", "Date Picker"));
  }
Beispiel #4
0
  private void warning(String msg) {
    final JDialog warn;
    JButton ok;
    JLabel message;

    warn = new JDialog();
    warn.setTitle(msg);

    message = new JLabel("CryoBay: " + msg);
    ok = new JButton("Ok");

    ok.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            warn.dispose();
          }
        });

    warn.getContentPane().setLayout(new BorderLayout());
    warn.getContentPane().add(message, "North");
    warn.getContentPane().add(ok, "South");

    warn.setSize(200, 80);
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    warn.setLocation(screenSize.width / 2 - 100, screenSize.height / 2 - 40);
    warn.setResizable(false);
    warn.show();
  }
Beispiel #5
0
  /**
   * @param aWritableModel
   * @param store
   * @return
   * @throws MessagingException
   * @throws JAXBException
   */
  private Folder getInputFolder(final GnucashWritableFile aWritableModel, Store store)
      throws MessagingException, JAXBException {
    String folderName = aWritableModel.getUserDefinedAttribute("imap.folder");
    Folder folder = null;
    if (folderName != null) {
      folder = store.getFolder(folderName);
    }
    while (folder == null || !folder.exists()) {
      final JDialog selectFolderDialog = new JDialog((JFrame) null, "Select mail folder");
      selectFolderDialog.getContentPane().setLayout(new BorderLayout());
      final JList folderListBox = new JList(new Vector<String>(getFolders(store)));
      JButton okButton = new JButton("OK");
      okButton.addActionListener(
          new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent aE) {
              if (folderListBox.getSelectedIndices() != null) {
                if (folderListBox.getSelectedIndices().length == 1) {
                  selectFolderDialog.setVisible(false);
                }
              }
            }
          });
      selectFolderDialog.getContentPane().add(new JScrollPane(folderListBox), BorderLayout.CENTER);
      selectFolderDialog.getContentPane().add(okButton, BorderLayout.SOUTH);
      selectFolderDialog.setModal(true);
      selectFolderDialog.pack();
      selectFolderDialog.setVisible(true);
      folderName = folderListBox.getSelectedValue().toString();
      aWritableModel.setUserDefinedAttribute("imap.folder", folderName);
      folder = store.getFolder(folderName);
    }
    return folder;
  }
  /** If Certificate was not accepted during installation user must accept it here. */
  public static boolean acceptCertificatePanel(String certificate) throws Exception {
    CertificatePanel CertificatePanel = new CertificatePanel(certificate);
    ResourceBundle bundle = NbBundle.getBundle(AcceptCertificate.class);
    String yesLabel = bundle.getString("MSG_CertificateYesButton");
    String noLabel = bundle.getString("MSG_CertificateNoButton");
    JButton yesButton = new JButton(yesLabel);
    JButton noButton = new JButton(noLabel);

    ActionListener listener =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            command = e.getActionCommand();
            d.setVisible(false);
          }
        };
    yesButton.addActionListener(listener);
    noButton.addActionListener(listener);

    yesButton.setActionCommand("yes"); // NOI18N
    noButton.setActionCommand("no"); // NOI18N

    yesButton.getAccessibleContext().setAccessibleName(bundle.getString("ACSN_AcceptButton"));
    yesButton.getAccessibleContext().setAccessibleName(bundle.getString("ACSD_AcceptButton"));

    noButton.getAccessibleContext().setAccessibleName(bundle.getString("ACSN_RejectButton"));
    noButton.getAccessibleContext().setAccessibleName(bundle.getString("ACSD_RejectButton"));

    int maxWidth = Math.max(yesButton.getPreferredSize().width, noButton.getPreferredSize().width);
    int maxHeight =
        Math.max(yesButton.getPreferredSize().height, noButton.getPreferredSize().height);
    yesButton.setPreferredSize(new Dimension(maxWidth, maxHeight));
    noButton.setPreferredSize(new Dimension(maxWidth, maxHeight));

    d = new JDialog((Frame) null, bundle.getString("MSG_CertificateDlgTitle"), true);

    d.getAccessibleContext().setAccessibleName(bundle.getString("ACSN_CertificateDlg"));
    d.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_CertificateDlg"));

    d.getContentPane().add(CertificatePanel, BorderLayout.CENTER);
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
    buttonPanel.setBorder(BorderFactory.createEmptyBorder(17, 12, 11, 11));
    buttonPanel.add(yesButton);
    buttonPanel.add(noButton);
    d.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
    d.setSize(new Dimension(600, 600));
    d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    d.setModal(true);
    d.setResizable(true);
    // Center on screen
    d.setLocationRelativeTo(null);
    d.setVisible(true);

    if ("yes".equals(command)) { // NOI18N
      return true;
    } else {
      return false;
    }
  }
Beispiel #7
0
  public void addContainer(Container container) {
    if (dialog.getContentPane() != null) {
      dialog.getContentPane().removeAll();
    }

    dialog.getContentPane().add(container);
    dialog.pack();
    dialog.setLocationRelativeTo(container);
  }
Beispiel #8
0
  /** Searches a contact */
  private void searchContact() {
    final JDialog dialog = new JDialog();
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    setTitle("Kontakt suchen");
    dialog.setResizable(false);
    dialog.setBounds(
        this.getLocationOnScreen().x + 350, this.getLocationOnScreen().y - 40, 250, 110);
    dialog.getContentPane().setLayout(new BorderLayout());
    JPanel contentPanel = new JPanel();
    contentPanel.setLayout(new FlowLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    dialog.getContentPane().add(contentPanel, BorderLayout.CENTER);

    JLabel lblKontaktid = new JLabel("Kontaktnummer");
    contentPanel.add(lblKontaktid);

    final JTextField textField = new JTextField();
    contentPanel.add(textField);
    textField.setColumns(3);

    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
    dialog.getContentPane().add(buttonPane, BorderLayout.SOUTH);

    JButton okButton = new JButton("OK");
    okButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              refresh(ekd.select(Integer.parseInt(textField.getText().trim())));
            } catch (NumberFormatException ex) {
              ex.printStackTrace();
            } catch (NoEmailKontaktFoundException e1) {
              JOptionPane.showMessageDialog(null, e1.getMessage());
              e1.printStackTrace();
            }
          }
        });
    buttonPane.add(okButton);
    getRootPane().setDefaultButton(okButton);

    JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            dialog.dispose();
          }
        });
    buttonPane.add(cancelButton);

    dialog.setVisible(true);
  }
 private JDialog getNotifyWindow() {
   if (NotifyWindow == null) {
     NotifyWindow = new JDialog();
     NotifyWindow.getContentPane().setLayout(null);
     NotifyWindow.setPreferredSize(new java.awt.Dimension(271, 138));
     NotifyWindow.getContentPane().add(getJLabel8());
     NotifyWindow.getContentPane().add(getJLabel9());
     NotifyWindow.getContentPane().add(getCloseButton());
     NotifyWindow.getContentPane().add(getJLabel10());
     NotifyWindow.setLocationRelativeTo(null);
     NotifyWindow.setSize(271, 138);
   }
   return NotifyWindow;
 }
Beispiel #10
0
  /**
   * Show a window dialog where the user can select which painters are active
   *
   * @param owner The window which will be parenting the created dialog
   */
  public void showSelectionDialog(Window owner) {
    JPanel inner = getSelectionPanel();

    JDialog dialog = new JDialog(owner);
    dialog.getContentPane().setLayout(new BorderLayout());
    dialog.setTitle(I18n.text("Active layers selection"));
    JScrollPane scrollPane = new JScrollPane(inner);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

    dialog.getContentPane().add(scrollPane);
    dialog.setSize(300, 300);
    dialog.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    GuiUtils.centerOnScreen(dialog);
    dialog.setVisible(true);
  }
Beispiel #11
0
  private void installPlugin(final File plugin) {
    final JDialog dialog = new JDialog(frame, "Installing Plugin", true);
    dialog.getContentPane().setLayout(new BorderLayout());
    JProgressBar bar = new JProgressBar();
    bar.setIndeterminate(true);
    bar.setString("Installing Plugin.  Please wait...");
    bar.setStringPainted(true);
    dialog.getContentPane().add(bar, BorderLayout.CENTER);
    dialog.pack();
    dialog.setSize(225, 55);

    final SwingWorker installerThread =
        new SwingWorker() {
          @Override
          public Object construct() {
            File pluginsDir = new File(binDir.getParentFile(), "plugins");
            String tempName = plugin.getName() + ".part";
            File tempPluginsFile = new File(pluginsDir, tempName);

            File realPluginsFile = new File(pluginsDir, plugin.getName());

            // Copy Plugin into Dir.
            try {
              // Just for fun. Show no matter what for two seconds.
              Thread.sleep(2000);

              copy(plugin.toURI().toURL(), tempPluginsFile);

              // If successfull, rename to real plugin name.
              tempPluginsFile.renameTo(realPluginsFile);
            } catch (Exception e) {
              e.printStackTrace();
            }
            return realPluginsFile;
          }

          @Override
          public void finished() {
            dialog.setVisible(false);
          }
        };

    // Start installation
    installerThread.start();

    dialog.setLocationRelativeTo(frame);
    dialog.setVisible(true);
  }
Beispiel #12
0
  private void createEditorDialog() {

    int w = top.getSize().width;
    //      int h = top.getSize().height;

    editorDialog = new JDialog(top, true);
    editorDialog.setTitle(rb.getString("dialog.editor.title"));

    JPanel base = new JPanel(new GridLayout(2, 1));
    editorDialog.getContentPane().add(base);

    JPanel p = new JPanel(new BorderLayout());
    p.setPreferredSize(new Dimension(w * 6 / 10, 0));
    editorChooser = new JFileChooserHistoryComboBox();
    editorChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    p.add(BorderLayout.SOUTH, editorChooser);
    base.add(p);

    p = new JPanel();

    okEditorDialogButton = new JButton();
    okEditorDialogButton.setText(rb.getString("dialog.common.button.ok.text"));
    editorDialog.getRootPane().setDefaultButton(okEditorDialogButton);
    p.add(okEditorDialogButton);

    cancelEditorDialogButton = new JButton();
    cancelEditorDialogButton.setText(rb.getString("dialog.common.button.cancel.text"));
    p.add(cancelEditorDialogButton);
    base.add(p);

    editorDialog.pack();
  }
  /** Creates a new instance of Main */
  public Main() {

    TextElementModel textElementModel = new TextElementModel();
    DocumentModel documentModel = new DocumentModel();

    DefaultController controller = new DefaultController();

    DisplayViewPanel displayViewPanel = new DisplayViewPanel(controller);
    PropertiesViewPanel propertiesViewPanel = new PropertiesViewPanel(controller);

    controller.addView(displayViewPanel);
    controller.addView(propertiesViewPanel);
    controller.addModel(textElementModel);
    controller.addModel(documentModel);

    textElementModel.initDefault();
    documentModel.initDefault();

    JFrame displayFrame = new JFrame("Display (View 1)");
    displayFrame.getContentPane().add(displayViewPanel, BorderLayout.CENTER);
    displayFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    displayFrame.pack();

    JDialog propertiesDialog = new JDialog(displayFrame, "Properties (View 2)");
    propertiesDialog.setModal(false);
    propertiesDialog.getContentPane().add(propertiesViewPanel, BorderLayout.CENTER);
    propertiesDialog.pack();

    displayFrame.setVisible(true);
    propertiesDialog.setVisible(true);
  }
  /** Brings up a window with a scrolling text pane that display the help information. */
  private void showHelp() {
    JDialog dialog = new JDialog(this, resources.getString("dialog.help.title"));
    final JEditorPane helpText = new JEditorPane();
    try {
      URL url = getClass().getResource("GridWorldHelp.html");

      helpText.setPage(url);
    } catch (Exception e) {
      helpText.setText(resources.getString("dialog.help.error"));
    }
    helpText.setEditable(false);
    helpText.addHyperlinkListener(
        new HyperlinkListener() {
          public void hyperlinkUpdate(HyperlinkEvent ev) {
            if (ev.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
              try {
                helpText.setPage(ev.getURL());
              } catch (Exception ex) {
              }
          }
        });
    JScrollPane sp = new JScrollPane(helpText);
    sp.setPreferredSize(new Dimension(650, 500));
    dialog.getContentPane().add(sp);
    dialog.setLocation(getX() + getWidth() - 200, getY() + 50);
    dialog.pack();
    dialog.setVisible(true);
  }
  /**
   * Shows the dialog. First a dialog must be constructed using one of the constructors of this
   * class. After that this method should be called to actually show the dialog. This method returns
   * either JOptionPane.OK_OPTION if the user wants to select his choices or
   * JOptionPane.CANCEL_OPTION if he does not want to.
   *
   * @param parent The parent frame of this dialog.
   * @return int The returnvalue, can be either JOptionPane.OK_OPTION or JOptionPane.CANCEL_OPTION
   */
  public int showDialog(Component parent) {
    Frame frame =
        parent instanceof Frame
            ? (Frame) parent
            : (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parent);

    // String title = getUI().getDialogTitle(this);

    dialog = new JDialog(frame, title, true);
    Container contentPane = dialog.getContentPane();
    contentPane.setLayout(new BorderLayout());
    contentPane.add(this, BorderLayout.CENTER);

    dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    dialog.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent we) {
            cancel();
          }
        });

    dialog.pack();
    dialog.setLocationRelativeTo(parent);

    dialog.setVisible(true);
    return returnValue;
  }
 public void testContextIsJDialogWhenJDialogIsShown() {
   JDialog dialog = new JDialog();
   JButton comp = new JButton();
   dialog.getContentPane().add(comp);
   windowContext.setActiveWindow(comp);
   assertSame(dialog, windowContext.activeWindow());
 }
  /** Show the dialog. if c is null, the dialog will not have a parent. */
  public int showDialog(Component c) {
    Window topLevel = null;
    if (c != null) {
      topLevel = SwingUtilities.getWindowAncestor(c);
    }

    if (topLevel == null) {
      dialog = new JDialog();
      dialog.setModal(true);
    } else if (topLevel instanceof Frame) {
      dialog = new JDialog((Frame) topLevel, true);
    } else if (topLevel instanceof Dialog) {
      dialog = new JDialog((Dialog) topLevel, true);
    }

    dialog.getContentPane().add(this);
    dialog.setDefaultCloseOperation(dialog.DISPOSE_ON_CLOSE);

    dialog.setTitle("Arithmetic operation");
    dialog.pack();
    Misc.centerFrame(dialog);

    dialog.setVisible(true);

    return getDialogResult();
  }
Beispiel #18
0
  public void login() {

    if (DataUser.getUsr() == null) {
      LoginDialog form = new LoginDialog();
      ODatabaseDocumentTx db = App.getDbd();
      ODatabaseRecordThreadLocal.INSTANCE.set(db);
      form.buildComponent(db);
      db.close();
      JDialog d = new JDialog(frame);
      d.setModalityType(ModalityType.APPLICATION_MODAL);
      d.getContentPane().add(form.getPanel());
      d.pack();
      setCenterDialog(d);
      d.setVisible(true);
    } else {
      // logout
      DataUser.setUsr(null);
      DataUser.setGrp(null);
      closeAllWindow();
    }
    DataUser.setAkses();
    for (HakAksesListener hakAksesListener : cangeHakAkses) {
      hakAksesListener.changeHakAkses();
    }
    //		if (DataUser.usr != null) {
    //			// open default like welcome
    //
    //		}
  }
Beispiel #19
0
  private void createPatternDialog() {

    int w = top.getSize().width;
    // int h = top.getSize().height;

    patternDialog = new JDialog(top, true);
    patternDialog.setTitle(rb.getString("dialog.pattern.title"));

    JPanel base = new JPanel(new GridLayout(2, 1));
    patternDialog.getContentPane().add(base);

    JPanel p = new JPanel(new BorderLayout());
    p.setPreferredSize(new Dimension(w * 4 / 10, 0));
    patternField = new JHistoryComboBox();
    p.add(BorderLayout.SOUTH, patternField);
    base.add(p);

    p = new JPanel();

    okPatternDialogButton = new JButton();
    okPatternDialogButton.setText(rb.getString("dialog.common.button.ok.text"));
    patternDialog.getRootPane().setDefaultButton(okPatternDialogButton);
    p.add(okPatternDialogButton);

    cancelPatternDialogButton = new JButton();
    cancelPatternDialogButton.setText(rb.getString("dialog.common.button.cancel.text"));
    p.add(cancelPatternDialogButton);
    base.add(p);

    patternDialog.pack();
  }
  @Override
  public void onCannotStonePlaced() {
    JDialog diag = new JDialog(this, CANNOT_PLACE, true);
    diag.setSize(new Dimension(300, 200));

    JPanel pan = new JPanel(new BorderLayout());
    JLabel lab = new JLabel(CANNOT_PLACE_MSG);
    lab.setSize(280, 190);
    pan.add(lab, BorderLayout.CENTER);
    JButton but = new JButton(VERIFY);
    pan.add(but, BorderLayout.SOUTH);

    final JDialog dia = diag;
    but.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            dia.dispose();
          }
        });

    diag.getContentPane().add(pan);
    diag.setLocationRelativeTo(null);
    diag.setVisible(true);
  }
 /**
  * This method initializes jDialog
  *
  * @return javax.swing.JDialog
  */
 private JDialog getJDialog() {
   if (jDialog == null) {
     jDialog = new JDialog();
     jDialog.setContentPane(getJContentPane());
     jDialog.setTitle(title);
     jDialog.setSize(this.getWidth() + 5, this.getHeight() + 35);
     jDialog.setLayout(new BorderLayout());
     jDialog.getContentPane().add(this, BorderLayout.CENTER);
     jDialog.setModal(true);
     jDialog.setAlwaysOnTop(true);
     GuiUtils.centerOnScreen(jDialog);
     jDialog.setResizable(false);
     jDialog.setAlwaysOnTop(true);
     jDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
     jDialog.addWindowListener(
         new WindowAdapter() {
           public void windowClosing(WindowEvent e) {
             JOptionPane.showMessageDialog(jDialog, "You must enter a password!");
           }
         });
     // getJContentPane().paintImmediately(0, 0, 300, 300);
     jDialog.setIconImage(ImageUtils.getImage("images/neptus-icon.png"));
     jDialog.toFront();
     jDialog.setFocusTraversalPolicy(new PasswordPanelFocusTraversalPolicy());
     jDialog.setVisible(true);
   }
   return jDialog;
 }
Beispiel #22
0
 /**
  * Create a new ForceConfigAction.
  *
  * @param frame the parent frame for which to create the dialog
  * @param fsim the force simulator to configure
  */
 public ForceConfigAction(JFrame frame, ForceSimulator fsim) {
   dialog = new JDialog(frame, false);
   dialog.setTitle("Configure Force Simulator");
   JPanel forcePanel = new JForcePanel(fsim);
   dialog.getContentPane().add(forcePanel);
   dialog.pack();
 }
  private JDialog createDialog(String title) {
    JDialog dlg = null;
    Presenter currentPst = AWWindowsManager.instance().getCurrentPst();
    //        boolean thrower = (currentPst!=null &&
    // currentPst.getClass().getSimpleName().equals("AbrirDocumentoPst"));
    //        if (thrower){
    //            dlg = new JDialog(null, title, Dialog.ModalityType.MODELESS);
    //        }else
    if (AWWindowsManager.instance().isInMainWindow() || (currentPst == null)) {
      dlg =
          new JDialog(
              AWWindowsManager.instance().getFrame(), title, Dialog.ModalityType.DOCUMENT_MODAL);
    } else {
      JDialog parent = (JDialog) ((View) currentPst.getView()).getParentContainer();
      dlg = new JDialog(parent, title, Dialog.ModalityType.DOCUMENT_MODAL);
    }
    setupIcons(dlg);
    dlg.setUndecorated(true);
    dlg.getContentPane().setLayout(new BorderLayout());

    installFestFixture(dlg);

    //        installMouseAdapter(dlg);

    return dlg;
  }
Beispiel #24
0
  public void run(DataLayer pnmlData) {
    // Build interface
    JDialog guiDialog = new JDialog(CreateGui.getApp(), MODULE_NAME, true);

    // 1 Set layout
    Container contentPane = guiDialog.getContentPane();
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS));

    // 2 Add file browser
    contentPane.add(sourceFilePanel = new PetriNetChooserPanel("Source net", pnmlData));

    // 3 Add results pane
    contentPane.add(results = new ResultsHTMLPane(pnmlData.getURI()));

    // 4 Add button
    contentPane.add(new ButtonBar("Analyse", analyseButtonClick));

    // 5 Make window fit contents' preferred size
    guiDialog.pack();

    // 6 Move window to the middle of the screen
    guiDialog.setLocationRelativeTo(null);

    guiDialog.setVisible(true);

    //    warnUser(pnmlData.getURI(), guiFrame);
    //    StateSpace stateSpace = new StateSpace(pnmlData);
  }
  private void displayFilteredDialog() {
    try {
      log.debug("displayFilteredDialog: subAction name = " + this.m_subAction.sub_action_name());
      // toolbarAction parentAction = getParentAction();

      JDialog initDebaterecord;
      initDebaterecord = new JDialog();
      initDebaterecord.setTitle("Enter Settings for Document");
      initDebaterecord.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
      // initDebaterecord.setPreferredSize(new Dimension(420, 300));

      InitDebateRecord panel =
          new InitDebateRecord(ooDocument, initDebaterecord, m_parentAction, m_subAction);
      // panel.setDialogMode(SelectorDialogModes.TEXT_INSERTION);
      // panel.setBackground(new Color(255, 255, 153));
      // initDebaterecord.setTitle("Selection Mode");
      initDebaterecord.getContentPane().add(panel);
      initDebaterecord.pack();
      initDebaterecord.setLocationRelativeTo(null);
      initDebaterecord.setVisible(true);
      initDebaterecord.setAlwaysOnTop(true);
    } catch (Exception ex) {
      log.error("displayFilteredDialog : " + ex.getMessage());
      log.error(
          "displayFilteredDialog: stack trace :  \n"
              + org.bungeni.ooo.utils.CommonExceptionUtils.getStackTrace(ex));
    }
  }
Beispiel #26
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();
          }
        });
  }
Beispiel #27
0
  /**
   * This should take its inspiration from {@link org.tigris.gef.base.CmdSpawn}.
   *
   * <p>The spawned/cloned tab will be a JFrame. Currently this feature is disabled for ArgoUML,
   * except for the find dialog. Code should behave though as if spawning might work at a later
   * stage.
   *
   * @return a copy of the frame or null if not clone-able.
   */
  public AbstractArgoJPanel spawn() {

    JDialog f = new JDialog(ArgoFrame.getInstance());
    f.getContentPane().setLayout(new BorderLayout());
    // TODO: Once we have fixed all subclasses the title will
    // always be localized so this localization can be removed.
    f.setTitle(Translator.localize(title));
    AbstractArgoJPanel newPanel = (AbstractArgoJPanel) clone();
    if (newPanel == null) {
      return null; // failed to clone
    }

    //        if (newPanel instanceof TabToDo) {
    //            TabToDo me = (TabToDo) this;
    //            TabToDo it = (TabToDo) newPanel;
    //            it.setTarget(me.getTarget());
    //        } else if (newPanel instanceof TabModelTarget) {
    //            TabModelTarget me = (TabModelTarget) this;
    //            TabModelTarget it = (TabModelTarget) newPanel;
    //            it.setTarget(me.getTarget());
    //        } else if (newPanel instanceof TabDiagram) {
    //            TabDiagram me = (TabDiagram) this;
    //            TabDiagram it = (TabDiagram) newPanel;
    //            it.setTarget(me.getTarget());
    //        }

    // TODO: Once we have fixed all subclasses the title will
    // always be localized so this localization can be removed.
    newPanel.setTitle(Translator.localize(title));

    f.getContentPane().add(newPanel, BorderLayout.CENTER);
    Rectangle bounds = getBounds();
    bounds.height += OVERLAPP * 2;
    f.setBounds(bounds);

    Point loc = new Point(0, 0);
    SwingUtilities.convertPointToScreen(loc, this);
    loc.y -= OVERLAPP;
    f.setLocation(loc);
    f.setVisible(true);

    if (tear && (getParent() instanceof JTabbedPane)) {
      ((JTabbedPane) getParent()).remove(this);
    }

    return newPanel;
  }
Beispiel #28
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);
  }
  private void init(String title) {
    diag = new JDialog(frame, title, false);

    preview = new PreviewPanel(null, new MetaData(), Globals.prefs.get("preview1"));

    sortedEntries =
        new SortedList<BibtexEntry>(entries, new EntryComparator(false, true, "author"));
    model = new EventTableModel<BibtexEntry>(sortedEntries, new EntryTableFormat());
    entryTable = new JTable(model);
    GeneralRenderer renderer = new GeneralRenderer(Color.white);
    entryTable.setDefaultRenderer(JLabel.class, renderer);
    entryTable.setDefaultRenderer(String.class, renderer);
    setWidths();
    TableComparatorChooser<BibtexEntry> tableSorter =
        new TableComparatorChooser<BibtexEntry>(
            entryTable, sortedEntries, TableComparatorChooser.MULTIPLE_COLUMN_KEYBOARD);
    setupComparatorChooser(tableSorter);
    JScrollPane sp = new JScrollPane(entryTable);

    EventSelectionModel<BibtexEntry> selectionModel =
        new EventSelectionModel<BibtexEntry>(sortedEntries);
    entryTable.setSelectionModel(selectionModel);
    selectionModel.getSelected().addListEventListener(new EntrySelectionListener());
    entryTable.addMouseListener(new TableClickListener());

    contentPane.setTopComponent(sp);
    contentPane.setBottomComponent(preview);

    // Key bindings:
    AbstractAction closeAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            diag.dispose();
          }
        };
    ActionMap am = contentPane.getActionMap();
    InputMap im = contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    im.put(Globals.prefs.getKey("Close dialog"), "close");
    am.put("close", closeAction);

    diag.addWindowListener(
        new WindowAdapter() {
          public void windowOpened(WindowEvent e) {
            contentPane.setDividerLocation(0.5f);
          }

          public void windowClosing(WindowEvent event) {
            Globals.prefs.putInt("searchDialogWidth", diag.getSize().width);
            Globals.prefs.putInt("searchDialogHeight", diag.getSize().height);
          }
        });

    diag.getContentPane().add(contentPane, BorderLayout.CENTER);
    // Remember and default to last size:
    diag.setSize(
        new Dimension(
            Globals.prefs.getInt("searchDialogWidth"), Globals.prefs.getInt("searchDialogHeight")));
    diag.setLocationRelativeTo(frame);
  }
 private void visualizarReporteGenerado() throws HeadlessException {
   JDialog viewer = new JDialog(new JFrame(), "Vista previa del reporte", true);
   viewer.setSize(800, 600);
   viewer.setLocationRelativeTo(null);
   JRViewer jrv = new JRViewer(reporteFill);
   viewer.getContentPane().add(jrv);
   viewer.setVisible(true);
 }