/** Listener to handle button actions */
 public void actionPerformed(ActionEvent e) {
   // Check if the user changed the service filter option
   if (e.getSource() == service_box) {
     service_list.setEnabled(service_box.isSelected());
     service_list.clearSelection();
     remove_service_button.setEnabled(false);
     add_service_field.setEnabled(service_box.isSelected());
     add_service_field.setText("");
     add_service_button.setEnabled(false);
   }
   // Check if the user pressed the add service button
   if ((e.getSource() == add_service_button) || (e.getSource() == add_service_field)) {
     String text = add_service_field.getText();
     if ((text != null) && (text.length() > 0)) {
       service_data.addElement(text);
       service_list.setListData(service_data);
     }
     add_service_field.setText("");
     add_service_field.requestFocus();
   }
   // Check if the user pressed the remove service button
   if (e.getSource() == remove_service_button) {
     Object[] sels = service_list.getSelectedValues();
     for (int i = 0; i < sels.length; i++) {
       service_data.removeElement(sels[i]);
     }
     service_list.setListData(service_data);
     service_list.clearSelection();
   }
 }
 public void setValueAt(Object value, int row, int col) {
   if (rowData.size() > row && row >= 0) {
     Object[] data = (Object[]) rowData.get(row);
     data[col] = value;
   }
   fireTableCellUpdated(row, col);
 }
    public void actionPerformed(java.awt.event.ActionEvent arg0) {
      if (JTable1.getSelectedRowCount() != 1) {
        Utilities.errorMessage(resourceBundle.getString("Please select a view to delete"));
        return;
      }

      if (JOptionPane.showConfirmDialog(
              null,
              resourceBundle.getString("Are you sure you want to delete the selected view "),
              resourceBundle.getString("Warning!"),
              JOptionPane.YES_NO_OPTION,
              JOptionPane.WARNING_MESSAGE,
              null)
          == JOptionPane.NO_OPTION) return;

      Vector viewvec = model.getAllViews();
      for (int i = 0; i < viewvec.size(); i++) {
        String viewname = ((AuthViewWithOperations) viewvec.elementAt(i)).getAuthorizedViewName();
        if (JTable1.getValueAt(JTable1.getSelectedRow(), 0).toString().equals(viewname)) {
          AuthViewWithOperations avop = (AuthViewWithOperations) viewvec.elementAt(i);

          model.delViewOp(
              avop.getAuthorizedViewName(), avop.getViewProperties(), avop.getOperations());
        }
      }

      disableButtons();
    }
 @Override
 public void onCommand(String command) {
   String[] parts = command.split(" ");
   if (parts[0].equalsIgnoreCase("blockid")
       && parts.length == 2
       && StringTools.isInteger(parts[1])) {
     synchronized (lock) {
       blockID = Integer.parseInt(parts[1]);
       JTable list = ui.getList();
       DefaultTableModel model = (DefaultTableModel) list.getModel();
       Vector<?> dataVector = model.getDataVector();
       dataVector.clear();
       model.fireTableDataChanged();
       displayText(ChatColor.GRAY + "Block ID for searching is now " + ChatColor.GOLD + blockID);
     }
   } else if (parts[0].equalsIgnoreCase("blockradius")
       && parts.length == 2
       && StringTools.isInteger(parts[1])) {
     synchronized (lock) {
       radius = Integer.parseInt(parts[1]);
       displayText(
           ChatColor.GRAY + "Block radius for searching is now " + ChatColor.GOLD + radius);
     }
   }
 }
 public void actionPerformed(ActionEvent evt) {
   // 删除原来的JTable(JTable使用scrollPane来包装)
   if (scrollPane != null) {
     jf.remove(scrollPane);
   }
   try (
   // 根据用户输入的SQL执行查询
   ResultSet rs = stmt.executeQuery(sqlField.getText())) {
     // 取出ResultSet的MetaData
     ResultSetMetaData rsmd = rs.getMetaData();
     Vector<String> columnNames = new Vector<>();
     Vector<Vector<String>> data = new Vector<>();
     // 把ResultSet的所有列名添加到Vector里
     for (int i = 0; i < rsmd.getColumnCount(); i++) {
       columnNames.add(rsmd.getColumnName(i + 1));
     }
     // 把ResultSet的所有记录添加到Vector里
     while (rs.next()) {
       Vector<String> v = new Vector<>();
       for (int i = 0; i < rsmd.getColumnCount(); i++) {
         v.add(rs.getString(i + 1));
       }
       data.add(v);
     }
     // 创建新的JTable
     JTable table = new JTable(data, columnNames);
     scrollPane = new JScrollPane(table);
     // 添加新的Table
     jf.add(scrollPane);
     // 更新主窗口
     jf.validate();
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
 public int submit() {
   String newName = produktgruppeFormular.nameField.getText();
   if (isProdGrAlreadyKnown(newName)) {
     // not allowed: changing name to one that is already registered in DB
     JOptionPane.showMessageDialog(
         this,
         "Fehler: Produktgruppe '" + newName + "' bereits vorhanden!",
         "Info",
         JOptionPane.INFORMATION_MESSAGE);
     produktgruppeFormular.nameField.setText("");
     return 0;
   }
   Integer parentProdGrID =
       produktgruppeFormular.parentProdGrIDs.get(
           produktgruppeFormular.parentProdGrBox.getSelectedIndex());
   Vector<Integer> idsNew = produktgruppeFormular.idsOfNewProdGr(parentProdGrID);
   Integer topID = idsNew.get(0);
   Integer subID = idsNew.get(1);
   Integer subsubID = idsNew.get(2);
   Integer mwstID =
       produktgruppeFormular.mwstIDs.get(produktgruppeFormular.mwstBox.getSelectedIndex());
   Integer pfandID =
       produktgruppeFormular.pfandIDs.get(produktgruppeFormular.pfandBox.getSelectedIndex());
   return insertNewProdGr(topID, subID, subsubID, newName, mwstID, pfandID);
 }
    public void actionPerformed(java.awt.event.ActionEvent arg0) {

      if (JTable1.getSelectedRowCount() != 1) {

        Utilities.errorMessage(resourceBundle.getString("Please select a view to edit"));
        return;
      }

      views = new ViewsWizard(ViewConfig.this, applet);
      views.setSecurityModel(model);
      Point p = JLabel1.getLocationOnScreen();
      views.setLocation(p);
      views.init();

      views.setState(false);
      Vector viewvec = model.getAllViews();
      for (int i = 0; i < viewvec.size(); i++) {
        String viewname = ((AuthViewWithOperations) viewvec.elementAt(i)).getAuthorizedViewName();
        if (JTable1.getValueAt(JTable1.getSelectedRow(), 0).toString().equals(viewname)) {
          views.setValues((AuthViewWithOperations) viewvec.elementAt(i));
        }
      }

      disableButtons();
      views.setVisible(true);
    }
 /** Get row count (part of table model interface) */
 public int getRowCount() {
   int count = data.size();
   if (filter_data != null) {
     count = filter_data.size();
   }
   return count;
 }
 /** Constructor */
 public SOAPMonitorFilter() {
   // By default, exclude NotificationService and
   // EventViewerService messages
   filter_exclude_list = new Vector();
   filter_exclude_list.addElement("NotificationService");
   filter_exclude_list.addElement("EventViewerService");
 }
  /**
   * Constructs a <code>VariabilityRecordTable</code> with a list of variability records.
   *
   * @param record_list the list of variability records.
   * @param desktop the parent desktop.
   */
  public VariabilityRecordTable(Vector record_list, net.aerith.misao.gui.Desktop desktop) {
    this.record_list = record_list;
    this.desktop = desktop;

    index = new ArrayIndex(record_list.size());

    model = new DefaultTableModel(column_names, 0);
    Object[] objects = new Object[column_names.length];
    objects[0] = new Boolean(true);
    for (int i = 1; i < column_names.length; i++) objects[i] = "";
    for (int i = 0; i < record_list.size(); i++) model.addRow(objects);
    setModel(model);

    column_model = (DefaultTableColumnModel) getColumnModel();
    for (int i = 1; i < column_names.length; i++)
      column_model
          .getColumn(i)
          .setCellRenderer(
              new StringRenderer(column_names[i], LabelTableCellRenderer.MODE_MULTIPLE_SELECTION));

    initializeCheckColumn();

    setTableHeader(new TableHeader(column_model));

    setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    initializeColumnWidth();

    pane = this;

    initPopupMenu();
  }
Exemple #11
0
 // add new Chef
 public void add(Chef chef) {
   _entries.addElement(chef);
   int index = _entries.size() - 1;
   _chefsByName.put(chef.getName(), new Integer(index));
   // tell TableView to update
   fireTableRowsInserted(index, index);
   fireTableRowsUpdated(index, index);
 }
Exemple #12
0
  /** Sets the call stack with the given vector of method names. */
  public void setContents(Vector newMethodNames) {
    methodNames = (Vector) newMethodNames.clone();
    callStackTable.revalidate();

    Rectangle r = callStackTable.getCellRect(newMethodNames.size() - 1, 0, true);
    callStackTable.scrollRectToVisible(r);
    repaint();
  }
 public AttributiveCellTableModel(int numRows, int numColumns) {
   Vector names = new Vector(numColumns);
   names.setSize(numColumns);
   setColumnIdentifiers(names);
   dataVector = new Vector();
   setNumRows(numRows);
   cellAtt = new DefaultCellAttribute(numRows, numColumns);
 }
 /** Get the data for a row */
 public SOAPMonitorData getData(int row) {
   SOAPMonitorData soap = null;
   if (filter_data == null) {
     soap = (SOAPMonitorData) data.elementAt(row);
   } else {
     soap = (SOAPMonitorData) filter_data.elementAt(row);
   }
   return soap;
 }
 /** Find the row in the table for a given message id */
 public int findRow(SOAPMonitorData soap) {
   int row = -1;
   if (filter_data != null) {
     row = filter_data.indexOf(soap);
   } else {
     row = data.indexOf(soap);
   }
   return row;
 }
 /**
  * moveData
  *
  * @param curRow Old row for the data
  * @param newRow New row for the data
  */
 private void moveData(int curRow, int newRow) {
   int lastRow = rowData.size() - 1;
   if (curRow >= 0 && curRow <= lastRow && newRow >= 0 && newRow <= lastRow) {
     Object[] curData = (Object[]) rowData.elementAt(curRow);
     rowData.removeElementAt(curRow);
     rowData.insertElementAt(curData, newRow);
     fireTableDataChanged();
   }
 }
 /** Find the data for a given id */
 public SOAPMonitorData findData(Long id) {
   SOAPMonitorData soap = null;
   for (int row = data.size(); (row > 0) && (soap == null); row--) {
     soap = (SOAPMonitorData) data.elementAt(row - 1);
     if (soap.getId().longValue() != id.longValue()) {
       soap = null;
     }
   }
   return soap;
 }
 /** Sets the pins list's contents with the given vector of PartPinInfo objects. */
 public void setContents(Vector newPins) {
   partPins = new PartPinInfo[newPins.size()];
   valuesStr = new String[newPins.size()];
   newPins.toArray(partPins);
   for (int i = 0; i < partPins.length; i++)
     valuesStr[i] = Format.translateValueToString(partPins[i].value, dataFormat);
   pinsTable.clearSelection();
   pinsTable.revalidate();
   repaint();
 }
 /**
  * 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;
 }
Exemple #20
0
 public Object getValueAt(int rowIndex, int columnIndex) {
   if (timeList != null) {
     if (rowIndex < timeList.size()) {
       JCTimeObject ctObj = (JCTimeObject) timeList.get(rowIndex);
       if (columnIndex == 0) {
         return ctObj.toString();
       }
     }
   }
   return null;
 }
 public void updateTableData() {
   // we need to get the stored filters
   Object[] row_data;
   rowData.removeAllElements();
   for (Iterator it = m_filters.keySet().iterator(); it.hasNext(); ) {
     row_data = new Object[2];
     row_data[0] = it.next();
     row_data[1] = m_filters.get(row_data[0]);
     rowData.add(row_data);
   }
   fireTableDataChanged();
 }
 /** Remove a message from the table */
 public void removeRow(int row) {
   SOAPMonitorData soap = null;
   if (filter_data == null) {
     soap = (SOAPMonitorData) data.elementAt(row);
     data.remove(soap);
   } else {
     soap = (SOAPMonitorData) filter_data.elementAt(row);
     filter_data.remove(soap);
     data.remove(soap);
   }
   fireTableRowsDeleted(row, row);
 }
 private void addNewRow() {
   Object[] row_data = new Object[2];
   if (rowData.size() < 1) { // add a new html filter
     row_data[0] = "text/html";
   } else {
     row_data[0] = "Enter MIME type";
   }
   row_data[1] = "Replace with " + mimeTypeEditorBuilder.getValueClassName() + " class name";
   logger.debug3("Adding new row");
   rowData.add(row_data);
   fireTableDataChanged();
 }
 /** Add data to the table as a new row */
 public void addData(SOAPMonitorData soap) {
   int row = data.size();
   data.addElement(soap);
   if (filter_data != null) {
     if (filterMatch(soap)) {
       row = filter_data.size();
       filter_data.addElement(soap);
       fireTableRowsInserted(row, row);
     }
   } else {
     fireTableRowsInserted(row, row);
   }
 }
 @Override
 public void onStop() {
   commandManager.unregisterListener("blockid");
   commandManager.unregisterListener("blockradius");
   ui.setVisible(false);
   synchronized (lock) {
     JTable list = ui.getList();
     DefaultTableModel model = (DefaultTableModel) list.getModel();
     Vector<?> dataVector = model.getDataVector();
     dataVector.clear();
     model.fireTableDataChanged();
   }
 }
 /** Remove all messages from the table (but leave "most recent") */
 public void clearAll() {
   int last_row = data.size() - 1;
   if (last_row > 0) {
     data.removeAllElements();
     SOAPMonitorData soap = new SOAPMonitorData(null, null, null);
     data.addElement(soap);
     if (filter_data != null) {
       filter_data.removeAllElements();
       filter_data.addElement(soap);
     }
     fireTableDataChanged();
   }
 }
 public Object getValueAt(int nRow, int nCol) {
   if (nRow < 0 || nRow >= getRowCount()) return "";
   if (nCol > 1) {
     return "";
   }
   return rowData.elementAt(nRow);
 }
Exemple #28
0
 public void actionPerformed(ActionEvent e) {
   List<Resource> loadedDocuments;
   try {
     // get all the documents loaded in the system
     loadedDocuments = Gate.getCreoleRegister().getAllInstances("gate.Document");
   } catch (GateException ge) {
     // gate.Document is not registered in creole.xml....what is!?
     throw new GateRuntimeException(
         "gate.Document is not registered in the creole register!\n"
             + "Something must be terribly wrong...take a vacation!");
   }
   Vector<String> docNames = new Vector<String>();
   for (Resource loadedDocument : new ArrayList<Resource>(loadedDocuments)) {
     if (corpus.contains(loadedDocument)) {
       loadedDocuments.remove(loadedDocument);
     } else {
       docNames.add(loadedDocument.getName());
     }
   }
   JList docList = new JList(docNames);
   docList.getSelectionModel().setSelectionInterval(0, docNames.size() - 1);
   docList.setCellRenderer(renderer);
   final JOptionPane optionPane =
       new JOptionPane(
           new JScrollPane(docList), JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
   final JDialog dialog =
       optionPane.createDialog(CorpusEditor.this, "Add document(s) to this corpus");
   docList.addMouseListener(
       new MouseAdapter() {
         public void mouseClicked(MouseEvent e) {
           if (e.getClickCount() == 2) {
             optionPane.setValue(JOptionPane.OK_OPTION);
             dialog.dispose();
           }
         }
       });
   dialog.setVisible(true);
   if (optionPane.getValue().equals(JOptionPane.OK_OPTION)) {
     int[] selectedIndices = docList.getSelectedIndices();
     for (int selectedIndice : selectedIndices) {
       corpus.add((Document) loadedDocuments.get(selectedIndice));
     }
   }
   changeMessage();
 }
  public void setData() {
    /*
       if(model.getAllViews() == null)
    	{
            	return;
    }
    */
    for (int i = JTable1.getRowCount() - 1; i >= 0; i--) {
      ViewTableModel.removeRow(i);
    }

    Vector views = model.getAllViews();
    for (int j = 0; j < views.size(); j++) {
      AuthViewWithOperations view = (AuthViewWithOperations) views.elementAt(j);
      String viewNa = view.getAuthorizedViewName();
      ViewTableModel.addRow(new Object[] {viewNa});
    }
  }
 public void handle(Throwable exception) {
   try {
     if (exception instanceof NullPointerException) {
       synchronized (lock) {
         JTable table = ui.getList();
         DefaultTableModel model = (DefaultTableModel) table.getModel();
         Vector<?> data = model.getDataVector();
         for (int i = 0; i < data.size(); i++) {
           Object row = data.get(i);
           if (row == null) data.remove(i);
         }
       }
     }
     exception.printStackTrace();
   } catch (Throwable exception2) {
     exception.printStackTrace();
   }
 }