KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > form > assistant > AssistantModel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.form.assistant;
20
21 import java.beans.*;
22 import java.util.*;
23
24 /**
25  * Assistant model.
26  *
27  * @author Jan Stola
28  */

29 public class AssistantModel {
30     private PropertyChangeSupport support;
31     private String JavaDoc context;
32     private String JavaDoc additionalContext;
33     private Object JavaDoc[] parameters;
34
35     public AssistantModel() {
36         support = new PropertyChangeSupport(this);
37     }
38
39     public String JavaDoc getContext() {
40         return context;
41     }
42
43     public String JavaDoc getAdditionalContext() {
44         return additionalContext;
45     }
46
47     public Object JavaDoc[] getParameters() {
48         return parameters;
49     }
50
51     public void setContext(String JavaDoc context) {
52         setContext(context, (String JavaDoc)null);
53     }
54
55     public void setContext(String JavaDoc context, String JavaDoc additionalContext) {
56         this.context = context;
57         this.additionalContext = additionalContext;
58         this.parameters = null;
59         fireContextChange();
60     }
61
62     public void setContext(String JavaDoc context, Object JavaDoc[] parameters) {
63         this.context = context;
64         this.additionalContext = null;
65         this.parameters = parameters;
66         fireContextChange();
67     }
68
69     private void fireContextChange() {
70         support.firePropertyChange("context", null, null); // NOI18N
71
}
72
73     public String JavaDoc[] getMessages() {
74         return AssistantMessages.getDefault().getMessages(context);
75     }
76
77     public String JavaDoc[] getAdditionalMessages() {
78         return AssistantMessages.getDefault().getMessages(additionalContext);
79     }
80
81     // Property change support
82
public void addPropertyChangeListener(PropertyChangeListener listener) {
83         support.addPropertyChangeListener(listener);
84     }
85
86     public void removePropertyChangeListener(PropertyChangeListener listener) {
87         support.removePropertyChangeListener(listener);
88     }
89
90 }
91
Popular Tags