Exemplo n.º 1
0
  private void fillGUI() {
    Object[] attributes;
    boolean enabled;
    if (context != null) {
      attributes = this.context.getAttributes().toArray();
      enabled = true;
    } else {
      attributes = new Object[] {"No context available"};
      enabled = false;
    }

    sequenceColumnChooser.setModel(new DefaultComboBoxModel(attributes));
    sequenceColumnChooser.setEnabled(enabled);

    timelineColumnChooser.setModel(new DefaultComboBoxModel(attributes));
    timelineColumnChooser.setEnabled(enabled);
    if (context != null) {
      timelineColumnChooser.setSelectedIndex(Math.min(attributes.length - 1, 1));
    }

    calculateValueLists();
    fillSequenceChooser();

    setButtonStates(!enabled);
  }
Exemplo n.º 2
0
  private void resetSettings() {
    downloadDirectoryTextField.setText(Groovesquid.getConfig().getDownloadDirectory());
    maxParallelDownloadsSpinner.setValue(Groovesquid.getConfig().getMaxParallelDownloads());
    fileNameSchemeTextField.setText(Groovesquid.getConfig().getFileNameScheme());

    String[] downloadCompleteActions = Config.DownloadComplete.names();
    DefaultComboBoxModel downloadCompleteComboBoxModel = new DefaultComboBoxModel();
    downloadCompletedComboBox.setModel(downloadCompleteComboBoxModel);
    for (String downloadCompleteAction : downloadCompleteActions) {
      downloadCompleteComboBoxModel.addElement(I18n.getLocaleString(downloadCompleteAction));
    }
    downloadCompletedComboBox.setSelectedIndex(Groovesquid.getConfig().getDownloadComplete());

    String[] startTabs = Config.StartTab.names();
    DefaultComboBoxModel startTabComboBoxModel = new DefaultComboBoxModel();
    startTabComboBox.setModel(startTabComboBoxModel);
    for (String startTab : startTabs) {
      startTabComboBoxModel.addElement(I18n.getLocaleString(startTab));
    }
    startTabComboBox.setSelectedIndex(Groovesquid.getConfig().getStartTab());

    String[] fileExistsActions = Config.FileExists.names();
    DefaultComboBoxModel fileExistsComboBoxModel = new DefaultComboBoxModel();
    fileExistsComboBox.setModel(fileExistsComboBoxModel);
    for (String fileExistsAction : fileExistsActions) {
      fileExistsComboBoxModel.addElement(I18n.getLocaleString(fileExistsAction));
    }
    fileExistsComboBox.setSelectedIndex(Groovesquid.getConfig().getFileExists());

    if (Groovesquid.getConfig().getProxyHost() != null
        && Groovesquid.getConfig().getProxyPort() != null) {
      proxyHostTextField.setText(Groovesquid.getConfig().getProxyHost());
      proxyPortTextField.setText(Groovesquid.getConfig().getProxyPort().toString());
    }
  }
 /*
  * (non-Javadoc)
  *
  * @see java.util.Observer#update(java.util.Observable, java.lang.Object)
  */
 @Override
 public void update(Observable o, Object arg) {
   if (o instanceof qcevolutionbackend) {
     if (null != backend.getCurrentse()) {
       backend.getCurrentse().addObserver(this);
     }
   } else if (o instanceof ProblemManager) {
     Set<String> probs = backend.getProbmanager().getAvailableProblems();
     String[] options = new String[probs.size() + 1];
     options[0] = "Please Select Problem";
     int index = 1;
     Iterator<String> iter = probs.iterator();
     while (iter.hasNext()) {
       options[index++] = iter.next();
     }
     selection_model = new DefaultComboBoxModel(options);
     if (backend.getQproblem() != null) {
       String key = backend.getQproblem().getName();
       selection_model.setSelectedItem(key);
       description.setText(backend.getProbmanager().getSearchEngineDesc(key));
     }
     selection.setModel(selection_model);
   } else {
     if (backend.getCurrentse() != null) {
       if (backend.getCurrentse().getState() == SearchEngineState.Searching) {
         selection.setEnabled(false);
       } else {
         selection.setEnabled(true);
       }
       validate();
     }
   }
 }
Exemplo n.º 4
0
 private void _setUpResources() {
   DefaultComboBoxModel dlm = new DefaultComboBoxModel();
   Set<String> keys = HEADING_LIST.keySet();
   for (String key : keys) {
     dlm.addElement(key);
   }
   mHeadingComboBox.setModel(dlm);
 }
Exemplo n.º 5
0
  /**
   * Chromosome "0" is whole genome
   *
   * @param chromosomes list of chromosomes
   */
  void setChromosomes(List<Chromosome> chromosomes) {
    int[] chromosomeBoundaries = new int[chromosomes.size() - 1];
    long bound = 0;
    for (int i = 1; i < chromosomes.size(); i++) {
      Chromosome c = chromosomes.get(i);
      bound += (c.getLength() / 1000);
      chromosomeBoundaries[i - 1] = (int) bound;
    }
    heatmapPanel.setChromosomeBoundaries(chromosomeBoundaries);

    chrBox1.setModel(
        new DefaultComboBoxModel<Chromosome>(
            chromosomes.toArray(new Chromosome[chromosomes.size()])));
    chrBox2.setModel(
        new DefaultComboBoxModel<Chromosome>(
            chromosomes.toArray(new Chromosome[chromosomes.size()])));
  }
Exemplo n.º 6
0
 public void setSelectedDisplayOption(MatrixType[] options, boolean control) {
   if (control) {
     MatrixType originalMatrixType = (MatrixType) displayOptionComboBox.getSelectedItem();
     displayOptionComboBox.setModel(new DefaultComboBoxModel<MatrixType>(options));
     int indx = 0;
     for (int i = 0; i < displayOptionComboBox.getItemCount(); i++) {
       if (originalMatrixType.equals(displayOptionComboBox.getItemAt(i))) {
         indx = i;
         break;
       }
     }
     displayOptionComboBox.setSelectedIndex(indx);
   } else {
     displayOptionComboBox.setModel(new DefaultComboBoxModel<MatrixType>(options));
     displayOptionComboBox.setSelectedIndex(0);
   }
 }
Exemplo n.º 7
0
 @Override
 public void setMultiConfValues(String[] multiConfValues) {
   multiConfValuesModel = new DefaultComboBoxModel(multiConfValues);
   multiConfValuesBox = new JComboBox();
   multiConfValuesBox.setModel(multiConfValuesModel);
   if (!Configuration.getInstance().isEuMode()) {
     multiConfValuesBox.setEditable(true);
   }
 }
Exemplo n.º 8
0
  @SuppressWarnings({"unchecked"})
  public SimulationPanel(final MainFrame frame, final PartitionDataList dataList) {

    this.frame = frame;
    this.dataList = dataList;

    optionPanel = new OptionsPanel(12, 12, SwingConstants.CENTER);

    simulationsNumberField = new WholeNumberField(1, Integer.MAX_VALUE);
    simulationsNumberField.setColumns(10);
    simulationsNumberField.setValue(dataList.simulationsCount);
    optionPanel.addComponentWithLabel("Number of simulations:", simulationsNumberField);

    setSeed = new JCheckBox();
    setSeed.addItemListener(new SetSeedCheckBoxListener());
    setSeed.setSelected(dataList.setSeed);
    optionPanel.addComponentWithLabel("Set seed:", setSeed);

    startingSeedNumberField = new WholeNumberField(1, Long.MAX_VALUE);
    startingSeedNumberField.setColumns(10);
    startingSeedNumberField.setValue(dataList.startingSeed);
    startingSeedNumberField.setEnabled(dataList.setSeed);
    optionPanel.addComponentWithLabel("Starting seed:", startingSeedNumberField);

    outputFormat = new JComboBox();
    optionPanel.addComponentWithLabel("Output format:", outputFormat);
    outputFormatModel = new DefaultComboBoxModel(SimpleAlignment.OutputType.values());
    outputFormat.setModel(outputFormatModel);

    outputAncestralSequences = new JCheckBox();
    outputAncestralSequences.addItemListener(new outputAncestralSequencesCheckBoxListener());
    outputAncestralSequences.setSelected(dataList.useParallel);
    optionPanel.addComponentWithLabel("Output ancestral sequences:", outputAncestralSequences);

    useParallel = new JCheckBox();
    useParallel.addItemListener(new UseParallelCheckBoxListener());
    useParallel.setSelected(dataList.useParallel);
    optionPanel.addComponentWithLabel("Use parallel implementation:", useParallel);

    // Buttons holder
    JPanel buttonsHolder = new JPanel();
    buttonsHolder.setOpaque(false);

    // simulate button
    simulate = new JButton("Simulate", Utils.createImageIcon(Utils.BIOHAZARD_ICON));
    simulate.addActionListener(new ListenSimulate());
    buttonsHolder.add(simulate);

    generateXML = new JButton("Generate XML", Utils.createImageIcon(Utils.HAMMER_ICON));
    generateXML.addActionListener(new ListenGenerateXML());
    buttonsHolder.add(generateXML);

    setOpaque(false);
    setLayout(new BorderLayout());
    add(optionPanel, BorderLayout.NORTH);
    add(buttonsHolder, BorderLayout.SOUTH);
  } // END: SimulationPanel
Exemplo n.º 9
0
 public void setEnabledForNormalization(String[] normalizationOptions, boolean status) {
   if (normalizationOptions.length == 1) {
     normalizationComboBox.setEnabled(false);
   } else {
     normalizationComboBox.setModel(new DefaultComboBoxModel<String>(normalizationOptions));
     normalizationComboBox.setSelectedIndex(0);
     normalizationComboBox.setEnabled(status && !isWholeGenome());
   }
 }
Exemplo n.º 10
0
  public Component getRoot(final Project project) {
    dataModel = new IssueTableModel();
    statusFilter.setModel(new DefaultComboBoxModel(StatusFilter.values()));
    userFilter.setModel(new DefaultComboBoxModel(UserFilter.values()));

    table1.setModel(dataModel);
    update.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            IssueViewer.this.updateIssues(project);
          }
        });
    table1.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            Point p = e.getPoint();
            int row = table1.rowAtPoint(p);
            if (e.getClickCount() == 2 && issues != null && 0 <= row && row < issues.size()) {
              Issue issue = issues.get(row);
              String resource_uri = issue.getResource_uri();
              // replace使うのはまずいけど面倒なので今はこれで対応
              String substring =
                  resource_uri
                      .substring("/1.0/repositories/".length(), resource_uri.length())
                      .replace("issues", "issue");
              try {
                Desktop.getDesktop().browse(new URL("https://bitbucket.org/" + substring).toURI());
              } catch (IOException e1) {
                e1.printStackTrace();
              } catch (URISyntaxException e1) {
                e1.printStackTrace();
              }
            }
          }
        });
    return panel1;
  }
Exemplo n.º 11
0
    @Override
    public Component getTableCellEditorComponent(
        JTable table, Object value, boolean isSelected, int row, int column) {
      MyTableModel tableModel = (MyTableModel) table.getModel();
      DefaultComboBoxModel comboModel = new DefaultComboBoxModel();

      for (ValidationResult.Option each : tableModel.getOptions(row)) {
        comboModel.addElement(each);
      }
      ((JComboBox) editorComponent).setModel(comboModel);

      return super.getTableCellEditorComponent(table, value, isSelected, row, column);
    }
 public void updateLists(List<? extends ChangeList> lists) {
   //noinspection unchecked
   myChooser.setModel(new DefaultComboBoxModel(lists.toArray()));
   myChooser.setEnabled(lists.size() > 1);
   if (lists.contains(mySelectedChangeList)) {
     myChooser.setSelectedItem(mySelectedChangeList);
   } else {
     if (myChooser.getItemCount() > 0) {
       myChooser.setSelectedIndex(0);
     }
   }
   mySelectedChangeList = (ChangeList) myChooser.getSelectedItem();
 }
 private void initCompileOrderCmb() {
   myCompileOrderCmb.setModel(new ListComboBoxModel<String>(mySettings.COMPILE_ORDERS));
   myCompileOrderCmb.setSelectedItem(mySettings.COMPILE_ORDER);
   myCompileOrderCmb.setRenderer(
       new ListCellRendererWrapper<String>() {
         @Override
         public void customize(
             JList list, String value, int index, boolean selected, boolean hasFocus) {
           if (value.equals("Mixed")) setText("Mixed");
           if (value.equals("JavaThenScala")) setText("Java then Scala");
           if (value.equals("ScalaThenJava")) setText("Scala then Java");
         }
       });
 }
 private void initCompilerTypeCmb() {
   myIncrementalTypeCmb.setModel(new ListComboBoxModel<String>(mySettings.INCREMENTAL_TYPES));
   myIncrementalTypeCmb.setSelectedItem(mySettings.INCREMENTAL_TYPE);
   myIncrementalTypeCmb.setRenderer(
       new ListCellRendererWrapper<String>() {
         @Override
         public void customize(
             JList list, String value, int index, boolean selected, boolean hasFocus) {
           if (value.equals("SBT")) setText("SBT incremental compiler");
           if (value.equals("IDEA")) setText("IntelliJ IDEA");
         }
       });
   myIncrementalTypeCmb.setToolTipText("Rebuild is required after change");
 }
  /** Creates the property iterator panel initially disabled. */
  public GeneratorPropertyIteratorPanel() {

    String[] options = {"Disabled", "Enabled"};
    ComboBoxModel cbm = new DefaultComboBoxModel(options);
    m_StatusBox.setModel(cbm);
    m_StatusBox.setSelectedIndex(0);
    m_StatusBox.addActionListener(this);
    m_StatusBox.setEnabled(false);
    m_ConfigureBut.setEnabled(false);
    m_ConfigureBut.addActionListener(this);
    JPanel buttons = new JPanel();
    GridBagLayout gb = new GridBagLayout();
    GridBagConstraints constraints = new GridBagConstraints();
    buttons.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 5));
    //    buttons.setLayout(new GridLayout(1, 2));
    buttons.setLayout(gb);
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.weightx = 5;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.insets = new Insets(0, 2, 0, 2);
    buttons.add(m_StatusBox, constraints);
    constraints.gridx = 1;
    constraints.gridy = 0;
    constraints.weightx = 5;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    buttons.add(m_ConfigureBut, constraints);
    buttons.setMaximumSize(
        new Dimension(buttons.getMaximumSize().width, buttons.getMinimumSize().height));
    setBorder(BorderFactory.createTitledBorder("Generator properties"));
    setLayout(new BorderLayout());
    add(buttons, BorderLayout.NORTH);
    //    add(Box.createHorizontalGlue());
    m_ArrayEditor.setBorder(BorderFactory.createEtchedBorder());
    m_ArrayEditor.addPropertyChangeListener(
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent e) {
            System.err.println("Updating experiment property iterator array");
            m_Exp.setPropertyArray(m_ArrayEditor.getValue());
          }
        });
    add(m_ArrayEditor, BorderLayout.CENTER);
  }
Exemplo n.º 16
0
  /** Utility method that will load mortgage data from a file. */
  private void loadMortgages() {
    // create a list of mortgages so we can dynamically add as many as our
    // data file allows. the first entry is always our default
    // "user entered" value so the combo box works consistently...
    final LinkedList mortgages = new LinkedList();
    mortgages.add(LABEL_USER_ENTERED_CHOICE);

    try {
      final InputStream resource =
          getClass().getClassLoader().getResourceAsStream(FILENAME_MORTGAGE_DATA);
      if (resource == null) {
        throw new IOException(FILENAME_MORTGAGE_DATA + " not found");
      }
      final BufferedReader reader = new BufferedReader(new InputStreamReader(resource));

      String line;
      while ((line = reader.readLine()) != null) {
        // split the line of data into tokens separated by commas; if
        // there are two tokens found, we assume we have a valid line
        // of data that can be parsed into rate and term values
        final String[] values = line.split(",");
        if (values.length == 2) {
          final double rate = Double.parseDouble(values[0].trim());
          final int term = Integer.parseInt(values[1].trim());

          // add a new set of mortgage terms to the list; the term
          // must be divided by 12 to convert to the number of years
          mortgages.add(new Mortgage(rate, term / 12));
        }
      }
    } catch (IOException ex) {
      JOptionPane.showMessageDialog(
          getRootPane(), ERR_DATA_FILE_IOERR, ERR_DATA_FILE_ERROR, JOptionPane.ERROR_MESSAGE);
      ex.printStackTrace(System.err);
    } catch (NumberFormatException ex) {
      JOptionPane.showMessageDialog(
          getRootPane(), ERR_DATA_FILE_CORRUPT, ERR_DATA_FILE_ERROR, JOptionPane.ERROR_MESSAGE);
      ex.printStackTrace(System.err);
    }

    fieldMortgageChoices.setModel(new DefaultComboBoxModel(mortgages.toArray()));
  }
Exemplo n.º 17
0
        @Override
        public void run() {
          final RunningVM[] vms = p.getRunningVMs();
          final Object[] ar = new Object[((vms == null) ? 0 : vms.length) + 1];

          if (vms == null) {
            ar[0] = ERROR_GETTING_PROCESSES_ITEM_TEXT;
          } else if (vms.length == 0) {
            ar[0] = NO_PROCESSES_ITEM_TEXT;
          } else {
            ar[0] = SELECT_PROCESS_ITEM_TEXT;
            arraycopy(vms, 0, ar, 1, vms.length);
          }
          invokeLater(
              () -> {
                combo.setEnabled(true);
                combo.setModel(new DefaultComboBoxModel<>(ar));
                updateInfo();
              });
        }
Exemplo n.º 18
0
  /** Sets up the panel. */
  private void setupPanel() {

    // layout the panel
    setLayout(new GridLayout(1, 1));
    add(panelMain);

    setPreferredSize(new Dimension(-1, 35));
    setMaximumSize(new Dimension(500, 35));

    // set the scale types
    comboboxType.setModel(
        new DefaultComboBoxModel(
            (ScaleType[])
                ScaleType.getEnumList().toArray(new ScaleType[ScaleType.getEnumList().size()])));

    DefaultFormatterFactory formatterTare =
        new DefaultFormatterFactory(new NumberFormatter(formatTare));

    textfieldTare.setFormatterFactory(formatterTare);
  }
Exemplo n.º 19
0
  public JavaCompilersTab(
      final Project project,
      Collection<BackendCompiler> compilers,
      BackendCompiler defaultCompiler) {
    myDefaultCompiler = defaultCompiler;
    myCompilerConfiguration =
        (CompilerConfigurationImpl) CompilerConfiguration.getInstance(project);
    myConfigurables = new ArrayList<Configurable>(compilers.size());

    myCardLayout = new CardLayout();
    myContentPanel.setLayout(myCardLayout);

    for (BackendCompiler compiler : compilers) {
      Configurable configurable = compiler.createConfigurable();
      myConfigurables.add(configurable);

      myContentPanel.add(configurable.createComponent(), compiler.getId());
    }
    myCompiler.setModel(new DefaultComboBoxModel(new Vector(compilers)));
    myCompiler.setRenderer(
        new DefaultListCellRenderer() {
          public Component getListCellRendererComponent(
              JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            JLabel component =
                (JLabel)
                    super.getListCellRendererComponent(
                        list, value, index, isSelected, cellHasFocus);
            component.setText(((BackendCompiler) value).getPresentableName());
            return component;
          }
        });
    myCompiler.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            BackendCompiler compiler = (BackendCompiler) myCompiler.getSelectedItem();
            if (compiler == null) return;
            selectCompiler(compiler);
          }
        });
  }
Exemplo n.º 20
0
  private void initUI() {
    SortedMap<String, SourceIdentifier> stats = mainFrame.getAvailableStatistics();

    List<WrappedSourceIdentifier> wrappedSources =
        new ArrayList<WrappedSourceIdentifier>(stats.size() + 1);
    wrappedSources.add(new WrappedSourceIdentifier("Global", new SourceIdentifier("global")));
    for (Map.Entry<String, SourceIdentifier> current : stats.entrySet()) {
      WrappedSourceIdentifier wrapped =
          new WrappedSourceIdentifier(current.getKey(), current.getValue());
      wrappedSources.add(wrapped);
    }
    Object[] newSourcesArray = wrappedSources.toArray();
    if (!Arrays.equals(previousSourcesArray, newSourcesArray)) {
      previousSourcesArray = newSourcesArray;
      DefaultComboBoxModel model = new DefaultComboBoxModel(newSourcesArray);
      sourcesComboBox.setModel(model);
    }
    int index = 0;
    if (sourceIdentifier != null) {
      ComboBoxModel model = sourcesComboBox.getModel();
      for (int i = 0; i < model.getSize(); i++) {
        Object current = model.getElementAt(i);
        if (current instanceof WrappedSourceIdentifier) {
          WrappedSourceIdentifier wrapped = (WrappedSourceIdentifier) current;
          if (sourceIdentifier.getIdentifier().equals(wrapped.sourceIdentifier.getIdentifier())) {
            if (logger.isDebugEnabled()) logger.debug("Equal");
            index = i;
            break;
          } else {
            if (logger.isDebugEnabled()) {
              logger.debug("Not equal: {} != {}", sourceIdentifier, wrapped.sourceIdentifier);
            }
          }
        } else {
          if (logger.isWarnEnabled()) logger.warn("Not instanceof WrappedSourceIdentifier");
        }
      }
    }
    sourcesComboBox.setSelectedIndex(index);
  }
Exemplo n.º 21
0
  public FriendsListView() {
    super();
    this.setTitle(friendsListViewMessages.getString("friends"));
    this.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    this.setSize(400, 800);
    this.setLayout(new BorderLayout());
    JSplitPane splitter = new JSplitPane();
    splitter.setResizeWeight(0.5);

    JPanel topPanel = new JPanel(new BorderLayout());
    topPanel.add(new LocalizedJLabel(friendsListViewMessages, "online"), BorderLayout.NORTH);
    this.onlineList = new JList<RosterEntry>();
    this.onlineList.setCellRenderer(new FriendListItemRenderer());
    topPanel.add(new JScrollPane(this.onlineList), BorderLayout.CENTER);

    JPanel bottomPanel = new JPanel(new BorderLayout());
    bottomPanel.add(new LocalizedJLabel(friendsListViewMessages, "offline"), BorderLayout.NORTH);
    this.offlineList = new JList<RosterEntry>();
    this.offlineList.setCellRenderer(new FriendListItemRenderer());
    bottomPanel.add(new JScrollPane(this.offlineList), BorderLayout.CENTER);

    splitter.setTopComponent(topPanel);
    splitter.setBottomComponent(bottomPanel);
    this.add(splitter, BorderLayout.CENTER);

    JPanel presencePanel = new JPanel(new GridLayout(2, 1));
    presenceComboBox = new JComboBox<Status>();
    presenceComboBox.setModel(new StatusComboBoxModel());
    presenceComboBox.setRenderer(new StatusComboBoxRenderer());
    presencePanel.add(presenceComboBox);
    presenceStatusField = new JTextField();
    presencePanel.add(presenceStatusField);
    this.add(presencePanel, BorderLayout.SOUTH);

    this.setVisible(true);
  }
 private void loadListOfMonthlyFeeTypes() {
   Hypothec.MonthlyFeeType[] types = Hypothec.MonthlyFeeType.values();
   monthlyFeeType.setModel(new JComboBox<>(types).getModel());
 }
 private void loadListOfCreditTypes() {
   Hypothec.CreditType[] types = Hypothec.CreditType.values();
   creditType.setModel(new JComboBox<>(types).getModel());
 }
 private void loadListOfInterestRateTypes() {
   Hypothec.InterestRateType[] types = Hypothec.InterestRateType.values();
   interestRateType.setModel(new JComboBox<>(types).getModel());
 }
 private void loadListOfFlatFeeTypes() {
   Hypothec.FlatFeeType[] types = Hypothec.FlatFeeType.values();
   flatFeeType.setModel(new JComboBox<>(types).getModel());
 }
 private void loadListOfPeriods() {
   Hypothec.PeriodType[] periods = Hypothec.PeriodType.values();
   periodType.setModel(new JComboBox<>(periods).getModel());
 }
 private void loadListOfCurrencies() {
   Hypothec.CurrencyType[] currencies = Hypothec.CurrencyType.values();
   currencyType.setModel(new JComboBox<>(currencies).getModel());
 }
Exemplo n.º 28
0
  // ambil data dari database untuk tabel
  public void setDataTabel() {
    // combobox jenis
    JComboBox cbJenis = new JComboBox();
    cbJenis.setModel(new DefaultComboBoxModel(dataJenis.toArray()));

    dataProduk = new ArrayList<Produk>();
    try {
      String qry =
          "SELECT * FROM produk,suplier,jenis,stok_produk WHERE produk.id_jenis = jenis.id_jenis AND produk.id_suplier = suplier.id_suplier AND produk.id_produk=stok_produk.id_produk";
      ResultSet rs = stm.executeQuery(qry);
      while (rs.next()) {
        Produk p = new Produk();
        p.setIdProduk(rs.getInt("id_produk"));
        p.setNamaProduk(rs.getString("nama_produk"));
        p.setJenis(rs.getString("nama_jenis"));
        p.setHarga(rs.getInt("harga"));
        p.setStok(rs.getInt("stok"));
        p.setNamaSuplier(rs.getString("nama_suplier"));

        p.setComboJenis(cbJenis);

        dataProduk.add(p);
      }
    } catch (Exception err) {
      err.printStackTrace();
    }

    model = new TableModelProduk(dataProduk);
    tabel.setModel(model);
    tabel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    class EditProdukListener implements TableModelListener {
      public void tableChanged(TableModelEvent tme) {
        int baris = tme.getFirstRow();
        int kolom = tme.getColumn();

        TableModel model = (TableModel) tme.getSource();
        int id = (Integer) model.getValueAt(baris, 0);

        String query = "";
        switch (kolom) {
          case 1:
            String nama = (String) model.getValueAt(baris, kolom);
            query = "UPDATE produk SET nama_produk='" + nama + "' WHERE id_produk=" + id;
            prosesEdit(query);
            break;
          case 2:
            String jenis = (String) model.getValueAt(baris, kolom);
            try {
              query = "select * from jenis where nama_jenis='" + jenis + "'";
              ResultSet rs = stm.executeQuery(query);
              if (rs.next()) {
                int idJenis = rs.getInt("id_jenis");
                query = "UPDATE produk SET id_jenis=" + idJenis + " WHERE id_produk=" + id;
                prosesEdit(query);
              } else {
                setDataTabel();
                JOptionPane.showMessageDialog(null, "gagal,jenis tidak ada");
              }
            } catch (SQLException SQLerr) {
              SQLerr.printStackTrace();
            }
            break;
          case 3:
            int stok = (Integer) model.getValueAt(baris, kolom);
            query = "UPDATE `stok_produk` SET stok=" + stok + " WHERE id_produk=" + id;
            prosesEdit(query);
            break;
          case 4:
            int harga = (Integer) model.getValueAt(baris, kolom);
            query = "UPDATE produk SET harga=" + harga + " WHERE id_produk=" + id;
            prosesEdit(query);
            break;
          case 5:
            String suplier = (String) model.getValueAt(baris, kolom);
            try {
              query = "SELECT * FROM suplier WHERE nama_suplier='" + suplier + "'";
              ResultSet rs = stm.executeQuery(query);
              if (rs.next()) {
                int idSuplier = rs.getInt("id_suplier");
                query = "UPDATE produk SET id_suplier=" + idSuplier + " WHERE id_produk=" + id;
                prosesEdit(query);
              } else {
                setDataTabel();
                JOptionPane.showMessageDialog(null, "gagal,suplier belum terdaftar");
              }
            } catch (SQLException SQLerr) {
              SQLerr.printStackTrace();
            }
            break;
          default:
            break;
        }
      }

      private void prosesEdit(String query) {
        try {
          int hasil = stm.executeUpdate(query);
          if (hasil == 1) {
            setDataTabel();
            JOptionPane.showMessageDialog(null, "edit berhasil");
          } else {
            JOptionPane.showMessageDialog(null, "gagal");
          }
        } catch (SQLException SQLerr) {
          SQLerr.printStackTrace();
        }
      }
    }
    model.addTableModelListener(new EditProdukListener());
  }
Exemplo n.º 29
0
    private void initComponents() {
      label1 = new JLabel();
      comboBox1 = new JComboBox();
      button1 = new JButton();

      // ======== this ========
      setTitle("SneakyFarmer");
      Container contentPane = getContentPane();
      contentPane.setLayout(null);

      // ---- label1 ----
      label1.setText("Which herb to farm:");
      label1.setFont(label1.getFont().deriveFont(label1.getFont().getSize() + 1f));
      contentPane.add(label1);
      label1.setBounds(10, 10, 125, 35);

      // ---- comboBox1 ----
      comboBox1.setModel(
          new DefaultComboBoxModel(
              new String[] {
                "Guam",
                "Marrentill",
                "Tarromin",
                "Harralander",
                "Ranarr",
                "Toadflax",
                "Irit",
                "Avantoe",
                "Kwuarm",
                "Snapdragon",
                "Cadantine",
                "Lantadyme",
                "Dwarf Weed",
                "Torstol"
              }));
      contentPane.add(comboBox1);
      comboBox1.setBounds(135, 10, 90, 35);

      // ---- button1 ----
      button1.setText("Start Farming!");
      button1.setFont(button1.getFont().deriveFont(button1.getFont().getSize() + 7f));
      contentPane.add(button1);
      button1.setBounds(10, 50, 215, 35);
      button1.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              startActionPerformed(e);
            }
          });

      { // compute preferred size
        Dimension preferredSize = new Dimension();
        for (int i = 0; i < contentPane.getComponentCount(); i++) {
          Rectangle bounds = contentPane.getComponent(i).getBounds();
          preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
          preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
        }
        Insets insets = contentPane.getInsets();
        preferredSize.width += insets.right;
        preferredSize.height += insets.bottom;
        contentPane.setMinimumSize(preferredSize);
        contentPane.setPreferredSize(preferredSize);
      }
      pack();
      setLocationRelativeTo(getOwner());
    }
Exemplo n.º 30
0
  /** Create the arrow head choicebox. */
  private JPanel createArrowChoiceBox() {

    JPanel drawPanel = new JPanel(new BorderLayout());
    CSH.setHelpIDString(drawPanel, "toolbars.formatlink"); // $NON-NLS-1$

    cbArrows = new JComboBox();
    cbArrows.setToolTipText(
        LanguageProperties.getString(
            LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.selectArrow")); // $NON-NLS-1$
    cbArrows.setOpaque(true);
    cbArrows.setEditable(false);
    cbArrows.setEnabled(false);
    cbArrows.setMaximumRowCount(4);
    cbArrows.setFont(new Font("Dialog", Font.PLAIN, 10)); // $NON-NLS-1$

    Vector arrows = new Vector(5);
    arrows.insertElementAt(
        LanguageProperties.getString(
            LanguageProperties.DIALOGS_BUNDLE, "UILinkEditDialog.noArrows"),
        0); //$NON-NLS-1$
    arrows.insertElementAt(
        LanguageProperties.getString(LanguageProperties.DIALOGS_BUNDLE, "UILinkEditDialog.fromTo"),
        1); //$NON-NLS-1$
    arrows.insertElementAt(
        LanguageProperties.getString(LanguageProperties.DIALOGS_BUNDLE, "UILinkEditDialog.toFfrom"),
        2); //$NON-NLS-1$
    arrows.insertElementAt(
        LanguageProperties.getString(
            LanguageProperties.DIALOGS_BUNDLE, "UILinkEditDialog.bothWays"),
        3); //$NON-NLS-1$
    DefaultComboBoxModel comboModel = new DefaultComboBoxModel(arrows);
    cbArrows.setModel(comboModel);
    cbArrows.setSelectedIndex(0);

    DefaultListCellRenderer comboRenderer =
        new DefaultListCellRenderer() {
          public Component getListCellRendererComponent(
              JList list, Object value, int modelIndex, boolean isSelected, boolean cellHasFocus) {
            if (isSelected) {
              setBackground(list.getSelectionBackground());
              setForeground(list.getSelectionForeground());
            } else {
              setBackground(list.getBackground());
              setForeground(list.getForeground());
            }

            setText((String) value);

            return this;
          }
        };
    cbArrows.setRenderer(comboRenderer);

    cbArrows.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onUpdateArrowType(cbArrows.getSelectedIndex());
          }
        });

    drawPanel.add(new JLabel(" "), BorderLayout.WEST); // $NON-NLS-1$
    drawPanel.add(cbArrows, BorderLayout.CENTER);
    return drawPanel;
  }