1 19 20 28 29 package org.netbeans.modules.xml.schema.refactoring.query; 30 31 import javax.swing.SwingUtilities ; 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 47 public class QuerySubstitutionGroups implements Query { 48 protected String displayName; 49 private String shortName; 50 private SchemaModel model; 51 52 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 toString() { 69 return displayName; 70 } 71 72 77 public void setDisplayName(String displayName) { 78 this.displayName = displayName; 79 } 80 81 82 83 88 public void setShortName(String shortName) { 89 this.shortName = shortName; 90 } 91 92 97 public String 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 (){ 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 (){ 121 public void run() { 122 123 if (view != null){ 124 if (!queryPanel.getIsVisible()) { 125 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 |