KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > schema > refactoring > query > QuerySubstitutionGroups


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-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 /*
21  * QuerySubstitutionGroups.java
22  *
23  * Created on January 16, 2006, 4:43 PM
24  *
25  * To change this template, choose Tools | Template Manager
26  * and open the template in the editor.
27  */

28
29 package org.netbeans.modules.xml.schema.refactoring.query;
30
31 import javax.swing.SwingUtilities JavaDoc;
32 import org.netbeans.api.progress.ProgressHandle;
33 import org.netbeans.api.progress.ProgressHandleFactory;
34 import org.netbeans.modules.xml.nbprefuse.AnalysisViewer;
35 import org.netbeans.modules.xml.schema.model.SchemaModel;
36 import org.netbeans.modules.xml.schema.refactoring.query.views.QuerySubstitutionGroupsView;
37 import org.netbeans.modules.xml.schema.refactoring.ui.QueryPanel;
38 import org.netbeans.modules.xml.schema.refactoring.ui.QueryPanelContainer;
39 import org.openide.ErrorManager;
40 import org.openide.util.NbBundle;
41 import org.openide.util.RequestProcessor;
42
43 /**
44  *
45  * @author Jeri Lockhart
46  */

47 public class QuerySubstitutionGroups implements Query {
48     protected String JavaDoc displayName;
49     private String JavaDoc shortName;
50     private SchemaModel model;
51     
52     /** Creates a new instance of QuerySubstitutionGroups */
53     public QuerySubstitutionGroups(final SchemaModel model) {
54         super();
55         this.model = model;
56         shortName = NbBundle.getMessage(QuerySubstitutionGroups.class,
57                 "LBL_Query_SubstitutionGroups_ShortName");
58         initialize();
59     }
60     
61     private void initialize() {
62         displayName = NbBundle.getMessage(QuerySubstitutionGroups.class,
63                 "LBL_QuerySubstitutionGroupsCustomizerPanel_desc");
64         
65     }
66
67     
68     public String JavaDoc toString() {
69         return displayName;
70     }
71    
72     /**
73      * Setter for property displayName.
74      *
75      * @param displayName New value of property displayName.
76      */

77     public void setDisplayName(String JavaDoc displayName) {
78         this.displayName = displayName;
79     }
80     
81     
82     
83     /**
84      * Setter for property shortName - used on customizer column button
85      *
86      * @param shortName New value of property shortName.
87      */

88     public void setShortName(String JavaDoc shortName) {
89         this.shortName = shortName;
90     }
91     
92     /**
93      * Getter for property shortName - used on customizer column button
94      *
95      * @return Value of property shortName.
96      */

97     public String JavaDoc getShortName() {
98         return shortName;
99     }
100     
101     
102     public void runQuery(final QueryPanel queryPanel, final AnalysisViewer analysisViewer) {
103         final QuerySubstitutionGroupsView view = new QuerySubstitutionGroupsView(
104                     model);
105             
106             
107             RequestProcessor.getDefault().post(new Runnable JavaDoc(){
108                 public void run() {
109                     ProgressHandle ph = ProgressHandleFactory.createHandle(
110                             NbBundle.getMessage(QuerySubstitutionGroups.class,
111                             "LBL_Finding_Substitution_Groups"));
112                     ph.start();
113                     ph.switchToIndeterminate();
114                     view.createModels();
115                     
116                     if(Thread.currentThread().isInterrupted()){
117                         return;
118                     }
119                     ph.finish();
120                     SwingUtilities.invokeLater(new Runnable JavaDoc(){
121                     public void run() {
122                         
123                         if (view != null){
124                             if (!queryPanel.getIsVisible()) {
125                                 // dock it into output window area and display
126
QueryPanelContainer cont =
127                                         QueryPanelContainer.getUsagesComponent();
128                                 if (cont == null){
129                                     ErrorManager.getDefault().log(
130                                             ErrorManager.ERROR,
131                                             "XML Schema Query Failed to open QueryPanelContainer. The problem could be that the XML settings and wstcref files in userdir Windows2Local are obsolete. Try removing xml-schema-query.* and restart the IDE.");
132                                     return;
133                                 }
134                                 cont.open();
135                                 cont.requestActive();
136                                 cont.addPanel(queryPanel);
137                                 queryPanel.setIsVisible(true);
138                             }
139                             
140                             queryPanel.requestFocus();
141                             
142                             if (view != null){
143                                 view.showView(analysisViewer);
144                                 analysisViewer.validate();
145                                 analysisViewer.repaint();
146                             }
147                             
148                         }
149                     }
150                 });
151                 }});
152                 
153          
154     }
155
156     public SchemaModel getModel() {
157         return model;
158     }
159     
160     
161  
162 }
163
Popular Tags