1 19 20 package org.netbeans.modules.tasklist.bugs.bugzilla; 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 import org.netbeans.modules.tasklist.bugs.*; 34 import org.openide.awt.HtmlBrowser; 35 import org.openide.awt.StatusDisplayer; 36 37 import javax.swing.*; 38 39 45 public class BZBugEngine implements BugEngine { 47 public BZBugEngine() { 48 } 49 50 53 public String getName() { 54 return (NbBundle.getMessage(BZBugEngine.class, "BugZilla")); } 56 57 public JComponent getQueryCustomizer(BugQuery query, boolean edit) { 58 return new BugzillaQueryPanel(query, edit); 59 } 60 61 public void refresh(final BugQuery query, final BugList list) { 62 RequestProcessor.postRequest(new Runnable () { 64 public void run() { 65 doRefresh(query, list); 66 } 67 }); 68 } 69 70 73 public void doRefresh(BugQuery inQuery, BugList list) { 74 TaskListView v = TaskListView.getCurrent(); 75 BugsView view = null; 76 if (v instanceof BugsView) { 77 view = (BugsView) v; 78 view.setCursor(Utilities.createProgressCursor(view)); 79 } 80 try { 81 String baseurl = inQuery.getBaseUrl() + "/buglist.cgi?"; 83 String query = inQuery.getQueryString(); 84 if ((baseurl == null || baseurl.equals("")) || (query == null || query.equals(""))) { 85 StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(BZBugEngine.class, 87 "BadQuery")); return; 89 } 90 System.out.println("Baseurl = " + baseurl + " query = " + query); 91 92 StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(BZBugEngine.class, 93 "Refreshing")); URL url = null; 95 try { 96 url = new URL (baseurl); 97 } catch (MalformedURLException e) { 98 ErrorManager.getDefault().notify(e); 99 } 100 if (url != null) { 101 Bugzilla bz = new Bugzilla(url); 102 try { 103 StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(BZBugEngine.class, 104 "DoingQuery")); int bugids[] = bz.query(query); 106 107 109 int n = bugids.length; 110 LinkedList issues = new LinkedList (); 111 for (int i = 0; i < n; i++) { 112 StatusDisplayer.getDefault().setStatusText(MessageFormat.format(NbBundle.getMessage(BZBugEngine.class, 113 "QueryingBug"), new String []{Integer.toString(bugids[i])})); 115 116 Issue izbug = bz.getBug(bugids[i]); 117 118 Bug bug = new Bug(Integer.toString(izbug.getId()), 119 izbug.getSummary(), 120 izbug.getPriority(), 121 izbug.getType(), 122 izbug.getComponent(), 123 izbug.getSubcomponent(), 124 izbug.getCreated(), 125 "", 126 izbug.getAssignedTo(), 127 izbug.getReportedBy(), 128 izbug.getStatus(), 129 izbug.getTargetMilestone(), 130 0); 131 bug.setEngine(this); 132 133 issues.add(bug); 134 } 135 136 list.setBugs(issues); 138 } catch (org.xml.sax.SAXException se) { 139 ErrorManager.getDefault().notify(se); 140 System.out.println("Couldn't read bug list: sax exception"); 141 } catch (java.net.UnknownHostException uhe) { 142 StatusDisplayer.getDefault().setStatusText(MessageFormat.format(NbBundle.getMessage(BZBugEngine.class, 143 "NoNet"), new String []{baseurl})); 145 146 } catch (java.io.IOException ioe) { 147 ErrorManager.getDefault().notify(ioe); 148 System.out.println("Couldn't read bug list: io exception"); 149 } 150 StatusDisplayer.getDefault().setStatusText(""); 151 } 152 } finally { 153 if (view != null) { 154 view.setCursor(null); 155 } 156 } 157 } 158 159 162 public void viewBug(Bug bug, String server) { 163 try { 167 URL url = new URL (new URL (server), "bugzilla/show_bug.cgi?id=" + bug.getId()); 169 HtmlBrowser.URLDisplayer.getDefault().showURL(url); 170 } catch (MalformedURLException e) { 171 ErrorManager.getDefault().notify(e); 172 } 173 } 174 } 175 | Popular Tags |