Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 22100 Details for
Bug 81795
[Bugs] No CVS access for bugzilla plug-in
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch to remove most warnings in org.eclipse.team.bugzilla
org.eclipse.team.bugzilla.patch (text/plain), 192.92 KB, created by
Ed Burnette
on 2005-05-31 16:27:59 EDT
(
hide
)
Description:
Patch to remove most warnings in org.eclipse.team.bugzilla
Filename:
MIME Type:
Creator:
Ed Burnette
Created:
2005-05-31 16:27:59 EDT
Size:
192.92 KB
patch
obsolete
>Index: src/org/eclipse/team/bugzilla/adapters/BugzillaAttachmentAdapter.java >=================================================================== >RCS file: /cvs/eclipse/bugzilla/org.eclipse.team.bugzilla/src/org/eclipse/team/bugzilla/adapters/BugzillaAttachmentAdapter.java,v >retrieving revision 1.1 >diff -u -r1.1 BugzillaAttachmentAdapter.java >--- src/org/eclipse/team/bugzilla/adapters/BugzillaAttachmentAdapter.java 10 Jan 2005 17:08:28 -0000 1.1 >+++ src/org/eclipse/team/bugzilla/adapters/BugzillaAttachmentAdapter.java 31 May 2005 20:25:41 -0000 >@@ -1,82 +1,82 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2004 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Common Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/cpl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.team.bugzilla.adapters; >- >-import org.eclipse.jface.resource.ImageDescriptor; >-import org.eclipse.swt.custom.StyledText; >-import org.eclipse.swt.graphics.FontData; >-import org.eclipse.team.bugzilla.BugzillaImages; >-import org.eclipse.team.bugzilla.browser.IWebContentAdapter; >-import org.eclipse.team.bugzilla.datatypes.AttachmentDescription; >-import org.eclipse.team.bugzilla.model.BugzillaAttachment; >-import org.eclipse.team.bugzilla.view.BugzillaModelPresenter; >-import org.eclipse.team.bugzilla.view.IPresentableAdapter; >- >-/** >- * >- */ >-public class BugzillaAttachmentAdapter extends ModelElementAdapter implements IPresentableAdapter, IWebContentAdapter { >- >- public BugzillaAttachmentAdapter() { >- super(); >- } >- >- public void present(Object presentable, StyledText styledText) { >- >- if (!(presentable instanceof BugzillaAttachment)) >- return; >- >- new BugzillaModelPresenter().present((BugzillaAttachment)presentable, styledText); >- } >- >- protected ImageDescriptor doGetImageDescriptor(Object object) { >- final BugzillaAttachment attachment= (BugzillaAttachment)object; >- return attachment.getData() != null ? BugzillaImages.ATTACHMENT: BugzillaImages.INCOMPLETE_ATTACHMENT; >- } >- >- public String getLabel(Object o) { >- final BugzillaAttachment attachment= (BugzillaAttachment)o; >- return attachment.isRefreshing() ? getRefreshingLabel("attachment " + attachment.getID()) : getStandardLabel(attachment); >- } >- >- /** >- * @param attachment >- * @return >- */ >- private String getStandardLabel(final BugzillaAttachment attachment) { >- final StringBuffer label= new StringBuffer(); >- >- if (attachment.getDescription().getBoolean(AttachmentDescription.OBSOLETE)) >- label.append("[OBSOLETE] "); >- >- label.append("[").append(attachment.getDescription().getString(AttachmentDescription.ID)).append("] "); >- >- if (attachment.hasLocalContent()) >- label.append(attachment.getDescription().getString(AttachmentDescription.DESCRIPTION)); >- >- return label.toString(); >- } >- >- public String getURL(Object o) { >- return null; >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.team.bugzilla.adapters.ModelElementAdapter#getFont(java.lang.Object) >- */ >- public FontData getFont(Object element) { >- final BugzillaAttachment attachment= (BugzillaAttachment)element; >- if (attachment.isRefreshing()) >- return getRefreshingFont(); >- return super.getFont(element); >- } >-} >+/******************************************************************************* >+ * Copyright (c) 2000, 2004 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.team.bugzilla.adapters; >+ >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.swt.custom.StyledText; >+import org.eclipse.swt.graphics.FontData; >+import org.eclipse.team.bugzilla.BugzillaImages; >+import org.eclipse.team.bugzilla.browser.IWebContentAdapter; >+import org.eclipse.team.bugzilla.datatypes.AttachmentDescription; >+import org.eclipse.team.bugzilla.model.BugzillaAttachment; >+import org.eclipse.team.bugzilla.view.BugzillaModelPresenter; >+import org.eclipse.team.bugzilla.view.IPresentableAdapter; >+ >+/** >+ * >+ */ >+public class BugzillaAttachmentAdapter extends ModelElementAdapter implements IPresentableAdapter, IWebContentAdapter { >+ >+ public BugzillaAttachmentAdapter() { >+ super(); >+ } >+ >+ public void present(Object presentable, StyledText styledText) { >+ >+ if (!(presentable instanceof BugzillaAttachment)) >+ return; >+ >+ new BugzillaModelPresenter().present((BugzillaAttachment)presentable, styledText); >+ } >+ >+ protected ImageDescriptor doGetImageDescriptor(Object object) { >+ final BugzillaAttachment attachment= (BugzillaAttachment)object; >+ return attachment.getData() != null ? BugzillaImages.ATTACHMENT: BugzillaImages.INCOMPLETE_ATTACHMENT; >+ } >+ >+ public String getLabel(Object o) { >+ final BugzillaAttachment attachment= (BugzillaAttachment)o; >+ return attachment.isRefreshing() ? getRefreshingLabel("attachment " + attachment.getID()) : getStandardLabel(attachment); >+ } >+ >+ /** >+ * @param attachment >+ * @return String >+ */ >+ private String getStandardLabel(final BugzillaAttachment attachment) { >+ final StringBuffer label= new StringBuffer(); >+ >+ if (attachment.getDescription().getBoolean(AttachmentDescription.OBSOLETE)) >+ label.append("[OBSOLETE] "); >+ >+ label.append("[").append(attachment.getDescription().getString(AttachmentDescription.ID)).append("] "); >+ >+ if (attachment.hasLocalContent()) >+ label.append(attachment.getDescription().getString(AttachmentDescription.DESCRIPTION)); >+ >+ return label.toString(); >+ } >+ >+ public String getURL(Object o) { >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.team.bugzilla.adapters.ModelElementAdapter#getFont(java.lang.Object) >+ */ >+ public FontData getFont(Object element) { >+ final BugzillaAttachment attachment= (BugzillaAttachment)element; >+ if (attachment.isRefreshing()) >+ return getRefreshingFont(); >+ return super.getFont(element); >+ } >+} >Index: src/org/eclipse/team/bugzilla/adapters/BugzillaFolderAdapter.java >=================================================================== >RCS file: /cvs/eclipse/bugzilla/org.eclipse.team.bugzilla/src/org/eclipse/team/bugzilla/adapters/BugzillaFolderAdapter.java,v >retrieving revision 1.5 >diff -u -r1.5 BugzillaFolderAdapter.java >--- src/org/eclipse/team/bugzilla/adapters/BugzillaFolderAdapter.java 1 Mar 2005 19:51:09 -0000 1.5 >+++ src/org/eclipse/team/bugzilla/adapters/BugzillaFolderAdapter.java 31 May 2005 20:25:41 -0000 >@@ -1,35 +1,31 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2004 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Common Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/cpl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.team.bugzilla.adapters; >- >-import org.eclipse.swt.custom.StyledText; >-import org.eclipse.team.bugzilla.model.BugzillaFolder; >-import org.eclipse.team.bugzilla.view.BugzillaModelPresenter; >-import org.eclipse.team.bugzilla.view.IPresentableAdapter; >- >-/** >- * >- */ >-public class BugzillaFolderAdapter extends ContainerAdapter /*implements IPresentableAdapter*/ { >- >- public BugzillaFolderAdapter() { >- } >- /* >- public void present(Object presentable, StyledText styledText) { >- >- if (!(presentable instanceof BugzillaFolder)) >- return; >- >- new BugzillaModelPresenter().present((BugzillaFolder)presentable, styledText); >- } >- */ >-} >+/******************************************************************************* >+ * Copyright (c) 2000, 2004 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.team.bugzilla.adapters; >+ >+ >+/** >+ * >+ */ >+public class BugzillaFolderAdapter extends ContainerAdapter /*implements IPresentableAdapter*/ { >+ >+ public BugzillaFolderAdapter() { >+ } >+ /* >+ public void present(Object presentable, StyledText styledText) { >+ >+ if (!(presentable instanceof BugzillaFolder)) >+ return; >+ >+ new BugzillaModelPresenter().present((BugzillaFolder)presentable, styledText); >+ } >+ */ >+} >Index: src/org/eclipse/team/bugzilla/adapters/BugzillaQueryAdapter.java >=================================================================== >RCS file: /cvs/eclipse/bugzilla/org.eclipse.team.bugzilla/src/org/eclipse/team/bugzilla/adapters/BugzillaQueryAdapter.java,v >retrieving revision 1.2 >diff -u -r1.2 BugzillaQueryAdapter.java >--- src/org/eclipse/team/bugzilla/adapters/BugzillaQueryAdapter.java 10 Jan 2005 20:07:03 -0000 1.2 >+++ src/org/eclipse/team/bugzilla/adapters/BugzillaQueryAdapter.java 31 May 2005 20:25:41 -0000 >@@ -1,80 +1,80 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2004 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Common Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/cpl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.team.bugzilla.adapters; >- >-import org.eclipse.jface.resource.ImageDescriptor; >-import org.eclipse.swt.custom.StyledText; >-import org.eclipse.swt.graphics.FontData; >-import org.eclipse.team.bugzilla.BugzillaImages; >-import org.eclipse.team.bugzilla.browser.IWebContentAdapter; >-import org.eclipse.team.bugzilla.model.BugzillaQuery; >-import org.eclipse.team.bugzilla.view.BugzillaModelPresenter; >-import org.eclipse.team.bugzilla.view.IPresentableAdapter; >- >-public class BugzillaQueryAdapter extends ContainerAdapter implements IWebContentAdapter, IPresentableAdapter { >- >- /* (non-Javadoc) >- * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object) >- */ >- protected ImageDescriptor doGetImageDescriptor(Object object) { >- return BugzillaImages.QUERY; >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.team.bugzilla.browser.IWebContentAdapter#getURL(java.lang.Object) >- */ >- public String getURL(Object o) { >- if (o instanceof BugzillaQuery) { >- return ((BugzillaQuery)o).getQueryUrl().toUrlString(); >- } >- return null; >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.team.bugzilla.adapters.ContainerAdapter#getLabel(java.lang.Object) >- */ >- public String getLabel(Object o) { >- final BugzillaQuery query= (BugzillaQuery)o; >- return query.isRefreshing() ? getRefreshingLabel("query " + query.getName()) : getStandardLabel(query); >- } >- >- /** >- * @param query >- * @return >- */ >- private String getStandardLabel(final BugzillaQuery query) { >- final StringBuffer label= new StringBuffer(); >- if (query.hasLocalContent()) { >- label.append("("); >- final int size= query.getChildren().length; >- label.append(size).append(size == 1 ? " result" : " results").append(") "); >- } >- return label.append(query.getName()).toString(); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.team.bugzilla.adapters.ModelElementAdapter#getFont(java.lang.Object) >- */ >- public FontData getFont(Object element) { >- final BugzillaQuery query= (BugzillaQuery)element; >- if (query.isRefreshing()) >- return getRefreshingFont(); >- return super.getFont(element); >- } >- >- public void present(Object presentable, StyledText styledText) { >- >- if (!(presentable instanceof BugzillaQuery)) >- return; >- >- new BugzillaModelPresenter().present((BugzillaQuery)presentable, styledText); >- } >-} >+/******************************************************************************* >+ * Copyright (c) 2000, 2004 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.team.bugzilla.adapters; >+ >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.swt.custom.StyledText; >+import org.eclipse.swt.graphics.FontData; >+import org.eclipse.team.bugzilla.BugzillaImages; >+import org.eclipse.team.bugzilla.browser.IWebContentAdapter; >+import org.eclipse.team.bugzilla.model.BugzillaQuery; >+import org.eclipse.team.bugzilla.view.BugzillaModelPresenter; >+import org.eclipse.team.bugzilla.view.IPresentableAdapter; >+ >+public class BugzillaQueryAdapter extends ContainerAdapter implements IWebContentAdapter, IPresentableAdapter { >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object) >+ */ >+ protected ImageDescriptor doGetImageDescriptor(Object object) { >+ return BugzillaImages.QUERY; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.team.bugzilla.browser.IWebContentAdapter#getURL(java.lang.Object) >+ */ >+ public String getURL(Object o) { >+ if (o instanceof BugzillaQuery) { >+ return ((BugzillaQuery)o).getQueryUrl().toUrlString(); >+ } >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.team.bugzilla.adapters.ContainerAdapter#getLabel(java.lang.Object) >+ */ >+ public String getLabel(Object o) { >+ final BugzillaQuery query= (BugzillaQuery)o; >+ return query.isRefreshing() ? getRefreshingLabel("query " + query.getName()) : getStandardLabel(query); >+ } >+ >+ /** >+ * @param query >+ * @return String >+ */ >+ private String getStandardLabel(final BugzillaQuery query) { >+ final StringBuffer label= new StringBuffer(); >+ if (query.hasLocalContent()) { >+ label.append("("); >+ final int size= query.getChildren().length; >+ label.append(size).append(size == 1 ? " result" : " results").append(") "); >+ } >+ return label.append(query.getName()).toString(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.team.bugzilla.adapters.ModelElementAdapter#getFont(java.lang.Object) >+ */ >+ public FontData getFont(Object element) { >+ final BugzillaQuery query= (BugzillaQuery)element; >+ if (query.isRefreshing()) >+ return getRefreshingFont(); >+ return super.getFont(element); >+ } >+ >+ public void present(Object presentable, StyledText styledText) { >+ >+ if (!(presentable instanceof BugzillaQuery)) >+ return; >+ >+ new BugzillaModelPresenter().present((BugzillaQuery)presentable, styledText); >+ } >+} >Index: src/org/eclipse/team/bugzilla/adapters/BugzillaReportAdapter.java >=================================================================== >RCS file: /cvs/eclipse/bugzilla/org.eclipse.team.bugzilla/src/org/eclipse/team/bugzilla/adapters/BugzillaReportAdapter.java,v >retrieving revision 1.1 >diff -u -r1.1 BugzillaReportAdapter.java >--- src/org/eclipse/team/bugzilla/adapters/BugzillaReportAdapter.java 10 Jan 2005 17:08:28 -0000 1.1 >+++ src/org/eclipse/team/bugzilla/adapters/BugzillaReportAdapter.java 31 May 2005 20:25:41 -0000 >@@ -1,137 +1,136 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2004 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Common Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/cpl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.team.bugzilla.adapters; >- >-import org.eclipse.jface.resource.ImageDescriptor; >-import org.eclipse.swt.custom.StyledText; >-import org.eclipse.swt.graphics.FontData; >-import org.eclipse.swt.graphics.RGB; >-import org.eclipse.team.bugzilla.BugzillaImages; >-import org.eclipse.team.bugzilla.browser.IWebContentAdapter; >-import org.eclipse.team.bugzilla.datatypes.ReportData; >-import org.eclipse.team.bugzilla.model.BugzillaProvider; >-import org.eclipse.team.bugzilla.model.BugzillaReport; >-import org.eclipse.team.bugzilla.operations.CachedOperations; >-import org.eclipse.team.bugzilla.view.BugzillaModelPresenter; >-import org.eclipse.team.bugzilla.view.IPresentableAdapter; >- >-/** >- * >- */ >-public class BugzillaReportAdapter extends ModelElementAdapter implements IPresentableAdapter, IWebContentAdapter { >- >- >- public void present(Object presentable, StyledText styledText) { >- >- if (!(presentable instanceof BugzillaReport)) >- return; >- >- new BugzillaModelPresenter().present((BugzillaReport)presentable, styledText); >- } >- >- public Object[] getChildren(Object o) { >- return ((BugzillaReport)o).getComments().toArray(); >- } >- >- protected ImageDescriptor doGetImageDescriptor(Object object) { >- final BugzillaReport report= (BugzillaReport)object; >- final ReportData data= report.getReportData(); >- return data != null ? BugzillaImages.BUG : BugzillaImages.INCOMPLETE_BUG; >- } >- >- public String getLabel(Object o) { >- final BugzillaReport report= (BugzillaReport)o; >- return report.isRefreshing() ? getRefreshingLabel("bug " + report.getID()) : getStandardLabel(report); >- } >- >- /** >- * @param report >- * @param name >- * @return >- */ >- private String getStandardLabel(final BugzillaReport report) { >- final StringBuffer name= new StringBuffer(); >- name.append(report.getID()); >- >- final ReportData data= report.getReportData(); >- >- if (data != null) { >- final String priority= data.getString(ReportData.PRIORITY); >- final String status= data.getString(ReportData.STATUS); >- final String milestone= data.getString(ReportData.TARGETMILESTONE); >- final String title= data.getString(ReportData.TITLE); >- >- name.append(" ["); >- if (priority != null) name.append(priority); >- if (status != null) name.append(" ").append(status); >- if (milestone != null) name.append(" ").append(milestone); >- name.append("]"); >- if (title != null) name.append(" ").append(title); >- } >- return name.toString(); >- } >- >- public String getURL(Object o) { >- final BugzillaReport report= (BugzillaReport)o; >- final BugzillaProvider provider= (BugzillaProvider)report.getProvider(); >- final CachedOperations operations= provider.getOperations(); >- if (operations.isCached()) { >- return operations.getOperations().getReportURL(provider.getConfiguration(), report.getID()); >- } >- return null; >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.ui.model.IWorkbenchAdapter2#getForeground(java.lang.Object) >- */ >- public RGB getForeground(Object element) { >- final ReportData data= ((BugzillaReport)element).getReportData(); >- >- if (data == null) >- return super.getForeground(element); >- >- final String severity= data.getString(ReportData.SEVERITY); >- >- if ("blocker".equals(severity) || "critical".equals(severity)) { >- return RED; >- } >- return super.getForeground(element); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.ui.model.IWorkbenchAdapter2#getFont(java.lang.Object) >- */ >- public FontData getFont(Object element) { >- >- final BugzillaReport report= (BugzillaReport)element; >- if (report.isRefreshing()) >- return getRefreshingFont(); >- >- final ReportData data= report.getReportData(); >- >- if (data == null) >- return super.getFont(element); >- >- final String severity= data.getString(ReportData.SEVERITY); >- >- if ("enhancement".equals(severity)) { >- return ITALIC_FONT; >- } >- >- if ("blocker".equals(severity)) { >- return BOLD_FONT; >- } >- >- return super.getFont(element); >- } >- >-} >+/******************************************************************************* >+ * Copyright (c) 2000, 2004 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.team.bugzilla.adapters; >+ >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.swt.custom.StyledText; >+import org.eclipse.swt.graphics.FontData; >+import org.eclipse.swt.graphics.RGB; >+import org.eclipse.team.bugzilla.BugzillaImages; >+import org.eclipse.team.bugzilla.browser.IWebContentAdapter; >+import org.eclipse.team.bugzilla.datatypes.ReportData; >+import org.eclipse.team.bugzilla.model.BugzillaProvider; >+import org.eclipse.team.bugzilla.model.BugzillaReport; >+import org.eclipse.team.bugzilla.operations.CachedOperations; >+import org.eclipse.team.bugzilla.view.BugzillaModelPresenter; >+import org.eclipse.team.bugzilla.view.IPresentableAdapter; >+ >+/** >+ * >+ */ >+public class BugzillaReportAdapter extends ModelElementAdapter implements IPresentableAdapter, IWebContentAdapter { >+ >+ >+ public void present(Object presentable, StyledText styledText) { >+ >+ if (!(presentable instanceof BugzillaReport)) >+ return; >+ >+ new BugzillaModelPresenter().present((BugzillaReport)presentable, styledText); >+ } >+ >+ public Object[] getChildren(Object o) { >+ return ((BugzillaReport)o).getComments().toArray(); >+ } >+ >+ protected ImageDescriptor doGetImageDescriptor(Object object) { >+ final BugzillaReport report= (BugzillaReport)object; >+ final ReportData data= report.getReportData(); >+ return data != null ? BugzillaImages.BUG : BugzillaImages.INCOMPLETE_BUG; >+ } >+ >+ public String getLabel(Object o) { >+ final BugzillaReport report= (BugzillaReport)o; >+ return report.isRefreshing() ? getRefreshingLabel("bug " + report.getID()) : getStandardLabel(report); >+ } >+ >+ /** >+ * @param report >+ * @return String >+ */ >+ private String getStandardLabel(final BugzillaReport report) { >+ final StringBuffer name= new StringBuffer(); >+ name.append(report.getID()); >+ >+ final ReportData data= report.getReportData(); >+ >+ if (data != null) { >+ final String priority= data.getString(ReportData.PRIORITY); >+ final String status= data.getString(ReportData.STATUS); >+ final String milestone= data.getString(ReportData.TARGETMILESTONE); >+ final String title= data.getString(ReportData.TITLE); >+ >+ name.append(" ["); >+ if (priority != null) name.append(priority); >+ if (status != null) name.append(" ").append(status); >+ if (milestone != null) name.append(" ").append(milestone); >+ name.append("]"); >+ if (title != null) name.append(" ").append(title); >+ } >+ return name.toString(); >+ } >+ >+ public String getURL(Object o) { >+ final BugzillaReport report= (BugzillaReport)o; >+ final BugzillaProvider provider= (BugzillaProvider)report.getProvider(); >+ final CachedOperations operations= provider.getOperations(); >+ if (operations.isCached()) { >+ return operations.getOperations().getReportURL(provider.getConfiguration(), report.getID()); >+ } >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.model.IWorkbenchAdapter2#getForeground(java.lang.Object) >+ */ >+ public RGB getForeground(Object element) { >+ final ReportData data= ((BugzillaReport)element).getReportData(); >+ >+ if (data == null) >+ return super.getForeground(element); >+ >+ final String severity= data.getString(ReportData.SEVERITY); >+ >+ if ("blocker".equals(severity) || "critical".equals(severity)) { >+ return RED; >+ } >+ return super.getForeground(element); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.model.IWorkbenchAdapter2#getFont(java.lang.Object) >+ */ >+ public FontData getFont(Object element) { >+ >+ final BugzillaReport report= (BugzillaReport)element; >+ if (report.isRefreshing()) >+ return getRefreshingFont(); >+ >+ final ReportData data= report.getReportData(); >+ >+ if (data == null) >+ return super.getFont(element); >+ >+ final String severity= data.getString(ReportData.SEVERITY); >+ >+ if ("enhancement".equals(severity)) { >+ return ITALIC_FONT; >+ } >+ >+ if ("blocker".equals(severity)) { >+ return BOLD_FONT; >+ } >+ >+ return super.getFont(element); >+ } >+ >+} >Index: src/org/eclipse/team/bugzilla/datatypes/BugzillaConfiguration.java >=================================================================== >RCS file: /cvs/eclipse/bugzilla/org.eclipse.team.bugzilla/src/org/eclipse/team/bugzilla/datatypes/BugzillaConfiguration.java,v >retrieving revision 1.2 >diff -u -r1.2 BugzillaConfiguration.java >--- src/org/eclipse/team/bugzilla/datatypes/BugzillaConfiguration.java 25 Jan 2005 20:07:01 -0000 1.2 >+++ src/org/eclipse/team/bugzilla/datatypes/BugzillaConfiguration.java 31 May 2005 20:25:41 -0000 >@@ -1,68 +1,62 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2004 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Common Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/cpl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.team.bugzilla.datatypes; >- >-import org.eclipse.team.bugzilla.BugzillaFactory; >- >- >- >-public class BugzillaConfiguration { >- >- private String fName; >- private String fBaseURL; >- private String fCookie; >- private int version; >- >- public BugzillaConfiguration(String name, String baseURL) { >- fName= name; >- fBaseURL= baseURL; >- version = BugzillaFactory.VERSION_UNKNOWN; >- } >- >- public void setBaseURL(String baseURL) { >- fBaseURL = baseURL; >- } >- >- public String getBaseURL() { >- return fBaseURL; >- } >- >- public String getName() { >- return fName; >- } >- >- public void setName(String name) { >- fName = name; >- } >- >- /** >- * @param cookie >- */ >- public void setLoginCookie(String cookie) { >- this.fCookie = cookie; >- } >- >- /** >- * @return >- */ >- public String getLoginCookie() { >- return fCookie; >- } >- >- >- public int getVersion() { >- return version; >- } >- >- public void setVersion(int version) { >- this.version = version; >- } >-} >+/******************************************************************************* >+ * Copyright (c) 2000, 2004 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.team.bugzilla.datatypes; >+ >+import org.eclipse.team.bugzilla.BugzillaFactory; >+ >+ >+ >+public class BugzillaConfiguration { >+ >+ private String fName; >+ private String fBaseURL; >+ private String fCookie; >+ private int version; >+ >+ public BugzillaConfiguration(String name, String baseURL) { >+ fName= name; >+ fBaseURL= baseURL; >+ version = BugzillaFactory.VERSION_UNKNOWN; >+ } >+ >+ public void setBaseURL(String baseURL) { >+ fBaseURL = baseURL; >+ } >+ >+ public String getBaseURL() { >+ return fBaseURL; >+ } >+ >+ public String getName() { >+ return fName; >+ } >+ >+ public void setName(String name) { >+ fName = name; >+ } >+ >+ public void setLoginCookie(String cookie) { >+ this.fCookie = cookie; >+ } >+ >+ public String getLoginCookie() { >+ return fCookie; >+ } >+ >+ >+ public int getVersion() { >+ return version; >+ } >+ >+ public void setVersion(int version) { >+ this.version = version; >+ } >+} >Index: src/org/eclipse/team/bugzilla/datatypes/CommentData.java >=================================================================== >RCS file: /cvs/eclipse/bugzilla/org.eclipse.team.bugzilla/src/org/eclipse/team/bugzilla/datatypes/CommentData.java,v >retrieving revision 1.1 >diff -u -r1.1 CommentData.java >--- src/org/eclipse/team/bugzilla/datatypes/CommentData.java 10 Jan 2005 17:08:28 -0000 1.1 >+++ src/org/eclipse/team/bugzilla/datatypes/CommentData.java 31 May 2005 20:25:41 -0000 >@@ -1,70 +1,67 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2004 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Common Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/cpl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.team.bugzilla.datatypes; >- >-import java.util.Collection; >-import java.util.LinkedHashSet; >- >- >- >-public class CommentData extends Data implements Comparable { >- >- public final static String AUTHOR= "0"; >- public final static String DATE= "1"; >- public final static String TEXT= "2"; >- >- private final static LinkedHashSet sSet; >- >- static { >- sSet= new LinkedHashSet(); >- sSet.add(AUTHOR); >- sSet.add(DATE); >- sSet.add(TEXT); >- } >- >- public AttachmentDescription attachmentDesc; >- >- public CommentData() { >- attachmentDesc= null; >- } >- >- public String toString() { >- final StringBuffer buffer= new StringBuffer(); >- final String nl= System.getProperty("line.separator"); //$NON-NLS-1$ >- buffer.append("Author: ").append(getString(AUTHOR)).append(nl); //$NON-NLS-1$ >- buffer.append("Date: ").append(getString(DATE)).append(nl); //$NON-NLS-1$ >- buffer.append("Text: ").append(getString(TEXT)).append(nl); //$NON-NLS-1$ >- return buffer.toString(); >- } >- >- public int compareTo(Object o) { >- return getDate(DATE).compareTo(((CommentData)o).getDate(DATE)); >- } >- >- public boolean equals(Object obj) { >- if (!(obj instanceof CommentData)) >- return false; >- final CommentData other = (CommentData)obj; >- return getString(TEXT).equals(other.getString(TEXT)) && getString(AUTHOR).equals(other.getString(AUTHOR)) && getDate(DATE).equals(other.getDate(DATE)); >- } >- >- protected Collection getKeys() { >- return sSet; >- } >- >- /** >- * @return >- */ >- public String getId() { >- return getDate(DATE).toString(); >- } >-} >+/******************************************************************************* >+ * Copyright (c) 2000, 2004 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.team.bugzilla.datatypes; >+ >+import java.util.Collection; >+import java.util.LinkedHashSet; >+ >+ >+ >+public class CommentData extends Data implements Comparable { >+ >+ public final static String AUTHOR= "0"; >+ public final static String DATE= "1"; >+ public final static String TEXT= "2"; >+ >+ private final static LinkedHashSet sSet; >+ >+ static { >+ sSet= new LinkedHashSet(); >+ sSet.add(AUTHOR); >+ sSet.add(DATE); >+ sSet.add(TEXT); >+ } >+ >+ public AttachmentDescription attachmentDesc; >+ >+ public CommentData() { >+ attachmentDesc= null; >+ } >+ >+ public String toString() { >+ final StringBuffer buffer= new StringBuffer(); >+ final String nl= System.getProperty("line.separator"); //$NON-NLS-1$ >+ buffer.append("Author: ").append(getString(AUTHOR)).append(nl); //$NON-NLS-1$ >+ buffer.append("Date: ").append(getString(DATE)).append(nl); //$NON-NLS-1$ >+ buffer.append("Text: ").append(getString(TEXT)).append(nl); //$NON-NLS-1$ >+ return buffer.toString(); >+ } >+ >+ public int compareTo(Object o) { >+ return getDate(DATE).compareTo(((CommentData)o).getDate(DATE)); >+ } >+ >+ public boolean equals(Object obj) { >+ if (!(obj instanceof CommentData)) >+ return false; >+ final CommentData other = (CommentData)obj; >+ return getString(TEXT).equals(other.getString(TEXT)) && getString(AUTHOR).equals(other.getString(AUTHOR)) && getDate(DATE).equals(other.getDate(DATE)); >+ } >+ >+ protected Collection getKeys() { >+ return sSet; >+ } >+ >+ public String getId() { >+ return getDate(DATE).toString(); >+ } >+} >Index: src/org/eclipse/team/bugzilla/datatypes/Data.java >=================================================================== >RCS file: /cvs/eclipse/bugzilla/org.eclipse.team.bugzilla/src/org/eclipse/team/bugzilla/datatypes/Data.java,v >retrieving revision 1.1 >diff -u -r1.1 Data.java >--- src/org/eclipse/team/bugzilla/datatypes/Data.java 10 Jan 2005 17:08:28 -0000 1.1 >+++ src/org/eclipse/team/bugzilla/datatypes/Data.java 31 May 2005 20:25:41 -0000 >@@ -1,99 +1,99 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2004 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Common Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/cpl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.team.bugzilla.datatypes; >- >-import java.text.DateFormat; >-import java.text.ParseException; >-import java.text.SimpleDateFormat; >-import java.util.Collection; >-import java.util.Date; >-import java.util.HashMap; >- >-/** >- * >- */ >-public abstract class Data { >- >- private final static DateFormat sDateFormat= new SimpleDateFormat("yyyy-MM-dd HH:mm"); //$NON-NLS-1$ >- >- private final HashMap fValues; >- private final HashMap fChangedValues; >- >- public Data() { >- fValues= new HashMap(); >- fChangedValues= new HashMap(); >- } >- >- public void set(String key, String value) { >- if (!getKeys().contains(key)) >- return; >- >- final String oldValue= (String)fValues.get(key); >- if (oldValue == null) { >- fValues.put(key, value); >- fChangedValues.remove(key); >- } else if (!oldValue.equals(value)) { >- fChangedValues.put(key, value); >- } >- } >- >- public void set(String key, Date date) { >- set(key, sDateFormat.format(date)); >- } >- >- public void set(String key, boolean state) { >- set(key, Boolean.valueOf(state).toString()); >- } >- >- public String getString(String key) { >- if (fChangedValues.containsKey(key)) >- return (String)fChangedValues.get(key); >- return (String)fValues.get(key); >- } >- >- public Date getDate(String key) { >- try { >- return sDateFormat.parse((String)fValues.get(key)); >- } catch (ParseException e) { >- return null; // should not happen! >- } >- } >- >- public boolean getBoolean(String key) { >- return Boolean.valueOf(getString(key)).booleanValue(); >- } >- >- public boolean hasChanged(String key) { >- return fChangedValues.containsKey(key); >- } >- >- public boolean exists(String key) { >- return fValues.containsKey(key); >- } >- >- public void commitChanged() { >- fValues.putAll(fChangedValues); >- } >- >- public void commitChanged(String key) { >- if (fChangedValues.containsKey(key)) { >- fValues.put(key, fChangedValues.get(key)); >- } >- } >- >- /** >- * Clients must implement this to define the set of keys which are allowed. Iteration and lookup >- * should be fast, so a LinkedHashSet may be a good choice. >- * @return >- */ >- protected abstract Collection getKeys(); >-} >+/******************************************************************************* >+ * Copyright (c) 2000, 2004 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.team.bugzilla.datatypes; >+ >+import java.text.DateFormat; >+import java.text.ParseException; >+import java.text.SimpleDateFormat; >+import java.util.Collection; >+import java.util.Date; >+import java.util.HashMap; >+ >+/** >+ * >+ */ >+public abstract class Data { >+ >+ private final static DateFormat sDateFormat= new SimpleDateFormat("yyyy-MM-dd HH:mm"); //$NON-NLS-1$ >+ >+ private final HashMap fValues; >+ private final HashMap fChangedValues; >+ >+ public Data() { >+ fValues= new HashMap(); >+ fChangedValues= new HashMap(); >+ } >+ >+ public void set(String key, String value) { >+ if (!getKeys().contains(key)) >+ return; >+ >+ final String oldValue= (String)fValues.get(key); >+ if (oldValue == null) { >+ fValues.put(key, value); >+ fChangedValues.remove(key); >+ } else if (!oldValue.equals(value)) { >+ fChangedValues.put(key, value); >+ } >+ } >+ >+ public void set(String key, Date date) { >+ set(key, sDateFormat.format(date)); >+ } >+ >+ public void set(String key, boolean state) { >+ set(key, Boolean.valueOf(state).toString()); >+ } >+ >+ public String getString(String key) { >+ if (fChangedValues.containsKey(key)) >+ return (String)fChangedValues.get(key); >+ return (String)fValues.get(key); >+ } >+ >+ public Date getDate(String key) { >+ try { >+ return sDateFormat.parse((String)fValues.get(key)); >+ } catch (ParseException e) { >+ return null; // should not happen! >+ } >+ } >+ >+ public boolean getBoolean(String key) { >+ return Boolean.valueOf(getString(key)).booleanValue(); >+ } >+ >+ public boolean hasChanged(String key) { >+ return fChangedValues.containsKey(key); >+ } >+ >+ public boolean exists(String key) { >+ return fValues.containsKey(key); >+ } >+ >+ public void commitChanged() { >+ fValues.putAll(fChangedValues); >+ } >+ >+ public void commitChanged(String key) { >+ if (fChangedValues.containsKey(key)) { >+ fValues.put(key, fChangedValues.get(key)); >+ } >+ } >+ >+ /** >+ * Clients must implement this to define the set of keys which are allowed. Iteration and lookup >+ * should be fast, so a LinkedHashSet may be a good choice. >+ * @return Collection >+ */ >+ protected abstract Collection getKeys(); >+} >Index: src/org/eclipse/team/bugzilla/datatypes/DataCache.java >=================================================================== >RCS file: /cvs/eclipse/bugzilla/org.eclipse.team.bugzilla/src/org/eclipse/team/bugzilla/datatypes/DataCache.java,v >retrieving revision 1.4 >diff -u -r1.4 DataCache.java >--- src/org/eclipse/team/bugzilla/datatypes/DataCache.java 25 Feb 2005 19:24:45 -0000 1.4 >+++ src/org/eclipse/team/bugzilla/datatypes/DataCache.java 31 May 2005 20:25:41 -0000 >@@ -1,274 +1,270 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2004 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Common Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/cpl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.team.bugzilla.datatypes; >- >-import java.lang.reflect.InvocationTargetException; >-import java.util.ArrayList; >-import java.util.Collections; >-import java.util.HashMap; >-import java.util.HashSet; >-import java.util.Iterator; >-import java.util.List; >-import java.util.Map; >-import java.util.Set; >- >-import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.core.runtime.ISafeRunnable; >-import org.eclipse.core.runtime.MultiStatus; >-import org.eclipse.core.runtime.Platform; >-import org.eclipse.jface.util.ListenerList; >-import org.eclipse.team.bugs.extension.BugsException; >-import org.eclipse.team.bugzilla.BugzillaException; >-import org.eclipse.team.bugzilla.BugzillaPlugin; >-import org.eclipse.team.bugzilla.model.BugzillaProvider; >-import org.eclipse.team.bugzilla.model.BugzillaQueryOptions; >-import org.eclipse.team.bugzilla.model.IRemoteModel; >-import org.eclipse.team.bugzilla.operations.RefreshOperation; >- >-/** >- * Caches any data fetched from a bugzilla server >- */ >-public class DataCache { >- >- protected final BugzillaProvider fProvider; >- private final Map fReports; >- private final Map fAttachments; >- private final Map fQueries; >- >- private final Set fReportErrors; >- private final Set fAttachmentErrors; >- private final Set fQueryErrors; >- >- private final BugzillaQueryOptions queryOptions; >- >- private ListenerList fListeners = new ListenerList(); >- >- public DataCache(BugzillaProvider provider) { >- fProvider = provider; >- >- fReports= Collections.synchronizedMap(new HashMap()); >- fAttachments= Collections.synchronizedMap(new HashMap()); >- fQueries= Collections.synchronizedMap(new HashMap()); >- >- fReportErrors= Collections.synchronizedSet(new HashSet()); >- fAttachmentErrors = Collections.synchronizedSet(new HashSet()); >- fQueryErrors= Collections.synchronizedSet(new HashSet()); >- >- /* TODO: jpound - cache query options */ >- queryOptions = new BugzillaQueryOptions(provider.getBaseURL()); >- } >- >- /** >- * Return the cached report data for the given bug id. >- * If no data is cached, <code>null</code> is returned. >- * @param id the bug id >- * @return the cached ReportData or <code>null</code> >- */ >- public ReportData getReport(String id) { >- return (ReportData)fReports.get(id); >- } >- >- /** >- * Return the cached attachment for the given id. >- * If no attachment is cached, <code>null</code> is returned. >- * @param desc the attachment id >- * @return the cached attachment or <code>null</code> >- */ >- public AttachmentData getAttachment(AttachmentDescription desc) { >- return (AttachmentData)fAttachments.get(desc); >- } >- >- public void refreshReports(String[] reportIds, IProgressMonitor monitor) throws BugzillaException { >- List errors = new ArrayList(); >- for (int i = 0; i < reportIds.length; i++) { >- String id = reportIds[i]; >- try { >- ReportData data = fProvider.getOperations().getReportData(monitor, id); >- add(data); >- fReportErrors.remove(id); >- } catch (BugzillaException e) { >- errors.add(e); >- fReportErrors.add(id); >- } >- } >- fireReportDataChanged(reportIds); >- handleErrors(errors); >- } >- >- private void handleErrors(List errors) throws BugzillaException { >- if (errors.size() == 1) { >- throw (BugzillaException)errors.get(0); >- } else if (!errors.isEmpty()) { >- MultiStatus status = new MultiStatus(BugzillaPlugin.ID, 0, "Errors occured during refresh", null); >- for (Iterator iter = errors.iterator(); iter.hasNext();) { >- BugsException e = (BugsException) iter.next(); >- status.add(e.getStatus()); >- throw new BugzillaException(status); >- } >- } >- >- } >- >- public void refreshAttachments(AttachmentDescription[] descs, IProgressMonitor monitor) throws BugzillaException { >- List errors = new ArrayList(); >- for (int i = 0; i < descs.length; i++) { >- AttachmentDescription desc = descs[i]; >- try { >- AttachmentData data = fProvider.getOperations().getAttachment(monitor, desc); >- add(desc, data); >- fAttachmentErrors.remove(desc); >- } catch (BugzillaException e) { >- errors.add(e); >- fAttachmentErrors.add(desc); >- } >- } >- fireAttachmentDataChanged(descs); >- handleErrors(errors); >- } >- >- private void add(AttachmentDescription desc, AttachmentData data) { >- fAttachments.put(desc, data); >- } >- >- private void fireAttachmentDataChanged(final AttachmentDescription[] descs) { >- Object[] allListeners = fListeners.getListeners(); >- for (int i = 0; i < allListeners.length; i++) { >- final IBugRefreshListener listener = (IBugRefreshListener)allListeners[i]; >- Platform.run(new ISafeRunnable() { >- public void handleException(Throwable exception) { >- } >- public void run() throws Exception { >- listener.attachmentsChanged(fProvider, descs); >- } >- }); >- } >- } >- >- private void fireReportDataChanged(final String[] reportIds) { >- Object[] allListeners = fListeners.getListeners(); >- for (int i = 0; i < allListeners.length; i++) { >- final IBugRefreshListener listener = (IBugRefreshListener)allListeners[i]; >- Platform.run(new ISafeRunnable() { >- public void handleException(Throwable exception) { >- // Logged by Core >- } >- public void run() throws Exception { >- listener.reportDataChange(fProvider, reportIds); >- } >- }); >- } >- } >- >- private void add(ReportData data) { >- fReports.put(data.getString(ReportData.ID), data); >- } >- >- public void addRefreshListener(IBugRefreshListener listener) { >- fListeners.add(listener); >- } >- >- public void removeRefreshListener(IBugRefreshListener listener) { >- fListeners.remove(listener); >- } >- >- /** >- * @param datas >- * @param monitor >- */ >- public void refreshQuery(QueryURL[] datas, IProgressMonitor monitor) throws BugzillaException { >- List errors = new ArrayList(); >- for (int i = 0; i < datas.length; i++) { >- QueryURL url = datas[i]; >- try { >- QueryData data = fProvider.getOperations().getQueryData(monitor, url); >- if (data == null) { >- return; >- } >- add(url, data); >- fQueryErrors.remove(url); >- } catch (BugzillaException e) { >- errors.add(e); >- fQueryErrors.add(url); >- } >- } >- fireQueryChanged(datas); >- handleErrors(errors); >- } >- >- private void fireQueryChanged(final QueryURL[] datas) { >- Object[] allListeners = fListeners.getListeners(); >- for (int i = 0; i < allListeners.length; i++) { >- final IBugRefreshListener listener = (IBugRefreshListener)allListeners[i]; >- Platform.run(new ISafeRunnable() { >- public void handleException(Throwable exception) { >- // Logged by Core >- } >- public void run() throws Exception { >- listener.queryChange(fProvider, datas); >- } >- }); >- } >- } >- >- private void add(QueryURL url, QueryData data) { >- fQueries.put(url, data); >- ReportData[] datas = data.getReportDatas(); >- for (int i = 0; i < datas.length; i++) { >- ReportData report = datas[i]; >- if (getReport(report.getString(ReportData.ID)) == null) { >- add(report); >- } >- } >- } >- >- /** >- * @param queryUrl >- * @return >- */ >- public QueryData getQueryData(QueryURL queryUrl) { >- return (QueryData)fQueries.get(queryUrl); >- } >- >- public boolean hadErrorsForReport(String id) { >- return fReportErrors.contains(id); >- } >- >- public boolean hadErrorsForQuery(QueryURL url) { >- return fQueryErrors.contains(url); >- } >- >- public boolean hadErrorsForAttachment(AttachmentDescription desc) { >- return fAttachmentErrors.contains(desc); >- } >- >- /** >- * >- * @return The query options for this bugzilla database. >- */ >- public BugzillaQueryOptions getQueryOptions() { >- return queryOptions; >- } >- >- /** >- * >- */ >- public void refreshQueryOptions() { >- try { >- new RefreshOperation(null, new IRemoteModel[] { getQueryOptions() }).run(); >- } catch (InvocationTargetException e) { >- System.err.println("InvocationTargetException"); >- //handleError(e); >- } catch (InterruptedException e) { >- System.err.println("InterruptedException"); >- // Ignore >- } >- } >-} >+/******************************************************************************* >+ * Copyright (c) 2000, 2004 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.team.bugzilla.datatypes; >+ >+import java.lang.reflect.InvocationTargetException; >+import java.util.ArrayList; >+import java.util.Collections; >+import java.util.HashMap; >+import java.util.HashSet; >+import java.util.Iterator; >+import java.util.List; >+import java.util.Map; >+import java.util.Set; >+ >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.ISafeRunnable; >+import org.eclipse.core.runtime.MultiStatus; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.jface.util.ListenerList; >+import org.eclipse.team.bugs.extension.BugsException; >+import org.eclipse.team.bugzilla.BugzillaException; >+import org.eclipse.team.bugzilla.BugzillaPlugin; >+import org.eclipse.team.bugzilla.model.BugzillaProvider; >+import org.eclipse.team.bugzilla.model.BugzillaQueryOptions; >+import org.eclipse.team.bugzilla.model.IRemoteModel; >+import org.eclipse.team.bugzilla.operations.RefreshOperation; >+ >+/** >+ * Caches any data fetched from a bugzilla server >+ */ >+public class DataCache { >+ >+ protected final BugzillaProvider fProvider; >+ private final Map fReports; >+ private final Map fAttachments; >+ private final Map fQueries; >+ >+ private final Set fReportErrors; >+ private final Set fAttachmentErrors; >+ private final Set fQueryErrors; >+ >+ private final BugzillaQueryOptions queryOptions; >+ >+ private ListenerList fListeners = new ListenerList(); >+ >+ public DataCache(BugzillaProvider provider) { >+ fProvider = provider; >+ >+ fReports= Collections.synchronizedMap(new HashMap()); >+ fAttachments= Collections.synchronizedMap(new HashMap()); >+ fQueries= Collections.synchronizedMap(new HashMap()); >+ >+ fReportErrors= Collections.synchronizedSet(new HashSet()); >+ fAttachmentErrors = Collections.synchronizedSet(new HashSet()); >+ fQueryErrors= Collections.synchronizedSet(new HashSet()); >+ >+ /* TODO: jpound - cache query options */ >+ queryOptions = new BugzillaQueryOptions(provider.getBaseURL()); >+ } >+ >+ /** >+ * Return the cached report data for the given bug id. >+ * If no data is cached, <code>null</code> is returned. >+ * @param id the bug id >+ * @return the cached ReportData or <code>null</code> >+ */ >+ public ReportData getReport(String id) { >+ return (ReportData)fReports.get(id); >+ } >+ >+ /** >+ * Return the cached attachment for the given id. >+ * If no attachment is cached, <code>null</code> is returned. >+ * @param desc the attachment id >+ * @return the cached attachment or <code>null</code> >+ */ >+ public AttachmentData getAttachment(AttachmentDescription desc) { >+ return (AttachmentData)fAttachments.get(desc); >+ } >+ >+ public void refreshReports(String[] reportIds, IProgressMonitor monitor) throws BugzillaException { >+ List errors = new ArrayList(); >+ for (int i = 0; i < reportIds.length; i++) { >+ String id = reportIds[i]; >+ try { >+ ReportData data = fProvider.getOperations().getReportData(monitor, id); >+ add(data); >+ fReportErrors.remove(id); >+ } catch (BugzillaException e) { >+ errors.add(e); >+ fReportErrors.add(id); >+ } >+ } >+ fireReportDataChanged(reportIds); >+ handleErrors(errors); >+ } >+ >+ private void handleErrors(List errors) throws BugzillaException { >+ if (errors.size() == 1) { >+ throw (BugzillaException)errors.get(0); >+ } else if (!errors.isEmpty()) { >+ MultiStatus status = new MultiStatus(BugzillaPlugin.ID, 0, "Errors occured during refresh", null); >+ for (Iterator iter = errors.iterator(); iter.hasNext();) { >+ BugsException e = (BugsException) iter.next(); >+ status.add(e.getStatus()); >+ throw new BugzillaException(status); >+ } >+ } >+ >+ } >+ >+ public void refreshAttachments(AttachmentDescription[] descs, IProgressMonitor monitor) throws BugzillaException { >+ List errors = new ArrayList(); >+ for (int i = 0; i < descs.length; i++) { >+ AttachmentDescription desc = descs[i]; >+ try { >+ AttachmentData data = fProvider.getOperations().getAttachment(monitor, desc); >+ add(desc, data); >+ fAttachmentErrors.remove(desc); >+ } catch (BugzillaException e) { >+ errors.add(e); >+ fAttachmentErrors.add(desc); >+ } >+ } >+ fireAttachmentDataChanged(descs); >+ handleErrors(errors); >+ } >+ >+ private void add(AttachmentDescription desc, AttachmentData data) { >+ fAttachments.put(desc, data); >+ } >+ >+ private void fireAttachmentDataChanged(final AttachmentDescription[] descs) { >+ Object[] allListeners = fListeners.getListeners(); >+ for (int i = 0; i < allListeners.length; i++) { >+ final IBugRefreshListener listener = (IBugRefreshListener)allListeners[i]; >+ Platform.run(new ISafeRunnable() { >+ public void handleException(Throwable exception) { >+ } >+ public void run() throws Exception { >+ listener.attachmentsChanged(fProvider, descs); >+ } >+ }); >+ } >+ } >+ >+ private void fireReportDataChanged(final String[] reportIds) { >+ Object[] allListeners = fListeners.getListeners(); >+ for (int i = 0; i < allListeners.length; i++) { >+ final IBugRefreshListener listener = (IBugRefreshListener)allListeners[i]; >+ Platform.run(new ISafeRunnable() { >+ public void handleException(Throwable exception) { >+ // Logged by Core >+ } >+ public void run() throws Exception { >+ listener.reportDataChange(fProvider, reportIds); >+ } >+ }); >+ } >+ } >+ >+ private void add(ReportData data) { >+ fReports.put(data.getString(ReportData.ID), data); >+ } >+ >+ public void addRefreshListener(IBugRefreshListener listener) { >+ fListeners.add(listener); >+ } >+ >+ public void removeRefreshListener(IBugRefreshListener listener) { >+ fListeners.remove(listener); >+ } >+ >+ /** >+ * @param datas >+ * @param monitor >+ */ >+ public void refreshQuery(QueryURL[] datas, IProgressMonitor monitor) throws BugzillaException { >+ List errors = new ArrayList(); >+ for (int i = 0; i < datas.length; i++) { >+ QueryURL url = datas[i]; >+ try { >+ QueryData data = fProvider.getOperations().getQueryData(monitor, url); >+ if (data == null) { >+ return; >+ } >+ add(url, data); >+ fQueryErrors.remove(url); >+ } catch (BugzillaException e) { >+ errors.add(e); >+ fQueryErrors.add(url); >+ } >+ } >+ fireQueryChanged(datas); >+ handleErrors(errors); >+ } >+ >+ private void fireQueryChanged(final QueryURL[] datas) { >+ Object[] allListeners = fListeners.getListeners(); >+ for (int i = 0; i < allListeners.length; i++) { >+ final IBugRefreshListener listener = (IBugRefreshListener)allListeners[i]; >+ Platform.run(new ISafeRunnable() { >+ public void handleException(Throwable exception) { >+ // Logged by Core >+ } >+ public void run() throws Exception { >+ listener.queryChange(fProvider, datas); >+ } >+ }); >+ } >+ } >+ >+ private void add(QueryURL url, QueryData data) { >+ fQueries.put(url, data); >+ ReportData[] datas = data.getReportDatas(); >+ for (int i = 0; i < datas.length; i++) { >+ ReportData report = datas[i]; >+ if (getReport(report.getString(ReportData.ID)) == null) { >+ add(report); >+ } >+ } >+ } >+ >+ public QueryData getQueryData(QueryURL queryUrl) { >+ return (QueryData)fQueries.get(queryUrl); >+ } >+ >+ public boolean hadErrorsForReport(String id) { >+ return fReportErrors.contains(id); >+ } >+ >+ public boolean hadErrorsForQuery(QueryURL url) { >+ return fQueryErrors.contains(url); >+ } >+ >+ public boolean hadErrorsForAttachment(AttachmentDescription desc) { >+ return fAttachmentErrors.contains(desc); >+ } >+ >+ /** >+ * >+ * @return The query options for this bugzilla database. >+ */ >+ public BugzillaQueryOptions getQueryOptions() { >+ return queryOptions; >+ } >+ >+ /** >+ * >+ */ >+ public void refreshQueryOptions() { >+ try { >+ new RefreshOperation(null, new IRemoteModel[] { getQueryOptions() }).run(); >+ } catch (InvocationTargetException e) { >+ System.err.println("InvocationTargetException"); >+ //handleError(e); >+ } catch (InterruptedException e) { >+ System.err.println("InterruptedException"); >+ // Ignore >+ } >+ } >+} >Index: src/org/eclipse/team/bugzilla/datatypes/QueryURL.java >=================================================================== >RCS file: /cvs/eclipse/bugzilla/org.eclipse.team.bugzilla/src/org/eclipse/team/bugzilla/datatypes/QueryURL.java,v >retrieving revision 1.3 >diff -u -r1.3 QueryURL.java >--- src/org/eclipse/team/bugzilla/datatypes/QueryURL.java 19 Jan 2005 21:04:29 -0000 1.3 >+++ src/org/eclipse/team/bugzilla/datatypes/QueryURL.java 31 May 2005 20:25:41 -0000 >@@ -1,207 +1,204 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2004 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Common Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/cpl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.team.bugzilla.datatypes; >- >-import java.io.UnsupportedEncodingException; >-import java.net.URLDecoder; >-import java.net.URLEncoder; >-import java.util.Iterator; >-import java.util.LinkedList; >-import java.util.List; >-import java.util.Set; >- >-import org.eclipse.team.bugzilla.Util; >- >- >-/** >- * Wrapper for a bugzilla query URL >- */ >-public class QueryURL extends BugzillaTransactionURL { >- >- public QueryURL(String baseUrl) { >- super(baseUrl); >- >- script = "buglist.cgi?"; >- >- // initiallize default parameter settings >- addTransactionParam("format", "rdf"); >- addTransactionParam("search", "Search"); >- } >- >- >- /* (non-Javadoc) >- * @see java.lang.Object#equals(java.lang.Object) >- */ >- public boolean equals(Object obj) { >- if (obj instanceof QueryURL) { >- return toUrlString().equals(((QueryURL)obj).toUrlString()); >- } >- return super.equals(obj); >- } >- >- /* (non-Javadoc) >- * @see java.lang.Object#hashCode() >- */ >- public int hashCode() { >- return toUrlString().hashCode(); >- } >- >- // generate the query string (.cgi) from the parameter set >- protected String generateTransactionString() { >- >- if (url.equals("")) { >- System.err.println("BugzillaAction: No URL defined for action"); >- return url; >- } >- /* A QueryURL object is being created from an already existing query url */ >- int index; >- if ( (index = url.indexOf(script)) >= 0) { >- transUrl = url; >- if (transUrl.endsWith("/")) { >- transUrl = transUrl.substring(0, transUrl.lastIndexOf("/")); >- } >- url = url.substring(0, index); >- return transUrl; >- } >- >- transUrl = url + script; >- Iterator fieldIter = ((Set)params.keySet()).iterator(); >- >- try { >- while (fieldIter.hasNext()) { >- String field = (String)fieldIter.next(); >- Iterator paramIter = ((List)params.get(field)).iterator(); >- >- while(paramIter.hasNext()) { >- String value = URLEncoder.encode((String)paramIter.next(), "UTF-8"); >- transUrl += "&" + field + "=" + value; >- } >- } >- } catch (UnsupportedEncodingException e) { >- e.printStackTrace(); >- } >- >- return transUrl; >- } >- >- // add the specified 'param' to the list mapped to by 'field' >- public void addTransactionParam(String field, String param) { >- if (param == null) { >- return; >- } >- >- List parameters = (List)params.get(field); >- >- if(parameters == null) { >- parameters = new LinkedList(); >- params.put(field, parameters); >- } >- >- parameters.add(param.trim()); >- } >- >- // set param fields. These fields can map to ONLY 1 value. >- public void setFormatType(String type) { >- params.put("format", null); // clear any previous value >- addTransactionParam("format", type); // set the new value (only one value allowed for this type) >- } >- >- public void setSearchType(String type) { >- params.put("search", null); // clear any previous value >- addTransactionParam("search", type); // set the new value (only one value allowed for this type) >- } >- >- public void setShorDescType(String type) { >- params.put("short_desc_type", null); // clear any previous value >- addTransactionParam("short_desc_type", type); // set the new value (only one value allowed for this type) >- } >- >- public void setLongDescType(String type) { >- params.put("long_desc_type", null); // clear any previous value >- addTransactionParam("long_desc_type", type); // set the new value (only one value allowed for this type) >- } >- >- public String getFormatType() { >- return (String)((List)params.get("format")).get(0); >- } >- >- /** >- * @return >- */ >- public String toUrlString() { >- return (transUrl.equals("")) ? generateTransactionString() : transUrl; >- } >- >- /** >- * Return the url that will execute the query and return XML >- * @param configuration the configuration which identifies the bugzilla server >- * @return the URL that executes this query >- */ >- public final String getUrl(BugzillaConfiguration configuration) { >- return getUrlString(configuration); >- } >- >- /** >- * Build the string that is the URL to perform the query >- * @param configuration the configuration which identifies the bugzilla server >- * @return a String that is a valid URL >- */ >- protected String getUrlString(BugzillaConfiguration configuration) { >- String urlString = Util.appendPath(configuration.getBaseURL(), toUrlString()); >- return urlString; >- } >- >- /** >- * Returns the base url of the bugzilla database >- * @return The base url of the bugzilla database >- */ >- public String getBaseUrl() { >- return url; >- } >- >- /** >- * Return whether the query is a named query which requires >- * a login. >- * @return whether the query is a named query >- */ >- public boolean isNamedQuery() { >- return transUrl.indexOf("cmdtype=runnamed") != -1; >- } >- >- /** >- * @return >- */ >- public String getLoginCookie() { >- // TODO Auto-generated method stub >- return null; >- } >- >- /** >- * Return an appropriate name for the query >- * @return an appropriate name for the query >- */ >- public String getName() { >- if (isNamedQuery()) { >- String key = "namedcmd="; //$NON-NLS-1$ >- int start = transUrl.indexOf(key); >- if (start != -1) { >- start += key.length(); >- } >- String name = transUrl.substring(start); >- try { >- return URLDecoder.decode(name, "UTF-8"); //$NON-NLS-1$ >- } catch (UnsupportedEncodingException e) { >- // Ignore >- } >- } >- return transUrl; >- } >-} >+/******************************************************************************* >+ * Copyright (c) 2000, 2004 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.team.bugzilla.datatypes; >+ >+import java.io.UnsupportedEncodingException; >+import java.net.URLDecoder; >+import java.net.URLEncoder; >+import java.util.Iterator; >+import java.util.LinkedList; >+import java.util.List; >+import java.util.Set; >+ >+import org.eclipse.team.bugzilla.Util; >+ >+ >+/** >+ * Wrapper for a bugzilla query URL >+ */ >+public class QueryURL extends BugzillaTransactionURL { >+ >+ public QueryURL(String baseUrl) { >+ super(baseUrl); >+ >+ script = "buglist.cgi?"; >+ >+ // initiallize default parameter settings >+ addTransactionParam("format", "rdf"); >+ addTransactionParam("search", "Search"); >+ } >+ >+ >+ /* (non-Javadoc) >+ * @see java.lang.Object#equals(java.lang.Object) >+ */ >+ public boolean equals(Object obj) { >+ if (obj instanceof QueryURL) { >+ return toUrlString().equals(((QueryURL)obj).toUrlString()); >+ } >+ return super.equals(obj); >+ } >+ >+ /* (non-Javadoc) >+ * @see java.lang.Object#hashCode() >+ */ >+ public int hashCode() { >+ return toUrlString().hashCode(); >+ } >+ >+ // generate the query string (.cgi) from the parameter set >+ protected String generateTransactionString() { >+ >+ if (url.equals("")) { >+ System.err.println("BugzillaAction: No URL defined for action"); >+ return url; >+ } >+ /* A QueryURL object is being created from an already existing query url */ >+ int index; >+ if ( (index = url.indexOf(script)) >= 0) { >+ transUrl = url; >+ if (transUrl.endsWith("/")) { >+ transUrl = transUrl.substring(0, transUrl.lastIndexOf("/")); >+ } >+ url = url.substring(0, index); >+ return transUrl; >+ } >+ >+ transUrl = url + script; >+ Iterator fieldIter = ((Set)params.keySet()).iterator(); >+ >+ try { >+ while (fieldIter.hasNext()) { >+ String field = (String)fieldIter.next(); >+ Iterator paramIter = ((List)params.get(field)).iterator(); >+ >+ while(paramIter.hasNext()) { >+ String value = URLEncoder.encode((String)paramIter.next(), "UTF-8"); >+ transUrl += "&" + field + "=" + value; >+ } >+ } >+ } catch (UnsupportedEncodingException e) { >+ e.printStackTrace(); >+ } >+ >+ return transUrl; >+ } >+ >+ // add the specified 'param' to the list mapped to by 'field' >+ public void addTransactionParam(String field, String param) { >+ if (param == null) { >+ return; >+ } >+ >+ List parameters = (List)params.get(field); >+ >+ if(parameters == null) { >+ parameters = new LinkedList(); >+ params.put(field, parameters); >+ } >+ >+ parameters.add(param.trim()); >+ } >+ >+ // set param fields. These fields can map to ONLY 1 value. >+ public void setFormatType(String type) { >+ params.put("format", null); // clear any previous value >+ addTransactionParam("format", type); // set the new value (only one value allowed for this type) >+ } >+ >+ public void setSearchType(String type) { >+ params.put("search", null); // clear any previous value >+ addTransactionParam("search", type); // set the new value (only one value allowed for this type) >+ } >+ >+ public void setShorDescType(String type) { >+ params.put("short_desc_type", null); // clear any previous value >+ addTransactionParam("short_desc_type", type); // set the new value (only one value allowed for this type) >+ } >+ >+ public void setLongDescType(String type) { >+ params.put("long_desc_type", null); // clear any previous value >+ addTransactionParam("long_desc_type", type); // set the new value (only one value allowed for this type) >+ } >+ >+ public String getFormatType() { >+ return (String)((List)params.get("format")).get(0); >+ } >+ >+ public String toUrlString() { >+ return (transUrl.equals("")) ? generateTransactionString() : transUrl; >+ } >+ >+ /** >+ * Return the url that will execute the query and return XML >+ * @param configuration the configuration which identifies the bugzilla server >+ * @return the URL that executes this query >+ */ >+ public final String getUrl(BugzillaConfiguration configuration) { >+ return getUrlString(configuration); >+ } >+ >+ /** >+ * Build the string that is the URL to perform the query >+ * @param configuration the configuration which identifies the bugzilla server >+ * @return a String that is a valid URL >+ */ >+ protected String getUrlString(BugzillaConfiguration configuration) { >+ String urlString = Util.appendPath(configuration.getBaseURL(), toUrlString()); >+ return urlString; >+ } >+ >+ /** >+ * Returns the base url of the bugzilla database >+ * @return The base url of the bugzilla database >+ */ >+ public String getBaseUrl() { >+ return url; >+ } >+ >+ /** >+ * Return whether the query is a named query which requires >+ * a login. >+ * @return whether the query is a named query >+ */ >+ public boolean isNamedQuery() { >+ return transUrl.indexOf("cmdtype=runnamed") != -1; >+ } >+ >+ /** >+ * @return login cookie >+ */ >+ public String getLoginCookie() { >+ // TODO Auto-generated method stub >+ return null; >+ } >+ >+ /** >+ * Return an appropriate name for the query >+ * @return an appropriate name for the query >+ */ >+ public String getName() { >+ if (isNamedQuery()) { >+ String key = "namedcmd="; //$NON-NLS-1$ >+ int start = transUrl.indexOf(key); >+ if (start != -1) { >+ start += key.length(); >+ } >+ String name = transUrl.substring(start); >+ try { >+ return URLDecoder.decode(name, "UTF-8"); //$NON-NLS-1$ >+ } catch (UnsupportedEncodingException e) { >+ // Ignore >+ } >+ } >+ return transUrl; >+ } >+} >Index: src/org/eclipse/team/bugzilla/dialogs/AddQueryDialog.java >=================================================================== >RCS file: /cvs/eclipse/bugzilla/org.eclipse.team.bugzilla/src/org/eclipse/team/bugzilla/dialogs/AddQueryDialog.java,v >retrieving revision 1.20 >diff -u -r1.20 AddQueryDialog.java >--- src/org/eclipse/team/bugzilla/dialogs/AddQueryDialog.java 17 May 2005 20:11:46 -0000 1.20 >+++ src/org/eclipse/team/bugzilla/dialogs/AddQueryDialog.java 31 May 2005 20:25:41 -0000 >@@ -801,8 +801,7 @@ > } > > /** >- * @param searchGroup >- * @return >+ * @param group > */ > private Combo createSearchTypeCombo(Composite group) { > Combo combo = new Combo(group, SWT.READ_ONLY); >@@ -839,9 +838,7 @@ > } > > /** >- * > * @param group >- * @return > */ > private List createList(Composite group) { > GridData smallVertData = new GridData(SWT.FILL, SWT.FILL, true, true); >Index: src/org/eclipse/team/bugzilla/model/BugzillaContainer.java >=================================================================== >RCS file: /cvs/eclipse/bugzilla/org.eclipse.team.bugzilla/src/org/eclipse/team/bugzilla/model/BugzillaContainer.java,v >retrieving revision 1.1 >diff -u -r1.1 BugzillaContainer.java >--- src/org/eclipse/team/bugzilla/model/BugzillaContainer.java 10 Jan 2005 17:08:28 -0000 1.1 >+++ src/org/eclipse/team/bugzilla/model/BugzillaContainer.java 31 May 2005 20:25:41 -0000 >@@ -1,169 +1,169 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2004 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Common Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/cpl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.team.bugzilla.model; >- >-import java.util.ArrayList; >-import java.util.Iterator; >-import java.util.LinkedHashMap; >-import java.util.List; >-import java.util.Map; >- >-import org.eclipse.team.bugzilla.BugzillaException; >- >-/** >- * A generic model element container >- */ >-public abstract class BugzillaContainer extends BugzillaModel { >- >- private Map fChildren; >- >- public BugzillaContainer() { >- super(); >- fChildren= new LinkedHashMap(); >- } >- >- public BugzillaModel[] getChildren() { >- return (BugzillaModel[]) fChildren.values().toArray(new BugzillaModel[fChildren.size()]); >- } >- >- /** >- * Add a child to this container and set the child's path correctly. If this >- * container already contains a child with the same ID, the existing child >- * is removed and replaced by the new one. This method assumes that >- * <code>isReadOnly()</code> has been checked before, if applicable, and >- * thus inserts new children regardless of this property. A <code>childAdded</code> event >- * is fired after the child has been inserted. >- * >- * @param child The child to be added. >- */ >- public void addChildren(BugzillaModel [] children) { >- >- if (children.length == 0) >- return; >- >- final List existing= new ArrayList(); >- for (int i = 0; i < children.length; i++) { >- final BugzillaModel child= children[i]; >- if (contains(child)) { >- existing.add(fChildren.get(child.getID())); >- } >- } >- removeChildren((BugzillaModel [])existing.toArray(new BugzillaModel [existing.size()])); >- >- for (int i = 0; i < children.length; i++) { >- final BugzillaModel child= children[i]; >- child.setParent(this); >- fChildren.put(child.getID(), child); >- } >- fireChildrenAdded(children); >- } >- >- public boolean contains(String id) { >- return fChildren.containsKey(id); >- } >- >- public boolean contains(BugzillaModel child) { >- return contains(child.getID()) && getChild(child.getID()) == child; >- } >- >- /** >- * Remove a child from this container. The child's parent is set to null >- * and a <code>childRemoved</code> event is fired. >- * @param child The child to be removed. >- */ >- public void removeChildren(BugzillaModel [] children) { >- >- if (children.length == 0) >- return; >- >- final List removed= new ArrayList(); >- for (int i = 0; i < children.length; i++) { >- final BugzillaModel child = children[i]; >- if (!contains(child)) >- continue; >- fChildren.remove(child.getID()); >- child.setParent(null); >- removed.add(child); >- } >- fireChildrenRemoved((BugzillaModel [])removed.toArray(new BugzillaModel [removed.size()])); >- } >- >- public void setRefreshing(boolean refreshing) { >- if (isRefreshing() == refreshing) >- return; >- super.setRefreshing(refreshing); >- setChildrenRefreshing(refreshing); >- } >- >- /** >- * @param refreshing >- */ >- protected void setChildrenRefreshing(boolean refreshing) { >- for (final Iterator iter = fChildren.values().iterator(); iter.hasNext();) { >- ((BugzillaModel)iter.next()).setRefreshing(refreshing); >- } >- } >- >- public boolean hasParent(Object candiate) { >- >- final BugzillaContainer parent= (BugzillaContainer)getParent(); >- if (parent == null) >- return false; >- >- return this == candiate || parent.hasParent(candiate); >- } >- >- public void accept(IBugzillaModelVisitor visitor) throws BugzillaException { >- if (visitor.visit(this)) { >- BugzillaModel[] children = getChildren(); >- for (int i = 0; i < children.length; i++) { >- BugzillaModel model = children[i]; >- model.accept(visitor); >- } >- } >- } >- >- /** >- * Get the name of the container as it would appear in any lists or trees. >- * This name is used to ensure a unique name within a parent container. >- * @return the name of the container >- */ >- public abstract String getName(); >- >- /** >- * Return the child with the given id or <code>null</code> >- * if one does not exist. >- * @param id the id of a child >- * @return the child with the given id or <code>null</code> >- */ >- public BugzillaModel getChild(String id) { >- return (BugzillaModel)fChildren.get(id); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.team.bugzilla.model.BugzillaModel#resetPath() >- */ >- protected void resetPath() { >- super.resetPath(); >- for (Iterator iter = fChildren.values().iterator(); iter.hasNext();) { >- final BugzillaModel child = (BugzillaModel) iter.next(); >- child.resetPath(); >- } >- } >- >- /** >- * This method indicates whether a user should be able to add or delete any children >- * of this container. >- * @return True if a user can modify the children, false otherwise. >- */ >- public abstract boolean canModifyChildren(); >-} >+/******************************************************************************* >+ * Copyright (c) 2000, 2004 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.team.bugzilla.model; >+ >+import java.util.ArrayList; >+import java.util.Iterator; >+import java.util.LinkedHashMap; >+import java.util.List; >+import java.util.Map; >+ >+import org.eclipse.team.bugzilla.BugzillaException; >+ >+/** >+ * A generic model element container >+ */ >+public abstract class BugzillaContainer extends BugzillaModel { >+ >+ private Map fChildren; >+ >+ public BugzillaContainer() { >+ super(); >+ fChildren= new LinkedHashMap(); >+ } >+ >+ public BugzillaModel[] getChildren() { >+ return (BugzillaModel[]) fChildren.values().toArray(new BugzillaModel[fChildren.size()]); >+ } >+ >+ /** >+ * Add a child to this container and set the child's path correctly. If this >+ * container already contains a child with the same ID, the existing child >+ * is removed and replaced by the new one. This method assumes that >+ * <code>isReadOnly()</code> has been checked before, if applicable, and >+ * thus inserts new children regardless of this property. A <code>childAdded</code> event >+ * is fired after the child has been inserted. >+ * >+ * @param children The children to be added. >+ */ >+ public void addChildren(BugzillaModel [] children) { >+ >+ if (children.length == 0) >+ return; >+ >+ final List existing= new ArrayList(); >+ for (int i = 0; i < children.length; i++) { >+ final BugzillaModel child= children[i]; >+ if (contains(child)) { >+ existing.add(fChildren.get(child.getID())); >+ } >+ } >+ removeChildren((BugzillaModel [])existing.toArray(new BugzillaModel [existing.size()])); >+ >+ for (int i = 0; i < children.length; i++) { >+ final BugzillaModel child= children[i]; >+ child.setParent(this); >+ fChildren.put(child.getID(), child); >+ } >+ fireChildrenAdded(children); >+ } >+ >+ public boolean contains(String id) { >+ return fChildren.containsKey(id); >+ } >+ >+ public boolean contains(BugzillaModel child) { >+ return contains(child.getID()) && getChild(child.getID()) == child; >+ } >+ >+ /** >+ * Remove a child from this container. The child's parent is set to null >+ * and a <code>childRemoved</code> event is fired. >+ * @param children The childrem to be removed. >+ */ >+ public void removeChildren(BugzillaModel [] children) { >+ >+ if (children.length == 0) >+ return; >+ >+ final List removed= new ArrayList(); >+ for (int i = 0; i < children.length; i++) { >+ final BugzillaModel child = children[i]; >+ if (!contains(child)) >+ continue; >+ fChildren.remove(child.getID()); >+ child.setParent(null); >+ removed.add(child); >+ } >+ fireChildrenRemoved((BugzillaModel [])removed.toArray(new BugzillaModel [removed.size()])); >+ } >+ >+ public void setRefreshing(boolean refreshing) { >+ if (isRefreshing() == refreshing) >+ return; >+ super.setRefreshing(refreshing); >+ setChildrenRefreshing(refreshing); >+ } >+ >+ /** >+ * @param refreshing >+ */ >+ protected void setChildrenRefreshing(boolean refreshing) { >+ for (final Iterator iter = fChildren.values().iterator(); iter.hasNext();) { >+ ((BugzillaModel)iter.next()).setRefreshing(refreshing); >+ } >+ } >+ >+ public boolean hasParent(Object candiate) { >+ >+ final BugzillaContainer parent= (BugzillaContainer)getParent(); >+ if (parent == null) >+ return false; >+ >+ return this == candiate || parent.hasParent(candiate); >+ } >+ >+ public void accept(IBugzillaModelVisitor visitor) throws BugzillaException { >+ if (visitor.visit(this)) { >+ BugzillaModel[] children = getChildren(); >+ for (int i = 0; i < children.length; i++) { >+ BugzillaModel model = children[i]; >+ model.accept(visitor); >+ } >+ } >+ } >+ >+ /** >+ * Get the name of the container as it would appear in any lists or trees. >+ * This name is used to ensure a unique name within a parent container. >+ * @return the name of the container >+ */ >+ public abstract String getName(); >+ >+ /** >+ * Return the child with the given id or <code>null</code> >+ * if one does not exist. >+ * @param id the id of a child >+ * @return the child with the given id or <code>null</code> >+ */ >+ public BugzillaModel getChild(String id) { >+ return (BugzillaModel)fChildren.get(id); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.team.bugzilla.model.BugzillaModel#resetPath() >+ */ >+ protected void resetPath() { >+ super.resetPath(); >+ for (Iterator iter = fChildren.values().iterator(); iter.hasNext();) { >+ final BugzillaModel child = (BugzillaModel) iter.next(); >+ child.resetPath(); >+ } >+ } >+ >+ /** >+ * This method indicates whether a user should be able to add or delete any children >+ * of this container. >+ * @return True if a user can modify the children, false otherwise. >+ */ >+ public abstract boolean canModifyChildren(); >+} >Index: src/org/eclipse/team/bugzilla/model/BugzillaQueryOptions.java >=================================================================== >RCS file: /cvs/eclipse/bugzilla/org.eclipse.team.bugzilla/src/org/eclipse/team/bugzilla/model/BugzillaQueryOptions.java,v >retrieving revision 1.9 >diff -u -r1.9 BugzillaQueryOptions.java >--- src/org/eclipse/team/bugzilla/model/BugzillaQueryOptions.java 17 May 2005 20:11:46 -0000 1.9 >+++ src/org/eclipse/team/bugzilla/model/BugzillaQueryOptions.java 31 May 2005 20:25:41 -0000 >@@ -187,11 +187,11 @@ > > private static final String URL_SUFFIX_QUERY = "query.cgi?format=advanced"; > private static final String URL_SUFFIX_KEYWORDS = "describekeywords.cgi?"; >- private BugzillaQueryOptions queryOption; >+ //private BugzillaQueryOptions queryOption; > > public BugzillaQueryOptionParser(BugzillaQueryOptions qo, String queryPage) { > setUrl(queryPage); >- queryOption = qo; >+ //queryOption = qo; > } > > public void setUrl(String queryPage) { >Index: src/org/eclipse/team/bugzilla/model/IRemoteModel.java >=================================================================== >RCS file: /cvs/eclipse/bugzilla/org.eclipse.team.bugzilla/src/org/eclipse/team/bugzilla/model/IRemoteModel.java,v >retrieving revision 1.1 >diff -u -r1.1 IRemoteModel.java >--- src/org/eclipse/team/bugzilla/model/IRemoteModel.java 10 Jan 2005 17:08:28 -0000 1.1 >+++ src/org/eclipse/team/bugzilla/model/IRemoteModel.java 31 May 2005 20:25:41 -0000 >@@ -1,40 +1,39 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2004 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Common Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/cpl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.team.bugzilla.model; >- >-import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.team.bugs.model.IGenericModel; >-import org.eclipse.team.bugzilla.BugzillaException; >- >- >-/** >- * An interface for elements which have remote content. >- */ >-public interface IRemoteModel extends IGenericModel { >- >- /** >- * Re-fetch data from the BTS. >- * >- * @param monitor a progress monitor >- */ >- public void refresh(IProgressMonitor monitor) throws BugzillaException; >- >- /** >- * Update this element with the new data. >- * @param state the new data >- */ >- public void update(); >- >- >- public boolean needsRefresh(); >- >-} >+/******************************************************************************* >+ * Copyright (c) 2000, 2004 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.team.bugzilla.model; >+ >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.team.bugs.model.IGenericModel; >+import org.eclipse.team.bugzilla.BugzillaException; >+ >+ >+/** >+ * An interface for elements which have remote content. >+ */ >+public interface IRemoteModel extends IGenericModel { >+ >+ /** >+ * Re-fetch data from the BTS. >+ * >+ * @param monitor a progress monitor >+ */ >+ public void refresh(IProgressMonitor monitor) throws BugzillaException; >+ >+ /** >+ * Update this element with the new data. >+ */ >+ public void update(); >+ >+ >+ public boolean needsRefresh(); >+ >+} >Index: src/org/eclipse/team/bugzilla/operations/BugzillaOperations.java >=================================================================== >RCS file: /cvs/eclipse/bugzilla/org.eclipse.team.bugzilla/src/org/eclipse/team/bugzilla/operations/BugzillaOperations.java,v >retrieving revision 1.12 >diff -u -r1.12 BugzillaOperations.java >--- src/org/eclipse/team/bugzilla/operations/BugzillaOperations.java 18 May 2005 17:51:21 -0000 1.12 >+++ src/org/eclipse/team/bugzilla/operations/BugzillaOperations.java 31 May 2005 20:25:41 -0000 >@@ -1,162 +1,161 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2003 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Common Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/cpl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.team.bugzilla.operations; >- >-import java.io.BufferedReader; >-import java.io.IOException; >-import java.io.InputStream; >-import java.io.InputStreamReader; >-import java.net.MalformedURLException; >-import java.net.URL; >-import java.net.URLConnection; >-import java.util.regex.Matcher; >-import java.util.regex.Pattern; >- >-import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.jface.resource.ImageDescriptor; >-import org.eclipse.team.bugzilla.BugzillaException; >-import org.eclipse.team.bugzilla.BugzillaFactory; >-import org.eclipse.team.bugzilla.datatypes.AttachmentData; >-import org.eclipse.team.bugzilla.datatypes.AttachmentDescription; >-import org.eclipse.team.bugzilla.datatypes.BugzillaConfiguration; >-import org.eclipse.team.bugzilla.datatypes.QueryData; >-import org.eclipse.team.bugzilla.datatypes.QueryURL; >-import org.eclipse.team.bugzilla.datatypes.ReportData; >-import org.eclipse.team.bugzilla.xml.Parser; >-import org.eclipse.team.bugzilla.xml.VersionHandler; >- >- >-public abstract class BugzillaOperations { >- >- protected static String bugScript; /* TODO: jpound - part of redirect workaround for gcj */ >- //TODO:private static final String BAD_XML_HEADER = "<?xml version=\"1.0\" ?>"; >- public static BugzillaOperations getOperations(IProgressMonitor monitor, BugzillaConfiguration configuration) throws BugzillaException { >- int version = configuration.getVersion(); >- if (version < 0) { >- version = getVersion(monitor, configuration); >- configuration.setVersion(version); >- } >- return create(version); >- } >- >- public static BugzillaOperations create(int version) { >- switch (version) { >- case BugzillaFactory.VERSION_2_16: >- return new BugzillaOperations_2_16(); >- case BugzillaFactory.VERSION_2_18: >- return new BugzillaOperations_2_18(); >- >- } >- return null; >- } >- >- public static int getVersion(IProgressMonitor monitor, BugzillaConfiguration configuration) throws BugzillaException { >- // find the version by requesting an invalid bug. >- String url = configuration.getBaseURL(); >- if (!url.endsWith("/")) { >- url += "/"; >- } >- try { >- final HTTPConnection connection= new HTTPConnection(url + "xml.cgi?id=1"); >- final String xml= connection.getString(monitor); >- final Parser parser= new Parser(false, false); >- final VersionHandler handler= new VersionHandler(); >- parser.parse(xml, handler); >- bugScript = "xml.cgi?id="; >- return handler.getVersion(); >- } catch (Exception e) { >- /* FIXME: jpound - work around for gcj not handling the xml.cgi redirect in bugilla 2.18 */ >- bugScript = "show_bug.cgi?ctype=xml&id="; >- final HTTPConnection connection= new HTTPConnection(url + bugScript + "1"); >- final String xml= connection.getString(monitor); >- final Parser parser= new Parser(false, false); >- final VersionHandler handler= new VersionHandler(); >- parser.parse(xml, handler); >- return handler.getVersion(); >- } >- } >- >- public static ImageDescriptor getBugzillaIcon(String url) { >- try { >- BufferedReader read = new BufferedReader(new InputStreamReader(new URL(url).openStream())); >- String line; >- String image; >- url = url.endsWith("/") ? url : url + "/"; >- Pattern iconFlag = Pattern.compile(".*rel=\".*icon\".*"); >- >- while ((line = read.readLine()) != null) { >- >- Matcher m = iconFlag.matcher(line); >- if (m.matches()) { >- image = parseUrl(read, line, url); >- read.close(); >- return (image == null) ? null : ImageDescriptor.createFromURL(new URL(image)); >- } >- } >- read.close(); >- /* Attempt to find the default icon */ >- URL base = new URL(url); >- URL iconUrl = new URL(base.getProtocol() + "://" + base.getHost() + "/" + "favicon.ico"); >- >- URLConnection con = iconUrl.openConnection(); >- int len = con.getContentLength(); >- >- if (len <= 0) { >- return null; >- } >- >- >- ImageDescriptor defaultIcon = ImageDescriptor.createFromURL(new URL(iconUrl.toString())); >- >- if (defaultIcon.getImageData() != null) { >- return defaultIcon; >- } >- >- } catch (MalformedURLException e) { >- System.err.println("BugzillaOperations: Malformed URL when fetching icon"); >- } catch (IOException e) { >- System.err.println("BugzillaOperations: IOException exception when fetching icon"); >- } >- return null; >- } >- >- private static String parseUrl(BufferedReader read, String line, String url) throws IOException { >- String hrefFlag = "href=\""; >- int index; >- do { >- if ((index = line.indexOf(hrefFlag)) >= 0) { >- /* keep breaking off begining part of string to get icon url */ >- line = line.substring(index + hrefFlag.length()); >- url += line.substring(0, line.indexOf("\"")); >- >- return url; >- } >- } while ((line = read.readLine()) != null); >- >- return null; >- } >- >- public abstract ReportData getReportData(IProgressMonitor monitor, BugzillaConfiguration configuration, String id) throws BugzillaException; >- >- public abstract QueryData getQueryData(IProgressMonitor monitor, BugzillaConfiguration configuration, QueryURL queryURL) throws BugzillaException; >- >- public abstract AttachmentData getAttachment(IProgressMonitor monitor, BugzillaConfiguration configuration, AttachmentDescription desc) throws BugzillaException; >- >- public abstract String getReportURL(BugzillaConfiguration configuration, String reportID); >- >- public abstract String getCommentURL(BugzillaConfiguration configuration, String reportID, int commentNbr); >- >- public abstract String getAttachmentURL(BugzillaConfiguration configuration, String attachmentID); >- >- public abstract String getReportIDFromURL(BugzillaConfiguration configuration, String url); >- >- public abstract String getQueryURL(BugzillaConfiguration configuration, String url); >+/******************************************************************************* >+ * Copyright (c) 2000, 2003 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.team.bugzilla.operations; >+ >+import java.io.BufferedReader; >+import java.io.IOException; >+import java.io.InputStreamReader; >+import java.net.MalformedURLException; >+import java.net.URL; >+import java.net.URLConnection; >+import java.util.regex.Matcher; >+import java.util.regex.Pattern; >+ >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.team.bugzilla.BugzillaException; >+import org.eclipse.team.bugzilla.BugzillaFactory; >+import org.eclipse.team.bugzilla.datatypes.AttachmentData; >+import org.eclipse.team.bugzilla.datatypes.AttachmentDescription; >+import org.eclipse.team.bugzilla.datatypes.BugzillaConfiguration; >+import org.eclipse.team.bugzilla.datatypes.QueryData; >+import org.eclipse.team.bugzilla.datatypes.QueryURL; >+import org.eclipse.team.bugzilla.datatypes.ReportData; >+import org.eclipse.team.bugzilla.xml.Parser; >+import org.eclipse.team.bugzilla.xml.VersionHandler; >+ >+ >+public abstract class BugzillaOperations { >+ >+ protected static String bugScript; /* TODO: jpound - part of redirect workaround for gcj */ >+ //TODO:private static final String BAD_XML_HEADER = "<?xml version=\"1.0\" ?>"; >+ public static BugzillaOperations getOperations(IProgressMonitor monitor, BugzillaConfiguration configuration) throws BugzillaException { >+ int version = configuration.getVersion(); >+ if (version < 0) { >+ version = getVersion(monitor, configuration); >+ configuration.setVersion(version); >+ } >+ return create(version); >+ } >+ >+ public static BugzillaOperations create(int version) { >+ switch (version) { >+ case BugzillaFactory.VERSION_2_16: >+ return new BugzillaOperations_2_16(); >+ case BugzillaFactory.VERSION_2_18: >+ return new BugzillaOperations_2_18(); >+ >+ } >+ return null; >+ } >+ >+ public static int getVersion(IProgressMonitor monitor, BugzillaConfiguration configuration) throws BugzillaException { >+ // find the version by requesting an invalid bug. >+ String url = configuration.getBaseURL(); >+ if (!url.endsWith("/")) { >+ url += "/"; >+ } >+ try { >+ final HTTPConnection connection= new HTTPConnection(url + "xml.cgi?id=1"); >+ final String xml= connection.getString(monitor); >+ final Parser parser= new Parser(false, false); >+ final VersionHandler handler= new VersionHandler(); >+ parser.parse(xml, handler); >+ bugScript = "xml.cgi?id="; >+ return handler.getVersion(); >+ } catch (Exception e) { >+ /* FIXME: jpound - work around for gcj not handling the xml.cgi redirect in bugilla 2.18 */ >+ bugScript = "show_bug.cgi?ctype=xml&id="; >+ final HTTPConnection connection= new HTTPConnection(url + bugScript + "1"); >+ final String xml= connection.getString(monitor); >+ final Parser parser= new Parser(false, false); >+ final VersionHandler handler= new VersionHandler(); >+ parser.parse(xml, handler); >+ return handler.getVersion(); >+ } >+ } >+ >+ public static ImageDescriptor getBugzillaIcon(String url) { >+ try { >+ BufferedReader read = new BufferedReader(new InputStreamReader(new URL(url).openStream())); >+ String line; >+ String image; >+ url = url.endsWith("/") ? url : url + "/"; >+ Pattern iconFlag = Pattern.compile(".*rel=\".*icon\".*"); >+ >+ while ((line = read.readLine()) != null) { >+ >+ Matcher m = iconFlag.matcher(line); >+ if (m.matches()) { >+ image = parseUrl(read, line, url); >+ read.close(); >+ return (image == null) ? null : ImageDescriptor.createFromURL(new URL(image)); >+ } >+ } >+ read.close(); >+ /* Attempt to find the default icon */ >+ URL base = new URL(url); >+ URL iconUrl = new URL(base.getProtocol() + "://" + base.getHost() + "/" + "favicon.ico"); >+ >+ URLConnection con = iconUrl.openConnection(); >+ int len = con.getContentLength(); >+ >+ if (len <= 0) { >+ return null; >+ } >+ >+ >+ ImageDescriptor defaultIcon = ImageDescriptor.createFromURL(new URL(iconUrl.toString())); >+ >+ if (defaultIcon.getImageData() != null) { >+ return defaultIcon; >+ } >+ >+ } catch (MalformedURLException e) { >+ System.err.println("BugzillaOperations: Malformed URL when fetching icon"); >+ } catch (IOException e) { >+ System.err.println("BugzillaOperations: IOException exception when fetching icon"); >+ } >+ return null; >+ } >+ >+ private static String parseUrl(BufferedReader read, String line, String url) throws IOException { >+ String hrefFlag = "href=\""; >+ int index; >+ do { >+ if ((index = line.indexOf(hrefFlag)) >= 0) { >+ /* keep breaking off begining part of string to get icon url */ >+ line = line.substring(index + hrefFlag.length()); >+ url += line.substring(0, line.indexOf("\"")); >+ >+ return url; >+ } >+ } while ((line = read.readLine()) != null); >+ >+ return null; >+ } >+ >+ public abstract ReportData getReportData(IProgressMonitor monitor, BugzillaConfiguration configuration, String id) throws BugzillaException; >+ >+ public abstract QueryData getQueryData(IProgressMonitor monitor, BugzillaConfiguration configuration, QueryURL queryURL) throws BugzillaException; >+ >+ public abstract AttachmentData getAttachment(IProgressMonitor monitor, BugzillaConfiguration configuration, AttachmentDescription desc) throws BugzillaException; >+ >+ public abstract String getReportURL(BugzillaConfiguration configuration, String reportID); >+ >+ public abstract String getCommentURL(BugzillaConfiguration configuration, String reportID, int commentNbr); >+ >+ public abstract String getAttachmentURL(BugzillaConfiguration configuration, String attachmentID); >+ >+ public abstract String getReportIDFromURL(BugzillaConfiguration configuration, String url); >+ >+ public abstract String getQueryURL(BugzillaConfiguration configuration, String url); > } >\ No newline at end of file >Index: src/org/eclipse/team/bugzilla/operations/BugzillaOperations_2_16.java >=================================================================== >RCS file: /cvs/eclipse/bugzilla/org.eclipse.team.bugzilla/src/org/eclipse/team/bugzilla/operations/BugzillaOperations_2_16.java,v >retrieving revision 1.5 >diff -u -r1.5 BugzillaOperations_2_16.java >--- src/org/eclipse/team/bugzilla/operations/BugzillaOperations_2_16.java 26 Apr 2005 21:22:44 -0000 1.5 >+++ src/org/eclipse/team/bugzilla/operations/BugzillaOperations_2_16.java 31 May 2005 20:25:41 -0000 >@@ -1,213 +1,212 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2004 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Common Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/cpl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.team.bugzilla.operations; >- >-import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.team.bugs.extension.BugsException; >-import org.eclipse.team.bugzilla.BugzillaException; >-import org.eclipse.team.bugzilla.datatypes.AttachmentData; >-import org.eclipse.team.bugzilla.datatypes.AttachmentDescription; >-import org.eclipse.team.bugzilla.datatypes.BugzillaConfiguration; >-import org.eclipse.team.bugzilla.datatypes.QueryData; >-import org.eclipse.team.bugzilla.datatypes.QueryURL; >-import org.eclipse.team.bugzilla.datatypes.ReportData; >-import org.eclipse.team.bugzilla.xml.Parser; >-import org.eclipse.team.bugzilla.xml.QueryHandler; >-import org.eclipse.team.bugzilla.xml.ReportHandler; >-import org.eclipse.team.bugzilla.xml.ReportHandler_2_16; >- >-/** >- * >- */ >-public class BugzillaOperations_2_16 extends BugzillaOperations { >- >- private final static class Reader { >- >- private final String fSource; >- private int fIndex; >- >- public Reader(String source) { >- fSource= source; >- fIndex= 0; >- } >- >- public char read() { >- return fSource.charAt(fIndex++); >- } >- >- public boolean isFinished() { >- return fIndex == fSource.length(); >- } >- >- public void consume(String string) throws BugzillaException { >- if (!fSource.startsWith(string, fIndex)) { >- throw new BugzillaException(BugzillaException.XML_ERROR, "Parse error consuming " + string); >- } >- fIndex += string.length(); >- } >- } >- >- public ReportData getReportData(IProgressMonitor monitor, BugzillaConfiguration configuration, String id) throws BugzillaException { >- >- monitor.subTask("Fetching report data"); >- try { >- String url = configuration.getBaseURL(); >- if (!url.endsWith("/")) { >- url += "/"; >- } >- url += bugScript + id.trim(); //$NON-NLS-1$ >- final HTTPConnection connection= new HTTPConnection(url); >- final String xml= connection.getString(monitor); >- final ReportHandler handler= new ReportHandler_2_16(); >- new Parser(false, false).parse(xml, handler); >- return handler.getReportData(); >- } finally { >- monitor.done(); >- } >- } >- >- public AttachmentData getAttachment(IProgressMonitor monitor, BugzillaConfiguration configuration, AttachmentDescription desc) throws BugzillaException { >- >- monitor.subTask("Fetching attachment data"); >- try { >- final String id= desc.getString(AttachmentDescription.ID).trim(); >- final String url= getAttachmentURL(configuration, id); >- final HTTPConnection connection= new HTTPConnection(url); >- final AttachmentData attachment= new AttachmentData(); >- attachment.data= connection.getBytes(monitor); >- parse(connection.getContentType(), attachment); >- return attachment; >- } finally { >- monitor.done(); >- } >- } >- >- private void parse(String contentType, AttachmentData data) throws BugzillaException { >- >- /** >- * The format we parse is like: >- * text/plain; name="bug36204-1.txt"; charset=ISO-8859-1 >- * or >- * image/jpeg; name="text_editor_bug.jpg" >- * >- */ >- final StringBuffer mimeType= new StringBuffer(); >- final StringBuffer filename= new StringBuffer(); >- final StringBuffer charset= new StringBuffer(); >- >- final Reader reader= new Reader(contentType); >- >- /** >- * Read the MIME type. >- */ >- char ch; >- while ((ch= reader.read()) != ';') { >- mimeType.append(ch); >- } >- >- reader.consume(" name=\""); >- >- /** >- * Read the file name >- */ >- while ((ch= reader.read()) != '"') { >- filename.append(ch); >- } >- >- /** >- * Read the encoding if specified. >- */ >- if (!reader.isFinished()) { >- reader.consume("; charset="); >- >- while (!reader.isFinished()) { >- charset.append(reader.read()); >- } >- } >- data.set(AttachmentData.FILENAME, filename.toString()); >- data.set(AttachmentData.MIMETYPE, mimeType.toString()); >- data.set(AttachmentData.ENCODING, charset.toString()); >- } >- >- public String getReportURL(BugzillaConfiguration configuration, String reportID) { >- return configuration.getBaseURL() + "/show_bug.cgi?id=" + reportID.trim(); >- } >- >- public String getCommentURL(BugzillaConfiguration configuration, String reportID, int commentNbr) { >- return getReportURL(configuration, reportID) + "#c" + commentNbr; >- } >- >- public String getAttachmentURL(BugzillaConfiguration configuration, String attachmentID) { >- return configuration.getBaseURL() + "/attachment.cgi?id=" + attachmentID; //$NON-NLS-1$ >- } >- >- public String getReportIDFromURL(BugzillaConfiguration configuration, String url) { >- if (!url.startsWith(configuration.getBaseURL() + "/show_bug.cgi?id=")) >- return null; >- >- final int hashIndex = url.indexOf("#"); >- final int equalsIndex = url.indexOf("="); >- try { >- if(hashIndex == -1) >- return url.substring(equalsIndex + 1); >- return url.substring(equalsIndex + 1, hashIndex); >- } catch (ArrayIndexOutOfBoundsException e) { >- return null; >- } >- } >- >- >- public String getQueryURL(BugzillaConfiguration configuration, String url) { >- if (!url.startsWith(configuration.getBaseURL() + "/buglist.cgi?")) >- return null; >- >- if (url.indexOf("regetlastlist") != -1) >- return null; >- return url; >- } >- >- /** >- * Fetch the query data for the given query from the server identified by the supplied >- * configuration. This method uses the query handler returned from <code>getQueryHandler</code> >- * to perform the parsing. >- * @param monitor a progress monitor >- * @param configuration the configuration which identified the bugzilla server >- * @param queryURL the query to be fetched >- * @return the data retrieved for the given query >- * @throws BugsException >- */ >- public QueryData getQueryData(IProgressMonitor monitor, BugzillaConfiguration configuration, QueryURL queryURL) throws BugzillaException { >- final QueryHandler handler= new QueryHandler(); >- >- String url= queryURL.getUrl(configuration); //$NON-NLS-1$ >- // catch query data triggered by the browser (non-xml) >- // this also prevents queries from being added to the history >- if (url.indexOf("format=rdf") < 0) { >- return null; >- } >- final String loginCookie = configuration.getLoginCookie(); >- if (queryURL.isNamedQuery() && loginCookie == null) { >- throw new BugzillaException(BugzillaException.REQUIRES_LOGIN, "Please login to Bugzilla."); >- } >- final HTTPConnection connection= new HTTPConnection(url, loginCookie); >- final String xml= connection.getString(monitor); >- if (isLoginFailure(xml)) { >- throw new BugzillaException(BugzillaException.REQUIRES_LOGIN, "Bugzilla user authentication failed."); >- } >- new Parser(false, false).parse(xml, handler); >- return handler.getQueryData(); >- } >- >- public boolean isLoginFailure(String xml) { >- return xml.indexOf("<html>") != -1 && xml.indexOf("Login") != -1; //$NON-NLS-1$ //$NON-NLS-2$ >- } >-} >+/******************************************************************************* >+ * Copyright (c) 2000, 2004 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.team.bugzilla.operations; >+ >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.team.bugzilla.BugzillaException; >+import org.eclipse.team.bugzilla.datatypes.AttachmentData; >+import org.eclipse.team.bugzilla.datatypes.AttachmentDescription; >+import org.eclipse.team.bugzilla.datatypes.BugzillaConfiguration; >+import org.eclipse.team.bugzilla.datatypes.QueryData; >+import org.eclipse.team.bugzilla.datatypes.QueryURL; >+import org.eclipse.team.bugzilla.datatypes.ReportData; >+import org.eclipse.team.bugzilla.xml.Parser; >+import org.eclipse.team.bugzilla.xml.QueryHandler; >+import org.eclipse.team.bugzilla.xml.ReportHandler; >+import org.eclipse.team.bugzilla.xml.ReportHandler_2_16; >+ >+/** >+ * >+ */ >+public class BugzillaOperations_2_16 extends BugzillaOperations { >+ >+ private final static class Reader { >+ >+ private final String fSource; >+ private int fIndex; >+ >+ public Reader(String source) { >+ fSource= source; >+ fIndex= 0; >+ } >+ >+ public char read() { >+ return fSource.charAt(fIndex++); >+ } >+ >+ public boolean isFinished() { >+ return fIndex == fSource.length(); >+ } >+ >+ public void consume(String string) throws BugzillaException { >+ if (!fSource.startsWith(string, fIndex)) { >+ throw new BugzillaException(BugzillaException.XML_ERROR, "Parse error consuming " + string); >+ } >+ fIndex += string.length(); >+ } >+ } >+ >+ public ReportData getReportData(IProgressMonitor monitor, BugzillaConfiguration configuration, String id) throws BugzillaException { >+ >+ monitor.subTask("Fetching report data"); >+ try { >+ String url = configuration.getBaseURL(); >+ if (!url.endsWith("/")) { >+ url += "/"; >+ } >+ url += bugScript + id.trim(); //$NON-NLS-1$ >+ final HTTPConnection connection= new HTTPConnection(url); >+ final String xml= connection.getString(monitor); >+ final ReportHandler handler= new ReportHandler_2_16(); >+ new Parser(false, false).parse(xml, handler); >+ return handler.getReportData(); >+ } finally { >+ monitor.done(); >+ } >+ } >+ >+ public AttachmentData getAttachment(IProgressMonitor monitor, BugzillaConfiguration configuration, AttachmentDescription desc) throws BugzillaException { >+ >+ monitor.subTask("Fetching attachment data"); >+ try { >+ final String id= desc.getString(AttachmentDescription.ID).trim(); >+ final String url= getAttachmentURL(configuration, id); >+ final HTTPConnection connection= new HTTPConnection(url); >+ final AttachmentData attachment= new AttachmentData(); >+ attachment.data= connection.getBytes(monitor); >+ parse(connection.getContentType(), attachment); >+ return attachment; >+ } finally { >+ monitor.done(); >+ } >+ } >+ >+ private void parse(String contentType, AttachmentData data) throws BugzillaException { >+ >+ /** >+ * The format we parse is like: >+ * text/plain; name="bug36204-1.txt"; charset=ISO-8859-1 >+ * or >+ * image/jpeg; name="text_editor_bug.jpg" >+ * >+ */ >+ final StringBuffer mimeType= new StringBuffer(); >+ final StringBuffer filename= new StringBuffer(); >+ final StringBuffer charset= new StringBuffer(); >+ >+ final Reader reader= new Reader(contentType); >+ >+ /** >+ * Read the MIME type. >+ */ >+ char ch; >+ while ((ch= reader.read()) != ';') { >+ mimeType.append(ch); >+ } >+ >+ reader.consume(" name=\""); >+ >+ /** >+ * Read the file name >+ */ >+ while ((ch= reader.read()) != '"') { >+ filename.append(ch); >+ } >+ >+ /** >+ * Read the encoding if specified. >+ */ >+ if (!reader.isFinished()) { >+ reader.consume("; charset="); >+ >+ while (!reader.isFinished()) { >+ charset.append(reader.read()); >+ } >+ } >+ data.set(AttachmentData.FILENAME, filename.toString()); >+ data.set(AttachmentData.MIMETYPE, mimeType.toString()); >+ data.set(AttachmentData.ENCODING, charset.toString()); >+ } >+ >+ public String getReportURL(BugzillaConfiguration configuration, String reportID) { >+ return configuration.getBaseURL() + "/show_bug.cgi?id=" + reportID.trim(); >+ } >+ >+ public String getCommentURL(BugzillaConfiguration configuration, String reportID, int commentNbr) { >+ return getReportURL(configuration, reportID) + "#c" + commentNbr; >+ } >+ >+ public String getAttachmentURL(BugzillaConfiguration configuration, String attachmentID) { >+ return configuration.getBaseURL() + "/attachment.cgi?id=" + attachmentID; //$NON-NLS-1$ >+ } >+ >+ public String getReportIDFromURL(BugzillaConfiguration configuration, String url) { >+ if (!url.startsWith(configuration.getBaseURL() + "/show_bug.cgi?id=")) >+ return null; >+ >+ final int hashIndex = url.indexOf("#"); >+ final int equalsIndex = url.indexOf("="); >+ try { >+ if(hashIndex == -1) >+ return url.substring(equalsIndex + 1); >+ return url.substring(equalsIndex + 1, hashIndex); >+ } catch (ArrayIndexOutOfBoundsException e) { >+ return null; >+ } >+ } >+ >+ >+ public String getQueryURL(BugzillaConfiguration configuration, String url) { >+ if (!url.startsWith(configuration.getBaseURL() + "/buglist.cgi?")) >+ return null; >+ >+ if (url.indexOf("regetlastlist") != -1) >+ return null; >+ return url; >+ } >+ >+ /** >+ * Fetch the query data for the given query from the server identified by the supplied >+ * configuration. This method uses the query handler returned from <code>getQueryHandler</code> >+ * to perform the parsing. >+ * @param monitor a progress monitor >+ * @param configuration the configuration which identified the bugzilla server >+ * @param queryURL the query to be fetched >+ * @return the data retrieved for the given query >+ * @throws BugzillaException >+ */ >+ public QueryData getQueryData(IProgressMonitor monitor, BugzillaConfiguration configuration, QueryURL queryURL) throws BugzillaException { >+ final QueryHandler handler= new QueryHandler(); >+ >+ String url= queryURL.getUrl(configuration); //$NON-NLS-1$ >+ // catch query data triggered by the browser (non-xml) >+ // this also prevents queries from being added to the history >+ if (url.indexOf("format=rdf") < 0) { >+ return null; >+ } >+ final String loginCookie = configuration.getLoginCookie(); >+ if (queryURL.isNamedQuery() && loginCookie == null) { >+ throw new BugzillaException(BugzillaException.REQUIRES_LOGIN, "Please login to Bugzilla."); >+ } >+ final HTTPConnection connection= new HTTPConnection(url, loginCookie); >+ final String xml= connection.getString(monitor); >+ if (isLoginFailure(xml)) { >+ throw new BugzillaException(BugzillaException.REQUIRES_LOGIN, "Bugzilla user authentication failed."); >+ } >+ new Parser(false, false).parse(xml, handler); >+ return handler.getQueryData(); >+ } >+ >+ public boolean isLoginFailure(String xml) { >+ return xml.indexOf("<html>") != -1 && xml.indexOf("Login") != -1; //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+} >Index: src/org/eclipse/team/bugzilla/persistence/PersistenceManager.java >=================================================================== >RCS file: /cvs/eclipse/bugzilla/org.eclipse.team.bugzilla/src/org/eclipse/team/bugzilla/persistence/PersistenceManager.java,v >retrieving revision 1.1 >diff -u -r1.1 PersistenceManager.java >--- src/org/eclipse/team/bugzilla/persistence/PersistenceManager.java 10 Jan 2005 17:08:28 -0000 1.1 >+++ src/org/eclipse/team/bugzilla/persistence/PersistenceManager.java 31 May 2005 20:25:41 -0000 >@@ -1,252 +1,251 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2004 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Common Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/cpl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.team.bugzilla.persistence; >- >-import java.util.ArrayList; >-import java.util.HashMap; >-import java.util.Map; >- >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.core.runtime.preferences.InstanceScope; >-import org.eclipse.team.bugs.extension.BugsException; >-import org.eclipse.team.bugs.model.IBugProvider; >-import org.eclipse.team.bugs.model.IGenericModel; >-import org.eclipse.team.bugs.model.IProviderListener; >-import org.eclipse.team.bugzilla.BugzillaException; >-import org.eclipse.team.bugzilla.BugzillaPlugin; >-import org.eclipse.team.bugzilla.adapters.BugzillaAdapterFactory; >-import org.eclipse.team.bugzilla.model.BugzillaContainer; >-import org.eclipse.team.bugzilla.model.BugzillaFolder; >-import org.eclipse.team.bugzilla.model.BugzillaHistoryFolder; >-import org.eclipse.team.bugzilla.model.BugzillaModel; >-import org.eclipse.team.bugzilla.model.BugzillaProvider; >-import org.eclipse.team.bugzilla.model.BugzillaQuery; >-import org.eclipse.team.bugzilla.model.BugzillaReport; >-import org.osgi.service.prefs.BackingStoreException; >-import org.osgi.service.prefs.Preferences; >- >-/** >- * >- */ >-public class PersistenceManager { >- >- /* >- * The preference node in the instance scope where the providers are persisted >- */ >- private static final String PROVIDER_STORE_ID = "providers"; //$NON-NLS-1$ >- >- protected static final BugzillaModel [] EMPTY_ARRAY= new BugzillaModel[0]; >- >- /** >- * The key for the model type preference. >- */ >- public final static String MODEL_TYPE= "org.eclipse.team.bugzilla.modelType"; //$NON-NLS-1$ >- >- public final static String ELEMENT_ID = "org.eclipse.team.bugzilla.elementId"; //$NON-NLS-1$ >- >- /** >- * IDs for the different persistent model types. >- */ >- public final static String PROVIDER= "provider"; //$NON-NLS-1$ >- public final static String FOLDER= "folder"; //$NON-NLS-1$ >- public final static String HISTORY= "history"; //$NON-NLS-1$ >- public final static String REPORT= "report"; //$NON-NLS-1$ >- public final static String QUERY= "query"; //$NON-NLS-1$ >- >- private final static Map type2classMap; >- >- /* >- * Listener that is registered with each provider to update >- * the store when the model changes >- */ >- private static IProviderListener listener = new IProviderListener() { >- /* (non-Javadoc) >- * @see org.eclipse.team.bugs.model.IProviderListener#modelAdded(org.eclipse.team.bugs.model.IGenericModel, org.eclipse.team.bugs.model.IGenericModel) >- */ >- public void elementsAdded(IGenericModel parent, IGenericModel[] children) { >- elementsChanged(children); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.team.bugs.model.IProviderListener#modelChanged(org.eclipse.team.bugs.model.IGenericModel) >- */ >- public void elementsChanged(IGenericModel[] elements) { >- for (int i = 0; i < elements.length; i++) { >- final BugzillaModel model = (BugzillaModel)elements[i]; >- final IPersistenceAdapter adapter = getPersistenceAdapter(elements[i]); >- if (adapter != null) >- adapter.storeElement(model, false); >- } >- final BugzillaProvider provider= ((BugzillaModel)elements[0]).getBugzillaProvider(); >- try { >- AbstractPersistenceAdapter.getPreferences(provider).flush(); >- } catch (BackingStoreException e) { >- BugzillaPlugin.log(BugzillaException.asBugsException(e)); >- } >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.team.bugs.model.IProviderListener#modelRemoved(org.eclipse.team.bugs.model.IGenericModel, org.eclipse.team.bugs.model.IGenericModel) >- */ >- public void elementsRemoved(IGenericModel parent, IGenericModel[] children) { >- for (int i = 0; i < children.length; i++) { >- final BugzillaModel model = (BugzillaModel)children[i]; >- final IPersistenceAdapter adapter = getPersistenceAdapter(parent); >- if (adapter != null) >- adapter.purgeChild((BugzillaModel)parent, model, false); >- } >- try { >- AbstractPersistenceAdapter.getPreferences(parent).flush(); >- } catch (BackingStoreException e) { >- BugzillaPlugin.log(BugzillaException.asBugsException(e)); >- } >- } >- }; >- >- >- static { >- type2classMap = new HashMap(); >- type2classMap.put(PROVIDER, BugzillaProvider.class); >- type2classMap.put(FOLDER, BugzillaFolder.class); >- type2classMap.put(HISTORY, BugzillaHistoryFolder.class); >- type2classMap.put(REPORT, BugzillaReport.class); >- type2classMap.put(QUERY, BugzillaQuery.class); >- } >- >- /** >- * Return the root preferences node whose children are providers >- * @return the root preferences node whose children are providers >- */ >- /* package */ static Preferences getRootNode() { >- return new InstanceScope().getNode(BugzillaPlugin.ID).node(PROVIDER_STORE_ID); >- } >- >- /** >- * Restore the providers from the preference store and return the restored providers >- * @return the restored providers >- */ >- public static IBugProvider[] restoreProviders() { >- BugzillaModel[] providers = restoreChildren(null /* no parent */, getRootNode()); >- IBugProvider[] result = new IBugProvider[providers.length]; >- System.arraycopy(providers, 0, result, 0, providers.length); >- return result; >- } >- >- /** >- * Return the persistence adapter for the given element >- * or <code>null</code> if there isn't one. >- * @param element the element >- * @return the persistence adapter for the given element >- * or <code>null</code> >- */ >- public static IPersistenceAdapter getPersistenceAdapter(Object element) { >- if (element instanceof IAdaptable) { >- Object adapter = ((IAdaptable)element).getAdapter(IPersistenceAdapter.class); >- if (adapter instanceof IPersistenceAdapter) >- return (IPersistenceAdapter)adapter; >- } >- return null; >- } >- >- /* >- * Method used by persistence adapters to restore a bugzilla model >- */ >- /* package */ static BugzillaModel restoreChild(BugzillaContainer parent, Preferences node) { >- final String type= node.get(MODEL_TYPE, ""); //$NON-NLS-1$ >- final String id = node.get(ELEMENT_ID, ""); //$NON-NLS-1$ >- IPersistenceAdapter adapter = getPersistenceAdapter(type); >- if (adapter != null) { >- try { >- BugzillaModel element = adapter.restoreElement(parent, node, id); >- return element; >- } catch (BugzillaException e) { >- BugzillaPlugin.log(e); >- } >- } >- return null; >- } >- >- /** >- * Restore the childen of the given element. >- * @param parent the element >- * @param node the node for the element that may contain child nodes >- * representing children of the element >- * @return the restored children >- */ >- /* package */ static final BugzillaModel[] restoreChildren(BugzillaContainer parent, Preferences node) { >- final String [] childrenNames; >- try { >- childrenNames= node.childrenNames(); >- } catch (BackingStoreException e) { >- BugzillaPlugin.log(BugsException.asBugsException(e)); >- return EMPTY_ARRAY; >- } >- final ArrayList children= new ArrayList(); >- for (int i = 0; i < childrenNames.length; i++) { >- final String childName= childrenNames[i]; >- final Preferences childNode= node.node(childName); >- final BugzillaModel child= restoreChild(parent, childNode); >- if (child != null) >- children.add(child); >- } >- return (BugzillaModel[]) children.toArray(new BugzillaModel[children.size()]); >- } >- >- private static IPersistenceAdapter getPersistenceAdapter(String type) { >- Class typeClass = (Class)type2classMap.get(type); >- if (typeClass != null) { >- Object adapter = BugzillaAdapterFactory.getPersistenceAdapter(typeClass); >- if (adapter instanceof IPersistenceAdapter) >- return (IPersistenceAdapter)adapter; >- } >- return null; >- } >- >- /** >- * The provider has been added so persist it's state >- * @param provider >- */ >- public static void providerAdded(BugzillaProvider provider) { >- IPersistenceAdapter adapter = getPersistenceAdapter(provider); >- if (adapter != null) { >- adapter.storeElement(provider, true /* flush to disk */); >- } >- provider.getEventHandler().addProviderListener(listener ); >- } >- >- /** >- * The provider has been removed so purge any persisted state >- * @param provider >- */ >- public static void providerRemoved(BugzillaProvider provider) { >- IPersistenceAdapter adapter = getPersistenceAdapter(provider); >- if (adapter != null) { >- adapter.purgeChild(null, provider, true /* flush to disk */); >- } >- provider.getEventHandler().removeProviderListener(listener); >- } >- >- /** >- * @param container >- * @return >- */ >- public static Preferences getPreferenceNode(BugzillaContainer container) { >- return AbstractPersistenceAdapter.getPreferences(container); >- } >- >- /* >- * Do not allow instantiation >- */ >- private PersistenceManager() { >- } >- >-} >+/******************************************************************************* >+ * Copyright (c) 2000, 2004 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.team.bugzilla.persistence; >+ >+import java.util.ArrayList; >+import java.util.HashMap; >+import java.util.Map; >+ >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.core.runtime.preferences.InstanceScope; >+import org.eclipse.team.bugs.extension.BugsException; >+import org.eclipse.team.bugs.model.IBugProvider; >+import org.eclipse.team.bugs.model.IGenericModel; >+import org.eclipse.team.bugs.model.IProviderListener; >+import org.eclipse.team.bugzilla.BugzillaException; >+import org.eclipse.team.bugzilla.BugzillaPlugin; >+import org.eclipse.team.bugzilla.adapters.BugzillaAdapterFactory; >+import org.eclipse.team.bugzilla.model.BugzillaContainer; >+import org.eclipse.team.bugzilla.model.BugzillaFolder; >+import org.eclipse.team.bugzilla.model.BugzillaHistoryFolder; >+import org.eclipse.team.bugzilla.model.BugzillaModel; >+import org.eclipse.team.bugzilla.model.BugzillaProvider; >+import org.eclipse.team.bugzilla.model.BugzillaQuery; >+import org.eclipse.team.bugzilla.model.BugzillaReport; >+import org.osgi.service.prefs.BackingStoreException; >+import org.osgi.service.prefs.Preferences; >+ >+/** >+ * >+ */ >+public class PersistenceManager { >+ >+ /* >+ * The preference node in the instance scope where the providers are persisted >+ */ >+ private static final String PROVIDER_STORE_ID = "providers"; //$NON-NLS-1$ >+ >+ protected static final BugzillaModel [] EMPTY_ARRAY= new BugzillaModel[0]; >+ >+ /** >+ * The key for the model type preference. >+ */ >+ public final static String MODEL_TYPE= "org.eclipse.team.bugzilla.modelType"; //$NON-NLS-1$ >+ >+ public final static String ELEMENT_ID = "org.eclipse.team.bugzilla.elementId"; //$NON-NLS-1$ >+ >+ /** >+ * IDs for the different persistent model types. >+ */ >+ public final static String PROVIDER= "provider"; //$NON-NLS-1$ >+ public final static String FOLDER= "folder"; //$NON-NLS-1$ >+ public final static String HISTORY= "history"; //$NON-NLS-1$ >+ public final static String REPORT= "report"; //$NON-NLS-1$ >+ public final static String QUERY= "query"; //$NON-NLS-1$ >+ >+ private final static Map type2classMap; >+ >+ /* >+ * Listener that is registered with each provider to update >+ * the store when the model changes >+ */ >+ private static IProviderListener listener = new IProviderListener() { >+ /* (non-Javadoc) >+ * @see org.eclipse.team.bugs.model.IProviderListener#modelAdded(org.eclipse.team.bugs.model.IGenericModel, org.eclipse.team.bugs.model.IGenericModel) >+ */ >+ public void elementsAdded(IGenericModel parent, IGenericModel[] children) { >+ elementsChanged(children); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.team.bugs.model.IProviderListener#modelChanged(org.eclipse.team.bugs.model.IGenericModel) >+ */ >+ public void elementsChanged(IGenericModel[] elements) { >+ for (int i = 0; i < elements.length; i++) { >+ final BugzillaModel model = (BugzillaModel)elements[i]; >+ final IPersistenceAdapter adapter = getPersistenceAdapter(elements[i]); >+ if (adapter != null) >+ adapter.storeElement(model, false); >+ } >+ final BugzillaProvider provider= ((BugzillaModel)elements[0]).getBugzillaProvider(); >+ try { >+ AbstractPersistenceAdapter.getPreferences(provider).flush(); >+ } catch (BackingStoreException e) { >+ BugzillaPlugin.log(BugzillaException.asBugsException(e)); >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.team.bugs.model.IProviderListener#modelRemoved(org.eclipse.team.bugs.model.IGenericModel, org.eclipse.team.bugs.model.IGenericModel) >+ */ >+ public void elementsRemoved(IGenericModel parent, IGenericModel[] children) { >+ for (int i = 0; i < children.length; i++) { >+ final BugzillaModel model = (BugzillaModel)children[i]; >+ final IPersistenceAdapter adapter = getPersistenceAdapter(parent); >+ if (adapter != null) >+ adapter.purgeChild((BugzillaModel)parent, model, false); >+ } >+ try { >+ AbstractPersistenceAdapter.getPreferences(parent).flush(); >+ } catch (BackingStoreException e) { >+ BugzillaPlugin.log(BugzillaException.asBugsException(e)); >+ } >+ } >+ }; >+ >+ >+ static { >+ type2classMap = new HashMap(); >+ type2classMap.put(PROVIDER, BugzillaProvider.class); >+ type2classMap.put(FOLDER, BugzillaFolder.class); >+ type2classMap.put(HISTORY, BugzillaHistoryFolder.class); >+ type2classMap.put(REPORT, BugzillaReport.class); >+ type2classMap.put(QUERY, BugzillaQuery.class); >+ } >+ >+ /** >+ * Return the root preferences node whose children are providers >+ * @return the root preferences node whose children are providers >+ */ >+ /* package */ static Preferences getRootNode() { >+ return new InstanceScope().getNode(BugzillaPlugin.ID).node(PROVIDER_STORE_ID); >+ } >+ >+ /** >+ * Restore the providers from the preference store and return the restored providers >+ * @return the restored providers >+ */ >+ public static IBugProvider[] restoreProviders() { >+ BugzillaModel[] providers = restoreChildren(null /* no parent */, getRootNode()); >+ IBugProvider[] result = new IBugProvider[providers.length]; >+ System.arraycopy(providers, 0, result, 0, providers.length); >+ return result; >+ } >+ >+ /** >+ * Return the persistence adapter for the given element >+ * or <code>null</code> if there isn't one. >+ * @param element the element >+ * @return the persistence adapter for the given element >+ * or <code>null</code> >+ */ >+ public static IPersistenceAdapter getPersistenceAdapter(Object element) { >+ if (element instanceof IAdaptable) { >+ Object adapter = ((IAdaptable)element).getAdapter(IPersistenceAdapter.class); >+ if (adapter instanceof IPersistenceAdapter) >+ return (IPersistenceAdapter)adapter; >+ } >+ return null; >+ } >+ >+ /* >+ * Method used by persistence adapters to restore a bugzilla model >+ */ >+ /* package */ static BugzillaModel restoreChild(BugzillaContainer parent, Preferences node) { >+ final String type= node.get(MODEL_TYPE, ""); //$NON-NLS-1$ >+ final String id = node.get(ELEMENT_ID, ""); //$NON-NLS-1$ >+ IPersistenceAdapter adapter = getPersistenceAdapter(type); >+ if (adapter != null) { >+ try { >+ BugzillaModel element = adapter.restoreElement(parent, node, id); >+ return element; >+ } catch (BugzillaException e) { >+ BugzillaPlugin.log(e); >+ } >+ } >+ return null; >+ } >+ >+ /** >+ * Restore the childen of the given element. >+ * @param parent the element >+ * @param node the node for the element that may contain child nodes >+ * representing children of the element >+ * @return the restored children >+ */ >+ /* package */ static final BugzillaModel[] restoreChildren(BugzillaContainer parent, Preferences node) { >+ final String [] childrenNames; >+ try { >+ childrenNames= node.childrenNames(); >+ } catch (BackingStoreException e) { >+ BugzillaPlugin.log(BugsException.asBugsException(e)); >+ return EMPTY_ARRAY; >+ } >+ final ArrayList children= new ArrayList(); >+ for (int i = 0; i < childrenNames.length; i++) { >+ final String childName= childrenNames[i]; >+ final Preferences childNode= node.node(childName); >+ final BugzillaModel child= restoreChild(parent, childNode); >+ if (child != null) >+ children.add(child); >+ } >+ return (BugzillaModel[]) children.toArray(new BugzillaModel[children.size()]); >+ } >+ >+ private static IPersistenceAdapter getPersistenceAdapter(String type) { >+ Class typeClass = (Class)type2classMap.get(type); >+ if (typeClass != null) { >+ Object adapter = BugzillaAdapterFactory.getPersistenceAdapter(typeClass); >+ if (adapter instanceof IPersistenceAdapter) >+ return (IPersistenceAdapter)adapter; >+ } >+ return null; >+ } >+ >+ /** >+ * The provider has been added so persist it's state >+ * @param provider >+ */ >+ public static void providerAdded(BugzillaProvider provider) { >+ IPersistenceAdapter adapter = getPersistenceAdapter(provider); >+ if (adapter != null) { >+ adapter.storeElement(provider, true /* flush to disk */); >+ } >+ provider.getEventHandler().addProviderListener(listener ); >+ } >+ >+ /** >+ * The provider has been removed so purge any persisted state >+ * @param provider >+ */ >+ public static void providerRemoved(BugzillaProvider provider) { >+ IPersistenceAdapter adapter = getPersistenceAdapter(provider); >+ if (adapter != null) { >+ adapter.purgeChild(null, provider, true /* flush to disk */); >+ } >+ provider.getEventHandler().removeProviderListener(listener); >+ } >+ >+ /** >+ * @param container >+ */ >+ public static Preferences getPreferenceNode(BugzillaContainer container) { >+ return AbstractPersistenceAdapter.getPreferences(container); >+ } >+ >+ /* >+ * Do not allow instantiation >+ */ >+ private PersistenceManager() { >+ } >+ >+} >Index: src/org/eclipse/team/bugzilla/tools/IBugzillaSelectionProvider.java >=================================================================== >RCS file: /cvs/eclipse/bugzilla/org.eclipse.team.bugzilla/src/org/eclipse/team/bugzilla/tools/IBugzillaSelectionProvider.java,v >retrieving revision 1.1 >diff -u -r1.1 IBugzillaSelectionProvider.java >--- src/org/eclipse/team/bugzilla/tools/IBugzillaSelectionProvider.java 10 Jan 2005 17:08:28 -0000 1.1 >+++ src/org/eclipse/team/bugzilla/tools/IBugzillaSelectionProvider.java 31 May 2005 20:25:41 -0000 >@@ -1,28 +1,25 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2004 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Common Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/cpl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.team.bugzilla.tools; >- >-/** >- * >- */ >-public interface IBugzillaSelectionProvider { >- >- /** >- * @return >- */ >- BugzillaSelection getSelection(); >- >- void addListener(IBugzillaSelectionListener listener); >- >- void removeListener(IBugzillaSelectionListener listener); >- >-} >+/******************************************************************************* >+ * Copyright (c) 2000, 2004 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.team.bugzilla.tools; >+ >+/** >+ * >+ */ >+public interface IBugzillaSelectionProvider { >+ >+ BugzillaSelection getSelection(); >+ >+ void addListener(IBugzillaSelectionListener listener); >+ >+ void removeListener(IBugzillaSelectionListener listener); >+ >+} >Index: src/org/eclipse/team/bugzilla/view/ActionManager.java >=================================================================== >RCS file: /cvs/eclipse/bugzilla/org.eclipse.team.bugzilla/src/org/eclipse/team/bugzilla/view/ActionManager.java,v >retrieving revision 1.1 >diff -u -r1.1 ActionManager.java >--- src/org/eclipse/team/bugzilla/view/ActionManager.java 10 Jan 2005 17:08:28 -0000 1.1 >+++ src/org/eclipse/team/bugzilla/view/ActionManager.java 31 May 2005 20:25:41 -0000 >@@ -1,103 +1,103 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2004 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Common Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/cpl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.team.bugzilla.view; >- >-import org.eclipse.jface.action.*; >-import org.eclipse.swt.custom.StyledText; >-import org.eclipse.swt.events.FocusAdapter; >-import org.eclipse.swt.events.FocusEvent; >-import org.eclipse.team.bugs.extension.IViewerProxy; >-import org.eclipse.team.bugzilla.actions.*; >-import org.eclipse.team.bugzilla.tools.IBugzillaSelectionProvider; >-import org.eclipse.ui.IWorkbenchActionConstants; >-import org.eclipse.ui.actions.ActionFactory; >- >-/** >- * >- */ >-class ActionManager extends FocusAdapter { >- >- private final BugzillaDeleteAction fDeleteAction; >- private final BugzillaCopyAction fCopyAction; >- private final BugzillaPasteAction fPasteAction; >- private final BugzillaMoveAction fMoveAction; >- private final BugzillaRenameAction fRenameAction; >- private final RefreshAction fRefreshAction; >- >- private final ShowInBrowserAction fShowInBrowserAction; >- private final ClearHistoryAction fClearHistoryAction; >- >- private final TextSelectAllAction fTextSelectAllAction; >- >- private final BugzillaViewExtension fExtension; >- >- public ActionManager(BugzillaViewExtension extension) { >- >- fExtension= extension; >- final IViewerProxy proxy= extension.getProxy(); >- final IBugzillaSelectionProvider provider = extension.getBugzillaSelectionProvider(); >- fDeleteAction= new BugzillaDeleteAction(proxy, provider); >- fPasteAction= new BugzillaPasteAction(proxy, provider); >- fCopyAction= new BugzillaCopyAction(proxy, extension, fPasteAction); >- fMoveAction= new BugzillaMoveAction(proxy, provider); >- fRenameAction= new BugzillaRenameAction(proxy, provider); >- fClearHistoryAction= new ClearHistoryAction(proxy, provider); >- fShowInBrowserAction= new ShowInBrowserAction(proxy, provider); >- fRefreshAction= new RefreshAction(proxy, provider); >- fTextSelectAllAction= new TextSelectAllAction(extension); >- >- proxy.registerGlobalAction(ActionFactory.DELETE.getId(), fDeleteAction); >- proxy.registerGlobalAction(ActionFactory.COPY.getId(), fCopyAction); >- proxy.registerGlobalAction(ActionFactory.PASTE.getId(), fPasteAction); >- proxy.registerGlobalAction(ActionFactory.MOVE.getId(), fMoveAction); >- proxy.registerGlobalAction(ActionFactory.RENAME.getId(), fRenameAction); >- proxy.registerGlobalAction(ActionFactory.REFRESH.getId(), fRefreshAction); >- proxy.registerGlobalAction(ActionFactory.SELECT_ALL.getId(), fTextSelectAllAction); >- } >- >- public void fillContextMenu(IMenuManager menu) { >- if (fShowInBrowserAction.isEnabled()) >- menu.add(fShowInBrowserAction); >- if (fClearHistoryAction.isEnabled()) >- menu.add(fClearHistoryAction); >- } >- >- public void updateActionEnablements() { >- fShowInBrowserAction.setEnablement(); >- fDeleteAction.setEnablement(); >- fCopyAction.setEnablement(); >- fPasteAction.setEnablement(); >- fMoveAction.setEnablement(); >- fRefreshAction.setEnablement(); >- fRenameAction.setEnablement(); >- fClearHistoryAction.setEnablement(); >- fTextSelectAllAction.setEnablement(); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.swt.events.FocusAdapter#focusGained(org.eclipse.swt.events.FocusEvent) >- */ >- public void focusGained(FocusEvent e) { >- updateActionEnablements(); >- } >- >- /** >- * @param styledText >- */ >- public void createTextContextMenu(StyledText styledText) { >- final MenuManager menu= new MenuManager(null); >- menu.add(fCopyAction); >- menu.add(fTextSelectAllAction); >- menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); >- styledText.setMenu(menu.createContextMenu(styledText)); >- } >-} >+/******************************************************************************* >+ * Copyright (c) 2000, 2004 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.team.bugzilla.view; >+ >+import org.eclipse.jface.action.*; >+import org.eclipse.swt.custom.StyledText; >+import org.eclipse.swt.events.FocusAdapter; >+import org.eclipse.swt.events.FocusEvent; >+import org.eclipse.team.bugs.extension.IViewerProxy; >+import org.eclipse.team.bugzilla.actions.*; >+import org.eclipse.team.bugzilla.tools.IBugzillaSelectionProvider; >+import org.eclipse.ui.IWorkbenchActionConstants; >+import org.eclipse.ui.actions.ActionFactory; >+ >+/** >+ * >+ */ >+class ActionManager extends FocusAdapter { >+ >+ private final BugzillaDeleteAction fDeleteAction; >+ private final BugzillaCopyAction fCopyAction; >+ private final BugzillaPasteAction fPasteAction; >+ private final BugzillaMoveAction fMoveAction; >+ private final BugzillaRenameAction fRenameAction; >+ private final RefreshAction fRefreshAction; >+ >+ private final ShowInBrowserAction fShowInBrowserAction; >+ private final ClearHistoryAction fClearHistoryAction; >+ >+ private final TextSelectAllAction fTextSelectAllAction; >+ >+ //private final BugzillaViewExtension fExtension; >+ >+ public ActionManager(BugzillaViewExtension extension) { >+ >+ //fExtension= extension; >+ final IViewerProxy proxy= extension.getProxy(); >+ final IBugzillaSelectionProvider provider = extension.getBugzillaSelectionProvider(); >+ fDeleteAction= new BugzillaDeleteAction(proxy, provider); >+ fPasteAction= new BugzillaPasteAction(proxy, provider); >+ fCopyAction= new BugzillaCopyAction(proxy, extension, fPasteAction); >+ fMoveAction= new BugzillaMoveAction(proxy, provider); >+ fRenameAction= new BugzillaRenameAction(proxy, provider); >+ fClearHistoryAction= new ClearHistoryAction(proxy, provider); >+ fShowInBrowserAction= new ShowInBrowserAction(proxy, provider); >+ fRefreshAction= new RefreshAction(proxy, provider); >+ fTextSelectAllAction= new TextSelectAllAction(extension); >+ >+ proxy.registerGlobalAction(ActionFactory.DELETE.getId(), fDeleteAction); >+ proxy.registerGlobalAction(ActionFactory.COPY.getId(), fCopyAction); >+ proxy.registerGlobalAction(ActionFactory.PASTE.getId(), fPasteAction); >+ proxy.registerGlobalAction(ActionFactory.MOVE.getId(), fMoveAction); >+ proxy.registerGlobalAction(ActionFactory.RENAME.getId(), fRenameAction); >+ proxy.registerGlobalAction(ActionFactory.REFRESH.getId(), fRefreshAction); >+ proxy.registerGlobalAction(ActionFactory.SELECT_ALL.getId(), fTextSelectAllAction); >+ } >+ >+ public void fillContextMenu(IMenuManager menu) { >+ if (fShowInBrowserAction.isEnabled()) >+ menu.add(fShowInBrowserAction); >+ if (fClearHistoryAction.isEnabled()) >+ menu.add(fClearHistoryAction); >+ } >+ >+ public void updateActionEnablements() { >+ fShowInBrowserAction.setEnablement(); >+ fDeleteAction.setEnablement(); >+ fCopyAction.setEnablement(); >+ fPasteAction.setEnablement(); >+ fMoveAction.setEnablement(); >+ fRefreshAction.setEnablement(); >+ fRenameAction.setEnablement(); >+ fClearHistoryAction.setEnablement(); >+ fTextSelectAllAction.setEnablement(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.swt.events.FocusAdapter#focusGained(org.eclipse.swt.events.FocusEvent) >+ */ >+ public void focusGained(FocusEvent e) { >+ updateActionEnablements(); >+ } >+ >+ /** >+ * @param styledText >+ */ >+ public void createTextContextMenu(StyledText styledText) { >+ final MenuManager menu= new MenuManager(null); >+ menu.add(fCopyAction); >+ menu.add(fTextSelectAllAction); >+ menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); >+ styledText.setMenu(menu.createContextMenu(styledText)); >+ } >+} >Index: src/org/eclipse/team/bugzilla/view/BugzillaModelPresenter.java >=================================================================== >RCS file: /cvs/eclipse/bugzilla/org.eclipse.team.bugzilla/src/org/eclipse/team/bugzilla/view/BugzillaModelPresenter.java,v >retrieving revision 1.7 >diff -u -r1.7 BugzillaModelPresenter.java >--- src/org/eclipse/team/bugzilla/view/BugzillaModelPresenter.java 1 Mar 2005 19:51:09 -0000 1.7 >+++ src/org/eclipse/team/bugzilla/view/BugzillaModelPresenter.java 31 May 2005 20:25:41 -0000 >@@ -1,337 +1,336 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2004 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Common Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/cpl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.team.bugzilla.view; >- >-import java.io.UnsupportedEncodingException; >-import java.net.URLDecoder; >-import java.text.DateFormat; >-import java.util.Date; >-import java.util.HashMap; >-import java.util.Iterator; >- >-import org.eclipse.jface.text.TextPresentation; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.custom.BusyIndicator; >-import org.eclipse.swt.custom.StyleRange; >-import org.eclipse.swt.custom.StyledText; >-import org.eclipse.team.bugzilla.datatypes.AttachmentData; >-import org.eclipse.team.bugzilla.datatypes.AttachmentDescription; >-import org.eclipse.team.bugzilla.datatypes.CommentData; >-import org.eclipse.team.bugzilla.datatypes.ReportData; >-import org.eclipse.team.bugzilla.model.BugzillaAttachment; >-import org.eclipse.team.bugzilla.model.BugzillaComment; >-import org.eclipse.team.bugzilla.model.BugzillaFolder; >-import org.eclipse.team.bugzilla.model.BugzillaModel; >-import org.eclipse.team.bugzilla.model.BugzillaQuery; >-import org.eclipse.team.bugzilla.model.BugzillaReport; >- >-public class BugzillaModelPresenter { >- >- protected TextPresentation fPresentation; >- protected StringBuffer fBuffer; >- protected StyledText fStyledText; >- >- public BugzillaModelPresenter() { >- fStyledText= null; >- fPresentation= null; >- fBuffer= null; >- } >- >- private void begin(StyledText styledText) { >- fPresentation= new TextPresentation(); >- fBuffer= new StringBuffer(); >- fStyledText= styledText; >- >- } >- >- private void end(final boolean wordWrap) { >- BusyIndicator.showWhile(fStyledText.getDisplay(), new Runnable() { >- public void run() { >- fStyledText.setRedraw(false); >- fStyledText.setText(""); >- fStyledText.setWordWrap(wordWrap); >- fStyledText.setText(fBuffer.toString()); >- TextPresentation.applyTextPresentation(fPresentation, fStyledText); >- fStyledText.setRedraw(true); >- } >- }); >- >- fBuffer= null; >- fPresentation= null; >- fStyledText= null; >- } >- >-// public void present(BugzillaProvider provider, StyledText styledText) { >-// begin(styledText); >-// end(true); >-// } >- >- public void present(BugzillaQuery query, StyledText styledText) { >- begin(styledText); >- append(query); >- end(true); >- } >- >- public void present(BugzillaReport report, StyledText styledText) { >- begin(styledText); >- append(report); >- end(true); >- } >- >- public void present(BugzillaComment comment, StyledText styledText) { >- begin(styledText); >- append(comment); >- end(true); >- } >- >- public void present(BugzillaAttachment bugzillaAttachment, StyledText styledText) { >- >- final AttachmentData attachment= bugzillaAttachment.getData(); >- >- boolean wordWrap= false; >- begin(styledText); >- >- if (attachment != null) { >- final String data= bugzillaAttachment.getDataAsString(); >- final String mimeType= bugzillaAttachment.getData().getString(AttachmentData.MIMETYPE); >- if (mimeType.startsWith("text/")) { >- append(data); >- wordWrap= false; >- } else { >- append(attachment.getString(AttachmentData.FILENAME)).space().append("[").append(mimeType).append("]"); >- wordWrap= true; >- } >- } >- end(wordWrap); >- } >- >- /** >- * @param folder >- * @param styledText >- */ >-// public void present(BugzillaFolder folder, StyledText styledText) { >-// begin(styledText); >-// append(folder); >-// end(true); >-// } >- >-// /** >-// * @param folder >-// */ >-// private void append(BugzillaFolder folder) { >-// /* TODO: jpound - implement folder presentation */ >-// bold(folder.getName()).endl().endl(); >-// >-// BugzillaModel[] children = folder.getChildren(); >-// int numQueries = 0; >-// int numBugs = 0; >-// if (children != null) { >-// for (int i = 0; i < children.length; i++) { >-// if (children[i] instanceof BugzillaQuery) { >-// numQueries++; >-// } >-// else { >-// numBugs++; >-// } >-// } >-// } >-// else { >-// italic("Empty Folder"); >-// return; >-// } >-// >-// if (numQueries > 0) { >-// append("Queries:\t" + numQueries).endl(); >-// } >-// if (numBugs > 0) { >-// append("Bugs:\t\t" + numBugs); >-// } >-// } >- >- private BugzillaModelPresenter append(BugzillaQuery query) { >- >- String queryUrl = query.getQueryUrl().toUrlString(); >- String summary = null; >- String comment = null; >- >- int summaryIndex = queryUrl.indexOf("short_desc="); >- if (summaryIndex >= 0) { >- summary = queryUrl.substring(summaryIndex, queryUrl.length()); >- int ampIndex = summary.indexOf('&'); >- if (ampIndex < 0) { >- ampIndex = summary.length(); >- } >- try { >- summary = URLDecoder.decode(summary.substring(summary.indexOf('=') + 1, ampIndex), "UTF-8"); >- } catch (UnsupportedEncodingException e) { >- e.printStackTrace(); >- } >- } >- >- int commentIndex = queryUrl.indexOf("long_desc="); >- if (commentIndex >= 0) { >- comment = queryUrl.substring(commentIndex, queryUrl.length()); >- int ampIndex = comment.indexOf('&'); >- if (ampIndex < 0) { >- ampIndex = comment.length(); >- } >- try { >- comment = URLDecoder.decode(comment.substring(comment.indexOf('=') + 1, ampIndex), "UTF-8"); >- } catch (UnsupportedEncodingException e) { >- e.printStackTrace(); >- } >- } >- >- BugzillaModel[] children = query.getChildren(); >- HashMap bugFreqs = new HashMap(7); // 7 bugzilla status' >- int criticalBugs = 0; >- >- for (int i = 0; i < children.length; i++) { >- ReportData reportData = ((BugzillaReport)children[i]).getReportData(); >- if (reportData == null) { >- return this; >- } >- String status = reportData.getString(ReportData.STATUS); >- >- if (reportData.getString(ReportData.SEVERITY).equals("critical")) { >- criticalBugs++; >- } >- >- Integer count = (Integer)bugFreqs.get(status); >- if (count == null) { >- bugFreqs.put(status, new Integer(1)); >- } >- else { >- bugFreqs.put(status, new Integer(count.intValue() + 1)); >- } >- } >- >- bold("Query from " + query.getQueryUrl().getBaseUrl()).endl(); >- if (summary != null && !summary.equals("")) { >- append("Summary:\t\t").italic(summary).endl(); >- } >- if (comment != null && !comment.equals("")) { >- append("Comment:\t\t").italic(comment).endl(); >- } >- endl(); >- >- append("Total Bugs:\t" + children.length).endl(); >- Iterator iter = bugFreqs.keySet().iterator(); >- while (iter.hasNext()) { >- String status = (String)iter.next(); >- String tab = "\t"; >- int statusLength; >- if ( (statusLength = status.length()) < 8) { >- tab += "\t"; >- if (statusLength < 4) { >- tab += "\t"; >- } >- } >- append(status + tab + bugFreqs.get(status)).endl(); >- } >- endl(); >- if (criticalBugs > 0) { >- append("This query contains").bold(" "+criticalBugs).append(" critical " + ((criticalBugs > 1) ? "bugs" : "bug")); >- } >- >- return this; >- } >- >- private BugzillaModelPresenter append(BugzillaComment bugzillaComment) { >- final CommentData comment= bugzillaComment.getCommentData(); >- if (comment == null) >- return this; >- bold(comment.getString(CommentData.AUTHOR)).append(" - ").append(comment.getDate(CommentData.DATE)).endl(2); >- >- if (comment.attachmentDesc != null && comment.attachmentDesc.getBoolean(AttachmentDescription.OBSOLETE)) >- append("*** This attachment is obsolete ***").endl(2); >- append(comment.getString(CommentData.TEXT)); >- return this; >- } >- >- private BugzillaModelPresenter append(BugzillaReport bugzillaReport) { >- >- if (!bugzillaReport.hasLocalContent()) >- return this; >- >- final ReportData report= bugzillaReport.getReportData(); >- >- bold("[").bold(report.getString(ReportData.ID)).bold("]").space().bold(report.getString(ReportData.TITLE)).endl(2); >- >- append("Assigned To: ").append(report.getString(ReportData.ASSIGNEDTO)).endl(); >- append("Severity: ").append(report.getString(ReportData.SEVERITY)).endl(); >- append("Priority: ").append(report.getString(ReportData.PRIORITY)).endl(); >- append("Target Milestone: ").append(report.getString(ReportData.TARGETMILESTONE)).endl(); >- endl(); >- append("Operating System: ").append(report.getString(ReportData.OPERATINGSYSTEM)).endl(); >- append("Platform: ").append(report.getString(ReportData.PLATFORM)).endl(); >- >- endl(); >- >- /* append first comment >- final Iterator iter= bugzillaReport.getComments().iterator(); >- if (iter.hasNext()) { >- append((BugzillaComment)iter.next()); >- } >- */ >- return this; >- } >- >- private BugzillaModelPresenter append(String suffix) { >- fBuffer.append(suffix); >- return this; >- } >- >- private BugzillaModelPresenter bold(String suffix) { >- final int offset= fBuffer.length(); >- final int length= suffix.length(); >- fBuffer.append(suffix); >- fPresentation.addStyleRange(new StyleRange(offset, length, null, null, SWT.BOLD)); >- return this; >- } >- >- private BugzillaModelPresenter italic(String suffix) { >- final int offset= fBuffer.length(); >- final int length= suffix.length(); >- fBuffer.append(suffix); >- fPresentation.addStyleRange(new StyleRange(offset, length, null, null, SWT.ITALIC)); >- return this; >- } >- >- private BugzillaModelPresenter endl() { >- fBuffer.append("\n"); >- return this; >- } >- >- private BugzillaModelPresenter endl(int n) { >- for (int i= 0; i < n; ++i) >- fBuffer.append("\n"); >- return this; >- } >- >- private BugzillaModelPresenter space() { >- fBuffer.append(" "); >- return this; >- } >- >-// private BugzillaModelPresenter space(int n) { >-// for (int i= 0; i < n; i++) >-// fBuffer.append(" "); >-// return this; >-// } >- >- private BugzillaModelPresenter append(Date date) { >- fBuffer.append(DateFormat.getDateTimeInstance().format(date)); >- return this; >- } >- >-} >+/******************************************************************************* >+ * Copyright (c) 2000, 2004 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.team.bugzilla.view; >+ >+import java.io.UnsupportedEncodingException; >+import java.net.URLDecoder; >+import java.text.DateFormat; >+import java.util.Date; >+import java.util.HashMap; >+import java.util.Iterator; >+ >+import org.eclipse.jface.text.TextPresentation; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.custom.BusyIndicator; >+import org.eclipse.swt.custom.StyleRange; >+import org.eclipse.swt.custom.StyledText; >+import org.eclipse.team.bugzilla.datatypes.AttachmentData; >+import org.eclipse.team.bugzilla.datatypes.AttachmentDescription; >+import org.eclipse.team.bugzilla.datatypes.CommentData; >+import org.eclipse.team.bugzilla.datatypes.ReportData; >+import org.eclipse.team.bugzilla.model.BugzillaAttachment; >+import org.eclipse.team.bugzilla.model.BugzillaComment; >+import org.eclipse.team.bugzilla.model.BugzillaModel; >+import org.eclipse.team.bugzilla.model.BugzillaQuery; >+import org.eclipse.team.bugzilla.model.BugzillaReport; >+ >+public class BugzillaModelPresenter { >+ >+ protected TextPresentation fPresentation; >+ protected StringBuffer fBuffer; >+ protected StyledText fStyledText; >+ >+ public BugzillaModelPresenter() { >+ fStyledText= null; >+ fPresentation= null; >+ fBuffer= null; >+ } >+ >+ private void begin(StyledText styledText) { >+ fPresentation= new TextPresentation(); >+ fBuffer= new StringBuffer(); >+ fStyledText= styledText; >+ >+ } >+ >+ private void end(final boolean wordWrap) { >+ BusyIndicator.showWhile(fStyledText.getDisplay(), new Runnable() { >+ public void run() { >+ fStyledText.setRedraw(false); >+ fStyledText.setText(""); >+ fStyledText.setWordWrap(wordWrap); >+ fStyledText.setText(fBuffer.toString()); >+ TextPresentation.applyTextPresentation(fPresentation, fStyledText); >+ fStyledText.setRedraw(true); >+ } >+ }); >+ >+ fBuffer= null; >+ fPresentation= null; >+ fStyledText= null; >+ } >+ >+// public void present(BugzillaProvider provider, StyledText styledText) { >+// begin(styledText); >+// end(true); >+// } >+ >+ public void present(BugzillaQuery query, StyledText styledText) { >+ begin(styledText); >+ append(query); >+ end(true); >+ } >+ >+ public void present(BugzillaReport report, StyledText styledText) { >+ begin(styledText); >+ append(report); >+ end(true); >+ } >+ >+ public void present(BugzillaComment comment, StyledText styledText) { >+ begin(styledText); >+ append(comment); >+ end(true); >+ } >+ >+ public void present(BugzillaAttachment bugzillaAttachment, StyledText styledText) { >+ >+ final AttachmentData attachment= bugzillaAttachment.getData(); >+ >+ boolean wordWrap= false; >+ begin(styledText); >+ >+ if (attachment != null) { >+ final String data= bugzillaAttachment.getDataAsString(); >+ final String mimeType= bugzillaAttachment.getData().getString(AttachmentData.MIMETYPE); >+ if (mimeType.startsWith("text/")) { >+ append(data); >+ wordWrap= false; >+ } else { >+ append(attachment.getString(AttachmentData.FILENAME)).space().append("[").append(mimeType).append("]"); >+ wordWrap= true; >+ } >+ } >+ end(wordWrap); >+ } >+ >+// /** >+// * @param folder >+// * @param styledText >+// */ >+// public void present(BugzillaFolder folder, StyledText styledText) { >+// begin(styledText); >+// append(folder); >+// end(true); >+// } >+ >+// /** >+// * @param folder >+// */ >+// private void append(BugzillaFolder folder) { >+// /* TODO: jpound - implement folder presentation */ >+// bold(folder.getName()).endl().endl(); >+// >+// BugzillaModel[] children = folder.getChildren(); >+// int numQueries = 0; >+// int numBugs = 0; >+// if (children != null) { >+// for (int i = 0; i < children.length; i++) { >+// if (children[i] instanceof BugzillaQuery) { >+// numQueries++; >+// } >+// else { >+// numBugs++; >+// } >+// } >+// } >+// else { >+// italic("Empty Folder"); >+// return; >+// } >+// >+// if (numQueries > 0) { >+// append("Queries:\t" + numQueries).endl(); >+// } >+// if (numBugs > 0) { >+// append("Bugs:\t\t" + numBugs); >+// } >+// } >+ >+ private BugzillaModelPresenter append(BugzillaQuery query) { >+ >+ String queryUrl = query.getQueryUrl().toUrlString(); >+ String summary = null; >+ String comment = null; >+ >+ int summaryIndex = queryUrl.indexOf("short_desc="); >+ if (summaryIndex >= 0) { >+ summary = queryUrl.substring(summaryIndex, queryUrl.length()); >+ int ampIndex = summary.indexOf('&'); >+ if (ampIndex < 0) { >+ ampIndex = summary.length(); >+ } >+ try { >+ summary = URLDecoder.decode(summary.substring(summary.indexOf('=') + 1, ampIndex), "UTF-8"); >+ } catch (UnsupportedEncodingException e) { >+ e.printStackTrace(); >+ } >+ } >+ >+ int commentIndex = queryUrl.indexOf("long_desc="); >+ if (commentIndex >= 0) { >+ comment = queryUrl.substring(commentIndex, queryUrl.length()); >+ int ampIndex = comment.indexOf('&'); >+ if (ampIndex < 0) { >+ ampIndex = comment.length(); >+ } >+ try { >+ comment = URLDecoder.decode(comment.substring(comment.indexOf('=') + 1, ampIndex), "UTF-8"); >+ } catch (UnsupportedEncodingException e) { >+ e.printStackTrace(); >+ } >+ } >+ >+ BugzillaModel[] children = query.getChildren(); >+ HashMap bugFreqs = new HashMap(7); // 7 bugzilla status' >+ int criticalBugs = 0; >+ >+ for (int i = 0; i < children.length; i++) { >+ ReportData reportData = ((BugzillaReport)children[i]).getReportData(); >+ if (reportData == null) { >+ return this; >+ } >+ String status = reportData.getString(ReportData.STATUS); >+ >+ if (reportData.getString(ReportData.SEVERITY).equals("critical")) { >+ criticalBugs++; >+ } >+ >+ Integer count = (Integer)bugFreqs.get(status); >+ if (count == null) { >+ bugFreqs.put(status, new Integer(1)); >+ } >+ else { >+ bugFreqs.put(status, new Integer(count.intValue() + 1)); >+ } >+ } >+ >+ bold("Query from " + query.getQueryUrl().getBaseUrl()).endl(); >+ if (summary != null && !summary.equals("")) { >+ append("Summary:\t\t").italic(summary).endl(); >+ } >+ if (comment != null && !comment.equals("")) { >+ append("Comment:\t\t").italic(comment).endl(); >+ } >+ endl(); >+ >+ append("Total Bugs:\t" + children.length).endl(); >+ Iterator iter = bugFreqs.keySet().iterator(); >+ while (iter.hasNext()) { >+ String status = (String)iter.next(); >+ String tab = "\t"; >+ int statusLength; >+ if ( (statusLength = status.length()) < 8) { >+ tab += "\t"; >+ if (statusLength < 4) { >+ tab += "\t"; >+ } >+ } >+ append(status + tab + bugFreqs.get(status)).endl(); >+ } >+ endl(); >+ if (criticalBugs > 0) { >+ append("This query contains").bold(" "+criticalBugs).append(" critical " + ((criticalBugs > 1) ? "bugs" : "bug")); >+ } >+ >+ return this; >+ } >+ >+ private BugzillaModelPresenter append(BugzillaComment bugzillaComment) { >+ final CommentData comment= bugzillaComment.getCommentData(); >+ if (comment == null) >+ return this; >+ bold(comment.getString(CommentData.AUTHOR)).append(" - ").append(comment.getDate(CommentData.DATE)).endl(2); >+ >+ if (comment.attachmentDesc != null && comment.attachmentDesc.getBoolean(AttachmentDescription.OBSOLETE)) >+ append("*** This attachment is obsolete ***").endl(2); >+ append(comment.getString(CommentData.TEXT)); >+ return this; >+ } >+ >+ private BugzillaModelPresenter append(BugzillaReport bugzillaReport) { >+ >+ if (!bugzillaReport.hasLocalContent()) >+ return this; >+ >+ final ReportData report= bugzillaReport.getReportData(); >+ >+ bold("[").bold(report.getString(ReportData.ID)).bold("]").space().bold(report.getString(ReportData.TITLE)).endl(2); >+ >+ append("Assigned To: ").append(report.getString(ReportData.ASSIGNEDTO)).endl(); >+ append("Severity: ").append(report.getString(ReportData.SEVERITY)).endl(); >+ append("Priority: ").append(report.getString(ReportData.PRIORITY)).endl(); >+ append("Target Milestone: ").append(report.getString(ReportData.TARGETMILESTONE)).endl(); >+ endl(); >+ append("Operating System: ").append(report.getString(ReportData.OPERATINGSYSTEM)).endl(); >+ append("Platform: ").append(report.getString(ReportData.PLATFORM)).endl(); >+ >+ endl(); >+ >+ /* append first comment >+ final Iterator iter= bugzillaReport.getComments().iterator(); >+ if (iter.hasNext()) { >+ append((BugzillaComment)iter.next()); >+ } >+ */ >+ return this; >+ } >+ >+ private BugzillaModelPresenter append(String suffix) { >+ fBuffer.append(suffix); >+ return this; >+ } >+ >+ private BugzillaModelPresenter bold(String suffix) { >+ final int offset= fBuffer.length(); >+ final int length= suffix.length(); >+ fBuffer.append(suffix); >+ fPresentation.addStyleRange(new StyleRange(offset, length, null, null, SWT.BOLD)); >+ return this; >+ } >+ >+ private BugzillaModelPresenter italic(String suffix) { >+ final int offset= fBuffer.length(); >+ final int length= suffix.length(); >+ fBuffer.append(suffix); >+ fPresentation.addStyleRange(new StyleRange(offset, length, null, null, SWT.ITALIC)); >+ return this; >+ } >+ >+ private BugzillaModelPresenter endl() { >+ fBuffer.append("\n"); >+ return this; >+ } >+ >+ private BugzillaModelPresenter endl(int n) { >+ for (int i= 0; i < n; ++i) >+ fBuffer.append("\n"); >+ return this; >+ } >+ >+ private BugzillaModelPresenter space() { >+ fBuffer.append(" "); >+ return this; >+ } >+ >+// private BugzillaModelPresenter space(int n) { >+// for (int i= 0; i < n; i++) >+// fBuffer.append(" "); >+// return this; >+// } >+ >+ private BugzillaModelPresenter append(Date date) { >+ fBuffer.append(DateFormat.getDateTimeInstance().format(date)); >+ return this; >+ } >+ >+} >Index: src/org/eclipse/team/bugzilla/view/TextPane.java >=================================================================== >RCS file: /cvs/eclipse/bugzilla/org.eclipse.team.bugzilla/src/org/eclipse/team/bugzilla/view/TextPane.java,v >retrieving revision 1.6 >diff -u -r1.6 TextPane.java >--- src/org/eclipse/team/bugzilla/view/TextPane.java 1 Mar 2005 19:51:09 -0000 1.6 >+++ src/org/eclipse/team/bugzilla/view/TextPane.java 31 May 2005 20:25:41 -0000 >@@ -1,187 +1,186 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2004 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Common Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/cpl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.team.bugzilla.view; >- >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.jface.viewers.IOpenListener; >-import org.eclipse.jface.viewers.IStructuredSelection; >-import org.eclipse.jface.viewers.OpenEvent; >-import org.eclipse.jface.viewers.StructuredSelection; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.browser.LocationListener; >-import org.eclipse.swt.custom.SashForm; >-import org.eclipse.swt.custom.StyledText; >-import org.eclipse.swt.widgets.Composite; >-import org.eclipse.swt.widgets.Control; >-import org.eclipse.team.bugs.model.IGenericModel; >-import org.eclipse.team.bugs.model.IProviderListener; >-import org.eclipse.team.bugzilla.browser.BugzillaBrowser; >-import org.eclipse.team.bugzilla.browser.IWebContentAdapter; >-import org.eclipse.team.bugzilla.model.BugzillaModel; >-import org.eclipse.team.bugzilla.model.BugzillaProvider; >-import org.eclipse.team.bugzilla.tools.BugzillaSelection; >-import org.eclipse.team.bugzilla.tools.IBugzillaSelectionListener; >-import org.eclipse.ui.IWorkbenchPart; >-import org.eclipse.ui.PlatformUI; >-import org.eclipse.ui.part.PageBook; >- >-public class TextPane implements IBugzillaSelectionListener, IProviderListener, IOpenListener { >- >- private StyledText fStyledText; >- //private Control fEmptyControl; >- private PageBook fPageBook; >- private SashForm sashForm = null; >- private int[] userWeights = {2, 1}; >- >- private BugzillaSelection fSelection; >- >- private final DelayedRefreshPresenter fDelayedRefresh; >- private BugzillaViewExtension fExtension; >- >- public TextPane(BugzillaViewExtension extension, Composite parent) { >- fExtension= extension; >- fDelayedRefresh= new DelayedRefreshPresenter(); >- >- fPageBook= new PageBook(parent, SWT.NONE); >- //fEmptyControl= new Composite(fPageBook, SWT.NONE); >- fStyledText= new StyledText(fPageBook, SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY); >- fSelection= new BugzillaSelection(StructuredSelection.EMPTY); >- >- final ActionManager manager= fExtension.getActionManager(); >- manager.createTextContextMenu(fStyledText); >- >- if (parent.getParent() instanceof SashForm) { >- sashForm = (SashForm)parent.getParent(); >- hideView(); >- } >- } >- >- public void selectionChanged(BugzillaSelection selection) { >- fSelection= selection; >- >- final BugzillaModel element= fSelection.getOnlyElement(); >- fDelayedRefresh.refresh(element); >- >- if (element != null) { >- present(element); >- } >- else { >- hideView(); >- } >- } >- >- >- public void elementsAdded(IGenericModel parent, IGenericModel[] children) { >- } >- >- public void elementsChanged(IGenericModel[] elements) { >- /** >- * We only update the styled text if the model has just refreshed >- * and is currently selected. >- */ >- final BugzillaModel selected= fSelection.getOnlyElement(); >- if (selected == null) >- return; >- >- for (int i = 0; i < elements.length; i++) { >- if (selected == elements[i] && !selected.isRefreshing()) { >- present(selected); >- } >- } >- } >- >- public void elementsRemoved(IGenericModel parent, IGenericModel[] children) { >- } >- >- private void present(BugzillaModel element) { >- >- final IPresentableAdapter adapter= getPresentableAdapter(element); >- if (adapter == null) { >- hideView(); >- return; >- } >- >- adapter.present(element, fStyledText); >- //final boolean hasText= fStyledText.getText().trim().length() != 0; >- fPageBook.showPage(fStyledText); >- >- if (sashForm.getWeights()[1] == 0) { >- showView(); >- } >- } >- >- private void showView() { >- if (sashForm == null) { >- return; >- } >- sashForm.setWeights(userWeights); >- } >- >- private void hideView() { >- if (sashForm == null) { >- return; >- } >- int current[]; >- if ((current = sashForm.getWeights())[1] != 0) { >- userWeights = sashForm.getWeights(); >- } >- sashForm.setWeights(new int[] {1, 0}); >- } >- >- private IPresentableAdapter getPresentableAdapter(Object o) { >- if (o instanceof IAdaptable) { >- return (IPresentableAdapter)((IAdaptable)o).getAdapter(IPresentableAdapter.class); >- } >- return null; >- } >- >- public void open(OpenEvent event) { >- if (!(event.getSelection() instanceof IStructuredSelection)) >- return; >- >- final IStructuredSelection selection= (IStructuredSelection)event.getSelection(); >- >- if (!(selection.getFirstElement() instanceof BugzillaModel)) >- return; >- >- final BugzillaModel model= (BugzillaModel)selection.getFirstElement(); >- >- final IWebContentAdapter adapter= (IWebContentAdapter)model.getAdapter(IWebContentAdapter.class); >- if (adapter == null) >- return; >- >- final LocationListener listener= (BugzillaProvider)model.getProvider(); >- >- final String url= adapter.getURL(model); >- if (url != null) { >- final IWorkbenchPart part= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart(); >- BugzillaBrowser.open(part, listener, url.replaceAll("format=rdf", "")); >- } >- >- } >- >-// public String getSelection() { >-// return fStyledText.getSelectionText(); >-// } >-// >-// public boolean hasFocus() { >-// return fStyledText.isFocusControl(); >-// } >- >- public StyledText getStyledText() { >- return fStyledText; >- } >- >- public Control getControl() { >- return fPageBook; >- } >+/******************************************************************************* >+ * Copyright (c) 2000, 2004 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.team.bugzilla.view; >+ >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.jface.viewers.IOpenListener; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.jface.viewers.OpenEvent; >+import org.eclipse.jface.viewers.StructuredSelection; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.browser.LocationListener; >+import org.eclipse.swt.custom.SashForm; >+import org.eclipse.swt.custom.StyledText; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.team.bugs.model.IGenericModel; >+import org.eclipse.team.bugs.model.IProviderListener; >+import org.eclipse.team.bugzilla.browser.BugzillaBrowser; >+import org.eclipse.team.bugzilla.browser.IWebContentAdapter; >+import org.eclipse.team.bugzilla.model.BugzillaModel; >+import org.eclipse.team.bugzilla.model.BugzillaProvider; >+import org.eclipse.team.bugzilla.tools.BugzillaSelection; >+import org.eclipse.team.bugzilla.tools.IBugzillaSelectionListener; >+import org.eclipse.ui.IWorkbenchPart; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.part.PageBook; >+ >+public class TextPane implements IBugzillaSelectionListener, IProviderListener, IOpenListener { >+ >+ private StyledText fStyledText; >+ //private Control fEmptyControl; >+ private PageBook fPageBook; >+ private SashForm sashForm = null; >+ private int[] userWeights = {2, 1}; >+ >+ private BugzillaSelection fSelection; >+ >+ private final DelayedRefreshPresenter fDelayedRefresh; >+ private BugzillaViewExtension fExtension; >+ >+ public TextPane(BugzillaViewExtension extension, Composite parent) { >+ fExtension= extension; >+ fDelayedRefresh= new DelayedRefreshPresenter(); >+ >+ fPageBook= new PageBook(parent, SWT.NONE); >+ //fEmptyControl= new Composite(fPageBook, SWT.NONE); >+ fStyledText= new StyledText(fPageBook, SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY); >+ fSelection= new BugzillaSelection(StructuredSelection.EMPTY); >+ >+ final ActionManager manager= fExtension.getActionManager(); >+ manager.createTextContextMenu(fStyledText); >+ >+ if (parent.getParent() instanceof SashForm) { >+ sashForm = (SashForm)parent.getParent(); >+ hideView(); >+ } >+ } >+ >+ public void selectionChanged(BugzillaSelection selection) { >+ fSelection= selection; >+ >+ final BugzillaModel element= fSelection.getOnlyElement(); >+ fDelayedRefresh.refresh(element); >+ >+ if (element != null) { >+ present(element); >+ } >+ else { >+ hideView(); >+ } >+ } >+ >+ >+ public void elementsAdded(IGenericModel parent, IGenericModel[] children) { >+ } >+ >+ public void elementsChanged(IGenericModel[] elements) { >+ /** >+ * We only update the styled text if the model has just refreshed >+ * and is currently selected. >+ */ >+ final BugzillaModel selected= fSelection.getOnlyElement(); >+ if (selected == null) >+ return; >+ >+ for (int i = 0; i < elements.length; i++) { >+ if (selected == elements[i] && !selected.isRefreshing()) { >+ present(selected); >+ } >+ } >+ } >+ >+ public void elementsRemoved(IGenericModel parent, IGenericModel[] children) { >+ } >+ >+ private void present(BugzillaModel element) { >+ >+ final IPresentableAdapter adapter= getPresentableAdapter(element); >+ if (adapter == null) { >+ hideView(); >+ return; >+ } >+ >+ adapter.present(element, fStyledText); >+ //final boolean hasText= fStyledText.getText().trim().length() != 0; >+ fPageBook.showPage(fStyledText); >+ >+ if (sashForm.getWeights()[1] == 0) { >+ showView(); >+ } >+ } >+ >+ private void showView() { >+ if (sashForm == null) { >+ return; >+ } >+ sashForm.setWeights(userWeights); >+ } >+ >+ private void hideView() { >+ if (sashForm == null) { >+ return; >+ } >+ if ((sashForm.getWeights())[1] != 0) { >+ userWeights = sashForm.getWeights(); >+ } >+ sashForm.setWeights(new int[] {1, 0}); >+ } >+ >+ private IPresentableAdapter getPresentableAdapter(Object o) { >+ if (o instanceof IAdaptable) { >+ return (IPresentableAdapter)((IAdaptable)o).getAdapter(IPresentableAdapter.class); >+ } >+ return null; >+ } >+ >+ public void open(OpenEvent event) { >+ if (!(event.getSelection() instanceof IStructuredSelection)) >+ return; >+ >+ final IStructuredSelection selection= (IStructuredSelection)event.getSelection(); >+ >+ if (!(selection.getFirstElement() instanceof BugzillaModel)) >+ return; >+ >+ final BugzillaModel model= (BugzillaModel)selection.getFirstElement(); >+ >+ final IWebContentAdapter adapter= (IWebContentAdapter)model.getAdapter(IWebContentAdapter.class); >+ if (adapter == null) >+ return; >+ >+ final LocationListener listener= (BugzillaProvider)model.getProvider(); >+ >+ final String url= adapter.getURL(model); >+ if (url != null) { >+ final IWorkbenchPart part= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart(); >+ BugzillaBrowser.open(part, listener, url.replaceAll("format=rdf", "")); >+ } >+ >+ } >+ >+// public String getSelection() { >+// return fStyledText.getSelectionText(); >+// } >+// >+// public boolean hasFocus() { >+// return fStyledText.isFocusControl(); >+// } >+ >+ public StyledText getStyledText() { >+ return fStyledText; >+ } >+ >+ public Control getControl() { >+ return fPageBook; >+ } > } >\ No newline at end of file
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 81795
:
22099
| 22100