1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
|
/** BEGIN COPYRIGHT BLOCK
* Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
* Copyright (C) 2005 Red Hat, Inc.
* All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version
* 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* END COPYRIGHT BLOCK **/
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import com.sun.java.swing.*;
import com.sun.java.swing.event.*;
import com.netscape.management.client.*;
import com.netscape.management.client.console.*;
class ReplacementTaskModel extends TaskModel
{
TaskObject root;
public ReplacementTaskModel() {
root = new TaskObject("Top 2 Tasks");
TaskObject outline1 = new MyTaskObject("Manage users and groups",
new ImageIcon("icons/task1.jpg"));
TaskObject outline2 = new MyTaskObject("Install or upgrade server",
new ImageIcon("icons/task2.jpg"));
root.add(outline1);
root.add(outline2);
setRoot(root);
}
}
public class DemoTaskModel extends TaskModel implements IMenuInfo {
TaskObject _root[] = new TaskObject[2];
public DemoTaskModel() {
_root[0] = new TaskObject("Top 7 Tasks");
TaskObject outline1 = new MyTaskObject("Manage users and groups",
new ImageIcon("icons/task1.jpg"));
TaskObject outline2 = new MyTaskObject("Install or upgrade server",
new ImageIcon("icons/task2.jpg"));
TaskObject outline3 =
new MyTaskObject("Configure server performance",
new ImageIcon("icons/task3.jpg"));
TaskObject outline4 =
new MyTaskObject("Setup security", new ImageIcon("icons/task4.jpg"));
TaskObject outline5 = new MyTaskObject("Manage secure access",
new ImageIcon("icons/task5.jpg"));
TaskObject outline6 =
new MyTaskObject("Setup programs and data access",
new ImageIcon("icons/task6.jpg"));
TaskObject outline7 =
new MyTaskObject("Configure content and services",
new ImageIcon("icons/task7.jpg"));
TaskObject outline8 = new MyTaskObject("Monitor server performance",
new ImageIcon("icons/task1.jpg"));
TaskObject outline9 =
new MyTaskObject("Backup and recover configuration",
new ImageIcon("icons/task2.jpg"));
TaskObject outlineA = new MyTaskObject("Manage server content",
new ImageIcon("icons/task3.jpg"));
outline1.setDescription("Specifies the cell at the upper left of the component's display area, where the upper-left-most cell has address.");
outline2.setDescription("Properties behave in some ways like a memory location.");
outline3.setDescription("Used when the component is smaller than its display area to determine where .");
outline4.setDescription("Scriptlets let Web authors create reusable objects with Dynamic HTML.");
outline5.setDescription("Components are a key technology for improving the amount and quality of software.");
outline6.setDescription("You customize a GridBagConstraints object by setting one or more of its instance variables.");
outline7.setDescription("Events are notices that a component transmits at run time to the outside application.");
outline8.setDescription("Scriptlets are as secure as Dynamic HTML and script itself.");
outline9.setDescription("This is a description for this task.");
outlineA.setDescription("Properties act like named memory values inside the component.");
_root[0].add(outline1);
outline1.add(new TaskObject("Search for user or group"));
outline1.add(new TaskObject("Add a new user"));
outline1.add(new TaskObject("Add a new group"));
_root[0].add(outline2);
outline2.add(new TaskObject("Install/clone a new Enterprise 4.0 server"));
outline2.add(new TaskObject("Upgrade server"));
outline2.add(new TaskObject("Upgrade server with a field-level patch"));
outline2.add(new TaskObject("Remove a server"));
_root[0].add(outline3);
_root[0].add(outline4);
_root[0].add(outline5);
_root[0].add(outline6);
_root[0].add(outline7);
_root[1] = new TaskObject("Monthly Tasks (Outline)");
_root[1].add(outline8);
_root[1].add(outline9);
_root[1].add(outlineA);
}
/**
* Notification that objects have been selected in the task list.
* Called by TaskPage
*/
public void actionObjectSelected(IPage viewInstance,
ITaskObject selection, ITaskObject previousSelection) {
System.out.println("DemoTaskModel.actionObjectSelected()");
super.actionObjectSelected(viewInstance, selection,
previousSelection);
fireDisableMenuItem(viewInstance, "COMMON_ID");
}
public Object getRoot() {
return _root[0];
}
public Object getRoot(int viewIndex) {
return _root[viewIndex];
}
public Object getChild(Object parent, int index) {
return ((TaskObject) parent).getChildAt(index);
}
public int getChildCount(Object parent) {
return ((TaskObject) parent).getChildCount();
}
public boolean isLeaf(Object node) {
return ((TaskObject) node).getChildCount() == 0;
}
public int getViewCount() {
return _root.length;
}
public String getViewName(int index) {
return _root[index].getName();
}
public int getViewType(int index) {
if (index == 1)
return ITaskModel.VIEW_BRIEF;
else
return ITaskModel.VIEW_DETAIL;
}
/**
* Notification that the framework window is closing.
* Called by ResourcePage
*/
public void actionViewClosing(IPage viewInstance)
throws CloseVetoException {
}
/**
* Returns menu categories for this model.
*/
public String[] getMenuCategoryIDs() {
return new String[]{ Framework.MENU_FILE,
TaskPage.MENU_CONTEXT, "ContextCategoryID", "FileCascadeID" };
}
/**
* Returns menu items for this model.
*/
public IMenuItem[] getMenuItems(String category) {
String COMMON_ID = "COMMON_ID";
if (category.equals(ResourcePage.MENU_CONTEXT)) {
return new IMenuItem[]{ new MenuItemCategory("ContextCategoryID",
"MyCategory1"), new MenuItemSeparator(),
new MenuItemText("MyContextItem1_ID", "MyContextItem1",
"description1"),
new MenuItemText("MyContextItem2_ID", "MyContextItem2",
"description2"),
new MenuItemText(COMMON_ID, "CommonMenuItem", "description"), };
} else if (category.equals(Framework.MENU_FILE)) {
return new IMenuItem[]{ new MenuItemCategory("FileCascadeID",
"MyCascade"), new MenuItemSeparator(),
new MenuItemText("MyFileItem1_ID", "MyFileItem1",
"description1"),
new MenuItemText("MyFileItem2_ID", "MyFileItem2",
"description2"),
new MenuItemText("ReplaceTaskModel_ID", "Replace Task Model",
"description2"),
new MenuItemText(COMMON_ID, "CommonMenuItem", "description"), };
} else if (category.equals("ContextCategoryID")) {
return new IMenuItem[]{ new MenuItemText("CascadeItemID", "MyCascadeItem",
"MyItem Description")};
} else if (category.equals("FileCascadeID")) {
return new IMenuItem[]{ new MenuItemText("FileItemID", "MyCascadeItem",
"MyItem Description")};
}
return null;
}
/**
* Notification that a menu item has been selected.
*/
public void actionMenuSelected(IPage viewInstance, IMenuItem item) {
System.out.println(item.getID());
if(item.getID().equals("ReplaceTaskModel_ID"))
{
((TaskPage)viewInstance).setTaskModel(new ReplacementTaskModel());
}
}
}
class MyTaskObject extends TaskObject {
static int progress = -1;
public MyTaskObject(String name) {
super(name);
}
public MyTaskObject(String name, Icon icon) {
super(name, icon);
}
/**
* Called when this object is selected.
* Called by: TaskModel
*/
public void select(IPage viewInstance) {
System.out.println("MyTaskObject.select() disabling MyFileItem1_ID");
fireDisableMenuItem(viewInstance, "MyFileItem1_ID");
fireChangeStatusItemState(viewInstance,
TaskPage.STATUS_PROGRESS, new Integer(progress));
progress += 20;
if (progress > 100)
progress = -1;
}
public boolean run(IPage viewInstance) {
System.out.println("MyTaskObject.run() viewInstance = " +
viewInstance);
return true;
}
}
|