private void init_tbl_branch_locations() {
   tbl_branch_locations_ALM = new ArrayListModel();
   tbl_branch_locations_M = new Tblbranch_locationsModel(tbl_branch_locations_ALM);
   tbl_branch_locations.getTableHeader().setPreferredSize(new Dimension(100, 40));
   tbl_branch_locations.setModel(tbl_branch_locations_M);
   tbl_branch_locations.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
   tbl_branch_locations.setRowHeight(25);
   int[] tbl_widths_branch_locations = {200, 200, 70, 0, 0, 0};
   for (int i = 0, n = tbl_widths_branch_locations.length; i < n; i++) {
     if (i == 0) {
       continue;
     }
     TableWidthUtilities.setColumnWidth(tbl_branch_locations, i, tbl_widths_branch_locations[i]);
   }
   Dimension d = tbl_branch_locations.getTableHeader().getPreferredSize();
   d.height = 25;
   tbl_branch_locations.getTableHeader().setPreferredSize(d);
   tbl_branch_locations.getTableHeader().setFont(new java.awt.Font("Arial", 0, 11));
   tbl_branch_locations.setRowHeight(25);
   tbl_branch_locations.setFont(new java.awt.Font("Arial", 0, 11));
 }
  @SuppressWarnings("unchecked")
  private void initComponents() {
    org.jdesktop.application.ResourceMap resourceMap =
        org.jdesktop.application.Application.getInstance(
                insalmo_instream_gui.InsalmoInstreamApp.class)
            .getContext()
            .getResourceMap(ShowErrorsWarnings.class);

    // CLOSE
    closeButton.setName("closeButton");
    closeButton.setText(resourceMap.getString("closeButton.text"));
    closeButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            closeButtonActionPerfomed(evt);
          }
        });

    showErrorWarningsPanel = new javax.swing.JPanel();

    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    setName("showErrorsWarnings");

    // ERROR/WARNING TABLE
    errorTable = this.createXTable();
    errorTable.setName("errorTable");
    errorTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    DefaultTableModel dataModel =
        new DefaultTableModel() {
          Class[] types =
              new Class[] {
                java.lang.String.class,
                java.lang.String.class,
                java.lang.String.class,
                java.lang.String.class,
                java.lang.String.class,
                Parameter.class
              };
          boolean[] canEdit = new boolean[] {false, false, false, false, false, false};

          public Class getColumnClass(int columnIndex) {
            return types[columnIndex];
          }

          public boolean isCellEditable(int rowIndex, int columnIndex) {
            return canEdit[columnIndex];
          }
        };
    dataModel.setColumnIdentifiers(
        new String[] {"", "Parameter", "Value", "Location", "Message", "Parameter Object"});
    for (Parameter p : this.openProject.getErrors()) {
      String filename;
      if (p.getSource().getClass().equals(SetupParameters.class)) {
        filename = ((SetupParameters) p.getSource()).getFileName();
      } else {
        filename = "Experiment.Setup";
      }
      dataModel.addRow(
          new Object[] {
            "Error",
            p.getParameterName(),
            p.getParameterValue(),
            filename,
            p.getValidationMessage(),
            p
          });
    }
    for (Parameter p : this.openProject.getWarnings()) {
      String filename;
      if (p.getSource().getClass().equals(SetupParameters.class)) {
        filename = ((SetupParameters) p.getSource()).getFileName();
      } else {
        filename = "Experiment.Setup";
      }
      dataModel.addRow(
          new Object[] {
            "Warning",
            p.getParameterName(),
            p.getParameterValue(),
            filename,
            p.getValidationMessage(),
            p
          });
    }
    errorTable.setModel(dataModel);
    errorTable.getColumnExt("Parameter Object").setVisible(false);
    errorTable.addMouseListener(
        new MouseListener() {
          public void mouseClicked(MouseEvent e) {
            forwardEventToButton(e);
          }

          public void mouseEntered(MouseEvent e) {}

          public void mouseExited(MouseEvent e) {}

          public void mousePressed(MouseEvent e) {}

          public void mouseReleased(MouseEvent e) {}
        });
    tableScrollPane.setViewportView(errorTable);

    // LABEL
    errorLabel.setText(resourceMap.getString("errorLabel.text"));

    javax.swing.GroupLayout showErrorWarningsTypeLayout =
        new javax.swing.GroupLayout(showErrorWarningsPanel);
    showErrorWarningsPanel.setLayout(showErrorWarningsTypeLayout);
    showErrorWarningsTypeLayout.setHorizontalGroup(
        showErrorWarningsTypeLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                showErrorWarningsTypeLayout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        showErrorWarningsTypeLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(errorLabel)
                            .addComponent(tableScrollPane)
                            .addComponent(closeButton))
                    .addContainerGap()));
    showErrorWarningsTypeLayout.setVerticalGroup(
        showErrorWarningsTypeLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                showErrorWarningsTypeLayout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(errorLabel)
                    .addComponent(tableScrollPane)
                    .addComponent(closeButton)
                    .addContainerGap()));

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(
                        showErrorWarningsPanel,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        Short.MAX_VALUE)
                    .addContainerGap()));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(
                        showErrorWarningsPanel,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

    pack();
  }
Пример #3
0
  public void init() {
    _persistentRequested = false;
    this.addMouseListener(new MouseAdapt(this));

    super.setShowGrid(true); // --> Not reliable with Nimbus
    super.setGridColor(new Color(160, 160, 160));
    ;
    // super.setShowGrid(false); // override default mode of any LAF
    // this.addHighlighter(new BorderHighlighter(null,SplitTableDefaults.innerCellBorder(),false));

    super.setSortOrderCycle(SortOrder.ASCENDING, SortOrder.DESCENDING, SortOrder.UNSORTED);

    JTableHeader h = super.getTableHeader();
    h.addMouseListener(new zc3MouseAdaptForHeader(this));
    h.addMouseMotionListener(new zc3MouseAdaptForHeader(this));
    h.getColumnModel()
        .addColumnModelListener(
            new TableColumnModelListener() {
              public void columnAdded(TableColumnModelEvent e) {
                storeIfRequested();
              }

              public void columnRemoved(TableColumnModelEvent e) {
                storeIfRequested();
              }

              public void columnMoved(TableColumnModelEvent e) {
                storeIfRequested();
              }

              public void columnMarginChanged(ChangeEvent e) {
                storeIfRequested();
              }

              public void columnSelectionChanged(ListSelectionEvent e) {
                storeIfRequested();
              }
            });

    super.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    super.getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent e) {
                if (!e.getValueIsAdjusting()) {
                  int index = getSelectedRow();
                  int indices[] = getSelectedRows();
                  if (index == -1) {
                    informUnselect();
                  } else if (indices.length > 1) {
                    Vector<Integer> rows = new Vector<Integer>();
                    for (int i : indices) {
                      rows.add(i);
                    }
                    informSelect(rows);
                  } else {
                    informSelect(index);
                  }
                }
              }
            });

    _listeners = new HashSet<SelectionListener>();
    _mlisteners = new HashSet<MultipleSelectionListener>();
    _hlisteners = new HashSet<HeaderListener>();

    addKey(
        KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0),
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            if (JX2Table.this.getSelectedRow() != -1) {
              JX2Table.this.deleteEvent();
            }
          }
        });

    addKey(
        KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, 0),
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            if (JX2Table.this.getSelectedRow() != -1) {
              JX2Table.this.insertEvent();
            }
          }
        });

    addKey(
        KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.VK_CONTROL),
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            if (JX2Table.this.getSelectedRow() != -1) {
              JX2Table.this.enterEvent();
            }
          }
        });

    readPrefs();
  }
Пример #4
0
  public JLoadTestAssertionsTable(WsdlLoadTest wsdlLoadTest) {
    super(new BorderLayout());
    this.loadTest = wsdlLoadTest;

    loadTest.addLoadTestListener(internalLoadTestListener);

    tableModel = new LoadTestAssertionsTableModel();
    table = new JXTable(tableModel);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    TableColumnModel columnModel = table.getColumnModel();
    columnModel.getColumn(0).setMaxWidth(16);
    columnModel.getColumn(0).setCellRenderer(new IconTableCellRenderer());
    columnModel.getColumn(1).setPreferredWidth(100);
    columnModel.getColumn(2).setPreferredWidth(100);
    columnModel.getColumn(3).setPreferredWidth(200);

    JScrollPane scrollPane = new JScrollPane(table);
    add(scrollPane, BorderLayout.CENTER);

    table.addMouseListener(
        new MouseAdapter() {

          public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() < 2) return;

            int ix = table.getSelectedRow();
            if (ix == -1) return;
            ix = table.convertRowIndexToModel(ix);

            Object obj = loadTest.getAssertionAt(ix);
            if (obj instanceof Configurable) {
              ((Configurable) obj).configure();
            } else Toolkit.getDefaultToolkit().beep();
          }
        });

    add(buildToolbar(), BorderLayout.NORTH);

    table
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {

              public void valueChanged(ListSelectionEvent e) {
                int ix = table.getSelectedRow();

                configureAssertionAction.setEnabled(ix >= 0);
                removeAssertionAction.setEnabled(ix >= 0);

                if (ix == -1) return;

                ix = table.convertRowIndexToModel(ix);
                configureAssertionAction.setEnabled(
                    loadTest.getAssertionAt(ix) instanceof Configurable);
              }
            });

    assertionPopup = new JPopupMenu();
    assertionPopup.add(configureAssertionAction);
    assertionPopup.addSeparator();
    assertionPopup.add(addLoadTestAssertionAction);
    assertionPopup.add(removeAssertionAction);

    setComponentPopupMenu(assertionPopup);

    scrollPane.setInheritsPopupMenu(true);
    table.setComponentPopupMenu(assertionPopup);
  }
Пример #5
0
  public AttachmentsView(@Service ApplicationContext context, @Uses AttachmentsModel model) {
    setLayout(new BorderLayout());

    final ActionMap am = context.getActionMap(this);

    this.attachmentsModel = model;
    TableFormat tableFormat = new AttachmentsTableFormatter();
    tableModel = new EventJXTableModel<AttachmentDTO>(attachmentsModel.getEventList(), tableFormat);

    attachments = new JXTable(tableModel);

    attachments.setFocusTraversalKeys(
        KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
        KeyboardFocusManager.getCurrentKeyboardFocusManager()
            .getDefaultFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));
    attachments.setFocusTraversalKeys(
        KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,
        KeyboardFocusManager.getCurrentKeyboardFocusManager()
            .getDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS));

    attachments.getColumn(0).setPreferredWidth(20);
    attachments.getColumn(0).setMaxWidth(20);
    attachments.getColumn(0).setResizable(false);
    attachments.getColumn(2).setPreferredWidth(100);
    attachments.getColumn(2).setMaxWidth(100);
    attachments.getColumn(3).setPreferredWidth(100);
    attachments.getColumn(3).setMaxWidth(100);

    attachments.setAutoCreateColumnsFromModel(false);

    attachments.addHighlighter(HighlighterFactory.createAlternateStriping());

    attachments.setModel(tableModel);
    attachments.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    JPanel toolbar = new JPanel();
    StreamflowButton addButton = new StreamflowButton(am.get("add"));
    toolbar.add(addButton);
    StreamflowButton removeButton = new StreamflowButton(am.get("remove"));
    toolbar.add(removeButton);
    final StreamflowButton openButton = new StreamflowButton(am.get("open"));
    toolbar.add(openButton);
    attachments
        .getSelectionModel()
        .addListSelectionListener(new SelectionActionEnabler(am.get("open")));
    attachments
        .getSelectionModel()
        .addListSelectionListener(
            new SelectionActionEnabler(am.get("remove")) {

              @Override
              public boolean isSelectedValueValid(javax.swing.Action action) {
                return !attachments
                    .getValueAt(attachments.convertRowIndexToModel(attachments.getSelectedRow()), 0)
                    .equals(Icons.formSubmitted);
              }
            });

    attachmentsModel.addObserver(
        new RefreshComponents().visibleOn("createattachment", addButton, removeButton));

    attachments.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "open");
    attachments.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "remove");
    attachments.setActionMap(am);

    attachments.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent me) {
            int obj = attachments.getSelectedRow();
            if (obj == -1) return;
            if (me.getClickCount() == 2) {
              am.get("open")
                  .actionPerformed(
                      new ActionEvent(openButton, ActionEvent.ACTION_PERFORMED, "open"));
              me.consume();
            }
          }
        });

    attachments
        .getColumn(0)
        .setCellRenderer(
            new DefaultTableCellRenderer() {
              @Override
              public Component getTableCellRendererComponent(
                  JTable table,
                  Object value,
                  boolean isSelected,
                  boolean hasFocus,
                  int row,
                  int column) {

                JLabel iconLabel = new JLabel(" ");
                switch ((Icons) value) {
                  case attachments:
                    iconLabel = new JLabel(i18n.icon((Icons) value, 11));
                    break;

                  case conversations:
                    iconLabel = new JLabel(i18n.icon((Icons) value, 11));
                    break;

                  case formSubmitted:
                    iconLabel = new JLabel(i18n.icon((Icons) value, 11));
                    break;
                }

                iconLabel.setOpaque(true);

                if (isSelected) iconLabel.setBackground(attachments.getSelectionBackground());
                return iconLabel;
              }
            });

    JScrollPane attachmentsScrollPane = new JScrollPane(attachments);

    add(attachmentsScrollPane, BorderLayout.CENTER);
    add(toolbar, BorderLayout.SOUTH);

    new RefreshWhenShowing(this, attachmentsModel);
  }