Beispiel #1
0
  /**
   * Gets the data from the <tt>ConfigurationService</tt> that will construct the
   * <tt>PropsTableModel</tt> for the properties table.
   *
   * @return The data necessary to initialize the <tt>PropsTableModel</tt>
   */
  private Object[][] initTableModel() {
    ConfigurationService confService = PropertiesEditorActivator.getConfigurationService();
    java.util.List<String> properties = confService.getAllPropertyNames();
    Object[][] data = new Object[properties.size()][];
    int i = 0;

    for (String property : properties) {
      data[i++] = new Object[] {property, confService.getProperty(property)};
    }

    return data;
  }
Beispiel #2
0
  /** Creates an instance <tt>PropertiesEditorPanel</tt>. */
  public PropertiesEditorPanel() {
    super(new BorderLayout());

    /**
     * Instantiates the properties table and adds selection model and listener and adds a row sorter
     * to the table model
     */
    ResourceManagementService r = PropertiesEditorActivator.getResourceManagementService();
    String[] columnNames =
        new String[] {r.getI18NString("service.gui.NAME"), r.getI18NString("service.gui.VALUE")};

    propsTable = new JTable(new PropsTableModel(initTableModel(), columnNames));
    propsTable.setRowSorter(new TableRowSorter<TableModel>(propsTable.getModel()));
    propsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    PropsListSelectionListener selectionListener = new PropsListSelectionListener();

    propsTable.getSelectionModel().addListSelectionListener(selectionListener);
    propsTable.getColumnModel().getSelectionModel().addListSelectionListener(selectionListener);

    JScrollPane scrollPane = new JScrollPane(propsTable);
    SearchField searchField = new SearchField("", propsTable);

    buttonsPanel = new ButtonsPanel(propsTable, searchField);

    centerPanel = new TransparentPanel(new BorderLayout());
    centerPanel.add(scrollPane, BorderLayout.CENTER);
    centerPanel.add(buttonsPanel, BorderLayout.EAST);

    JLabel needRestart = new JLabel(r.getI18NString("plugin.propertieseditor.NEED_RESTART"));

    needRestart.setForeground(Color.RED);

    TransparentPanel searchPanel = new TransparentPanel(new BorderLayout(5, 0));

    searchPanel.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 5));
    searchPanel.add(searchField, BorderLayout.CENTER);

    setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
    add(searchPanel, BorderLayout.NORTH);
    add(centerPanel, BorderLayout.CENTER);
    add(needRestart, BorderLayout.SOUTH);
  }