void selectExhibit() {
    ExhibitInfo e = getCurrentExhibit();

    contentListModel.notifyChange();
    exhibitPhotosModel.notifyChange();
    contentList.setSelectionInterval(0, 0);
    for (ListSelectionListener l : contentList.getListSelectionListeners()) {
      l.valueChanged(new ListSelectionEvent(contentList, 0, 0, false));
    }
    exhibitXCoordField.getModel().setValue(e.getX());
    exhibitXCoordOrig.setText("X coordinate: (was " + e.origXCoord + ")");
    exhibitYCoordField.getModel().setValue(e.getY());
    exhibitYCoordOrig.setText("Y coordinate: (was " + e.origYCoord + ")");

    exhibitNextDropdown.setSelectedItem(e.getNext());
    if (e.getNext() != null) {
      exhibitNextOrig.setText("Next: (was " + e.origNext + ")");
    } else {
      exhibitPreviousOrig.setText("Next:");
    }
    exhibitPreviousDropdown.setSelectedItem(e.getPrevious());
    if (e.getPrevious() != null) {
      exhibitPreviousOrig.setText("Previous: (was " + e.origPrevious + ")");
    } else {
      exhibitPreviousOrig.setText("Previous:");
    }

    exhibitPhotosList.setSelectionInterval(0, 0);
    exhibitAliasesList.setSelectionInterval(0, 0);

    exhibitAliasesModel.notifyChange();

    selectPhoto();
    selectAlias();
  }
  public void updateAttribsFromComponents() {
    if (widthCB.isSelected()) {
      String w = widthField.getModel().getValue().toString();
      if (widthCombo.getSelectedIndex() == 0) w += "%"; // $NON-NLS-1$
      attribs.put("width", w); // $NON-NLS-1$
    } else attribs.remove("width"); // $NON-NLS-1$

    if (alignCB.isSelected())
      attribs.put("align", alignCombo.getSelectedItem().toString()); // $NON-NLS-1$
    else attribs.remove("align"); // $NON-NLS-1$

    if (borderCB.isSelected())
      attribs.put(
          "border", //$NON-NLS-1$
          borderField.getModel().getValue().toString());
    else attribs.remove("border"); // $NON-NLS-1$

    if (cellSpacingCB.isSelected())
      attribs.put(
          "cellspacing", //$NON-NLS-1$
          cellSpacingField.getModel().getValue().toString());
    else attribs.remove("cellspacing"); // $NON-NLS-1$

    if (cellPaddingCB.isSelected())
      attribs.put(
          "cellpadding", //$NON-NLS-1$
          cellPaddingField.getModel().getValue().toString());
    else attribs.remove("cellpadding"); // $NON-NLS-1$

    if (bgPanel.isSelected()) attribs.put("bgcolor", bgPanel.getColor()); // $NON-NLS-1$
    else attribs.remove("bgcolor"); // $NON-NLS-1$
  }
 void selectAlias() {
   int index = exhibitAliasesList.getSelectedIndex();
   if (index < getCurrentExhibit().getAliases().length) {
     aliasDataPanel.setVisible(true);
     Alias alias = getCurrentExhibit().getAliases()[index];
     aliasXCoordField.getModel().setValue(alias.xPos);
     aliasYCoordField.getModel().setValue(alias.yPos);
   } else {
     aliasDataPanel.setVisible(false);
   }
 }
  @Override
  public void setSelection(List<Operator> selection) {
    Operator operator = selection.isEmpty() ? null : selection.get(0);
    if (operator == this.operator) {
      return;
    }
    if (this.operator != null) {
      this.operator.getParameters().removeObserver(parameterObserver);
    }
    this.operator = operator;
    if (operator != null) {
      this.operator.getParameters().addObserver(parameterObserver, true);
      breakpointButton.setEnabled(true);

      // compatibility level
      OperatorVersion[] versionChanges = operator.getIncompatibleVersionChanges();
      if (versionChanges.length == 0) {
        // no incompatible versions exist
        compatibilityLevelSpinner.setVisible(false);
        compatibilityLabel.setVisible(false);
      } else {
        compatibilityLevelSpinner.setVisible(true);
        compatibilityLabel.setVisible(true);
        ((CompatibilityLevelSpinnerModel) compatibilityLevelSpinner.getModel())
            .setOperator(operator);
      }

    } else {
      breakpointButton.setEnabled(false);
    }
    setNameFor(operator);
    setupComponents();
  }
  public void setIReportConnection(IReportConnection c) {

    this.iReportConnection = c;
    if (iReportConnection instanceof JREmptyDatasourceConnection) {
      JREmptyDatasourceConnection con = (JREmptyDatasourceConnection) iReportConnection;
      jSpinnerNumRecords.getModel().setValue(new Integer(con.getRecords()));
    }
  }
  /** Update date spinner to synchronize with the other spinners */
  private void updateDate() {
    // Get current month and year in int
    int month = ((SpinnerListModel) jspMonth.getModel()).getList().indexOf(jspMonth.getValue());
    int year = ((Integer) spinnerYear.getValue()).intValue();

    // Set a new maximum number of days for the new month and year
    SpinnerNumberModel numberModel = (SpinnerNumberModel) jspDay.getModel();
    numberModel.setMaximum(new Integer(maxDaysInMonth(year, month)));

    // Set a new current day if it exceeds the maximum
    if (((Integer) (numberModel.getValue())).intValue() > maxDaysInMonth(year, month))
      numberModel.setValue(new Integer(maxDaysInMonth(year, month)));

    // Get the current day
    int day = ((Integer) jspDay.getValue()).intValue();

    // Set a new date in the date spinner
    jspDate.setValue(new GregorianCalendar(year, month, day).getTime());
  }
  public void weeklyRepeatRB_actionPerformed(ActionEvent e) {
    disableElements();
    enableExceptionElements();

    weekdaysCB.setEnabled(true);
    startDate.setEnabled(true);
    setStartDateB.setEnabled(true);
    lblSince.setEnabled(true);
    enableEndDateCB.setEnabled(true);
    startDate.getModel().setValue(startCalFrame.cal.get().getCalendar().getTime());
  }
  private void initSpinner() {
    spinner.setBorder(BorderFactory.createEmptyBorder());
    Component textfield = ((JSpinner.DefaultEditor) spinner.getEditor()).getTextField();
    // textfield.removeFocusListener(focusListener);
    textfield.addFocusListener(focusListener);

    // spinner.removeChangeListener(changeListener);
    spinner.addChangeListener(changeListener);

    if (spinner.getModel() instanceof SpinnerNumberModel) isNumberModel = true;
  }
  void addExceptionDate_actionPerformed(ActionEvent e) {
    SimpleDateFormat sdf = new SimpleDateFormat("M/d/yyyy");
    String str = sdf.format(exceptionDate.getModel().getValue());

    if (exceptionModel.getSize() > 0) {
      for (int i = 0; i < exceptionModel.getSize(); i++) {
        if (str.equals(exceptionModel.getElementAt(i))) return;
      }
    }

    exceptionModel.addElement(str);
  }
  public void monthlyRepeatRB_actionPerformed(ActionEvent e) {
    disableElements();
    enableExceptionElements();

    dayOfMonthSpin.setEnabled(true);
    startDate.setEnabled(true);
    setStartDateB.setEnabled(true);
    lblSince.setEnabled(true);
    enableEndDateCB.setEnabled(true);
    workingDaysOnlyCB.setEnabled(true);
    startDate.getModel().setValue(startCalFrame.cal.get().getCalendar().getTime());
  }
 /**
  * Check if current value set in spinner is correct and set it to bound parameter object (mainly
  * used in change listeners).
  */
 private void setFromSpinner() {
   NullableSpinnerModel numberModel = (NullableSpinnerModel) spinner.getModel();
   Integer value = numberModel.getNumber();
   if (value == null && !param.isOptional()) {
     setState(ParameterInputComponent.INPUT_IS_REQUIRED_AND_EMPTY);
   } else if (param.checkValidityOf(value) == true) {
     param.setValue(value);
     setState(ParameterInputComponent.INPUT_IS_VALID);
   } else {
     setState(ParameterInputComponent.INPUT_IS_OUT_OF_BOUNDS);
   }
 }
  public IReportConnection getIReportConnection() {

    IReportConnection irConn = new JREmptyDatasourceConnection();

    ((JREmptyDatasourceConnection) irConn)
        .setRecords(
            ((javax.swing.SpinnerNumberModel) jSpinnerNumRecords.getModel())
                .getNumber()
                .intValue());
    iReportConnection = irConn;
    return iReportConnection;
  }
 public void setFormats(Format inputFormat, Format outputFormat) {
   this.inputFormat = inputFormat;
   this.outputFormat = outputFormat;
   // System.out.println("Spinner model: " + spinner.getModel());
   spinner.setModel(spinner.getModel());
   // System.out.println("**** Setting spinner editor");
   if (inputFormat instanceof DecimalFormat) {
     spinner.setEditor(
         new JSpinner.NumberEditor(spinner, ((DecimalFormat) inputFormat).toPattern()));
   } else if (outputFormat instanceof SimpleDateFormat) {
     spinner.setEditor(
         new JSpinner.DateEditor(spinner, ((SimpleDateFormat) inputFormat).toPattern()));
   }
   initSpinner();
   initComboBox();
 }
示例#14
0
 public void stateChanged(ChangeEvent ce) {
   JSpinner spinner = (JSpinner) ce.getSource();
   int value = ((SpinnerNumberModel) spinner.getModel()).getNumber().intValue();
   if (spinner == labelSpinner) {
     positionSpinner
         .getModel()
         .setValue(
             new Double((chart1.getAxes().getLeft().getCustomLabels().getItem(value)).getValue()));
   } else if (spinner == positionSpinner) {
     chart1
         .getAxes()
         .getLeft()
         .getCustomLabels()
         .getItem(labelModel.getNumber().intValue())
         .setValue(value);
   }
 }
示例#15
0
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() == jbColor) {
     ColorChooseDialog ccd = new ColorChooseDialog(this);
     edge.color = ccd.getColor();
     colorLabel.setBackground(edge.color);
     return;
   }
   if (e.getSource() == jcbAnchored) {
     edge.setFixed(jcbAnchored.isSelected());
     return;
   }
   Double w = 0d;
   if (e.getSource() != jbDelete) {
     try {
       w = Double.parseDouble(tf.getText());
     } catch (NumberFormatException ve) {
       w = Double.NaN;
     }
     // An empty String is considered as 0.
     if (tf.getText().length() == 0) w = 0d;
   }
   if (w == 0) {
     control
         .getDataFramePanel()
         .setValueAt(
             new EdgeWeight(0),
             netzListe.getNodes().indexOf(edge.from),
             netzListe.getNodes().indexOf(edge.to),
             edge.layer);
     netzListe.removeEdge(edge);
   } else {
     edge.setW(tf.getText());
     int n = Integer.parseInt(spinner.getModel().getValue().toString());
     edge.linewidth = n;
     control
         .getDataFramePanel()
         .setValueAt(
             new EdgeWeight(tf.getText()),
             netzListe.getNodes().indexOf(edge.from),
             netzListe.getNodes().indexOf(edge.to),
             edge.layer);
   }
   netzListe.repaint();
   dispose();
 }
 private void hire() {
   int number = (Integer) spnNumber.getModel().getValue();
   while (number > 0) {
     Person p = campaign.newPerson(choiceType.getSelectedIndex() + 1);
     p.setRankNumeric(
         campaign
             .getRanks()
             .getRankNumericFromNameAndProfession(
                 p.getProfession(), (String) choiceRanks.getSelectedItem()));
     if (!campaign.recruitPerson(p)) {
       number = 0;
     } else {
       number--;
     }
   }
   hqView.refreshPersonnelList();
   hqView.refreshPatientList();
   hqView.refreshTechsList();
   hqView.refreshDoctorsList();
   hqView.refreshReport();
   hqView.refreshFinancialTransactions();
   hqView.refreshOverview();
 }
  public void actionPerformed(ActionEvent e) {
    SpinnerNumberModel m = ((SpinnerNumberModel) daysnr.getModel());
    int days = m.getNumber().intValue();
    String location = ((JTextField) loc).getText();
    java.util.List<PointOfInterest> points = parent.textFieldPoints(location);
    if (!points.isEmpty()) {
      double latitude = points.get(0).getLatlon().latitude.getDegrees(),
          longitude = points.get(0).getLatlon().longitude.getDegrees();
      // we want only the firs two decimals
      latitude = ((double) ((long) (latitude * 100))) / 100;
      longitude = ((double) ((long) (latitude * 100))) / 100;
      String APIKey = "65ea00ff33143650113112";
      String address =
          "http://free.worldweatheronline.com/feed/weather.ashx?"
              + "key="
              + APIKey
              + "&num_of_days="
              + days
              + "&q="
              + latitude
              + ","
              + longitude
              + "&format=json&cc=no";
      try {
        URL link = new URL(address);
        URLConnection yc = link.openConnection();
        BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
        Vector<WeatherElements> elem = new Vector<WeatherElements>();
        String jsonFile = in.readLine();
        int i1 = 0, i2 = 0;
        for (int i = 0; i < days; i++) {
          i1 = jsonFile.indexOf("\"date\"", i2) + 9;
          i2 = jsonFile.indexOf("\"", i1);
          String date = jsonFile.substring(i1, i2);
          i2++;

          i1 = jsonFile.indexOf("\"precipMM\"", i2) + 13;
          i2 = jsonFile.indexOf("\"", i1);
          String rain = jsonFile.substring(i1, i2);
          i2++;

          i1 = jsonFile.indexOf("\"tempMaxC\"", i2) + 13;
          i2 = jsonFile.indexOf("\"", i1);
          String tempMax = jsonFile.substring(i1, i2);
          i2++;

          i1 = jsonFile.indexOf("\"tempMinC\"", i2) + 13;
          i2 = jsonFile.indexOf("\"", i1);
          String tempMin = jsonFile.substring(i1, i2);
          i2++;

          i1 = jsonFile.indexOf("\"value\"", i2) + 10;
          i2 = jsonFile.indexOf("\"", i1);
          String weatherStatus = jsonFile.substring(i1, i2);
          i2++;

          i1 = jsonFile.indexOf("\"value\"", i2) + 10;
          i2 = jsonFile.indexOf("\"", i1);
          String imgLink = jsonFile.substring(i1, i2);
          imgLink = imgLink.replace("\\", "");
          i2++;

          i1 = jsonFile.indexOf("\"winddirDegree\"", i2) + 18;
          i2 = jsonFile.indexOf("\"", i1);
          String windDirDegree = jsonFile.substring(i1, i2);
          i2++;

          i1 = jsonFile.indexOf("\"winddirection\"", i2) + 18;
          i2 = jsonFile.indexOf("\"", i1);
          String windDir = jsonFile.substring(i1, i2);
          i2++;

          i1 = jsonFile.indexOf("\"windspeedKmph\"", i2) + 18;
          i2 = jsonFile.indexOf("\"", i1);
          String windSpeed = jsonFile.substring(i1, i2);
          i2++;

          WeatherElements o =
              new WeatherElements(
                  date,
                  rain,
                  tempMax,
                  tempMin,
                  weatherStatus,
                  imgLink,
                  windDirDegree,
                  windDir,
                  windSpeed);
          elem.add(o);
        }

        weatherIcon.setVisible(true);
        dateout.setText(elem.elementAt(0).date);
        weatherIcon.setText("<html><img src=\"" + elem.elementAt(0).imgLink + "\" /></html>");
        weatherstatus.setText("<html><h1>" + elem.elementAt(0).weatherStatus + "</h1></html>");
        temperature.setText(
            "<html>Temperatures:<br />Temp min: "
                + elem.elementAt(0).tempMin
                + "°C<br />Temp max: "
                + elem.elementAt(0).tempMax
                + "°C</html>");
        rain.setText("Rain: " + elem.elementAt(0).rain + " mm");
        wind.setText(
            "<html>Wind: <br />"
                + "<img src=\"http://www.worldweatheronline.com"
                + "/App_Themes/Default/images/wind/"
                + elem.elementAt(0).windDir
                + ".png\" /><br />"
                + "Wind speed: "
                + elem.elementAt(0).windSpeed
                + "Km/h<br />"
                + elem.elementAt(0).windDir
                + "("
                + elem.elementAt(0).windDirDegree
                + "°)</html>");

        buttons.removeAll();
        pageNum.removeAll();
        buttons.updateUI();
        pageNum.updateUI();

        JButton previous = new JButton("Previous");
        previous.setEnabled(false);
        previous.setName("prev");

        JButton next = new JButton("Next");
        next.setName("next");

        if (days == 1) {
          next.setEnabled(false);
        }

        JTextField current = new JTextField("1", 3);
        current.setEditable(false);
        JTextField maxNum = new JTextField("" + elem.size(), 3);
        maxNum.setEditable(false);
        pageNum.add(current);
        pageNum.add(maxNum);

        previous.addActionListener(
            new WeatherButtonsActionListener(
                previous,
                next,
                weatherIcon,
                dateout,
                weatherstatus,
                temperature,
                rain,
                wind,
                elem,
                current));
        next.addActionListener(
            new WeatherButtonsActionListener(
                previous,
                next,
                weatherIcon,
                dateout,
                weatherstatus,
                temperature,
                rain,
                wind,
                elem,
                current));
        buttons.add(next);
        buttons.add(previous);
        JButton genHTML = new JButton("Generate HTML");
        genHTML.addActionListener(new genHTMLWeatherReport(parent, elem));
        buttons.add(genHTML);
      } catch (Exception ex) {
        parent.standardDialogBox("Fetching data error", "Somethnig goes wrong with the connection");
      }
    } else {
      parent.standardDialogBox("Incorrect input", "Input is incorrect!");
    }
  }
 public NullableSpinnerModel getModel() {
   return (NullableSpinnerModel) spinner.getModel();
 }
示例#19
0
 /**
  * Gets the currently selected integer value in a spinner control.
  *
  * @param aSpinner Spinner, whose chosen value is to be extracted.
  * @return The selected value of the spinner rounded to integer.
  * @throws ClassCastException If the spinner's model is not a {@link
  *     javax.swing.SpinnerNumberModel}.
  */
 public static int getSpinnerInt(JSpinner aSpinner) {
   return ((SpinnerNumberModel) aSpinner.getModel()).getNumber().intValue();
 }
示例#20
0
 private SpinnerNumberModel getSpinnerModel() {
   return (SpinnerNumberModel) spinner.getModel();
 }
示例#21
0
  /** Create the dialog. */
  public SettingsDialog() {
    setBounds(100, 100, 400, 450);
    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(0, 0, 0, 0));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(new BorderLayout(0, 0));
    {
      JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
      contentPanel.add(tabbedPane, BorderLayout.CENTER);
      {
        generalTab = new JPanel();
        tabbedPane.addTab("General", null, generalTab, "General settings.");
        tabbedPane.setEnabledAt(0, true);

        JLabel lblLauncherFilename = new JLabel("Launcher Filename:");
        launcherFileTextField = new JTextField(AppSettings.getLauncherFilename());
        launcherFileTextField.setColumns(10);
        launcherFileTextField.addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                AppSettings.setLauncherFilename(launcherFileTextField.getText());
              }
            });

        JLabel lblConsoleSettings = new JLabel("Console Settings:");

        chckbxShowConsole = new JCheckBox("Show console");
        chckbxShowConsole.getModel().setSelected(AppSettings.getShowConsole());
        chckbxShowConsole
            .getModel()
            .addActionListener(
                new ActionListener() {
                  @Override
                  public void actionPerformed(ActionEvent e) {
                    AppSettings.setShowConsole(chckbxShowConsole.getModel().isSelected());
                  }
                });

        chckbxAutoCloseConsole = new JCheckBox("Close console when instance exits.");
        chckbxAutoCloseConsole.getModel().setSelected(AppSettings.getAutoCloseConsole());
        chckbxAutoCloseConsole
            .getModel()
            .addActionListener(
                new ActionListener() {
                  @Override
                  public void actionPerformed(ActionEvent e) {
                    AppSettings.setAutoCloseConsole(chckbxAutoCloseConsole.getModel().isSelected());
                  }
                });

        chckbxAutoUpdate = new JCheckBox("Automatically check for updates when MultiMC starts");
        chckbxAutoUpdate.getModel().setSelected(AppSettings.getAutoUpdate());
        chckbxAutoUpdate
            .getModel()
            .addActionListener(
                new ActionListener() {
                  @Override
                  public void actionPerformed(ActionEvent e) {
                    AppSettings.setCheckUpdates(chckbxAutoUpdate.getModel().isSelected());
                  }
                });

        GroupLayout gl_generalTab = new GroupLayout(generalTab);
        gl_generalTab.setHorizontalGroup(
            gl_generalTab
                .createParallelGroup(Alignment.LEADING)
                .addGroup(
                    gl_generalTab
                        .createSequentialGroup()
                        .addContainerGap()
                        .addGroup(
                            gl_generalTab
                                .createParallelGroup(Alignment.LEADING)
                                .addGroup(
                                    gl_generalTab
                                        .createSequentialGroup()
                                        .addComponent(lblLauncherFilename)
                                        .addPreferredGap(ComponentPlacement.RELATED)
                                        .addComponent(
                                            launcherFileTextField,
                                            GroupLayout.DEFAULT_SIZE,
                                            262,
                                            Short.MAX_VALUE))
                                .addGroup(
                                    gl_generalTab
                                        .createSequentialGroup()
                                        .addGap(6)
                                        .addGroup(
                                            gl_generalTab
                                                .createParallelGroup(Alignment.LEADING)
                                                .addComponent(chckbxAutoCloseConsole)
                                                .addComponent(chckbxShowConsole)))
                                .addComponent(chckbxAutoUpdate)
                                .addComponent(lblConsoleSettings))
                        .addContainerGap()));
        gl_generalTab.setVerticalGroup(
            gl_generalTab
                .createParallelGroup(Alignment.LEADING)
                .addGroup(
                    gl_generalTab
                        .createSequentialGroup()
                        .addContainerGap()
                        .addGroup(
                            gl_generalTab
                                .createParallelGroup(Alignment.BASELINE)
                                .addComponent(lblLauncherFilename)
                                .addComponent(
                                    launcherFileTextField,
                                    GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE))
                        .addGap(18)
                        .addComponent(lblConsoleSettings)
                        .addPreferredGap(ComponentPlacement.RELATED)
                        .addComponent(chckbxShowConsole)
                        .addPreferredGap(ComponentPlacement.RELATED)
                        .addComponent(chckbxAutoCloseConsole)
                        .addGap(18)
                        .addComponent(chckbxAutoUpdate)
                        .addContainerGap(198, Short.MAX_VALUE)));
        generalTab.setLayout(gl_generalTab);
      }
      {
        advancedTab = new JPanel();
        tabbedPane.addTab(
            "Advanced", null, advancedTab, "Advanced settings such as memory allocations.");

        initialMemorySpinner = new JSpinner();
        initialMemorySpinner.setModel(
            new SpinnerNumberModel(
                AppSettings.getInitialMemAlloc(), new Integer(512), null, new Integer(512)));
        initialMemorySpinner
            .getModel()
            .addChangeListener(
                new ChangeListener() {
                  @Override
                  public void stateChanged(ChangeEvent arg0) {
                    AppSettings.setInitialMemAlloc(
                        (Integer) initialMemorySpinner.getModel().getValue());
                  }
                });

        JLabel lblInitialMemoryAllocation = new JLabel("Initial Memory Allocation (MB): ");

        maxMemorySpinner = new JSpinner();
        maxMemorySpinner.setModel(
            new SpinnerNumberModel(
                AppSettings.getMaxMemAlloc(), new Integer(1024), null, new Integer(512)));
        maxMemorySpinner
            .getModel()
            .addChangeListener(
                new ChangeListener() {
                  @Override
                  public void stateChanged(ChangeEvent e) {
                    AppSettings.setMaxMemAlloc((Integer) maxMemorySpinner.getModel().getValue());
                  }
                });

        JLabel labelMaxMemAlloc = new JLabel("Maximum Memory Allocation (MB): ");
        GroupLayout gl_advancedTab = new GroupLayout(advancedTab);
        gl_advancedTab.setHorizontalGroup(
            gl_advancedTab
                .createParallelGroup(Alignment.LEADING)
                .addGroup(
                    gl_advancedTab
                        .createSequentialGroup()
                        .addContainerGap()
                        .addGroup(
                            gl_advancedTab
                                .createParallelGroup(Alignment.LEADING)
                                .addComponent(labelMaxMemAlloc)
                                .addComponent(lblInitialMemoryAllocation))
                        .addPreferredGap(ComponentPlacement.RELATED)
                        .addGroup(
                            gl_advancedTab
                                .createParallelGroup(Alignment.LEADING, false)
                                .addComponent(maxMemorySpinner)
                                .addComponent(initialMemorySpinner))
                        .addGap(144)));
        gl_advancedTab.setVerticalGroup(
            gl_advancedTab
                .createParallelGroup(Alignment.LEADING)
                .addGroup(
                    gl_advancedTab
                        .createSequentialGroup()
                        .addContainerGap()
                        .addGroup(
                            gl_advancedTab
                                .createParallelGroup(Alignment.BASELINE)
                                .addComponent(lblInitialMemoryAllocation)
                                .addComponent(
                                    initialMemorySpinner,
                                    GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(ComponentPlacement.RELATED)
                        .addGroup(
                            gl_advancedTab
                                .createParallelGroup(Alignment.BASELINE)
                                .addComponent(labelMaxMemAlloc)
                                .addComponent(
                                    maxMemorySpinner,
                                    GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE))
                        .addContainerGap(276, Short.MAX_VALUE)));
        advancedTab.setLayout(gl_advancedTab);
      }
    }
    {
      JPanel buttonPane = new JPanel();
      buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
      getContentPane().add(buttonPane, BorderLayout.SOUTH);
      {
        JButton okButton = new JButton("Close");
        okButton.addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                AppSettings.setLauncherFilename(launcherFileTextField.getText());
                setVisible(false);
              }
            });
        okButton.setMnemonic('C');
        okButton.setActionCommand("OK");
        buttonPane.add(okButton);
        getRootPane().setDefaultButton(okButton);
      }
    }
  }
  public void updateComponentsFromAttribs() {
    if (attribs.containsKey("width")) // $NON-NLS-1$
    {
      widthCB.setSelected(true);
      String w = attribs.get("width").toString(); // $NON-NLS-1$
      if (w.endsWith("%")) // $NON-NLS-1$
      w = w.substring(0, w.length() - 1);
      else widthCombo.setSelectedIndex(1);
      widthField.setEnabled(true);

      try {
        widthField.getModel().setValue(new Integer(w));
      } catch (Exception ex) {
        ex.printStackTrace();
      }
    } else {
      widthCB.setSelected(false);
      widthField.setEnabled(false);
      widthCombo.setEnabled(false);
    }

    if (attribs.containsKey("align")) // $NON-NLS-1$
    {
      alignCB.setSelected(true);
      alignCombo.setEnabled(true);
      alignCombo.setSelectedItem(attribs.get("align")); // $NON-NLS-1$
    } else {
      alignCB.setSelected(false);
      alignCombo.setEnabled(false);
    }

    if (attribs.containsKey("border")) // $NON-NLS-1$
    {
      borderCB.setSelected(true);
      borderField.setEnabled(true);
      try {
        borderField
            .getModel()
            .setValue(new Integer(attribs.get("border").toString())); // $NON-NLS-1$
      } catch (Exception ex) {
        ex.printStackTrace();
      }
    } else {
      borderCB.setSelected(false);
      borderField.setEnabled(false);
    }

    if (attribs.containsKey("cellpadding")) // $NON-NLS-1$
    {
      cellPaddingCB.setSelected(true);
      cellPaddingField.setEnabled(true);
      try {
        cellPaddingField
            .getModel()
            .setValue(new Integer(attribs.get("cellpadding").toString())); // $NON-NLS-1$
      } catch (Exception ex) {
        ex.printStackTrace();
      }
    } else {
      cellPaddingCB.setSelected(false);
      cellPaddingField.setEnabled(false);
    }

    if (attribs.containsKey("cellspacing")) // $NON-NLS-1$
    {
      cellSpacingCB.setSelected(true);
      cellSpacingField.setEnabled(true);
      try {
        cellSpacingField
            .getModel()
            .setValue(new Integer(attribs.get("cellspacing").toString())); // $NON-NLS-1$
      } catch (Exception ex) {
        ex.printStackTrace();
      }
    } else {
      cellSpacingCB.setSelected(false);
      cellSpacingField.setEnabled(false);
    }

    if (attribs.containsKey("bgcolor")) // $NON-NLS-1$
    {
      bgPanel.setSelected(true);
      bgPanel.setColor(attribs.get("bgcolor").toString()); // $NON-NLS-1$
    } else {
      bgPanel.setSelected(false);
    }
  }
示例#23
0
 @Override
 public void stateChanged(ChangeEvent arg0) {
   ExhibitInfo e = getCurrentExhibit();
   if (arg0.getSource().equals(exhibitXCoordField.getModel())) {
     int val = Integer.parseInt(exhibitXCoordField.getModel().getValue().toString());
     e.setCoords(val, e.getY());
     if (e.origXCoord != e.getX()) {
       peer.makeChange();
     }
   } else if (arg0.getSource().equals(exhibitYCoordField.getModel())) {
     int val = Integer.parseInt(exhibitYCoordField.getModel().getValue().toString());
     e.setCoords(e.getX(), val);
     if (e.origYCoord != e.getY()) {
       peer.makeChange();
     }
   } else if (arg0.getSource().equals(aliasXCoordField.getModel())) {
     int val = Integer.parseInt(aliasXCoordField.getModel().getValue().toString());
     int index = exhibitAliasesList.getSelectedIndex();
     Alias alias = e.getAliases()[index];
     if (alias.xPos != val) {
       e.addAlias(alias.name, val, alias.yPos, alias.tag);
       peer.makeChange();
     }
   } else if (arg0.getSource().equals(aliasYCoordField.getModel())) {
     int val = Integer.parseInt(aliasYCoordField.getModel().getValue().toString());
     int index = exhibitAliasesList.getSelectedIndex();
     Alias alias = e.getAliases()[index];
     if (alias.yPos != val) {
       e.addAlias(alias.name, alias.xPos, val, alias.tag);
       peer.makeChange();
     }
   } else if (arg0.getSource().equals(groupXCoordField.getModel())) {
     int val = Integer.parseInt(groupXCoordField.getModel().getValue().toString());
     String name = groupNameList.getSelectedValue().toString();
     ExhibitGroup group = peer.getLoader().getGroup(name);
     if (val != group.xPos) {
       peer.getLoader().addGroup(name, group.exhibits, val, group.yPos);
       peer.makeChange();
     }
   } else if (arg0.getSource().equals(groupYCoordField.getModel())) {
     int val = Integer.parseInt(groupYCoordField.getModel().getValue().toString());
     String name = groupNameList.getSelectedValue().toString();
     ExhibitGroup group = peer.getLoader().getGroup(name);
     if (val != group.yPos) {
       peer.getLoader().addGroup(name, group.exhibits, group.xPos, val);
       peer.makeChange();
     }
   } else if (arg0.getSource().equals(eventStart.getModel())) {
     Event event = peer.getLoader().getEvents().get(eventsList.getSelectedIndex());
     event.setStartDay((Date) eventStart.getModel().getValue());
     peer.makeChange();
   } else if (arg0.getSource().equals(eventEnd.getModel())) {
     Event event = peer.getLoader().getEvents().get(eventsList.getSelectedIndex());
     event.setEndDay((Date) eventEnd.getModel().getValue());
     peer.makeChange();
   }
 }
示例#24
0
  public void actionPerformed(ActionEvent e) {

    if (e.getSource() == remoteAppletPath) {//apparently no events are fired to reach this, maybe "enter" does it
      String path = remoteAppletPath.getText();
      WebExport.setAppletPath(path, true);
      return;
    }

    if (e.getSource() == localAppletPath) {//apparently no events are fired to reach this, maybe "enter" does it
      String path = localAppletPath.getText();
      WebExport.setAppletPath(path, false);
      return;
    }

    //Handle open button action.
    if (e.getSource() == addInstanceButton) {
      //make dialog to get name for instance
      //create an instance with this name.  Each instance is just a container for a string with the Jmol state
      //which contains the full information on the file that is loaded and manipulations done.
      String label = (instanceList.getSelectedIndices().length != 1 ? ""
          : getInstanceName(-1));
      String name = JOptionPane.showInputDialog(
          GT._("Give the occurrence of Jmol a name:"), label);
      if (name == null)
        return;
      //need to get the script...
      String script = viewer.getStateInfo();
      if (script == null) {
        LogPanel.log("Error trying to get Jmol State within pop_in_Jmol.");
      }
      DefaultListModel listModel = (DefaultListModel) instanceList.getModel();
      int width = 300;
      int height = 300;
      if (appletSizeSpinnerH != null) {
        width = ((SpinnerNumberModel) (appletSizeSpinnerW.getModel()))
            .getNumber().intValue();
        height = ((SpinnerNumberModel) (appletSizeSpinnerH.getModel()))
            .getNumber().intValue();
      }
      JmolInstance instance = new JmolInstance(viewer, name, script, width, height);
      if (instance == null) {
        LogPanel
            .log(GT._("Error creating new instance containing script(s) and image."));
      }

      int i;
      for (i = instanceList.getModel().getSize(); --i >= 0;)
        if (getInstanceName(i).equals(instance.name))
          break;
      if (i < 0) {
        i = listModel.getSize();
        listModel.addElement(instance);
        LogPanel.log(GT._("added Instance {0}", instance.name));
      } else {
        listModel.setElementAt(instance, i);
        LogPanel.log(GT._("updated Instance {0}", instance.name));
      }
      instanceList.setSelectedIndex(i);
      syncLists();
      return;
    }

    if (e.getSource() == deleteInstanceButton) {
      DefaultListModel listModel = (DefaultListModel) instanceList.getModel();
      //find out which are selected and remove them.
      int[] todelete = instanceList.getSelectedIndices();
      int nDeleted = 0;
      for (int i = 0; i < todelete.length; i++){
        JmolInstance instance = (JmolInstance) listModel.get(todelete[i]);
        try {
          instance.delete();
        } catch (IOException err) {
          LogPanel.log(err.getMessage());
        }
        listModel.remove(todelete[i] - nDeleted++);
      }
      syncLists();
      return;
    }

    if (e.getSource() == showInstanceButton) {
      DefaultListModel listModel = (DefaultListModel) instanceList.getModel();
      //find out which are selected and remove them.
      int[] list = instanceList.getSelectedIndices();
      if (list.length != 1)
        return;
      JmolInstance instance = (JmolInstance) listModel.get(list[0]);
      viewer.evalStringQuiet(")" + instance.script); //leading paren disabled history
      return;
    }

    if (e.getSource() == saveButton) {
      fc.setDialogTitle(GT._("Select a directory to create or an HTML file to save"));
      int returnVal = fc.showSaveDialog(this);
      if (returnVal != JFileChooser.APPROVE_OPTION)
        return;
      File file = fc.getSelectedFile();
      boolean retVal = true;
      try {
        String path = remoteAppletPath.getText();
        WebExport.setAppletPath(path, true);
        path = localAppletPath.getText();
        WebExport.setAppletPath(path, false);
        String authorName = pageAuthorName.getText();
        WebExport.setWebPageAuthor(authorName);
        retVal = fileWriter(file, instanceList);
      } catch (IOException IOe) {
        LogPanel.log(IOe.getMessage());
      }
      if (!retVal) {
        LogPanel.log(GT._("Call to FileWriter unsuccessful."));
      }
    }
    if (e.getSource() == helpButton){
      HelpDialog webExportHelp = new HelpDialog(WebExport.getFrame(), 
          WebExport.getHtmlResource(this, panelName + "_instructions"));
      webExportHelp.setVisible(true);
      webExportHelp.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    }
  }
示例#25
0
 /** @return lag time between two checks */
 public int getLag() {
   return (Integer) (lag.getModel().getValue());
 }
示例#26
0
  public void init() {
    exhibitNameList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    exhibitNameList.setModel(exhibitNameModel);
    exhibitNameList.addListSelectionListener(
        new ListSelectionListener() {
          @Override
          public void valueChanged(ListSelectionEvent arg0) {
            selectExhibit();
          }
        });

    contentList.setModel(contentListModel);
    contentList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    contentList.addListSelectionListener(
        new ListSelectionListener() {
          @Override
          public void valueChanged(ListSelectionEvent arg0) {
            selectContent();
          }
        });

    groupExhibitsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    groupExhibitsList.setModel(groupExhibitsModel);

    exhibitAliasesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    exhibitAliasesList.setModel(exhibitAliasesModel);
    exhibitAliasesList.addListSelectionListener(
        new ListSelectionListener() {
          @Override
          public void valueChanged(ListSelectionEvent arg0) {
            selectAlias();
          }
        });

    groupNameList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    groupNameList.setModel(groupListModel);
    groupNameList.addListSelectionListener(
        new ListSelectionListener() {
          @Override
          public void valueChanged(ListSelectionEvent arg0) {
            selectGroup();
          }
        });

    eventsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    eventsList.setModel(eventsListModel);
    eventsList.addListSelectionListener(
        new ListSelectionListener() {
          @Override
          public void valueChanged(ListSelectionEvent arg0) {
            Event e = eventsListModel.getEvent(eventsList.getSelectedIndex());
            eventDescription.setText(e.getDescription());
            eventName.setText(e.getTitle());
            eventStart.getModel().setValue(e.getStartDay());
            eventEnd.getModel().setValue(e.getEndDay());
            eventPhotoDropdown.setSelectedItem(e.getImage());
          }
        });

    exhibitNextDropdown.setModel(new ExhibitDropdownModel());
    exhibitPreviousDropdown.setModel(new ExhibitDropdownModel());

    htmlContentViewer.setEditable(false);
    htmlContentViewer.setEditorKit(htmlKit);
    Document doc = htmlKit.createDefaultDocument();
    htmlContentViewer.setDocument(doc);

    eventName
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              private void change() {
                Event e = peer.getLoader().getEvents().get(eventsList.getSelectedIndex());
                e.setTitle(eventName.getText());
                peer.makeChange();
                eventsListModel.notifyChange();
              }

              @Override
              public void changedUpdate(DocumentEvent arg0) {
                change();
              }

              @Override
              public void insertUpdate(DocumentEvent arg0) {
                change();
              }

              @Override
              public void removeUpdate(DocumentEvent arg0) {
                change();
              }
            });

    eventDescription.setLineWrap(true);
    eventDescription.setWrapStyleWord(true);
    eventDescription
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              private void change() {
                Event e = peer.getLoader().getEvents().get(eventsList.getSelectedIndex());
                e.setDescription(eventDescription.getText());
                peer.makeChange();
              }

              @Override
              public void changedUpdate(DocumentEvent arg0) {
                change();
              }

              @Override
              public void insertUpdate(DocumentEvent arg0) {
                change();
              }

              @Override
              public void removeUpdate(DocumentEvent arg0) {
                change();
              }
            });

    photoCaption.setBorder(paddedLine);
    photoCaption.setLineWrap(true);
    photoCaption.setWrapStyleWord(true);
    photoCaption
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              private void change() {
                getCurrentExhibit()
                    .getPhotos()[exhibitPhotosList.getSelectedIndex()]
                    .setCaption(photoCaption.getText());
                peer.makeChange();
              }

              @Override
              public void changedUpdate(DocumentEvent arg0) {
                change();
              }

              @Override
              public void insertUpdate(DocumentEvent arg0) {
                change();
              }

              @Override
              public void removeUpdate(DocumentEvent arg0) {
                change();
              }
            });

    exhibitNextDropdown.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            setNext();
          }
        });

    exhibitPreviousDropdown.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            setPrevious();
          }
        });

    addGroupExhibitButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent a) {
            addGroupExhibit();
          }
        });

    removeGroupExhibitButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            removeGroupExhibit();
          }
        });

    addGroupButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            addGroup();
          }
        });

    editFileButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent a) {
            editFile();
          }
        });

    viewFileButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent a) {
            viewFile();
          }
        });

    removeGroupButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            removeGroup();
          }
        });

    newFileButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            peer.addFile();
            modifiedFilesListModel.notifyChange();
          }
        });

    newExhibitButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            addExhibit();
          }
        });

    removeExhibitButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            removeExhibit();
          }
        });

    newTagButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            addContent();
          }
        });

    removeTagButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            removeTag();
          }
        });

    newImageButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            addImage();
          }
        });

    addEventButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            Event e = new Event();
            e.setTitle("New Event");
            e.setStartDay(new Date());
            peer.getLoader().getEvents().add(e);
            peer.getLoader().getEvents();
            eventsListModel.notifyChange();
            peer.makeChange();
            eventsList.setSelectedIndex(0);
          }
        });

    removeEventButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            peer.getLoader().getEvents().remove(eventsList.getSelectedIndex());
            peer.getLoader().getEvents();
            eventsListModel.notifyChange();
            peer.makeChange();
          }
        });

    exhibitXSpinnerModel.addChangeListener(this);
    exhibitYSpinnerModel.addChangeListener(this);

    aliasXSpinnerModel.addChangeListener(this);
    aliasYSpinnerModel.addChangeListener(this);

    groupXSpinnerModel.addChangeListener(this);
    groupYSpinnerModel.addChangeListener(this);

    eventStart.getModel().addChangeListener(this);
    eventEnd.getModel().addChangeListener(this);

    eventPhotoDropdown.setEditable(false);
    eventPhotoDropdown.setModel(new PhotoDropdownModel());
    eventPhotoDropdown.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            Event e = peer.getLoader().getEvents().get(eventsList.getSelectedIndex());
            e.setImage(eventPhotoDropdown.getSelectedItem().toString());
          }
        });

    newContentDropdown.setEditable(false);
    newContentDropdown.setModel(new ContentDropdownModel());
    newContentDropdown.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            ExhibitInfo e = getCurrentExhibit();
            String currentTag = (String) contentList.getSelectedValue();
            String content = (String) newContentDropdown.getSelectedItem();
            e.setContent(currentTag, content);
            loadHTMLContent(content);
            if (false == e.getContent(currentTag).equals(e.getOrigContents(currentTag))) {
              peer.makeChange();
            }
          }
        });

    exhibitPhotosList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    exhibitPhotosList.setModel(exhibitPhotosModel);
    exhibitPhotosList.addListSelectionListener(
        new ListSelectionListener() {
          @Override
          public void valueChanged(ListSelectionEvent arg0) {
            selectPhoto();
          }
        });

    exhibitContentLabel.setBorder(paddedLine);

    modifiedFilesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    modifiedFilesList.setModel(modifiedFilesListModel);

    originalFilesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    originalFilesList.setModel(originalFilesListModel);

    modifiedFilesList.setSelectionInterval(0, 0);
    exhibitNameList.setSelectionInterval(0, 0);
    contentList.setSelectionInterval(0, 0);
    exhibitPhotosList.setSelectionInterval(0, 0);
    groupNameList.setSelectionInterval(0, 0);
    exhibitAliasesList.setSelectionInterval(0, 0);
    eventsList.setSelectionInterval(0, 0);

    JPanel contentDropdownPanel = new JPanel(new GridLayout(4, 1, 2, 2));
    contentDropdownPanel.add(new JLabel("Original content:"));
    contentDropdownPanel.add(exhibitContentLabel);
    contentDropdownPanel.add(new JLabel("Current content:"));
    contentDropdownPanel.add(newContentDropdown);

    JPanel contentButtonPanel = new JPanel(new GridLayout(3, 1, 2, 2));
    contentButtonPanel.add(newTagButton);
    contentButtonPanel.add(removeTagButton);
    contentButtonPanel.add(renameTagButton);

    for (Component c : contentButtonPanel.getComponents()) {
      JButton b = (JButton) c;
      b.setBorder(BorderFactory.createCompoundBorder(b.getBorder(), mediumPaddedBorder));
    }

    addEventButton.setBorder(largePaddedBorder);
    removeEventButton.setBorder(largePaddedBorder);

    JPanel contentListPanel = new JPanel(new BorderLayout());
    contentListPanel.add(new JScrollPane(contentList), BorderLayout.CENTER);
    contentListPanel.add(contentButtonPanel, BorderLayout.EAST);

    JPanel contentControlPanel = new JPanel(new GridLayout(2, 1, 2, 2));
    contentControlPanel.add(contentListPanel);
    contentControlPanel.add(contentDropdownPanel);

    contentPanel.add(new JScrollPane(htmlContentViewer));
    contentPanel.add(contentControlPanel);
    contentPanel.setBorder(mediumPaddedBorder);

    exhibitDataPanel.add(exhibitXCoordOrig);
    exhibitDataPanel.add(exhibitXCoordField);
    exhibitDataPanel.add(exhibitPreviousOrig);
    exhibitDataPanel.add(exhibitPreviousDropdown);
    exhibitDataPanel.add(exhibitYCoordOrig);
    exhibitDataPanel.add(exhibitYCoordField);
    exhibitDataPanel.add(exhibitNextOrig);
    exhibitDataPanel.add(exhibitNextDropdown);

    JPanel exhibitButtonsPanel = new JPanel(new GridLayout(3, 1, 2, 2));
    exhibitButtonsPanel.add(newExhibitButton);
    exhibitButtonsPanel.add(removeExhibitButton);
    exhibitButtonsPanel.add(renameExhibitButton);

    for (Component c : exhibitButtonsPanel.getComponents()) {
      JButton b = (JButton) c;
      b.setBorder(BorderFactory.createCompoundBorder(b.getBorder(), mediumPaddedBorder));
    }

    JPanel listPanelTop = new JPanel(new BorderLayout());
    listPanelTop.add(new JLabel("Exhibits:"), BorderLayout.NORTH);
    listPanelTop.add(new JScrollPane(exhibitNameList), BorderLayout.CENTER);
    listPanelTop.add(exhibitButtonsPanel, BorderLayout.EAST);

    JPanel photoButtonPanel = new JPanel(new GridLayout(1, 2, 2, 2));
    photoButtonPanel.add(newImageButton);
    photoButtonPanel.add(removeImageButton);

    JPanel photoDataPanel = new JPanel(new GridLayout(2, 1, 2, 2));
    photoDataPanel.add(new JScrollPane(exhibitPhotosList));
    photoDataPanel.add(photoCaption);

    JPanel photoPanelRight = new JPanel(new BorderLayout());
    photoPanelRight.add(new JLabel("Exhibit Photos:"), BorderLayout.NORTH);
    photoPanelRight.add(photoDataPanel, BorderLayout.CENTER);
    photoPanelRight.add(photoButtonPanel, BorderLayout.SOUTH);

    JPanel aliasPanel = new JPanel(new GridLayout(1, 3, 2, 2));
    aliasDataPanel.add(new JLabel("Alias X Coordinate"));
    aliasDataPanel.add(aliasXCoordField);
    aliasDataPanel.add(new JLabel("Alias Y Coordinate"));
    aliasDataPanel.add(aliasYCoordField);

    JPanel aliasDataLabeled = new JPanel(new BorderLayout());
    aliasDataLabeled.add(new JLabel("Exhibit Aliases:"), BorderLayout.NORTH);
    aliasDataLabeled.add(new JScrollPane(exhibitAliasesList), BorderLayout.CENTER);

    JPanel aliasButtonsPanel = new JPanel(new GridLayout(2, 1, 2, 2));
    aliasButtonsPanel.add(addAliasButton);
    aliasButtonsPanel.add(removeAliasButton);

    aliasPanel.add(aliasDataLabeled);
    aliasPanel.add(aliasDataPanel);
    aliasPanel.add(aliasButtonsPanel);
    aliasPanel.setBorder(paddedLine);

    JPanel groupXCoordPanel = new JPanel(new GridLayout(1, 2, 2, 2));
    groupXCoordPanel.add(new JLabel("Group X Coordinate"));
    groupXCoordPanel.add(groupXCoordField);

    JPanel groupYCoordPanel = new JPanel(new GridLayout(1, 2, 2, 2));
    groupYCoordPanel.add(new JLabel("Group Y Coordinate"));
    groupYCoordPanel.add(groupYCoordField);

    JPanel groupDataButtonsPanel = new JPanel(new GridLayout(4, 1, 2, 2));
    groupDataButtonsPanel.add(addGroupButton);
    groupDataButtonsPanel.add(removeGroupButton);
    groupDataButtonsPanel.add(addGroupExhibitButton);
    groupDataButtonsPanel.add(removeGroupExhibitButton);

    JPanel groupLocationPanel = new JPanel(new GridLayout(2, 1, 2, 2));
    groupLocationPanel.add(groupXCoordPanel);
    groupLocationPanel.add(groupYCoordPanel);
    groupLocationPanel.setBorder(paddedLine);

    JPanel groupDataPanel = new JPanel(new GridLayout(1, 2, 2, 2));
    groupDataPanel.add(groupLocationPanel);
    groupDataPanel.add(groupDataButtonsPanel);

    JPanel combinedDataPanel = new JPanel(new GridLayout(2, 1, 2, 2));
    combinedDataPanel.add(exhibitDataPanel);
    combinedDataPanel.add(aliasPanel);
    combinedDataPanel.setBorder(mediumPaddedBorder);

    photosPanel.add(new JScrollPane(exhibitPhotosImage));
    photosPanel.add(photoPanelRight);
    photosPanel.setBorder(mediumPaddedBorder);

    exhibitTabs.add("Exhibit Content", contentPanel);
    exhibitTabs.add("Exhibit Photos", photosPanel);
    exhibitTabs.add("Exhibit Properties", combinedDataPanel);

    mainPanel.add(listPanelTop, BorderLayout.NORTH);
    mainPanel.add(exhibitTabs, BorderLayout.CENTER);

    mainPanel.setBorder(mediumPaddedBorder);

    groupListPanel.add(new JScrollPane(groupNameList));
    groupListPanel.add(new JScrollPane(groupExhibitsList));

    JPanel fileButtonPanel = new JPanel(new GridLayout(2, 1, 2, 2));
    fileButtonPanel.add(newFileButton);
    fileButtonPanel.add(editFileButton);

    for (Component c : fileButtonPanel.getComponents()) {
      JButton b = (JButton) c;
      b.setBorder(BorderFactory.createCompoundBorder(b.getBorder(), largePaddedBorder));
    }

    JPanel originalListPanel = new JPanel(new BorderLayout());
    originalListPanel.add(new JLabel("Original Files:"), BorderLayout.NORTH);
    originalListPanel.add(new JScrollPane(originalFilesList), BorderLayout.CENTER);
    originalListPanel.add(viewFileButton, BorderLayout.EAST);

    JPanel modifiedListPanel = new JPanel(new BorderLayout());
    modifiedListPanel.add(new JLabel("Added Files:"), BorderLayout.NORTH);
    modifiedListPanel.add(new JScrollPane(modifiedFilesList), BorderLayout.CENTER);
    modifiedListPanel.add(fileButtonPanel, BorderLayout.EAST);

    JPanel eventImagePanel = new JPanel(new BorderLayout());
    eventImagePanel.add(new JLabel("Event Image: "), BorderLayout.WEST);
    eventImagePanel.add(eventPhotoDropdown, BorderLayout.CENTER);

    JPanel eventTimePanel = new JPanel(new GridLayout(1, 4, 2, 2));
    eventTimePanel.add(new JLabel("Start Date:"));
    eventTimePanel.add(eventStart);
    eventTimePanel.add(new JLabel("End Date:"));
    eventTimePanel.add(eventEnd);

    JPanel eventsSmallDataPanel = new JPanel(new GridLayout(2, 1, 2, 2));
    eventsSmallDataPanel.add(eventTimePanel);
    eventsSmallDataPanel.add(eventImagePanel);

    JPanel eventsDataPanel = new JPanel(new BorderLayout());
    eventsDataPanel.add(eventName, BorderLayout.NORTH);
    eventsDataPanel.add(new JScrollPane(eventDescription), BorderLayout.CENTER);
    eventsDataPanel.add(eventsSmallDataPanel, BorderLayout.SOUTH);

    JPanel eventButtonsPanel = new JPanel(new GridLayout(1, 2, 2, 2));
    eventButtonsPanel.add(addEventButton);
    eventButtonsPanel.add(removeEventButton);

    JPanel eventsListPanel = new JPanel(new BorderLayout());
    eventsListPanel.add(new JScrollPane(eventsList), BorderLayout.CENTER);
    eventsListPanel.add(eventButtonsPanel, BorderLayout.SOUTH);

    JPanel eventsPanel = new JPanel(new GridLayout(2, 1, 2, 2));
    eventsPanel.add(eventsListPanel);
    eventsPanel.add(eventsDataPanel);

    filePanel.add(originalListPanel);
    filePanel.add(modifiedListPanel);

    groupPanel.add(groupListPanel);
    groupPanel.add(groupDataPanel);
    groupPanel.setBorder(mediumPaddedBorder);

    tabbedPane.setBorder(thinPaddedBorder);

    tabbedPane.addTab("Exhibits", mainPanel);
    tabbedPane.addTab("Groups", groupPanel);
    tabbedPane.addTab("Map", mapPanel);
    tabbedPane.addTab("Files", filePanel);
    tabbedPane.addTab("Events", eventsPanel);
  }
 public void setStepSize(final Number step) {
   SpinnerNumberModel model = (SpinnerNumberModel) field.getModel();
   model.setStepSize(step);
 }
 public Number getStepSize() {
   SpinnerNumberModel model = (SpinnerNumberModel) field.getModel();
   return model.getStepSize();
 }
示例#29
0
  private JComponent getButtonPanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

    choiceType = new JComboBox<PersonTypeItem>();
    choiceType.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) choiceType.getPreferredSize().getHeight()));
    DefaultComboBoxModel<PersonTypeItem> personTypeModel = new DefaultComboBoxModel<>();
    personTypeModel.addElement(
        new PersonTypeItem(resourceMap.getString("primaryRole.choice.text"), null)); // $NON-NLS-1$
    for (int i = 1; i < Person.T_NUM; ++i) {
      personTypeModel.addElement(
          new PersonTypeItem(Person.getRoleDesc(i, campaign.getFaction().isClan()), i));
    }
    personTypeModel.addElement(
        new PersonTypeItem(Person.getRoleDesc(0, campaign.getFaction().isClan()), 0));
    // Add "none" for generic AsTechs
    choiceType.setModel(personTypeModel);
    choiceType.setSelectedIndex(0);
    choiceType.addActionListener(
        e -> {
          personnelFilter.setPrimaryRole(((PersonTypeItem) choiceType.getSelectedItem()).id);
          updatePersonnelTable();
        });
    panel.add(choiceType);

    choiceExp = new JComboBox<PersonTypeItem>();
    choiceExp.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) choiceType.getPreferredSize().getHeight()));
    DefaultComboBoxModel<PersonTypeItem> personExpModel = new DefaultComboBoxModel<>();
    personExpModel.addElement(
        new PersonTypeItem(resourceMap.getString("experience.choice.text"), null)); // $NON-NLS-1$
    for (int i = 0; i < 5; ++i) {
      personExpModel.addElement(new PersonTypeItem(SkillType.getExperienceLevelName(i), i));
    }
    choiceExp.setModel(personExpModel);
    choiceExp.setSelectedIndex(0);
    choiceExp.addActionListener(
        e -> {
          personnelFilter.setExpLevel(((PersonTypeItem) choiceExp.getSelectedItem()).id);
          updatePersonnelTable();
        });
    panel.add(choiceExp);

    choiceSkill = new JComboBox<String>();
    choiceSkill.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) choiceSkill.getPreferredSize().getHeight()));
    DefaultComboBoxModel<String> personSkillModel = new DefaultComboBoxModel<>();
    personSkillModel.addElement(choiceNoSkill);
    for (String skill : SkillType.getSkillList()) {
      personSkillModel.addElement(skill);
    }
    choiceSkill.setModel(personSkillModel);
    choiceSkill.setSelectedIndex(0);
    choiceSkill.addActionListener(
        e -> {
          if (choiceNoSkill.equals(choiceSkill.getSelectedItem())) {
            personnelFilter.setSkill(null);
            ((SpinnerNumberModel) skillLevel.getModel()).setMaximum(10);
            buttonSpendXP.setEnabled(false);
          } else {
            String skillName = (String) choiceSkill.getSelectedItem();
            personnelFilter.setSkill(skillName);
            int maxSkillLevel = SkillType.getType(skillName).getMaxLevel();
            int currentLevel = (Integer) skillLevel.getModel().getValue();
            ((SpinnerNumberModel) skillLevel.getModel()).setMaximum(maxSkillLevel);
            if (currentLevel > maxSkillLevel) {
              skillLevel.getModel().setValue(Integer.valueOf(maxSkillLevel));
            }
            buttonSpendXP.setEnabled(true);
          }
          updatePersonnelTable();
        });
    panel.add(choiceSkill);

    panel.add(Box.createRigidArea(new Dimension(10, 10)));
    panel.add(new JLabel(resourceMap.getString("targetSkillLevel.text"))); // $NON-NLS-1$

    skillLevel = new JSpinner(new SpinnerNumberModel(10, 0, 10, 1));
    skillLevel.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) skillLevel.getPreferredSize().getHeight()));
    skillLevel.addChangeListener(
        e -> {
          personnelFilter.setMaxSkillLevel((Integer) skillLevel.getModel().getValue());
          updatePersonnelTable();
        });
    panel.add(skillLevel);

    allowPrisoners = new JCheckBox(resourceMap.getString("allowPrisoners.text")); // $NON-NLS-1$
    allowPrisoners.setHorizontalAlignment(SwingConstants.LEFT);
    allowPrisoners.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) allowPrisoners.getPreferredSize().getHeight()));
    allowPrisoners.addChangeListener(
        e -> {
          personnelFilter.setAllowPrisoners(allowPrisoners.isSelected());
          updatePersonnelTable();
        });
    JPanel allowPrisonersPanel = new JPanel(new GridLayout(1, 1));
    allowPrisonersPanel.setAlignmentY(JComponent.LEFT_ALIGNMENT);
    allowPrisonersPanel.add(allowPrisoners);
    allowPrisonersPanel.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) allowPrisonersPanel.getPreferredSize().getHeight()));
    panel.add(allowPrisonersPanel);

    panel.add(Box.createVerticalGlue());

    matchedPersonnelLabel = new JLabel(""); // $NON-NLS-1$
    matchedPersonnelLabel.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) matchedPersonnelLabel.getPreferredSize().getHeight()));
    panel.add(matchedPersonnelLabel);

    JPanel buttons = new JPanel(new FlowLayout());
    buttons.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) buttons.getPreferredSize().getHeight()));

    buttonSpendXP = new JButton(resourceMap.getString("spendXP.text")); // $NON-NLS-1$
    buttonSpendXP.setEnabled(false);
    buttonSpendXP.addActionListener(e -> spendXP());
    buttons.add(buttonSpendXP);

    JButton button = new JButton(resourceMap.getString("close.text")); // $NON-NLS-1$
    button.addActionListener(e -> setVisible(false));
    buttons.add(button);

    panel.add(buttons);

    panel.setMaximumSize(new Dimension((int) panel.getPreferredSize().getWidth(), Short.MAX_VALUE));
    panel.setMinimumSize(new Dimension((int) panel.getPreferredSize().getWidth(), 300));

    return panel;
  }
示例#30
0
  /** performs the creation of the dialog and all its components. */
  protected void initGUI() {
    JPanel panel;
    SpinnerNumberModel model;
    JPanel panel2;

    getContentPane().setLayout(new BorderLayout());

    panel = new JPanel(new GridLayout(6, 1));
    panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    getContentPane().add(panel, BorderLayout.CENTER);

    // mean precision
    m_MeanPrecSpinner = new JSpinner();
    m_MeanPrecSpinner.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            getData();
          }
        });
    model = (SpinnerNumberModel) m_MeanPrecSpinner.getModel();
    model.setMaximum(new Integer(20));
    model.setMinimum(new Integer(0));
    m_MeanPrecLabel = new JLabel("Mean Precision");
    m_MeanPrecLabel.setDisplayedMnemonic('M');
    m_MeanPrecLabel.setLabelFor(m_MeanPrecSpinner);
    panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    panel2.add(m_MeanPrecLabel);
    panel2.add(m_MeanPrecSpinner);
    panel.add(panel2);

    // stddev precision
    m_StdDevPrecSpinner = new JSpinner();
    m_StdDevPrecSpinner.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            getData();
          }
        });
    model = (SpinnerNumberModel) m_StdDevPrecSpinner.getModel();
    model.setMaximum(new Integer(20));
    model.setMinimum(new Integer(0));
    m_StdDevPrecLabel = new JLabel("StdDev. Precision");
    m_StdDevPrecLabel.setDisplayedMnemonic('S');
    m_StdDevPrecLabel.setLabelFor(m_StdDevPrecSpinner);
    panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    panel2.add(m_StdDevPrecLabel);
    panel2.add(m_StdDevPrecSpinner);
    panel.add(panel2);

    // Format
    m_OutputFormatComboBox = new JComboBox(m_OutputFormatNames);
    m_OutputFormatComboBox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            getData();
          }
        });
    m_OutputFormatLabel = new JLabel("Output Format");
    m_OutputFormatLabel.setDisplayedMnemonic('F');
    m_OutputFormatLabel.setLabelFor(m_OutputFormatComboBox);
    panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    panel2.add(m_OutputFormatLabel);
    panel2.add(m_OutputFormatComboBox);
    panel.add(panel2);

    // Average
    m_ShowAverageCheckBox = new JCheckBox("");
    m_ShowAverageCheckBox.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            getData();
          }
        });
    m_ShowAverageLabel = new JLabel("Show Average");
    m_ShowAverageLabel.setDisplayedMnemonic('A');
    m_ShowAverageLabel.setLabelFor(m_ShowAverageCheckBox);
    panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    panel2.add(m_ShowAverageLabel);
    panel2.add(m_ShowAverageCheckBox);
    panel.add(panel2);

    // Remove filter classname
    m_RemoveFilterNameCheckBox = new JCheckBox("");
    m_RemoveFilterNameCheckBox.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            getData();
          }
        });
    m_RemoveFilterNameLabel = new JLabel("Remove filter classnames");
    m_RemoveFilterNameLabel.setDisplayedMnemonic('R');
    m_RemoveFilterNameLabel.setLabelFor(m_RemoveFilterNameCheckBox);
    panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    panel2.add(m_RemoveFilterNameLabel);
    panel2.add(m_RemoveFilterNameCheckBox);
    panel.add(panel2);

    // Advanced setup
    m_ResultMatrix = ExperimenterDefaults.getOutputFormat();
    m_ResultMatrixEditor = new GenericObjectEditor(true);
    m_ResultMatrixEditor.setClassType(ResultMatrix.class);
    m_ResultMatrixEditor.setValue(m_ResultMatrix);
    m_ResultMatrixEditor.addPropertyChangeListener(
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent e) {
            // user selected different class?
            if (!m_ResultMatrix.getClass().equals(m_ResultMatrixEditor.getValue().getClass())) {
              // if it's the preferred class, then automaticallly use the Experimenter defaults
              if (m_ResultMatrixEditor
                  .getValue()
                  .getClass()
                  .equals(ExperimenterDefaults.getOutputFormat().getClass())) {
                m_ResultMatrix = ExperimenterDefaults.getOutputFormat();
                m_ResultMatrixEditor.setValue(ExperimenterDefaults.getOutputFormat());
              } else {
                m_ResultMatrix = (ResultMatrix) m_ResultMatrixEditor.getValue();
              }
              setData();
            }
            repaint();
          }
        });
    ((GenericObjectEditor.GOEPanel) m_ResultMatrixEditor.getCustomEditor())
        .addOkListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                m_ResultMatrix = (ResultMatrix) m_ResultMatrixEditor.getValue();
                setData();
              }
            });
    m_ResultMatrixPanel = new PropertyPanel(m_ResultMatrixEditor, false);
    m_ResultMatrixLabel = new JLabel("Advanced setup");
    panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    panel2.add(m_ResultMatrixLabel);
    panel2.add(m_ResultMatrixPanel);
    panel.add(panel2);

    // Buttons
    panel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    getContentPane().add(panel, BorderLayout.SOUTH);
    m_CancelButton = new JButton("Cancel");
    m_CancelButton.setMnemonic('C');
    m_CancelButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            m_Result = CANCEL_OPTION;
            setVisible(false);
          }
        });
    m_OkButton = new JButton("OK");
    m_OkButton.setMnemonic('O');
    m_OkButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            getData();
            m_Result = APPROVE_OPTION;
            setVisible(false);
          }
        });
    panel.add(m_OkButton);
    panel.add(m_CancelButton);

    // default button
    getRootPane().setDefaultButton(m_OkButton);

    // initial layout (to get widths and heights)
    pack();

    // adjust dimensions
    m_MeanPrecLabel.setPreferredSize(
        new Dimension(m_RemoveFilterNameLabel.getWidth(), m_MeanPrecLabel.getHeight()));
    m_MeanPrecSpinner.setPreferredSize(
        new Dimension(m_MeanPrecSpinner.getWidth() * 3, m_MeanPrecSpinner.getHeight()));
    m_StdDevPrecLabel.setPreferredSize(
        new Dimension(m_RemoveFilterNameLabel.getWidth(), m_StdDevPrecLabel.getHeight()));
    m_StdDevPrecSpinner.setPreferredSize(
        new Dimension(m_StdDevPrecSpinner.getWidth() * 3, m_StdDevPrecSpinner.getHeight()));
    m_OutputFormatLabel.setPreferredSize(
        new Dimension(m_RemoveFilterNameLabel.getWidth(), m_OutputFormatLabel.getHeight()));
    m_ShowAverageLabel.setPreferredSize(
        new Dimension(m_RemoveFilterNameLabel.getWidth(), m_ShowAverageLabel.getHeight()));
    m_ResultMatrixLabel.setPreferredSize(
        new Dimension(m_RemoveFilterNameLabel.getWidth(), m_ResultMatrixLabel.getHeight()));
    m_ResultMatrixPanel.setPreferredSize(
        new Dimension(
            (int) (m_ResultMatrixPanel.getWidth() * 1.5), m_ResultMatrixPanel.getHeight()));

    // final layout
    pack();
  }