diff options
author | mkersten | 2007-02-24 05:18:58 +0000 |
---|---|---|
committer | mkersten | 2007-02-24 05:18:58 +0000 |
commit | d04040897b18f4c0d4dc27817a6ac6bdbe74727c (patch) | |
tree | 1dd98cc8f8142a1730424d93c555c12fcd917252 | |
parent | d88abf0d98e44736ab9c3e2a6ff2528e401d0ead (diff) | |
download | org.eclipse.mylyn.tasks-d04040897b18f4c0d4dc27817a6ac6bdbe74727c.tar.gz org.eclipse.mylyn.tasks-d04040897b18f4c0d4dc27817a6ac6bdbe74727c.tar.xz org.eclipse.mylyn.tasks-d04040897b18f4c0d4dc27817a6ac6bdbe74727c.zip |
Version update
43 files changed, 1368 insertions, 391 deletions
diff --git a/org.eclipse.mylyn-feature/feature.xml b/org.eclipse.mylyn-feature/feature.xml index 6f87005e6..e87ecd0ed 100644 --- a/org.eclipse.mylyn-feature/feature.xml +++ b/org.eclipse.mylyn-feature/feature.xml @@ -2,7 +2,7 @@ <feature id="org.eclipse.mylar_feature" label="Mylar Task List (Required)" - version="2.0.0.v20070216" + version="2.0.0.v20070223-1930" provider-name="Eclipse.org" plugin="org.eclipse.mylar"> @@ -237,56 +237,56 @@ litigation. id="org.eclipse.mylar.doc" download-size="0" install-size="0" - version="2.0.0.v20070216" + version="2.0.0.v20070223-1930" unpack="false"/> <plugin id="org.eclipse.mylar" download-size="0" install-size="0" - version="2.0.0.v20070216" + version="2.0.0.v20070223-1930" unpack="false"/> <plugin id="org.eclipse.mylar.context.core" download-size="0" install-size="0" - version="2.0.0.v20070216" + version="2.0.0.v20070223-1930" unpack="false"/> <plugin id="org.eclipse.mylar.tasks.ui" download-size="0" install-size="0" - version="2.0.0.v20070216" + version="2.0.0.v20070223-1930" unpack="false"/> <plugin id="org.eclipse.mylar.tasks.core" download-size="0" install-size="0" - version="2.0.0.v20070216" + version="2.0.0.v20070223-1930" unpack="false"/> <plugin id="org.eclipse.mylar.tasks.web" download-size="0" install-size="0" - version="2.0.0.v20070216" + version="2.0.0.v20070223-1930" unpack="false"/> <plugin id="org.eclipse.mylar.monitor.core" download-size="0" install-size="0" - version="2.0.0.v20070216" + version="2.0.0.v20070223-1930" unpack="false"/> <plugin id="org.eclipse.mylar.monitor.ui" download-size="0" install-size="0" - version="2.0.0.v20070216" + version="2.0.0.v20070223-1930" unpack="false"/> </feature> diff --git a/org.eclipse.mylyn.bugzilla-feature/feature.xml b/org.eclipse.mylyn.bugzilla-feature/feature.xml index 82765c6ea..e0f440c92 100644 --- a/org.eclipse.mylyn.bugzilla-feature/feature.xml +++ b/org.eclipse.mylyn.bugzilla-feature/feature.xml @@ -2,7 +2,7 @@ <feature id="org.eclipse.mylar.bugzilla_feature" label="Mylar Connector: Bugzilla" - version="2.0.0.v20070216" + version="2.0.0.v20070223-1930" provider-name="Eclipse.org" plugin="org.eclipse.mylar"> @@ -243,14 +243,14 @@ litigation. id="org.eclipse.mylar.bugzilla.core" download-size="0" install-size="0" - version="2.0.0.v20070216" + version="2.0.0.v20070223-1930" unpack="false"/> <plugin id="org.eclipse.mylar.bugzilla.ui" download-size="0" install-size="0" - version="2.0.0.v20070216" + version="2.0.0.v20070223-1930" unpack="false"/> </feature> diff --git a/org.eclipse.mylyn.bugzilla.ui/META-INF/MANIFEST.MF b/org.eclipse.mylyn.bugzilla.ui/META-INF/MANIFEST.MF index 96ff9fee5..f8e9a1d1e 100644 --- a/org.eclipse.mylyn.bugzilla.ui/META-INF/MANIFEST.MF +++ b/org.eclipse.mylyn.bugzilla.ui/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Mylar Bugzilla Client Ui Plug-in Bundle-SymbolicName: org.eclipse.mylar.bugzilla.ui; singleton:=true -Bundle-Version: 2.0.0.v20070216 +Bundle-Version: 2.0.0.v20070223-1930 Bundle-Activator: org.eclipse.mylar.internal.bugzilla.ui.BugzillaUiPlugin Bundle-Vendor: Eclipse.org Require-Bundle: org.eclipse.ui, diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditor.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditor.java index 9a5c20e53..bae8bcd56 100644 --- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditor.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditor.java @@ -479,7 +479,7 @@ public class BugzillaTaskEditor extends AbstractRepositoryTaskEditor { GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label); // toolkit.createText(attributesComposite, keywords) - keywordsText = createTextField(attributesComposite, attribute, SWT.FLAT); + keywordsText = createTextField(attributesComposite, attribute, SWT.FLAT | SWT.READ_ONLY); keywordsText.setFont(TEXT_FONT); keywordsText.setEditable(false); // keywordsText.setForeground(foreground); @@ -544,22 +544,21 @@ public class BugzillaTaskEditor extends AbstractRepositoryTaskEditor { layout.marginHeight = 0; layout.marginWidth = 0; votingComposite.setLayout(layout); - // GridDataFactory.fillDefaults().span(2, 1).applyTo(votingComposite); + RepositoryTaskAttribute votesAttribute = taskData.getAttribute(BugzillaReportElement.VOTES.getKeyString()); - // String voteValue = votesAttribute != null ? votesAttribute.getValue() - // : "0"; - votesText = createTextField(votingComposite, votesAttribute, SWT.FLAT); + + votesText = createTextField(votingComposite, votesAttribute, SWT.FLAT | SWT.READ_ONLY); votesText.setFont(TEXT_FONT); if (votesAttribute != null && hasChanged(votesAttribute)) { IThemeManager themeManager = getSite().getWorkbenchWindow().getWorkbench().getThemeManager(); Color backgroundIncoming = themeManager.getCurrentTheme().getColorRegistry().get( TaskListColorsAndFonts.THEME_COLOR_TASKLIST_CATEGORY); - keywordsText.setBackground(backgroundIncoming); + votesText.setBackground(backgroundIncoming); } votesText.setEditable(false); - Hyperlink showVotesHyperlink = toolkit.createHyperlink(votingComposite, "Show votes for this bug", SWT.NONE); + Hyperlink showVotesHyperlink = toolkit.createHyperlink(votingComposite, "Show votes", SWT.NONE); showVotesHyperlink.addHyperlinkListener(new HyperlinkAdapter() { @Override public void linkActivated(HyperlinkEvent e) { @@ -571,7 +570,7 @@ public class BugzillaTaskEditor extends AbstractRepositoryTaskEditor { } }); - Hyperlink voteHyperlink = toolkit.createHyperlink(votingComposite, "Vote for this bug", SWT.NONE); + Hyperlink voteHyperlink = toolkit.createHyperlink(votingComposite, "Vote", SWT.NONE); voteHyperlink.addHyperlinkListener(new HyperlinkAdapter() { @Override public void linkActivated(HyperlinkEvent e) { diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/search/BugzillaSearchPage.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/search/BugzillaSearchPage.java index 85da29ba5..5ba73a9fb 100644 --- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/search/BugzillaSearchPage.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/search/BugzillaSearchPage.java @@ -1757,4 +1757,4 @@ public class BugzillaSearchPage extends AbstractRepositoryQueryPage implements L public void setRestoreQueryOptions(boolean restoreQueryOptions) { this.restoreQueryOptions = restoreQueryOptions; } -}
\ No newline at end of file +} diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaRepositorySettingsPage.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaRepositorySettingsPage.java index 314b6bccf..19a6f6931 100644 --- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaRepositorySettingsPage.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaRepositorySettingsPage.java @@ -12,7 +12,6 @@ package org.eclipse.mylar.internal.bugzilla.ui.tasklist; import java.io.IOException; -import java.lang.reflect.InvocationTargetException; import java.net.MalformedURLException; import java.net.Proxy; import java.net.URL; @@ -22,9 +21,7 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Status; -import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.mylar.core.MylarStatusHandler; -import org.eclipse.mylar.core.net.WebClientUtil; import org.eclipse.mylar.internal.bugzilla.core.BugzillaClient; import org.eclipse.mylar.internal.bugzilla.core.BugzillaClientFactory; import org.eclipse.mylar.internal.bugzilla.core.BugzillaCorePlugin; @@ -188,79 +185,79 @@ public class BugzillaRepositorySettingsPage extends AbstractRepositorySettingsPa return false; } - /* public for testing */ - @Override - public void validateSettings() { - - final String serverUrl = getServerUrl(); - final String newUserId = getUserName(); - final String newPassword = getPassword(); - final boolean isAnonymous = isAnonymousAccess(); - final String newEncoding = getCharacterEncoding(); - final String httpAuthUser = getHttpAuthUserId(); - final String httpAuthPass = getHttpAuthPassword(); - final Proxy tempProxy; - try { - setMessage("Validating server settings..."); - setErrorMessage(null); - if (getUseDefaultProxy()) { - tempProxy = TaskRepository.getSystemProxy(); - } else { - tempProxy = WebClientUtil.getProxy(getProxyHostname(), getProxyPort(), getProxyUsername(), - getProxyPassword()); - } - final boolean checkVersion = repositoryVersionCombo.getSelectionIndex() == 0; - final String[] version = new String[1]; - getWizard().getContainer().run(true, false, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - if (monitor == null) { - monitor = new NullProgressMonitor(); - } - try { - monitor.beginTask("Validating server settings", IProgressMonitor.UNKNOWN); - BugzillaClient client = null; - if (isAnonymous) { - client = BugzillaClientFactory.createClient(serverUrl, newUserId, newPassword, - httpAuthUser, httpAuthPass, tempProxy, newEncoding); - client.logout(); - } else if (version != null) { - client = BugzillaClientFactory.createClient(serverUrl, newUserId, newPassword, - httpAuthUser, httpAuthPass, tempProxy, newEncoding); - client.validate(); - } - if (checkVersion && client != null) { - RepositoryConfiguration config = client.getRepositoryConfiguration(); - if (config != null) { - version[0] = config.getInstallVersion(); - } - } - - } catch (Exception ex) { - throw new InvocationTargetException(ex); - - } finally { - monitor.done(); - } - } - }); - - if (version[0] != null) { - setBugzillaVersion(version[0]); - } - - if (!isAnonymous) { - setMessage("Valid Bugzilla server found and your login was accepted"); - } else { - setMessage("Valid Bugzilla server found"); - } - } catch (InvocationTargetException e) { - setMessage(null); - displayError(serverUrl, e.getTargetException()); - - } catch (InterruptedException e) { - setErrorMessage("Could not connect to Bugzilla server or authentication failed"); - } - } +// /* public for testing */ +// @Override +// public void validateSettings() { +// +// final String serverUrl = getServerUrl(); +// final String newUserId = getUserName(); +// final String newPassword = getPassword(); +// final boolean isAnonymous = isAnonymousAccess(); +// final String newEncoding = getCharacterEncoding(); +// final String httpAuthUser = getHttpAuthUserId(); +// final String httpAuthPass = getHttpAuthPassword(); +// final Proxy tempProxy; +// try { +// setMessage("Validating server settings..."); +// setErrorMessage(null); +// if (getUseDefaultProxy()) { +// tempProxy = TaskRepository.getSystemProxy(); +// } else { +// tempProxy = WebClientUtil.getProxy(getProxyHostname(), getProxyPort(), getProxyUsername(), +// getProxyPassword()); +// } +// final boolean checkVersion = repositoryVersionCombo.getSelectionIndex() == 0; +// final String[] version = new String[1]; +// getWizard().getContainer().run(true, false, new IRunnableWithProgress() { +// public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { +// if (monitor == null) { +// monitor = new NullProgressMonitor(); +// } +// try { +// monitor.beginTask("Validating server settings", IProgressMonitor.UNKNOWN); +// BugzillaClient client = null; +// if (isAnonymous) { +// client = BugzillaClientFactory.createClient(serverUrl, newUserId, newPassword, +// httpAuthUser, httpAuthPass, tempProxy, newEncoding); +// client.logout(); +// } else if (version != null) { +// client = BugzillaClientFactory.createClient(serverUrl, newUserId, newPassword, +// httpAuthUser, httpAuthPass, tempProxy, newEncoding); +// client.validate(); +// } +// if (checkVersion && client != null) { +// RepositoryConfiguration config = client.getRepositoryConfiguration(); +// if (config != null) { +// version[0] = config.getInstallVersion(); +// } +// } +// +// } catch (Exception ex) { +// throw new InvocationTargetException(ex); +// +// } finally { +// monitor.done(); +// } +// } +// }); +// +// if (version[0] != null) { +// setBugzillaVersion(version[0]); +// } +// +// if (!isAnonymous) { +// setMessage("Valid Bugzilla server found and your login was accepted"); +// } else { +// setMessage("Valid Bugzilla server found"); +// } +// } catch (InvocationTargetException e) { +// setMessage(null); +// displayError(serverUrl, e.getTargetException()); +// +// } catch (InterruptedException e) { +// setErrorMessage("Could not connect to Bugzilla server or authentication failed"); +// } +// } private void displayError(final String serverUrl, Throwable e) { IStatus status; @@ -278,4 +275,132 @@ public class BugzillaRepositorySettingsPage extends AbstractRepositorySettingsPa } MylarStatusHandler.displayStatus("Validation failed", status); } + + @Override + protected Validator getValidator(TaskRepository repository) { + + if(repositoryVersionCombo.getSelectionIndex() != 0) { + return new BugzillaValidator(repository, repositoryVersionCombo.getItem(repositoryVersionCombo.getSelectionIndex())); + } else { + return new BugzillaValidator(repository, null); + } + } + +// public String getBugzillaVersion() { +// if (repositoryVersionCombo.getSelectionIndex() == 0) { +// return null; +// } else { +// return repositoryVersionCombo.getItem(repositoryVersionCombo.getSelectionIndex()); +// } +// } + + @Override + protected void applyValidatorResult(Validator validator) { + super.applyValidatorResult(validator); + + if (((BugzillaValidator) validator).getResult() != null && ((BugzillaValidator) validator).getResult() != null) { + setBugzillaVersion(((BugzillaValidator) validator).getResult()); + } + } + + public class BugzillaValidator extends Validator { + + final String serverUrl; + + final String newUserId; + + final String newPassword; + + final boolean isAnonymous; + + final String newEncoding; + + final String httpAuthUser; + + final String httpAuthPass; + + final Proxy proxy; + + private String[] versions = new String[1];; + + public BugzillaValidator(TaskRepository repository, String version) { + serverUrl = getServerUrl(); + newUserId = getUserName(); + newPassword = getPassword(); + isAnonymous = isAnonymousAccess(); + newEncoding = getCharacterEncoding(); + httpAuthUser = getHttpAuthUserId(); + httpAuthPass = getHttpAuthPassword(); + proxy = repository.getProxy(); + versions[0] = version; + } + + public void run(IProgressMonitor monitor) throws CoreException { + try { + validate(monitor); + } catch (Exception e) { + displayError(serverUrl, e); +// IStatus status; +// if (e instanceof MalformedURLException) { +// status = new MylarStatus(Status.WARNING, BugzillaCorePlugin.PLUGIN_ID, +// IMylarStatusConstants.NETWORK_ERROR, "Server URL is invalid."); +// } else if (e instanceof CoreException) { +// status = ((CoreException) e).getStatus(); +// } else if (e instanceof IOException) { +// status = new MylarStatus(Status.WARNING, BugzillaCorePlugin.PLUGIN_ID, +// IMylarStatusConstants.IO_ERROR, serverUrl, e.getMessage()); +// } else { +// status = new MylarStatus(Status.WARNING, BugzillaCorePlugin.PLUGIN_ID, +// IMylarStatusConstants.NETWORK_ERROR, serverUrl, e.getMessage()); +// } +// MylarStatusHandler.displayStatus("Validation failed", status); + } + } + + public void validate(IProgressMonitor monitor) throws IOException, CoreException { + + if (monitor == null) { + monitor = new NullProgressMonitor(); + } + try { + monitor.beginTask("Validating server settings", IProgressMonitor.UNKNOWN); + BugzillaClient client = null; + +// Proxy tempProxy = Proxy.NO_PROXY; +// +// if (getUseDefaultProxy()) { +// tempProxy = TaskRepository.getSystemProxy(); +// } else { +// tempProxy = WebClientUtil.getProxy(getProxyHostname(), getProxyPort(), getProxyUsername(), +// getProxyPassword()); +// } + boolean checkVersion = versions[0] == null; + + if (isAnonymous) { + client = BugzillaClientFactory.createClient(serverUrl, newUserId, newPassword, httpAuthUser, + httpAuthPass, proxy, newEncoding); + client.logout(); + } else if (versions != null) { + client = BugzillaClientFactory.createClient(serverUrl, newUserId, newPassword, httpAuthUser, + httpAuthPass, proxy, newEncoding); + client.validate(); + } + if (checkVersion && client != null) { + RepositoryConfiguration config = client.getRepositoryConfiguration(); + if (config != null) { + versions[0] = config.getInstallVersion(); + } + } + + } finally { + monitor.done(); + } + } + + public String getResult() { + return versions[0]; + } + + } + }
\ No newline at end of file diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaRepositoryUi.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaRepositoryUi.java index 5d708d782..e65efbf50 100644 --- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaRepositoryUi.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaRepositoryUi.java @@ -15,6 +15,7 @@ import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.wizard.IWizard; import org.eclipse.mylar.internal.bugzilla.core.BugzillaCorePlugin; import org.eclipse.mylar.internal.bugzilla.core.BugzillaRepositoryQuery; +import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants; import org.eclipse.mylar.internal.bugzilla.ui.search.BugzillaSearchPage; import org.eclipse.mylar.internal.bugzilla.ui.wizard.NewBugzillaTaskWizard; import org.eclipse.mylar.tasks.core.AbstractRepositoryQuery; @@ -31,7 +32,7 @@ import org.eclipse.mylar.tasks.ui.wizards.AbstractRepositorySettingsPage; public class BugzillaRepositoryUi extends AbstractRepositoryConnectorUi { public String getTaskKindLabel(AbstractRepositoryTask repositoryTask) { - return "Bug"; + return IBugzillaConstants.BUGZILLA_TASK_KIND; } @Override @@ -73,4 +74,4 @@ public class BugzillaRepositoryUi extends AbstractRepositoryConnectorUi { return BugzillaCorePlugin.REPOSITORY_KIND; } -}
\ No newline at end of file +} diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaTaskDecorator.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaTaskDecorator.java index bd046ec3c..759ef49e2 100644 --- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaTaskDecorator.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaTaskDecorator.java @@ -15,8 +15,10 @@ import org.eclipse.jface.viewers.IDecoration; import org.eclipse.jface.viewers.ILabelProviderListener; import org.eclipse.jface.viewers.ILightweightLabelDecorator; import org.eclipse.mylar.internal.bugzilla.core.BugzillaQueryHit; +import org.eclipse.mylar.internal.bugzilla.core.BugzillaReportElement; import org.eclipse.mylar.internal.bugzilla.core.BugzillaTask; import org.eclipse.mylar.internal.bugzilla.ui.BugzillaImages; +import org.eclipse.mylar.tasks.core.RepositoryTaskAttribute; /** * @author Mik Kersten @@ -24,16 +26,23 @@ import org.eclipse.mylar.internal.bugzilla.ui.BugzillaImages; public class BugzillaTaskDecorator implements ILightweightLabelDecorator { public void decorate(Object element, IDecoration decoration) { - if (element instanceof BugzillaTask) { - String kind = ((BugzillaTask)element).getTaskKind(); - // XXX: refactor to use configuration - if ("major".equals(kind) || "blocker".equals(kind) || "critical".equals(kind)) { - decoration.addOverlay(BugzillaImages.OVERLAY_MAJOR, IDecoration.BOTTOM_RIGHT); - } else if ("enhancement".equals(kind)){ - decoration.addOverlay(BugzillaImages.OVERLAY_ENHANCEMENT, IDecoration.BOTTOM_RIGHT); + if (element instanceof BugzillaTask) { + BugzillaTask task = (BugzillaTask) element; + if (task.getTaskData() != null) { + RepositoryTaskAttribute attribute = task.getTaskData().getAttribute( + BugzillaReportElement.BUG_SEVERITY.getKeyString()); + if (attribute != null) { + String severity = attribute.getValue(); + // XXX: refactor to use configuration + if ("major".equals(severity) || "blocker".equals(severity) || "critical".equals(severity)) { + decoration.addOverlay(BugzillaImages.OVERLAY_MAJOR, IDecoration.BOTTOM_RIGHT); + } else if ("enhancement".equals(severity)) { + decoration.addOverlay(BugzillaImages.OVERLAY_ENHANCEMENT, IDecoration.BOTTOM_RIGHT); + } + } } } else if (element instanceof BugzillaQueryHit) { - BugzillaQueryHit hit = (BugzillaQueryHit)element; + BugzillaQueryHit hit = (BugzillaQueryHit) element; if (hit.getCorrespondingTask() != null) { decorate(hit.getCorrespondingTask(), decoration); } diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/NewBugzillaTaskWizard.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/NewBugzillaTaskWizard.java index 6d2eb04a9..0da9e160d 100644 --- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/NewBugzillaTaskWizard.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/NewBugzillaTaskWizard.java @@ -19,6 +19,7 @@ import org.eclipse.mylar.internal.bugzilla.core.BugzillaCorePlugin; import org.eclipse.mylar.internal.bugzilla.ui.BugzillaUiPlugin; import org.eclipse.mylar.internal.tasks.ui.TaskListPreferenceConstants; import org.eclipse.mylar.tasks.core.RepositoryTaskData; +import org.eclipse.mylar.tasks.core.Task; import org.eclipse.mylar.tasks.core.TaskRepository; import org.eclipse.mylar.tasks.ui.TasksUiPlugin; import org.eclipse.mylar.tasks.ui.TasksUiUtil; @@ -56,7 +57,7 @@ public class NewBugzillaTaskWizard extends Wizard implements INewWizard { public NewBugzillaTaskWizard(TaskRepository repository) { this(false, repository); taskData = new RepositoryTaskData(new BugzillaAttributeFactory(), BugzillaCorePlugin.REPOSITORY_KIND, - repository.getUrl(), TasksUiPlugin.getDefault().getNextNewRepositoryTaskId()); + repository.getUrl(), TasksUiPlugin.getDefault().getNextNewRepositoryTaskId(), Task.DEFAULT_TASK_KIND); taskData.setNew(true); super.setDefaultPageImageDescriptor(BugzillaUiPlugin.imageDescriptorFromPlugin( "org.eclipse.mylar.internal.bugzilla.ui", "icons/wizban/bug-wizard.gif")); @@ -96,7 +97,7 @@ public class NewBugzillaTaskWizard extends Wizard implements INewWizard { return true; } catch (Exception e) { productPage.applyToStatusLine(new Status(IStatus.ERROR, "not_used", 0, - "Problem occured retrieving repository configuration from " + repository.getUrl(), null)); + "Problem occurred retrieving repository configuration from " + repository.getUrl(), null)); } return false; } diff --git a/org.eclipse.mylyn.tasks.ui/META-INF/MANIFEST.MF b/org.eclipse.mylyn.tasks.ui/META-INF/MANIFEST.MF index 6046856d2..d4c296eaf 100644 --- a/org.eclipse.mylyn.tasks.ui/META-INF/MANIFEST.MF +++ b/org.eclipse.mylyn.tasks.ui/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Mylar Tasks UI Plug-in Bundle-SymbolicName: org.eclipse.mylar.tasks.ui;singleton:=true -Bundle-Version: 2.0.0.v20070216 +Bundle-Version: 2.0.0.v20070223-1930 Bundle-Activator: org.eclipse.mylar.tasks.ui.TasksUiPlugin Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, diff --git a/org.eclipse.mylyn.tasks.ui/icons/etool16/task-repository-history.gif b/org.eclipse.mylyn.tasks.ui/icons/etool16/task-repository-history.gif Binary files differnew file mode 100644 index 000000000..829d0797d --- /dev/null +++ b/org.eclipse.mylyn.tasks.ui/icons/etool16/task-repository-history.gif diff --git a/org.eclipse.mylyn.tasks.ui/icons/eview16/overlay-due.gif b/org.eclipse.mylyn.tasks.ui/icons/eview16/overlay-due.gif Binary files differnew file mode 100644 index 000000000..8ec39c96f --- /dev/null +++ b/org.eclipse.mylyn.tasks.ui/icons/eview16/overlay-due.gif diff --git a/org.eclipse.mylyn.tasks.ui/plugin.xml b/org.eclipse.mylyn.tasks.ui/plugin.xml index 7ca1af544..3b5663c6f 100644 --- a/org.eclipse.mylyn.tasks.ui/plugin.xml +++ b/org.eclipse.mylyn.tasks.ui/plugin.xml @@ -4,6 +4,7 @@ <extension-point id="actions" name="Tasklist Actions" schema="schema/actions.exsd"/> <extension-point id="repositories" name="Task Repositories" schema="schema/repositories.exsd"/> <extension-point id="editors" name="Task Editors" schema="schema/editors.exsd"/> + <extension-point id="projectLinkProviders" name="Linking Provider from Project to the Task Repository" schema="schema/projectLinkProviders.exsd"/> <!-- <extension @@ -706,6 +707,15 @@ </commandParameter> </command> </extension> + <extension + point="org.eclipse.mylar.tasks.ui.projectLinkProviders"> + <linkProvider + class="org.eclipse.mylar.tasks.ui.ProjectPreferencesLinkProvider" + name="Default Repository Link" + order="1000" + id="org.eclipse.mylar.tasks.ui.defaultRepositoryLinkProvider"> + </linkProvider> + </extension> </plugin> @@ -733,4 +743,4 @@ class="org.eclipse.mylar.tasklist.ui.actions.GoIntoAction" icon="icons/etool16/go-into.gif" enablesFor="1"/> ---> +-->
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.ui/schema/projectLinkProviders.exsd b/org.eclipse.mylyn.tasks.ui/schema/projectLinkProviders.exsd new file mode 100644 index 000000000..2f89daec4 --- /dev/null +++ b/org.eclipse.mylyn.tasks.ui/schema/projectLinkProviders.exsd @@ -0,0 +1,126 @@ +<?xml version='1.0' encoding='UTF-8'?> +<!-- Schema file written by PDE --> +<schema targetNamespace="org.eclipse.mylar.tasks.ui"> +<annotation> + <appInfo> + <meta.schema plugin="org.eclipse.mylar.tasks.ui" id="projectLinkProviders" name="Task Repository Link Provider"/> + </appInfo> + <documentation> + Providers responsible for linking Workspace resources/projects to the Task Repositories. + </documentation> + </annotation> + + <element name="extension"> + <complexType> + <sequence> + <element ref="linkProvider"/> + </sequence> + <attribute name="point" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="id" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute translatable="true"/> + </appInfo> + </annotation> + </attribute> + </complexType> + </element> + + <element name="linkProvider"> + <complexType> + <attribute name="id" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="class" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute kind="java" basedOn="org.eclipse.mylar.tasks.ui.AbstractTaskRepositoryLinkProvider"/> + </appInfo> + </annotation> + </attribute> + <attribute name="order" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + </complexType> + </element> + + <annotation> + <appInfo> + <meta.section type="since"/> + </appInfo> + <documentation> + [Enter the first release in which this extension point appears.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="examples"/> + </appInfo> + <documentation> + [Enter extension point usage example here.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="apiInfo"/> + </appInfo> + <documentation> + See org.eclipse.mylar.tasks.ui.TasksUiPlugin.getRepositoryForResource(IResource resource, boolean silent) + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="implementation"/> + </appInfo> + <documentation> + [Enter information about supplied implementation of this extension point.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="copyright"/> + </appInfo> + <documentation> + + </documentation> + </annotation> + +</schema> diff --git a/org.eclipse.mylyn.tasks.ui/schema/repositories.exsd b/org.eclipse.mylyn.tasks.ui/schema/repositories.exsd index cf63fd355..15d203492 100644 --- a/org.eclipse.mylyn.tasks.ui/schema/repositories.exsd +++ b/org.eclipse.mylyn.tasks.ui/schema/repositories.exsd @@ -127,6 +127,13 @@ </documentation> </annotation> </attribute> + <attribute name="userManaged" type="boolean"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> </complexType> </element> diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/RepositoryTaskDecorator.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/RepositoryTaskDecorator.java index f0ede2eb0..3fea719cc 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/RepositoryTaskDecorator.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/RepositoryTaskDecorator.java @@ -62,18 +62,25 @@ public class RepositoryTaskDecorator implements ILightweightLabelDecorator { } else { decoration.addOverlay(TaskListImages.OVERLAY_REPOSITORY, IDecoration.BOTTOM_LEFT); } - } + } if (task.isSynchronizing()) { decoration.addOverlay(TaskListImages.OVERLAY_SYNCHRONIZING, IDecoration.TOP_LEFT); } + if (!task.isCompleted() && TasksUiPlugin.getTaskListManager().isDue(task)) { + decoration.addOverlay(TaskListImages.OVERLAY_DUE, IDecoration.TOP_LEFT); + } } else if (element instanceof AbstractQueryHit) { ITask correspondingTask = ((AbstractQueryHit) element).getCorrespondingTask(); decorate(correspondingTask, decoration); } else if (element instanceof ITask) { - String url = ((ITask) element).getTaskUrl(); + ITask task = (ITask) element; + String url = task.getTaskUrl(); if (url != null && !url.trim().equals("") && !url.equals("http://")) { decoration.addOverlay(TaskListImages.OVERLAY_WEB, IDecoration.BOTTOM_LEFT); } + if (!task.isCompleted() && TasksUiPlugin.getTaskListManager().isDue(task)) { + decoration.addOverlay(TaskListImages.OVERLAY_DUE, IDecoration.TOP_LEFT); + } } else if (element instanceof TaskRepository) { ImageDescriptor overlay = TasksUiPlugin.getDefault().getOverlayIcon(((TaskRepository) element).getKind()); if (overlay != null) { diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListImages.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListImages.java index a4ecced34..0b3557aa3 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListImages.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListImages.java @@ -69,6 +69,8 @@ public class TaskListImages { public static final ImageDescriptor TASK_NOTES = createSize(create(T_TOOL, "task-notes.gif"), SIZE); + public static final ImageDescriptor TASK_REPOSITORY_HISTORY = createSize(create(T_TOOL, "task-repository-history.gif"), SIZE); + public static final ImageDescriptor TASK_REPOSITORY_NOTES = createSize(create(T_TOOL, "task-repository-notes.gif"), SIZE); public static final ImageDescriptor TASK_REPOSITORY_COMPLETED = createSize(create(T_TOOL, "task-repository-completed.gif"), SIZE); @@ -78,6 +80,8 @@ public class TaskListImages { public static final ImageDescriptor OVERLAY_WEB = create(T_TOOL, "overlay-web.gif"); public static final ImageDescriptor OVERLAY_SYNCHRONIZING = create(T_EVIEW, "overlay-synchronizing.gif"); + + public static final ImageDescriptor OVERLAY_DUE = create(T_EVIEW, "overlay-due.gif"); public static final ImageDescriptor TASK_WEB = createWithOverlay(TASK, OVERLAY_WEB, false, true); diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskSearchPage.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskSearchPage.java index 24a1c61f8..073160037 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskSearchPage.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskSearchPage.java @@ -48,6 +48,8 @@ import org.eclipse.ui.forms.widgets.Hyperlink; * @author Mik Kersten */ public class TaskSearchPage extends DialogPage implements ISearchPage { + + public static final String ID = "org.eclipse.mylar.tasks.ui.core.search.page"; private static final String PAGE_KEY = "page"; diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/AbstractTaskRepositoryAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/AbstractTaskRepositoryAction.java new file mode 100644 index 000000000..8a9d3def9 --- /dev/null +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/AbstractTaskRepositoryAction.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2004 - 2006 Mylar committers and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.eclipse.mylar.internal.tasks.ui.actions; + +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.mylar.tasks.core.AbstractRepositoryConnector; +import org.eclipse.mylar.tasks.core.TaskRepository; +import org.eclipse.mylar.tasks.ui.TasksUiPlugin; +import org.eclipse.ui.actions.BaseSelectionListenerAction; + +/** + * @author Shawn Minto + */ +public abstract class AbstractTaskRepositoryAction extends BaseSelectionListenerAction { + + public AbstractTaskRepositoryAction(String text) { + super(text); + } + + @Override + protected boolean updateSelection(IStructuredSelection selection) { + if (selection != null && !selection.isEmpty()) { + Object selectedObject = selection.getFirstElement(); + if (selectedObject instanceof TaskRepository) { + TaskRepository taskRepository = (TaskRepository) selectedObject; + AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager().getRepositoryConnector( + taskRepository.getKind()); + if (connector.isUserManaged()) { + return true; + } + return false; + } + } + return false; + } + +} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/DeleteTaskRepositoryAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/DeleteTaskRepositoryAction.java index 16c0cb92e..6cc5c2d15 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/DeleteTaskRepositoryAction.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/DeleteTaskRepositoryAction.java @@ -24,13 +24,12 @@ import org.eclipse.mylar.tasks.ui.TasksUiPlugin; import org.eclipse.ui.ISharedImages; import org.eclipse.ui.IViewPart; import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.BaseSelectionListenerAction; import org.eclipse.ui.internal.WorkbenchImages; /** * @author Mik Kersten */ -public class DeleteTaskRepositoryAction extends BaseSelectionListenerAction { +public class DeleteTaskRepositoryAction extends AbstractTaskRepositoryAction { private static final String ID = "org.eclipse.mylar.tasklist.repositories.delete"; @@ -41,11 +40,6 @@ public class DeleteTaskRepositoryAction extends BaseSelectionListenerAction { setEnabled(false); } - @Override - protected boolean updateSelection(IStructuredSelection selection) { - return selection != null && !selection.isEmpty(); - } - public void init(IViewPart view) { // ignore } diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/EditRepositoryPropertiesAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/EditRepositoryPropertiesAction.java index 3d0ce06a1..ee80c58bc 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/EditRepositoryPropertiesAction.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/EditRepositoryPropertiesAction.java @@ -12,14 +12,15 @@ package org.eclipse.mylar.internal.tasks.ui.actions; import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.mylar.tasks.core.AbstractRepositoryConnector; import org.eclipse.mylar.tasks.core.TaskRepository; +import org.eclipse.mylar.tasks.ui.TasksUiPlugin; import org.eclipse.mylar.tasks.ui.TasksUiUtil; -import org.eclipse.ui.actions.BaseSelectionListenerAction; /** * @author Mik Kersten */ -public class EditRepositoryPropertiesAction extends BaseSelectionListenerAction { +public class EditRepositoryPropertiesAction extends AbstractTaskRepositoryAction { private static final String ID = "org.eclipse.mylar.tasklist.repositories.properties"; @@ -31,7 +32,18 @@ public class EditRepositoryPropertiesAction extends BaseSelectionListenerAction @Override protected boolean updateSelection(IStructuredSelection selection) { - return selection != null && !selection.isEmpty(); + if(selection != null && !selection.isEmpty()){ + Object selectedObject = selection.getFirstElement(); + if(selectedObject instanceof TaskRepository){ + TaskRepository taskRepository = (TaskRepository) selectedObject; + AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager().getRepositoryConnector(taskRepository.getKind()); + if(connector.isUserManaged()){ + return true; + } + return false; + } + } + return false; } @Override diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskPlanningEditor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskPlanningEditor.java index f47a1768d..73df61607 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskPlanningEditor.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskPlanningEditor.java @@ -39,6 +39,7 @@ import org.eclipse.mylar.tasks.ui.editors.TaskEditor; import org.eclipse.mylar.tasks.ui.editors.TaskEditorInput; import org.eclipse.mylar.tasks.ui.editors.TaskFormPage; import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CCombo; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.events.ModifyEvent; @@ -49,7 +50,6 @@ import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; @@ -61,9 +61,12 @@ import org.eclipse.ui.forms.FormColors; import org.eclipse.ui.forms.IManagedForm; import org.eclipse.ui.forms.editor.FormEditor; import org.eclipse.ui.forms.events.ExpansionEvent; +import org.eclipse.ui.forms.events.HyperlinkAdapter; +import org.eclipse.ui.forms.events.HyperlinkEvent; import org.eclipse.ui.forms.events.IExpansionListener; import org.eclipse.ui.forms.widgets.ExpandableComposite; import org.eclipse.ui.forms.widgets.FormToolkit; +import org.eclipse.ui.forms.widgets.ImageHyperlink; import org.eclipse.ui.forms.widgets.ScrolledForm; import org.eclipse.ui.forms.widgets.Section; @@ -74,6 +77,8 @@ import org.eclipse.ui.forms.widgets.Section; */ public class TaskPlanningEditor extends TaskFormPage { + private static final String LABEL_DUE = "Due:"; + public static final String PLANNING_EDITOR_ID = "org.eclipse.mylar.editors.planning"; private static final String LABEL_SCHEDULE = "Scheduled for:"; @@ -93,6 +98,8 @@ public class TaskPlanningEditor extends TaskFormPage { private static final String LABEL_NOTES = "Notes"; + private DatePicker dueDatePicker; + private DatePicker datePicker; private ITask task; @@ -101,8 +108,6 @@ public class TaskPlanningEditor extends TaskFormPage { protected static final String CONTEXT_MENU_ID = "#MylarPlanningEditor"; - private Button removeReminder; - private Text pathText; private Text endDate; @@ -113,9 +118,9 @@ public class TaskPlanningEditor extends TaskFormPage { private Text issueReportURL; - private Combo priorityCombo; + private CCombo priorityCombo; - private Combo statusCombo; + private CCombo statusCombo; private TextViewer noteEditor; @@ -255,6 +260,11 @@ public class TaskPlanningEditor extends TaskFormPage { } else { TasksUiPlugin.getTaskListManager().setScheduledFor(task, null); } + if (dueDatePicker != null && dueDatePicker.getDate() != null) { + TasksUiPlugin.getTaskListManager().setDueDate(task, dueDatePicker.getDate().getTime()); + } else { + TasksUiPlugin.getTaskListManager().setDueDate(task, null); + } if (parentEditor != null) { parentEditor.notifyTaskChanged(); @@ -290,7 +300,9 @@ public class TaskPlanningEditor extends TaskFormPage { // toolkit.decorateFormHeading(form.getForm()); editorComposite = form.getBody(); - editorComposite.setLayout(new GridLayout()); + GridLayout editorLayout = new GridLayout(); + editorLayout.verticalSpacing = 0; + editorComposite.setLayout(editorLayout); editorComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); // try { if (task instanceof AbstractRepositoryTask) { @@ -322,19 +334,40 @@ public class TaskPlanningEditor extends TaskFormPage { return form; } + private Text addNameValueComp(Composite parent, String label, String value, int style) { + Composite nameValueComp = toolkit.createComposite(parent); + GridLayout layout = new GridLayout(2, false); + layout.marginHeight = 3; + nameValueComp.setLayout(layout); + toolkit.createLabel(nameValueComp, label, SWT.NONE).setForeground( + toolkit.getColors().getColor(FormColors.TITLE)); + Text text; + if ((SWT.READ_ONLY & style) == SWT.READ_ONLY) { + text = new Text(nameValueComp, style); + toolkit.adapt(text, true, true); + text.setText(value); + } else { + text = toolkit.createText(nameValueComp, value, style); + } + return text; + } + private void createSummarySection(Composite parent) { - Composite container = toolkit.createComposite(parent); - GridLayout compLayout = new GridLayout(); - compLayout.numColumns = 2; - container.setLayout(compLayout); - container.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - summary = toolkit.createText(container, task.getSummary(), SWT.NONE); + // Summary + Composite summaryComposite = toolkit.createComposite(parent); + GridLayout summaryLayout = new GridLayout(2, false); + summaryLayout.verticalSpacing = 0; + summaryLayout.marginHeight = 0; + //summaryLayout.marginLeft = 5; + summaryComposite.setLayout(summaryLayout); + GridDataFactory.fillDefaults().grab(true, false).applyTo(summaryComposite); + + summary = toolkit.createText(summaryComposite, task.getSummary(), SWT.NONE); summary.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); GridData summaryGridData = new GridData(GridData.FILL_HORIZONTAL); - summaryGridData.horizontalSpan = 2; + summaryGridData.horizontalSpan = 7; summary.setLayoutData(summaryGridData); - toolkit.paintBordersFor(container); if (task instanceof AbstractRepositoryTask) { summary.setEnabled(false); @@ -345,13 +378,24 @@ public class TaskPlanningEditor extends TaskFormPage { } }); } + toolkit.paintBordersFor(summaryComposite); - toolkit.createLabel(container, "Status:").setForeground(toolkit.getColors().getColor(FormColors.TITLE));; - Composite statusComposite = toolkit.createComposite(container); - statusComposite.setLayout(new GridLayout(6, false)); + Composite statusComposite = toolkit.createComposite(parent); + GridLayout compLayout = new GridLayout(7, false); + compLayout.verticalSpacing = 0; + compLayout.horizontalSpacing = 5; + compLayout.marginHeight = 3; + statusComposite.setLayout(compLayout); statusComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - priorityCombo = new Combo(statusComposite, SWT.READ_ONLY); + Composite nameValueComp = toolkit.createComposite(statusComposite); + GridLayout nameValueLayout = new GridLayout(2, false); + nameValueLayout.marginHeight = 3; + nameValueComp.setLayout(nameValueLayout); + toolkit.createLabel(nameValueComp, "Priority:").setForeground(toolkit.getColors().getColor(FormColors.TITLE)); + priorityCombo = new CCombo(nameValueComp, SWT.FLAT); + priorityCombo.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); + toolkit.paintBordersFor(nameValueComp); // Populate the combo box with priority levels for (String priorityLevel : TaskListView.PRIORITY_LEVEL_DESCRIPTIONS) { @@ -367,22 +411,21 @@ public class TaskPlanningEditor extends TaskFormPage { if (task instanceof AbstractRepositoryTask) { priorityCombo.setEnabled(false); } else { - priorityCombo.addSelectionListener(new SelectionListener() { + priorityCombo.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { TaskPlanningEditor.this.markDirty(true); } - - public void widgetDefaultSelected(SelectionEvent e) { - // do nothing - - } }); } - statusCombo = new Combo(statusComposite, SWT.READ_ONLY); - + nameValueComp = toolkit.createComposite(statusComposite); + nameValueComp.setLayout(new GridLayout(2, false)); + toolkit.createLabel(nameValueComp, "Status:").setForeground(toolkit.getColors().getColor(FormColors.TITLE)); + statusCombo = new CCombo(nameValueComp, SWT.FLAT); + statusCombo.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); + toolkit.paintBordersFor(nameValueComp); statusCombo.add(LABEL_COMPLETE); statusCombo.add(LABEL_INCOMPLETE); if (task.isCompleted()) { @@ -393,7 +436,7 @@ public class TaskPlanningEditor extends TaskFormPage { if (task instanceof AbstractRepositoryTask) { statusCombo.setEnabled(false); } else { - statusCombo.addSelectionListener(new SelectionListener() { + statusCombo.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (statusCombo.getSelectionIndex() == 0) { @@ -403,17 +446,69 @@ public class TaskPlanningEditor extends TaskFormPage { } TaskPlanningEditor.this.markDirty(true); } + }); + } - public void widgetDefaultSelected(SelectionEvent e) { - // do nothing + String creationDateString = ""; + try { + creationDateString = DateFormat.getDateInstance(DateFormat.LONG).format(task.getCreationDate()); + } catch (RuntimeException e) { + MylarStatusHandler.fail(e, "Could not format creation date", true); + } + addNameValueComp(statusComposite, "Created:", creationDateString, SWT.FLAT | SWT.READ_ONLY); - } - }); + nameValueComp = makeComposite(statusComposite, 3); + Label label = toolkit.createLabel(nameValueComp, LABEL_DUE); + label.setForeground(toolkit.getColors().getColor(FormColors.TITLE)); + + dueDatePicker = new DatePicker(nameValueComp, SWT.FLAT, DatePicker.LABEL_CHOOSE); + + Calendar calendar = Calendar.getInstance(); + if (task.getDueDate() != null) { + calendar.setTime(task.getDueDate()); + dueDatePicker.setDate(calendar); } - Label label = toolkit.createLabel(statusComposite, "URL:"); + dueDatePicker.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE)); + dueDatePicker.addPickerSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent arg0) { + TaskPlanningEditor.this.markDirty(true); + } + }); + + dueDatePicker.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); + toolkit.adapt(dueDatePicker, true, true); + toolkit.paintBordersFor(nameValueComp); + + ImageHyperlink clearDueDate = toolkit.createImageHyperlink(nameValueComp, SWT.NONE); + clearDueDate.setImage(TaskListImages.getImage(TaskListImages.REMOVE)); + clearDueDate.setToolTipText("clear"); + clearDueDate.addHyperlinkListener(new HyperlinkAdapter() { + + @Override + public void linkActivated(HyperlinkEvent e) { + dueDatePicker.setDate(null); + TaskPlanningEditor.this.markDirty(true); + } + }); + + String completionDateString = ""; + if (task.isCompleted()) { + completionDateString = getTaskDateString(task); + } + endDate = addNameValueComp(statusComposite, "Completed:", completionDateString, SWT.FLAT | SWT.READ_ONLY); + // URL + Composite urlComposite = toolkit.createComposite(parent); + GridLayout urlLayout = new GridLayout(3, false); + urlLayout.verticalSpacing = 0; + urlLayout.marginHeight = 2; + urlLayout.marginLeft = 5; + urlComposite.setLayout(urlLayout); + GridDataFactory.fillDefaults().grab(true, false).applyTo(urlComposite); + + label = toolkit.createLabel(urlComposite, "URL:"); label.setForeground(toolkit.getColors().getColor(FormColors.TITLE)); - issueReportURL = toolkit.createText(statusComposite, task.getTaskUrl(), SWT.FLAT); + issueReportURL = toolkit.createText(urlComposite, task.getTaskUrl(), SWT.FLAT); issueReportURL.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); if (task instanceof AbstractRepositoryTask) { @@ -426,9 +521,8 @@ public class TaskPlanningEditor extends TaskFormPage { }); } - getDescButton = toolkit.createButton(statusComposite, "Get Description", SWT.PUSH); + getDescButton = toolkit.createButton(urlComposite, "Get Description", SWT.FLAT | SWT.PUSH); getDescButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); - toolkit.paintBordersFor(container); setButtonStatus(); issueReportURL.addKeyListener(new KeyListener() { @@ -449,6 +543,7 @@ public class TaskPlanningEditor extends TaskFormPage { public void widgetDefaultSelected(SelectionEvent e) { } }); + toolkit.paintBordersFor(urlComposite); toolkit.paintBordersFor(statusComposite); } @@ -515,17 +610,18 @@ public class TaskPlanningEditor extends TaskFormPage { Composite sectionClient = toolkit.createComposite(section); section.setClient(sectionClient); GridLayout layout = new GridLayout(); - layout.numColumns = 6; + layout.numColumns = 3; + layout.horizontalSpacing = 15; layout.makeColumnsEqualWidth = false; sectionClient.setLayout(layout); GridData clientDataLayout = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); sectionClient.setLayoutData(clientDataLayout); - // Reminder - Label label = toolkit.createLabel(sectionClient, LABEL_SCHEDULE); + Composite nameValueComp = makeComposite(sectionClient, 3); + Label label = toolkit.createLabel(nameValueComp, LABEL_SCHEDULE); label.setForeground(toolkit.getColors().getColor(FormColors.TITLE)); - datePicker = new DatePicker(sectionClient, SWT.NONE, DatePicker.LABEL_CHOOSE); + datePicker = new DatePicker(nameValueComp, SWT.FLAT, DatePicker.LABEL_CHOOSE); Calendar calendar = Calendar.getInstance(); if (task.getScheduledForDate() != null) { @@ -544,49 +640,33 @@ public class TaskPlanningEditor extends TaskFormPage { // ignore } }); + datePicker.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); + toolkit.adapt(datePicker, true, true); + toolkit.paintBordersFor(nameValueComp); + + + + ImageHyperlink clearScheduledDate = toolkit.createImageHyperlink(nameValueComp, SWT.NONE); + clearScheduledDate.setImage(TaskListImages.getImage(TaskListImages.REMOVE)); + clearScheduledDate.setToolTipText("clear"); + clearScheduledDate.addHyperlinkListener(new HyperlinkAdapter() { - removeReminder = toolkit.createButton(sectionClient, "Clear", SWT.PUSH | SWT.CENTER); - removeReminder.addSelectionListener(new SelectionAdapter() { @Override - public void widgetSelected(SelectionEvent e) { + public void linkActivated(HyperlinkEvent e) { datePicker.setDate(null); task.setReminded(false); TaskPlanningEditor.this.markDirty(true); } }); - - // 1 Blank column after Reminder clear button - Label dummy = toolkit.createLabel(sectionClient, ""); - GridData dummyLabelDataLayout = new GridData(GridData.HORIZONTAL_ALIGN_CENTER); - dummyLabelDataLayout.horizontalSpan = 1; - dummyLabelDataLayout.widthHint = 30; - dummy.setLayoutData(dummyLabelDataLayout); - - // Creation date - label = toolkit.createLabel(sectionClient, "Creation date:"); - label.setForeground(toolkit.getColors().getColor(FormColors.TITLE)); - - String creationDateString = ""; - try { - creationDateString = DateFormat.getDateInstance(DateFormat.LONG).format(task.getCreationDate()); - } catch (RuntimeException e) { - MylarStatusHandler.fail(e, "Could not format creation date", true); - } - - Text creationDate = toolkit.createText(sectionClient, creationDateString, SWT.NONE); - GridData creationDateDataLayout = new GridData(); - creationDateDataLayout.widthHint = 120; - creationDate.setLayoutData(creationDateDataLayout); - creationDate.setEditable(false); - creationDate.setEnabled(true); - + // Estimated time - - label = toolkit.createLabel(sectionClient, "Estimated time:"); + nameValueComp = makeComposite(sectionClient, 3); + label = toolkit.createLabel(nameValueComp, "Estimated time:"); label.setForeground(toolkit.getColors().getColor(FormColors.TITLE)); - estimated = new Spinner(sectionClient, SWT.NONE); + estimated = new Spinner(nameValueComp, SWT.NONE); + toolkit.adapt(estimated, true, true); estimated.setSelection(task.getEstimateTimeHours()); estimated.setDigits(0); estimated.setMaximum(100); @@ -599,54 +679,22 @@ public class TaskPlanningEditor extends TaskFormPage { }); estimated.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); + toolkit.paintBordersFor(nameValueComp); GridData estimatedDataLayout = new GridData(); - estimatedDataLayout.widthHint = 110; + estimatedDataLayout.widthHint = 30; estimated.setLayoutData(estimatedDataLayout); - label = toolkit.createLabel(sectionClient, "hours "); + label = toolkit.createLabel(nameValueComp, "hours "); label.setForeground(toolkit.getColors().getColor(FormColors.TITLE)); - // 1 Blank column - Label blankLabel2 = toolkit.createLabel(sectionClient, ""); - GridData blankLabl2Layout = new GridData(GridData.HORIZONTAL_ALIGN_CENTER); - blankLabl2Layout.horizontalSpan = 1; - blankLabl2Layout.widthHint = 25; - blankLabel2.setLayoutData(blankLabl2Layout); - - // Completion date - label = toolkit.createLabel(sectionClient, "Completion date:"); - label.setForeground(toolkit.getColors().getColor(FormColors.TITLE)); - - String completionDateString = ""; - if (task.isCompleted()) { - completionDateString = getTaskDateString(task); - } - endDate = toolkit.createText(sectionClient, completionDateString, SWT.NONE); - GridData endDateDataLayout = new GridData(); - endDateDataLayout.widthHint = 120; - endDate.setLayoutData(endDateDataLayout); - - endDate.setEditable(false); - endDate.setEnabled(true); - toolkit.paintBordersFor(sectionClient); - - // Elapsed Time - - label = toolkit.createLabel(sectionClient, "Active time:"); + // Active Time + nameValueComp = makeComposite(sectionClient, 3); + // GridDataFactory.fillDefaults().span(2, 1).align(SWT.LEFT, + // SWT.DEFAULT).applyTo(nameValueComp); + label = toolkit.createLabel(nameValueComp, "Active time:"); label.setForeground(toolkit.getColors().getColor(FormColors.TITLE)); label.setToolTipText(DESCRIPTION_ESTIMATED); - Composite elapsedComposite = toolkit.createComposite(sectionClient); - GridLayout elapsedLayout = new GridLayout(); - elapsedLayout.numColumns = 2; - elapsedLayout.marginWidth = 0; - elapsedLayout.marginHeight = 1; - elapsedLayout.makeColumnsEqualWidth = false; - elapsedComposite.setLayout(elapsedLayout); - GridData elapsedCompositeGridData = new GridData(); - elapsedCompositeGridData.horizontalSpan = 5; - elapsedComposite.setLayoutData(elapsedCompositeGridData); - String elapsedTimeString = NO_TIME_ELAPSED; try { elapsedTimeString = DateUtil.getFormattedDuration(TasksUiPlugin.getTaskListManager().getElapsedTime(task), @@ -657,14 +705,16 @@ public class TaskPlanningEditor extends TaskFormPage { MylarStatusHandler.fail(e, "Could not format elapsed time", true); } - final Text elapsedTimeText = toolkit.createText(elapsedComposite, elapsedTimeString, SWT.NONE); + final Text elapsedTimeText = new Text(nameValueComp, SWT.READ_ONLY | SWT.FLAT); + elapsedTimeText.setText(elapsedTimeString); GridData td = new GridData(GridData.FILL_HORIZONTAL); td.widthHint = 120; elapsedTimeText.setLayoutData(td); elapsedTimeText.setEditable(false); // Refresh Button - Button timeRefresh = toolkit.createButton(elapsedComposite, "Refresh", SWT.PUSH | SWT.CENTER); + Button timeRefresh = toolkit.createButton(nameValueComp, "Refresh", SWT.PUSH | SWT.CENTER); + // timeRefresh.setImage(TaskListImages.getImage(TaskListImages.REFRESH)); timeRefresh.addSelectionListener(new SelectionAdapter() { @Override @@ -684,7 +734,15 @@ public class TaskPlanningEditor extends TaskFormPage { } }); - toolkit.paintBordersFor(elapsedComposite); + toolkit.paintBordersFor(sectionClient); + } + + private Composite makeComposite(Composite parent, int col) { + Composite nameValueComp = toolkit.createComposite(parent); + GridLayout layout = new GridLayout(3, false); + layout.marginHeight = 3; + nameValueComp.setLayout(layout); + return nameValueComp; } private void createNotesSection(Composite parent) { @@ -825,4 +883,4 @@ public class TaskPlanningEditor extends TaskFormPage { return form.getText(); } -}
\ No newline at end of file +} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiExtensionReader.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiExtensionReader.java index 60f9a06b8..92bf1f10f 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiExtensionReader.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiExtensionReader.java @@ -28,6 +28,7 @@ import org.eclipse.mylar.tasks.core.AbstractRepositoryConnector; import org.eclipse.mylar.tasks.core.ITaskListExternalizer; import org.eclipse.mylar.tasks.core.RepositoryTemplate; import org.eclipse.mylar.tasks.ui.AbstractRepositoryConnectorUi; +import org.eclipse.mylar.tasks.ui.AbstractTaskRepositoryLinkProvider; import org.eclipse.mylar.tasks.ui.TasksUiPlugin; import org.eclipse.mylar.tasks.ui.editors.ITaskEditorFactory; import org.eclipse.ui.plugin.AbstractUIPlugin; @@ -41,6 +42,8 @@ public class TasksUiExtensionReader { public static final String EXTENSION_REPOSITORIES = "org.eclipse.mylar.tasks.ui.repositories"; + public static final String EXTENSION_REPOSITORY_LINKS_PROVIDERS = "org.eclipse.mylar.tasks.ui.projectLinkProviders"; + public static final String EXTENSION_TEMPLATES = "org.eclipse.mylar.tasks.core.templates"; public static final String EXTENSION_TMPL_REPOSITORY = "repository"; @@ -68,7 +71,11 @@ public class TasksUiExtensionReader { public static final String ELMNT_TMPL_ADDAUTO = "addAutomatically"; public static final String ELMNT_REPOSITORY_CONNECTOR = "connectorCore"; + + public static final String ATTR_USER_MANAGED = "userManaged"; + public static final String ELMNT_REPOSITORY_LINK_PROVIDER = "linkProvider"; + public static final String ELMNT_REPOSITORY_UI= "connectorUi"; public static final String ELMNT_EXTERNALIZER = "externalizer"; @@ -174,8 +181,34 @@ public class TasksUiExtensionReader { } } } + + IExtensionPoint linkProvidersExtensionPoint = registry.getExtensionPoint(EXTENSION_REPOSITORY_LINKS_PROVIDERS); + IExtension[] linkProvidersExtensions = linkProvidersExtensionPoint.getExtensions(); + for (int i = 0; i < linkProvidersExtensions.length; i++) { + IConfigurationElement[] elements = linkProvidersExtensions[i].getConfigurationElements(); + for (int j = 0; j < elements.length; j++) { + if (elements[j].getName().equals(ELMNT_REPOSITORY_LINK_PROVIDER)) { + readLinkProvider(elements[j]); + } + } + } + } + private static void readLinkProvider(IConfigurationElement element) { + try { + Object repositoryLinkProvider = element.createExecutableExtension(ATTR_CLASS); + if (repositoryLinkProvider instanceof AbstractTaskRepositoryLinkProvider) { + TasksUiPlugin.getDefault().addRepositoryLinkProvider((AbstractTaskRepositoryLinkProvider) repositoryLinkProvider); + } else { + MylarStatusHandler.log("Could not load repository link provider: " + repositoryLinkProvider.getClass().getCanonicalName(), + null); + } + } catch (CoreException e) { + MylarStatusHandler.log(e, "Could not load repository link provider extension"); + } + } + private static void readHyperlinkDetector(IConfigurationElement element) { try { Object hyperlinkDetector = element.createExecutableExtension(ATTR_CLASS); @@ -209,7 +242,15 @@ public class TasksUiExtensionReader { Object type = element.getAttribute(ELMNT_TYPE); Object connectorCore = element.createExecutableExtension(ATTR_CLASS); if (connectorCore instanceof AbstractRepositoryConnector && type != null) { - TasksUiPlugin.getRepositoryManager().addRepositoryConnector((AbstractRepositoryConnector) connectorCore); + AbstractRepositoryConnector repositoryConnector = (AbstractRepositoryConnector) connectorCore; + TasksUiPlugin.getRepositoryManager().addRepositoryConnector(repositoryConnector); + + String userManagedString = element.getAttribute(ATTR_USER_MANAGED); + if(userManagedString != null){ + boolean userManaged = Boolean.parseBoolean(userManagedString); + repositoryConnector.setUserManaged(userManaged); + } + } else { MylarStatusHandler.log("could not not load connector core: " + connectorCore, null); } diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/ResetRepositoryConfigurationAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/ResetRepositoryConfigurationAction.java index f451553fa..28e16e318 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/ResetRepositoryConfigurationAction.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/ResetRepositoryConfigurationAction.java @@ -19,15 +19,15 @@ import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.mylar.core.MylarStatusHandler; +import org.eclipse.mylar.internal.tasks.ui.actions.AbstractTaskRepositoryAction; import org.eclipse.mylar.tasks.core.AbstractRepositoryConnector; import org.eclipse.mylar.tasks.core.TaskRepository; import org.eclipse.mylar.tasks.ui.TasksUiPlugin; -import org.eclipse.ui.actions.BaseSelectionListenerAction; /** * @author Mik Kersten */ -public class ResetRepositoryConfigurationAction extends BaseSelectionListenerAction { +public class ResetRepositoryConfigurationAction extends AbstractTaskRepositoryAction { private static final String ID = "org.eclipse.mylar.tasklist.repositories.reset"; @@ -38,11 +38,6 @@ public class ResetRepositoryConfigurationAction extends BaseSelectionListenerAct } @Override - protected boolean updateSelection(IStructuredSelection selection) { - return selection != null && !selection.isEmpty(); - } - - @Override public void run() { try { IStructuredSelection selection = getStructuredSelection(); @@ -80,6 +75,5 @@ public class ResetRepositoryConfigurationAction extends BaseSelectionListenerAct } public void selectionChanged(IAction action, ISelection selection) { - // TODO Auto-generated method stub } } diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskRepositoriesView.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskRepositoriesView.java index 309dd5d00..b7d6fd094 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskRepositoriesView.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskRepositoriesView.java @@ -128,7 +128,9 @@ public class TaskRepositoriesView extends ViewPart { viewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { - repositoryPropertiesAction.run(); + if(repositoryPropertiesAction.isEnabled()){ + repositoryPropertiesAction.run(); + } } }); diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/ContextRetrieveWizardPage.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/ContextRetrieveWizardPage.java index 615f8a400..57feed57c 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/ContextRetrieveWizardPage.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/ContextRetrieveWizardPage.java @@ -96,9 +96,9 @@ public class ContextRetrieveWizardPage extends WizardPage { Collections.sort(contextAttachments, new Comparator<RepositoryAttachment>() { public int compare(RepositoryAttachment attachment1, RepositoryAttachment attachment2) { - Date created1 = offlineHandler.getDateForAttributeType(RepositoryTaskAttribute.ATTACHMENT_DATE, + Date created1 = task.getTaskData().getAttributeFactory().getDateForAttributeType(RepositoryTaskAttribute.ATTACHMENT_DATE, attachment1.getDateCreated()); - Date created2 = offlineHandler.getDateForAttributeType(RepositoryTaskAttribute.ATTACHMENT_DATE, + Date created2 = task.getTaskData().getAttributeFactory().getDateForAttributeType(RepositoryTaskAttribute.ATTACHMENT_DATE, attachment2.getDateCreated()); if (created1 != null && created2 != null) { return created1.compareTo(created2); diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/MultiRepositoryAwareWizard.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/MultiRepositoryAwareWizard.java index 1a9cd057b..b8f019153 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/MultiRepositoryAwareWizard.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/MultiRepositoryAwareWizard.java @@ -44,12 +44,11 @@ public class MultiRepositoryAwareWizard extends Wizard implements INewWizard { @Override public boolean canFinish() { - return false; + return selectRepositoryPage.canFinish(); } @Override public boolean performFinish() { - // Can't finish on the first page - return false; + return selectRepositoryPage.performFinish(); } } diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/SelectRepositoryClientPage.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/SelectRepositoryClientPage.java index 8e33c1f77..6867d9be2 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/SelectRepositoryClientPage.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/SelectRepositoryClientPage.java @@ -11,6 +11,9 @@ package org.eclipse.mylar.internal.tasks.ui.wizards; +import java.util.ArrayList; +import java.util.List; + import org.eclipse.jface.viewers.IOpenListener; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredContentProvider; @@ -52,7 +55,14 @@ public class SelectRepositoryClientPage extends WizardPage { } public Object[] getElements(Object parent) { - return TasksUiPlugin.getRepositoryManager().getRepositoryConnectors().toArray(); + List<AbstractRepositoryConnector> userManagedRepositories = new ArrayList<AbstractRepositoryConnector>(); + for(AbstractRepositoryConnector connector: TasksUiPlugin.getRepositoryManager().getRepositoryConnectors()){ + if(connector.isUserManaged()){ + userManagedRepositories.add(connector); + } + } + + return userManagedRepositories.toArray(); } } diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/SelectRepositoryPage.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/SelectRepositoryPage.java index ca0f939da..70e22d90f 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/SelectRepositoryPage.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/SelectRepositoryPage.java @@ -148,7 +148,7 @@ public abstract class SelectRepositoryPage extends WizardSelectionPage { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); if (selection.getFirstElement() instanceof TaskRepository) { setSelectedNode(new CustomWizardNode((TaskRepository) selection.getFirstElement())); - setPageComplete(true); + setPageComplete(true); } setPageComplete(false); } @@ -170,6 +170,25 @@ public abstract class SelectRepositoryPage extends WizardSelectionPage { protected abstract IWizard createWizard(TaskRepository taskRepository); + @Override + public boolean canFlipToNextPage() { + return getSelectedNode() != null && getNextPage() != null; + } + + public boolean canFinish() { + return getSelectedNode() != null && getNextPage() == null; + } + + public boolean performFinish() { + if (getSelectedNode() == null || getNextPage() != null) { + // finish event will get forwarded to nested wizard + // by container + return false; + } + + return getSelectedNode().getWizard().performFinish(); + } + private class CustomWizardNode implements IWizardNode { private final TaskRepository repository; @@ -193,6 +212,7 @@ public abstract class SelectRepositoryPage extends WizardSelectionPage { public IWizard getWizard() { if (wizard == null) { wizard = SelectRepositoryPage.this.createWizard(repository); + wizard.setContainer(getContainer()); } return wizard; @@ -222,4 +242,5 @@ public abstract class SelectRepositoryPage extends WizardSelectionPage { } } + } diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/AbstractTaskRepositoryLinkProvider.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/AbstractTaskRepositoryLinkProvider.java new file mode 100644 index 000000000..a639aa9f8 --- /dev/null +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/AbstractTaskRepositoryLinkProvider.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2004 - 2006 Mylar committers and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.eclipse.mylar.tasks.ui; + +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExecutableExtension; +import org.eclipse.mylar.tasks.core.TaskRepository; +import org.eclipse.mylar.tasks.core.TaskRepositoryManager; + +/** + * Abstract Task Repository link provider + * + * @author Eugene Kuleshov + */ +public abstract class AbstractTaskRepositoryLinkProvider implements IExecutableExtension { + + private static final int DEFAULT_ORDER = 1000; + + private String id; + private String name; + private int order; + + public void setInitializationData(IConfigurationElement config, String propertyName, Object data) { + id = config.getAttribute("id"); + name = config.getAttribute("name"); + try { + order = Integer.parseInt(config.getAttribute("order")); + } catch(NumberFormatException ex) { + order = DEFAULT_ORDER; + } + } + + public abstract TaskRepository getTaskRepository(IResource resource, TaskRepositoryManager repositoryManager); + + public boolean canSetTaskRepository(IResource resource) { + return false; + } + + public boolean setTaskRepository(IResource resource, TaskRepository repository) { + return false; + } + + public String getId() { + return id; + } + + public String getName() { + return name; + } + + public int getOrder() { + return order; + } + +}
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/DatePicker.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/DatePicker.java index 8a04dbb78..462e1ec29 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/DatePicker.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/DatePicker.java @@ -89,10 +89,9 @@ public class DatePicker extends Composite { gridLayout.makeColumnsEqualWidth = false; this.setLayout(gridLayout); - dateText = new Text(this, SWT.NONE); - + dateText = new Text(this, SWT.FLAT); GridData dateTextGridData = new org.eclipse.swt.layout.GridData(); - dateTextGridData.widthHint = 110; + dateTextGridData.widthHint = 135; dateTextGridData.horizontalAlignment = GridData.FILL; dateText.setLayoutData(dateTextGridData); @@ -101,7 +100,7 @@ public class DatePicker extends Composite { public void keyPressed(KeyEvent e) { // key listener used because setting of date picker text causes - // modify litener to fire which results in perpetual dirty + // modify listener to fire which results in perpetual dirty // editor notifyPickerListeners(); } @@ -133,7 +132,7 @@ public class DatePicker extends Composite { } }); - pickButton = new Button(this, SWT.ARROW | SWT.DOWN); + pickButton = new Button(this, SWT.FLAT | SWT.ARROW | SWT.DOWN); GridData pickButtonGridData = new org.eclipse.swt.layout.GridData(); pickButtonGridData.horizontalAlignment = org.eclipse.swt.layout.GridData.END; pickButton.setLayoutData(pickButtonGridData); @@ -254,9 +253,10 @@ public class DatePicker extends Composite { if (!canceled) { this.date = selectedDate != null ? selectedDate : null; updateDateText(); + notifyPickerListeners(); } - notifyPickerListeners(); + pickButton.setEnabled(true); dateText.setEnabled(true); } @@ -284,4 +284,5 @@ public class DatePicker extends Composite { pickButton.setEnabled(enabled); super.setEnabled(enabled); } + } diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/ProjectPreferencesLinkProvider.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/ProjectPreferencesLinkProvider.java new file mode 100644 index 000000000..4cd6d963b --- /dev/null +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/ProjectPreferencesLinkProvider.java @@ -0,0 +1,79 @@ +/******************************************************************************* + * Copyright (c) 2004 - 2006 Mylar committers and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.eclipse.mylar.tasks.ui; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.ProjectScope; +import org.eclipse.core.runtime.preferences.IEclipsePreferences; +import org.eclipse.core.runtime.preferences.IScopeContext; +import org.eclipse.mylar.core.MylarStatusHandler; +import org.eclipse.mylar.tasks.core.TaskRepository; +import org.eclipse.mylar.tasks.core.TaskRepositoryManager; +import org.osgi.service.prefs.BackingStoreException; + +/** + * Default Task Repository link provider + * + * @author Eugene Kuleshov + */ +public class ProjectPreferencesLinkProvider extends AbstractTaskRepositoryLinkProvider { + + private static final String PROPERTY_PREFIX = "project.repository"; + + private static final String PROJECT_REPOSITORY_KIND = PROPERTY_PREFIX + ".kind"; + + private static final String PROJECT_REPOSITORY_URL = PROPERTY_PREFIX + ".url"; + + public TaskRepository getTaskRepository(IResource resource, TaskRepositoryManager repositoryManager) { + IProject project = resource.getProject(); + if (project == null || !project.isAccessible()) { + return null; + } + + IScopeContext projectScope = new ProjectScope(project); + IEclipsePreferences projectNode = projectScope.getNode(TasksUiPlugin.PLUGIN_ID); + if (projectNode != null) { + String kind = projectNode.get(PROJECT_REPOSITORY_KIND, ""); + String urlString = projectNode.get(PROJECT_REPOSITORY_URL, ""); + return repositoryManager.getRepository(kind, urlString); + } + return null; + } + + + @Override + public boolean canSetTaskRepository(IResource resource) { + IProject project = resource.getProject(); + return project != null && project.isAccessible(); + } + + @Override + public boolean setTaskRepository(IResource resource, TaskRepository repository) { + IProject project = resource.getProject(); + if (project == null || !project.isAccessible()) { + return false; + } + + IScopeContext projectScope = new ProjectScope(project); + IEclipsePreferences projectNode = projectScope.getNode(TasksUiPlugin.PLUGIN_ID); + if (projectNode != null) { + projectNode.put(PROJECT_REPOSITORY_KIND, repository.getKind()); + projectNode.put(PROJECT_REPOSITORY_URL, repository.getUrl()); + try { + projectNode.flush(); + return true; + } catch (BackingStoreException e) { + MylarStatusHandler.fail(e, "Failed to save task repository to project association preference", false); + } + } + return false; + } + +} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/RepositorySynchronizationManager.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/RepositorySynchronizationManager.java index a7097193b..6c438d3e7 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/RepositorySynchronizationManager.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/RepositorySynchronizationManager.java @@ -203,7 +203,7 @@ public class RepositorySynchronizationManager { if (connector.getTaskDataHandler() != null && task.getTaskData() != null && task.getTaskData().getLastModified() != null) { - taskModifiedDate = connector.getTaskDataHandler().getDateForAttributeType( + taskModifiedDate = task.getTaskData().getAttributeFactory().getDateForAttributeType( RepositoryTaskAttribute.DATE_MODIFIED, task.getTaskData().getLastModified()); } else { continue; diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskListManager.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskListManager.java index dea31fef7..3a6fbe293 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskListManager.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskListManager.java @@ -837,6 +837,18 @@ public class TaskListManager implements IPropertyChangeListener { parseFutureReminders(); taskList.notifyLocalInfoChanged(task); } + + public void setDueDate(ITask task, Date dueDate) { + task.setDueDate(dueDate); + taskList.notifyLocalInfoChanged(task); + } + + /** + * @return true if task due date != null and has past + */ + public boolean isDue(ITask task) { + return (task.getDueDate() != null && new Date().after(task.getDueDate())); + } public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(TaskListPreferenceConstants.PLANNING_STARTHOUR) diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiPlugin.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiPlugin.java index c5152905f..be68fc568 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiPlugin.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiPlugin.java @@ -13,24 +13,22 @@ package org.eclipse.mylar.tasks.ui; import java.io.File; import java.util.ArrayList; import java.util.Collection; +import java.util.Comparator; import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.TreeSet; -import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ProjectScope; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Preferences.IPropertyChangeListener; import org.eclipse.core.runtime.Preferences.PropertyChangeEvent; -import org.eclipse.core.runtime.preferences.IEclipsePreferences; -import org.eclipse.core.runtime.preferences.IScopeContext; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.resource.ImageDescriptor; @@ -70,6 +68,7 @@ import org.eclipse.mylar.tasks.core.ITaskActivityListener; import org.eclipse.mylar.tasks.core.ITaskDataHandler; import org.eclipse.mylar.tasks.core.ITaskListExternalizer; import org.eclipse.mylar.tasks.core.RepositoryTaskAttribute; +import org.eclipse.mylar.tasks.core.RepositoryTemplate; import org.eclipse.mylar.tasks.core.Task; import org.eclipse.mylar.tasks.core.TaskComment; import org.eclipse.mylar.tasks.core.TaskRepository; @@ -84,7 +83,6 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; -import org.osgi.service.prefs.BackingStoreException; /** * @author Mik Kersten @@ -97,12 +95,6 @@ public class TasksUiPlugin extends AbstractUIPlugin implements IStartup { public static final String PLUGIN_ID = "org.eclipse.mylar.tasklist"; - private static final String PROPERTY_PREFIX = "project.repository"; - - private static final String PROJECT_REPOSITORY_KIND = PROPERTY_PREFIX + ".kind"; - - private static final String PROJECT_REPOSITORY_URL = PROPERTY_PREFIX + ".url"; - private static final String NAME_DATA_DIR = ".mylar"; private static final char DEFAULT_PATH_SEPARATOR = '/'; @@ -133,6 +125,8 @@ public class TasksUiPlugin extends AbstractUIPlugin implements IStartup { private ArrayList<IHyperlinkDetector> hyperlinkDetectors = new ArrayList<IHyperlinkDetector>(); + private TreeSet<AbstractTaskRepositoryLinkProvider> repositoryLinkProviders = new TreeSet<AbstractTaskRepositoryLinkProvider>(new OrderComparator()); + private TaskListWriter taskListWriter; private ITaskHighlighter highlighter; @@ -147,6 +141,12 @@ public class TasksUiPlugin extends AbstractUIPlugin implements IStartup { private boolean eclipse_3_3_workbench = false; + private static final class OrderComparator implements Comparator<AbstractTaskRepositoryLinkProvider> { + public int compare(AbstractTaskRepositoryLinkProvider p1, AbstractTaskRepositoryLinkProvider p2) { + return p1.getOrder()-p2.getOrder(); + } + } + public enum TaskListSaveMode { ONE_HOUR, THREE_HOURS, DAY; @Override @@ -296,7 +296,7 @@ public class TasksUiPlugin extends AbstractUIPlugin implements IStartup { if (connector != null) { ITaskDataHandler offlineHandler = connector.getTaskDataHandler(); if (offlineHandler != null && repositoryTask.getTaskData().getLastModified() != null) { - Date modified = offlineHandler.getDateForAttributeType( + Date modified = repositoryTask.getTaskData().getAttributeFactory().getDateForAttributeType( RepositoryTaskAttribute.DATE_MODIFIED, repositoryTask.getTaskData() .getLastModified()); notification.setDate(modified); @@ -385,13 +385,29 @@ public class TasksUiPlugin extends AbstractUIPlugin implements IStartup { // NOTE: initializing extensions in start(..) has caused race // conditions previously TasksUiExtensionReader.initStartupExtensions(taskListWriter); + + taskRepositoryManager.readRepositories(getRepositoriesFilePath()); + + // add the automatically created templates + for(AbstractRepositoryConnector connector: taskRepositoryManager.getRepositoryConnectors()){ + for(RepositoryTemplate template: connector.getTemplates()){ + if(template.addAutomatically){ + TaskRepository taskRepository = taskRepositoryManager.getRepository(connector.getRepositoryType(), template.repositoryUrl); + if(taskRepository == null){ + taskRepository = new TaskRepository(connector.getRepositoryType(), template.repositoryUrl, template.version); + taskRepositoryManager.addRepository(taskRepository, getRepositoriesFilePath()); + } + } + } + } + readOfflineReports(); for (ITaskListExternalizer externalizer : taskListWriter.getExternalizers()) { if (externalizer instanceof DelegatingTaskExternalizer) { ((DelegatingTaskExternalizer) externalizer).init(offlineTaskManager); } } - taskRepositoryManager.readRepositories(getRepositoriesFilePath()); + taskListWriter.setTaskDataManager(offlineTaskManager); // NOTE: task list must be read before Task List view can be initialized @@ -671,6 +687,11 @@ public class TasksUiPlugin extends AbstractUIPlugin implements IStartup { this.hyperlinkDetectors.add(listener); } + public void addRepositoryLinkProvider(AbstractTaskRepositoryLinkProvider repositoryLinkProvider) { + if (repositoryLinkProvider != null) + this.repositoryLinkProviders.add(repositoryLinkProvider); + } + public TaskListBackupManager getBackupManager() { return taskListBackupManager; } @@ -684,7 +705,7 @@ public class TasksUiPlugin extends AbstractUIPlugin implements IStartup { } catch (Throwable t) { MylarStatusHandler .log(t, - "Could not restore offline repository tasks file, creating new one, likely cause is format update."); + "Recreating offline task cache due to format update."); boolean deleted = offlineReportsPath.toFile().delete(); if (!deleted) { MylarStatusHandler.log(t, "could not delete offline repository tasks file"); @@ -736,6 +757,27 @@ public class TasksUiPlugin extends AbstractUIPlugin implements IStartup { return getDataDirectory() + File.separator + TaskRepositoryManager.DEFAULT_REPOSITORIES_FILE; } + public boolean canSetRepositoryForResource(IResource resource) { + if (resource == null) { + return false; + } + + // find first provider that can link repository + for (AbstractTaskRepositoryLinkProvider linkProvider : repositoryLinkProviders) { + TaskRepository repository = linkProvider.getTaskRepository(resource, getRepositoryManager()); + if (repository != null) { + return linkProvider.canSetTaskRepository(resource); + } + } + // find first provider that can set new repository + for (AbstractTaskRepositoryLinkProvider linkProvider : repositoryLinkProviders) { + if (linkProvider.canSetTaskRepository(resource)) { + return true; + } + } + return false; + } + /** * Associate a Task Repository with a workbench project * @@ -746,21 +788,19 @@ public class TasksUiPlugin extends AbstractUIPlugin implements IStartup { * @throws CoreException */ public void setRepositoryForResource(IResource resource, TaskRepository repository) throws CoreException { - if (resource == null || repository == null || !resource.getProject().isOpen()) { + if (resource == null || repository == null) { return; } - IProject project = resource.getProject(); - if (project == null) - return; - IScopeContext projectScope = new ProjectScope(project); - IEclipsePreferences projectNode = projectScope.getNode(PLUGIN_ID); - if (projectNode != null) { - projectNode.put(PROJECT_REPOSITORY_KIND, repository.getKind()); - projectNode.put(PROJECT_REPOSITORY_URL, repository.getUrl()); - try { - projectNode.flush(); - } catch (BackingStoreException e) { - MylarStatusHandler.fail(e, "Failed to save task repository to project association preference", false); + + for (AbstractTaskRepositoryLinkProvider linkProvider : repositoryLinkProviders) { + TaskRepository r = linkProvider.getTaskRepository(resource, getRepositoryManager()); + boolean canSetRepository = linkProvider.canSetTaskRepository(resource); + if (r != null && !canSetRepository) { + return; + } + if (canSetRepository) { + linkProvider.setTaskRepository(resource, repository); + return; } } } @@ -770,25 +810,24 @@ public class TasksUiPlugin extends AbstractUIPlugin implements IStartup { * project (or resource belonging to a project) */ public TaskRepository getRepositoryForResource(IResource resource, boolean silent) { - if (resource == null) + if (resource == null) { return null; - IProject project = resource.getProject(); - if (project == null) - return null; - TaskRepository taskRepository = null; - IScopeContext projectScope = new ProjectScope(project); - IEclipsePreferences projectNode = projectScope.getNode(PLUGIN_ID); - if (projectNode != null) { - String kind = projectNode.get(PROJECT_REPOSITORY_KIND, ""); - String urlString = projectNode.get(PROJECT_REPOSITORY_URL, ""); - taskRepository = getRepositoryManager().getRepository(kind, urlString); - if (taskRepository == null && !silent) { - MessageDialog - .openInformation(null, "No Repository Found", - "No repository was found. Associate a Task Repository with this project via the project's property page."); + } + + for (AbstractTaskRepositoryLinkProvider linkProvider : repositoryLinkProviders) { + TaskRepository repository = linkProvider.getTaskRepository(resource, getRepositoryManager()); + if (repository != null) { + return repository; } } - return taskRepository; + + if (!silent) { + MessageDialog + .openInformation(null, "No Repository Found", + "No repository was found. Associate a Task Repository with this project via the project's property page."); + } + + return null; } public boolean isEclipse_3_3_workbench() { diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractNewRepositoryTaskEditor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractNewRepositoryTaskEditor.java index a0082bc86..31b8d72e9 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractNewRepositoryTaskEditor.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractNewRepositoryTaskEditor.java @@ -164,6 +164,7 @@ public abstract class AbstractNewRepositoryTaskEditor extends AbstractRepository if (attribute != null) { createLabel(summaryComposite, attribute); summaryText = createTextField(summaryComposite, attribute, SWT.FLAT); + attributeCombo.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); IThemeManager themeManager = getSite().getWorkbenchWindow().getWorkbench().getThemeManager(); Font summaryFont = themeManager.getCurrentTheme().getFontRegistry().get( TaskListColorsAndFonts.TASK_EDITOR_FONT); diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java index b60ba0932..38dff7f5f 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java @@ -35,6 +35,7 @@ import org.eclipse.core.runtime.jobs.IJobChangeListener; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.runtime.jobs.JobChangeAdapter; import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.ControlContribution; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.MenuManager; @@ -152,7 +153,6 @@ import org.eclipse.ui.forms.events.HyperlinkAdapter; import org.eclipse.ui.forms.events.HyperlinkEvent; import org.eclipse.ui.forms.widgets.ExpandableComposite; import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.forms.widgets.Hyperlink; import org.eclipse.ui.forms.widgets.ImageHyperlink; import org.eclipse.ui.forms.widgets.ScrolledForm; import org.eclipse.ui.forms.widgets.Section; @@ -171,6 +171,10 @@ import org.eclipse.ui.views.contentoutline.IContentOutlinePage; */ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage { + private static final String LABEL_HISTORY = "History"; + + private static final String LABEL_REPLY = "reply"; + public static final String LABEL_JOB_SUBMIT = "Submitting to repository"; protected static final String HEADER_DATE_FORMAT = "yyyy-MM-dd HH:mm"; @@ -203,7 +207,7 @@ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage { protected TaskRepository repository; - public static final int RADIO_OPTION_WIDTH = 150; + public static final int RADIO_OPTION_WIDTH = 120; protected Display display; @@ -697,13 +701,19 @@ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage { kindLabel = connectorUi.getTaskKindLabel(repositoryTask); } String idLabel = ""; + if (repositoryTask != null) { idLabel = repositoryTask.getIdentifyingLabel(); } else { idLabel = taskData.getId(); } - form.setText(kindLabel + " " + idLabel); + if (taskData != null && taskData.isNew()) { + form.setText("New " + kindLabel); + } else { + form.setText(kindLabel + " " + idLabel); + } + // toolkit.decorateFormHeading(form.getForm()); editorComposite = form.getBody(); @@ -722,7 +732,31 @@ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage { if (summaryText != null) { summaryText.setFocus(); } + addHeaderControls(); } + + + protected void addHeaderControls() { + ControlContribution repositoryLabelControl = new ControlContribution("TaskEditorHeader") { //$NON-NLS-1$ + protected Control createControl(Composite parent) { + Text text = new Text(parent, SWT.FLAT | SWT.READ_ONLY); + text.setFont(TITLE_FONT); + text.setForeground(toolkit.getColors().getColor(FormColors.TITLE)); + String label = repository.getRepositoryLabel(); + if(label.equals("") && repository.getUrl().indexOf("//") != -1){ + label = repository.getUrl().substring((repository.getUrl().indexOf("//") + 2)); + } else { + label = repository.getUrl(); + } + text.setText(label); + text.setBackground(null); + return text; + } + }; + form.getToolBarManager().add(repositoryLabelControl); + form.getToolBarManager().update(true); + } + protected void createSections() { createReportHeaderLayout(editorComposite); @@ -765,33 +799,35 @@ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage { headerLayout.horizontalSpacing = 6; headerInfoComposite.setLayout(headerLayout); - - RepositoryTaskAttribute statusAtribute = taskData.getAttribute(RepositoryTaskAttribute.STATUS); addNameValue(headerInfoComposite, statusAtribute); + toolkit.paintBordersFor(headerInfoComposite); RepositoryTaskAttribute priorityAttribute = taskData.getAttribute(RepositoryTaskAttribute.PRIORITY); addNameValue(headerInfoComposite, priorityAttribute); String idLabel = (repositoryTask != null) ? repositoryTask.getIdentifyingLabel() : taskData.getId(); if (idLabel != null) { - + Composite nameValue = toolkit.createComposite(headerInfoComposite); nameValue.setLayout(new GridLayout(2, false)); - toolkit.createLabel(nameValue, "ID:");// .setFont(TITLE_FONT); - toolkit.createText(nameValue, idLabel, SWT.FLAT | SWT.READ_ONLY); + Label label = toolkit.createLabel(nameValue, "ID:");// .setFont(TITLE_FONT); + label.setForeground(toolkit.getColors().getColor(FormColors.TITLE)); + //toolkit.createText(nameValue, idLabel, SWT.FLAT | SWT.READ_ONLY); + Text text = new Text(nameValue, SWT.FLAT | SWT.READ_ONLY); + toolkit.adapt(text, true, true); + text.setText(idLabel); } - String openedDateString = ""; String modifiedDateString = ""; final ITaskDataHandler taskDataManager = connector.getTaskDataHandler(); if (taskDataManager != null) { - Date created = taskDataManager.getDateForAttributeType(RepositoryTaskAttribute.DATE_CREATION, taskData + Date created = taskData.getAttributeFactory().getDateForAttributeType(RepositoryTaskAttribute.DATE_CREATION, taskData .getCreated()); openedDateString = created != null ? DateUtil.getFormattedDate(created, HEADER_DATE_FORMAT) : ""; - Date modified = taskDataManager.getDateForAttributeType(RepositoryTaskAttribute.DATE_MODIFIED, taskData + Date modified = taskData.getAttributeFactory().getDateForAttributeType(RepositoryTaskAttribute.DATE_MODIFIED, taskData .getLastModified()); modifiedDateString = modified != null ? DateUtil.getFormattedDate(modified, HEADER_DATE_FORMAT) : ""; } @@ -801,20 +837,29 @@ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage { Composite nameValue = toolkit.createComposite(headerInfoComposite); nameValue.setLayout(new GridLayout(2, false)); createLabel(nameValue, creationAttribute); - toolkit.createText(nameValue, openedDateString, SWT.FLAT | SWT.READ_ONLY); + //toolkit.createText(nameValue, openedDateString, SWT.FLAT | SWT.READ_ONLY); + Text text = new Text(nameValue, SWT.FLAT | SWT.READ_ONLY); + toolkit.adapt(text, true, true); + text.setText(openedDateString); } RepositoryTaskAttribute modifiedAttribute = taskData.getAttribute(RepositoryTaskAttribute.DATE_MODIFIED); - if (modifiedAttribute != null) { + if (modifiedAttribute != null) { Composite nameValue = toolkit.createComposite(headerInfoComposite); nameValue.setLayout(new GridLayout(2, false)); createLabel(nameValue, modifiedAttribute); - toolkit.createText(nameValue, modifiedDateString, SWT.FLAT | SWT.READ_ONLY); + //toolkit.createText(nameValue, modifiedDateString, SWT.FLAT | SWT.READ_ONLY); + Text text = new Text(nameValue, SWT.FLAT | SWT.READ_ONLY); + toolkit.adapt(text, true, true); + text.setText(modifiedDateString); } if (getActivityUrl() != null) { - String linkName = kindLabel + " History"; - Hyperlink hyperlink = toolkit.createHyperlink(headerInfoComposite, linkName, SWT.NONE); + String linkName = LABEL_HISTORY; + ImageHyperlink hyperlink = toolkit.createImageHyperlink(headerInfoComposite, SWT.NONE); + hyperlink.setText(linkName); + hyperlink.setToolTipText(kindLabel + " "+LABEL_HISTORY); + hyperlink.setImage(TaskListImages.getImage(TaskListImages.TASK_REPOSITORY_HISTORY)); hyperlink.addHyperlinkListener(new HyperlinkAdapter() { @Override public void linkActivated(HyperlinkEvent e) { @@ -824,17 +869,15 @@ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage { } } }); - // GridDataFactory.fillDefaults().span(1, - // SWT.DEFAULT).align(SWT.RIGHT, SWT.DEFAULT).applyTo(hyperlink); } } - + private void addNameValue(Composite parent, RepositoryTaskAttribute attribute) { Composite nameValue = toolkit.createComposite(parent); nameValue.setLayout(new GridLayout(2, false)); if (attribute != null) { - createLabel(nameValue, attribute);// .setFont(TITLE_FONT); - createTextField(nameValue, attribute, SWT.NONE | SWT.READ_ONLY); + createLabel(nameValue, attribute); + createTextField(nameValue, attribute, SWT.FLAT | SWT.READ_ONLY); } } @@ -854,7 +897,15 @@ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage { } else { value = attribute.getValue(); } - text = toolkit.createText(composite, value, style); + if((SWT.READ_ONLY & style) == SWT.READ_ONLY) { + text = new Text(composite, style); + toolkit.adapt(text, true, true); + text.setText(value); + } else { + text = toolkit.createText(composite, value, style); + } + + if (attribute != null && !attribute.isReadOnly()) { text.setData(attribute); text.addModifyListener(new ModifyListener() { @@ -939,7 +990,7 @@ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage { attributeCombo = new CCombo(attributesComposite, SWT.FLAT | SWT.READ_ONLY); toolkit.adapt(attributeCombo, true, true); attributeCombo.setFont(TEXT_FONT); - + attributeCombo.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); if (hasChanged(attribute)) { attributeCombo.setBackground(backgroundIncoming); } @@ -968,7 +1019,7 @@ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage { if (attribute.isReadOnly()) { final Text text = createTextField(textFieldComposite, attribute, SWT.FLAT | SWT.READ_ONLY); - text.setLayoutData(textData); + text.setLayoutData(textData); } else { final Text text = createTextField(textFieldComposite, attribute, SWT.FLAT); // text.setFont(COMMENT_FONT); @@ -1071,9 +1122,9 @@ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage { public int compare(Viewer viewer, Object e1, Object e2) { RepositoryAttachment attachment1 = (RepositoryAttachment) e1; RepositoryAttachment attachment2 = (RepositoryAttachment) e2; - Date created1 = offlineHandler.getDateForAttributeType(RepositoryTaskAttribute.ATTACHMENT_DATE, + Date created1 = taskData.getAttributeFactory().getDateForAttributeType(RepositoryTaskAttribute.ATTACHMENT_DATE, attachment1.getDateCreated()); - Date created2 = offlineHandler.getDateForAttributeType(RepositoryTaskAttribute.ATTACHMENT_DATE, + Date created2 = taskData.getAttributeFactory().getDateForAttributeType(RepositoryTaskAttribute.ATTACHMENT_DATE, attachment2.getDateCreated()); if (created1 != null && created2 != null) { return created1.compareTo(created2); @@ -1537,6 +1588,7 @@ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage { final ImageHyperlink replyLink = new ImageHyperlink(section, SWT.NULL); toolkit.adapt(replyLink, true, true); replyLink.setImage(TaskListImages.getImage(TaskListImages.REPLY)); + replyLink.setToolTipText(LABEL_REPLY); // no need for the background - transparency will take care of it replyLink.setBackground(null); // replyLink.setBackground(section.getTitleBarGradientBackground()); @@ -1746,8 +1798,8 @@ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage { ImageHyperlink replyLink = createReplyHyperlink(taskComment.getNumber(), expandableComposite, taskComment .getText()); - replyLink.setVisible(expandableComposite.isExpanded()); - + replyLink.setVisible(expandableComposite.isExpanded()); + // HACK: This is necessary // due to a bug in SWT's ExpandableComposite. // 165803: Expandable bars should expand when clicking anywhere @@ -1760,13 +1812,14 @@ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage { Composite ecComposite = toolkit.createComposite(expandableComposite); GridLayout ecLayout = new GridLayout(); ecLayout.marginHeight = 0; - ecLayout.marginBottom = 10; + ecLayout.marginBottom = 3; ecLayout.marginLeft = 10; ecComposite.setLayout(ecLayout); ecComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); expandableComposite.setClient(ecComposite); - TextViewer viewer = addTextViewer(repository, ecComposite, taskComment.getText(), SWT.MULTI | SWT.WRAP); + TextViewer viewer = addTextViewer(repository, ecComposite, taskComment.getText().trim(), SWT.MULTI + | SWT.WRAP); // viewer.getControl().setBackground(new // Color(expandableComposite.getDisplay(), 123, 34, 155)); styledText = viewer.getTextWidget(); @@ -1805,7 +1858,7 @@ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage { ITaskDataHandler offlineHandler = connector.getTaskDataHandler(); if (offlineHandler != null) { - Date lastSyncDate = offlineHandler.getDateForAttributeType(RepositoryTaskAttribute.DATE_MODIFIED, + Date lastSyncDate = taskData.getAttributeFactory().getDateForAttributeType(RepositoryTaskAttribute.DATE_MODIFIED, repositoryTask.getLastSyncDateStamp()); if (lastSyncDate != null) { @@ -1815,7 +1868,7 @@ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage { calLastMod.setTimeInMillis(lastSyncDate.getTime()); calLastMod.set(Calendar.SECOND, 0); - Date commentDate = offlineHandler.getDateForAttributeType(RepositoryTaskAttribute.COMMENT_DATE, + Date commentDate = taskData.getAttributeFactory().getDateForAttributeType(RepositoryTaskAttribute.COMMENT_DATE, comment.getCreated()); if (commentDate != null) { if (commentDate.after(calLastMod.getTime())) { @@ -2378,19 +2431,11 @@ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage { radioData.horizontalSpan = 1; radioData.heightHint = 20; radioData.widthHint = RADIO_OPTION_WIDTH; - // radioOptions[i] = new Combo(buttonComposite, SWT.NULL); radioOptions[i] = new CCombo(buttonComposite, SWT.FLAT | SWT.READ_ONLY); + radioOptions[i].setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); toolkit.adapt(radioOptions[i], true, true); - // radioOptions[i] = new Combo(buttonComposite, SWT.MULTI | - // SWT.V_SCROLL | SWT.READ_ONLY); - // radioOptions[i].setData(FormToolkit.KEY_DRAW_BORDER, - // FormToolkit.TEXT_BORDER); - // radioOptions[i] = new Combo(buttonComposite, - // SWT.NO_BACKGROUND | SWT.MULTI | SWT.V_SCROLL - // | SWT.READ_ONLY); radioOptions[i].setFont(TEXT_FONT); radioOptions[i].setLayoutData(radioData); - // radioOptions[i].setBackground(background); Object[] a = o.getOptionNames().toArray(); Arrays.sort(a); @@ -2402,15 +2447,13 @@ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage { } else if (o.isInput()) { radioData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); radioData.horizontalSpan = 1; - radioData.widthHint = 120; + radioData.widthHint = RADIO_OPTION_WIDTH - 10; - // TODO: add condition for if opName = reassign to... String assignmentValue = ""; if (opName.equals(REASSIGN_BUG_TO)) { assignmentValue = repository.getUserName(); } - radioOptions[i] = toolkit.createText(buttonComposite, assignmentValue);// , - // SWT.SINGLE); + radioOptions[i] = toolkit.createText(buttonComposite, assignmentValue); radioOptions[i].setFont(TEXT_FONT); radioOptions[i].setLayoutData(radioData); // radioOptions[i].setBackground(background); @@ -2580,8 +2623,6 @@ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage { public void submitToRepository() { submitButton.setEnabled(false); showBusy(true); - - // updateEditor(); updateTask(); if (isDirty()) { runSaveJob(); @@ -2615,14 +2656,12 @@ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage { .getTask(repository.getUrl(), taskData.getId()); } - // Attach context if required - if (attachContext) { - attachContext(modifiedTask); - } - // Synchronization accounting... if (modifiedTask != null) { - + // Attach context if required + if (attachContext) { + attachContext(modifiedTask); + } submitting = true; modifiedTask.getTaskData().setHasLocalChanges(true); TasksUiPlugin.getSynchronizationManager().synchronize(connector, modifiedTask, true, @@ -2630,10 +2669,7 @@ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage { @Override public void done(IJobChangeEvent event) { - - // if (!isNew) { - // updateEditor(); - // } else { + if (isNew) { close(); TasksUiPlugin.getSynchronizationManager().setTaskRead(modifiedTask, true); @@ -2723,11 +2759,13 @@ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage { * the form during refresh */ private void setNullMenu(Composite comp) { - comp.setMenu(null); - for (Control child : comp.getChildren()) { - child.setMenu(null); - if (child instanceof Composite) { - setNullMenu((Composite) child); + if (!comp.isDisposed()) { + comp.setMenu(null); + for (Control child : comp.getChildren()) { + child.setMenu(null); + if (child instanceof Composite) { + setNullMenu((Composite) child); + } } } } diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/TaskEditor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/TaskEditor.java index 6244318a4..c1953512e 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/TaskEditor.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/TaskEditor.java @@ -30,6 +30,7 @@ import org.eclipse.mylar.internal.tasks.ui.views.TaskListView; import org.eclipse.mylar.tasks.core.AbstractRepositoryTask; import org.eclipse.mylar.tasks.core.ITask; import org.eclipse.mylar.tasks.ui.TasksUiPlugin; +import org.eclipse.mylar.tasks.ui.TasksUiUtil; import org.eclipse.swt.SWT; import org.eclipse.swt.SWTError; import org.eclipse.swt.browser.Browser; @@ -322,6 +323,8 @@ public class TaskEditor extends FormEditor { if (webBrowser != null) { webBrowser.setUrl(url); revealBrowser(); + } else { + TasksUiUtil.openBrowser(url); } } @@ -465,4 +468,4 @@ public class TaskEditor extends FormEditor { return StructuredSelection.EMPTY; } } -} +}
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/properties/ProjectTaskRepositoryPage.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/properties/ProjectTaskRepositoryPage.java index caae91f3f..9bd88130b 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/properties/ProjectTaskRepositoryPage.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/properties/ProjectTaskRepositoryPage.java @@ -103,11 +103,6 @@ public class ProjectTaskRepositoryPage extends PropertyPage { listViewer.setSorter(new TaskRepositoriesSorter()); listViewer.setInput(project.getWorkspace()); - TaskRepository repository = TasksUiPlugin.getDefault().getRepositoryForResource(project, true); - - if (repository != null) { - listViewer.setCheckedElements(new Object[] { repository }); - } listViewer.addCheckStateListener(new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent event) { if (event.getChecked()) { @@ -118,6 +113,7 @@ public class ProjectTaskRepositoryPage extends PropertyPage { modified = true; } }); + updateLinkedRepository(); final AddRepositoryAction action = new AddRepositoryAction(); @@ -129,12 +125,21 @@ public class ProjectTaskRepositoryPage extends PropertyPage { public void widgetSelected(SelectionEvent e) { action.run(); listViewer.setInput(project.getWorkspace()); + updateLinkedRepository(); } }); return composite; } + void updateLinkedRepository() { + TaskRepository repository = TasksUiPlugin.getDefault().getRepositoryForResource(project, true); + if (repository != null) { + listViewer.setCheckedElements(new Object[] { repository }); + } + listViewer.getControl().setEnabled(TasksUiPlugin.getDefault().canSetRepositoryForResource(project)); + } + private static int getDefaultFontHeight(Control control, int lines) { FontData[] viewerFontData = control.getFont().getFontData(); int fontHeight = 10; @@ -167,7 +172,10 @@ public class ProjectTaskRepositoryPage extends PropertyPage { if (listViewer.getCheckedElements().length > 0) { TaskRepository selectedRepository = (TaskRepository) listViewer.getCheckedElements()[0]; try { - TasksUiPlugin.getDefault().setRepositoryForResource(project, selectedRepository); + TasksUiPlugin plugin = TasksUiPlugin.getDefault(); + if(plugin.canSetRepositoryForResource(project)) { + plugin.setRepositoryForResource(project, selectedRepository); + } } catch (CoreException e) { MylarStatusHandler.fail(e, "Unable to associate project with task repository", true); } diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/search/SearchScoreComputerAdapterFactory.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/search/SearchScoreComputerAdapterFactory.java new file mode 100644 index 000000000..95c532a3e --- /dev/null +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/search/SearchScoreComputerAdapterFactory.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2004 - 2006 University Of British Columbia and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * University Of British Columbia - initial API and implementation + *******************************************************************************/ + +package org.eclipse.mylar.tasks.ui.search; + +import org.eclipse.core.runtime.IAdapterFactory; +import org.eclipse.mylar.internal.tasks.ui.TaskSearchPage; +import org.eclipse.mylar.tasks.core.ITaskListElement; +import org.eclipse.search.ui.ISearchPageScoreComputer; + +/** + * Implements a {@link IAdapterFactory} for {@link ISearchPageScoreComputer}s + * which ranks {@link ITaskListElement}s high for the task search page + * + * @author Willian Mitsuda + */ +public class SearchScoreComputerAdapterFactory implements IAdapterFactory { + + private final ISearchPageScoreComputer computer = new ISearchPageScoreComputer() { + + public int computeScore(String pageId, Object input) { + if (!TaskSearchPage.ID.equals(pageId)) { + return ISearchPageScoreComputer.UNKNOWN; + } + if (input instanceof ITaskListElement) { + return 100; + } + return ISearchPageScoreComputer.LOWEST; + } + + }; + + @SuppressWarnings("unchecked") + public Object getAdapter(Object adaptableObject, Class adapterType) { + if (ISearchPageScoreComputer.class.equals(adapterType)) { + return computer; + } + return null; + } + + @SuppressWarnings("unchecked") + public Class[] getAdapterList() { + return new Class[] { ISearchPageScoreComputer.class }; + } + +}
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/wizards/AbstractRepositorySettingsPage.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/wizards/AbstractRepositorySettingsPage.java index fbe251609..758cb731a 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/wizards/AbstractRepositorySettingsPage.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/wizards/AbstractRepositorySettingsPage.java @@ -11,12 +11,18 @@ package org.eclipse.mylar.tasks.ui.wizards; +import java.lang.reflect.InvocationTargetException; import java.nio.charset.Charset; import java.util.HashSet; import java.util.List; import java.util.Set; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; import org.eclipse.jface.layout.GridDataFactory; +import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.preference.StringFieldEditor; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.mylar.core.MylarStatusHandler; @@ -49,6 +55,7 @@ import org.eclipse.ui.forms.widgets.Section; /** * @author Mik Kersten * @author Rob Elves + * @author Steffen Pingel */ public abstract class AbstractRepositorySettingsPage extends WizardPage { @@ -64,6 +71,10 @@ public abstract class AbstractRepositorySettingsPage extends WizardPage { protected static final String URL_PREFIX_HTTP = "http://"; + protected static final String INVALID_REPOSITORY_URL = "Repository url is invalid."; + + protected static final String INVALID_LOGIN = "Unable to authenticate with repository. Login credentials invalid."; + protected AbstractRepositoryConnector connector; protected StringFieldEditor repositoryLabelEditor; @@ -116,6 +127,8 @@ public abstract class AbstractRepositorySettingsPage extends WizardPage { private boolean needsHttpAuth; + private boolean needsValidation; + private Composite container; private Composite httpAuthComp; @@ -164,6 +177,7 @@ public abstract class AbstractRepositorySettingsPage extends WizardPage { setNeedsEncoding(true); setNeedsTimeZone(true); setNeedsProxy(true); + setNeedsValidation(true); } public void createControl(Composite parent) { @@ -459,17 +473,19 @@ public abstract class AbstractRepositorySettingsPage extends WizardPage { addProxySection(); } - validateServerButton = new Button(container, SWT.PUSH); - GridDataFactory.swtDefaults().span(2, SWT.DEFAULT).grab(false, false).applyTo(validateServerButton); - validateServerButton.setText("Validate Settings"); - validateServerButton.addSelectionListener(new SelectionAdapter() { - - @Override - public void widgetSelected(SelectionEvent e) { - validateSettings(); - } - }); + if (needsValidation()) { + validateServerButton = new Button(container, SWT.PUSH); + GridDataFactory.swtDefaults().span(2, SWT.DEFAULT).grab(false, false).applyTo(validateServerButton); + validateServerButton.setText("Validate Settings"); + validateServerButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + validateSettings(); + } + }); + } + setControl(container); } @@ -695,8 +711,6 @@ public abstract class AbstractRepositorySettingsPage extends WizardPage { protected abstract void createAdditionalControls(Composite parent); - protected abstract void validateSettings(); - protected abstract boolean isValidUrl(String name); /* Public for testing. */ @@ -964,6 +978,14 @@ public abstract class AbstractRepositorySettingsPage extends WizardPage { this.needsAnonymousLogin = needsAnonymousLogin; } + public void setNeedsValidation(boolean needsValidation) { + this.needsValidation = needsValidation; + } + + public boolean needsValidation() { + return needsValidation; + } + public void updateProperties(TaskRepository repository) { // none } @@ -982,4 +1004,89 @@ public abstract class AbstractRepositorySettingsPage extends WizardPage { public void setPassword(String pass) { repositoryPasswordEditor.setStringValue(pass); } -}
\ No newline at end of file + + protected void validateSettings() { + final Validator validator = getValidator(createTaskRepository()); + if (validator == null) { + return; + } + + try { + getWizard().getContainer().run(true, false, new IRunnableWithProgress() { + public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { + monitor.beginTask("Validating server settings", IProgressMonitor.UNKNOWN); + try { + validator.run(monitor); + if (validator.getStatus() == null) { + validator.setStatus(Status.OK_STATUS); + } + } catch (CoreException e) { + validator.setStatus(e.getStatus()); + } catch (Exception e) { + throw new InvocationTargetException(e); + } finally { + monitor.done(); + } + } + }); + } catch (InvocationTargetException e) { + MylarStatusHandler.fail(e.getCause(), "Internal error validating repository", true); + return; + } catch (InterruptedException e) { + // canceled + return; + } + + applyValidatorResult(validator); + getWizard().getContainer().updateButtons(); + } + + protected void applyValidatorResult(Validator validator) { + IStatus status = validator.getStatus(); + String message = status.getMessage(); + if (message == null || message.length() == 0) + message = null; + switch (status.getSeverity()) { + case IStatus.OK: + if (status == Status.OK_STATUS) { + if (getUserName().length() > 0) { + message = "Authentication credentials are valid."; + } else { + message = "Repository is valid."; + } + } + setMessage(message, WizardPage.INFORMATION); + break; + case IStatus.INFO: + setMessage(message, WizardPage.INFORMATION); + break; + case IStatus.WARNING: + setMessage(message, WizardPage.WARNING); + break; + default: + setMessage(message, WizardPage.ERROR); + break; + } + setErrorMessage(null); + } + + protected abstract Validator getValidator(TaskRepository repository); + + // public for testing + public abstract class Validator { + + private IStatus status; + + public abstract void run(IProgressMonitor monitor) throws CoreException; + + public IStatus getStatus() { + return status; + } + + public void setStatus(IStatus status) { + this.status = status; + } + + } + +} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/wizards/NewTaskWizard.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/wizards/NewTaskWizard.java new file mode 100644 index 000000000..197a82508 --- /dev/null +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/wizards/NewTaskWizard.java @@ -0,0 +1,108 @@ +/******************************************************************************* + * Copyright (c) 2004 - 2006 Mylar committers and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.eclipse.mylar.tasks.ui.wizards; + +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.mylar.core.MylarStatusHandler; +import org.eclipse.mylar.internal.tasks.ui.TaskListPreferenceConstants; +import org.eclipse.mylar.tasks.core.AbstractAttributeFactory; +import org.eclipse.mylar.tasks.core.AbstractRepositoryConnector; +import org.eclipse.mylar.tasks.core.ITaskDataHandler; +import org.eclipse.mylar.tasks.core.RepositoryTaskData; +import org.eclipse.mylar.tasks.core.Task; +import org.eclipse.mylar.tasks.core.TaskRepository; +import org.eclipse.mylar.tasks.ui.TasksUiPlugin; +import org.eclipse.mylar.tasks.ui.TasksUiUtil; +import org.eclipse.mylar.tasks.ui.editors.NewTaskEditorInput; +import org.eclipse.ui.INewWizard; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PlatformUI; + +/** + * @author Steffen Pingel + */ +public class NewTaskWizard extends Wizard implements INewWizard { + + private TaskRepository taskRepository; + + public NewTaskWizard(TaskRepository taskRepository) { + this.taskRepository = taskRepository; + } + + public void init(IWorkbench workbench, IStructuredSelection selection) { + } + + @Override + public void addPages() { + } + + @Override + public boolean canFinish() { + return true; + } + + @Override + public boolean performFinish() { + AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager().getRepositoryConnector( + taskRepository.getKind()); + + final ITaskDataHandler taskDataHandler = (ITaskDataHandler) connector.getTaskDataHandler(); + if (taskDataHandler == null) { + MylarStatusHandler.displayStatus("Error creating new task", new Status(IStatus.ERROR, + TasksUiPlugin.PLUGIN_ID, IStatus.OK, "The selected repository does not support creating new tasks.", null)); + return false; + } + + AbstractAttributeFactory attributeFactory = taskDataHandler.getAttributeFactory(taskRepository.getUrl(), taskRepository.getKind(), Task.DEFAULT_TASK_KIND); + + final RepositoryTaskData taskData = new RepositoryTaskData(attributeFactory, taskRepository.getKind(), + taskRepository.getUrl(), TasksUiPlugin.getDefault().getNextNewRepositoryTaskId(), Task.DEFAULT_TASK_KIND); + taskData.setNew(true); + + try { + IRunnableWithProgress runnable = new IRunnableWithProgress() { + public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { + try { + if (!taskDataHandler.initializeTaskData(taskRepository, taskData, monitor)) { + throw new CoreException(new Status(IStatus.ERROR, + TasksUiPlugin.PLUGIN_ID, IStatus.OK, "The selected repository does not support creating new tasks.", null)); + } + } catch (CoreException e) { + throw new InvocationTargetException(e); + } + } + }; + + getContainer().run(true, true, runnable); + } catch (InvocationTargetException e) { + if (e.getCause() instanceof CoreException) { + MylarStatusHandler.displayStatus("Error creating new task", ((CoreException) e.getCause()).getStatus()); + } else { + MylarStatusHandler.fail(e.getCause(), "Error creating new task", true); + } + return false; + } catch (InterruptedException e) { + return false; + } + + NewTaskEditorInput editorInput = new NewTaskEditorInput(taskRepository, taskData); + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + TasksUiUtil.openEditor(editorInput, TaskListPreferenceConstants.TASK_EDITOR_ID, page); + return true; + } +} diff --git a/org.eclipse.mylyn.trac-feature/feature.xml b/org.eclipse.mylyn.trac-feature/feature.xml index fd93bdc5a..1518babb6 100644 --- a/org.eclipse.mylyn.trac-feature/feature.xml +++ b/org.eclipse.mylyn.trac-feature/feature.xml @@ -2,7 +2,7 @@ <feature id="org.eclipse.mylar.trac_feature" label="Mylar Connector: Trac" - version="2.0.0.v20070216" + version="2.0.0.v20070223-1930" provider-name="Eclipse.org" plugin="org.eclipse.mylar"> @@ -234,14 +234,14 @@ litigation. id="org.eclipse.mylar.trac.ui" download-size="0" install-size="0" - version="2.0.0.v20070216" + version="2.0.0.v20070223-1930" unpack="false"/> <plugin id="org.eclipse.mylar.trac.core" download-size="0" install-size="0" - version="2.0.0.v20070216" + version="2.0.0.v20070223-1930" unpack="false"/> </feature> |