private void loadList(JList list) {
    list.removeAll();
    profiles = parentGenerator.getProfiles();
    DefaultListModel model = new DefaultListModel();
    int i = 0;
    int foundLastProfile = -1;
    for (Profile p : profiles) {

      // Check that this profile says it's for this machine
      if (ProfileUtils.shouldDisplay(p) || filterBox.isSelected()) model.addElement(p.toString());
      if (p.toString().equals(Base.preferences.get("lastGeneratorProfileSelected", "---"))) {
        Base.logger.fine("Selecting last used element: " + p);
        foundLastProfile = i;
      }
      i++;
    }
    list.setModel(model);
    list.clearSelection();
    if (foundLastProfile != -1) {
      list.setSelectedIndex(foundLastProfile);
      doneButton.setEnabled(true);
      doneButton.requestFocusInWindow();
      doneButton.setFocusPainted(true);
    }
  }
Пример #2
0
  public NotificacioGenerica(String missatge) {
    frame = new JFrame("Notificació");
    frame.getContentPane().setLayout(new GridBagLayout());
    label = new JTextArea(missatge);
    label.setEnabled(false);
    label.setEditable(false);
    button = new JButton("D'acord!");
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    frame.getContentPane().add(label, c);
    c.gridy = 1;
    frame.getContentPane().add(button, c);
    button.requestFocusInWindow();

    button.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent actionEvent) {
            frame.dispose();
          }
        });

    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    pack();
    mostra(true);
  }
Пример #3
0
 @Override
 public void setVisible(final boolean visible) {
   showOrHide();
   super.setVisible(visible);
   if (visible) {
     UpdaterUserInterface.get().addWindow(this);
     apply.requestFocusInWindow();
   }
 }
Пример #4
0
  private void createUI() {
    JPanel cp = new JPanel();

    okButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            setVisible(false);
            dispose();
          }
        });

    cp.setBorder(new EmptyBorder(16, 16, 16, 16));
    cp.setLayout(new MigLayout("wrap 2", "[][100::, grow]", "[][][]20[][][][][]20[]"));

    cp.add(playerVersionLabel, "c, span 2");

    JPanel vendorPanel = new JPanel();
    vendorPanel.add(copyrightLabel);
    vendorPanel.add(vendorHomePageLabel);

    cp.add(vendorPanel, "c, span 2");

    JPanel termsPanel = new JPanel();
    termsPanel.add(termsLabel);
    termsPanel.add(licensePageLabel);

    cp.add(termsPanel, "c, span 2");
    cp.add(new HeaderLabel("Components:"), "span 2, grow");
    cp.add(vlcjVersionLabel);
    cp.add(vlcjVersionValueLabel, "grow");
    cp.add(libVlcVersionLabel);
    cp.add(libVlcVersionValueLabel, "grow");
    cp.add(libVlcChangeSetLabel);
    cp.add(libVlcChangeSetValueLabel, "grow");
    cp.add(libVlcCompilerLabel);
    cp.add(libVlcCompilerValueLabel, "grow");
    cp.add(okButton, "r, span 2, tag ok");

    setLayout(new BorderLayout());
    add(cp, BorderLayout.CENTER);

    LinkListener linkListener = new LinkListener();
    vendorHomePageLabel.addActionListener(linkListener);
    licensePageLabel.addActionListener(linkListener);

    pack();

    okButton.requestFocusInWindow();
  }
Пример #5
0
 public void actionPerformed(ActionEvent event) {
   if (event.getSource().equals(launchBrowser)) {
     Configuration config = Configuration.getInstance();
     String ip = Util.getIPAddress();
     String protocol = "http" + (config.ssl ? "s" : "");
     String url = protocol + "://" + ip + ":" + config.port;
     Util.openURL(url);
   } else if (event.getSource().equals(stop)) {
     Util.shutdown();
     running = Util.isRunning();
     setStatus();
   } else if (event.getSource().equals(start)) {
     clearLogsDir();
     run();
     launchBrowser.requestFocusInWindow();
   }
 }
Пример #6
0
  public OwnerDialog(Araucaria parent) {

    super((Frame) null, true);
    araucaria = parent;
    propText = araucaria.getArgument().getSelectedProps();
    try {
      init();
      okButton.requestFocusInWindow();
      addDialogCloser(masterPanel);
      this.getRootPane().setDefaultButton(okButton);
      this.pack();
    } catch (Exception e) {
      e.printStackTrace();
    }
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    this.setLocation(
        d.width / 2 - this.getSize().width / 2, d.height / 2 - this.getSize().height / 2);
  }
Пример #7
0
  protected void showThirdParty() {
    // Show third parties licenses list
    thirdPartyBtn.setForeground(UIConstants.INTEL_DARK_GRAY);
    thirdPartyBtn.setBackground(UIConstants.INTEL_WHITE);
    copyrightBtn.setForeground(UIConstants.INTEL_BLUE);
    copyrightBtn.setBackground(tabBgColor);

    java.net.URL otherJarsURL = getClass().getResource("/help/ThirdPartyJars.html");

    if (otherJarsURL != null) {
      try {
        editor.setPage(otherJarsURL);
      } catch (IOException ioe) {
        System.err.println("ThirdPartyJars.html file is not found.");
        ioe.printStackTrace();
      }
    }
    okBtn.requestFocusInWindow();
  }
 private void loadList(JList list) {
   list.removeAll();
   List<Profile> profiles = getProfiles();
   DefaultListModel model = new DefaultListModel();
   int i = 0;
   int foundLastProfile = -1;
   for (Profile p : profiles) {
     model.addElement(p);
     if (p.toString().equals(Base.preferences.get("lastGeneratorProfileSelected", "---"))) {
       Base.logger.fine("Selecting last used element: " + p);
       foundLastProfile = i;
     }
     i++;
   }
   list.setModel(model);
   list.clearSelection();
   if (foundLastProfile != -1) {
     list.setSelectedIndex(foundLastProfile);
     generate.setEnabled(true);
     generate.requestFocusInWindow();
     generate.setFocusPainted(true);
   }
 }
Пример #9
0
  public ExercisePassedDialog(Exercise exo) {
    super(MainFrame.getInstance(), "Exercice passed \\o/", false);

    this.setTitle(Game.i18n.tr("Exercice passed \\o/"));

    setLayout(new MigLayout("fill", "", "[fill,grow,push][]"));

    JTabbedPane panes = new JTabbedPane();
    add(panes, "span,grow");

    /* ------------ The congrats panel ------------ */
    JPanel congratsPane = new JPanel();
    panes.addTab(Game.i18n.tr("Congrats"), congratsPane);
    congratsPane.setLayout(new MigLayout("fill"));

    JLabel msg = new JLabel();
    Vector<Lecture> nextExercises = exo.getDependingLectures();
    final JComboBox<Lecture> exoChooser =
        nextExercises.isEmpty() ? null : new JComboBox<Lecture>(nextExercises);

    if (nextExercises.size() == 0) {
      if (exo.lastResult.passedTests > 1) {
        msg.setText(
            Game.i18n.tr(
                    "<html>Congratulations, you passed this exercise.<br>{0} tests passed.</html>",
                    exo.lastResult.passedTests)
                + exo.lastResult.executionError);
      } else {
        msg.setText(
            Game.i18n.tr(
                    "<html>Congratulations, you passed this exercise.</html>",
                    exo.lastResult.passedTests)
                + exo.lastResult.executionError);
      }

      congratsPane.add(new JLabel(ResourcesCache.getIcon("img/trophy.png")));
      congratsPane.add(msg, "wrap,grow,aligny 50%");

    } else {

      if (exo.lastResult.passedTests > 1) {
        msg.setText(
            Game.i18n.tr(
                "<html>Congratulations, you passed this exercise.<br>({0} tests passed)<br>Which exercise will you do now?</html>",
                exo.lastResult.passedTests));
      } else {
        msg.setText(
            Game.i18n.tr(
                "<html>Congratulations, you passed this exercise.<br>Which exercise will you do now?</html>"));
      }

      congratsPane.add(new JLabel(ResourcesCache.getIcon("img/trophy.png")), "spany 2");
      congratsPane.add(msg, "wrap,grow,aligny 50%");
      congratsPane.add(exoChooser, "wrap,alignx 50%");
    }

    /* ------------ The feedback panel ------------ */
    JPanel feedbackPane = new JPanel();
    panes.addTab(Game.i18n.tr("Give feedback"), feedbackPane);
    feedbackPane.setLayout(
        new MigLayout("fill", "[][grow,fill]20[][grow,fill]", "[][][][grow,fill,push]0[]"));

    feedbackPane.add(
        new JLabel(
            Game.i18n.tr(
                "Please help us to improve this exercise by filling this little evaluation.")),
        "growx, growy 0,wrap,spanx 4");

    JLabel lbDifficulty = new JLabel(Game.i18n.tr("Difficulty:"));
    feedbackPane.add(lbDifficulty, "align right");
    /* Difficulties are the text presented to the user while difficultiesEN are the one that will be added to the report */
    String[] difficulties =
        new String[] {
          Game.i18n.tr("(please choose)"),
          Game.i18n.tr("Too easy"),
          Game.i18n.tr("Easy"),
          Game.i18n.tr("Just right"),
          Game.i18n.tr("Difficult"),
          Game.i18n.tr("Too difficult")
        };
    final String[] difficultiesEN =
        new String[] {"Too easy", "Easy", "Just right", "Difficult", "Too difficult"};
    final JComboBox<String> difficultiesChooser = new JComboBox<String>(difficulties);
    feedbackPane.add(difficultiesChooser, "grow");

    JLabel lbInterest = new JLabel(Game.i18n.tr("Interest:"));
    feedbackPane.add(lbInterest, "");
    String[] interests =
        new String[] {
          Game.i18n.tr("(please choose)"),
          Game.i18n.tr("Really good"),
          Game.i18n.tr("Amusing"),
          Game.i18n.tr("Just okay"),
          Game.i18n.tr("Boring"),
          Game.i18n.tr("Really bad"),
        };
    final String[] interestsEN =
        new String[] {
          "(please choose)", "Really good", "Amusing", "Just okay", "Boring", "Really bad"
        };
    final JComboBox<String> interestChooser = new JComboBox<String>(interests);
    feedbackPane.add(interestChooser, "grow,wrap");

    feedbackPane.add(
        new JLabel(Game.i18n.tr("Free comments on that exercise:")), "grow 0,spanx 4,wrap");
    final JEditorPane comment = new JEditorPane();
    JScrollPane spComment = new JScrollPane(comment);
    feedbackPane.add(spComment, "push,grow 20000 20000,wrap,span");

    /* ------------ The close button ------------ */
    final ExecutionProgress result = exo.lastResult;
    JButton close = new JButton(Game.i18n.tr("Close"));
    close.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            if (exoChooser != null) {
              Game.getInstance().setCurrentExercise((Lecture) exoChooser.getSelectedItem());
            }

            String chosenDifficulty = null;
            for (String d : difficultiesEN)
              if (difficultiesChooser.getSelectedItem().equals(Game.i18n.tr(d)))
                chosenDifficulty = d;
            String chosenInterest = null;
            for (String d : interestsEN)
              if (interestChooser.getSelectedItem().equals(Game.i18n.tr(d))) chosenInterest = d;

            result.feedbackDifficulty = chosenDifficulty;
            result.feedbackInterest = chosenInterest;
            result.feedback = comment.getText();
            if (result.feedback.equals("")) result.feedback = null;
            dispose();
          }
        });
    add(close, "span, alignx 50%");

    /* ------------ wrap up the dialog ------------ */
    setModal(true);
    setModalityType(ModalityType.APPLICATION_MODAL);
    pack();
    close.requestFocusInWindow();
    setMinimumSize(getSize());
    setVisible(true);
  }
Пример #10
0
 public void setFocusOnStart() {
   start.requestFocusInWindow();
 }
Пример #11
0
  /** Creates a new WelcomeFrame and makes it visible. */
  public WelcomeFrame() {
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(final WindowEvent event) {
            cancel();
          };
        });

    setIconImage(Icons.SC2GEARS.getImage());

    final Box box = Box.createVerticalBox();
    box.add(Box.createVerticalStrut(5));
    box.add(GuiUtils.wrapInPanel(SharedUtils.createAnimatedLogoLabel()));
    box.add(Box.createVerticalStrut(10));
    GuiUtils.changeFontToBold(welcomeLabel);
    box.add(Box.createVerticalStrut(15));
    box.add(GuiUtils.wrapInPanel(welcomeLabel));
    box.add(Box.createVerticalStrut(15));
    box.add(GuiUtils.wrapInPanel(firstRunLabel));
    box.add(GuiUtils.wrapInPanel(chooseLabel));
    box.add(Box.createVerticalStrut(15));
    box.add(GuiUtils.wrapInPanel(thankYouLabel));
    box.add(Box.createVerticalStrut(15));

    final JPanel languagePanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 1));
    languagePanel.add(languageLabel);
    final JComboBox<String> languagesComboBox = new JComboBox<>(Language.getAvailableLanguages());
    languagesComboBox.setMaximumRowCount(
        languagesComboBox.getModel().getSize()); // Display all languages
    languagesComboBox.setRenderer(
        new BaseLabelListCellRenderer<String>() {
          @Override
          public Icon getIcon(final String value) {
            return Icons.getLanguageIcon(value);
          }
        });
    languagesComboBox.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent event) {
            final String language = (String) languagesComboBox.getSelectedItem();
            Language.loadAndActivateLanguage(language);

            reassignTexts();
          }
        });
    languagePanel.add(languagesComboBox);
    box.add(languagePanel);

    final JPanel voicePanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 1));
    voicePanel.add(voiceLabel);
    final JComboBox<VoiceDescription> voiceComboBox = new JComboBox<>(Sounds.VOICE_DESCRIPTIONS);
    voiceComboBox.setMaximumRowCount(15); // Not too many languages, display them all
    voiceComboBox.setRenderer(
        new BaseLabelListCellRenderer<VoiceDescription>() {
          @Override
          public Icon getIcon(final VoiceDescription value) {
            return Icons.getLanguageIcon(value.language);
          }
        });
    voiceComboBox.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent event) {
            final VoiceDescription voiceDescription =
                (VoiceDescription) voiceComboBox.getSelectedItem();
            Settings.set(Settings.KEY_SETTINGS_VOICE, voiceDescription.name);
            Sounds.playSoundSample(Sounds.SAMPLE_WELCOME, false);
          }
        });
    voicePanel.add(voiceComboBox);
    box.add(voicePanel);

    int maxWidth =
        Math.max(
            languagesComboBox.getPreferredSize().width, voiceComboBox.getPreferredSize().width);
    maxWidth += 5;
    languagesComboBox.setPreferredSize(
        new Dimension(maxWidth, languagesComboBox.getPreferredSize().height));
    voiceComboBox.setPreferredSize(
        new Dimension(maxWidth, voiceComboBox.getPreferredSize().height));

    box.add(Box.createVerticalStrut(15));

    final JPanel buttonsPanel = new JPanel();
    okButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent event) {
            dispose();
            Settings.set(
                Settings.KEY_SETTINGS_LANGUAGE, (String) languagesComboBox.getSelectedItem());
            Settings.saveProperties();
            synchronized (WelcomeFrame.this) {
              Sounds.playSoundSample(Sounds.SAMPLE_THANK_YOU, false);
              WelcomeFrame.this
                  .notify(); // Notify the main thread to continue starting the application
            }
          }
        });
    buttonsPanel.add(okButton);
    cancelButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent event) {
            cancel();
          }
        });
    buttonsPanel.add(cancelButton);
    box.add(buttonsPanel);

    box.add(Box.createVerticalStrut(15));

    final JPanel panel = new JPanel();
    panel.add(Box.createHorizontalStrut(15));
    panel.add(box);
    panel.add(Box.createHorizontalStrut(15));
    getContentPane().add(panel);

    setResizable(false);

    reassignTexts();
    setVisible(true);

    okButton.requestFocusInWindow();
    Sounds.playSoundSample(Sounds.SAMPLE_WELCOME, false);
  }
Пример #12
0
 /** Shows the dialog. */
 public void showDialog() {
   returnVal = JOptionPane.CANCEL_OPTION;
   setVisible(true);
   okButton.requestFocusInWindow();
 }
Пример #13
0
  public Home(Master frame) {
    filler = new JPanel();
    fillers = new JPanel();
    signup = new JButton("Sign Up");
    login = new JButton("Log In");
    username = new JTextField(10);
    password = new JPasswordField(10);
    status = new JLabel("");

    username.setText("username");
    username.addFocusListener(
        new FocusListener() {
          public void focusGained(FocusEvent e) {
            if (username.getText().equals("username")) {
              username.setText("");
            }
          }

          public void focusLost(FocusEvent e) {
            if (username.getText().trim().length() == 0) {
              username.setText("username");
            }
          }
        });
    password.setText("password");
    password.addFocusListener(
        new FocusListener() {
          public void focusGained(FocusEvent e) {
            if (password.getText().equals("password")) {
              password.setText("");
            }
          }

          public void focusLost(FocusEvent e) {
            if (password.getText().trim().length() == 0) {
              password.setText("password");
            }
          }
        });

    filler.setPreferredSize(new Dimension(app_width, app_height - 80));
    filler.setOpaque(false);
    fillers.setPreferredSize(new Dimension(app_width, 5));
    fillers.setOpaque(false);

    signup.setBackground(Color.WHITE);
    login.setBackground(Color.WHITE);

    signup.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            status.setText("Creating new user...");
            user = new Player(username.getText(), password.getPassword().toString());
            WorldMap worldmap = new WorldMap(frame, user);
            worldmap.newUserMode();
            frame.switchContentPane(worldmap);
            // TODO: create new player
            // TODO: connect to server
            // TODO: check if username already taken
            // TODO: else, add to master list of players and log in
            // TODO: check towns that are online / available
          }
        });

    login.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            status.setText("Connecting to server...");
            // TODO: connect to server
            // TODO: get player from server
            // TODO: if connect success, move to index
            // frame.switchContentPane(new Index(frame, user));
          }
        });

    setPreferredSize(new Dimension(app_width, (app_height)));
    setBackground(Color.WHITE);
    add(filler);
    add(username);
    add(password);
    add(signup);
    add(login);
    add(fillers);
    add(status);

    signup.requestFocusInWindow();
  }
Пример #14
-1
  public EventInfoFrame(TestEvent event) {
    setAlwaysOnTop(true);
    textArea = new JTextArea(stackTraceToString(event.getStackTrace()));
    textArea.setEditable(false);
    textArea.setColumns(80);
    textArea.setWrapStyleWord(true);
    textArea.setLineWrap(true);
    getContentPane().add(new JScrollPane(textArea));
    Container southPanel = new JPanel(new FlowLayout());
    Action disposeAction =
        new AbstractAction("Close") {
          private static final long serialVersionUID = -1L;

          public void actionPerformed(ActionEvent e) {
            dispose();
          }
        };
    closeButton = new JButton(disposeAction);
    southPanel.add(closeButton);
    getContentPane().add(southPanel, BorderLayout.SOUTH);
    String message = event.getMessage();
    if (message == null) {
      message = "";
    }
    setTitle(event.getTestName() + "." + event.getTestMethod() + "()");
    pack();
    closeButton.requestFocusInWindow();
  }