public void setIndexer(LibrariesIndexer indexer) {
    this.indexer = indexer;

    DropdownItem<DownloadableContribution> previouslySelectedCategory = (DropdownItem<DownloadableContribution>) categoryChooser.getSelectedItem();
    DropdownItem<DownloadableContribution> previouslySelectedType = (DropdownItem<DownloadableContribution>) typeChooser.getSelectedItem();

    categoryChooser.removeActionListener(categoryChooserActionListener);
    typeChooser.removeActionListener(typeChooserActionListener);

    // TODO: Remove setIndexer and make getContribModel 
    // return a FilteredAbstractTableModel
    getContribModel().setIndexer(indexer);

    categoryFilter = null;
    categoryChooser.removeAllItems();

    // Load categories
    categoryChooser.addItem(new DropdownAllItem());
    Collection<String> categories = indexer.getIndex().getCategories();
    for (String category : categories) {
      categoryChooser.addItem(new DropdownLibraryOfCategoryItem(category));
    }

    categoryChooser.setEnabled(categoryChooser.getItemCount() > 1);

    categoryChooser.addActionListener(categoryChooserActionListener);
    if (previouslySelectedCategory != null) {
      categoryChooser.setSelectedItem(previouslySelectedCategory);
    } else {
      categoryChooser.setSelectedIndex(0);
    }

    typeFilter = null;
    typeChooser.removeAllItems();
    typeChooser.addItem(new DropdownAllItem());
    typeChooser.addItem(new DropdownInstalledLibraryItem(indexer.getIndex()));
    java.util.List<String> types = new LinkedList<String>(indexer.getIndex().getTypes());
    Collections.sort(types, new LibraryTypeComparator());
    for (String type : types) {
      typeChooser.addItem(new DropdownLibraryOfTypeItem(type));
    }
    typeChooser.setEnabled(typeChooser.getItemCount() > 1);
    typeChooser.addActionListener(typeChooserActionListener);
    if (previouslySelectedType != null) {
      typeChooser.setSelectedItem(previouslySelectedType);
    } else {
      typeChooser.setSelectedIndex(0);
    }

    filterField.setEnabled(contribModel.getRowCount() > 0);

    // Create LibrariesInstaller tied with the provided index
    installer = new LibraryInstaller(indexer, platform) {
      @Override
      public void onProgress(Progress progress) {
        setProgress(progress);
      }
    };
  }
Beispiel #2
0
 protected void createButtons(JPanel panel) {
   panel.add(new Filler(24, 20));
   JComboBox drawingChoice = new JComboBox();
   drawingChoice.addItem(fgUntitled);
   String param = getParameter("DRAWINGS");
   if (param == null) {
     param = "";
   }
   StringTokenizer st = new StringTokenizer(param);
   while (st.hasMoreTokens()) {
     drawingChoice.addItem(st.nextToken());
   }
   if (drawingChoice.getItemCount() > 1) {
     panel.add(drawingChoice);
   } else {
     panel.add(new JLabel(fgUntitled));
   }
   drawingChoice.addItemListener(
       new ItemListener() {
         public void itemStateChanged(ItemEvent e) {
           if (e.getStateChange() == ItemEvent.SELECTED) {
             loadDrawing((String) e.getItem());
           }
         }
       });
   panel.add(new Filler(6, 20));
   JButton button;
   button = new CommandButton(new DeleteCommand("Delete", this));
   panel.add(button);
   button = new CommandButton(new DuplicateCommand("Duplicate", this));
   panel.add(button);
   button = new CommandButton(new GroupCommand("Group", this));
   panel.add(button);
   button = new CommandButton(new UngroupCommand("Ungroup", this));
   panel.add(button);
   button = new JButton("Help");
   button.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent event) {
           showHelp();
         }
       });
   panel.add(button);
   fUpdateButton = new JButton("Simple Update");
   fUpdateButton.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent event) {
           if (fSimpleUpdate) {
             setBufferedDisplayUpdate();
           } else {
             setSimpleDisplayUpdate();
           }
         }
       });
 }
Beispiel #3
0
 public HeaderPanel(String heading) {
   super();
   this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
   this.setBackground(background);
   JLabel panelLabel = new JLabel(" " + heading, SwingConstants.LEFT);
   Font labelFont = new Font("Dialog", Font.BOLD, 18);
   panelLabel.setFont(labelFont);
   this.add(panelLabel);
   this.add(Box.createHorizontalGlue());
   refresh = new JButton("Refresh");
   refresh.addActionListener(this);
   this.add(refresh);
   this.add(Box.createHorizontalStrut(5));
   root = new JComboBox();
   Dimension d = root.getPreferredSize();
   d.width = 90;
   root.setPreferredSize(d);
   root.setMaximumSize(d);
   File[] roots = directoryPane.getRoots();
   for (int i = 0; i < roots.length; i++) root.addItem(roots[i].getAbsolutePath());
   this.add(root);
   root.setSelectedIndex(directoryPane.getCurrentRootIndex());
   root.addActionListener(this);
   this.add(Box.createHorizontalStrut(17));
 }
  private void affectLibelle() {
    setTitle(ConcoursJeunes.ajrLibelle.getResourceString("criterion.titre"));

    jlCode.setText(ConcoursJeunes.ajrLibelle.getResourceString("criterion.code"));
    jlLibelle.setText(ConcoursJeunes.ajrLibelle.getResourceString("criterion.libelle"));
    jlSortOrder.setText(ConcoursJeunes.ajrLibelle.getResourceString("criterion.ordretri"));
    jcbSortOrder.removeAllItems();
    jcbSortOrder.addItem(ConcoursJeunes.ajrLibelle.getResourceString("criterion.ordretri.asc"));
    jcbSortOrder.addItem(ConcoursJeunes.ajrLibelle.getResourceString("criterion.ordretri.desc"));
    jcbPlacementCriterion.setText(
        ConcoursJeunes.ajrLibelle.getResourceString("criterion.placement"));
    jcbClassementCriterion.setText(
        ConcoursJeunes.ajrLibelle.getResourceString("criterion.classement"));

    jbValider.setText(ConcoursJeunes.ajrLibelle.getResourceString("bouton.valider"));
    jbAnnuler.setText(ConcoursJeunes.ajrLibelle.getResourceString("bouton.annuler"));
  }
Beispiel #5
0
 /**
  * creates a new channel, if the channel exists it is removed (this method doubles as a
  * removeChannel)
  *
  * @param name the name of the channel
  */
 public void newChannel(String name, boolean pass) {
   if (channels.containsKey(name)) {
     channels.remove(name);
     cboChannels.removeItem(name);
   } else {
     channels.put(name, new Boolean(pass));
     cboChannels.addItem(name);
   }
 }
 {
   for (myjava.gui.syntax.Painter painter : myjava.gui.syntax.Painter.getPainters()) {
     painterComboBox.addItem(painter);
     EntryListPanel panel = new EntryListPanel(painter);
     listPanelSet.add(panel);
     centerPanel.add(panel, painter.getName());
   }
   componentSet.addAll(Arrays.asList(matchBracket, painterComboBox, centerPanel));
 }
  private void updateParams(EDPCellData data) {
    paramComboBox.removeAllItems();
    paramKeys = data.getPlugin().getPrintfDescrs(!m_isCrawlRuleEditor);
    if (!m_isCrawlRuleEditor) {
      paramComboBox.addItem(STRING_LITERAL);
    }

    for (Iterator it = paramKeys.values().iterator(); it.hasNext(); ) {
      ConfigParamDescr descr = (ConfigParamDescr) it.next();
      int type = descr.getType();
      if (!m_isCrawlRuleEditor
          && (type == ConfigParamDescr.TYPE_SET || type == ConfigParamDescr.TYPE_RANGE)) continue;
      paramComboBox.addItem(descr);
    }
    paramComboBox.setEnabled(true);
    paramComboBox.setSelectedIndex(0);
    paramComboBox.setToolTipText("Select a parameter to insert into the format string");
    insertButton.setEnabled(true);
  }
 /** {@inheritDoc} */
 public Component getTableCellEditorComponent(
     JTable table, Object value, boolean isSelected, int row, int column) {
   BranchDescriptor d = myBranches.get(row);
   myComboBox.removeAllItems();
   for (String s : d.referencesToSelect) {
     myComboBox.addItem(s);
   }
   myComboBox.setSelectedItem(d.referenceToCheckout);
   return myPanel;
 }
      private void prepareTextComboBox(final Object propertyValue) {
        // _textComboBox wird in der letzten Zeile editierbar gemacht, und es wird
        // der übergebene Wert in diese Zeile eingetragen und selektiert, wenn er nicht
        // einem der anderen Einträge entspricht.

        if (propertyValue != null) {
          String propertyValueAsString = (String) propertyValue;
          final int size = _textComboBox.getModel().getSize();
          boolean propertyValueFound = false;
          for (int i = 0; i < size - 1; i++) {
            if (propertyValueAsString.equals((String) _textComboBox.getItemAt(i))) {
              propertyValueFound = true;
              _textComboBox.setSelectedIndex(i);
              break;
            }
          }
          if (!propertyValueFound) {
            _textComboBox.removeItemAt(size - 1);
            _textComboBox.addItem(propertyValueAsString);
            _textComboBox.setSelectedIndex(size - 1);
          }
        }

        ItemListener textComboBoxItemListener =
            new ItemListener() {
              public void itemStateChanged(ItemEvent e) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                  if (_textComboBox.getSelectedIndex()
                      == DOTPointPainter.DYNAMIC_TEXT_ITEMS.length - 1) {
                    _textComboBox.setEditable(true);
                  } else {
                    _textComboBox.setEditable(false);
                  }
                }
              }
            };
        _textComboBox.addItemListener(textComboBoxItemListener);

        ActionListener editorActionListener =
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                final int length = DOTPointPainter.DYNAMIC_TEXT_ITEMS.length;
                final int index = length - 1;
                final ComboBoxEditor editor = _textComboBox.getEditor();
                String editedItem = (String) editor.getItem();
                _textComboBox.insertItemAt(editedItem, index);
                final DefaultComboBoxModel model = (DefaultComboBoxModel) _textComboBox.getModel();
                if (model.getSize()
                    > length) { // Sieht komisch aus, aber der direkte Weg ging nicht.
                  model.removeElementAt(length);
                }
              }
            };
        _textComboBox.getEditor().addActionListener(editorActionListener);
      }
Beispiel #10
0
  public EmpMain() {
    String[] col = {"사번", "이름", "직위", "입사일", "부서번호"};
    String[][] row = new String[0][5];
    model =
        new DefaultTableModel(row, col) {
          public boolean isCellEditable(int r, int c) {
            return false;
          }
        };
    table = new JTable(model);
    JScrollPane js = new JScrollPane(table);
    la = new JLabel("사원목록");
    la.setFont(new Font("나눔스퀘어", Font.BOLD, 30));
    table.setFont(new Font("나눔스퀘어", Font.PLAIN, 12));
    JPanel p = new JPanel();
    p.add(la);

    la1 = new JLabel("Search");
    tf = new JTextField(10);
    box = new JComboBox();
    box.addItem("이름");
    box.addItem("입사일");
    box.addItem("부서");
    b1 = new JButton("찾기");
    b2 = new JButton("목록");
    JPanel p1 = new JPanel();
    p1.add(la1);
    p1.add(box);
    p1.add(tf);
    p1.add(b1);
    p1.add(b2);
    add("South", p1);
    add("Center", js);
    add("North", p);
    setSize(640, 480);
    setVisible(true);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    getData();
    table.addMouseListener(this);
    b1.addActionListener(this);
    b2.addActionListener(this);
  }
Beispiel #11
0
  // Вид формы при изменении сотрудника
  public void sotrDiaUpdate(Sotrudnik s) {
    label_id_hidden.setText(Integer.toString(s.getId_sotrudnika()));
    textField_familiya.setText(s.getFamiliya());
    textField_imya.setText(s.getImya());
    textField_otchestvo.setText(s.getOtchestvo());
    textField_phone.setText(s.getPhone());
    textField_date.setText(s.getData_priema().toString());
    comboBox_doljnost.removeAllItems();
    comboBox_kvalification.removeAllItems();

    try {
      DBClass db = new DBClass();
      ArrayList<Doljnost> d = db.doljnostFromDB();
      DBClass db2 = new DBClass();
      Doljnost dd = db2.doljnostFromDB(s);
      for (int i = 0; i < d.size(); i++) {
        comboBox_doljnost.addItem(d.get(i));
        Doljnost ddd = (Doljnost) comboBox_doljnost.getItemAt(i);
        if (dd.getNazvanie_doljnosti().equals(ddd.getNazvanie_doljnosti())) dd = ddd;
      }
      comboBox_doljnost.setSelectedItem(dd);

      DBClass db3 = new DBClass();
      ArrayList<Kvalification> k = db3.kvalificationFromDB();
      DBClass db4 = new DBClass();
      Kvalification kk = db4.kvalificationFromDB(s);
      for (int i = 0; i < k.size(); i++) {
        comboBox_kvalification.addItem(k.get(i));
        Kvalification kkk = (Kvalification) comboBox_kvalification.getItemAt(i);
        if (kk.getNazvanie_kvalification().equals(kkk.getNazvanie_kvalification())) kk = kkk;
      }

      comboBox_kvalification.setSelectedItem(kk);

    } catch (ClassNotFoundException e) {
      e.printStackTrace();
      JOptionPane.showMessageDialog(panelException, e.getMessage());
    } catch (SQLException ee) {
      ee.printStackTrace();
      JOptionPane.showMessageDialog(panelException, ee.getMessage());
    }
  }
 /**
  * Establishes combo box editor for 'from onramp' column.
  *
  * @param clmn
  */
 private void setUpToOnrampColumn() {
   JComboBox combo = new JComboBox();
   Vector<AbstractNetworkElement> nes =
       ((AbstractControllerComplex) controller).getMyMonitor().getSuccessors();
   for (int i = 0; i < nes.size(); i++)
     if ((nes.get(i).getType() & TypesHWC.MASK_LINK) > 0) combo.addItem(nes.get(i));
   TableColumn clmn = zonetab.getColumnModel().getColumn(3);
   clmn.setCellEditor(new DefaultCellEditor(combo));
   clmn.setCellRenderer(new DefaultTableCellRenderer());
   return;
 }
Beispiel #13
0
  // Вид формы при добавлении нового сотрудника
  public void sotrDiaInsert() {
    label_id_hidden.setText("Новый сотрудник");
    textField_familiya.setText("");
    textField_imya.setText("");
    textField_otchestvo.setText("");
    textField_phone.setText("");
    comboBox_doljnost.removeAllItems();
    comboBox_kvalification.removeAllItems();

    Calendar calend = Calendar.getInstance();
    if (calend.get(Calendar.MONTH) <= 9) {
      textField_date.setText(
          String.valueOf(
              (calend.get(Calendar.YEAR) + "-" + ("0" + (1 + calend.get(Calendar.MONTH))) + "-")
                  + (calend.get(Calendar.DATE))));
    } else
      textField_date.setText(
          String.valueOf(
              ((calend.get(Calendar.YEAR)) + "-" + (1 + calend.get(Calendar.MONTH)) + "-")
                  + (calend.get(Calendar.DATE))));
    textField_date.setEnabled(false);

    try {
      DBClass db = new DBClass();
      ArrayList<Doljnost> d = db.doljnostFromDB();
      for (int i = 0; i < d.size(); i++) {
        comboBox_doljnost.addItem(d.get(i));
      }
      DBClass db2 = new DBClass();
      ArrayList<Kvalification> k = db2.kvalificationFromDB();
      for (int i = 0; i < k.size(); i++) {
        comboBox_kvalification.addItem(k.get(i));
      }
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
      JOptionPane.showMessageDialog(panelException, e.getMessage());
    } catch (SQLException ee) {
      ee.printStackTrace();
      JOptionPane.showMessageDialog(panelException, ee.getMessage());
    }
  }
Beispiel #14
0
 protected void updateCategoryChooser() {
   if (categoryChooser != null) {
     ArrayList<String> categories;
     categoryChooser.removeAllItems();
     categories = new ArrayList<String>(contribListing.getCategories(filter));
     //      for (int i = 0; i < categories.size(); i++) {
     //        System.out.println(i + " category: " + categories.get(i));
     //      }
     Collections.sort(categories);
     //    categories.add(0, ContributionManagerDialog.ANY_CATEGORY);
     boolean categoriesFound = false;
     categoryChooser.addItem(ContributionManagerDialog.ANY_CATEGORY);
     for (String s : categories) {
       categoryChooser.addItem(s);
       if (!s.equals(Contribution.UNKNOWN_CATEGORY)) {
         categoriesFound = true;
       }
     }
     categoryChooser.setVisible(categoriesFound);
   }
 }
Beispiel #15
0
 private void addPainter(myjava.gui.syntax.Painter painter) {
   EntryListPanel newPanel = new EntryListPanel(painter);
   listPanelSet.add(newPanel);
   centerPanel.add(newPanel, painter.getName());
   painterComboBox.removeItemListener(painterChangeListener);
   painterComboBox.removeAllItems();
   for (EntryListPanel p : listPanelSet) {
     painterComboBox.addItem(p.getPainter());
   }
   removedPainters.remove(painter);
   painterComboBox.addItemListener(painterChangeListener);
 }
  private void initMatches() {
    matchesKeys.put(STRING_LITERAL, "");
    matchesKeys.put("Any number", "[0-9]+");
    matchesKeys.put("Anything", ".*");
    matchesKeys.put("Start", "^");
    matchesKeys.put("End", "$");
    matchesKeys.put("Single path component", "[^/]+");

    for (Iterator it = matchesKeys.keySet().iterator(); it.hasNext(); ) {
      matchComboBox.addItem(it.next());
    }
  }
 @NotNull
 JComponent createComponent() {
   myRemoteCombobox = new JComboBox();
   myRemoteCombobox.setRenderer(new RemoteCellRenderer(myRemoteCombobox.getRenderer()));
   for (GitRemote remote : myRemotes) {
     myRemoteCombobox.addItem(remote);
   }
   myRemoteCombobox.setToolTipText("Select remote");
   if (myRemotes.size() == 1) {
     myRemoteCombobox.setEnabled(false);
   }
   return myRemoteCombobox;
 }
  public void setModel(SkeletonProperty[] sprops) {
    if (sprops == null) sprops = new SkeletonProperty[0];

    SkeletonPropertyEditor.SkelPropTableModel model =
        new SkeletonPropertyEditor.SkelPropTableModel(sprops);
    m_table.setModel(model);
    m_model = model;
    m_table.createDefaultColumnsFromModel();

    // model.addColumn("DescriptiveString");
    // model.addColumn("DescriptiveString");
    // model.addColumn("DescriptiveString");
    // model.addColumn("DescriptiveString");
    // model.addColumn("DescriptiveString");

    TableColumn type = m_table.getColumnModel().getColumn(3);
    type.setHeaderValue("POUET");
    JComboBox typeCombo = new JComboBox();
    typeCombo.addItem(SkeletonProperty.TYPE_STRING);
    typeCombo.addItem(SkeletonProperty.TYPE_TEXTAREA);
    typeCombo.addItem(SkeletonProperty.TYPE_BOOLEAN);
    type.setCellEditor(new DefaultCellEditor(typeCombo));
  }
  public static void main(String[] args) {
    JFrame fr = new JFrame("belajar combo box");
    JPanel panel = new JPanel();
    JComboBox combo = new JComboBox();

    List<String> mahasiswa = new ArratList<String>();
    mahasiswa.add("sidratul");

    JLabel lnama = new JLabel("Nama");
    panel.add(lnama);

    combo.addItem("tidur");
    combo.addItem("makan");
    combo.addItem("belajar");

    panel.add(combo);

    fr.getContentPane().add(panel);
    fr.setVisible(true);
    fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    fr.setSize(500, 400);
    fr.setLocationRelativeTo(null);
  }
Beispiel #20
0
  public static void updateDoljnost() {
    try {
      DBClass db = new DBClass();
      ArrayList<Doljnost> d = db.doljnostFromDB();
      comboBox_doljnost.removeAllItems();
      for (int i = 0; i < d.size(); i++) {
        comboBox_doljnost.addItem(d.get(i));
      }

    } catch (ClassNotFoundException e) {
      e.printStackTrace();
      JOptionPane.showMessageDialog(null, e.getMessage());
    } catch (SQLException ee) {
      ee.printStackTrace();
      JOptionPane.showMessageDialog(null, ee.getMessage());
    }
  }
Beispiel #21
0
  public static void updateKvalification() {
    try {

      DBClass db2 = new DBClass();
      ArrayList<Kvalification> k = db2.kvalificationFromDB();
      comboBox_kvalification.removeAllItems();
      for (int i = 0; i < k.size(); i++) {
        comboBox_kvalification.addItem(k.get(i));
      }
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
      JOptionPane.showMessageDialog(null, e.getMessage());
    } catch (SQLException ee) {
      ee.printStackTrace();
      JOptionPane.showMessageDialog(null, ee.getMessage());
    }
  }
  public VisualizationPanel(List<String> metricNames, final Map<Project, Double[]> results) {
    Map<String, IVisualization> vis = VisualizationsRegistry.visualizations;
    int numVis = vis.size();

    setLayout(new GridLayout(2 + numVis, 1));

    this.metricNames = metricNames;
    this.results = results;

    metricNameComboBox = new JComboBox();
    for (String name : metricNames) {
      metricNameComboBox.addItem(name);
    }
    add(metricNameComboBox);

    for (final String visName : vis.keySet()) {
      JButton btn = new JButton(visName);
      btn.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent actionEvent) {
              showVis(visName);
            }
          });
      add(btn);
    }

    JButton boxPlotCombined = new JButton("box and whisker combined");
    boxPlotCombined.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent actionEvent) {
            showCombined("box and whisker");
          }
        });
    add(boxPlotCombined);
  }
    public ChoiceField(ChoiceOption option) {
      super(option);
      this.choices = option.getChoices().toArray(new Choice[0]);

      comboBox = new JComboBox();
      for (int i = 0; i < choices.length; i++) {
        comboBox.addItem(makeEntry(choices[i].getDisplayName()));
        if (i == 0 || choices[i].isDefault()) {
          comboBox.setSelectedIndex(i);
        }
      }
      comboBox.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              fireChangeEvent();
            }
          });

      configureEnableToggle(
          option.isInitiallyEnabled(),
          option.getDisabledValue(),
          Arrays.asList((JComponent) comboBox));
    }
  private boolean addSynapses() {
    // ModFile[] inbuiltSynapses = ModFileHelper.getSynapseModFilesInDir(new
    // File(GeneralProperties.getModTemplateDirectory()));

    Vector synapticTypes = project.cellMechanismInfo.getAllChemElecSynMechNames();

    for (int i = 0; i < synapticTypes.size(); i++) {
      jComboBoxSynapseType.addItem(synapticTypes.elementAt(i));

      if (this.mySynProps.getSynapseType().equals(synapticTypes.elementAt(i))) {
        jComboBoxSynapseType.setSelectedItem(synapticTypes.elementAt(i));
      }
    }
    /*
            ModFile[] mods = null;


            File neuronCodeDir = new File(project.getProjectFile()
                                    + System.getProperty("file.separator")
                                    + GeneralProperties.getDirForNeuronCode());

            mods = ModFileHelper.getSynapseModFilesInDir(neuronCodeDir);

            for (int i = 0; i < mods.length; i++)
            {
                jComboBoxSynapseType.addItem(mods[i]);
                if (this.mySynProps.synapseType.equals(mods[i].myNeuronElement.getProcessName()))
                {
                    jComboBoxSynapseType.setSelectedItem(mods[i]);
                }

            }
    */

    return true;
  }
    private void refresh(int index) {
      GridBagConstraints c = new GridBagConstraints();

      // No connector ................
      if (acs.size() == 0) {
        add(new JLabel(bundle.getString("CTL_No_Connector")), c);
        return;
      }

      // Connector switch ................
      if (acs.size() > 1) {
        c.insets = new Insets(0, 0, 3, 3);
        add(new JLabel(bundle.getString("CTL_Connector")), c);

        cbConnectors = new JComboBox();
        int i, k = acs.size();
        for (i = 0; i < k; i++) {
          AttachingConnector ac = (AttachingConnector) acs.get(i);
          int jj = ac.name().lastIndexOf('.');
          String s = (jj < 0) ? ac.name() : ac.name().substring(jj + 1);
          cbConnectors.addItem(s + " (" + ac.description() + ")");
        }
        c = new GridBagConstraints();
        c.insets = new Insets(0, 3, 3, 0);
        c.weightx = 1.0;
        c.fill = java.awt.GridBagConstraints.HORIZONTAL;
        c.gridwidth = 0;
        cbConnectors.setSelectedIndex(index);
        cbConnectors.setActionCommand("SwitchMe!");
        cbConnectors.addActionListener(this);
        add(cbConnectors, c);
      }

      ac = (AttachingConnector) acs.get(index);

      // Transport ................
      c = new GridBagConstraints();
      c.insets = new Insets(3, 0, 0, 3);
      add(new JLabel(bundle.getString("CTL_Transport")), c);

      JTextField tfTransport = new JTextField(ac.transport().name());
      tfTransport.setEnabled(false);
      c = new GridBagConstraints();
      c.gridwidth = 0;
      c.insets = new Insets(3, 3, 0, 0);
      c.fill = java.awt.GridBagConstraints.HORIZONTAL;
      c.weightx = 1.0;
      add(tfTransport, c);

      // Other params ................
      args = ac.defaultArguments();
      tfParams = new JTextField[args.size()];
      Iterator it = args.keySet().iterator();
      int i = 0;
      while (it.hasNext()) {
        String name = (String) it.next();
        Argument a = (Argument) args.get(name);

        c = new GridBagConstraints();
        c.insets = new Insets(6, 0, 0, 3);
        c.anchor = GridBagConstraints.WEST;
        add(new JLabel(a.label() + ": "), c);

        JTextField tfParam = new JTextField(a.value());
        tfParams[i++] = tfParam;
        tfParam.setName(name);
        c = new GridBagConstraints();
        c.gridwidth = 0;
        c.insets = new Insets(6, 3, 0, 0);
        c.fill = java.awt.GridBagConstraints.HORIZONTAL;
        c.weightx = 1.0;
        add(tfParam, c);
      }

      c = new GridBagConstraints();
      c.weighty = 1.0;
      JPanel p = new JPanel();
      p.setPreferredSize(new Dimension(1, 1));
      add(p, c);
    }
Beispiel #26
0
  public void setFrame() {
    f = new JFrame("数据通讯参数设置");
    // 获取屏幕分辨率的工具集
    Toolkit tool = Toolkit.getDefaultToolkit();
    // 利用工具集获取屏幕的分辨率
    Dimension dim = tool.getScreenSize();
    // 获取屏幕分辨率的高度
    int height = (int) dim.getHeight();
    // 获取屏幕分辨率的宽度
    int width = (int) dim.getWidth();
    // 设置位置
    f.setLocation((width - 300) / 2, (height - 400) / 2);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.pack();
    f.setVisible(true);
    f.setContentPane(this);
    f.setSize(320, 260);
    f.setResizable(false);

    lblIP = new JLabel("主机名");
    txtIp = new JTextField(20);
    try {
      InetAddress addr = InetAddress.getLocalHost();
      txtIp.setText(addr.getHostAddress().toString());
    } catch (Exception ex) {
    }

    lblNo = new JLabel("端口号");
    cmbNo = new JComboBox();
    cmbNo.setEditable(true);
    cmbNo.addPopupMenuListener(
        new PopupMenuListener() {
          @Override
          public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
            cmbNo.removeAllItems();
            CommPortIdentifier portId = null;
            Enumeration portList;
            portList = CommPortIdentifier.getPortIdentifiers();
            while (portList.hasMoreElements()) {
              portId = (CommPortIdentifier) portList.nextElement();
              cmbNo.addItem(portId.getName());
            }
          }

          @Override
          public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
            // To change body of implemented methods use File | Settings | File Templates.
          }

          @Override
          public void popupMenuCanceled(PopupMenuEvent e) {
            // To change body of implemented methods use File | Settings | File Templates.
          }
        });

    lblName = new JLabel("工程名");
    txtProjectName = new JComboBox();
    txtProjectName.setEditable(true);
    txtProjectName.addPopupMenuListener(
        new PopupMenuListener() {
          @Override
          public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
            txtProjectName.removeAllItems();
            Mongo m1 = null;
            try {
              m1 = new Mongo(txtIp.getText().toString(), 27017);
            } catch (UnknownHostException ex) {
              ex.printStackTrace();
            }
            for (String name : m1.getDatabaseNames()) {
              txtProjectName.addItem(name);
            }
            m1.close();
          }

          @Override
          public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
            // To change body of implemented methods use File | Settings | File Templates.
          }

          @Override
          public void popupMenuCanceled(PopupMenuEvent e) {
            // To change body of implemented methods use File | Settings | File Templates.
          }
        });

    lblBote = new JLabel("波特率");
    cmbBote = new JComboBox();
    cmbBote.addItem(9600);
    cmbBote.addItem(19200);
    cmbBote.addItem(57600);
    cmbBote.addItem(115200);

    lblLength = new JLabel("数据长度");
    cmbLength = new JComboBox();
    cmbLength.addItem(8);
    cmbLength.addItem(7);

    lblParity = new JLabel("校验");
    cmbParity = new JComboBox();
    cmbParity.addItem("None");
    cmbParity.addItem("Odd");
    cmbParity.addItem("Even");

    lblStopBit = new JLabel("停止位");
    cmbStopBit = new JComboBox();
    cmbStopBit.addItem(1);
    cmbStopBit.addItem(2);

    lblDelay = new JLabel("刷新");
    txtDelay = new JTextField(20);

    btnOk = new JButton("确定");
    btnOk.addActionListener(
        new AbstractAction() {
          @Override
          public void actionPerformed(ActionEvent e) {
            paramIp = txtIp.getText().toString();
            paramName = txtProjectName.getSelectedItem().toString();
            paramNo = cmbNo.getSelectedItem().toString();
            paramBote = Integer.parseInt(cmbBote.getSelectedItem().toString());
            parmLength = Integer.parseInt(cmbLength.getSelectedItem().toString());
            parmParity = cmbParity.getSelectedIndex();
            parmStopBit = Integer.parseInt(cmbStopBit.getSelectedItem().toString());
            parmDelay = Integer.parseInt(txtDelay.getText().toString());

            if (!paramName.equals("") && !paramNo.equals("")) {
              receiveData(
                  paramIp,
                  paramName,
                  paramNo,
                  paramBote,
                  parmLength,
                  parmParity,
                  parmStopBit,
                  parmDelay);
            } else {

            }
          }
        });
    btnCancel = new JButton("取消");
    btnCancel.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            System.exit(0);
          }
        });

    JPanel p1 = new JPanel();
    p1.setLayout(new GridLayout(9, 2));

    p1.add(lblIP);
    p1.add(txtIp);

    p1.add(lblNo);
    p1.add(cmbNo);

    p1.add(lblName);
    p1.add(txtProjectName);

    p1.add(lblBote);
    p1.add(cmbBote);

    p1.add(lblLength);
    p1.add(cmbLength);

    p1.add(lblParity);
    p1.add(cmbParity);

    p1.add(lblStopBit);
    p1.add(cmbStopBit);

    p1.add(lblDelay);
    p1.add(txtDelay);
    txtDelay.setText("500");

    p1.add(btnOk);
    p1.add(btnCancel);

    p1.validate();

    f.add(p1);
    f.validate();
  }
Beispiel #27
0
 private void addStsItem(String str, Sts sts) {
   statuses.put(sts, statusBox.getItemCount());
   statusBox.addItem(str);
 }
Beispiel #28
0
 private void addCnsItem(String str, Cns cns) {
   constructions.put(cns, constrBox.getItemCount());
   constrBox.addItem(str);
 }
Beispiel #29
0
 private void addReflItem(String str, Con con) {
   reflectivities.put(con, reflBox.getItemCount());
   reflBox.addItem(str);
 }
Beispiel #30
0
 private void addConItem(String str, Con con) {
   conspicuities.put(con, conBox.getItemCount());
   conBox.addItem(str);
 }