01: /*
02: * Copyright 2005 JBoss Inc
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.drools.brms.client;
18:
19: import java.util.ArrayList;
20:
21: import org.drools.brms.client.JBRMSFeature.ComponentInfo;
22:
23: import com.google.gwt.user.client.ui.Composite;
24: import com.google.gwt.user.client.ui.Hyperlink;
25: import com.google.gwt.user.client.ui.VerticalPanel;
26:
27: /**
28: * This is the list of features that make up the rule management console.
29: * Refer to the JBRMSFeatureConfigurator which actually sets up the individual features.
30: *
31: * This is the left panel that contains all of the features, along with a short description
32: * of each.
33: */
34: public class JBRMSFeatureList extends Composite {
35:
36: private VerticalPanel list = new VerticalPanel();
37: private ArrayList sinks = new ArrayList();
38: private int selectedSink = -1;
39:
40: public JBRMSFeatureList() {
41: initWidget(list);
42: setStyleName("ks-List");
43: }
44:
45: public void addSink(final ComponentInfo info) {
46: String name = info.getName();
47: Hyperlink link = new Hyperlink(name, name);
48: link.setStyleName("ks-SinkItem");
49:
50: list.add(link);
51: sinks.add(info);
52: }
53:
54: public ComponentInfo find(String sinkName) {
55: for (int i = 0; i < sinks.size(); ++i) {
56: ComponentInfo info = (ComponentInfo) sinks.get(i);
57: if (info.getName().equals(sinkName))
58: return info;
59: }
60:
61: return null;
62: }
63:
64: public void setSinkSelection(String name) {
65: if (selectedSink != -1)
66: list.getWidget(selectedSink).removeStyleName(
67: "ks-SinkItem-selected");
68:
69: for (int i = 0; i < sinks.size(); ++i) {
70: ComponentInfo info = (ComponentInfo) sinks.get(i);
71: if (info.getName().equals(name)) {
72: selectedSink = i;
73: list.getWidget(selectedSink).addStyleName(
74: "ks-SinkItem-selected");
75: return;
76: }
77: }
78: }
79: }
|