コード例 #1
2
ファイル: ClauseOrder.java プロジェクト: jdhuayta/libertya
  public void actionPerformed(ActionEvent ae) {
    if (ae.getActionCommand().equals(PUT)) {
      while (availableExpressions.getSelectedIndex() != -1) {
        String exp = (String) availableExpressions.getSelectedValue();
        setAsSelected(exp, true);
      }
    } else if (ae.getActionCommand().equals(PUSH)) {
      while (selectedExpressions.getSelectedRow() != -1) {
        String exp =
            (String) selectedExpressions.getValueAt(selectedExpressions.getSelectedRow(), 1);
        ((DefaultTableModel) selectedExpressions.getModel())
            .removeRow(selectedExpressions.getSelectedRow());
        ((DefaultListModel) availableExpressions.getModel()).addElement(exp);
      }
    } else if (ae.getActionCommand().equals(UP)) {
      int row = selectedExpressions.getSelectedRow();
      if (row < 1) return;
      ((DefaultTableModel) selectedExpressions.getModel()).moveRow(row, row, --row);
      selectedExpressions.setRowSelectionInterval(row, row);
      scrollToRow(row);
    } else if (ae.getActionCommand().equals(DOWN)) {
      int row = selectedExpressions.getSelectedRow();
      if (row == selectedExpressions.getRowCount() - 1) return;
      ((DefaultTableModel) selectedExpressions.getModel()).moveRow(row, row, ++row);
      selectedExpressions.setRowSelectionInterval(row, row);
      scrollToRow(row);
    }

    clauses.builder.syntax.refresh();
  }
コード例 #2
0
  /** Accepts button clicking */
  @Override
  public void actionPerformed(ActionEvent event) {
    // close dialog and save changes to the region
    if (event.getSource() == okButton) {
      Terrain r = new Terrain(null);
      r.setBackground((String) terrain.getSelectedItem());
      r.setName(nameField.getText());
      r.setRate((Integer) eRateSpinner.getValue());
      r.setFormations(formations);
      if (index == -1) parent.regions.add(r);
      else parent.regions.set(index, r);
      parent.regionList.setListData(parent.regions);
      parent.regionPane.setViewportView(parent.regionList);
      dispose();
    }

    // close dialog without saving changes
    if (event.getSource() == cancelButton) dispose();

    if (fList.getSelectedIndex() != -1) {
      // edit a formation
      if (event.getSource() == fEdtButton) new FormationDialog(this, fList.getSelectedIndex());
      // remove a formation
      else if (event.getSource() == fRemButton) {
        formations.remove(fList.getSelectedIndex());
        fList.setListData(formations);
        fPane.setViewportView(fList);
      }
    }
    // create a new formation
    if (event.getSource() == fAddButton) new FormationDialog(this);
  }
コード例 #3
0
ファイル: FisioFrame.java プロジェクト: pablolp/POPBL
 public void actionPerformed(ActionEvent evento) {
   Paciente nuevo = null;
   if (evento.getActionCommand().equals("Añadir")) {
     AñadePacienteFrame paciente = new AñadePacienteFrame(ventana, nuevo);
     nuevo = paciente.getPaciente();
     if (nuevo != null) modelo.addElement(nuevo);
   }
   if (evento.getActionCommand().equals("Eliminar")) {
     int indice = pacientes.getSelectedIndex();
     if (indice != FALLO) {
       int reply =
           JOptionPane.showConfirmDialog(
               null, "¿Estas seguro de eliminar al paciente?", "", JOptionPane.YES_NO_OPTION);
       if (reply == JOptionPane.YES_OPTION) modelo.remove(indice);
     }
   }
   if (evento.getActionCommand().equals("Modificar")) {
     int indice = pacientes.getSelectedIndex();
     if (indice != FALLO) {
       AñadePacienteFrame paciente = new AñadePacienteFrame(ventana, modelo.getElementAt(indice));
       if (cambios(paciente.getPaciente(), modelo.getElementAt(indice))) {
         modelo.getElementAt(indice).setPaciente(paciente.getPaciente());
         ventana.repaint();
       }
     }
   }
 }
コード例 #4
0
    /*----------------------------------------------------------------------*/
    public void actionPerformed(ActionEvent e) {
      SwingEditor.instance.setDirty(dirtyFlag);

      if (e.getSource() == add) {
        TileScript script = new FlavourText("");
        TileScriptEditor dialog =
            new TileScriptEditor(SwingEditor.instance, script, dirtyFlag, zone);
        if (dialog.getResult() != null) {
          SwingEditor.instance.setDirty(dirtyFlag);
          dataModel.add(dialog.getResult());
        }
      } else if (e.getSource() == delete) {
        int index = list.getSelectedIndex();
        if (index > -1) {
          SwingEditor.instance.setDirty(dirtyFlag);
          dataModel.remove(index);
        }
      } else if (e.getSource() == edit) {
        editListItem();
      } else if (e.getSource() == moveUp) {
        dataModel.moveUp(list.getSelectedIndex());
        list.setSelectedIndex(list.getSelectedIndex() - 1);
      } else if (e.getSource() == moveDown) {
        dataModel.moveDown(list.getSelectedIndex());
        list.setSelectedIndex(list.getSelectedIndex() + 1);
      }
    }
コード例 #5
0
  @Override
  public void actionPerformed(ActionEvent e) {
    if (e.getSource().equals(decoyStrategy_pattern)
        || e.getSource().equals(decoyStrategy_searchengine)) {
      // decoy pattern can only be edited, if decoy strategy is pattern
      decoyPattern_pattern.setEnabled(decoyStrategy_pattern.isSelected());
    } else if (e.getSource().equals(addToPreferred_button)
        && (availableScoresList.getSelectedIndex() > -1)) {
      preferredScoresModel.addElement(availableScoresList.getSelectedValue());
      availableScoresModel.remove(availableScoresList.getSelectedIndex());
    } else if (e.getSource().equals(removeFromPreferred_button)
        && (preferredScoresList.getSelectedIndex() > -1)) {
      availableScoresModel.addElement(preferredScoresList.getSelectedValue());
      preferredScoresModel.remove(preferredScoresList.getSelectedIndex());
    } else if (e.getSource().equals(calculatePSMFDR)) {
      // execute PSM level operations
      if (piaViewModel != null) {
        for (Map.Entry<String, Object> setIt : getSettings().entrySet()) {
          piaViewModel.addSetting(setIt.getKey(), setIt.getValue());
        }
        piaViewModel.executePSMOperations();
      }

      updateFDRPanel();
    }
  }
コード例 #6
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();
   }
 }
コード例 #7
0
  /** Invoked when an action occurs. */
  public void actionAdd() {
    int i = list.getSelectedIndex();

    if (i == -1) return;

    newItem =
        createNewElement(
            (String) DesignFrame.processingElements[list.getSelectedIndex()][1], cX, cY);
  }
コード例 #8
0
  private boolean ensureSelectionExists() {
    if (myList.getSelectedIndex() < 0 || myList.getSelectedIndex() >= myList.getModel().getSize()) {
      if (myList.getModel().getSize() >= 0) {
        myList.setSelectedIndex(0);
        return false;
      }
    }

    return true;
  }
コード例 #9
0
 private void addAction() {
   if (!entryField.getText().isEmpty()) {
     if (list.getSelectedIndex() >= 0) {
       model.add(list.getSelectedIndex(), entryField.getText());
     } else {
       model.addElement(entryField.getText());
     }
     entryField.setText(null);
   }
 }
コード例 #10
0
ファイル: JFontChooser.java プロジェクト: Jmdebugger/rusefi
  @Override
  public void setFont(Font font) {
    if (font == null) font = txtSample.getFont();

    fontList.setSelectedValue(font.getName(), true);
    fontList.ensureIndexIsVisible(fontList.getSelectedIndex());
    sizeList.setSelectedValue("" + font.getSize(), true);
    sizeList.ensureIndexIsVisible(sizeList.getSelectedIndex());

    cbBold.setSelected(font.isBold());
    cbItalic.setSelected(font.isItalic());
  }
コード例 #11
0
 @Override
 public void actionPerformed(ActionEvent e) {
   if (e.getSource().equals(comboAvailableFilters)) {
     RegisteredFilters selectedFilter =
         (RegisteredFilters) comboAvailableFilters.getSelectedItem();
     updateSelectedAvailableFilters(selectedFilter);
   } else if (e.getSource().equals(btnAddFilter)) {
     addToAppliedFilters();
   } else if (e.getSource().equals(btnRemoveFilter)
       && (listAppliedFilters.getSelectedIndex() > -1)) {
     modelAppliedFilters.remove(listAppliedFilters.getSelectedIndex());
   }
 }
コード例 #12
0
 private void enableOrDisableActions() {
   int idx = archetypeList.getSelectedIndex();
   if (archetypeList.getSelectedIndex() == -1) {
     deleteArchetypeAction.setEnabled(false);
     return;
   }
   if (StringUtils.equalsIgnoreCase("generic", listData.get(idx).getName())) {
     deleteArchetypeAction.setEnabled(false);
     return;
   }
   exportArchetypeAction.setEnabled(true);
   deleteArchetypeAction.setEnabled(true);
 }
コード例 #13
0
ファイル: Alcher.java プロジェクト: hellomot0123/Scripts
    private void jButton2ActionPerformed(final java.awt.event.ActionEvent evt) {
      try {
        if (jList1.getSelectedValue().toString().contains("No item in ")) {
          JOptionPane.showMessageDialog(
              null, "Please select an item.", "Error", JOptionPane.ERROR_MESSAGE);
        } else {
          jList1.getSelectedIndex();
          final int ID = inventory.getItemAt(jList1.getSelectedIndex()).getID();
          boolean afkon = false;
          if (jRadioButton1.isSelected()) {
            afkon = true;
          } else {
            afkon = false;
          }

          final int afkMin = StringintTo(jTextField1.getText());
          final int afkMax = StringintTo(jTextField2.getText());

          final Object[] options = {"High", "Low"};
          final int n =
              JOptionPane.showOptionDialog(
                  null,
                  "High or Low alch?",
                  "iPhQ's Alcher | What kind of alching?",
                  JOptionPane.YES_NO_OPTION,
                  JOptionPane.QUESTION_MESSAGE,
                  null, // do
                  // not
                  // use
                  // a
                  // custom Icon
                  options, // the titles of buttons
                  options[0]); // default button title

          boolean high = true;

          if (n == 0) {
            high = true;
          } else {
            high = false;
          }

          startScript(ID, afkon, afkMin, afkMax, high);
          setVisible(false);
        }

      } catch (final Exception e) {
        JOptionPane.showMessageDialog(
            null, "Please select an item.", "Error", JOptionPane.ERROR_MESSAGE);
      }
    }
コード例 #14
0
ファイル: ButtonPane.java プロジェクト: electrosy/codebase
  /** Switches the JList to the next record */
  private void switchToNext() {
    // if at the last record
    if (list.getSelectedIndex() + 1 > list.getModel().getSize() - 1) {
      // Then go to the begenning
      list.setSelectedIndex(0);
    } else {
      // otherwise to to the next.
      list.setSelectedIndex(list.getSelectedIndex() + 1);
    }

    // Update the contact pane
    contactdatapane.populateTextBoxesWithRecord(list.getSelectedValue().toString());
    list.ensureIndexIsVisible(list.getSelectedIndex());
  }
コード例 #15
0
  /** Updates the Rating-Lists */
  private void updateLists() {
    RatingComparator comperator = new RatingComparator();

    Vector<Rating> personalVector = new Vector<Rating>(mPlugin.getDatabase().getPersonalRatings());
    Collections.sort(personalVector, comperator);
    int index = mPersonalRatings.getSelectedIndex();
    mPersonalRatings.setListData(personalVector);
    mPersonalRatings.setSelectedIndex(index);

    Vector<Rating> overallVector = new Vector<Rating>(mPlugin.getDatabase().getServerRatings());
    Collections.sort(overallVector, comperator);
    index = mOverallRatings.getSelectedIndex();
    mOverallRatings.setListData(overallVector);
    mOverallRatings.setSelectedIndex(index);
  }
コード例 #16
0
  private void doSave() {
    ContactProps contact = new ContactProps();
    for (AccessInterface infoField : infoFields)
      contact.setProperty(infoField.getContactKey(), infoField.getContent());
    String newname = contact.getProperty(ContactProps.NAME);
    if (newname == null || newname.trim().equals("")) {
      AddrBookProps.save(addrbook);
      return;
    }
    if (contactList.getSelectedIndex() != -1) {
      String oldname = (String) contactList.getSelectedValue();
      if (oldname.equals(newname)) { // 同名
        addrbook.put(contact.getProperty(ContactProps.NAME), contact);
      } else { // 改变名字
        if (addrbook.containsKey(newname)) { // 名字冲突
        } else { // 名字不冲突
          addrbook.remove(oldname);
          addrbook.put(newname, contact);
        }
      }
    } else {

      if (addrbook.containsKey(newname)) { // 名字冲突
      } else { // 名字不冲突
        addrbook.put(newname, contact);
      }
    }
    refreshContactList();
    contactList.setSelectedValue(newname, true);
    AddrBookProps.save(addrbook);
  }
コード例 #17
0
 /**
  * Implements <code>ApplicationWindow.show</code> method.
  *
  * @param isVisible specifies whether the frame is to be visible or not.
  */
 @Override
 public void setVisible(boolean isVisible) {
   if (isVisible && configList.getSelectedIndex() < 0) {
     this.configList.setSelectedIndex(0);
   }
   super.setVisible(isVisible);
 }
コード例 #18
0
  // Listener method for list selection changes.
  public void valueChanged(ListSelectionEvent e) {
    if (e.getValueIsAdjusting() == false) {

      if (list.getSelectedIndex() == -1) {
        // No selection: disable delete, up, and down buttons.
        deleteButton.setEnabled(false);
        upButton.setEnabled(false);
        downButton.setEnabled(false);
        nameField.setText("");

      } else if (list.getSelectedIndices().length > 1) {
        // Multiple selection: disable up and down buttons.
        deleteButton.setEnabled(true);
        upButton.setEnabled(false);
        downButton.setEnabled(false);

      } else {
        // Single selection: permit all operations.
        deleteButton.setEnabled(true);
        upButton.setEnabled(true);
        downButton.setEnabled(true);
        nameField.setText(list.getSelectedValue().toString());
      }
    }
  }
コード例 #19
0
  /** update our data */
  void updateData() {

    // find out which one is selected
    final int curSel = _myList.getSelectedIndex();

    // create an object to put the data into
    final Vector<WorldLocationHolder> list = new Vector<WorldLocationHolder>(0, 1);

    if (getPath() != null) {
      final int len = getPath().size();
      for (int i = 0; i < len; i++) {
        final WorldLocation thisLoc = getPath().getLocationAt(i);
        final WorldLocationHolder holder = new WorldLocationHolder(thisLoc, i + 1);
        list.add(holder);
      }
    }

    // and put the data into the list
    _myList.setListData(list);

    // select the previous item
    if (curSel != -1 && curSel < _myPath.size()) _myList.setSelectedIndex(curSel);

    // update the list
    _myPlotter.update();
  }
コード例 #20
0
 @Override
 public String validateInput() {
   if (lst.getSelectedIndex() == -1) {
     return UIFactory.getI18n().tr("You must select a legend.");
   }
   return null;
 }
コード例 #21
0
 /**
  * Respond to selections within the left list.
  *
  * @throws InvocationTargetException
  * @throws InterruptedException
  */
 private void respondToListClick() {
   this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
   enableOrDisableActions();
   int idx = archetypeList.getSelectedIndex();
   if (idx == -1 || idx >= listData.size()) {
     // no selection
     if (archetypeControl == null) {
       return;
     }
     archetypeControl.removeNameChangeListener(this);
     rightPanel.removeAll();
     archetypeControl = null;
     rightPanel.add(selectLeftLabel);
     rightPanel.repaint();
     return;
   }
   if (archetypeControl == null) {
     archetypeControl = new ArchetypeControl(listData.get(idx));
     setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
     rightPanel.removeAll();
     rightPanel.add(archetypeControl, BorderLayout.CENTER);
     rightPanel.repaint();
     rightPanel.revalidate();
     setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
     archetypeControl.addNameChangeListener(this);
   } else {
     archetypeControl.setArchetype(listData.get(idx));
     archetypeControl.repaint();
   }
   this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
 }
コード例 #22
0
  protected void doExportSelected() {
    Archetype selected = listData.get(archetypeList.getSelectedIndex());
    if (selected == null) {
      return;
    }
    // Set up the dialog
    JMemoryFileChooser chooser = new JMemoryFileChooser();
    chooser.setFileFilter(characterFileFilter);
    chooser.setSelectedFile(new File(selected.getName() + ".xml"));
    chooser.setDialogTitle("Export Archetype");
    chooser.setApproveButtonText("Export");

    // Call dialog
    if (chooser.showSaveDialog(FILEDIALOG_NAME, this) != JFileChooser.APPROVE_OPTION) {
      return;
    }
    File targetFile = chooser.getSelectedFile();
    // Save it
    try {
      performSave(selected, targetFile);
    } catch (IOException e) {
      JOptionPane.showMessageDialog(
          this, "An error occured during export.", "Error", JOptionPane.ERROR_MESSAGE);
    }
  }
コード例 #23
0
    /*
     * Handles the checkbox selection process. Uses the bounds property of the
     * check box within the selected cell to determine whether the checkbox should
     * be selected or not
     **/
    public void mouseReleased(MouseEvent e) {
      if (list == null
          || list.getSelectedIndex() == -1
          || !isEnabled(list.locationToIndex(e.getPoint()))) {
        return;
      }

      int[] indices = list.getSelectedIndices();

      // get the current relative position of the check box
      // rect = box.getBounds(rect);

      for (int i = 0; i < indices.length; i++) {

        // get the current relative position of the check box
        int loc = list.locationToIndex(e.getPoint());
        rect = list.getCellBounds(loc, loc);

        // ensure the point clicked in within the checkBox
        /*if(e.getX() < (rect.getX() + 20) ) {
        	selState[indices[i]] = !selState[indices[i]];
        	setSelStateList(selState);
        } */
      }

      list.revalidate();
      list.repaint();
    }
コード例 #24
0
  protected void updateComponents() {
    final boolean querySelected = queryNameList.getSelectedIndex() != -1;
    final boolean hasQueries = queryNameList.getModel().getSize() > 0;

    queryNameTextField.setEnabled(querySelected);
    queryTextArea.setEnabled(querySelected);

    getConfirmAction().setEnabled(hasQueries && languageField.getSelectedIndex() != -1);
    queryTextArea.setSyntaxEditingStyle(
        mapLanguageToSyntaxHighlighting((String) languageField.getSelectedValue()));
    initScriptTextArea.setSyntaxEditingStyle(
        mapLanguageToSyntaxHighlighting((String) languageField.getSelectedValue()));
    shutdownScriptTextArea.setSyntaxEditingStyle(
        mapLanguageToSyntaxHighlighting((String) languageField.getSelectedValue()));
    previewAction.setEnabled(querySelected);
  }
コード例 #25
0
    void move(int direction) {
      int index = -1;
      int size = 0;

      if (myCombo != null) {
        index = myCombo.getSelectedIndex();
        size = myCombo.getModel().getSize();
      } else if (myList != null) {
        index = myList.getSelectedIndex();
        size = myList.getModel().getSize();
      }

      if (index == -1 || size == 0) return;

      index += direction;

      if (index == size) {
        if (!UISettings.getInstance().CYCLE_SCROLLING) return;
        index = 0;
      } else if (index == -1) {
        if (!UISettings.getInstance().CYCLE_SCROLLING) return;
        index = size - 1;
      }

      if (myCombo != null) {
        myCombo.setSelectedIndex(index);
      } else if (myList != null) {
        myList.setSelectedIndex(index);
      }
    }
コード例 #26
0
  public SplitPaneDemo() {

    // Create the list of images and put it in a scroll pane.

    list = new JList(imageNames);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.setSelectedIndex(0);
    list.addListSelectionListener(this);

    JScrollPane listScrollPane = new JScrollPane(list);
    picture = new JLabel();
    picture.setFont(picture.getFont().deriveFont(Font.ITALIC));
    picture.setHorizontalAlignment(JLabel.CENTER);

    JScrollPane pictureScrollPane = new JScrollPane(picture);

    // Create a split pane with the two scroll panes in it.
    splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, listScrollPane, pictureScrollPane);
    splitPane.setOneTouchExpandable(true);
    splitPane.setDividerLocation(150);

    // Provide minimum sizes for the two components in the split pane.
    Dimension minimumSize = new Dimension(100, 50);
    listScrollPane.setMinimumSize(minimumSize);
    pictureScrollPane.setMinimumSize(minimumSize);

    // Provide a preferred size for the split pane.
    splitPane.setPreferredSize(new Dimension(400, 200));
    updateLabel(imageNames[list.getSelectedIndex()]);
  }
コード例 #27
0
  // Take the incoming string and wherever there is a
  // newline, break it into a separate item in the list.
  protected void importString(JComponent c, String str) {
    JList target = (JList) c;
    DefaultListModel listModel = (DefaultListModel) target.getModel();
    int index = target.getSelectedIndex();

    // Prevent the user from dropping data back on itself.
    // For example, if the user is moving items #4,#5,#6 and #7 and
    // attempts to insert the items after item #5, this would
    // be problematic when removing the original items.
    // So this is not allowed.
    if (indices != null && index >= indices[0] - 1 && index <= indices[indices.length - 1]) {
      indices = null;
      return;
    }

    int max = listModel.getSize();
    if (index < 0) {
      index = max;
    } else {
      index++;
      if (index > max) {
        index = max;
      }
    }
    String[] values = str.split("\n");
    for (int i = 0; i < values.length; i++) {
      listModel.add(index++, values[i]);
    }
  }
コード例 #28
0
  public void valueChanged(ListSelectionEvent e) {
    switch (list.getSelectedIndex()) {
      case 0:
        this.text.setText(
            "A regular text file.  Text files usually end in .txt, and hold text data.");
        break;
      case 1:
        this.text.setText(
            "A machine learning method learns to recognize patterns in your data.  Machine learning methods include neural networks, support vector machines, and others.");
        break;
      case 2:
        this.text.setText(
            "CSV files hold tables of data.  Encog uses CSV files for many different purposes.");
        break;
      case 3:
        this.text.setText(
            "A binary training file.  Encog training files can be either supervised or unsupervised.  They are stored in a cross-platform binary format and can be easily converted to/from CSV files.");
        break;
      case 4:
        this.text.setText(
            "Create NeuroEvolution of Augmenting Topologies (NEAT) population.  This will create a population of genomes that can be used to create NEAT neural networks.  NEAT networks are trained using a genetic algorithm both to vary weights and structures.");
        break;
    }

    this.text.setSelectionStart(0);
    this.text.setSelectionEnd(0);
  }
コード例 #29
0
  public void actionPerformed(ActionEvent e) {
    String[] oldData = getData();

    if (e.getSource() == addButton) {
      String value = UISupport.prompt("Specify value to add", "Add..", defaultValue);
      if (value != null) {
        listModel.addElement(value);
        firePropertyChange("options", oldData, getData());
      }
    } else {
      int selectedIndex = list.getSelectedIndex();

      if (e.getSource() == removeButton && selectedIndex != -1) {
        Object elm = listModel.getElementAt(selectedIndex);
        if (UISupport.confirm("Remove [" + elm.toString() + "] from list", "Remove")) {
          listModel.remove(selectedIndex);
          firePropertyChange("options", oldData, getData());
        }
      } else if (e.getSource() == editButton && selectedIndex != -1) {
        String elm = (String) listModel.getElementAt(selectedIndex);
        String value = UISupport.prompt("Specify value", "Edit..", elm);

        if (value != null) {
          listModel.setElementAt(value, selectedIndex);
          firePropertyChange("options", oldData, getData());
        }
      }
    }
  }
コード例 #30
0
 private void updateButtons() {
   int index = list.getSelectedIndex();
   remove.setEnabled(index != -1 && listModel.getSize() != 0);
   moveUp.setEnabled(index > 0);
   moveDown.setEnabled(index != -1 && index != listModel.getSize() - 1);
   edit.setEnabled(index != -1);
 }