01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui.tests.macro;
11:
12: import org.eclipse.swt.custom.TableTree;
13: import org.eclipse.swt.custom.TableTreeItem;
14: import org.eclipse.swt.widgets.Event;
15: import org.eclipse.swt.widgets.Table;
16: import org.eclipse.swt.widgets.TableItem;
17: import org.eclipse.swt.widgets.Tree;
18: import org.eclipse.swt.widgets.TreeItem;
19: import org.eclipse.swt.widgets.Widget;
20:
21: public class CheckCommand extends ToggleStructuredCommand {
22: public static final String TYPE = "item-check";
23:
24: /**
25: * @param wid
26: */
27: public CheckCommand(WidgetIdentifier wid) {
28: super (wid);
29: }
30:
31: public String getType() {
32: return TYPE;
33: }
34:
35: public void processEvent(Event event) {
36: super .processEvent(event);
37: Widget item = event.item;
38: if (item instanceof TreeItem)
39: value = ((TreeItem) item).getChecked();
40: else if (item instanceof TableItem)
41: value = ((TableItem) item).getChecked();
42: else if (item instanceof TableTreeItem)
43: value = ((TableTreeItem) item).getChecked();
44: }
45:
46: protected void playTreeCommand(Tree tree, TreeItem[] matches) {
47: for (int i = 0; i < matches.length; i++) {
48: matches[i].setChecked(getValue());
49: }
50: }
51:
52: protected void playTableCommand(Table table, TableItem[] matches) {
53: for (int i = 0; i < matches.length; i++) {
54: matches[i].setChecked(getValue());
55: }
56: }
57:
58: protected void playTableTreeCommand(TableTree tableTree,
59: TableTreeItem[] matches) {
60: for (int i = 0; i < matches.length; i++) {
61: matches[i].setChecked(getValue());
62: }
63: }
64: }
|