コード例 #1
0
  /** Creates a new QuestionImportUI */
  public QuestionImportUI() {
    _dialog = new JDialog();
    _dialog.setIconImage(Loader.getImageIcon(Loader.IMAGE_STURESY).getImage());

    _dialog.setLayout(new BorderLayout());

    _loadButton = new JButton(Localize.getString("button.load"));
    _cancelButton = new JButton(Localize.getString("button.cancel"));

    _list = new JList(new DefaultListModel());
    _list.setCellRenderer(new QuestionListCellRenderer(35));
    JScrollPane pane = new JScrollPane(_list);

    JLabel label = new JLabel(Localize.getString("label.select.questions"));

    _dialog.add(label, BorderLayout.NORTH);
    _dialog.add(pane, BorderLayout.CENTER);

    JPanel southpanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    southpanel.add(_loadButton);
    southpanel.add(_cancelButton);

    _dialog.add(southpanel, BorderLayout.SOUTH);
    _dialog.setSize(300, 350);
  }
コード例 #2
0
 /**
  * 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;
 }
コード例 #3
0
ファイル: Utils.java プロジェクト: hathix/cabra-desktop
  /**
   * Utility method to put the given panel in a JDialog. You'll have to show it on your own.
   *
   * @param panel the panel to put in a dialog
   * @param owner the JFrame that owns the dialog. You can pass null.
   * @param dialogTitle the title for the dialog
   * @param iconPath the path to the dialog's icon, such as foo.png
   * @param width the dialog's width. Pass -1 to pack().
   * @param height the dialog's height. Pass -1 to pack().
   * @return the JDialog the panel is in
   */
  public static JDialog putPanelInDialog(
      JPanel panel, JFrame owner, String dialogTitle, String iconPath, int width, int height) {
    JDialog dialog = new JDialog(owner, dialogTitle, true); // boolean means modality

    dialog.add(panel);
    dialog.setIconImage(ImageManager.createImageIcon(iconPath).getImage());
    if (width < 0 && height < 0) dialog.pack();
    else dialog.setSize(width, height);
    dialog.setResizable(false);
    if (owner != null) Utils.centerComponent(dialog, owner);
    else dialog.setLocationRelativeTo(null);

    return dialog;
  }
コード例 #4
0
ファイル: ClientMain.java プロジェクト: yarhoslavme/Slyther
 private static void createNativesFolder(File folder) {
   if (folder.exists() && !folder.isDirectory()) {
     Desktop desktop = Desktop.getDesktop();
     JButton browseFolder;
     JButton ok = new JButton(UIManager.getString("OptionPane.okButtonText"));
     Object[] options;
     if (desktop.isSupported(Action.BROWSE)) {
       browseFolder = new JButton("Browse Folder");
       options = new Object[] {browseFolder, ok};
     } else {
       browseFolder = null;
       options = new Object[] {ok};
     }
     JOptionPane msg =
         new JOptionPane(
             "We must create this folder \""
                 + folder
                 + "\" and there is a file called natives in its place.\n"
                 + "Rename or move at this time or it will be deleted. Resistance is futile.",
             JOptionPane.INFORMATION_MESSAGE,
             JOptionPane.DEFAULT_OPTION,
             null,
             options);
     if (browseFolder != null) {
       browseFolder.addActionListener(
           action -> {
             try {
               Desktop.getDesktop().browse(folder.getParentFile().toURI());
             } catch (Exception e) {
               UIUtils.displayException("Unable to browse folder", e);
             }
           });
     }
     ok.addActionListener(action -> msg.setValue(0));
     JDialog dialog = msg.createDialog("Slyther");
     try (InputStream icon = ClientMain.class.getResourceAsStream("/textures/icon_32.png")) {
       dialog.setIconImage(ImageIO.read(icon));
     } catch (IOException e) {
     }
     dialog.setVisible(true);
     dialog.dispose();
     folder.delete();
   }
   folder.mkdirs();
 }
コード例 #5
0
ファイル: Utils.java プロジェクト: hathix/cabra-desktop
  /**
   * Uses a JEditorPane to open the given URL in a dialog
   *
   * @param url the url to load
   * @param title the title of the dialog
   * @param frame the parent frame
   * @param visible true if you want the dialog to be visible, false if you want it to be invisible
   *     to user
   * @param iconPath the path to the image icon for the dialog.
   */
  public static void openURLinDialog(
      String url, String title, String iconPath, JFrame frame, boolean visible) {
    // create panel with page in it
    final int WIDTH = 400;
    final int HEIGHT = 300;
    JPanel webView = createEditorPane(url, WIDTH, HEIGHT);

    // put it in a dialog
    JDialog dialog = new JDialog(frame);
    dialog.setTitle(title);
    dialog.setIconImage(GUI.createImageIcon(iconPath).getImage());
    dialog.setContentPane(webView);
    dialog.pack();
    dialog.setResizable(false);
    dialog.setModal(true);
    Utils.centerComponent(dialog, frame);

    // open it
    dialog.setVisible(visible);
  }
コード例 #6
0
ファイル: ApplicationActions.java プロジェクト: tl64/Jan
  @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.");
  }