Exemplo n.º 1
0
  /**
   * Initialisiere den unteren Bereichs des Benchmark-Panels mit einer Tabelle von Schätzungen und
   * Vorhersagen.
   */
  private void initTablePane() {
    JPanel tablePane = new JPanel(new GridLayout(1, 1));
    tablePane.add(new JScrollPane(benchmarkTable));
    benchmarkTable.setDefaultRenderer(Object.class, new BenchmarkTableCellRenderer());
    benchmarkTable.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            super.mouseClicked(e);

            int selRowIndex = benchmarkTable.getSelectedRow();
            int selColIndex = benchmarkTable.getSelectedColumn();

            String user = (String) benchmarkTableModel.getValueAt(selRowIndex, 0);

            if (selColIndex == 0) {
              new UserStatsWindow(user).setVisible(true);
              return;
            }

            Object cellVal = benchmarkTableModel.getValueAt(selRowIndex, selColIndex);
            if (!(cellVal instanceof String)) {
              return;
            }
            String repoName = (String) cellVal;

            Project p = new Project(user, repoName);
            if (metricsData.containsKey(p)) {
              new ProjectMetricsWindow(metricsData.get(p)).setVisible(true);
            }
          }
        });
    add(tablePane, BorderLayout.CENTER);
  }
  public TableCellRenderFrame() {
    setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);

    TableModel model = new PlanetTableModel();
    JTable table = new JTable(model);
    table.setRowSelectionAllowed(false);

    // set up renderers and editors

    table.setDefaultRenderer(Color.class, new ColorTableCellRenderer());
    table.setDefaultEditor(Color.class, new ColorTableCellEditor());

    JComboBox<Integer> moonCombo = new JComboBox<>();
    for (int i = 0; i <= 20; i++) moonCombo.addItem(i);

    TableColumnModel columnModel = table.getColumnModel();
    TableColumn moonColumn = columnModel.getColumn(PlanetTableModel.MOONS_COLUMN);
    moonColumn.setCellEditor(new DefaultCellEditor(moonCombo));
    moonColumn.setHeaderRenderer(table.getDefaultRenderer(ImageIcon.class));
    moonColumn.setHeaderValue(new ImageIcon(getClass().getResource("Moons.gif")));

    // show table

    table.setRowHeight(100);
    add(new JScrollPane(table), BorderLayout.CENTER);
  }
Exemplo n.º 3
0
  /**
   * Set the current open DarwinCSV. You should really, really, really setCurrentCSV(null) before
   * you load a new DarwinCSV.
   *
   * @param csv The new DarwinCSV object.
   */
  private void setCurrentCSV(DarwinCSV csv) {
    // Clear the old currentCSV object and matchAgainst object.
    currentCSV = null;
    matchAgainst(null);

    // Load the new currentCSV object.
    currentCSV = csv;
    table.removeAll();
    table.setDefaultRenderer(Name.class, this);

    // Set the currentCSV
    // TODO: This causes an exception occasionally, because we shouldn't
    // be calling setModel outside of the Event Queue thread; however, we're
    // currently in a worker thread, so dipping back into the Event thread
    // would just cause more problems. Sorry!
    if (csv != null) {
      table.setModel(currentCSV.getRowIndex());
    } else {
      table.setModel(blankDataModel);
    }

    columnInfoPanel.loadedFileChanged(csv);
    columnInfoPanel.columnChanged(-1);
    table.repaint();
  }
Exemplo n.º 4
0
 public void setModel(LogItemTableModel model) {
   this.model = model;
   logItemTable.setModel(model);
   logItemTable.getColumnModel().getColumn(0).setMinWidth(180);
   logItemTable.getColumnModel().getColumn(0).setMaxWidth(200);
   logItemTable.getColumnModel().getColumn(1).setMinWidth(50);
   logItemTable.getColumnModel().getColumn(1).setMaxWidth(80);
   logItemTable.setDefaultRenderer(Object.class, new LogEntryRenderer());
 }
Exemplo n.º 5
0
  protected void setupTable(JTable table) {

    table.setFillsViewportHeight(true);
    table.getColumnModel().getColumn(2).setMaxWidth(150);
    table.getColumnModel().getColumn(1).setMaxWidth(150);
    table.getColumnModel().getColumn(0).setMaxWidth(150);
    //   table.getColumnModel().getColumn(0).setPreferredWidth(10);

    table.setDefaultRenderer(Color.class, new ColorTableCellRenderer());
  }
Exemplo n.º 6
0
  public static void refreshCalendar(int month, int year) {
    // instantiation
    String[] months = {
      "January",
      "February",
      "March",
      "April",
      "May",
      "June",
      "July",
      "August",
      "September",
      "October",
      "November",
      "December"
    };
    int numoday, startom; // Number Of Days, Start Of Month

    // Allow/disallow buttons
    prev.setEnabled(true);
    next.setEnabled(true);
    if (month == 0 && year <= ryear) {
      prev.setEnabled(false);
    } // Cannot set an appointment back in time
    if (month == 11 && year >= ryear + 50) {
      next.setEnabled(false);
    } // Too early to set an appointment
    lmonth.setText(months[month]); // Refresh the month label (at the top)
    lmonth.setBounds(
        160 - lmonth.getPreferredSize().width / 2, 25, 180, 25); // Re-align label with calendar
    cyear.setSelectedItem(String.valueOf(year)); // Select the correct year in the combo box

    // deletes current table
    for (int i = 0; i < 6; i++) {
      for (int j = 0; j < 7; j++) {
        mcal.setValueAt(null, i, j);
      }
    }

    // Get first day of month and number of days
    GregorianCalendar cal = new GregorianCalendar(year, month, 1);
    numoday = cal.getActualMaximum(GregorianCalendar.DAY_OF_MONTH);
    startom = cal.get(GregorianCalendar.DAY_OF_WEEK);

    // Create calendar
    for (int i = 1; i <= numoday; i++) {
      int row = new Integer((i + startom - 2) / 7);
      int column = (i + startom - 2) % 7;
      mcal.setValueAt(i, row, column);
    }

    // Apply renderers
    Cal.setDefaultRenderer(Cal.getColumnClass(0), new tblCalendarRenderer());
  }
Exemplo n.º 7
0
  private void loadView() {
    // main views
    mTableModel = new SpreadsheetTableModel();

    mTableView = new JTable(mTableModel);
    mTableView.setRowSelectionAllowed(false);
    mTableView.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    mTableView.setFillsViewportHeight(true);
    mTableView.setDefaultRenderer(String.class, new ColorCellRenderer(TABLE_CELL_COLOR));
    mTableView.setDefaultEditor(
        String.class, new SpreadsheetCellEditor(mTableView.getDefaultEditor(String.class)));
    mTableView.getSelectionModel().addListSelectionListener(new SpreadsheetSelectionListener());
    mTableView
        .getColumnModel()
        .getSelectionModel()
        .addListSelectionListener(new SpreadsheetSelectionListener());

    JTable rowHeaderTable = new JTable(new RowHeaderTableModel());
    rowHeaderTable.setCellSelectionEnabled(false);
    rowHeaderTable.setPreferredScrollableViewportSize(new Dimension(50, Integer.MAX_VALUE));
    rowHeaderTable.setDefaultRenderer(Object.class, new ColorCellRenderer(ROW_HEADER_COLOR));

    mFormulaTextField = new BindableTextField();
    mFormulaTextField.setEditable(false);
    mFormulaTextField.setFocusable(false);

    JScrollPane scrollView = new JScrollPane(mTableView);
    scrollView.setRowHeaderView(rowHeaderTable);

    add(mFormulaTextField, BorderLayout.BEFORE_FIRST_LINE);
    add(scrollView, BorderLayout.CENTER);

    // helpers

    mFileChooser = new SingleExtensionFileChooser();
    String extension = SpreadsheetPersistenceManager.SPREADSHEET_FILE_EXTENSION;
    mFileChooser.setFileExtension(extension, "Spreadsheets file (." + extension + ")");
  }
  private void init() {
    setLayout(new BorderLayout());

    tableModel = new NotesTableModel(getCharacter());
    table = new JTable(tableModel);
    table.setRowHeight(50);
    tableModel.updateColumns(table);
    table.setDefaultRenderer(String.class, new NotesCellRenderer());
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent e) {
                updateControls();
              }
            });

    add(new JScrollPane(table), "Center");

    Box box = Box.createHorizontalBox();
    box.add(Box.createHorizontalGlue());
    addNoteButton = new JButton("Add Custom");
    addNoteButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            String note = JOptionPane.showInputDialog("Custom Note");
            getCharacter().addNote(getGameHandler().getClient().getClientName(), "Custom", note);
            updatePanel();
          }
        });
    box.add(addNoteButton);
    box.add(Box.createHorizontalGlue());
    deleteNoteButton = new JButton("Delete Custom");
    deleteNoteButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            Note note = getSelectedNote();
            if (note != null) {
              getCharacter().deleteNote(note.getId());
              updatePanel();
            }
          }
        });
    box.add(deleteNoteButton);
    box.add(Box.createHorizontalGlue());
    add(box, "South");

    updateControls();
  }
  public void init() {
    setTitle("Expression Property Metadata Editor");
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    expressionsTableModel = new EditableMetaDataTableModel();
    expressionsTable = new JTable(expressionsTableModel);
    expressionsTable.setDefaultRenderer(String.class, new EditableMetaDataRenderer());

    final JPanel contentPane = new JPanel();
    contentPane.setLayout(new BorderLayout());
    contentPane.add(new JScrollPane(expressionsTable), BorderLayout.CENTER);
    setContentPane(contentPane);
    setSize(800, 600);
  }
Exemplo n.º 10
0
  // Initializing this component.
  private void jbInit() {
    callStackTable.addFocusListener(
        new FocusListener() {
          public void focusGained(FocusEvent e) {
            callStackTable_focusGained(e);
          }

          public void focusLost(FocusEvent e) {
            callStackTable_focusLost(e);
          }
        });
    callStackTable.setTableHeader(null);
    callStackTable.setDefaultRenderer(callStackTable.getColumnClass(0), getCellRenderer());
    scrollPane = new JScrollPane(callStackTable);
    setVisibleRows(DEFAULT_VISIBLE_ROWS);
    scrollPane.setLocation(0, 27);
    setBorder(BorderFactory.createEtchedBorder());
    // this.setLayout(null);
    this.setLayout(new GridBagLayout());
    nameLbl.setText("Call Stack");
    nameLbl.setBounds(new Rectangle(3, 4, 70, 23));
    nameLbl.setFont(Utilities.labelsFont);

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.ipadx = 0;
    c.ipady = 0;
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 7;
    c.gridheight = 1;
    c.anchor = GridBagConstraints.PAGE_END;
    c.gridx = 0;
    c.gridy = 2;
    this.add(scrollPane, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.ipadx = 0;
    c.ipady = 0;
    c.weightx = 1;
    c.weighty = 0.0;
    c.gridwidth = 3;
    c.gridheight = 1;
    c.anchor = GridBagConstraints.FIRST_LINE_START;
    c.gridx = 0;
    c.gridy = 0;
    c.insets = new Insets(5, 0, 0, 0);
    this.add(nameLbl, c);
  }
  /** Constructs a new MemorySegmentComponent. */
  public MemorySegmentComponent() {
    dataFormat = Format.DEC_FORMAT;
    listeners = new Vector();
    errorEventListeners = new Vector();
    highlightIndex = new Vector();
    segmentTable = new JTable(getTableModel());
    segmentTable.setDefaultRenderer(segmentTable.getColumnClass(0), getCellRenderer());
    startEnabling = -1;
    endEnabling = -1;

    JTextField tf = new JTextField();
    tf.setFont(Utilities.bigBoldValueFont);
    tf.setBorder(null);
    DefaultCellEditor editor = new DefaultCellEditor(tf);
    segmentTable.getColumnModel().getColumn(getColumnValue()).setCellEditor(editor);

    jbInit();
  }
Exemplo n.º 12
0
  /** Create a new, empty property sheet. */
  public PropertySheet() {
    super(new EnhancedTable());
    this.getPreferredSize();
    props = new ForClassPropertyList();

    // Add bean change event listener
    props.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            // XXX Should I fire a 'stop editing' event here?
            refresh();
          }
        });

    // Add table
    JTable table = getTable();
    MyTableModel tableModel = new MyTableModel();
    table.setModel(tableModel);
    table.setDefaultRenderer(InstancePropertyDescriptor.class, new MyCellRenderer());
    table.setDefaultEditor(InstancePropertyDescriptor.class, new MyCellEditor());
  }
Exemplo n.º 13
0
  /**
   * Creates dialog.
   *
   * @param aFrame parent frame.
   * @param aTitle dialog title.
   * @param aPublishingAvailable <code>TRUE</code> if publishing is available.
   * @param aPublishingLimit the number of guides the user can have published.
   * @param aPublishingLimitReached <code>TRUE</code> if the limit is reached.
   */
  public BasicGuideDialog(
      Frame aFrame,
      String aTitle,
      boolean aPublishingAvailable,
      int aPublishingLimit,
      boolean aPublishingLimitReached) {
    super(aFrame, aTitle);

    publishingAvailable = aPublishingAvailable;
    publishingLimit = aPublishingLimit;
    publishingLimitReached = aPublishingLimitReached;

    presentTitles = Collections.EMPTY_SET;
    model = new GuideIcons.ComboBoxModel();
    renderer = new IconListCellRenderer();
    readingListsModel = new ReadingListsTableModel();

    tblReadingLists = new JTable(readingListsModel);
    tblReadingLists.setDefaultRenderer(
        String.class, new ReadingListsTableCellRenderer(readingListsModel));
    UifUtilities.setTableColWidth(tblReadingLists, 2, 90);

    btnAddReadingList = new JButton(null, ResourceUtils.getIcon("add.icon"));
    btnAddReadingList.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onAddReadingList();
          }
        });
    btnRemoveList = new JButton(null, ResourceUtils.getIcon("delete.icon"));
    btnRemoveList.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onRemoveReadingList();
          }
        });

    // Publishing components
    chPublishingEnabled =
        ComponentsFactory.createCheckBox(Strings.message("guide.dialog.enable.publishing"));
    lbPublishingPublic = new JLabel(Strings.message("guide.dialog.public.visibility"));
    chPublishingPublic = new JCheckBox();
    lbPublishingTitle =
        ComponentsFactory.createLabel(Strings.message("guide.dialog.reading.list.title"));
    lbPublishingTags = ComponentsFactory.createLabel(Strings.message("guide.dialog.tags"));
    lbPublishingURL = new JLabel(Strings.message("guide.dialog.publicationurl"));
    lnkPublishingURL = new LinkLabel(Strings.message("guide.dialog.not.published.yet"));
    lbLastPublishingDate = new JLabel(Strings.message("guide.dialog.last.update.date"));
    tfLastPublishingDate = new JLabel(Strings.message("guide.dialog.never.updated"));
    tfPublishingTitle = new JTextField();
    lbPublishingTitle.setLabelFor(tfPublishingTitle);
    tfPublishingTags = new JTextField();
    lbPublishingTags.setLabelFor(tfPublishingTags);

    vhPublishingRating = new ValueHolder(1);
    sscPublishingRating =
        new StarsSelectionComponent(new BoundedRangeAdapter(vhPublishingRating, 0, 1, 5));
    lbPublishingRating = new JLabel(Strings.message("guide.dialog.rating"));

    btnCopyToClipboard = new JButton(Strings.message("guide.dialog.copy"));
    btnCopyToClipboard.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            CommonUtils.copyTextToClipboard(lnkPublishingURL.getText());
          }
        });

    onPublishingEnabled();
    chPublishingEnabled.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            onPublishingEnabled();
          }
        });

    chAllowNotifications =
        ComponentsFactory.createCheckBox(Strings.message("guide.dialog.allow.notifications"));
  }
Exemplo n.º 14
0
  /** 公開スタンプブラウズペインを生成する。 */
  private JPanel createBrowsePane() {

    JPanel browsePane = new JPanel();

    tableModel = new ListTableModel<PublishedTreeModel>(COLUMN_NAMES, 10, METHOD_NAMES, CLASSES);
    browseTable = new JTable(tableModel);
    for (int i = 0; i < COLUMN_WIDTH.length; i++) {
      browseTable.getColumnModel().getColumn(i).setPreferredWidth(COLUMN_WIDTH[i]);
    }
    browseTable.setDefaultRenderer(Object.class, new OddEvenRowRenderer());

    importBtn = new JButton("インポート");
    importBtn.setEnabled(false);
    cancelBtn = new JButton("閉じる");
    deleteBtn = new JButton("削除");
    deleteBtn.setEnabled(false);
    publicLabel = new JLabel("グローバル", WEB_ICON, SwingConstants.CENTER);
    localLabel = new JLabel("院内", HOME_ICON, SwingConstants.CENTER);
    importedLabel = new JLabel("インポート済", FLAG_ICON, SwingConstants.CENTER);

    JScrollPane tableScroller = new JScrollPane(browseTable);
    tableScroller.getViewport().setPreferredSize(new Dimension(730, 380));

    // レイアウトする
    browsePane.setLayout(new BorderLayout(0, 17));
    JPanel flagPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 7, 5));
    flagPanel.add(localLabel);
    flagPanel.add(publicLabel);
    flagPanel.add(importedLabel);
    JPanel cmdPanel =
        GUIFactory.createCommandButtonPanel(new JButton[] {cancelBtn, deleteBtn, importBtn});
    browsePane.add(flagPanel, BorderLayout.NORTH);
    browsePane.add(tableScroller, BorderLayout.CENTER);
    browsePane.add(cmdPanel, BorderLayout.SOUTH);

    // レンダラを設定する
    PublishTypeRenderer pubTypeRenderer = new PublishTypeRenderer();
    browseTable.getColumnModel().getColumn(4).setCellRenderer(pubTypeRenderer);
    ImportedRenderer importedRenderer = new ImportedRenderer();
    browseTable.getColumnModel().getColumn(5).setCellRenderer(importedRenderer);

    // BrowseTableをシングルセレクションにする
    browseTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    ListSelectionModel sleModel = browseTable.getSelectionModel();
    sleModel.addListSelectionListener(
        new ListSelectionListener() {

          @Override
          public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting() == false) {
              int row = browseTable.getSelectedRow();
              PublishedTreeModel model = tableModel.getObject(row);
              if (model != null) {
                if (model.isImported()) {
                  importBtn.setEnabled(false);
                  deleteBtn.setEnabled(true);
                } else {
                  importBtn.setEnabled(true);
                  deleteBtn.setEnabled(false);
                }
              } else {
                importBtn.setEnabled(false);
                deleteBtn.setEnabled(false);
              }
            }
          }
        });

    // import
    importBtn.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            importPublishedTree();
          }
        });

    // remove
    deleteBtn.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            removeImportedTree();
          }
        });

    // キャンセル
    cancelBtn.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            stop();
          }
        });

    return browsePane;
  }
Exemplo n.º 15
0
  /**
   * Constructor initialises the table and a popup tool, as well as initialising the required GUI
   * elements. It adds action listeners for the three main buttons, which include basic user input
   * validation checking.
   */
  public TableAttributeEditor(JFrame MyOwner) {
    // As usual, it is insanely hard to get the swing components to display
    // and work properly.  If JTable is not displayed in a scroll pane no headers are
    // displayed, and you have to do it manually.  (If you *do* display it
    // in a scrollbar, in this instance, it screws up sizing)
    // The broken header mis-feature is only mentioned in the tutorial,
    // not in the api doco - go figure.

    super();

    owner = MyOwner;

    // final JPanel mainPanel = (JPanel)this;

    tableData = new AttributeTableModel();

    attributeTable = new JTable(tableData);
    // attributeTable.setRowHeight(20);	// This may be needed, depends on how fussy people get about
    // the bottom of letters like 'y' getting cut off when the cell is selected - bug 3013.

    popupTableTool = new SmartPopupTableTool(attributeTable, tableData, (JXplorerBrowser) owner);

    // Set the renderer for the attribute type...
    final AttributeTypeCellRenderer typeRenderer = new AttributeTypeCellRenderer();

    attributeTable.setDefaultRenderer(AttributeNameAndType.class, typeRenderer);

    // Set the renderer for the attribute value...
    final AttributeValueCellRenderer valueRenderer = new AttributeValueCellRenderer();

    attributeTable.setDefaultRenderer(AttributeValue.class, valueRenderer);

    // Set the editor for the attribute value...
    myEditor = new AttributeValueCellEditor(owner);

    attributeTable.setDefaultEditor(AttributeValue.class, myEditor);

    attributeTable.getTableHeader().setReorderingAllowed(false);

    currentDN = null;

    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    buttonPanel.add(
        submit =
            new CBButton(
                CBIntText.get("Submit"), CBIntText.get("Submit your changes to the Directory.")));
    buttonPanel.add(
        reset =
            new CBButton(
                CBIntText.get("Reset"),
                CBIntText.get("Reset this entry i.e. cancels any changes.")));
    buttonPanel.add(
        changeClass =
            new CBButton(
                CBIntText.get("Change Classes"),
                CBIntText.get("Change the Object Class of this entry.")));
    buttonPanel.add(
        opAttrs =
            new CBButton(
                CBIntText.get("Properties"),
                CBIntText.get("View the Operational Attributes of this entry.")));

    // I don't really understand why we have to do this...
    // but without it these buttons over ride the default
    // button (Search Bar's search button), if they have
    // been clicked and the user hits the enter key?
    opAttrs.setDefaultCapable(false);
    submit.setDefaultCapable(false);
    reset.setDefaultCapable(false);
    changeClass.setDefaultCapable(false);

    setLayout(new BorderLayout(10, 10));

    tableScroller = new JScrollPane();
    attributeTable.setBackground(Color.white);
    tableScroller.setPreferredSize(new Dimension(300, 285));
    tableScroller.setViewportView(attributeTable);
    add(tableScroller, BorderLayout.CENTER);
    add(buttonPanel, BorderLayout.SOUTH);

    if ("true".equals(JXConfig.getProperty("lock.read.only")))
      title = CBIntText.get("Table Viewer");
    else title = CBIntText.get("Table Editor");

    setVisible(true);

    // triggers adding operational attributes of the current entry.
    opAttrs.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            displayOperationalAttributes();
          }
        });

    reset.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            myEditor.stopCellEditing();
            // tableData.reset();
            displayEntry(originalEntry, dataSource, false);
          }
        });

    submit.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            doSubmit();
          }
        });

    // This allows the user to change the objectclass attribute.
    // This is pretty tricky, because it changes what attributes are available.
    changeClass.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            changeClass();
          }
        });

    attributeTable.addMouseListener(
        new MouseAdapter() {
          public void mousePressed(MouseEvent e) {
            if (!doPopupStuff(e)) super.mousePressed(e);
          }

          public void mouseReleased(MouseEvent e) {
            if (!doPopupStuff(e)) super.mouseReleased(e);
          }

          // TODO need to have a way to call this from a keystroke...
          public boolean doPopupStuff(MouseEvent e) {
            if (e.isPopupTrigger() == false) return false;

            int row = attributeTable.rowAtPoint(new Point(e.getX(), e.getY()));

            attributeTable.clearSelection();
            attributeTable.addRowSelectionInterval(row, row);
            attributeTable.repaint();

            popupTableTool.registerCurrentRow(
                (AttributeNameAndType) attributeTable.getValueAt(row, 0),
                (AttributeValue) attributeTable.getValueAt(row, 1),
                row,
                tableData.getRDN()); // active path also set by valueChanged
            popupTableTool.show(attributeTable, e.getX(), e.getY());
            popupTableTool.registerCellEditor(myEditor); // TE: for bug fix 3107.
            return true;
          }
        });
  }
Exemplo n.º 16
0
  // {{{ InstallPanel constructor
  InstallPanel(PluginManager window, boolean updates) {
    super(new BorderLayout(12, 12));

    this.window = window;
    this.updates = updates;

    setBorder(new EmptyBorder(12, 12, 12, 12));

    final JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    split.setResizeWeight(0.75);
    /* Setup the table */
    table = new JTable(pluginModel = new PluginTableModel());
    table.setShowGrid(false);
    table.setIntercellSpacing(new Dimension(0, 0));
    table.setRowHeight(table.getRowHeight() + 2);
    table.setPreferredScrollableViewportSize(new Dimension(500, 200));
    table.setDefaultRenderer(
        Object.class,
        new TextRenderer((DefaultTableCellRenderer) table.getDefaultRenderer(Object.class)));
    table.addFocusListener(new TableFocusHandler());
    InputMap tableInputMap = table.getInputMap(JComponent.WHEN_FOCUSED);
    ActionMap tableActionMap = table.getActionMap();
    tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), "tabOutForward");
    tableActionMap.put("tabOutForward", new KeyboardAction(KeyboardCommand.TAB_OUT_FORWARD));
    tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK), "tabOutBack");
    tableActionMap.put("tabOutBack", new KeyboardAction(KeyboardCommand.TAB_OUT_BACK));
    tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "editPlugin");
    tableActionMap.put("editPlugin", new KeyboardAction(KeyboardCommand.EDIT_PLUGIN));
    tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "closePluginManager");
    tableActionMap.put(
        "closePluginManager", new KeyboardAction(KeyboardCommand.CLOSE_PLUGIN_MANAGER));

    TableColumn col1 = table.getColumnModel().getColumn(0);
    TableColumn col2 = table.getColumnModel().getColumn(1);
    TableColumn col3 = table.getColumnModel().getColumn(2);
    TableColumn col4 = table.getColumnModel().getColumn(3);
    TableColumn col5 = table.getColumnModel().getColumn(4);

    col1.setPreferredWidth(30);
    col1.setMinWidth(30);
    col1.setMaxWidth(30);
    col1.setResizable(false);

    col2.setPreferredWidth(180);
    col3.setPreferredWidth(130);
    col4.setPreferredWidth(70);
    col5.setPreferredWidth(70);

    JTableHeader header = table.getTableHeader();
    header.setReorderingAllowed(false);
    header.addMouseListener(new HeaderMouseHandler());
    header.setDefaultRenderer(
        new HeaderRenderer((DefaultTableCellRenderer) header.getDefaultRenderer()));

    scrollpane = new JScrollPane(table);
    scrollpane.getViewport().setBackground(table.getBackground());
    split.setTopComponent(scrollpane);

    /* Create description */
    JScrollPane infoPane = new JScrollPane(infoBox = new PluginInfoBox());
    infoPane.setPreferredSize(new Dimension(500, 100));
    split.setBottomComponent(infoPane);

    EventQueue.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            split.setDividerLocation(0.75);
          }
        });

    final JTextField searchField = new JTextField();
    searchField.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_UP) {
              table.dispatchEvent(e);
              table.requestFocus();
            }
          }
        });
    searchField
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              void update() {
                pluginModel.setFilterString(searchField.getText());
              }

              @Override
              public void changedUpdate(DocumentEvent e) {
                update();
              }

              @Override
              public void insertUpdate(DocumentEvent e) {
                update();
              }

              @Override
              public void removeUpdate(DocumentEvent e) {
                update();
              }
            });
    table.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            int i = table.getSelectedRow(), n = table.getModel().getRowCount();
            if (e.getKeyCode() == KeyEvent.VK_DOWN && i == (n - 1)
                || e.getKeyCode() == KeyEvent.VK_UP && i == 0) {
              searchField.requestFocus();
              searchField.selectAll();
            }
          }
        });
    Box filterBox = Box.createHorizontalBox();
    filterBox.add(new JLabel("Filter : "));
    filterBox.add(searchField);
    add(BorderLayout.NORTH, filterBox);
    add(BorderLayout.CENTER, split);

    /* Create buttons */
    Box buttons = new Box(BoxLayout.X_AXIS);

    buttons.add(new InstallButton());
    buttons.add(Box.createHorizontalStrut(12));
    buttons.add(new SelectallButton());
    buttons.add(chooseButton = new ChoosePluginSet());
    buttons.add(new ClearPluginSet());
    buttons.add(Box.createGlue());
    buttons.add(new SizeLabel());

    add(BorderLayout.SOUTH, buttons);
    String path = jEdit.getProperty(PluginManager.PROPERTY_PLUGINSET, "");
    if (!path.isEmpty()) {
      loadPluginSet(path);
    }
  } // }}}
  public JComponent createComponentImpl() {
    final DefaultTableModel tableModel = createModel();
    myTable = new JBTable(tableModel);
    myTable.setIntercellSpacing(new Dimension(0, 0));
    myTable.setDefaultRenderer(TableItem.class, new MyRenderer());
    myTable.setShowGrid(false);
    myTable.setDragEnabled(false);
    myTable.setShowHorizontalLines(false);
    myTable.setShowVerticalLines(false);
    myTable.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

    JPanel tablePanel =
        ToolbarDecorator.createDecorator(myTable)
            .setAddAction(
                new AnActionButtonRunnable() {
                  @Override
                  public void run(AnActionButton button) {
                    FileChooserDescriptor myDescriptor =
                        FileChooserDescriptorFactory.createSingleFolderDescriptor();
                    myDescriptor.setTitle(
                        ProjectBundle.message("add.external.annotations.path.title"));
                    myDescriptor.setDescription(
                        ProjectBundle.message("add.external.annotations.path.description"));
                    VirtualFile[] files =
                        FileChooser.chooseFiles(myDescriptor, myTable, myProject, null);
                    final MyTableModel tableModel = (MyTableModel) myTable.getModel();
                    boolean changes = false;
                    for (final VirtualFile file : files) {
                      if (file != null) {
                        tableModel.addTableItem(new TableItem(file));
                        changes = true;
                      }
                    }
                    if (changes) {
                      saveData();
                      TableUtil.selectRows(myTable, new int[] {tableModel.getRowCount() - 1});
                    }
                  }
                })
            .setRemoveAction(
                new AnActionButtonRunnable() {
                  @Override
                  public void run(AnActionButton button) {
                    final List removedItems = TableUtil.removeSelectedItems(myTable);
                    if (removedItems.size() > 0) {
                      saveData();
                    }
                  }
                })
            .createPanel();

    final JPanel mainPanel = new JPanel(new BorderLayout());

    mainPanel.add(tablePanel, BorderLayout.CENTER);
    mainPanel.add(
        new JBLabel(
            ProjectBundle.message("project.roots.external.annotations.description"),
            UIUtil.ComponentStyle.SMALL,
            UIUtil.FontColor.BRIGHTER),
        BorderLayout.NORTH);
    return mainPanel;
  }
  public DetectedPluginsPanel() {
    super(PluginDownloader.class);
    final JTable entryTable = getEntryTable();
    myHeader = new PluginHeaderPanel(null, entryTable);
    entryTable.setTableHeader(null);
    entryTable.setDefaultRenderer(
        PluginDownloader.class,
        new ColoredTableCellRenderer() {
          protected void customizeCellRenderer(
              final JTable table,
              final Object value,
              final boolean selected,
              final boolean hasFocus,
              final int row,
              final int column) {
            setBorder(null);
            final PluginDownloader downloader = (PluginDownloader) value;
            if (downloader != null) {
              final String pluginName = downloader.getPluginName();
              append(pluginName, SimpleTextAttributes.REGULAR_ATTRIBUTES);
              final IdeaPluginDescriptor ideaPluginDescriptor =
                  PluginManager.getPlugin(PluginId.getId(downloader.getPluginId()));
              if (ideaPluginDescriptor != null) {
                final String oldPluginName = ideaPluginDescriptor.getName();
                if (!Comparing.strEqual(pluginName, oldPluginName)) {
                  append(" - " + oldPluginName, SimpleTextAttributes.REGULAR_ATTRIBUTES);
                }
              }
              final String loadedVersion = downloader.getPluginVersion();
              if (loadedVersion != null
                  || (ideaPluginDescriptor != null && ideaPluginDescriptor.getVersion() != null)) {
                final String installedVersion =
                    ideaPluginDescriptor != null && ideaPluginDescriptor.getVersion() != null
                        ? "v. "
                            + ideaPluginDescriptor.getVersion()
                            + (loadedVersion != null ? " -> " : "")
                        : "";
                final String availableVersion = loadedVersion != null ? loadedVersion : "";
                append(
                    " (" + installedVersion + availableVersion + ")",
                    SimpleTextAttributes.GRAY_ATTRIBUTES);
              }
            }
          }
        });
    entryTable
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent e) {
                final int selectedRow = entryTable.getSelectedRow();
                if (selectedRow != -1) {
                  final PluginDownloader selection = getValueAt(selectedRow);
                  final IdeaPluginDescriptor descriptor = selection.getDescriptor();
                  if (descriptor != null) {
                    PluginManagerMain.pluginInfoUpdate(
                        descriptor, null, myDescriptionPanel, myHeader, null);
                  }
                }
              }
            });
    setCheckboxColumnName("");
    myDescriptionPanel.setPreferredSize(new Dimension(400, -1));
    myDescriptionPanel.setEditable(false);
    myDescriptionPanel.setContentType(UIUtil.HTML_MIME);
    myDescriptionPanel.addHyperlinkListener(new PluginManagerMain.MyHyperlinkListener());
    removeAll();

    final Splitter splitter = new Splitter(false);
    splitter.setFirstComponent(ScrollPaneFactory.createScrollPane(entryTable));
    splitter.setSecondComponent(ScrollPaneFactory.createScrollPane(myDescriptionPanel));
    add(splitter, BorderLayout.CENTER);
  }
Exemplo n.º 19
0
  @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Generated Code">
  private void initComponents() {
    this.title = new javax.swing.JLabel();
    this.iconLabel = new javax.swing.JLabel();
    this.exportBtn = new javax.swing.JButton();
    this.searchBtn = new javax.swing.JButton();
    JScrollPane scroll = new JScrollPane();
    this.table = new javax.swing.JTable();
    this.search = new javax.swing.JTextField();

    Platform.runLater(
        () -> {
          this.graphPanel.setScene(createScene());
        });

    this.title.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
    this.title.setText("text");

    this.search = new JTextField("Search");
    this.search.setForeground(Color.LIGHT_GRAY);

    this.searchBtn.setText("Search");
    this.searchBtn.addActionListener(
        (e) -> {
          String searchString = search.getText();

          DefaultTableModel resultModel = getNewModel();
          DefaultTableModel oldModel =
              this.modelBackup == null
                  ? (DefaultTableModel) this.table.getModel()
                  : this.modelBackup;
          Pattern p = Pattern.compile(String.format(".*?%s.*?", searchString));
          int rows = oldModel.getRowCount();
          int cols = oldModel.getColumnCount();
          Vector dv = oldModel.getDataVector();

          for (int row = 0; row < rows; row++) {
            Vector v = (Vector) dv.get(row);
            for (int col = 0; col < cols; col++) {
              Object o = v.get(col);
              if (o != null) {
                Matcher m = p.matcher(o.toString());
                if (m.matches()) {
                  resultModel.addRow(v);
                  break;
                }
              }
            }
          }

          if (resultModel.getRowCount() != oldModel.getRowCount()
              && resultModel.getRowCount() > 0) {
            if (this.modelBackup == null) {
              this.modelBackup = oldModel;
            }
            this.table.setModel(resultModel);
            resultModel.fireTableDataChanged();
          }
        });

    table.setDefaultRenderer(
        Integer.class,
        new DefaultTableCellRenderer() {
          @Override
          public Component getTableCellRendererComponent(
              JTable table,
              Object value,
              boolean isSelected,
              boolean hasFocus,
              int row,
              int column) {
            JLabel label =
                (JLabel)
                    super.getTableCellRendererComponent(
                        table, value, isSelected, hasFocus, row, column);
            label.setHorizontalAlignment(JLabel.LEFT);
            return label;
          }
        });

    this.search.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if ("search".equalsIgnoreCase(ConnectionDialog.this.search.getText())) {
              ConnectionDialog.this.search.setForeground(Color.LIGHT_GRAY);
            } else {
              ConnectionDialog.this.search.setForeground(Color.BLACK);
            }
            if (ConnectionDialog.this.search.getText().length() == 0
                && ConnectionDialog.this.modelBackup != null) {
              ConnectionDialog.this.table.setModel(ConnectionDialog.this.modelBackup);
              ConnectionDialog.this.modelBackup.fireTableDataChanged();
              ConnectionDialog.this.modelBackup = null;
            }
          }
        });
    MouseAdapter removableListner =
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if ("search".equalsIgnoreCase(ConnectionDialog.this.search.getText())) {
              ConnectionDialog.this.search.setText("");
              ConnectionDialog.this.search.removeMouseListener(this);
            }
          }
        };
    this.search.addMouseListener(removableListner);

    this.iconLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    this.iconLabel.setIcon(Icons.Error.getIcon32()); // NOI18N
    this.iconLabel.setBorder(
        javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(204, 204, 204)));

    this.exportBtn.setText("Export to CSV");
    this.exportBtn.addActionListener(this::exportBtnActionPerformed);
    this.hideBroadCast = new JCheckBox("Hide Broadcast / Multicast");
    this.hideBroadCast.addActionListener(this::toggleBroadcastVisibility);
    this.hideBroadCast.setSelected(true);
    scroll.setViewportView(this.table);
    JPanel p = new JPanel();
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(p);
    p.setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(
                                scroll, javax.swing.GroupLayout.DEFAULT_SIZE, 976, Short.MAX_VALUE)
                            .addComponent(
                                this.graphPanel,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                976,
                                Short.MAX_VALUE)
                            //                    .addComponent(display)
                            .addGroup(
                                layout
                                    .createSequentialGroup()
                                    .addComponent(this.iconLabel)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(this.title)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        Short.MAX_VALUE)
                                    .addComponent(this.searchBtn)
                                    .addContainerGap()
                                    .addComponent(this.search)))
                    .addContainerGap()));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(this.iconLabel)
                            .addGroup(
                                layout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(this.title)
                                    .addComponent(this.searchBtn)
                                    .addComponent(
                                        this.search,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        21,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(
                        scroll, javax.swing.GroupLayout.DEFAULT_SIZE, 343, Short.MAX_VALUE)
                    .addComponent(
                        this.graphPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 342, Short.MAX_VALUE)
                    .addContainerGap()));
    // 457, 228
    setLayout(new BorderLayout());
    add(p, BorderLayout.CENTER);

    JPanel jPanel1 = new JPanel();
    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
        jPanel1Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                jPanel1Layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(this.hideBroadCast)
                    .addPreferredGap(
                        javax.swing.LayoutStyle.ComponentPlacement.RELATED, 395, Short.MAX_VALUE)
                    .addComponent(this.exportBtn)
                    .addContainerGap()));
    jPanel1Layout.setVerticalGroup(
        jPanel1Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                jPanel1Layout
                    .createSequentialGroup()
                    //                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
                    // Short.MAX_VALUE)
                    .addGroup(
                        jPanel1Layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(
                                this.hideBroadCast, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(
                                this.exportBtn, javax.swing.GroupLayout.Alignment.TRAILING))
                    .addContainerGap()));

    add(jPanel1, BorderLayout.SOUTH);
  } // </editor-fold>
Exemplo n.º 20
0
  public DownloadGUI() {

    setTitle("Rav's Download Manager");

    setSize(640, 480);

    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            actionExit();
          }
        });

    JPanel addPanel = new JPanel();
    pauseButton = new JButton("", new ImageIcon("icons/pause.gif"));
    pauseButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            actionPause();
          }
        });
    pauseButton.setEnabled(false);
    addPanel.add(pauseButton);
    resumeButton = new JButton("", new ImageIcon("icons/resume.gif"));
    resumeButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            actionResume();
          }
        });
    resumeButton.setEnabled(false);
    addPanel.add(resumeButton);
    cancelButton = new JButton("", new ImageIcon("icons/cancel.gif"));
    cancelButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            actionCancel();
          }
        });
    cancelButton.setEnabled(false);
    addPanel.add(cancelButton);
    clearButton = new JButton("", new ImageIcon("icons/clear.gif"));
    clearButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            actionClear();
          }
        });
    clearButton.setEnabled(false);
    addPanel.add(clearButton);

    JPanel addPane2 = new JPanel();
    addTextField = new JTextField(30);
    addPane2.add(addTextField);
    JButton addButton = new JButton("", new ImageIcon("icons/add.gif"));
    addButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            actionAdd();
          }
        });
    addPane2.add(addButton);

    tableModel = new DownloadList();
    table = new JTable(tableModel);
    table
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent e) {
                tableSelectionChanged();
              }
            });

    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    ProgressBar renderer = new ProgressBar(0, 100);
    renderer.setStringPainted(true);
    table.setDefaultRenderer(JProgressBar.class, renderer);

    table.setRowHeight((int) renderer.getPreferredSize().getHeight());

    JPanel downloadsPanel = new JPanel();
    downloadsPanel.setBorder(BorderFactory.createTitledBorder("Downloads"));
    downloadsPanel.setLayout(new BorderLayout());
    downloadsPanel.add(new JScrollPane(table), BorderLayout.CENTER);

    getContentPane().setLayout(new GridLayout(3, 1));
    getContentPane().add(addPane2);
    getContentPane().add(addPanel);
    getContentPane().add(downloadsPanel);
  }
  public NetworkTable(Properties display) {
    this.display = display;

    model =
        new GenericTableModel(
            new String[] {" ", "Address", "Label", "Description", "Pivot"}, "Address", 256);
    table = new ATable(model);
    TableRowSorter sorter = new TableRowSorter(model);
    sorter.toggleSortOrder(1);

    Comparator hostCompare =
        new Comparator() {
          public int compare(Object a, Object b) {
            long aa = Route.ipToLong(a + "");
            long bb = Route.ipToLong(b + "");

            if (aa > bb) {
              return 1;
            } else if (aa < bb) {
              return -1;
            } else {
              return 0;
            }
          }

          public boolean equals(Object a, Object b) {
            return (a + "").equals(b + "");
          }
        };

    sorter.setComparator(1, hostCompare);
    sorter.setComparator(4, hostCompare);

    table.setRowSorter(sorter);
    table.setColumnSelectionAllowed(false);

    table.getColumn("Address").setPreferredWidth(125);
    table.getColumn("Label").setPreferredWidth(125);
    table.getColumn("Pivot").setPreferredWidth(125);
    table.getColumn(" ").setPreferredWidth(32);
    table.getColumn(" ").setMaxWidth(32);
    table.getColumn("Description").setPreferredWidth(500);

    final TableCellRenderer parent = table.getDefaultRenderer(Object.class);
    table.setDefaultRenderer(
        Object.class,
        new TableCellRenderer() {
          public Component getTableCellRendererComponent(
              JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
            JLabel component =
                (JLabel)
                    parent.getTableCellRendererComponent(table, value, isSelected, false, row, col);

            if (col == 4 && Boolean.TRUE.equals(model.getValueAt(table, row, "Active"))) {
              component.setFont(component.getFont().deriveFont(Font.BOLD));
            } else if (col == 1 && !"".equals(model.getValueAt(table, row, "Description"))) {
              component.setFont(component.getFont().deriveFont(Font.BOLD));
            } else {
              component.setFont(component.getFont().deriveFont(Font.PLAIN));
            }

            String tip = model.getValueAt(table, row, "Tooltip") + "";

            if (tip.length() > 0) {
              component.setToolTipText(tip);
            }
            return component;
          }
        });

    table
        .getColumn(" ")
        .setCellRenderer(
            new TableCellRenderer() {
              public Component getTableCellRendererComponent(
                  JTable table,
                  Object value,
                  boolean isSelected,
                  boolean hasFocus,
                  int row,
                  int col) {
                JLabel component =
                    (JLabel)
                        parent.getTableCellRendererComponent(
                            table, value, isSelected, false, row, col);
                component.setIcon(new ImageIcon((Image) model.getValueAt(table, row, "Image")));
                component.setText("");

                String tip = model.getValueAt(table, row, "Tooltip") + "";

                if (tip.length() > 0) {
                  component.setToolTipText(tip);
                }

                return component;
              }
            });

    table.addMouseListener(
        new MouseAdapter() {
          public void all(MouseEvent ev) {
            if (ev.isPopupTrigger()) {
              popup.showGraphPopup(getSelectedHosts(), ev);
              ev.consume();
            }
          }

          public void mouseClicked(MouseEvent ev) {
            all(ev);
          }

          public void mousePressed(MouseEvent ev) {
            all(ev);
          }

          public void mouseReleased(MouseEvent ev) {
            all(ev);
          }
        });

    setLayout(new BorderLayout());
    scroller = new JScrollPane(table);
    add(scroller, BorderLayout.CENTER);
  }
Exemplo n.º 22
0
  public JComponent createComponentImpl() {
    final JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
    mainPanel.setPreferredSize(new Dimension(-1, 200));
    final DefaultTableModel tableModel = createModel();
    myTable = new Table(tableModel);
    myTable.setIntercellSpacing(new Dimension(0, 0));
    myTable.setDefaultRenderer(TableItem.class, new MyRenderer());
    myTable.setShowGrid(false);
    myTable.setDragEnabled(false);
    myTable.setShowHorizontalLines(false);
    myTable.setShowVerticalLines(false);
    myTable.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

    myAddPathButton = new JButton(ProjectBundle.message("module.javadoc.add.path.button"));
    myAddPathButton.addActionListener(new AddPathActionListener());

    myRemoveButton = new JButton(ProjectBundle.message("module.javadoc.remove.button"));
    myRemoveButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            final List removedItems = TableUtil.removeSelectedItems(myTable);
            if (removedItems.size() > 0) {
              saveData();
            }
          }
        });

    final JPanel panel = new JPanel(new GridBagLayout());
    panel.add(
        myAddPathButton,
        new GridBagConstraints(
            0,
            GridBagConstraints.RELATIVE,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.NORTH,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 6, 0, 0),
            0,
            0));
    panel.add(
        myRemoveButton,
        new GridBagConstraints(
            0,
            GridBagConstraints.RELATIVE,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTH,
            GridBagConstraints.HORIZONTAL,
            new Insets(6, 6, 0, 0),
            0,
            0));

    mainPanel.add(ScrollPaneFactory.createScrollPane(myTable), BorderLayout.CENTER);
    mainPanel.add(panel, BorderLayout.EAST);
    final PanelWithText panelWithText =
        new PanelWithText(ProjectBundle.message("project.roots.external.annotations.description"));
    panelWithText.setBorder(null);
    mainPanel.add(panelWithText, BorderLayout.NORTH);

    myTable
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent e) {
                if (e.getValueIsAdjusting()) {
                  return;
                }
                final int selectedIndex = myTable.getSelectedRow();
                myRemoveButton.setEnabled(selectedIndex >= 0);
              }
            });
    if (tableModel.getRowCount() > 0) {
      TableUtil.selectRows(myTable, new int[] {0});
    } else {
      myRemoveButton.setEnabled(false);
    }
    return mainPanel;
  }