1 /* |
|
2 * CDDL HEADER START |
|
3 * |
|
4 * The contents of this file are subject to the terms of the |
|
5 * Common Development and Distribution License (the "License"). |
|
6 * You may not use this file except in compliance with the License. |
|
7 * |
|
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
|
9 * or http://www.opensolaris.org/os/licensing. |
|
10 * See the License for the specific language governing permissions |
|
11 * and limitations under the License. |
|
12 * |
|
13 * When distributing Covered Code, include this CDDL HEADER in each |
|
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
|
15 * If applicable, add the following below this CDDL HEADER, with the |
|
16 * fields enclosed by brackets "[]" replaced with your own identifying |
|
17 * information: Portions Copyright [yyyy] [name of copyright owner] |
|
18 * |
|
19 * CDDL HEADER END |
|
20 */ |
|
21 |
|
22 /* |
|
23 * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. |
|
24 */ |
|
25 |
|
26 package com.oracle.solaris.vp.panels.svcs.client.swing; |
|
27 |
|
28 import java.util.*; |
|
29 import javax.swing.*; |
|
30 import com.oracle.solaris.vp.panel.common.action.StructuredAction; |
|
31 import com.oracle.solaris.vp.panel.common.model.*; |
|
32 import com.oracle.solaris.vp.panel.common.smf.InstanceManagedObject; |
|
33 import com.oracle.solaris.vp.panel.swing.model.ManagedObjectPropInfo; |
|
34 import com.oracle.solaris.vp.panel.swing.view.TableObjectsPanel; |
|
35 import com.oracle.solaris.vp.util.common.propinfo.PropInfo; |
|
36 import com.oracle.solaris.vp.util.misc.event.*; |
|
37 import com.oracle.solaris.vp.util.misc.finder.Finder; |
|
38 import com.oracle.solaris.vp.util.swing.SettingsPanel; |
|
39 |
|
40 @SuppressWarnings({"serial"}) |
|
41 public class InstancesPanel extends SettingsPanel |
|
42 { |
|
43 TableObjectsPanel<InstanceManagedObject> oPanel; |
|
44 |
|
45 // |
|
46 // Static data |
|
47 // |
|
48 |
|
49 @SuppressWarnings({"unchecked"}) |
|
50 private static final PropInfo<InstanceManagedObject, ?>[] |
|
51 props = new PropInfo[] { |
|
52 ManagedObjectPropInfo.instance, |
|
53 StatePropInfo.instance, |
|
54 STimePropInfo.instance, |
|
55 }; |
|
56 |
|
57 // |
|
58 // Constructors |
|
59 // |
|
60 |
|
61 public InstancesPanel(SvcsPanelDescriptor descriptor, |
|
62 StructuredAction<List<InstanceManagedObject>, ?, ?>[] actions, |
|
63 StructuredAction<List<InstanceManagedObject>, ?, ?> dAction) |
|
64 { |
|
65 String title = Finder.getString("smf.instances.title"); |
|
66 /* TableObjectsPanel<InstanceManagedObject> */ oPanel = |
|
67 new TableObjectsPanel<InstanceManagedObject>( |
|
68 new EmptyManagedObject<InstanceManagedObject>(), |
|
69 actions, dAction, title, null, props); |
|
70 |
|
71 // Sort table by default |
|
72 List<RowSorter.SortKey> keys = new ArrayList<RowSorter.SortKey>(); |
|
73 |
|
74 /* MAINT -> ONLINE */ |
|
75 keys.add(new RowSorter.SortKey(1, SortOrder.ASCENDING)); |
|
76 |
|
77 /* young -> old */ |
|
78 keys.add(new RowSorter.SortKey(2, SortOrder.DESCENDING)); |
|
79 |
|
80 oPanel.getTableObjectsView().getTable().getRowSorter(). |
|
81 setSortKeys(keys); |
|
82 oPanel.setHeaderVisible(false); |
|
83 oPanel.setShowContentBorder(false); |
|
84 oPanel.getToolBar().setFilterVisible(true); |
|
85 oPanel.getToolBar().getFilterField().setFilterListener( |
|
86 new FilterPredicate<InstanceManagedObject>( |
|
87 oPanel.getFilterManagedObject())); |
|
88 setContent(oPanel, false, false); |
|
89 |
|
90 oPanel.getFilterManagedObject().addIntervalListener( |
|
91 new IntervalListener() { |
|
92 |
|
93 public void intervalAdded(IntervalEvent event) { |
|
94 oPanel.getToolBar().getFilterField().setUnmatched( |
|
95 oPanel.getFilterManagedObject().getChildren().size() == 0); |
|
96 } |
|
97 |
|
98 public void intervalRemoved(IntervalEvent event) { |
|
99 oPanel.getToolBar().getFilterField().setUnmatched( |
|
100 oPanel.getFilterManagedObject().getChildren().size() == 0); |
|
101 } |
|
102 |
|
103 }); |
|
104 setOpaque(false); |
|
105 setBorder(BorderFactory.createEmptyBorder()); |
|
106 } |
|
107 |
|
108 public FilterManagedObject<InstanceManagedObject> getFmo() |
|
109 { |
|
110 return oPanel.getFilterManagedObject(); |
|
111 } |
|
112 } |
|