/**
  * 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;
 }
  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));
    }
  }
 static void showWaitDialog() {
   JLabel label = new JLabel("Finding classes...");
   label.setBorder(BorderFactory.createMatteBorder(5, 5, 5, 5, Color.BLUE));
   label.setHorizontalAlignment(SwingConstants.CENTER);
   Font font = label.getFont().deriveFont(32f);
   label.setFont(font);
   dialog.add(label);
   dialog.setUndecorated(true);
   dialog.setAlwaysOnTop(true);
   dialog.setSize(300, 100);
   dialog.setLocationRelativeTo(null);
   dialog.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
   dialog.setVisible(true);
 }
Beispiel #4
0
 public OpenConnection() {
   try {
     conn =
         DriverManager.getConnection(
             "jdbc:mysql://localhost:3306/ekdothria", "root", "dotaismind");
   } catch (Exception e) {
     JOptionPane optionPane =
         new JOptionPane(
             "Δεν μπόρεσε να συνδεθεί με την βάση.Ελέγξτε την βάση.", JOptionPane.ERROR_MESSAGE);
     JDialog dialog = optionPane.createDialog("Failure");
     dialog.setAlwaysOnTop(true);
     dialog.setVisible(true);
     System.exit(0);
   }
 }
 // See OptionPaneUtil
 // FIXME: this is a temporary solution.
 public static void prepareDialog(JDialog dialog) {
   if (Main.pref.getBoolean("window-handling.option-pane-always-on-top", true)) {
     try {
       dialog.setAlwaysOnTop(true);
     } catch (SecurityException e) {
       System.out.println(
           tr(
               "Warning: failed to put option pane dialog always on top. Exception was: {0}",
               e.toString()));
     }
   }
   dialog.setModal(true);
   dialog.toFront();
   dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
 }
Beispiel #6
0
  /**
   * Shows a modal dialog to select some files
   *
   * @param file_list default files in the selected file list
   * @return the file list returns <code>null</code> if the dialog was closed with cancel, or ESC or
   *     X
   */
  public static String[] showFileChooserDialog(final FileFilter filter, final String[] file_list) {

    final JDialog dlg = new JDialog();
    dlg.setAlwaysOnTop(true);
    dlg.setModalityType(ModalityType.APPLICATION_MODAL);
    final int[] cancelFlag = new int[] {0};

    final FileChooserPanel panel = new FileChooserPanel(filter);
    if (file_list != null) {
      panel.update(file_list);
    }

    final JButton ok = new JButton("OK");
    ok.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            cancelFlag[0] = -1;
            dlg.dispose();
          }
        });
    final JButton cancel = new JButton("Cancel");
    cancel.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            dlg.dispose();
          }
        });
    final JPanel buttons = new JPanel();
    buttons.add(ok);
    buttons.add(cancel);
    dlg.getContentPane().setLayout(new BorderLayout());
    dlg.getContentPane().add(panel, BorderLayout.CENTER);
    dlg.getContentPane().add(buttons, BorderLayout.SOUTH);

    dlg.pack();
    dlg.setVisible(true);

    if (cancelFlag[0] == -1) {
      return panel.getSelectedFiles();
    }
    return null;
  }
  private void showDialogNotification(JDialog parent, String type, String string) {
    final JDialog dialog = new JDialog(parent, type);
    JLabel pic = new JLabel();
    if (type.equals("Warning")) {
      pic.setIcon(new ImageIcon(getClass().getResource(BoardDialog.pictureWarning)));
    } else {
      pic.setIcon(new ImageIcon(getClass().getResource(BoardDialog.pictureError)));
    }
    GridBagLayout dialogLayout = new GridBagLayout();
    dialog.setLayout(dialogLayout);
    GridBagConstraints c = new GridBagConstraints();
    JLabel message = new JLabel(string);
    JButton close = new JButton("close");
    ActionListener actionListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // panel.setAlwaysOnTop(true);
            dialog.dispose();
          }
        };
    close.addActionListener(actionListener);

    c.gridx = 0;
    c.gridy = 0;
    c.ipadx = 20;
    dialog.add(pic, c);

    c.gridx = 1;
    c.gridy = 0;
    dialog.add(message, c);

    c.gridx = 1;
    c.gridy = 1;
    dialog.add(close, c);
    dialog.pack();
    dialog.setLocationRelativeTo(parent);
    dialog.setAlwaysOnTop(true);
    dialog.setVisible(true);
  }
  private void init() {
    window = new JDialog();

    JLabel hostLabel = new JLabel("host:");
    hostLabel.setHorizontalAlignment(JLabel.RIGHT);
    JLabel portLabel = new JLabel("port:");
    portLabel.setHorizontalAlignment(JLabel.RIGHT);
    JLabel passwordLabel = new JLabel("password:"******"user:"******"6600");
    passwordField = new JPasswordField();
    userField = new JTextField();

    okButton = new JButton("OK");

    window.setLayout(new GridLayout(5, 2));
    window.add(hostLabel);
    window.add(hostField);
    window.add(portLabel);
    window.add(portField);
    window.add(passwordLabel);
    window.add(passwordField);
    window.add(userLabel);
    window.add(userField);
    window.add(okButton);

    window.setAlwaysOnTop(true);
    window.pack();

    Rectangle bounds = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
    window.setLocation(
        (bounds.width / 2) - (window.getWidth() / 2),
        (bounds.height / 2) - (window.getHeight() / 2));
  }
  String showStringDialog(
      String title, String previousValue, boolean editable, Component component) {
    canceled = true;

    JEditorPane msgTextArea = null;
    JScrollPane jScrollPane = null;
    jScrollPane = new JScrollPane();

    msgTextArea = SyntaxDocument.getCustomEditor(new String[] {}, new String[] {}, "#", "");
    msgTextArea.setEditable(editable);
    jScrollPane.setViewportView(msgTextArea);
    jScrollPane.setVisible(true);

    if (previousValue == null) previousValue = "";
    msgTextArea.setText(previousValue);

    final JDialog dialog;
    if (component instanceof JFrame) dialog = new JDialog((JFrame) component);
    else if (component instanceof JDialog) dialog = new JDialog((JDialog) component);
    else dialog = new JDialog();
    // final JDialog dialog=new JDialog(component);
    dialog.setTitle(title);
    dialog.setSize(640, 480);
    dialog.setLayout(new BorderLayout());
    dialog.setModal(true);
    dialog.setAlwaysOnTop(true);
    GuiUtils.centerOnScreen(dialog);
    dialog.setResizable(true);
    dialog.setAlwaysOnTop(true);

    dialog.add(jScrollPane, BorderLayout.CENTER);

    JPanel toolbar = new JPanel();
    toolbar.setLayout(new BorderLayout());

    JPanel buttons = new JPanel();
    buttons.setLayout(new FlowLayout());

    JButton ok = new JButton("OK");
    ok.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            canceled = false;
            dialog.setVisible(false);
            dialog.dispose();
          }
        });
    buttons.add(ok);

    JButton cancel = new JButton("Cancel");
    cancel.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            dialog.setVisible(false);
            dialog.dispose();
          }
        });

    buttons.add(cancel);

    toolbar.add(buttons, BorderLayout.EAST);

    dialog.add(toolbar, BorderLayout.SOUTH);

    dialog.setVisible(true);
    if (canceled) {
      //	NeptusLog.pub().info("<###>CANCELED");
      return previousValue;
    } else {
      //	NeptusLog.pub().info("<###>NOT CANCELED: "+msgTextArea.getText());
      return msgTextArea.getText();
    }
  }
  private void prepareDialog(Visitor visitor) {
    listener = new VisitorPersonalListener();

    lbFirstName = new JLabel("имя:");
    lbFirstName.setBounds(10, 209, 70, 10);
    tfFirstName = new JTextField();
    tfFirstName.setBounds(80, 205, 110, 20);

    lbMiddleName = new JLabel("отчество:");
    lbMiddleName.setBounds(10, 230, 70, 10);
    tfMiddleName = new JTextField();
    tfMiddleName.setBounds(80, 225, 110, 20);

    lbSureName = new JLabel("фамилия:");
    lbSureName.setBounds(10, 248, 70, 15);
    tfSureName = new JTextField();
    tfSureName.setBounds(80, 245, 110, 20);

    lbBirthDay = new JLabel("д.рож.:");
    lbBirthDay.setBounds(10, 273, 70, 15);
    tfBirthDay = new JTextField();
    tfBirthDay.setBounds(80, 270, 110, 20);
    tfBirthDay.addKeyListener(listener);

    lbAdress = new JLabel("адресс:");
    lbAdress.setBounds(10, 298, 70, 15);
    tfAdress = new JTextField();
    tfAdress.setBounds(80, 295, 110, 20);

    lbNumberPhone = new JLabel("№ тел.:");
    lbNumberPhone.setBounds(10, 325, 70, 15);
    tfNumberPhone = new JTextField();
    tfNumberPhone.setBounds(80, 325, 110, 20);

    lbDateReg = new JLabel("д.регист.:");
    lbDateReg.setBounds(9, 350, 75, 15);
    tfDateReg = new JTextField();
    tfDateReg.setBounds(81, 350, 110, 20);
    tfDateReg.addKeyListener(listener);

    lbCard = new JLabel("карта:");
    lbCard.setBounds(10, 375, 70, 15);

    String[] arCard = new String[dbManager.getAllCards().size()];
    for (int i = 0; i < arCard.length; i++) {
      arCard[i] = dbManager.getAllCards().get(i).getCard();
    }
    cbCard = new JComboBox<String>(arCard);
    cbCard.setBounds(80, 375, 110, 20);

    lbBalance = new JLabel("баланс:");
    lbBalance.setBounds(10, 400, 70, 15);
    tfBalance = new JTextField();
    tfBalance.setBounds(80, 400, 110, 20);

    lbDiscount = new JLabel("скидки:");
    lbDiscount.setBounds(10, 425, 70, 15);
    tfDiscount = new JTextField();
    tfDiscount.setBounds(80, 425, 110, 20);
    sexButtonGroup = new ButtonGroup();
    rbtnMale = new JRadioButton("муж.");
    rbtnMale.setBounds(10, 450, 70, 20);
    rbtnFemale = new JRadioButton("жен.");
    rbtnFemale.setBounds(90, 450, 70, 20);
    sexButtonGroup.add(rbtnMale);
    sexButtonGroup.add(rbtnFemale);

    notation = new JTextArea();
    notation.setLineWrap(true);
    scroll =
        new JScrollPane(
            notation,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scroll.setBounds(10, 480, 180, 50);

    westPanel = new JPanel();
    westPanel.setFocusable(false);
    westPanel.setPreferredSize(new Dimension(200, 400));
    westPanel.setLayout(null);

    photo = new JLabel();
    photo.setName("photo");
    photo.addMouseListener(listener);

    if (visitor == null) {
      image = new ImageIcon(StartAplication.class.getClass().getResource("/visitor.png"));
      photo.setIcon(this.scaleImage(image));
      photo.setBounds(10, 10, 180, 180);
      photo.setBorder(BorderFactory.createEtchedBorder());

    } else {
      this.setVisitorId(visitor.getId());
      tfFirstName.setText(visitor.getFirst_name().toString());
      tfMiddleName.setText(visitor.getPatronymic().toString());
      tfSureName.setText(visitor.getSurname().toString());
      tfBirthDay.setText(visitor.getBirthday().toString());
      tfAdress.setText(visitor.getAdress().toString());
      if (visitor.getSex().equals("мужчина")) rbtnMale.setSelected(true);
      if (visitor.getSex().equals("женщина")) rbtnFemale.setSelected(true);
      tfNumberPhone.setText(visitor.getNumber_phone() + "");
      tfDateReg.setText(visitor.getData_reg().toString());
      cbCard.setSelectedIndex(visitor.getIndexCard() - 1);

      tfBalance.setText(visitor.getBalance() + "");
      tfDiscount.setText("уточнять");
      notation.setText(visitor.getNotation().toString());
      if ((visitor.getPhoto().toString()).equals(null)
          || (visitor.getPhoto().toString()).equals("---")
          || (visitor.getPhoto().toString()).equals("")) {
        image = new ImageIcon(StartAplication.class.getClass().getResource("/visitor.png"));
      } else {
        fileImage = visitor.getPhoto().toString();
        image = new ImageIcon(fileImage);
      }

      photo.setIcon(this.scaleImage(image));
      photo.setBounds(10, 10, 180, 180);
      photo.setBorder(BorderFactory.createEtchedBorder());
    }

    JSeparator separator = new JSeparator(JSeparator.HORIZONTAL);
    separator.setBounds(0, 200, 200, 1);

    westPanel.add(photo);
    westPanel.add(separator);
    westPanel.add(lbFirstName);
    westPanel.add(tfFirstName);
    westPanel.add(lbMiddleName);
    westPanel.add(tfMiddleName);
    westPanel.add(lbSureName);
    westPanel.add(tfSureName);
    westPanel.add(lbBirthDay);
    westPanel.add(tfBirthDay);
    westPanel.add(lbAdress);
    westPanel.add(tfAdress);
    westPanel.add(lbNumberPhone);
    westPanel.add(tfNumberPhone);
    westPanel.add(lbDateReg);
    westPanel.add(tfDateReg);
    westPanel.add(lbCard);
    westPanel.add(cbCard);
    westPanel.add(lbBalance);
    westPanel.add(tfBalance);
    westPanel.add(lbDiscount);
    westPanel.add(tfDiscount);
    westPanel.add(rbtnMale);
    westPanel.add(rbtnFemale);
    westPanel.add(scroll);

    abovePanel = new JPanel();

    abovePanel.setPreferredSize(new Dimension(50, 50));

    model = new DefaultTableModel(AppUtills.PERSONAL_TABLE_COLUMN_NAME, 1);
    if (visitor != null) {
      List<BookService> listBookService = dbManager.getBookServiceByVisitorId(visitor.getId());
      for (int row = 0; row < listBookService.size(); row++) {
        int column = 0;
        BookService tmp = listBookService.get(row);
        model.addRow(new Vector<String>());
        model.setValueAt(tmp.getId(), row, column++);
        model.setValueAt(tmp.getService(), row, column++);
        model.setValueAt(tmp.getDate(), row, column++);
        model.setValueAt(tmp.getStaff(), row, column++);
        model.setValueAt(tmp.getNotation(), row, column);
      }
    }

    personalTableService =
        new JTable(model) {
          @Override
          public boolean isCellEditable(int row, int column) {
            return false;
          }
        };
    personalTableService.setName("personalTableBookService");
    personalTableService.getColumnModel().getColumn(0).setMaxWidth(50);
    personalTableService.getColumnModel().getColumn(2).setMaxWidth(80);
    personalTableService.addMouseListener(listener);
    JScrollPane scroll =
        new JScrollPane(
            personalTableService,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    centerPanel = new JPanel();
    centerPanel.setLayout(new GridLayout(1, 1));
    centerPanel.add(scroll);
    centerPanel.setBackground(Color.RED);
    centerPanel.setPreferredSize(new Dimension(50, 50));

    JButton btnSave = new JButton("сохранить");
    btnSave.setToolTipText("сохранить нового посетителя");
    btnSave.addActionListener(listener);
    JButton btnCancel = new JButton("отмена");
    btnCancel.setToolTipText("закрыть без сохраниения");
    btnCancel.addActionListener(listener);

    bottomPanel = new JPanel();
    bottomPanel.add(btnSave);
    bottomPanel.add(btnCancel);
    bottomPanel.setPreferredSize(new Dimension(50, 50));

    infoPanel = new JPanel();
    infoPanel.setLayout(new BorderLayout());
    infoPanel.add(abovePanel, BorderLayout.NORTH);
    infoPanel.add(centerPanel, BorderLayout.CENTER);
    infoPanel.add(bottomPanel, BorderLayout.SOUTH);

    dialog = new JDialog();
    dialog.setAlwaysOnTop(true);
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    dialog.setSize(850, 550);
    dialog.setResizable(false);
    dialog.setLayout(new BorderLayout());
    dialog.getContentPane().add(westPanel, BorderLayout.WEST);
    dialog.getContentPane().add(infoPanel, BorderLayout.CENTER);
    dialog.setVisible(true);
  }
Beispiel #11
0
  @Override
  public void actionPerformed(final ActionEvent e) {
    beforeAction(e);

    final ResourceBundle appMessages =
        ResourceBundle.getBundle(
            "application", ServiceLocator.get(ConfigurationManager.class).get().getLocale());

    final Component parent;
    if (e.getSource() instanceof Component) parent = (Component) e.getSource();
    else parent = null;

    JFileChooser chooser = new JFileChooser();
    File defaultFile =
        ServiceLocator.get(ConfigurationManager.class).get().getLastExportPath().getParentFile();
    chooser.setCurrentDirectory(defaultFile);
    chooser.setFileFilter(
        new FileNameExtensionFilter("*." + format.toString().toLowerCase(), format.toString()));
    chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    chooser.setDialogType(JFileChooser.SAVE_DIALOG);
    chooser.setApproveButtonText(appMessages.getString("exportDialog.approve"));
    chooser.setApproveButtonMnemonic(
        KeyStroke.getKeyStroke(appMessages.getString("exportDialog.approve.mnemonic"))
            .getKeyCode());
    chooser.setApproveButtonToolTipText(
        ServiceLocator.get(TooltipFactory.class)
            .getDecorated(
                appMessages.getString("exportDialog.approve.tooltip.message"),
                appMessages.getString("exportDialog.approve.tooltip.title"),
                "save.png",
                KeyStroke.getKeyStroke(
                    "alt " + appMessages.getString("exportDialog.approve.mnemonic"))));
    if (chooser.showDialog(parent, null) == JFileChooser.APPROVE_OPTION) {
      chooserApproved(e);

      File f = chooser.getSelectedFile();
      if (!chooser.accept(f)) {
        f = new File(f.toString() + "." + format.toString().toLowerCase());
      }
      ServiceLocator.get(ConfigurationManager.class).get().setLastExportPath(f);

      if (f.exists()) {
        if (JOptionPane.showConfirmDialog(
                parent,
                MessageFormat.format(
                    appMessages.getString("exportDialog.overwrite"), new Object[] {f}),
                appMessages.getString("exportDialog.overwrite.title"),
                JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE,
                null)
            != JOptionPane.YES_OPTION) {
          return;
        }
      }

      final File file = f;

      final ExportOptions options = format.askForOptions(origami);

      final JDialog progressDialog = new JDialog();
      final JProgressBar bar = new JProgressBar(0, format.getNumOfProgressChunks(origami, options));
      bar.setStringPainted(true);
      bar.setString(appMessages.getString("exporting.no.percentage"));
      progressDialog.getContentPane().setLayout(new FlowLayout());
      progressDialog.setUndecorated(true);
      progressDialog.setAlwaysOnTop(true);
      progressDialog.setLocationRelativeTo(null);

      final SwingWorker<Set<File>, Void> worker =
          new SwingWorker<Set<File>, Void>() {

            private int chunksReceived = 0;

            @Override
            protected Set<File> doInBackground() throws Exception {
              final Runnable progressCallback =
                  new Runnable() {
                    @Override
                    public void run() {
                      publish(new Void[] {null});
                      if (isCancelled()) throw new RuntimeException();
                    }
                  };

              return ServiceLocator.get(OrigamiHandler.class)
                  .export(origami, file, format, options, progressCallback);
            }

            @Override
            protected void process(List<Void> chunks) {
              chunksReceived += chunks.size();
              bar.setValue(chunksReceived);
              bar.setString(
                  MessageFormat.format(
                      appMessages.getString("exporting.percentage"), bar.getPercentComplete()));
            }

            @Override
            protected void done() {
              progressDialog.setVisible(false);
              progressDialog.dispose();
              try {
                if (!isCancelled()) {
                  Set<File> resultFiles = get();
                  StringBuilder b = new StringBuilder();
                  for (File f : resultFiles) b.append("\n").append(f.toString());
                  JOptionPane.showMessageDialog(
                      parent,
                      MessageFormat.format(
                          appMessages.getString("exportSuccessful.message"),
                          new Object[] {b.toString(), resultFiles.size()}),
                      appMessages.getString("exportSuccessful.title"),
                      JOptionPane.INFORMATION_MESSAGE,
                      null);
                }
              } catch (HeadlessException e) {
                JOptionPane.showMessageDialog(
                    parent,
                    MessageFormat.format(
                        appMessages.getString("failedToExport.message"),
                        new Object[] {file.toString()}),
                    appMessages.getString("failedToExport.title"),
                    JOptionPane.ERROR_MESSAGE,
                    null);
                Logger.getLogger("application").warn("Unable to export origami.", e);
              } catch (InterruptedException e) {
                JOptionPane.showMessageDialog(
                    parent,
                    MessageFormat.format(
                        appMessages.getString("failedToExport.message"),
                        new Object[] {file.toString()}),
                    appMessages.getString("failedToExport.title"),
                    JOptionPane.ERROR_MESSAGE,
                    null);
                Logger.getLogger("application").warn("Unable to export origami.", e);
              } catch (ExecutionException e) {
                JOptionPane.showMessageDialog(
                    parent,
                    MessageFormat.format(
                        appMessages.getString("failedToExport.message"),
                        new Object[] {file.toString()}),
                    appMessages.getString("failedToExport.title"),
                    JOptionPane.ERROR_MESSAGE,
                    null);
                Logger.getLogger("application").warn("Unable to export origami.", e);
              }
              ExportAction.this.done(e);
            }
          };

      progressDialog.getContentPane().add(bar);
      JButton cancel = new JButton();
      cancel.setAction(
          new AbstractAction() {
            /** */
            private static final long serialVersionUID = 104733262578076493L;

            @Override
            public void actionPerformed(ActionEvent e) {
              worker.cancel(true);
            }
          });
      cancel.setText(appMessages.getString("buttons.cancel"));
      progressDialog.getContentPane().add(cancel);

      progressDialog.pack();

      progressDialog.setVisible(true);
      worker.execute();
    } else {
      if (e.getSource() instanceof JComponent)
        ((JComponent) e.getSource()).setCursor(Cursor.getDefaultCursor());
    }
  }
  @SuppressWarnings({"rawtypes", "unchecked"})
  private void GetSizeInformationDialog(BoardDialog parent) {
    int NrOfDevicePins = IOComponentTypes.GetNrOfFPGAPins(MyType);
    int min = 1;
    int max = 1;
    String text = "null";

    switch (MyType) {
      case DIPSwitch:
        min = DipSwitch.MIN_SWITCH;
        max = DipSwitch.MAX_SWITCH;
        text = "switch";
        break;
      case PortIO:
        min = PortIO.MIN_IO;
        max = PortIO.MAX_IO;
        text = "pins";
        break;
      default:
        break;
    }

    final JDialog selWindow = new JDialog(parent.GetPanel(), MyType + " number of " + text);
    ActionListener actionListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (e.getActionCommand().equals("next")) {
              MyType.setNbSwitch(
                  Integer.valueOf(
                      ((JComboBox) (selWindow.getContentPane().getComponents()[1]))
                          .getSelectedItem()
                          .toString()));
              // setNrOfPins(Integer.valueOf(((JComboBox)(selWindow.getContentPane().getComponents()[1])).getSelectedItem().toString()));
              selWindow.dispose();
            }
            selWindow.setVisible(false);
          }
        };

    JComboBox size = new JComboBox<>();
    for (int i = min; i <= max; i++) {
      size.addItem(i);
    }
    size.setSelectedItem(NrOfDevicePins);
    GridBagLayout dialogLayout = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    selWindow.setLayout(dialogLayout);
    c.fill = GridBagConstraints.HORIZONTAL;

    JLabel sizeText = new JLabel("Specify number of " + text + ": ");
    c.gridx = 0;
    c.gridy = 0;
    selWindow.add(sizeText, c);

    c.gridx = 1;
    selWindow.add(size, c);

    JButton nextButton = new JButton("Next");
    nextButton.setActionCommand("next");
    nextButton.addActionListener(actionListener);
    c.gridy++;
    selWindow.add(nextButton, c);
    selWindow.pack();
    selWindow.setLocation(Projects.getCenteredLoc(selWindow.getWidth(), selWindow.getHeight()));
    // PointerInfo mouseloc = MouseInfo.getPointerInfo();
    // Point mlocation = mouseloc.getLocation();
    // selWindow.setLocation(mlocation.x, mlocation.y);
    selWindow.setModal(true);
    selWindow.setResizable(false);
    selWindow.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    selWindow.setAlwaysOnTop(true);
    selWindow.setVisible(true);
  }
  private void GetSimpleInformationDialog(BoardDialog parent) {
    int NrOfDevicePins = IOComponentTypes.GetNrOfFPGAPins(MyType);
    final JDialog selWindow = new JDialog(parent.GetPanel(), MyType + " properties");
    JComboBox<String> DriveInput = new JComboBox<>(DriveStrength.Behavior_strings);
    JComboBox<String> PullInput = new JComboBox<>(PullBehaviors.Behavior_strings);
    JComboBox<String> ActiveInput = new JComboBox<>(PinActivity.Behavior_strings);
    ActionListener actionListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (e.getActionCommand().equals("cancel")) {
              MyType = IOComponentTypes.Unknown;
              abort = true;
            }
            selWindow.setVisible(false);
          }
        };
    GridBagLayout dialogLayout = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    selWindow.setLayout(dialogLayout);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridy = -1;
    ArrayList<JTextField> LocInputs = new ArrayList<JTextField>();
    ArrayList<String> PinLabels;
    switch (MyType) {
      case SevenSegment:
        PinLabels = SevenSegment.GetLabels();
        break;
      case RGBLED:
        PinLabels = RGBLed.GetLabels();
        break;
      case DIPSwitch:
        PinLabels = DipSwitch.GetLabels(NrOfDevicePins);
        break;
      case PortIO:
        PinLabels = PortIO.GetLabels(NrOfDevicePins);
        break;
      case LocalBus:
        PinLabels = ReptarLocalBus.GetLabels();
        break;
      default:
        PinLabels = new ArrayList<String>();
        if (NrOfDevicePins == 1) {
          PinLabels.add("FPGA pin");
        } else {
          for (int i = 0; i < NrOfDevicePins; i++) {
            PinLabels.add("pin " + i);
          }
        }
    }
    int offset = 0;
    int oldY = c.gridy;
    int maxY = -1;
    for (int i = 0; i < NrOfDevicePins; i++) {
      if (i % 32 == 0) {
        offset = (i / 32) * 2;
        c.gridy = oldY;
      }
      JLabel LocText = new JLabel("Specify " + PinLabels.get(i) + " location:");
      c.gridx = 0 + offset;
      c.gridy++;
      selWindow.add(LocText, c);
      JTextField txt = new JTextField(6);
      LocInputs.add(txt);
      c.gridx = 1 + offset;
      selWindow.add(LocInputs.get(i), c);
      maxY = c.gridy > maxY ? c.gridy : maxY;
    }
    c.gridy = maxY;

    JLabel StandardText = new JLabel("Specify FPGA pin standard:");
    c.gridy++;
    c.gridx = 0;
    selWindow.add(StandardText, c);
    JComboBox<String> StandardInput = new JComboBox<>(IoStandards.Behavior_strings);
    StandardInput.setSelectedIndex(parent.GetDefaultStandard());
    c.gridx = 1;
    selWindow.add(StandardInput, c);

    if (IOComponentTypes.OutputComponentSet.contains(MyType)) {
      JLabel DriveText = new JLabel("Specify FPGA pin drive strength:");
      c.gridy++;
      c.gridx = 0;
      selWindow.add(DriveText, c);
      DriveInput.setSelectedIndex(parent.GetDefaultDriveStrength());
      c.gridx = 1;
      selWindow.add(DriveInput, c);
    }

    if (IOComponentTypes.InputComponentSet.contains(MyType)) {
      JLabel PullText = new JLabel("Specify FPGA pin pull behavior:");
      c.gridy++;
      c.gridx = 0;
      selWindow.add(PullText, c);
      PullInput.setSelectedIndex(parent.GetDefaultPullSelection());
      c.gridx = 1;
      selWindow.add(PullInput, c);
    }

    if (!IOComponentTypes.InOutComponentSet.contains(MyType)) {
      JLabel ActiveText = new JLabel("Specify " + MyType + " activity:");
      c.gridy++;
      c.gridx = 0;
      selWindow.add(ActiveText, c);
      ActiveInput.setSelectedIndex(parent.GetDefaultActivity());
      c.gridx = 1;
      selWindow.add(ActiveInput, c);
    }

    JButton OkayButton = new JButton("Done and Store");
    OkayButton.setActionCommand("done");
    OkayButton.addActionListener(actionListener);
    c.gridx = 0;
    c.gridy++;
    selWindow.add(OkayButton, c);

    JButton CancelButton = new JButton("Cancel");
    CancelButton.setActionCommand("cancel");
    CancelButton.addActionListener(actionListener);
    c.gridx = 1;
    selWindow.add(CancelButton, c);
    selWindow.pack();
    selWindow.setLocation(Projects.getCenteredLoc(selWindow.getWidth(), selWindow.getHeight()));
    // PointerInfo mouseloc = MouseInfo.getPointerInfo();
    // Point mlocation = mouseloc.getLocation();
    // selWindow.setLocation(mlocation.x, mlocation.y);
    selWindow.setModal(true);
    selWindow.setResizable(false);
    selWindow.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    selWindow.setAlwaysOnTop(true);
    abort = false;
    while (!abort) {
      selWindow.setVisible(true);
      if (!abort) {
        boolean correct = true;
        for (int i = 0; i < NrOfDevicePins; i++) {
          if (LocInputs.get(i).getText().isEmpty()) {
            correct = false;
            showDialogNotification(
                selWindow,
                "Error",
                "<html>You have to specify a location for " + PinLabels.get(i) + "!</html>");
            continue;
          }
        }
        if (correct) {
          parent.SetDefaultStandard(StandardInput.getSelectedIndex());
          NrOfPins = NrOfDevicePins;
          for (int i = 0; i < NrOfDevicePins; i++) {
            MyPinLocations.put(i, LocInputs.get(i).getText());
          }
          MyIOStandard = IoStandards.getId(StandardInput.getSelectedItem().toString());
          if (IOComponentTypes.OutputComponentSet.contains(MyType)) {
            parent.SetDefaultDriveStrength(DriveInput.getSelectedIndex());
            MyDriveStrength = DriveStrength.getId(DriveInput.getSelectedItem().toString());
          }
          if (IOComponentTypes.InputComponentSet.contains(MyType)) {
            parent.SetDefaultPullSelection(PullInput.getSelectedIndex());
            MyPullBehavior = PullBehaviors.getId(PullInput.getSelectedItem().toString());
          }
          if (!IOComponentTypes.InOutComponentSet.contains(MyType)) {
            parent.SetDefaultActivity(ActiveInput.getSelectedIndex());
            MyActivityLevel = PinActivity.getId(ActiveInput.getSelectedItem().toString());
          }
          abort = true;
        }
      }
    }
    selWindow.dispose();
  }
 /** Make sure to keep the dialog always on top */
 protected JDialog createDialog(Component parent) throws HeadlessException {
   JDialog dialog = super.createDialog(parent);
   dialog.setAlwaysOnTop(true);
   return dialog;
 }
Beispiel #15
0
  @Override
  public void actionPerformed(ActionEvent event) {

    String cmd = event.getActionCommand();
    statusBar.setStatus("Befehl " + cmd + " wird ausgefuehrt...");
    System.out.println(cmd);
    if (cfg.useCmd_log()) {
      SendToServer.info("Action:" + cmd);
    }

    /*
     * Aufruf einer "Unterfunktion" in separatem thread:
     *
     * !!! Setzt aber voraus, daß der ActionListener in einem separaten
     * "NichtSwingThread" läuft!
     *
     * SwingUtilities.invokeLater(new Runnable() {
     *
     * public void run() { jIntKfzLb lb = new jIntKfzLb(); MyEventListener
     * el = new MyEventListener(); lb.addMyEventListener(el);
     * lb.setVisible(true); dp.add(lb); } }); }
     */

    /*
     * LOGIN mit Aufbau Vbdg.
     */
    if (cmd.equals("Anmeldung")) {
      this.cfg.initLDAP();
      this.gui.initMenu();
      this.cfg.setDst_list(null);
      System.out.println("Starte Anmelde-Prozess...");
      lD = LoginDialog.getInstance();
    }

    if (cmd.equals("USER")) {

      String user = LoginDialog.getInstance().getUserName();
      this.snd.play(Sound.SoundClip.KASSE);
      if (this.cfg.isDebug()) {
        System.out.println("USER: "******"LOGIN")) {

      if (this.cfg.isWaitPanel() && this.cfg.isUseSwingWorker()) {

        this.workerWait =
            new SwingWorker<String, Void>() {
              @Override
              protected String doInBackground() {
                wt = new Wait("WARTE", "Anmeldung am System...");
                return "OK";
              }

              @Override
              protected void done() {}
            };
        workerLogin =
            new SwingWorker<String, Void>() {
              @Override
              protected String doInBackground() {
                gui.login2();
                return "OK";
              }

              @Override
              protected void done() {
                wt.stop();
              }
            };
        // bei Anmeldung wird versucht, LOG-Eintrag zu erstellen, auch
        // wenn eventuell vorher die Vbdg. zum CMD-Server ohne Erfolg war
        cfg.setCmd_log(true);
        workerWait.execute();
        workerLogin.execute();

      } else {

        CursorTools.startWaitCursor(gui);
        gui.login2();
        CursorTools.stopWaitCursor(gui);
      }
    }

    if (cmd.equals("ABBRUCH")) {
      if (lD != null) {
        System.out.println("Abbruch LOGIN- Bearbeitung...");
        lD.close();
        lD = null;
        cfg.initLDAP();
        cfg.setLogin_usr("");
        cfg.setLogin_pwd("");
        cfg.setLogin_ok(false);
        Jan.logger.info("===> Abbruch der Anmeldung ");
        snd.play(Sound.SoundClip.LASER);
        gui.setTitle(cfg.getTitle() + " <NICHT ANGEMELDET>");
      }
    }

    // mit VM verbinden
    if (cmd.equals("CVM")) {

      if (cfg.isLogin_ok()) {

        act_dst = "";
        dl = LdapEntry_Parser.parse_protocol(cfg.getLdap_vm().trim());
        if (dl != null) {
          if (dl.getEntryNum() > 1) {
            SelectDestination sd = new SelectDestination();
            act_dst = sd.getDestination(dl);
          } else if (dl.getEntryNum() == 1) {
            act_dst = dl.getDstList().get(0).getDestinationTitle();
          } else {
            System.out.println("CVM: destination list is empty!!!");
          }
        } else {
          System.out.println("CVM: destination list is NULL!!!");
        }

        if (cfg.isDebug()) {
          System.out.print("selected destination: " + act_dst + "\n");
        }

        StartClientReturnCode rc = Destination_Hub.startThis(act_dst);

      } else {
        String msg = "\n Sie sind nicht erfolgreich angemeldet! \n\n";
        if (cfg.isInternalFrames()) {
          JOptionPane.showInternalMessageDialog(
              gui.getContentPane(), msg, "FEHLER", JOptionPane.ERROR_MESSAGE);
        } else {
          JOptionPane.showMessageDialog(gui, msg, "FEHLER", JOptionPane.ERROR_MESSAGE);
        }
      }
    }
    // Info/Version
    if (cmd.equals("VERSION")) {
      snd.play(Sound.SoundClip.TAB);
      String msg =
          "\n Titel: "
              + cfg.getTitle()
              + "\n Version: "
              + cfg.getVersion()
              + "\n\n Autor: "
              + cfg.getAutor()
              + "\n\n Info: "
              + cfg.getInfo()
              + "\n\n";
      if (cfg.isInternalFrames()) {
        JOptionPane.showInternalMessageDialog(
            gui.getContentPane(), msg, "Info", JOptionPane.INFORMATION_MESSAGE);
      } else {
        JOptionPane.showMessageDialog(gui, msg, "Info", JOptionPane.INFORMATION_MESSAGE);
      }
    }
    // Info/Umgebung
    if (cmd.equals("ENV")) {

      String param;
      snd.play(Sound.SoundClip.TAB);
      if (cfg.getLdap_vm().length() > 77) {
        param = cfg.getLdap_vm().substring(1, 77) + "...";
      } else {
        param = cfg.getLdap_vm();
      }
      String msg =
          "\n"
              + cfg.getTitle()
              + "\n"
              + cfg.getVersion()
              + "\n\n Host: "
              + cfg.getLocal_HostName()
              + "\n IP: "
              + cfg.getLocal_IP()
              + "\n MAC: "
              + cfg.getLocal_MAC()
              + "\n java version: "
              + cfg.getLocal_java_version()
              + "\n os name: "
              + cfg.getLocal_os_name()
              + "\n linux Rel.: "
              + cfg.getLinuxRelease()
              + "\n jvm version: "
              + cfg.getLocal_jvm_version()
              + "\n\n user: "******"\n context: "
              + cfg.getLogin_context()
              + "\n PARAM: "
              + param
              + "\n eMail: "
              + cfg.getLdap_mail()
              + "\n fullName: "
              + cfg.getLdap_fullName()
              + "\n last login time: "
              + Tools.t2s(cfg.getLdap_loginTime())
              + "\n login exp. time: "
              + Tools.t2s(cfg.getLdap_passwordExpirationTime())
              + "\n login disabled : "
              + cfg.getLdap_loginDisabled()
              + "\n login grace limit     : "
              + cfg.getLdap_loginGraceLimit()
              + "\n login grace remaining : "
              + cfg.getLdap_loginGraceRemaining()
              + "\n passwordMinimumLength : "
              + cfg.getLdap_passwordMinimumLength()
              + "\n passwordUniqueRequired: "
              + cfg.getLdap_passwordUniqueRequired()
              + "\n\n";
      if (cfg.isInternalFrames()) {
        JOptionPane.showInternalMessageDialog(
            gui.getContentPane(), msg, "Umgebung", JOptionPane.INFORMATION_MESSAGE);
      } else {
        JOptionPane.showMessageDialog(gui, msg, "Umgebung", JOptionPane.INFORMATION_MESSAGE);
      }
    }

    // Info/Uhr
    if (cmd.equals("UHR")) {
      JDialog f = new JDialog();
      f.setTitle("Uhr-Zeit");
      f.setIconImage(res.clockIcon);
      f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
      f.setResizable(false);
      f.getContentPane().add(new Clock());
      f.pack();
      f.setLocationRelativeTo(null);
      f.setAlwaysOnTop(true);
      f.setResizable(false);
      f.setVisible(true);
    }

    // Hilfe001
    if (cmd.equals("HELP001")) {
      Calendar cal = Calendar.getInstance();
      int day = cal.get(Calendar.DAY_OF_MONTH);
      int month = cal.get(Calendar.MONTH);

      if (day == 7 && month == 9) { // 7. October
        Help00x.show();
      } else {
        Help000.show();
      }
    }

    // CountDown via ProgressMonitor
    if (cmd.equals("CNTDWN")) {
      final JDialog f = new JDialog();
      f.setTitle("FRAGE");
      f.setResizable(false);
      f.setIconImage(res.clockIcon);
      f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
      f.setSize(290, 220);

      JLabel l1 = new JLabel("Start-Befehl wurde gesendet.");
      JLabel l2 = new JLabel(" Was soll ich jetzt tun?");
      final JButton ok = new JButton("VERBINDEN");
      ok.setMnemonic('v');
      ok.setIcon(res.computerImageIcon);
      ok.setToolTipText("Verbindung wird erneut versucht.");
      ok.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              gui.getInstance().startRHEV(true);
              f.dispose();
            }
          });

      final JButton cancel = new JButton("Abbruch");
      cancel.setMnemonic('a');
      cancel.setIcon(res.cancelImageIcon);
      cancel.setToolTipText("Funktion abbrechen.");
      cancel.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              f.dispose();
            }
          });

      JPanel p = new JPanel();
      p.setLayout(new BorderLayout());
      JPanel p_north = new JPanel();
      JPanel p_south = new JPanel();
      JPanel p_center = new JPanel();
      JPanel p_east = new JPanel();
      JPanel p_west = new JPanel();
      p_center.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));

      p_north.add(l1);
      p_center.add(l2);
      p_south.add(ok);
      p_south.add(cancel);

      p.add(BorderLayout.NORTH, p_north);
      p.add(BorderLayout.SOUTH, p_south);
      p.add(BorderLayout.CENTER, p_center);
      p.add(BorderLayout.EAST, p_east);
      p.add(BorderLayout.WEST, p_west);

      CountDown cd = new CountDown(cfg.getRhevCntDwnVMstart());
      // p.add(cd);

      f.add(p);
      f.pack();
      f.setLocationRelativeTo(null);
      f.setVisible(true);

      cd.start();
    }

    // Senden
    if (cmd.equals("SENDEN")) {

      if (cfg.isLogin_ok()) {
        System.out.println("starte Sende-Dialog!");
        int result = ImportSelector.selectFiles();
        if (result > 0) {
          System.out.println("" + result + " Dateien übertragen");
        } else {
          System.out.println("Fehler " + result + " beim Senden der Dateien aufgetreten.");
        }

      } else {
        String msg = "\n Sie sind nicht erfolgreich angemeldet! \n\n";
        if (cfg.isInternalFrames()) {
          JOptionPane.showInternalMessageDialog(
              gui.getContentPane(), msg, "FEHLER", JOptionPane.ERROR_MESSAGE);
        } else {
          JOptionPane.showMessageDialog(gui, msg, "FEHLER", JOptionPane.ERROR_MESSAGE);
        }
      }
    }

    // Empfangen
    if (cmd.equals("EMPFANGEN")) {
      if (cfg.isLogin_ok()) {

        System.out.println("starte Empfang-Dialog!");
        int result = ExportSelector.selectFiles();
        if (result > 0) {
          System.out.println("" + result + " Dateien kopiert");
        } else {
          System.out.println("Fehler " + result + " beim Empfang der Dateien aufgetreten.");
        }

      } else {
        String msg = "\n Sie sind nicht erfolgreich angemeldet! \n\n";
        if (cfg.isInternalFrames()) {
          JOptionPane.showInternalMessageDialog(
              gui.getContentPane(), msg, "FEHLER", JOptionPane.ERROR_MESSAGE);
        } else {
          JOptionPane.showMessageDialog(gui, msg, "FEHLER", JOptionPane.ERROR_MESSAGE);
        }
      }
    }

    // Programm-Ende
    if (cmd.equals("ENDE")) {
      gui.sac();
    }

    // Computer ausschalten
    if (cmd.equals("SHUTDOWN")) {
      System.out.println("Starte Shutdown-Prozess...");
      gui.shutdownClient();
    }

    statusBar.setStatus("Befehl " + cmd + " beendet.");
  }