예제 #1
2
  void bPronadji_actionPerformed(ActionEvent e) {
    if (txtOznakaBanke.getText().equals("")) {
      JOptionPane.showMessageDialog(null, "Oznaka banke mora biti uneta");
      txtOznakaBanke.grabFocus();
    } else {
      Vector filijale = DBF.getFilijale(txtOznakaBanke.getText());
      if (!filijale.isEmpty()) {

        ((TModelPrijave) tabBanke.getModel()).rejoinData(filijale);

        String adresa = DBF.getadresaB(txtOznakaBanke.getText());
        jLadresaBanke.setText(adresa);

        jLnazivBanke.setText(DBF.getnazivB(txtOznakaBanke.getText()));

      } else {
        JOptionPane.showMessageDialog(null, "Nije pronadjena ni jedna filijala");
      }
    }
  }
      @SuppressWarnings("unchecked")
      private Object initDynamicDefinitionComponent() {
        final String selectedPrimitiveFormName =
            _dotDefinitionDialogFrame.getSelectedPrimitiveForm();
        final DOTProperty currentProperty = _dotDefinitionDialogFrame.getSelectedProperty();
        PrimitiveFormPropertyPair pfpPair =
            new PrimitiveFormPropertyPair(selectedPrimitiveFormName, currentProperty);
        final JTable workWithThisTable = _dynamicTables.get(pfpPair);

        int selectedRow = workWithThisTable.getSelectedRow();
        if (selectedRow == -1) {
          if (workWithThisTable.getModel().getRowCount() > 0) {
            selectedRow = 0;
          } else {
            return null;
          }
        }
        selectedRow = workWithThisTable.convertRowIndexToModel(selectedRow);
        final TableModel model = workWithThisTable.getModel();
        DynamicDOTItemManager dynamicDOTItemManager = (DynamicDOTItemManager) model;
        final DisplayObjectTypeItemWithInterval dotItemWithInterval =
            dynamicDOTItemManager.get(selectedRow);
        _dynamicDefinitionComponent.fillComponents(dotItemWithInterval);
        return dotItemWithInterval.getItem().getPropertyValue();
      }
  /**
   * This method indicates whether changes to the model should cause the width to be dynamically
   * recalculated.
   *
   * @param isDynamicAdjustment Boolean value to determine if the width should be dynamically
   *     calculated
   */
  public void setDynamicAdjustment(boolean isDynamicAdjustment) {
    //  May need to add or remove the TableModelListener when changed

    if (this.isDynamicAdjustment != isDynamicAdjustment) {
      if (isDynamicAdjustment) {
        table.addPropertyChangeListener(this);
        table.getModel().addTableModelListener(this);
      } else {
        table.removePropertyChangeListener(this);
        table.getModel().removeTableModelListener(this);
      }
    }

    this.isDynamicAdjustment = isDynamicAdjustment;
  }
예제 #4
0
 @Override
 public void actionPerformed(ActionEvent e) {
   // Object o = table.getModel().getValueAt(table.getSelectedRow(), 0);
   int row = table.convertRowIndexToModel(table.getEditingRow());
   Object o = table.getModel().getValueAt(row, 0);
   JOptionPane.showMessageDialog(table, "Editing: " + o);
 }
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   final Color color = UIUtil.getTableFocusCellBackground();
   Component component;
   T t = (T) value;
   try {
     UIManager.put(UIUtil.TABLE_FOCUS_CELL_BACKGROUND_PROPERTY, table.getSelectionBackground());
     component =
         super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
     setText(t != null ? getItemText(t) : "");
     if (component instanceof JLabel) {
       ((JLabel) component).setBorder(noFocusBorder);
     }
   } finally {
     UIManager.put(UIUtil.TABLE_FOCUS_CELL_BACKGROUND_PROPERTY, color);
   }
   final MyTableModel model = (MyTableModel) table.getModel();
   component.setEnabled(
       ElementsChooser.this.isEnabled()
           && (myColorUnmarkedElements ? model.isElementMarked(row) : true));
   final ElementProperties properties = myElementToPropertiesMap.get(t);
   if (component instanceof JLabel) {
     final Icon icon =
         properties != null ? properties.getIcon() : t != null ? getItemIcon(t) : null;
     JLabel label = (JLabel) component;
     label.setIcon(icon);
     label.setDisabledIcon(icon);
   }
   component.setForeground(
       properties != null && properties.getColor() != null
           ? properties.getColor()
           : (isSelected ? table.getSelectionForeground() : table.getForeground()));
   return component;
 }
예제 #6
0
 /** 删除 */
 private void processDeleteEvent() {
   int index = timeTable.getSelectedRow();
   if (index == -1) return;
   JTimeTableModel model = (JTimeTableModel) timeTable.getModel();
   if (index < model.timeList.size()) model.timeList.removeElementAt(index);
   timeTable.updateUI();
 }
예제 #7
0
  /** 编辑 */
  private void processEditEvent() {
    int count = timeTable.getModel().getRowCount();
    if (count == 0) return;
    int index = timeTable.getSelectedRow();
    if (index < 0) return;
    JTimeTableModel model = (JTimeTableModel) timeTable.getModel();
    JCTimeObject obj = (JCTimeObject) model.timeList.get(index);

    Frame frame = JActiveDComDM.MainApplication.MainWindow;
    JManageCTimeDialog actionDlg;
    actionDlg = new JManageCTimeDialog(frame, "编辑时间方案", true);
    actionDlg.setSize(480, 310);
    actionDlg.CenterWindow();
    actionDlg.setCTimeObject(obj);
    actionDlg.setVisible(true);
    if (actionDlg.OPTION == actionDlg.OPTION_OK) {
      timeTable.getModel().setValueAt(actionDlg.getCTimeObject(), index, 0);
      timeTable.updateUI();
    }
  }
  @NotNull
  private static MyModel setTableModel(
      @NotNull JTable table,
      @NotNull UsageViewImpl usageView,
      @NotNull final List<UsageNode> data) {
    ApplicationManager.getApplication().assertIsDispatchThread();
    final int columnCount = calcColumnCount(data);
    MyModel model = table.getModel() instanceof MyModel ? (MyModel) table.getModel() : null;
    if (model == null || model.getColumnCount() != columnCount) {
      model = new MyModel(data, columnCount);
      table.setModel(model);

      ShowUsagesTableCellRenderer renderer = new ShowUsagesTableCellRenderer(usageView);
      for (int i = 0; i < table.getColumnModel().getColumnCount(); i++) {
        TableColumn column = table.getColumnModel().getColumn(i);
        column.setCellRenderer(renderer);
      }
    }
    return model;
  }
예제 #9
0
 /** 改变ScheduleObject对象. */
 private void processTaskTable() {
   Vector v = getCTimeList();
   if (taskTable == null) return;
   int index = taskTable.getSelectedRow();
   if (index > -1) {
     JTaskTableModel model = (JTaskTableModel) taskTable.getModel();
     JTaskObject task = (JTaskObject) model.taskList.get(index);
     task.schedule.modeContent = v;
     model.setValueAt(task, index, 0);
   }
 }
예제 #10
0
  protected void moveSelectedRow(JTable from, JTable to) {

    SimpleColorTableModel fromModel = (SimpleColorTableModel) from.getModel();
    SimpleColorTableModel toModel = (SimpleColorTableModel) to.getModel();

    for (int index : from.getSelectedRows()) {

      Vector rowValue = (Vector) fromModel.getDataVector().get(index);

      toModel.addRow(rowValue);
    }

    int selectedRow = -1;
    while ((selectedRow = from.getSelectedRow()) != -1) {

      fromModel.removeRow(selectedRow);
    }

    from.clearSelection();
  }
예제 #11
0
 @Override
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   JLabel l =
       (JLabel)
           tcr.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
   PluginTableModel model = (PluginTableModel) table.getModel();
   Icon icon =
       (column == model.sortType) ? (model.sortDirection == 1) ? ASC_ICON : DESC_ICON : null;
   l.setIcon(icon);
   // l.setHorizontalTextPosition(l.LEADING);
   return l;
 }
예제 #12
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 updateMetricsResults(
     MetricsRun run, MetricDisplaySpecification displaySpecification) {
   final MetricCategory[] categories = MetricCategory.values();
   for (final MetricCategory category : categories) {
     final JTable table = tables.get(category);
     final MetricTableModel model = (MetricTableModel) table.getModel();
     model.setResults(run.getResultsForCategory(category));
     final String shortName = MetricsCategoryNameUtil.getShortNameForCategory(category);
     setRenderers(table, shortName);
     final MetricTableSpecification specification =
         displaySpecification.getSpecification(category);
     setColumnWidths(table, specification);
   }
 }
예제 #14
0
 /** 增加 */
 private void processAddEvent() {
   Frame frame = JActiveDComDM.MainApplication.MainWindow;
   JManageCTimeDialog ctimeDlg;
   ctimeDlg = new JManageCTimeDialog(frame, "添加时间方案", true);
   ctimeDlg.setSize(480, 310);
   ctimeDlg.setMinimumSize(480, 310);
   ctimeDlg.CenterWindow();
   ctimeDlg.setVisible(true);
   if (ctimeDlg.OPTION == ctimeDlg.OPTION_OK) {
     int index = timeTable.getRowCount();
     timeTable.getModel().setValueAt(ctimeDlg.getCTimeObject(), index, 0);
     timeTable.updateUI();
   }
 }
  public void fixSelection(int rows[]) {
    if (rows.length == 0) return;

    table.getSelectionModel().setValueIsAdjusting(true);

    int rowcount = table.getModel().getRowCount();

    for (int x = 0; x < rows.length; x++) {
      if (rows[x] < rowcount) {
        table.getSelectionModel().addSelectionInterval(rows[x], rows[x]);
      }
    }

    table.getSelectionModel().setValueIsAdjusting(false);
  }
    @NotNull
    @Override
    public Component getTableCellRendererComponent(
        @NotNull JTable table,
        Object value,
        boolean isSelected,
        boolean hasFocus,
        int row,
        int column) {
      final RegistryValue v = ((MyTableModel) table.getModel()).getRegistryValue(row);
      myLabel.setIcon(null);
      myLabel.setText(null);
      myLabel.setHorizontalAlignment(SwingConstants.LEFT);
      Color fg = isSelected ? table.getSelectionForeground() : table.getForeground();
      Color bg = isSelected ? table.getSelectionBackground() : table.getBackground();

      if (v != null) {
        switch (column) {
          case 0:
            myLabel.setIcon(v.isRestartRequired() ? RESTART_ICON : null);
            myLabel.setHorizontalAlignment(SwingConstants.CENTER);
            break;
          case 1:
            myLabel.setText(v.getKey());
            break;
          case 2:
            if (v.asColor(null) != null) {
              myLabel.setIcon(createColoredIcon(v.asColor(null)));
            } else if (v.isBoolean()) {
              final JCheckBox box = new JCheckBox();
              box.setSelected(v.asBoolean());
              box.setBackground(bg);
              return box;
            } else {
              myLabel.setText(v.asString());
            }
        }

        myLabel.setOpaque(true);

        myLabel.setFont(
            myLabel.getFont().deriveFont(v.isChangedFromDefault() ? Font.BOLD : Font.PLAIN));
        myLabel.setForeground(fg);
        myLabel.setBackground(bg);
      }

      return myLabel;
    }
  private static void setColumnWidths(JTable table, MetricTableSpecification tableSpecification) {
    final TableModel model = table.getModel();
    final TableColumnModel columnModel = table.getColumnModel();

    final List<Integer> columnWidths = tableSpecification.getColumnWidths();
    final List<String> columnOrder = tableSpecification.getColumnOrder();
    if (columnWidths != null && !columnWidths.isEmpty()) {

      final int columnCount = model.getColumnCount();
      for (int i = 0; i < columnCount; i++) {
        final String columnName = model.getColumnName(i);
        final int index = columnOrder.indexOf(columnName);
        if (index != -1) {
          final Integer width = columnWidths.get(index);
          final TableColumn column = columnModel.getColumn(i);
          column.setPreferredWidth(width.intValue());
        }
      }
    } else {
      final Graphics graphics = table.getGraphics();
      final Font font = table.getFont();
      final FontMetrics fontMetrics = table.getFontMetrics(font);

      final int rowCount = model.getRowCount();
      int maxFirstColumnWidth = 100;
      for (int i = 0; i < rowCount; i++) {
        final String name = (String) model.getValueAt(i, 0);
        if (name != null) {
          final Rectangle2D stringBounds = fontMetrics.getStringBounds(name, graphics);
          final double stringWidth = stringBounds.getWidth();
          if (stringWidth > maxFirstColumnWidth) {
            maxFirstColumnWidth = (int) stringWidth;
          }
        }
      }

      final int allocatedFirstColumnWidth = Math.min(300, maxFirstColumnWidth + 5);
      final TableColumn column = columnModel.getColumn(0);
      column.setPreferredWidth(allocatedFirstColumnWidth);
    }
  }
예제 #18
0
    @Override
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
      Component result =
          super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
      if (!isSelected) {
        MyTableModel tableModel = (MyTableModel) table.getModel();
        Color color = table.getBackground();

        switch (tableModel.getKind(row)) {
          case ERROR:
            color = new Color(255, 175, 175);
            break;
          case CONFLICT:
            color = new Color(255, 240, 240);
            break;
        }
        result.setBackground(color);
      }
      return result;
    }
 public void removeDiffOverlay(MetricDisplaySpecification displaySpecification) {
   final MetricCategory[] categories = MetricCategory.values();
   for (final MetricCategory category : categories) {
     final JTable table = tables.get(category);
     final MetricTableModel model = (MetricTableModel) table.getModel();
     model.setPrevResults(null);
     final Container tab = table.getParent().getParent();
     if (model.getRowCount() == 0) {
       tabbedPane.remove(tab);
       continue;
     }
     final String longName = MetricsCategoryNameUtil.getLongNameForCategory(category);
     tabbedPane.add(tab, longName);
     final String shortName = MetricsCategoryNameUtil.getShortNameForCategory(category);
     setRenderers(table, shortName);
     final MetricTableSpecification specification =
         displaySpecification.getSpecification(category);
     setColumnWidths(table, specification);
   }
   hasOverlay = false;
 }
 private static void setRenderers(JTable table, String type) {
   final MetricTableModel model = (MetricTableModel) table.getModel();
   final MetricInstance[] metrics = model.getMetricsInstances();
   Arrays.sort(metrics, new MetricInstanceAbbreviationComparator());
   final TableColumnModel columnModel = table.getColumnModel();
   for (int i = 0; i < model.getColumnCount(); i++) {
     final String columnName = model.getColumnName(i);
     final TableColumn column = columnModel.getColumn(i);
     if (columnName.equals(type)) {
       column.setCellRenderer(new MetricCellRenderer(null));
       column.setHeaderRenderer(new HeaderRenderer(null, model, SwingConstants.LEFT));
     } else {
       final MetricInstance metricInstance = model.getMetricForColumn(i);
       final TableCellRenderer renderer = new MetricCellRenderer(metricInstance);
       column.setCellRenderer(renderer);
       final Metric metric = metricInstance.getMetric();
       final String displayName = metric.getDisplayName();
       column.setHeaderRenderer(new HeaderRenderer(displayName, model, SwingConstants.RIGHT));
     }
   }
 }
예제 #21
0
  public prueba() {
    setBorder(new LineBorder(new Color(0, 0, 0), 2, true));

    setBounds(0, 0, 800, 600);
    setOpaque(false);

    setLayout(null);

    JScrollPane scrollPane_1 = new JScrollPane();
    scrollPane_1.setBounds(new Rectangle(500, 0, 250, 400));
    scrollPane_1.setBounds(50, 50, 650, 450);
    add(scrollPane_1);
    leftTable = new JTable(new SimpleColorTableModel());
    leftTable.setBackground(new Color(153, 204, 255));
    scrollPane_1.setViewportView(leftTable);

    setupTable(leftTable);

    populate((SimpleColorTableModel) leftTable.getModel());

    setSize(800, 600);
  }
예제 #22
0
 @Nullable
 public Component getTableCellEditorComponent(
     JTable table, Object value, boolean isSelected, int row, int column) {
   myValue = ((MyTableModel) table.getModel()).getRegistryValue(row);
   if (myValue.asColor(null) != null) {
     final Color color =
         ColorChooser.chooseColor(
             table, "Choose color", ((RegistryValue) value).asColor(Color.WHITE));
     if (color != null) {
       myValue.setValue(color.getRed() + "," + color.getGreen() + "," + color.getBlue());
     }
     return null;
   } else if (myValue.isBoolean()) {
     myCheckBox.setSelected(myValue.asBoolean());
     myCheckBox.setBackground(table.getBackground());
     return myCheckBox;
   } else {
     myField.setText(myValue.asString());
     myField.setBorder(null);
     myField.selectAll();
     return myField;
   }
 }
예제 #23
0
 void jbInit() throws Exception {
   panel1.setLayout(borderLayout1);
   jPanel1.setBorder(BorderFactory.createEtchedBorder());
   jPanel1.setPreferredSize(new Dimension(14, 100));
   jPanel1.setLayout(borderLayout2);
   jPanel2.setBorder(BorderFactory.createEtchedBorder());
   jPanel2.setPreferredSize(new Dimension(10, 40));
   jPanel2.setLayout(gridBagLayout1);
   jLabel2.setText("Oznaka banke:");
   bPronadji.setPreferredSize(new java.awt.Dimension(80, 27));
   bPronadji.setText("Pronadji ");
   bPronadji.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           bPronadji_actionPerformed(e);
         }
       });
   bIzlaz.setPreferredSize(new Dimension(80, 27));
   bIzlaz.setText("Izlaz");
   bIzlaz.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           bIzlaz_actionPerformed(e);
         }
       });
   txtOznakaBanke.setPreferredSize(new Dimension(120, 21));
   getContentPane().add(panel1);
   panel1.add(jPanel1, BorderLayout.NORTH);
   {
     jLabel1 = new JLabel();
     jPanel1.add(jLabel1, BorderLayout.CENTER);
     jLabel1.setText("PREGLED FILIJALA BANKE");
     jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 18));
     jLabel1.setPreferredSize(new java.awt.Dimension(588, 96));
     jLabel1.setHorizontalTextPosition(SwingConstants.CENTER);
     jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
     jLabel1.setVerticalAlignment(SwingConstants.TOP);
     {
       jLabel3 = new JLabel();
       jLabel1.add(jLabel3);
       jLabel3.setText("NAZIV:");
       jLabel3.setBounds(7, 49, 42, 28);
       jLabel3.setFont(new java.awt.Font("Times New Roman", 1, 12));
     }
     {
       jLabel4 = new JLabel();
       jLabel1.add(jLabel4);
       jLabel4.setText("ADRESA:");
       jLabel4.setBounds(280, 49, 63, 28);
       jLabel4.setFont(new java.awt.Font("Times New Roman", 1, 12));
     }
     {
       jLnazivBanke = new JLabel();
       jLabel1.add(jLnazivBanke);
       jLnazivBanke.setBounds(56, 49, 203, 28);
     }
     {
       jLadresaBanke = new JLabel();
       jLabel1.add(jLadresaBanke);
       jLadresaBanke.setBounds(336, 49, 238, 28);
     }
   }
   panel1.add(jPanel2, BorderLayout.SOUTH);
   jPanel2.add(
       jLabel2,
       new GridBagConstraints(
           0,
           0,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.NONE,
           new Insets(0, 0, 0, 0),
           0,
           0));
   jPanel2.add(
       txtOznakaBanke,
       new GridBagConstraints(
           1,
           0,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.WEST,
           GridBagConstraints.NONE,
           new Insets(0, 10, 0, 0),
           0,
           0));
   jPanel2.add(
       bPronadji,
       new GridBagConstraints(
           5,
           0,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.NONE,
           new Insets(0, 10, 0, 0),
           0,
           0));
   jPanel2.add(
       bIzlaz,
       new GridBagConstraints(
           5,
           0,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.NONE,
           new Insets(0, 200, 0, 0),
           0,
           0));
   panel1.add(jScrollPane1, BorderLayout.CENTER);
   jScrollPane1.getViewport().add(tabBanke, null);
   TModelPrijave tMP = new TModelPrijave(tabBanke);
   tabBanke.setModel(tMP);
   ((TModelPrijave) tabBanke.getModel()).initColumns();
 }