Index: C:/workspaces/ws32ga/subclipse-ui/.classpath =================================================================== --- C:/workspaces/ws32ga/subclipse-ui/.classpath (revision 2837) +++ C:/workspaces/ws32ga/subclipse-ui/.classpath (working copy) @@ -2,14 +2,6 @@ - - - - - - - - - + Index: C:/workspaces/ws32ga/subclipse-ui/.settings/org.eclipse.jdt.core.prefs =================================================================== --- C:/workspaces/ws32ga/subclipse-ui/.settings/org.eclipse.jdt.core.prefs (revision 2837) +++ C:/workspaces/ws32ga/subclipse-ui/.settings/org.eclipse.jdt.core.prefs (working copy) @@ -1,4 +1,4 @@ -#Thu Oct 26 10:20:51 EDT 2006 +#Mon Oct 30 15:11:47 CST 2006 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 org.eclipse.jdt.core.compiler.compliance=1.4 Index: C:/workspaces/ws32ga/subclipse-ui/plugin.xml =================================================================== --- C:/workspaces/ws32ga/subclipse-ui/plugin.xml (revision 2837) +++ C:/workspaces/ws32ga/subclipse-ui/plugin.xml (working copy) @@ -1,6 +1,7 @@ + Index: C:/workspaces/ws32ga/subclipse-ui/schema/bugtrackingui.exsd =================================================================== --- C:/workspaces/ws32ga/subclipse-ui/schema/bugtrackingui.exsd (revision 0) +++ C:/workspaces/ws32ga/subclipse-ui/schema/bugtrackingui.exsd (revision 0) @@ -0,0 +1,113 @@ + + + + + + + + + Allows 3rd party extensions to the subclipse UI in order to integrate bug tracking ui in the commit dialog + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The type of issue tracking system this UI provider provides a UI for. This way different extensions can provide a UI for different systems, like Bugzilla, Jira, Scarab, etc. + + + + + + + + The class that provides the UI. Must implement org.tigris.subversion.subclipse.ui.IBugTrackingUIProvider + + + + + + + + + + + + + + + [Enter the first release in which this extension point appears.] + + + + + + + + + [Enter extension point usage example here.] + + + + + + + + + [Enter API information here.] + + + + + + + + + [Enter information about supplied implementation of this extension point.] + + + + + + + + + + + + + Index: C:/workspaces/ws32ga/subclipse-ui/src/org/tigris/subversion/subclipse/ui/BugTrackingUIProviders.java =================================================================== --- C:/workspaces/ws32ga/subclipse-ui/src/org/tigris/subversion/subclipse/ui/BugTrackingUIProviders.java (revision 0) +++ C:/workspaces/ws32ga/subclipse-ui/src/org/tigris/subversion/subclipse/ui/BugTrackingUIProviders.java (revision 0) @@ -0,0 +1,54 @@ +package org.tigris.subversion.subclipse.ui; + +import java.util.HashMap; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtension; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.InvalidRegistryObjectException; +import org.eclipse.core.runtime.Platform; + +/** + * Discover and cache IBugTrackingUIProvider objects from 3rd party plugins + * @author Frank Sauer + * + */ +public class BugTrackingUIProviders { + + private static HashMap providers; + + public static IBugTrackingUIProvider getUIProviderFor(String system) { + if (providers == null) { + providers = new HashMap(); + installProviders(); + } + return (IBugTrackingUIProvider)providers.get(system); + } + + private static void installProviders() { + IExtensionPoint p = Platform.getExtensionRegistry().getExtensionPoint(SVNUIPlugin.ID + ".bugtrackingui"); + if (p != null) { + IExtension[] xs = p.getExtensions(); + for (int i = 0; i < xs.length;i++) { + IConfigurationElement[] elements = xs[i].getConfigurationElements(); + for (int j = 0; j < elements.length; j++) { + IConfigurationElement next = elements[j]; + String kind = next.getName(); + if (kind.equals("bugtraqui")) { + try { + String type = next.getAttribute("type"); + IBugTrackingUIProvider provider = (IBugTrackingUIProvider) next.createExecutableExtension("class"); + providers.put(type, provider); + } catch (InvalidRegistryObjectException e) { + SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e); + } catch (CoreException e) { + SVNUIPlugin.log(e); + } + } + } + } + } + } +} Index: C:/workspaces/ws32ga/subclipse-ui/src/org/tigris/subversion/subclipse/ui/dialogs/CommitDialog.java =================================================================== --- C:/workspaces/ws32ga/subclipse-ui/src/org/tigris/subversion/subclipse/ui/dialogs/CommitDialog.java (revision 2837) +++ C:/workspaces/ws32ga/subclipse-ui/src/org/tigris/subversion/subclipse/ui/dialogs/CommitDialog.java (working copy) @@ -18,6 +18,7 @@ import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IStatus; import org.eclipse.jface.dialogs.TrayDialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogSettings; @@ -57,6 +58,8 @@ import org.tigris.subversion.subclipse.core.ISVNLocalResource; import org.tigris.subversion.subclipse.core.SVNException; import org.tigris.subversion.subclipse.core.resources.SVNWorkspaceRoot; +import org.tigris.subversion.subclipse.ui.BugTrackingUIProviders; +import org.tigris.subversion.subclipse.ui.IBugTrackingUIProvider; import org.tigris.subversion.subclipse.ui.IHelpContextIds; import org.tigris.subversion.subclipse.ui.ISVNUIConstants; import org.tigris.subversion.subclipse.ui.Policy; @@ -94,6 +97,7 @@ private CommentProperties commentProperties; private boolean sharing; + private IBugTrackingUIProvider bugTraqUI; public CommitDialog(Shell parentShell, IResource[] resourcesToCommit, String url, boolean unaddedResources, ProjectProperties projectProperties) { super(parentShell); @@ -157,7 +161,24 @@ } if (projectProperties != null) { - addBugtrackingArea(cTop); + boolean uiCreated = false; + if (projectProperties.getType() != null) { + bugTraqUI = BugTrackingUIProviders.getUIProviderFor(projectProperties.getType()); + if (bugTraqUI != null) { + try { + bugTraqUI.addBugTrackingArea(cTop, projectProperties); + uiCreated = true; + } catch (Exception x) { + // safety: don't let 3rd party extension break me + x.printStackTrace(); + SVNUIPlugin.log(IStatus.ERROR, x.getMessage(), x); + addBugtrackingArea(cTop); + } + } + } + if (!uiCreated) { + addBugtrackingArea(cTop); + } } commitCommentArea.createArea(cTop); @@ -258,7 +279,14 @@ protected void okPressed() { saveLocation(); - if (projectProperties != null) { + if (bugTraqUI != null) { + String errorMessage = bugTraqUI.getMessage(); + if (errorMessage != null) { + MessageDialog.openError(getShell(), Policy.bind("CommitDialog.title"), errorMessage); + return; + } + issue = bugTraqUI.getIssue(); + } else if (projectProperties != null) { issue = issueText.getText().trim(); if (projectProperties.isWarnIfNoIssue() && (issueText.getText().trim().length() == 0)) { if (!MessageDialog.openQuestion(getShell(), Policy.bind("CommitDialog.title"), Policy.bind("CommitDialog.0", projectProperties.getLabel()))) { //$NON-NLS-1$ //$NON-NLS-2$ Index: C:/workspaces/ws32ga/subclipse-ui/src/org/tigris/subversion/subclipse/ui/IBugTrackingUIProvider.java =================================================================== --- C:/workspaces/ws32ga/subclipse-ui/src/org/tigris/subversion/subclipse/ui/IBugTrackingUIProvider.java (revision 0) +++ C:/workspaces/ws32ga/subclipse-ui/src/org/tigris/subversion/subclipse/ui/IBugTrackingUIProvider.java (revision 0) @@ -0,0 +1,25 @@ +package org.tigris.subversion.subclipse.ui; + +import org.eclipse.swt.widgets.Composite; +import org.tigris.subversion.subclipse.ui.settings.ProjectProperties; + +public interface IBugTrackingUIProvider { + + /** + * Used by the bugtrackingprovider extension point to allow 3rd party + * bugtracking ui in the commit dialog + * @param parent SWT Composite to plug in to + * @param properties SVN properties or null if not set + */ + void addBugTrackingArea(Composite parent, ProjectProperties properties); + + /** + * @return null if a valid issue is present, or error message when something is wrong + */ + String getMessage(); + + /** + * @return the selected/entered issue + */ + String getIssue(); +} Index: C:/workspaces/ws32ga/subclipse-ui/src/org/tigris/subversion/subclipse/ui/settings/ProjectProperties.java =================================================================== --- C:/workspaces/ws32ga/subclipse-ui/src/org/tigris/subversion/subclipse/ui/settings/ProjectProperties.java (revision 2837) +++ C:/workspaces/ws32ga/subclipse-ui/src/org/tigris/subversion/subclipse/ui/settings/ProjectProperties.java (working copy) @@ -21,6 +21,8 @@ import org.tigris.subversion.svnclientadapter.ISVNProperty; public class ProjectProperties { + + protected IResource resource; protected String label = "Issue Number:"; //$NON-NLS-1$ protected String message; protected boolean number = false; @@ -27,6 +29,7 @@ protected String url; protected boolean warnIfNoIssue = false; protected boolean append = true; + protected String type; private static final String URL = "://"; //$NON-NLS-1$ @@ -205,7 +208,8 @@ "bugtraq:number: " + number + "\n" + //$NON-NLS-1$ //$NON-NLS-2$ "bugtraq:url: " + url + "\n" + //$NON-NLS-1$ //$NON-NLS-2$ "bugtraq:warnifnoissue: " + warnIfNoIssue + "\n" + //$NON-NLS-1$ //$NON-NLS-2$ - "bugtraq:append: " + append; //$NON-NLS-1$ + "bugtraq:append: " + append + "\n" + //$NON-NLS-1$ //$NON-NLS-2$ + "bugtraq:type:" + type; //$NON-NLS-1$ } // Get ProjectProperties for selected resource. First looks at selected resource, @@ -215,6 +219,7 @@ ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource); ISVNProperty property = null; ISVNProperty labelProperty = null; + ISVNProperty typeProperty = null; if (svnResource != null && svnResource.isManaged()) { try { property = svnResource.getSvnProperty("bugtraq:message"); //$NON-NLS-1$ @@ -219,6 +224,7 @@ try { property = svnResource.getSvnProperty("bugtraq:message"); //$NON-NLS-1$ labelProperty = svnResource.getSvnProperty("bugtraq:label"); //$NON-NLS-1$ + typeProperty = svnResource.getSvnProperty("bugtraq:type"); //$NON-NLS-1$ } catch (SVNException e) { } } @@ -224,8 +230,10 @@ } if ((property != null) && (property.getValue() != null) && (property.getValue().trim().length() > 0)) { ProjectProperties projectProperties = new ProjectProperties(); + projectProperties.setResource(resource); projectProperties.setMessage(property.getValue()); if ((labelProperty != null) && (labelProperty.getValue() != null) && (labelProperty.getValue().trim().length() != 0)) projectProperties.setLabel(labelProperty.getValue()); + if ((typeProperty != null) && (typeProperty.getValue() != null) && (typeProperty.getValue().trim().length() != 0)) projectProperties.setType(typeProperty.getValue()); property = svnResource.getSvnProperty("bugtraq:url"); //$NON-NLS-1$ if (property != null) projectProperties.setUrl(property.getValue()); property = svnResource.getSvnProperty("bugtraq:number"); //$NON-NLS-1$ @@ -254,4 +262,20 @@ public static ProjectProperties getProjectProperties(ISVNRemoteResource remoteResource) { return null; } + + public String getType() { + return type; + } + + void setType(String type) { + this.type = type; + } + + public IResource getResource() { + return resource; + } + + void setResource(IResource resource) { + this.resource = resource; + } } \ No newline at end of file