author | Stephen Talley <stephen.talley@oracle.com> |
Thu, 22 Jul 2010 10:10:18 -0400 | |
changeset 547 | e1d8b4ddb166 |
parent 457 | b9518666d83e |
child 558 | 547fc7c7e466 |
permissions | -rw-r--r-- |
0 | 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 |
/* |
|
547
e1d8b4ddb166
16625 SwingSettingsControl does not follow naming conventions
Stephen Talley <stephen.talley@oracle.com>
parents:
457
diff
changeset
|
23 |
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. |
0 | 24 |
*/ |
25 |
||
323
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
26 |
package org.opensolaris.os.vp.panels.svcs.client.swing; |
0 | 27 |
|
223
aa68c366f3d0
6923 Menu, connection pull-down should be removed from main window
Stephen Talley <stephen.talley@sun.com>
parents:
219
diff
changeset
|
28 |
import java.net.URL; |
109
7dc836d44752
3846 smf: services and instances should be browsable from breadcrumbs
Stephen Talley <stephen.talley@sun.com>
parents:
102
diff
changeset
|
29 |
import java.util.*; |
136
f9d1c2bd7b35
4401 ManagedObjectAction should be generalized to handle any preset input
Stephen Talley <stephen.talley@sun.com>
parents:
119
diff
changeset
|
30 |
import org.opensolaris.os.vp.panel.common.action.StructuredAction; |
109
7dc836d44752
3846 smf: services and instances should be browsable from breadcrumbs
Stephen Talley <stephen.talley@sun.com>
parents:
102
diff
changeset
|
31 |
import org.opensolaris.os.vp.panel.common.control.*; |
323
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
32 |
import org.opensolaris.os.vp.panel.common.smf.InstanceManagedObject; |
410
e87d2a04c16e
13713 LaunchManagedObjectAction should implement workBusy, not invoke
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
33 |
import org.opensolaris.os.vp.panel.swing.action.LaunchManagedObjectAction; |
40
d1412af1ae5b
3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents:
0
diff
changeset
|
34 |
import org.opensolaris.os.vp.panel.swing.control.*; |
366
610ee2561491
10344 need to reload panel when server changes
Stephen Talley <stephen.talley@sun.com>
parents:
360
diff
changeset
|
35 |
import org.opensolaris.os.vp.panel.swing.smf.EnableServiceAction; |
241
aab00f5fd6d8
7605 remove icons from tabs
Stephen Talley <stephen.talley@sun.com>
parents:
223
diff
changeset
|
36 |
import org.opensolaris.os.vp.util.misc.Finder; |
0 | 37 |
|
338
e9cd9bfae0b0
10464 time panel talks to server on every redraw
David Powell <David.Powell@sun.com>
parents:
323
diff
changeset
|
38 |
public class InstancesControl |
547
e1d8b4ddb166
16625 SwingSettingsControl does not follow naming conventions
Stephen Talley <stephen.talley@oracle.com>
parents:
457
diff
changeset
|
39 |
extends SettingsControl<SvcsPanelDescriptor, InstancesPanel> { |
282
fdae7ad420be
8192 SwingTabControl is unnecessary for most tab Controls
Stephen Talley <stephen.talley@sun.com>
parents:
274
diff
changeset
|
40 |
|
0 | 41 |
/* |
42 |
* Static data |
|
43 |
*/ |
|
44 |
||
183
0c00aab8dd38
4167 smf: instance edit panel needs a link to its service
Stephen Talley <stephen.talley@sun.com>
parents:
171
diff
changeset
|
45 |
public static final String ID = "instances"; |
0 | 46 |
private static final String NAME = Finder.getString("smf.instances.title"); |
47 |
||
48 |
/* |
|
49 |
* Instance data |
|
50 |
*/ |
|
136
f9d1c2bd7b35
4401 ManagedObjectAction should be generalized to handle any preset input
Stephen Talley <stephen.talley@sun.com>
parents:
119
diff
changeset
|
51 |
private StructuredAction<List<InstanceManagedObject>, ?, ?> editAction_ = |
410
e87d2a04c16e
13713 LaunchManagedObjectAction should implement workBusy, not invoke
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
52 |
new LaunchManagedObjectAction<InstanceManagedObject>(this) { |
323
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
53 |
|
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
54 |
@Override |
410
e87d2a04c16e
13713 LaunchManagedObjectAction should implement workBusy, not invoke
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
55 |
public Navigable[] getRuntimeInput( |
e87d2a04c16e
13713 LaunchManagedObjectAction should implement workBusy, not invoke
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
56 |
List<InstanceManagedObject> selection, Navigable[] path) { |
e87d2a04c16e
13713 LaunchManagedObjectAction should implement workBusy, not invoke
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
57 |
|
e87d2a04c16e
13713 LaunchManagedObjectAction should implement workBusy, not invoke
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
58 |
// Assume valid selection |
e87d2a04c16e
13713 LaunchManagedObjectAction should implement workBusy, not invoke
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
59 |
InstanceManagedObject obj = selection.get(0); |
e87d2a04c16e
13713 LaunchManagedObjectAction should implement workBusy, not invoke
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
60 |
|
e87d2a04c16e
13713 LaunchManagedObjectAction should implement workBusy, not invoke
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
61 |
return new Navigable[] { |
e87d2a04c16e
13713 LaunchManagedObjectAction should implement workBusy, not invoke
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
62 |
getNavigator().getPath().get(0), |
e87d2a04c16e
13713 LaunchManagedObjectAction should implement workBusy, not invoke
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
63 |
new SimpleNavigable("smf", null), |
e87d2a04c16e
13713 LaunchManagedObjectAction should implement workBusy, not invoke
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
64 |
new SimpleNavigable("svc", null, "service", |
e87d2a04c16e
13713 LaunchManagedObjectAction should implement workBusy, not invoke
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
65 |
obj.getServiceFmri().getService()), |
e87d2a04c16e
13713 LaunchManagedObjectAction should implement workBusy, not invoke
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
66 |
new SimpleNavigable("instance", null, "instance", |
e87d2a04c16e
13713 LaunchManagedObjectAction should implement workBusy, not invoke
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
67 |
obj.getSMFFmri().getInstance()) |
e87d2a04c16e
13713 LaunchManagedObjectAction should implement workBusy, not invoke
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
68 |
}; |
323
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
69 |
} |
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
70 |
}; |
112
27b414893431
3990 Stronger typing needed in ManagedObject-related classes
Stephen Talley <stephen.talley@sun.com>
parents:
109
diff
changeset
|
71 |
|
27b414893431
3990 Stronger typing needed in ManagedObject-related classes
Stephen Talley <stephen.talley@sun.com>
parents:
109
diff
changeset
|
72 |
private EnableServiceAction enableAction_ = |
102
a39a3f68b935
3751 add enable/disable actions to SMF panel
David Powell <David.Powell@sun.com>
parents:
80
diff
changeset
|
73 |
new EnableServiceAction(this, true); |
112
27b414893431
3990 Stronger typing needed in ManagedObject-related classes
Stephen Talley <stephen.talley@sun.com>
parents:
109
diff
changeset
|
74 |
|
27b414893431
3990 Stronger typing needed in ManagedObject-related classes
Stephen Talley <stephen.talley@sun.com>
parents:
109
diff
changeset
|
75 |
private EnableServiceAction disableAction_ = |
102
a39a3f68b935
3751 add enable/disable actions to SMF panel
David Powell <David.Powell@sun.com>
parents:
80
diff
changeset
|
76 |
new EnableServiceAction(this, false); |
a39a3f68b935
3751 add enable/disable actions to SMF panel
David Powell <David.Powell@sun.com>
parents:
80
diff
changeset
|
77 |
|
112
27b414893431
3990 Stronger typing needed in ManagedObject-related classes
Stephen Talley <stephen.talley@sun.com>
parents:
109
diff
changeset
|
78 |
@SuppressWarnings({"unchecked"}) |
136
f9d1c2bd7b35
4401 ManagedObjectAction should be generalized to handle any preset input
Stephen Talley <stephen.talley@sun.com>
parents:
119
diff
changeset
|
79 |
protected StructuredAction<List<InstanceManagedObject>, ?, ?>[] actions_ = |
f9d1c2bd7b35
4401 ManagedObjectAction should be generalized to handle any preset input
Stephen Talley <stephen.talley@sun.com>
parents:
119
diff
changeset
|
80 |
new StructuredAction[] { |
112
27b414893431
3990 Stronger typing needed in ManagedObject-related classes
Stephen Talley <stephen.talley@sun.com>
parents:
109
diff
changeset
|
81 |
enableAction_, disableAction_, editAction_ |
27b414893431
3990 Stronger typing needed in ManagedObject-related classes
Stephen Talley <stephen.talley@sun.com>
parents:
109
diff
changeset
|
82 |
}; |
0 | 83 |
|
323
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
84 |
private InstanceFilter filter_ = null; |
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
85 |
|
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
86 |
public static final String PARAM_FILTER = "filter"; |
0 | 87 |
|
88 |
/* |
|
89 |
* Constructors |
|
90 |
*/ |
|
91 |
||
338
e9cd9bfae0b0
10464 time panel talks to server on every redraw
David Powell <David.Powell@sun.com>
parents:
323
diff
changeset
|
92 |
public InstancesControl(SvcsPanelDescriptor descriptor) |
0 | 93 |
{ |
223
aa68c366f3d0
6923 Menu, connection pull-down should be removed from main window
Stephen Talley <stephen.talley@sun.com>
parents:
219
diff
changeset
|
94 |
super(ID, NAME, descriptor); |
0 | 95 |
} |
96 |
||
109
7dc836d44752
3846 smf: services and instances should be browsable from breadcrumbs
Stephen Talley <stephen.talley@sun.com>
parents:
102
diff
changeset
|
97 |
// |
7dc836d44752
3846 smf: services and instances should be browsable from breadcrumbs
Stephen Talley <stephen.talley@sun.com>
parents:
102
diff
changeset
|
98 |
// Control methods |
7dc836d44752
3846 smf: services and instances should be browsable from breadcrumbs
Stephen Talley <stephen.talley@sun.com>
parents:
102
diff
changeset
|
99 |
// |
7dc836d44752
3846 smf: services and instances should be browsable from breadcrumbs
Stephen Talley <stephen.talley@sun.com>
parents:
102
diff
changeset
|
100 |
|
7dc836d44752
3846 smf: services and instances should be browsable from breadcrumbs
Stephen Talley <stephen.talley@sun.com>
parents:
102
diff
changeset
|
101 |
@Override |
360
8943c58ad2f5
11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents:
350
diff
changeset
|
102 |
public URL getHelpURL() { |
457
b9518666d83e
14816 SMF help text attached to wrong panel
David Powell <David.Powell@sun.com>
parents:
410
diff
changeset
|
103 |
return buildHelpURL("help/smf-instance.html", null); |
360
8943c58ad2f5
11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents:
350
diff
changeset
|
104 |
} |
8943c58ad2f5
11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents:
350
diff
changeset
|
105 |
|
8943c58ad2f5
11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents:
350
diff
changeset
|
106 |
@Override |
323
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
107 |
public boolean isBrowsable() { |
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
108 |
// This Control requires init parameters |
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
109 |
return false; |
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
110 |
} |
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
111 |
|
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
112 |
@Override |
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
113 |
public void start(Navigator navigator, Map<String, String> parameters) |
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
114 |
throws NavigationAbortedException, InvalidParameterException { |
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
115 |
|
350
1e9744735024
11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents:
338
diff
changeset
|
116 |
String param = getParameter(parameters, PARAM_FILTER); |
109
7dc836d44752
3846 smf: services and instances should be browsable from breadcrumbs
Stephen Talley <stephen.talley@sun.com>
parents:
102
diff
changeset
|
117 |
|
323
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
118 |
InstanceFilter filter = getPanelDescriptor().getFilter(param); |
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
119 |
if (filter == null) |
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
120 |
throw new InvalidParameterException(getId(), PARAM_FILTER, param); |
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
121 |
|
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
122 |
filter_ = filter; |
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
123 |
setName(filter.getName()); |
109
7dc836d44752
3846 smf: services and instances should be browsable from breadcrumbs
Stephen Talley <stephen.talley@sun.com>
parents:
102
diff
changeset
|
124 |
|
323
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
125 |
super.start(navigator, parameters); |
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
126 |
} |
109
7dc836d44752
3846 smf: services and instances should be browsable from breadcrumbs
Stephen Talley <stephen.talley@sun.com>
parents:
102
diff
changeset
|
127 |
|
323
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
128 |
@Override |
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
129 |
public void stop(boolean isCancel) throws NavigationAbortedException { |
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
130 |
super.stop(isCancel); |
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
131 |
|
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
132 |
// Remove reference so it can be garbage collected if deleted |
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
133 |
filter_ = null; |
109
7dc836d44752
3846 smf: services and instances should be browsable from breadcrumbs
Stephen Talley <stephen.talley@sun.com>
parents:
102
diff
changeset
|
134 |
} |
7dc836d44752
3846 smf: services and instances should be browsable from breadcrumbs
Stephen Talley <stephen.talley@sun.com>
parents:
102
diff
changeset
|
135 |
|
0 | 136 |
/* |
137 |
* SwingControl methods |
|
138 |
*/ |
|
139 |
||
140 |
@Override |
|
244
b6f1fb4f5a89
7624 SwingControl: createComponent implementations should not be required to call setComponent
Stephen Talley <stephen.talley@sun.com>
parents:
241
diff
changeset
|
141 |
protected InstancesPanel createComponent() |
0 | 142 |
{ |
143 |
InstancesPanel panel = |
|
223
aa68c366f3d0
6923 Menu, connection pull-down should be removed from main window
Stephen Talley <stephen.talley@sun.com>
parents:
219
diff
changeset
|
144 |
new InstancesPanel(getPanelDescriptor(), actions_, editAction_); |
244
b6f1fb4f5a89
7624 SwingControl: createComponent implementations should not be required to call setComponent
Stephen Talley <stephen.talley@sun.com>
parents:
241
diff
changeset
|
145 |
|
b6f1fb4f5a89
7624 SwingControl: createComponent implementations should not be required to call setComponent
Stephen Talley <stephen.talley@sun.com>
parents:
241
diff
changeset
|
146 |
return panel; |
0 | 147 |
} |
323
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
148 |
|
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
149 |
@Override |
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
150 |
protected void initComponent() |
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
151 |
{ |
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
152 |
try { |
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
153 |
getComponent().getFmo().setManagedObject( |
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
154 |
filter_.getManagedObject()); |
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
155 |
} catch (Throwable t) { |
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
156 |
System.out.println("setManagedObject failed: " + t); |
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
157 |
t.printStackTrace(); |
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
158 |
} |
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
159 |
} |
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
160 |
|
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
161 |
@Override |
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
162 |
protected void deinitComponent() |
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
163 |
{ |
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
164 |
// getComponent().getFmo().setPredicate(TruePredicate.getInstance()); |
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
165 |
} |
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
166 |
|
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
167 |
public InstanceFilter getFilter() |
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
168 |
{ |
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
169 |
return (filter_); |
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
282
diff
changeset
|
170 |
} |
0 | 171 |
} |