OptionView.java revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* ident "%Z%%M% %I% %E% SMI"
*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/**
* The view for options. Only displays locally defined options.
*/
public class OptionView implements View {
// Model for the table displaying the options.
class OptionTableModel extends AbstractTableModel {
private boolean firstLoad;
public OptionTableModel() {
firstLoad = true;
}
public void load() {
// Update status line
// Kick off background loading
}
protected void doneLoading() {
if (firstLoad) {
firstLoad = false;
}
// Check for any ill-defined options, tell user about them
}
}
objs[0] =
}
}
}
public int getRowCount() {
return 0;
} else {
}
}
public int getColumnCount() {
return 6;
}
switch (column) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
default:
return null;
}
}
switch (column) {
case 0:
case 1:
case 3:
return String.class;
case 2:
case 4:
case 5:
return Integer.class;
default:
super.getColumnClass(column);
}
return null;
}
switch (column) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
default:
super.getColumnName(column);
}
return null;
}
}
}
// Background loader for options.
class OptionLoader extends SwingWorker {
try {
} catch (final BridgeException e) {
// Since we're in a background thread, ask Swing to run ASAP.
public void run() {
}
});
return null;
}
}
public void finished() {
}
}
}
/*
* Reload data when any dialogs this view launches indicate they've
* changed the data
*/
class DialogListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
reload();
}
}
}
private AutosizingTable optionTable;
private JScrollPane optionPane;
private JCheckBoxMenuItem showGrid;
private JMenuItem optionHelp;
private static boolean firstview = true;
private TableSorter sortedTableModel;
public OptionView() {
// Create table to display in data area
optionTableModel = new OptionTableModel();
// Use table which resizes columns to fit data
// Allow clicks in header to adjust sorting column
private int sortModelIndex = -1;
private TableCellRenderer savedRenderer;
private SortedHeaderRenderer sortedRenderer =
public void actionPerformed(ActionEvent e) {
// Clear the selection if sorting is changed
// Change the header rendering to show sorting column
int viewIndex =
if (sortModelIndex != -1) {
int sortViewIndex =
}
/*
* Save the column currently being sorted so we can restore
* the renderer later. We save model columns rather than
* view columns because model columns are invariant while
* view columns can be reordered with confusion resulting.
*/
TableColumn c =
savedRenderer = c.getHeaderRenderer();
}
});
// Make it scrollable
// Make double-clicks the same as Edit->Properties
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
}
}
});
// Create menu items
true);
public void actionPerformed(ActionEvent e) {
}
});
public void actionPerformed(ActionEvent e) {
}
});
/*
* Build the sets of menu items which we'll return to
* MainFrame when it asks for them.
*/
}
// Listen for selections events, manipulate menu item state as needed
new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
// Notify listeners that our selection state may have changed
}
});
}
}
// Return custom menus we want added, in our case none.
public Enumeration menus() {
return null;
}
// Return menu items for each menu as requested by MainFrame
}
public Component getDisplay() {
return optionPane;
}
if (state) {
// Things we do only the first time we're displayed
if (firstview) {
MainFrame.class, optionTable);
firstview = false;
}
}
}
false));
return;
}
}
// Got to the end, wrap around
for (int i = 0; i < startRow; ++i) {
false));
return;
}
}
}
public void handleCreate() {
d.addActionListener(new DialogListener());
d.pack();
d.setVisible(true);
}
public void handleDelete() {
if (selectedRow == -1) {
return;
}
d.addActionListener(new DialogListener());
d.pack();
d.setVisible(true);
}
public void handleDuplicate() {
if (selectedRow == -1) {
return;
}
d.addActionListener(new DialogListener());
d.pack();
d.setVisible(true);
}
public void handleProperties() {
if (selectedRow == -1) {
return;
}
d.addActionListener(new DialogListener());
d.pack();
d.setVisible(true);
}
public void handleUpdate() {
reload();
}
private void reload() {
}
}
}
private void notifySelectionListeners() {
while (en.hasMoreElements()) {
l.valueChanged();
}
}
public boolean isSelectionEmpty() {
}
public boolean isSelectionMultiple() {
return false; // Multiple selection is not allowed.
}
}