1 19 20 package org.netbeans.modules.tasklist.bugs.issuezilla; 21 22 import java.util.LinkedList ; 23 import java.net.URL ; 24 import java.net.MalformedURLException ; 25 import java.text.MessageFormat ; 26 27 import org.openide.ErrorManager; 28 import org.openide.util.NbBundle; 29 import org.openide.util.RequestProcessor; 30 import org.openide.util.Utilities; 31 32 import org.netbeans.modules.tasklist.core.TaskListView; 33 34 import org.netbeans.modules.tasklist.bugs.*; 35 import org.netbeans.modules.tasklist.bugs.bugzilla.BugzillaQueryPanel; 36 import org.netbeans.modules.tasklist.bugs.bugzilla.SourcePanel; 37 import org.openide.awt.HtmlBrowser; 38 import org.openide.awt.StatusDisplayer; 39 40 import javax.swing.*; 41 42 47 public class IZBugEngine implements BugEngine { 49 public IZBugEngine() { 50 } 51 52 55 public String getName() { 56 return (NbBundle.getMessage(IZBugEngine.class, "IssueZilla")); } 58 59 public void refresh(final BugQuery query, final BugList list) { 60 RequestProcessor.getDefault().post(new Runnable () { 62 public void run() { 63 doRefresh(query, list); 64 } 65 }); 66 } 67 68 public JComponent getQueryCustomizer(BugQuery query, boolean edit) { 69 return new SourcePanel(true); 70 } 71 72 public void doRefresh(BugQuery inQuery, BugList list) { 73 TaskListView v = TaskListView.getCurrent(); 74 BugsView view = null; 75 if (v instanceof BugsView) { 76 view = (BugsView) v; 77 view.setCursor(Utilities.createProgressCursor(view)); 78 } 79 try { 80 81 String query = null; 83 String baseurl = null; 84 baseurl = inQuery.getBaseUrl() + "/buglist.cgi?"; 101 query = inQuery.getQueryString(); 102 103 if ((baseurl == null || baseurl.equals("")) || (query == null || query.equals(""))) { 104 StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(IZBugEngine.class, 106 "BadQuery")); return; 108 } 109 110 112 113 StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(IZBugEngine.class, 114 "Refreshing")); URL url = null; 116 try { 117 url = new URL (baseurl); 118 } catch (MalformedURLException e) { 119 ErrorManager.getDefault().notify(e); 120 } 121 if (url != null) { 122 Issuezilla iz = new Issuezilla(url); 123 try { 124 StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(IZBugEngine.class, 125 "DoingQuery")); 127 int bugids[] = iz.query(query); 128 129 131 int n = bugids.length; 132 LinkedList issues = new LinkedList (); 133 for (int i = 0; i < n; i++) { 134 StatusDisplayer.getDefault().setStatusText(MessageFormat.format(NbBundle.getMessage(IZBugEngine.class, 135 "QueryingBug"), new String []{Integer.toString(bugids[i])})); 137 138 Issue izbug = iz.getBug(bugids[i]); 139 140 Bug bug = new Bug(Integer.toString(izbug.getId()), 141 izbug.getSummary(), 142 izbug.getPriority(), 143 izbug.getType(), 144 izbug.getComponent(), 145 izbug.getSubcomponent(), 146 izbug.getCreated(), 147 izbug.getKeywords(), 148 izbug.getAssignedTo(), 149 izbug.getReportedBy(), 150 izbug.getStatus(), 151 izbug.getTargetMilestone(), 152 izbug.getVotes()); 153 bug.setEngine(this); 154 155 issues.add(bug); 156 } 157 158 list.setBugs(issues); 160 } catch (org.xml.sax.SAXException se) { 161 ErrorManager.getDefault().notify(se); 162 System.out.println("Couldn't read bug list: sax exception"); 163 } catch (java.net.UnknownHostException uhe) { 164 StatusDisplayer.getDefault().setStatusText(MessageFormat.format(NbBundle.getMessage(IZBugEngine.class, 165 "NoNet"), new String []{baseurl})); 167 168 } catch (java.io.IOException ioe) { 169 ErrorManager.getDefault().notify(ioe); 170 System.out.println("Couldn't read bug list: io exception"); 171 } 172 StatusDisplayer.getDefault().setStatusText(""); 173 } 174 175 } finally { 176 if (view != null) { 177 view.setCursor(null); 178 } 179 } 180 } 181 182 185 public void viewBug(Bug bug, String service) { 186 try { 190 URL url = new URL (new URL (service), "issues/show_bug.cgi?id=" + bug.getId()); 191 HtmlBrowser.URLDisplayer.getDefault().showURL(url); 192 } catch (MalformedURLException e) { 193 ErrorManager.getDefault().notify(e); 194 } 195 } 196 } 197 | Popular Tags |