Ejemplo n.º 1
0
  /**
   * Mouse Listener Methods Handle double click on the getMulticastGroupConfigTable
   *
   * @param e
   */
  public void mouseClicked(MouseEvent e) {
    if (e.getClickCount() == 2) {
      JTable target = (JTable) e.getSource();

      int row = target.getSelectedRow();

      if (e.getSource() != this.multicastConnectivityPanel.getMulticastGroupConfigTable()) {
        System.err.println("Non standard table");
        return;
      }

      if (row < 0) {
        return;
      }

      int modelIndex = target.convertRowIndexToModel(row);

      MulticastGroupConfigModel model = (MulticastGroupConfigModel) target.getModel();

      MulticastChannelPairInfo info = model.getMulticastChannelPairInfo(modelIndex);

      chooseConfiguration();

      this.dispose();
    }

    return;
  }
Ejemplo n.º 2
0
  public JointPriorDialog(JFrame frame, BeautiOptions options) {
    this.frame = frame;

    this.options = options;

    priorSettingsPanel = new PriorSettingsPanel(frame);

    nameField.setColumns(30);

    parametersTableModel = new ParametersTableModel();
    //        TableSorter sorter = new TableSorter(traitsTableModel);
    //        traitsTable = new JTable(sorter);
    //        sorter.setTableHeader(traitsTable.getTableHeader());
    parametersTable = new JTable(parametersTableModel);

    parametersTable.getTableHeader().setReorderingAllowed(false);
    parametersTable.getTableHeader().setResizingAllowed(false);
    //        traitsTable.getTableHeader().setDefaultRenderer(
    //                new HeaderRenderer(SwingConstants.LEFT, new Insets(0, 4, 0, 4)));

    parametersTable
        .getSelectionModel()
        .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    parametersTable
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent evt) {
                parametersSelectionChanged();
              }
            });
  }
  private void createUIComponents() {
    mainPanel = new DollarPanel();

    graphicOfPayments = new JTable();
    JTableHeader header = graphicOfPayments.getTableHeader();
    header.setPreferredSize(new Dimension(graphicOfPayments.getWidth(), HEADERS_HEIGHT));
  }
Ejemplo n.º 4
0
    public JLabelPosition(JTable table) {
      this.table = table;
      setFont(getFont().deriveFont(Font.PLAIN));

      table.addKeyListener(this);
      table.addMouseListener(this);
    }
 public void mousePressed(MouseEvent e) {
   if (e.getButton() != MouseEvent.BUTTON1) {
     return;
   }
   if (e.getClickCount() != 2) {
     return;
   }
   JTable table = (JTable) e.getSource();
   Point p = e.getPoint();
   int row = table.rowAtPoint(p);
   if (row < 0) {
     return;
   }
   PickerTableModel model = getDataModel();
   ICFInternetISOCountryObj o =
       (ICFInternetISOCountryObj) model.getValueAt(row, COLID_ROW_HEADER);
   invokeWhenChosen.choseISOCountry(o);
   try {
     Container cont = getParent();
     while ((cont != null) && (!(cont instanceof JInternalFrame))) {
       cont = cont.getParent();
     }
     if (cont != null) {
       ((JInternalFrame) cont).setClosed(true);
     }
   } catch (Exception x) {
   }
 }
Ejemplo n.º 6
0
  private void createUIComponents() {
    portFreightTableModel = new FreightTableModel(Game.getInstance().getFreightMarket());
    portFreightTable = new JTable(portFreightTableModel);
    TableRowSorter<FreightTableModel> portTableSorter =
        new TableRowSorter<FreightTableModel>(portFreightTableModel);
    portTableSorter.setRowFilter(new FreightTableModel.PortRowFilter(portProxy));
    portFreightTable.setRowSorter(portTableSorter);

    Company playerCompany = Game.getInstance().getPlayerCompany();
    List<ShipModel> shipsInPortList = playerCompany.findShipsInPort(portProxy);

    shipsInPortListBox = new JList(shipsInPortList.toArray());

    // TODO this is fugly-hacked at the moment.
    FreightTableModel shipFreightTableModel = null;

    if (shipsInPortList.size() > 0) {
      shipFreightTableModel = new FreightTableModel(shipsInPortList.get(0));
    } else {
      shipFreightTableModel = new FreightTableModel(null);
    }

    shipFreightTable = new JTable(shipFreightTableModel);
    TableRowSorter<FreightTableModel> shipTableSorter =
        new TableRowSorter<FreightTableModel>(shipFreightTableModel);
    shipFreightTable.setRowSorter(shipTableSorter);

    nameOfPort = new JLabel();
    nameOfPort.setText(portProxy.getName());
  }
Ejemplo n.º 7
0
  private JScrollPane legendChart(int width, int height, List<String> rows) {
    JScrollPane jcp = new JScrollPane();
    DefaultTableModel dtm =
        new DefaultTableModel(
            new Object[][] {}, new String[] {"File", "Bar", "Type Query", "Time(ms)"});
    JTable jt = new JTable();
    jt.setModel(dtm);

    for (String s : rows) {
      if (s != null) {
        String[] vals = s.split("\\|");
        dtm.addRow(new String[] {vals[0], vals[3], vals[1], vals[2]});
      }
    }
    jt.getColumnModel().getColumn(0).setPreferredWidth(200);
    jt.getColumnModel().getColumn(1).setPreferredWidth(50);
    jt.getColumnModel().getColumn(2).setPreferredWidth(50);
    jt.getColumnModel().getColumn(3).setPreferredWidth(50);
    // jt.setEnabled(false);

    jcp.setViewportView(jt);
    jcp.setPreferredSize(new Dimension(width, height));
    jcp.setBackground(Color.WHITE);
    jcp.createHorizontalScrollBar();
    return jcp;
  }
Ejemplo n.º 8
0
  private void createandAddTable(String[][] rowData2, String[] columnNames2) {

    jtNotenAnzeige =
        new JTable(rowData2, columnNames2) {

          private static final long serialVersionUID = 1L;

          public boolean isCellEditable(int row, int column) {
            // set table column uneditable
            return false;
          }
        };
    jtNotenAnzeige.setRowSelectionAllowed(false);
    jtNotenAnzeige.getTableHeader().setReorderingAllowed(false);

    // / scrollPane removen weil dann tabelle !
    if (scrollPane != null) {
      tablePanel.remove(scrollPane);
    }

    scrollPane = new JScrollPane(jtNotenAnzeige);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setBounds(10, 21, 525, 261);
    tablePanel.add(scrollPane);
  }
Ejemplo n.º 9
0
  private void createAndMarkAndAddTable(String[][] rowData2, String[] columnNames2) {

    jtNotenAnzeige =
        new JTable(rowData2, columnNames2) {

          private static final long serialVersionUID = 1L;

          public boolean isCellEditable(int row, int column) {
            return true;
          }
        };

    jtNotenAnzeige.setRowSelectionAllowed(false);
    jtNotenAnzeige.getTableHeader().setReorderingAllowed(false);
    jtNotenAnzeige.setDefaultRenderer(Object.class, new ColorTableCellRenderer());

    if (scrollPane != null) {
      tablePanel.remove(scrollPane);
    }

    scrollPane = new JScrollPane(jtNotenAnzeige);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setBounds(10, 21, 525, 261);
    tablePanel.add(scrollPane);
  }
  public void rellenarTablaPedidos(Object object) {

    tabla = new Tabla();

    tabla.addColumn("ID_PED");
    tabla.addColumn("ID_PROV");
    tabla.addColumn("REALIZ.");
    tabla.addColumn("ENTREG.");
    tabla.addColumn("CANCEL.");

    if (object != null) {

      List<TPedido> lista = (List<TPedido>) object;

      for (TPedido tpedido : lista) {

        fila = new Vector();

        fila.add(tpedido.getId_pedido());
        fila.add(tpedido.getId_proveedor());
        fila.add(tpedido.getFechaRealizado());
        fila.add(tpedido.getFechaEntregado());
        fila.add(tpedido.getFechaCancelado());

        tabla.addRow(fila);
      }
    }

    tbPedidos.setModel(tabla);

    tbPedidos.getColumnModel().getColumn(0).setMaxWidth(60); // ajusta el ancho de las columnas ID
    tbPedidos.getColumnModel().getColumn(1).setMaxWidth(60);

    repaint();
  }
Ejemplo n.º 11
0
    private void initListeners() {
      // install a listener to cause the whole table to repaint when
      // a column is resized. we do this because the extended grid
      // lines may need to be repainted. this could be cleaned up,
      // but for now, it works fine.
      fTable
          .getColumnModel()
          .addColumnModelListener(
              new TableColumnModelListener() {
                @Override
                public void columnMarginChanged(ChangeEvent e) {
                  repaint();
                }

                @Override
                public void columnAdded(TableColumnModelEvent e) {}

                @Override
                public void columnRemoved(TableColumnModelEvent e) {}

                @Override
                public void columnMoved(TableColumnModelEvent e) {}

                @Override
                public void columnSelectionChanged(ListSelectionEvent e) {}
              });
      PropertyChangeListener listener = createTableColumnWidthListener();
      for (int i = 0; i < fTable.getColumnModel().getColumnCount(); i++) {
        fTable.getColumnModel().getColumn(i).addPropertyChangeListener(listener);
      }
    }
Ejemplo n.º 12
0
 private void initUI() {
   tblMain.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   refresh();
   btAdd.addActionListener(
       e -> {
         PropertyForm.start(null);
         refresh();
       });
   btEdit.addActionListener(e -> editAction());
   btRemove.addActionListener(
       e -> {
         Instance instance =
             ((InstanceTableModel) tblMain.getModel()).getItem(tblMain.getSelectedRow());
         if (instance != null && !instance.isNew()) {
           int dialogButton = JOptionPane.YES_NO_OPTION;
           int dialogResult =
               JOptionPane.showConfirmDialog(null, "Remove row ?", "Confirm", dialogButton);
           if (dialogResult == 0) {
             ConfigHelper.getInstance().remove(instance);
             refresh();
           }
         }
       });
   btRun.addActionListener(e -> this.startLoad(this));
   progressBar.setMinimum(0);
   progressBar.setStringPainted(true);
   tblMain.addMouseListener(
       new MouseAdapter() {
         public void mousePressed(MouseEvent me) {
           if (me.getClickCount() == 2) {
             editAction();
           }
         }
       });
 }
Ejemplo n.º 13
0
 private void editAction() {
   if (tblMain.getSelectedRowCount() > 0) {
     PropertyForm.start(
         ((InstanceTableModel) tblMain.getModel()).getItem(tblMain.getSelectedRow()));
     refresh();
   }
 }
Ejemplo n.º 14
0
  private void packColumn(JTable table, int vColIndex, int margin) {
    //		table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    DefaultTableColumnModel colModel = (DefaultTableColumnModel) table.getColumnModel();
    TableColumn col = colModel.getColumn(vColIndex);
    int width = 0;

    // obtiene la anchura de la cabecera de la columna
    TableCellRenderer renderer = col.getHeaderRenderer();
    if (renderer == null) {
      renderer = table.getTableHeader().getDefaultRenderer();
    }
    Component comp =
        renderer.getTableCellRendererComponent(table, col.getHeaderValue(), false, false, 0, 0);
    //		width = comp.getPreferredSize().width;
    width = 5;

    // Obtine la anchura maxima de la coluna de
    for (int r = 0; r < table.getRowCount(); r++) {
      renderer = table.getCellRenderer(r, vColIndex);
      comp =
          renderer.getTableCellRendererComponent(
              table, table.getValueAt(r, vColIndex), false, false, r, vColIndex);
      width = Math.max(width, 0);
    }

    width += 2 * margin;

    // Configura el ancho
    col.setPreferredWidth(width);
  }
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   final Color color = UIUtil.getTableFocusCellBackground();
   Component component;
   final Module module = value instanceof Module ? (Module) value : null;
   try {
     UIManager.put(UIUtil.TABLE_FOCUS_CELL_BACKGROUND_PROPERTY, table.getSelectionBackground());
     component =
         super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
     if (module != null) {
       setText(
           module.getName()
               + " ("
               + FileUtil.toSystemDependentName(module.getModuleFilePath())
               + ")");
     }
     if (component instanceof JLabel) {
       ((JLabel) component).setBorder(noFocusBorder);
     }
   } finally {
     UIManager.put(UIUtil.TABLE_FOCUS_CELL_BACKGROUND_PROPERTY, color);
   }
   component.setEnabled(ProcessedModulesTable.this.isEnabled());
   if (component instanceof JLabel) {
     final Icon icon = module != null ? ModuleType.get(module).getIcon() : null;
     JLabel label = (JLabel) component;
     label.setIcon(icon);
     label.setDisabledIcon(icon);
   }
   component.setForeground(isSelected ? table.getSelectionForeground() : table.getForeground());
   return component;
 }
Ejemplo n.º 16
0
  private void eliminarPersona() {
    try {
      int dialogButton = JOptionPane.YES_NO_OPTION;
      int dialogResult =
          JOptionPane.showConfirmDialog(
              this,
              "¿Esta seguro que desea eliminar el cliente...?",
              "Eliminar Cliente",
              dialogButton);
      if (dialogResult == 0) {
        int dniPersona =
            Integer.parseInt(tblPersonas.getValueAt(tblPersonas.getSelectedRow(), 0).toString());
        personas.setDnipersona(dniPersona);
        impPersonas.delete(personas);
      } else {

      }
    } catch (ArrayIndexOutOfBoundsException e) {
      JOptionPane.showMessageDialog(rootPane, "Primero seleccione el Cliente a eliminar!!!");
    } catch (NumberFormatException e) {
      JOptionPane.showMessageDialog(rootPane, "Error");
    } catch (org.hibernate.exception.ConstraintViolationException e) {
      JOptionPane.showMessageDialog(
          rootPane, "Debe imprimir los Codigos de Barras para poder eliminar...");
    }
  }
Ejemplo n.º 17
0
  public Component getTableCellRendererComponent(
      JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    if (isSelected) {
      setForeground(table.getSelectionForeground());
      setBackground(table.getSelectionBackground());
    } else {
      setForeground(table.getForeground());
      setBackground(table.getBackground());
    }

    String label = "";

    if (value instanceof Integer) {
      int val = ((Integer) value).intValue();

      if (val < 0 || val > 127) {
        label = "";
      } else {
        label = Integer.toString(val);
      }
    }

    this.setText(label);
    return this;
  }
Ejemplo n.º 18
0
  private void modificarPersona() {
    try {
      int dialogButton = JOptionPane.YES_NO_OPTION;
      int dialogResult =
          JOptionPane.showConfirmDialog(
              this,
              "¿Esta seguro que desea eliminar el cliente...?",
              "Eliminar Cliente",
              dialogButton);
      if (dialogResult == 0) {
        int dniPersona =
            Integer.parseInt(tblPersonas.getValueAt(tblPersonas.getSelectedRow(), 0).toString());
        personas.setDnipersona(dniPersona);
        personas.setApellido(txtApellido.getText());
        personas.setNombre(txtNombre.getText());
        personas.setDireccion(txtDireccion.getText());
        personas.setTelefono(txtTelefono.getText());
        personas.setEmail(txtEmail.getText());
        personas.setCuil(txtCuil.getText());
        Date fechaHoy = new Date();
        personas.setFechaalta(fechaHoy);
        personas.setPerfil(cmbPerfil.getSelectedItem().toString());
        impPersonas.update(personas);
      } else {

      }
    } catch (ArrayIndexOutOfBoundsException e) {
      JOptionPane.showMessageDialog(rootPane, "Primero seleccione el Cliente a eliminar!!!");
    } catch (NumberFormatException e) {
      JOptionPane.showMessageDialog(rootPane, "Error");
    } catch (org.hibernate.exception.ConstraintViolationException e) {
      JOptionPane.showMessageDialog(
          rootPane, "Debe imprimir los Codigos de Barras para poder eliminar...");
    }
  }
Ejemplo n.º 19
0
  protected void spendXP() {
    String skillName = (String) choiceSkill.getSelectedItem();
    if (choiceNoSkill.equals(skillName)) {
      // This shouldn't happen, but guard against it anyway.
      return;
    }
    int rows = personnelTable.getRowCount();
    int improvedPersonnelCount = rows;
    while (rows > 0) {
      for (int i = 0; i < rows; ++i) {
        Person p = personnelModel.getPerson(personnelTable.convertRowIndexToModel(i));
        int cost = 0;
        if (p.hasSkill(skillName)) {
          cost = p.getCostToImprove(skillName);
        } else {
          cost = SkillType.getType(skillName).getCost(0);
        }
        int experience = p.getExperienceLevel(false);

        // Improve the skill and deduce the cost
        p.improveSkill(skillName);
        campaign.personUpdated(p);
        p.setXp(p.getXp() - cost);

        // The next part is bollocks and doesn't belong here, but as long as we hardcode AtB ...
        if (campaign.getCampaignOptions().getUseAtB()) {
          if ((p.getPrimaryRole() > Person.T_NONE)
              && (p.getPrimaryRole() <= Person.T_CONV_PILOT)
              && (p.getExperienceLevel(false) > experience)
              && (experience >= SkillType.EXP_REGULAR)) {
            String spa = campaign.rollSPA(p.getPrimaryRole(), p);
            if (null == spa) {
              if (campaign.getCampaignOptions().useEdge()) {
                p.acquireAbility(
                    PilotOptions.EDGE_ADVANTAGES, "edge", p.getEdge() + 1); // $NON-NLS-1$
                p.addLogEntry(
                    campaign.getDate(),
                    String.format(resourceMap.getString("gainedEdge.text"))); // $NON-NLS-1$
              }
            } else {
              p.addLogEntry(
                  campaign.getDate(),
                  String.format(resourceMap.getString("gained.format"), spa)); // $NON-NLS-1$
            }
          }
        }
      }
      // Refresh the filter and continue if we still have anyone available
      updatePersonnelTable();
      rows = personnelTable.getRowCount();
      dataChanged = true;
    }
    if (improvedPersonnelCount > 0) {
      campaign.addReport(
          String.format(
              resourceMap.getString("improvedSkills.format"),
              skillName,
              improvedPersonnelCount)); //$NON-NLS-1$
    }
  }
Ejemplo n.º 20
0
  /**
   * Calculates the optimal width for the header of the given table. The calculation is based on the
   * preferred width of the header renderer.
   *
   * @param table the table to calculate the column width
   * @param col the column to calculate the widths
   * @return the width, -1 if error
   */
  public static int calcHeaderWidth(JTable table, int col) {
    if (table == null) return -1;

    if (col < 0 || col > table.getColumnCount()) {
      System.out.println("invalid col " + col);
      return -1;
    }

    JTableHeader header = table.getTableHeader();
    TableCellRenderer defaultHeaderRenderer = null;
    if (header != null) defaultHeaderRenderer = header.getDefaultRenderer();
    TableColumnModel columns = table.getColumnModel();
    TableModel data = table.getModel();
    TableColumn column = columns.getColumn(col);
    int width = -1;
    TableCellRenderer h = column.getHeaderRenderer();
    if (h == null) h = defaultHeaderRenderer;
    if (h != null) {
      // Not explicitly impossible
      Component c =
          h.getTableCellRendererComponent(table, column.getHeaderValue(), false, false, -1, col);
      width = c.getPreferredSize().width + 5;
    }

    return width;
  }
Ejemplo n.º 21
0
 /**
  * This method initializes ActiveAggTable
  *
  * @return javax.swing.JTable
  */
 private JTable getActiveAggTable() {
   if (ActiveAggTable == null) {
     ActiveAggTable = new JTable();
     controller.activeAgg_ = new ActiveAggTableModel();
     controller.activeAgg_.init(controller);
     ActiveAggTable.setModel(controller.activeAgg_);
     ActiveAggTable.addMouseListener(
         new java.awt.event.MouseAdapter() {
           public void mouseClicked(java.awt.event.MouseEvent e) {
             if (e.getClickCount() == 2) {
               int row = ActiveAggTable.getSelectedRow();
               if (row >= 0) {
                 aggEditorFrame =
                     new AggEditorFrame(
                         (jAudioFeatureExtractor.Aggregators.Aggregator)
                             controller.activeAgg_.getAggregator(row),
                         controller);
                 aggEditorFrame.setVisible(true);
                 ((ActiveAggTableModel) ActiveAggTable.getModel())
                     .setAggregator(
                         row, aggEditorFrame.getAggregator(), aggEditorFrame.isEdited());
               }
             }
           }
         });
   }
   return ActiveAggTable;
 }
  /*
   * Update radio button names in the same order as the table
   */
  private void updateControlPanel() {
    schedule.removeAll();
    noneButton.setName(""); // Name holds schedule id for the selected radio button
    noneButton.setSelected(true);
    commentTextArea.setText(""); // no text for the noneButton
    enableButtons(false);
    schedule.add(noneButton);
    schGroup.add(noneButton);

    for (int i = trainsScheduleModel.getFixedColumn();
        i < trainsScheduleModel.getColumnCount();
        i++) {
      log.debug("Column name: {}", trainsScheduleTable.getColumnName(i));
      TrainSchedule ts =
          trainScheduleManager.getScheduleByName(trainsScheduleTable.getColumnName(i));
      if (ts != null) {
        JRadioButton b = new JRadioButton();
        b.setText(ts.getName());
        b.setName(ts.getId());
        schedule.add(b);
        schGroup.add(b);
        addRadioButtonAction(b);
        if (b.getName().equals(trainManager.getTrainScheduleActiveId())) {
          b.setSelected(true);
          enableButtons(true);
          // update comment field
          commentTextArea.setText(ts.getComment());
        }
      }
    }
    schedule.revalidate();
  }
 public void mousePressed(MouseEvent e) {
   if (e.getButton() != MouseEvent.BUTTON1) {
     return;
   }
   if (e.getClickCount() != 2) {
     return;
   }
   JTable table = (JTable) e.getSource();
   Point p = e.getPoint();
   int row = table.rowAtPoint(p);
   if (row < 0) {
     return;
   }
   FinderTableModel model = getDataModel();
   ICFSecurityISOTimezoneObj o =
       (ICFSecurityISOTimezoneObj) model.getValueAt(row, COLID_ROW_HEADER);
   if (o == null) {
     return;
   }
   JInternalFrame frame = swingSchema.getISOTimezoneFactory().newViewEditJInternalFrame(o);
   ((ICFSecuritySwingISOTimezoneJPanelCommon) frame).setPanelMode(CFJPanel.PanelMode.View);
   if (frame == null) {
     return;
   }
   Container cont = getParent();
   while ((cont != null) && (!(cont instanceof JInternalFrame))) {
     cont = cont.getParent();
   }
   if (cont != null) {
     JInternalFrame myInternalFrame = (JInternalFrame) cont;
     myInternalFrame.getDesktopPane().add(frame);
     frame.setVisible(true);
     frame.show();
   }
 }
 public ReceiveAddressDialog(JDialog parent) {
   super(parent, "Receive Addresses", Dialog.ModalityType.DOCUMENT_MODAL);
   setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
   tableModel = new AddressTableModel(columnNames, columnClasses);
   table = new AddressTable(tableModel, columnTypes);
   table.setRowSorter(new TableRowSorter<>(tableModel));
   table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   scrollPane = new JScrollPane(table);
   JPanel tablePane = new JPanel();
   tablePane.setBackground(Color.WHITE);
   tablePane.add(Box.createGlue());
   tablePane.add(scrollPane);
   tablePane.add(Box.createGlue());
   JPanel buttonPane =
       new ButtonPane(
           this,
           10,
           new String[] {"New", "new"},
           new String[] {"Copy", "copy"},
           new String[] {"Edit", "edit"},
           new String[] {"Done", "done"});
   buttonPane.setBackground(Color.white);
   JPanel contentPane = new JPanel();
   contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
   contentPane.setOpaque(true);
   contentPane.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15));
   contentPane.setBackground(Color.WHITE);
   contentPane.add(tablePane);
   contentPane.add(buttonPane);
   setContentPane(contentPane);
 }
Ejemplo n.º 25
0
    @Override
    protected void showPopupMenu(MouseEvent ev) {
      // first select/deselect the row:
      int iRow = tblTasks.rowAtPoint(ev.getPoint());

      // Nur, wenn nicht selektiert, selektieren:
      if (!tblTasks.isRowSelected(iRow)) {
        if ((ev.getModifiers() & MouseEvent.CTRL_MASK) != 0) {
          // Control gedr\u00fcckt:
          // Zeile zur Selektion hinzuf\u00fcgen:
          tblTasks.addRowSelectionInterval(iRow, iRow);
        } else {
          // Sonst nur diese Zeile selektieren:
          tblTasks.setRowSelectionInterval(iRow, iRow);
        }
      } // if

      // enable/disable menu items
      final int iSelectedRow = this.tblTasks.getSelectedRow();
      final TimelimitTaskTableModel model = timelimittaskview.getTimelimitTaskTableModel();
      model.getTimelimitTask(iSelectedRow);

      // todo: there should be a better place for that...
      final boolean bPerformEnabled =
          existsRelatedObjectsFor(getSelectedTimelimitTasks(timelimittaskview));
      actPerformTask.setEnabled(bPerformEnabled);
      // this.popupTimelimitTasks.miPerform.setEnabled(bPerformEnabled);

      final boolean bFinished = areTasksCompleted(getSelectedTimelimitTasks(timelimittaskview));
      this.popupTimelimitTasks.miFinish.setState(bFinished);

      super.showPopupMenu(ev);
    }
Ejemplo n.º 26
0
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   if (row < tv.getRowData().size()) {
     Vector line = (Vector) tv.getRowData().get(row);
     if (value != null) {
       setText(value.toString());
     }
     this.setOpaque(true);
     String searchStr = tv.getSearchString();
     String ceilStr = (String) line.get(column);
     boolean found =
         (searchStr != null
             && searchStr.length() > 0
             && ceilStr.toUpperCase().indexOf(searchStr.toUpperCase()) >= 0);
     Color backColor =
         (row % 2 == 0 && !isSelected)
             ? found ? searchBackColor : stripColor
             : (isSelected
                 ? table.getSelectionBackground()
                 : found ? searchBackColor : table.getBackground());
     Color foreColor =
         isSelected
             ? found ? searchStringColor : table.getSelectionForeground()
             : found ? searchStringColor : table.getForeground();
     setBackground(backColor);
     setForeground(foreColor);
   }
   return this;
 }
Ejemplo n.º 27
0
  /** @param args */
  public static void main(String[] args) {
    Vector<String> names = new Vector<String>(2);
    names.add("Row");
    names.add("Random");

    JTable table = new JTable(getIntData(), names);
    table.setAutoCreateRowSorter(true);
    System.err.println("Sorting JTable (ints):");

    testJTable(table, 4);

    JXTable xTable = new JXTable(table.getModel());
    System.err.println("\nSorting JXTable (ints):");

    testJXTable(xTable, 4);

    table = new JTable(getStringData(), names);
    table.setAutoCreateRowSorter(true);
    System.err.println("\nSorting JTable (strings):");

    testJTable(table, 4);

    xTable = new JXTable(table.getModel());
    System.err.println("\nSorting JXTable (strings):");

    testJXTable(xTable, 4);
  }
Ejemplo n.º 28
0
  /**
   * Adds a new tab to the download dialog in JOSM.
   *
   * <p>This method is, for all intents and purposes, the constructor for this class.
   */
  @Override
  public void addGui(final DownloadDialog gui) {
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add(buildSearchPanel(), BorderLayout.NORTH);

    DefaultListSelectionModel selectionModel = new DefaultListSelectionModel();
    model = new NamedResultTableModel(selectionModel);
    columnmodel = new NamedResultTableColumnModel();
    tblSearchResults = new JTable(model, columnmodel);
    tblSearchResults.setSelectionModel(selectionModel);
    JScrollPane scrollPane = new JScrollPane(tblSearchResults);
    scrollPane.setPreferredSize(new Dimension(200, 200));
    panel.add(scrollPane, BorderLayout.CENTER);

    gui.addDownloadAreaSelector(panel, tr("Areas around places"));

    scrollPane.setPreferredSize(scrollPane.getPreferredSize());
    tblSearchResults.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    tblSearchResults.getSelectionModel().addListSelectionListener(new ListSelectionHandler());
    tblSearchResults.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() > 1) {
              SearchResult sr = model.getSelectedSearchResult();
              if (sr == null) return;
              parent.startDownload(sr.getDownloadArea());
            }
          }
        });
    parent = gui;
  }
Ejemplo n.º 29
0
  public WSPartsTable(List<StringToStringMap> parts, WssEntryBase entry) {
    super(new BorderLayout());
    this.parts = parts;
    this.entry = entry;

    partsTableModel = new PartsTableModel();
    partsTable = new JTable(partsTableModel);
    partsTable
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {

              public void valueChanged(ListSelectionEvent e) {
                removePartButton.setEnabled(partsTable.getSelectedRow() != -1);
              }
            });

    partsTable
        .getColumnModel()
        .getColumn(3)
        .setCellEditor(new DefaultCellEditor(new JComboBox(new String[] {"Content", "Element"})));

    JScrollPane scrollPane = new JScrollPane(partsTable);
    scrollPane.setBackground(Color.WHITE);
    scrollPane.setOpaque(true);
    add(scrollPane, BorderLayout.CENTER);
    add(buildToolbar(), BorderLayout.NORTH);

    setPreferredSize(new Dimension(350, 150));
  }
Ejemplo n.º 30
0
  private void selectInAllMethods(JipMethod selectedMethod) {

    if (selectedMethod == null) {
      mMethods.clearSelection();
      return;
    }

    // which row should we select?
    boolean foundIt = false;
    int nRow = mAllMethodsModel.getRowCount();
    int iRow;
    for (iRow = 0; iRow < nRow; iRow++) {
      MethodRow scan = mAllMethodsModel.getRow(iRow);
      if (scan.getMethod().equals(selectedMethod)) {
        foundIt = true;
        break;
      }
    }
    if (!foundIt) {
      System.out.println("couldn't find " + selectedMethod.getName());
      return;
    }

    // update the listSelectionModel
    int iRowInView = mAllMethodsSorterModel.viewIndex(iRow);
    mMethods.getSelectionModel().setSelectionInterval(iRowInView, iRowInView);

    // scroll to contain the new selection
    Rectangle selectionRect = mMethods.getCellRect(iRowInView, 0, true);
    mMethods.scrollRectToVisible(selectionRect);
  }