Beispiel #1
0
  public void refresh() {
    Iterable<Property> properties = Collections.emptyList();

    if (beanHelper != null) {
      Image icon = beanHelper.getIcon(BeanInfo.ICON_COLOR_32x32);
      if (icon == null) {
        remove(top);
      } else {
        JXImageView logo = new JXImageView();
        logo.setImage(icon);
        add(logo, BorderLayout.NORTH);
      }
      properties =
          filter(
              beanHelper.getProperties(),
              new Predicate<Property>() {
                @Override
                public boolean apply(Property input) {
                  return !input.isHidden();
                }
              });
    }

    table.setModel(new MyTableModel(properties));

    // should we expose minimum row/column sizes as a user property?
    table.setRowHeight(18); // essentially the minimum row height
    table.getColumnModel().getColumn(0).setMinWidth(1);
    table.getColumnModel().getColumn(0).setMaxWidth(1);
    table.getColumnModel().getColumn(1).setMinWidth(1);

    table.packAll();
    revalidate();
  }
  /**
   * Creates new form FortfuehrungsanlaesseDialog.
   *
   * @param parent DOCUMENT ME!
   * @param modal DOCUMENT ME!
   */
  private FortfuehrungsanlaesseDialog(final Frame parent, final boolean modal) {
    super(parent, modal);

    initComponents();

    final Highlighter istAbgearbeitetHighlighter = new IstAbgearbeitetHighlighter();
    jXTable1.setHighlighters(istAbgearbeitetHighlighter);

    jXTable1.setModel(new FortfuehrungenTableModel());

    jXTable1
        .getColumnModel()
        .getColumn(0)
        .setCellRenderer(jXTable1.getDefaultRenderer(String.class));
    jXTable1
        .getColumnModel()
        .getColumn(1)
        .setCellRenderer(jXTable1.getDefaultRenderer(String.class));
    jXTable1
        .getColumnModel()
        .getColumn(2)
        .setCellRenderer(jXTable1.getDefaultRenderer(String.class));

    jXTable1.getColumnModel().getColumn(0).setPreferredWidth(100);
    jXTable1.getColumnModel().getColumn(1).setPreferredWidth(150);
    jXTable1.getColumnModel().getColumn(2).setPreferredWidth(200);

    jXTable1.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    jXTable1.setDragEnabled(false);

    jXTable1.getTableHeader().setResizingAllowed(true);
    jXTable1.getTableHeader().setReorderingAllowed(false);
    // jXTable1.setSortOrder(1, SortOrder.ASCENDING);

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

              @Override
              public void valueChanged(final ListSelectionEvent e) {
                // If cell selection is enabled, both row and column change events are fired
                if ((e.getSource() == jXTable1.getSelectionModel())
                    && jXTable1.getRowSelectionAllowed()) {
                  fortfuehrungsTableListSelectionChanged(e);
                }
              }
            });

    jProgressBar1.setVisible(false);
  }
  // Initialize JTable
  private void initTable() {
    DialogTableModel tblModel = new DialogTableModel(students);
    studentsTbl.setModel(tblModel);

    studentsTbl.setAutoCreateRowSorter(true);
    studentsTbl.setRowSelectionAllowed(true);
    studentsTbl.getRowSorter().toggleSortOrder(1);
    studentsTbl.setGridColor(Color.gray);
    studentsTbl.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    studentsTbl.setRowHeight(22);

    TableColumn tc = studentsTbl.getColumnModel().getColumn(0);
    tc.setCellEditor(studentsTbl.getDefaultEditor(Boolean.class));
    tc.setCellRenderer(studentsTbl.getDefaultRenderer(Boolean.class));
    tc.setHeaderRenderer(
        new CheckBoxTableHeader(
            new ItemListener() {
              @Override
              public void itemStateChanged(ItemEvent e) {
                Object source = e.getSource();
                if (source instanceof AbstractButton == false) {
                  return;
                }
                boolean checked = e.getStateChange() == ItemEvent.SELECTED;
                for (int x = 0, y = studentsTbl.getRowCount(); x < y; x++) {
                  studentsTbl.setValueAt(new Boolean(checked), x, 0);
                }
              }
            }));
  }
  public MenuItemExplorer() {
    tableModel = new BeanTableModel<MenuItem>(MenuItem.class);
    tableModel.addColumn(POSConstants.ID.toUpperCase(), "id"); // $NON-NLS-1$
    tableModel.addColumn(POSConstants.NAME.toUpperCase(), "name"); // $NON-NLS-1$
    tableModel.addColumn(
        POSConstants.TRANSLATED_NAME.toUpperCase(), "translatedName"); // $NON-NLS-1$
    tableModel.addColumn(
        POSConstants.PRICE.toUpperCase() + " (" + Application.getCurrencySymbol() + ")",
        "price"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    tableModel.addColumn(POSConstants.VISIBLE.toUpperCase(), "visible"); // $NON-NLS-1$
    tableModel.addColumn(
        POSConstants.DISCOUNT.toUpperCase() + "(%)", "discountRate"); // $NON-NLS-1$ //$NON-NLS-2$
    tableModel.addColumn(POSConstants.FOOD_GROUP.toUpperCase(), "parent"); // $NON-NLS-1$
    tableModel.addColumn(POSConstants.TAX.toUpperCase(), "tax"); // $NON-NLS-1$
    tableModel.addColumn(POSConstants.SORT_ORDER.toUpperCase(), "sortOrder"); // $NON-NLS-1$
    tableModel.addColumn(POSConstants.BUTTON_COLOR.toUpperCase(), "buttonColor"); // $NON-NLS-1$
    tableModel.addColumn(POSConstants.TEXT_COLOR.toUpperCase(), "textColor"); // $NON-NLS-1$
    tableModel.addColumn(POSConstants.IMAGE.toUpperCase(), "imageData"); // $NON-NLS-1$

    tableModel.addRows(MenuItemDAO.getInstance().findAll());

    table = new JXTable(tableModel);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.setRowHeight(30);

    table.setDefaultRenderer(Object.class, new CustomCellRenderer());
    table
        .getColumnModel()
        .getColumn(10)
        .setCellRenderer(
            new DefaultTableCellRenderer() {
              @Override
              public Component getTableCellRendererComponent(
                  JTable table,
                  Object value,
                  boolean isSelected,
                  boolean hasFocus,
                  int row,
                  int column) {
                if (value instanceof Color) {
                  JLabel lblColor = new JLabel("TEXT COLOR", JLabel.CENTER);
                  lblColor.setForeground((Color) value);
                  return lblColor;
                }
                return super.getTableCellRendererComponent(
                    table, value, isSelected, hasFocus, row, column);
              }
            });

    setLayout(new BorderLayout(5, 5));
    add(new JScrollPane(table));

    add(createButtonPanel(), BorderLayout.SOUTH);
    add(buildSearchForm(), BorderLayout.NORTH);
  }
  /** Initialize the GUI */
  private void init() {
    setLayout(new BorderLayout(0, 0));

    JPanel panelMain = new JPanel();
    add(panelMain, BorderLayout.CENTER);
    panelMain.setLayout(new MigLayout("", "[grow]", "[grow]"));

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    panelMain.add(scrollPane, "cell 0 0,grow");

    table =
        new JXTable() {
          private static final long serialVersionUID = 1L;

          public void changeSelection(
              final int row, final int column, boolean toggle, boolean extend) {
            super.changeSelection(row, column, toggle, extend);
            if (table.isCellEditable(row, column)) {
              editCellAt(row, column);
            }
          }
        };

    table.setHorizontalScrollEnabled(true);
    table.setColumnControlVisible(true);
    model = new SeriesIdentityTableModel(containerFrame);

    SeriesIdentityTableCellRenderer renderer = new SeriesIdentityTableCellRenderer();

    table.setModel(model);

    table.getColumn(3).setCellRenderer(renderer);
    table.getColumn(4).setCellRenderer(renderer);
    table.getColumn(5).setCellRenderer(renderer);
    table.getColumn(6).setCellRenderer(renderer);
    table.getColumn(7).setCellRenderer(renderer);
    table.getColumn(8).setCellRenderer(renderer);
    table.getColumnExt(4).setIdentifier("SubObjectColumn");
    table.getColumnExt("SubObjectColumn").setVisible(false);

    table
        .getColumnModel()
        .addColumnModelListener(
            new TableColumnModelListener() {

              @Override
              public void columnAdded(TableColumnModelEvent arg0) {

                chkIncludeSubobjects.setSelected(table.getColumnExt("SubObjectColumn").isVisible());
              }

              @Override
              public void columnMarginChanged(ChangeEvent arg0) {
                // TODO Auto-generated method stub

              }

              @Override
              public void columnMoved(TableColumnModelEvent arg0) {
                // TODO Auto-generated method stub

              }

              @Override
              public void columnRemoved(TableColumnModelEvent arg0) {
                chkIncludeSubobjects.setSelected(table.getColumnExt("SubObjectColumn").isVisible());
              }

              @Override
              public void columnSelectionChanged(ListSelectionEvent arg0) {
                // TODO Auto-generated method stub

              }
            });

    scrollPane.setViewportView(table);

    JPanel panelButton = new JPanel();
    add(panelButton, BorderLayout.SOUTH);
    panelButton.setLayout(new MigLayout("", "[grow][][]", "[grow][grow][][][]"));

    model.addTableModelListener(this);

    JPanel panel = new JPanel();
    panelButton.add(panel, "cell 0 1 1 2,grow");
    panel.setLayout(new MigLayout("", "[31px][162px]", "[16px][][]"));

    JLabel lblKey = new JLabel("Key:");
    panel.add(lblKey, "cell 0 0,alignx left,aligny top");

    JLabel lblPresentIn = new JLabel("= Present in database");
    lblPresentIn.setFont(new Font("Dialog", Font.PLAIN, 12));
    lblPresentIn.setIcon(Builder.getIcon("found.png", 16));
    panel.add(lblPresentIn, "flowy,cell 1 0,alignx left,aligny top");

    JLabel lblAbsentFrom = new JLabel("= Absent from database");
    lblAbsentFrom.setFont(new Font("Dialog", Font.PLAIN, 12));
    lblAbsentFrom.setIcon(Builder.getIcon("missing.png", 16));
    panel.add(lblAbsentFrom, "cell 1 1,alignx left,aligny top");

    JLabel lblNotYet = new JLabel("= Not yet searched");
    lblNotYet.setFont(new Font("Dialog", Font.PLAIN, 12));
    lblNotYet.setIcon(Builder.getIcon("wait.png", 16));
    panel.add(lblNotYet, "cell 1 2,alignx left,aligny top");

    JPanel panel_1 = new JPanel();
    panelButton.add(panel_1, "cell 1 1 2 2,alignx right,growy");
    panel_1.setLayout(new MigLayout("", "[116px,fill]", "[22px][][][]"));

    JButton btnSearchDB = new JButton("Search Database");
    btnSearchDB.setFont(new Font("Dialog", Font.BOLD, 9));
    panel_1.add(btnSearchDB, "cell 0 0,alignx left,aligny top");
    btnSearchDB.setActionCommand("SearchDB");

    JButton btnDefineByPattern = new JButton("Define names by pattern");
    btnDefineByPattern.setFont(new Font("Dialog", Font.BOLD, 9));
    panel_1.add(btnDefineByPattern, "cell 0 1,alignx left,aligny top");
    btnDefineByPattern.setActionCommand("DefineByPattern");

    JButton btnGenerateMissing = new JButton("Generate missing entities");
    btnGenerateMissing.setActionCommand("GenerateMissing");
    btnGenerateMissing.addActionListener(this);

    JButton btnSetDefaults = new JButton("Set default parameters");
    btnSetDefaults.setActionCommand("SetDefaults");
    btnSetDefaults.addActionListener(this);
    btnSetDefaults.setFont(new Font("Dialog", Font.BOLD, 9));
    panel_1.add(btnSetDefaults, "cell 0 2");

    btnGenerateMissing.setFont(new Font("Dialog", Font.BOLD, 9));
    panel_1.add(btnGenerateMissing, "flowy,cell 0 3");
    btnDefineByPattern.addActionListener(this);
    btnSearchDB.addActionListener(this);

    chkIncludeSubobjects = new JCheckBox("Include sub-objects in import");
    chkIncludeSubobjects.addActionListener(this);
    chkIncludeSubobjects.setActionCommand("IncludeExcludeSubObjects");
    panelButton.add(chkIncludeSubobjects, "cell 0 3");

    chckbxOpenSeriesIn = new JCheckBox("Open series in editor when finished");
    chckbxOpenSeriesIn.setSelected(true);
    panelButton.add(chckbxOpenSeriesIn, "cell 0 4");
  }
  public void setEntity(ITridas entity) {
    theentity = entity;
    lookupUsersAndGroups();

    userTableModel = new UsersWithPermissionsTableModel(permsList);
    groupTableModel = new GroupsWithPermissionsTableModel(permsList);
    groupTableModel.addTableModelListener(
        new TableModelListener() {

          @Override
          public void tableChanged(TableModelEvent e) {
            updateUsersTable();
          }
        });
    setLayout(new MigLayout("", "[][grow]", "[86px][28.00][328px,grow]"));

    lblPermissionsInfoFor = new JLabel("Permissions info for:");
    add(lblPermissionsInfoFor, "cell 0 1,alignx trailing");

    // TODO : make this code pretty...
    txtLabCode = new JTextField();
    txtLabCode.setText(entity.getTitle());
    txtLabCode.setFocusable(false);

    txtLabCode.setEditable(false);
    add(txtLabCode, "cell 1 1,growx");
    txtLabCode.setColumns(10);

    tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    add(tabbedPane, "cell 0 2 2 1,grow");

    panelGroups = new JPanel();
    tabbedPane.addTab(
        "Group permissions", Builder.getIcon("edit_group.png", 22), panelGroups, null);
    panelGroups.setLayout(new MigLayout("", "[648px,grow]", "[381px,grow][]"));

    JScrollPane scrollGroup = new JScrollPane();
    panelGroups.add(scrollGroup, "cell 0 0,grow");

    tblGroupPerms = new JXTable(groupTableModel);
    tblGroupPerms.setSortable(true);

    searchableGroup = new TableSearchable(tblGroupPerms);
    tblGroupPerms.setSearchable(searchableGroup);

    scrollGroup.setViewportView(tblGroupPerms);

    btnEditGroup = new JButton("View / Edit Group");
    btnEditGroup.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            editSelectedGroup();
          }
        });
    panelGroups.add(btnEditGroup, "flowx,cell 0 1");

    btnRevertToDefault = new JButton("Revert to database defaults");
    btnRevertToDefault.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            resetPermissionsForCurrentGroup();
          }
        });
    panelGroups.add(btnRevertToDefault, "cell 0 1");

    btnGroupRefresh = new JButton("Refresh");
    btnGroupRefresh.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            updateGroupsTable();
          }
        });
    panelGroups.add(btnGroupRefresh, "cell 0 1");

    tblGroupPerms.getColumnModel().getColumn(0).setPreferredWidth(15);
    tblGroupPerms.getColumnModel().getColumn(1).setPreferredWidth(100);
    tblGroupPerms.getColumnModel().getColumn(2).setPreferredWidth(45);
    tblGroupPerms.getColumnModel().getColumn(3).setPreferredWidth(45);
    tblGroupPerms.getColumnModel().getColumn(4).setPreferredWidth(45);
    tblGroupPerms.getColumnModel().getColumn(5).setPreferredWidth(45);
    tblGroupPerms.getColumnModel().getColumn(6).setPreferredWidth(45);
    tblGroupPerms.getColumnModel().getColumn(7).setPreferredWidth(300);

    panelUsers = new JPanel();
    tabbedPane.addTab("Users with access", Builder.getIcon("edit_user.png", 22), panelUsers, null);
    panelUsers.setLayout(new MigLayout("", "[648px,grow]", "[381px,grow][]"));

    JScrollPane scrollUser = new JScrollPane();
    panelUsers.add(scrollUser, "cell 0 0,grow");

    tblUserPerms = new JXTable(userTableModel);

    searchableUser = new TableSearchable(tblUserPerms);
    tblUserPerms.setSearchable(searchableUser);

    tblUserPerms.setSortable(true);
    scrollUser.setViewportView(tblUserPerms);

    btnEditUser = new JButton("View / Edit User");
    btnEditUser.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            editSelectedUser();
          }
        });
    panelUsers.add(btnEditUser, "flowx,cell 0 1");

    btnUserRefresh = new JButton("Refresh");
    btnUserRefresh.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {

            updateUsersTable();
          }
        });
    panelUsers.add(btnUserRefresh, "cell 0 1");

    tblUserPerms.getColumnModel().getColumn(0).setPreferredWidth(15);
    tblUserPerms.getColumnModel().getColumn(1).setPreferredWidth(100);
    tblUserPerms.getColumnModel().getColumn(2).setPreferredWidth(45);
    tblUserPerms.getColumnModel().getColumn(3).setPreferredWidth(45);
    tblUserPerms.getColumnModel().getColumn(4).setPreferredWidth(45);
    tblUserPerms.getColumnModel().getColumn(5).setPreferredWidth(45);
    tblUserPerms.getColumnModel().getColumn(6).setPreferredWidth(45);
    tblUserPerms.getColumnModel().getColumn(7).setPreferredWidth(300);

    tblGroupPerms.addMouseListener(this);
    tblUserPerms.addMouseListener(this);

    panelTitle = new JPanel();
    add(panelTitle, "cell 0 0 2 1,growx,aligny top");
    panelTitle.setBackground(Color.WHITE);
    panelTitle.setLayout(new MigLayout("", "[411.00,grow][]", "[][grow]"));

    lblGroupPermissions = new JLabel("Access Permissions");
    lblGroupPermissions.setFont(new Font("Dialog", Font.BOLD, 14));
    panelTitle.add(lblGroupPermissions, "flowy,cell 0 0");

    panelIcon = new JPanel();
    panelIcon.setBackground(Color.WHITE);
    panelTitle.add(panelIcon, "cell 1 0 1 2,grow");

    lblIcon = new JLabel();
    lblIcon.setIcon(Builder.getIcon("trafficlight.png", 64));
    panelIcon.add(lblIcon);

    txtDescription = new JTextArea();
    txtDescription.setBorder(null);
    txtDescription.setEditable(false);
    txtDescription.setFocusable(false);
    txtDescription.setFont(new Font("Dialog", Font.PLAIN, 10));
    txtDescription.setLineWrap(true);
    txtDescription.setWrapStyleWord(true);
    txtDescription.setText(
        "Permissions are set on groups, not users.  You can set: create; read; "
            + "update; and delete permissions separately.  Permissions are inherited from the default "
            + "database permissions given to the group (editable in the main group dialog). If you "
            + "change permissions here you will override the access for the current entity and any "
            + "child entities in the database. "
            + "The users tab shows the current list of users who have permission to access this "
            + "entity in some way.");
    panelTitle.add(txtDescription, "cell 0 1,grow,wmin 10");
  }
  /** Constructor. */
  public CombinedRulesPanel() {
    super();
    this.combinedRulesTableModel = new CombinedRulesTableModel();
    this.combinedRulesTable =
        new JXTable() {

          private static final long serialVersionUID = 2L;

          @Override
          protected JTableHeader createDefaultTableHeader() {
            return new JXTableHeader(columnModel) {
              private static final long serialVersionUID = 1L;

              @Override
              public void updateUI() {
                super.updateUI();
                // need to do in updateUI to survive toggling of LAF
                if (getDefaultRenderer() instanceof JLabel) {
                  ((JLabel) getDefaultRenderer()).setHorizontalAlignment(JLabel.CENTER);
                }
              }
            };
          }
        };

    this.combinedRulesTable.setModel(combinedRulesTableModel);
    this.combinedRulesTable
        .getSelectionModel()
        .setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    this.combinedRulesTable.setShowGrid(false);

    this.combinedRulesTable.getSelectionModel().addListSelectionListener(this);

    @SuppressWarnings("unused")
    org.jdesktop.swingx.renderer.DefaultTableRenderer renderer =
        (org.jdesktop.swingx.renderer.DefaultTableRenderer)
            combinedRulesTable.getDefaultRenderer(String.class);

    // Make some columns wider than the rest, so that the info fits in.
    TableColumnModel columnModel = combinedRulesTable.getColumnModel();
    columnModel.getColumn(CombinedRulesTableColumns.COMBINED_RULE.ordinal()).setPreferredWidth(10);
    columnModel.getColumn(CombinedRulesTableColumns.RULE_FREQUENCY.ordinal()).setPreferredWidth(10);
    /*
        columnModel.getColumn(SequiturRulesTableColumns.RULE_USE_FREQUENCY.ordinal()).setPreferredWidth(40);
        columnModel.getColumn(SequiturRulesTableColumns.SEQUITUR_RULE.ordinal()).setPreferredWidth(100);
        columnModel.getColumn(SequiturRulesTableColumns.EXPANDED_SEQUITUR_RULE.ordinal()).setPreferredWidth(
            150);
        columnModel.getColumn(SequiturRulesTableColumns.RULE_MEAN_LENGTH.ordinal()).setPreferredWidth(120);
    */

    /*
         * dont need sorter -qz
         *
        TableRowSorter<CombinedRulesTableModel> sorter = new TableRowSorter<CombinedRulesTableModel>(
            combinedRulesTableModel);
        combinedRulesTable.setRowSorter(sorter);
        sorter.setComparator(SequiturRulesTableColumns.EXPANDED_SEQUITUR_RULE.ordinal(),
            expandedRuleComparator);

        DefaultTableCellRenderer rightRenderer = new DefaultTableCellRenderer();
        rightRenderer.setHorizontalAlignment(SwingConstants.RIGHT);
        this.combinedRulesTable.getColumnModel().getColumn(1).setCellRenderer(rightRenderer);
    */
    this.combinedRulesPanel = new JScrollPane(combinedRulesTable);
  }
  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);
  }
  private void initUI() {
    setLayout(new BorderLayout());

    JToolBar toolBar = new JToolBar();
    toolBar.putClientProperty("JToolBar.isRollover", Boolean.TRUE); // hide buttons borders
    toolBar.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH);
    toolBar.setBorderPainted(false);

    toolBar.add(
        new AbstractAction() {

          public Object getValue(String key) {
            if (AbstractAction.SMALL_ICON.equals(key)) {
              return ImageUtil.getImageIcon("add");
            } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) {
              return I18NSupport.getString("parameter.add");
            }

            return super.getValue(key);
          }

          public void actionPerformed(ActionEvent e) {
            add();
          }
        });

    toolBar.add(
        new AbstractAction() {

          public Object getValue(String key) {
            if (AbstractAction.SMALL_ICON.equals(key)) {
              return ImageUtil.getImageIcon("add_par");
            } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) {
              return I18NSupport.getString("parameter.add.from.report");
            }

            return super.getValue(key);
          }

          public void actionPerformed(ActionEvent e) {
            addFromReport();
          }
        });

    toolBar.add(
        new AbstractAction() {

          public Object getValue(String key) {
            if (AbstractAction.SMALL_ICON.equals(key)) {
              return ImageUtil.getImageIcon("parameter_clone");
            } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) {
              return I18NSupport.getString("parameter.add.clone");
            }

            return super.getValue(key);
          }

          public void actionPerformed(ActionEvent e) {
            cloneParameter();
          }
        });

    toolBar.add(
        new AbstractAction() {

          public Object getValue(String key) {
            if (AbstractAction.SMALL_ICON.equals(key)) {
              return ImageUtil.getImageIcon("edit");
            } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) {
              return I18NSupport.getString("parameter.edit");
            }

            return super.getValue(key);
          }

          public void actionPerformed(ActionEvent e) {
            modify();
          }
        });

    toolBar.add(
        new AbstractAction() {

          public Object getValue(String key) {
            if (AbstractAction.SMALL_ICON.equals(key)) {
              return ImageUtil.getImageIcon("delete");
            } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) {
              return I18NSupport.getString("parameter.delete");
            }

            return super.getValue(key);
          }

          public void actionPerformed(ActionEvent e) {
            delete();
          }
        });

    toolBar.add(
        new AbstractAction() {

          public Object getValue(String key) {
            if (AbstractAction.SMALL_ICON.equals(key)) {
              return ImageUtil.getImageIcon("parameter_up");
            } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) {
              return I18NSupport.getString("parameter.up");
            }

            return super.getValue(key);
          }

          public void actionPerformed(ActionEvent e) {
            up();
          }
        });

    toolBar.add(
        new AbstractAction() {

          public Object getValue(String key) {
            if (AbstractAction.SMALL_ICON.equals(key)) {
              return ImageUtil.getImageIcon("parameter_down");
            } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) {
              return I18NSupport.getString("parameter.down");
            }

            return super.getValue(key);
          }

          public void actionPerformed(ActionEvent e) {
            down();
          }
        });

    //        SwingUtil.registerButtonsForFocus(buttonsPanel);

    add(toolBar, BorderLayout.NORTH);

    createTable();
    table
        .getColumnModel()
        .getColumn(1)
        .setCellRenderer(
            new DefaultTableCellRenderer() {

              @Override
              public Component getTableCellRendererComponent(
                  JTable table,
                  Object value,
                  boolean isSelected,
                  boolean hasFocus,
                  int row,
                  int column) {
                super.getTableCellRendererComponent(
                    table, value, isSelected, hasFocus, row, column);
                String tmp = (String) value;
                tmp = tmp.substring(tmp.lastIndexOf('.') + 1);
                /*
                if ("Object".equals(tmp)) {
                	tmp = "Any";
                }
                */
                setText(tmp);

                return this;
              }
            });
    table.addMouseListener(
        new MouseAdapter() {

          @Override
          public void mouseClicked(MouseEvent event) {
            if (event.getClickCount() == 2) {
              modify();
            }
          }
        });
    table.addKeyListener(
        new KeyAdapter() {

          @Override
          public void keyPressed(KeyEvent event) {
            int keyCode = event.getKeyCode();
            if (keyCode == KeyEvent.VK_ENTER) {
              modify();
              // don't let anyone else handle the event
              event.consume();
            } else if (keyCode == KeyEvent.VK_INSERT) {
              add();
              // don't let anyone else handle the event
              event.consume();
            } else if (keyCode == KeyEvent.VK_DELETE) {
              delete();
              // don't let anyone else handle the event
              event.consume();
            }
          }
        });
    add(new JScrollPane(table), BorderLayout.CENTER);
    table.setPreferredScrollableViewportSize(new Dimension(250, 200));
  }
  public DownloadsMDIWindow(final UISubsystem ui) throws Exception {
    super(ui.getMainWindow().getMDIManager(), "downloads", ui);

    table = new JXTable();
    table.setModel(model = new DownloadsTableModel());
    table.setAutoCreateColumnsFromModel(false);
    table.getColumnModel().getColumn(1).setCellRenderer(new ProgressBarCellRenderer());
    table.getColumnModel().getColumn(0).setPreferredWidth(300);
    table.getColumnModel().getColumn(1).setPreferredWidth(80);

    status = (JLabel) xui.getComponent("status");
    downloadingFromText = (JLabel) xui.getComponent("downloadingfromtext");
    uploadingToText = (JLabel) xui.getComponent("uploadingtotext");

    setFixedColumnSize(table.getColumnModel().getColumn(2), 60);
    setFixedColumnSize(table.getColumnModel().getColumn(3), 60);
    setFixedColumnSize(table.getColumnModel().getColumn(4), 60);
    setFixedColumnSize(table.getColumnModel().getColumn(5), 10);

    table.setColumnControlVisible(true);

    downloadGrid = (JDownloadGrid) xui.getComponent("downloadgrid");
    table
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {

              @Override
              public void valueChanged(ListSelectionEvent e) {
                if (e.getFirstIndex() < 0 || e.getFirstIndex() >= rows.size()) {
                  downloadGrid.setDownload(null);
                  updateDownloadingFromAndUploadingToText();
                  return;
                }
                selectDownloadToShowOnDownloadGrid();
                updateDownloadingFromAndUploadingToText();
              }
            });

    table.addMouseListener(
        new MouseAdapter() {

          @Override
          public void mouseReleased(MouseEvent e) {
            maybeShowPopup(e);
          }

          @Override
          public void mousePressed(MouseEvent e) {
            maybeShowPopup(e);
          }

          @Override
          public void mouseClicked(MouseEvent e) {}

          private void maybeShowPopup(MouseEvent e) {
            if (e.isPopupTrigger()) {
              int row = table.rowAtPoint(e.getPoint());
              boolean b = false;
              for (int r : table.getSelectedRows()) {
                if (r == row) {
                  b = true;
                  break;
                }
              }
              if (!b) {
                table.getSelectionModel().setSelectionInterval(row, row);
              }
              popup.show(e.getComponent(), e.getX(), e.getY());
            }
          }
        });

    //        table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setColumnSelectionAllowed(false);

    ((JScrollPane) xui.getComponent("scroll")).setViewportView(table);

    popup = (JPopupMenu) xui.getComponent("popup");

    update();

    setTitle("Downloads");
    listenExternalLinks();
    postInit();
  }