Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 116890 Details for
Bug 244653
[api] extension for repository properties wizard page
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
final patch
clipboard.txt (text/plain), 41.31 KB, created by
Steffen Pingel
on 2008-11-03 20:19:48 EST
(
hide
)
Description:
final patch
Filename:
MIME Type:
Creator:
Steffen Pingel
Created:
2008-11-03 20:19:48 EST
Size:
41.31 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylyn.tasks.ui >Index: src/org/eclipse/mylyn/internal/tasks/ui/wizards/EditRepositoryWizard.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/EditRepositoryWizard.java,v >retrieving revision 1.34 >diff -u -r1.34 EditRepositoryWizard.java >--- src/org/eclipse/mylyn/internal/tasks/ui/wizards/EditRepositoryWizard.java 7 Oct 2008 05:09:48 -0000 1.34 >+++ src/org/eclipse/mylyn/internal/tasks/ui/wizards/EditRepositoryWizard.java 4 Nov 2008 01:19:32 -0000 >@@ -18,6 +18,7 @@ > import org.eclipse.jface.viewers.IStructuredSelection; > import org.eclipse.jface.wizard.Wizard; > import org.eclipse.mylyn.commons.core.StatusHandler; >+import org.eclipse.mylyn.internal.tasks.core.LocalRepositoryConnector; > import org.eclipse.mylyn.internal.tasks.ui.RefactorRepositoryUrlOperation; > import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin; > import org.eclipse.mylyn.tasks.core.TaskRepository; >@@ -72,7 +73,9 @@ > > repository.flushAuthenticationCredentials(); > >- repository.setRepositoryUrl(newUrl); >+ if (!repository.getConnectorKind().equals(LocalRepositoryConnector.CONNECTOR_KIND)) { >+ repository.setRepositoryUrl(newUrl); >+ } > settingsPage.applyTo(repository); > if (oldUrl != null && newUrl != null && !oldUrl.equals(newUrl)) { > TasksUiPlugin.getRepositoryManager().notifyRepositoryUrlChanged(repository, oldUrl); >@@ -90,8 +93,7 @@ > @Override > public void addPages() { > AbstractRepositoryConnectorUi connectorUi = TasksUiPlugin.getConnectorUi(repository.getConnectorKind()); >- // TODO 3.1 pass repository >- settingsPage = connectorUi.getSettingsPage(null); >+ settingsPage = connectorUi.getSettingsPage(repository); > if (settingsPage instanceof AbstractRepositorySettingsPage) { > ((AbstractRepositorySettingsPage) settingsPage).setRepository(repository); > ((AbstractRepositorySettingsPage) settingsPage).setVersion(repository.getVersion()); >Index: src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorExtensions.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorExtensions.java,v >retrieving revision 1.1 >diff -u -r1.1 TaskEditorExtensions.java >--- src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorExtensions.java 17 Oct 2008 03:22:28 -0000 1.1 >+++ src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorExtensions.java 4 Nov 2008 01:19:32 -0000 >@@ -86,7 +86,7 @@ > init(); > String id = taskRepository.getProperty(REPOSITORY_PROPERTY_EDITOR_EXTENSION); > if (id == null) { >- // TODO 3.1 disabled until bug 244653 is resolved >+ // TODO 3.1 disabled until bug 253115 is resolved > //id = getDefaultTaskEditorExtensionId(taskRepository); > } > return id; >@@ -96,9 +96,27 @@ > repository.setProperty(REPOSITORY_PROPERTY_EDITOR_EXTENSION, editorExtensionId); > } > >+ /** >+ * Get the default task editor extension id for the given task repository >+ * >+ * @param taskRepository >+ * @return the default task editor extension id or null if there is no default >+ */ > public static String getDefaultTaskEditorExtensionId(TaskRepository taskRepository) { >+ return getDefaultTaskEditorExtensionId(taskRepository.getConnectorKind()); >+ } >+ >+ /** >+ * Get the default task editor extension id for the given kind of connector >+ * >+ * @param connectorKind >+ * the kind of connector >+ * >+ * @return the default task editor extension id or null if there is no default >+ */ >+ public static String getDefaultTaskEditorExtensionId(String connectorKind) { > init(); >- return associationByConnectorKind.get(taskRepository.getConnectorKind()); >+ return associationByConnectorKind.get(connectorKind); > } > > /** >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/plugin.xml,v >retrieving revision 1.341 >diff -u -r1.341 plugin.xml >--- plugin.xml 17 Oct 2008 03:22:28 -0000 1.341 >+++ plugin.xml 4 Nov 2008 01:19:32 -0000 >@@ -8,6 +8,7 @@ > <extension-point id="duplicateDetectors" name="duplicateDetectors" schema="schema/duplicateDetectors.exsd"/> > <extension-point id="presentations" name="presentations" schema="schema/presentations.exsd"/> > <extension-point id="taskEditorExtensions" name="Task Editor Extension" schema="schema/taskEditorExtensions.exsd"/> >+ <extension-point id="taskRepositoryPageContribution" name="Task Repository Page Contribution" schema="schema/taskRepositoryPageContribution.exsd"/> > > <extension > point="org.eclipse.mylyn.context.core.bridges"> >Index: src/org/eclipse/mylyn/tasks/ui/wizards/AbstractRepositorySettingsPage.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/wizards/AbstractRepositorySettingsPage.java,v >retrieving revision 1.59 >diff -u -r1.59 AbstractRepositorySettingsPage.java >--- src/org/eclipse/mylyn/tasks/ui/wizards/AbstractRepositorySettingsPage.java 12 Sep 2008 04:19:26 -0000 1.59 >+++ src/org/eclipse/mylyn/tasks/ui/wizards/AbstractRepositorySettingsPage.java 4 Nov 2008 01:19:33 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >-* Copyright (c) 2004, 2008 Tasktop Technologies and others. >+ * Copyright (c) 2004, 2008 Tasktop Technologies 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 >@@ -28,7 +28,6 @@ > import org.eclipse.jface.operation.IRunnableWithProgress; > import org.eclipse.jface.preference.PreferenceDialog; > import org.eclipse.jface.preference.StringFieldEditor; >-import org.eclipse.jface.wizard.WizardPage; > import org.eclipse.mylyn.commons.core.StatusHandler; > import org.eclipse.mylyn.commons.net.AuthenticationCredentials; > import org.eclipse.mylyn.commons.net.AuthenticationType; >@@ -67,7 +66,6 @@ > import org.eclipse.ui.forms.events.HyperlinkEvent; > import org.eclipse.ui.forms.events.IHyperlinkListener; > import org.eclipse.ui.forms.widgets.ExpandableComposite; >-import org.eclipse.ui.forms.widgets.FormToolkit; > import org.eclipse.ui.forms.widgets.Hyperlink; > > /** >@@ -78,8 +76,10 @@ > * @author Rob Elves > * @author Steffen Pingel > * @author Frank Becker >+ * @author David Green >+ * @since 2.0 > */ >-public abstract class AbstractRepositorySettingsPage extends WizardPage implements ITaskRepositoryPage { >+public abstract class AbstractRepositorySettingsPage extends AbstractTaskRepositoryPage implements ITaskRepositoryPage { > > protected static final String PREFS_PAGE_ID_NET_PROXY = "org.eclipse.ui.net.NetPreferences"; > >@@ -123,6 +123,7 @@ > > protected StringFieldEditor proxyPasswordEditor; > >+ // FIXME shadows declaration in super > protected TaskRepository repository; > > private Button validateServerButton; >@@ -205,18 +206,13 @@ > > private Button disconnectedButton; > >- // TODO 3.1 make accessible to subclasses >- private FormToolkit toolkit; >- > /** > * @since 3.0 > */ > public AbstractRepositorySettingsPage(String title, String description, TaskRepository taskRepository) { >- super(title); >- this.repository = taskRepository; >+ super(title, description, taskRepository); >+ repository = taskRepository; > this.connector = TasksUi.getRepositoryManager().getRepositoryConnector(getConnectorKind()); >- setTitle(title); >- setDescription(description); > setNeedsAnonymousLogin(false); > setNeedsEncoding(true); > setNeedsTimeZone(true); >@@ -228,20 +224,27 @@ > /** > * @since 3.0 > */ >+ @Override > public abstract String getConnectorKind(); > > @Override > public void dispose() { > super.dispose(); >- if (toolkit != null) { >- toolkit.dispose(); >- toolkit = null; >- } > } > >- public void createControl(Composite parent) { >- toolkit = new FormToolkit(TasksUiPlugin.getDefault().getFormColors(parent.getDisplay())); >+ /** >+ * @since 2.0 >+ */ >+ @Override >+ protected void createContents(Composite parent) { >+ createSettingControls(parent); >+ } > >+ /** >+ * @since 2.0 >+ */ >+ @Override >+ protected void createSettingControls(Composite parent) { > if (repository != null) { > originalUrl = repository.getRepositoryUrl(); > AuthenticationCredentials oldCredentials = repository.getCredentials(AuthenticationType.REPOSITORY); >@@ -628,6 +631,8 @@ > > addStatusSection(); > >+ addContributionSection(); >+ > Composite managementComposite = new Composite(compositeContainer, SWT.NULL); > GridLayout managementLayout = new GridLayout(4, false); > managementLayout.marginHeight = 0; >@@ -701,7 +706,6 @@ > > updateHyperlinks(); > >- setControl(compositeContainer); > } > > private void addProxySection() { >@@ -855,6 +859,20 @@ > proxyExpComposite.setExpanded(!systemProxyButton.getSelection()); > } > >+ private void addContributionSection() { >+ Composite composite = toolkit.createComposite(compositeContainer); >+ GridDataFactory.fillDefaults().grab(true, false).span(2, SWT.DEFAULT).applyTo(composite); >+ >+ GridLayout layout = new GridLayout(1, false); >+ layout.marginWidth = 0; >+ layout.marginTop = -5; >+ composite.setLayout(layout); >+ >+ composite.setBackground(compositeContainer.getBackground()); >+ >+ createContributionControls(composite); >+ } >+ > private void addStatusSection() { > ExpandableComposite statusComposite = toolkit.createExpandableComposite(compositeContainer, > ExpandableComposite.COMPACT | ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR); >@@ -912,6 +930,9 @@ > } > } > >+ /** >+ * @since 2.0 >+ */ > public void setAnonymous(boolean selected) { > if (!needsAnonymousLogin) { > return; >@@ -937,6 +958,9 @@ > } > } > >+ /** >+ * @since 2.0 >+ */ > public void setHttpAuth(boolean selected) { > if (!needsHttpAuth) { > return; >@@ -963,6 +987,9 @@ > return httpAuthButton.getSelection(); > } > >+ /** >+ * @since 2.0 >+ */ > public void setUseDefaultProxy(boolean selected) { > if (!needsProxy) { > return; >@@ -985,8 +1012,10 @@ > setProxyAuth(proxyAuthButton.getSelection()); > } > >+ /** >+ * @since 2.0 >+ */ > public void setProxyAuth(boolean selected) { >- > proxyAuthButton.setSelection(selected); > proxyAuthButton.setEnabled(!systemProxyButton.getSelection()); > if (!selected) { >@@ -1039,8 +1068,14 @@ > protected void repositoryTemplateSelected(RepositoryTemplate template) { > } > >+ /** >+ * @since 2.0 >+ */ > protected abstract void createAdditionalControls(Composite parent); > >+ /** >+ * @since 2.0 >+ */ > protected abstract boolean isValidUrl(String name); > > private void updateHyperlinks() { >@@ -1064,6 +1099,9 @@ > } > } > >+ /** >+ * @since 2.0 >+ */ > public String getRepositoryLabel() { > return repositoryLabelEditor.getStringValue(); > } >@@ -1075,14 +1113,23 @@ > return TaskRepositoryManager.stripSlashes(serverUrlCombo.getText()); > } > >+ /** >+ * @since 2.0 >+ */ > public String getUserName() { > return repositoryUserNameEditor.getStringValue(); > } > >+ /** >+ * @since 2.0 >+ */ > public String getPassword() { > return repositoryPasswordEditor.getStringValue(); > } > >+ /** >+ * @since 2.0 >+ */ > public String getHttpAuthUserId() { > if (needsHttpAuth()) { > return httpAuthUserNameEditor.getStringValue(); >@@ -1091,6 +1138,9 @@ > } > } > >+ /** >+ * @since 2.0 >+ */ > public String getHttpAuthPassword() { > if (needsHttpAuth()) { > return httpAuthPasswordEditor.getStringValue(); >@@ -1099,6 +1149,9 @@ > } > } > >+ /** >+ * @since 2.0 >+ */ > public String getProxyHostname() { > if (needsProxy()) { > return proxyHostnameEditor.getStringValue(); >@@ -1107,6 +1160,9 @@ > } > } > >+ /** >+ * @since 2.0 >+ */ > public String getProxyPort() { > if (needsProxy()) { > return proxyPortEditor.getStringValue(); >@@ -1115,6 +1171,9 @@ > } > } > >+ /** >+ * @since 2.0 >+ */ > public Boolean getUseDefaultProxy() { > if (needsProxy()) { > return systemProxyButton.getSelection(); >@@ -1123,6 +1182,9 @@ > } > } > >+ /** >+ * @since 2.0 >+ */ > public String getProxyUserName() { > if (needsProxy()) { > return proxyUserNameEditor.getStringValue(); >@@ -1131,6 +1193,9 @@ > } > } > >+ /** >+ * @since 2.0 >+ */ > public String getProxyPassword() { > if (needsProxy()) { > return proxyPasswordEditor.getStringValue(); >@@ -1139,10 +1204,16 @@ > } > } > >+ /** >+ * @since 2.0 >+ */ > public void init(IWorkbench workbench) { > // ignore > } > >+ /** >+ * @since 2.0 >+ */ > public boolean isAnonymousAccess() { > if (anonymousButton != null) { > return anonymousButton.getSelection(); >@@ -1191,7 +1262,7 @@ > } > > setErrorMessage(errorMessage); >- return errorMessage == null; >+ return errorMessage == null && super.isPageComplete(); > } > > private String credentialsComplete() { >@@ -1206,6 +1277,9 @@ > || repositoryPasswordEditor.getStringValue().trim().equals(""); > } > >+ /** >+ * @since 2.0 >+ */ > protected String isUniqueUrl(String urlString) { > if (!urlString.equals(originalUrl)) { > if (repositoryUrls == null) { >@@ -1223,11 +1297,17 @@ > return null; > } > >+ /** >+ * @since 2.0 >+ */ > @Deprecated > public void setRepository(TaskRepository repository) { > this.repository = repository; > } > >+ /** >+ * @since 2.0 >+ */ > public void setVersion(String previousVersion) { > if (previousVersion == null) { > serverVersion = TaskRepository.NO_VERSION_SPECIFIED; >@@ -1236,14 +1316,23 @@ > } > } > >+ /** >+ * @since 2.0 >+ */ > public String getVersion() { > return serverVersion; > } > >+ /** >+ * @since 2.0 >+ */ > public TaskRepository getRepository() { > return repository; > } > >+ /** >+ * @since 2.0 >+ */ > public String getCharacterEncoding() { > if (defaultEncoding == null) { > return null; >@@ -1260,6 +1349,9 @@ > } > } > >+ /** >+ * @since 2.0 >+ */ > public TaskRepository createTaskRepository() { > TaskRepository repository = new TaskRepository(connector.getConnectorKind(), getRepositoryUrl()); > applyTo(repository); >@@ -1269,6 +1361,7 @@ > /** > * @since 2.2 > */ >+ @Override > public void applyTo(TaskRepository repository) { > repository.setVersion(getVersion()); > if (needsEncoding()) { >@@ -1307,56 +1400,97 @@ > } > > repository.setOffline(disconnectedButton.getSelection()); >+ >+ super.applyTo(repository); > } > >+ /** >+ * @since 2.0 >+ */ > public AbstractRepositoryConnector getConnector() { > return connector; > } > >+ /** >+ * @since 2.0 >+ */ > public boolean needsEncoding() { > return needsEncoding; > } > >+ /** >+ * @since 2.0 >+ */ > public boolean needsTimeZone() { > return needsTimeZone; > } > >+ /** >+ * @since 2.0 >+ */ > public boolean needsAnonymousLogin() { > return needsAnonymousLogin; > } > >+ /** >+ * @since 2.0 >+ */ > public boolean needsAdvanced() { > return needsAdvanced; > } > >+ /** >+ * @since 2.0 >+ */ > public void setNeedsEncoding(boolean needsEncoding) { > this.needsEncoding = needsEncoding; > } > >+ /** >+ * @since 2.0 >+ */ > public void setNeedsTimeZone(boolean needsTimeZone) { > this.needsTimeZone = needsTimeZone; > } > >+ /** >+ * @since 2.0 >+ */ > public void setNeedsAdvanced(boolean needsAdvanced) { > this.needsAdvanced = needsAdvanced; > } > >+ /** >+ * @since 2.0 >+ */ > public boolean needsHttpAuth() { > return this.needsHttpAuth; > } > >+ /** >+ * @since 2.0 >+ */ > public void setNeedsHttpAuth(boolean needsHttpAuth) { > this.needsHttpAuth = needsHttpAuth; > } > >+ /** >+ * @since 2.0 >+ */ > public void setNeedsProxy(boolean needsProxy) { > this.needsProxy = needsProxy; > } > >+ /** >+ * @since 2.0 >+ */ > public boolean needsProxy() { > return this.needsProxy; > } > >+ /** >+ * @since 2.0 >+ */ > public void setNeedsAnonymousLogin(boolean needsAnonymousLogin) { > this.needsAnonymousLogin = needsAnonymousLogin; > } >@@ -1365,21 +1499,36 @@ > this.needsValidation = needsValidation; > } > >+ /** >+ * @since 2.0 >+ */ > public boolean needsValidation() { > return needsValidation; > } > >- /** for testing */ >+ /** >+ * Public for testing. >+ * >+ * @since 2.0 >+ */ > public void setUrl(String url) { > serverUrlCombo.setText(url); > } > >- /** for testing */ >+ /** >+ * Public for testing. >+ * >+ * @since 2.0 >+ */ > public void setUserId(String id) { > repositoryUserNameEditor.setStringValue(id); > } > >- /** for testing */ >+ /** >+ * Public for testing. >+ * >+ * @since 2.0 >+ */ > public void setPassword(String pass) { > repositoryPasswordEditor.setStringValue(pass); > } >@@ -1413,6 +1562,11 @@ > } > } > >+ /** >+ * Validate settings provided by the {@link #getValidator(TaskRepository) validator}, typically the server settings. >+ * >+ * @since 2.0 >+ */ > protected void validateSettings() { > final Validator validator = getValidator(createTaskRepository()); > if (validator == null) { >@@ -1453,6 +1607,17 @@ > getWizard().getContainer().updateButtons(); > } > >+ /** >+ * @since 3.1 >+ */ >+ @Override >+ protected IStatus validate() { >+ return null; >+ } >+ >+ /** >+ * @since 2.0 >+ */ > protected void applyValidatorResult(Validator validator) { > IStatus status = validator.getStatus(); > String message = status.getMessage(); >@@ -1483,9 +1648,16 @@ > setErrorMessage(null); > } > >+ /** >+ * @since 2.0 >+ */ > protected abstract Validator getValidator(TaskRepository repository); > >- // public for testing >+ /** >+ * Public for testing. >+ * >+ * @since 2.0 >+ */ > public abstract class Validator { > > private IStatus status; >Index: schema/taskRepositoryPageContribution.exsd >=================================================================== >RCS file: schema/taskRepositoryPageContribution.exsd >diff -N schema/taskRepositoryPageContribution.exsd >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ schema/taskRepositoryPageContribution.exsd 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,119 @@ >+<?xml version='1.0' encoding='UTF-8'?> >+<!-- Schema file written by PDE --> >+<schema targetNamespace="org.eclipse.mylyn.tasks.ui" xmlns="http://www.w3.org/2001/XMLSchema"> >+<annotation> >+ <appinfo> >+ <meta.schema plugin="org.eclipse.mylyn.tasks.ui" id="taskRepositoryPageContribution" name="Task Repository Page Contribution"/> >+ </appinfo> >+ <documentation> >+ This extension point enables plug-ins to contribute user interface to the task repository settings dialog. >+ </documentation> >+ </annotation> >+ >+ <element name="extension"> >+ <annotation> >+ <appinfo> >+ <meta.element /> >+ </appinfo> >+ </annotation> >+ <complexType> >+ <sequence> >+ <element ref="taskRepositoryPageContribution" minOccurs="1" maxOccurs="unbounded"/> >+ </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="taskRepositoryPageContribution"> >+ <complexType> >+ <attribute name="class" type="string" use="required"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ <appinfo> >+ <meta.attribute kind="java" basedOn="org.eclipse.mylyn.tasks.ui.wizards.AbstractTaskRepositoryPageContribution:"/> >+ </appinfo> >+ </annotation> >+ </attribute> >+ <attribute name="connectorKind" type="string"> >+ <annotation> >+ <documentation> >+ the kind of repository connector for which this contributor should be used, or "" (the empty string) if it applies to all connectors >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="id" type="string" use="required"> >+ <annotation> >+ <documentation> >+ a unique identifier that identifies the contribution >+ </documentation> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <annotation> >+ <appinfo> >+ <meta.section type="since"/> >+ </appinfo> >+ <documentation> >+ 3.1 >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appinfo> >+ <meta.section type="examples"/> >+ </appinfo> >+ <documentation> >+ <extension >+ point="org.eclipse.mylyn.tasks.ui.taskRepositoryPageContribution"> >+ <taskRepositoryPageContribution class="org.eclipse.mylyn.internal.tasks.ui.wizards.TaskEditorExtensionSettingsContribution"/> >+ </extension> >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appinfo> >+ <meta.section type="apiinfo"/> >+ </appinfo> >+ <documentation> >+ [Enter API information here.] >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appinfo> >+ <meta.section type="implementation"/> >+ </appinfo> >+ <documentation> >+ [Enter information about supplied implementation of this extension point.] >+ </documentation> >+ </annotation> >+ >+ >+</schema> >Index: src/org/eclipse/mylyn/tasks/ui/wizards/AbstractTaskRepositoryPageContribution.java >=================================================================== >RCS file: src/org/eclipse/mylyn/tasks/ui/wizards/AbstractTaskRepositoryPageContribution.java >diff -N src/org/eclipse/mylyn/tasks/ui/wizards/AbstractTaskRepositoryPageContribution.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/tasks/ui/wizards/AbstractTaskRepositoryPageContribution.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,214 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2008 David Green 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: >+ * David Green - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylyn.tasks.ui.wizards; >+ >+import java.util.List; >+import java.util.concurrent.CopyOnWriteArrayList; >+ >+import org.eclipse.core.runtime.Assert; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.jface.dialogs.IDialogPage; >+import org.eclipse.jface.wizard.IWizardPage; >+import org.eclipse.mylyn.tasks.core.TaskRepository; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+ >+/** >+ * A contribution to a {@link ITaskRepositoryPage}, which enables plug-ins to contribute UI to the task repository >+ * settings. >+ * >+ * subclasses must have a default public constructor. >+ * >+ * @author David Green >+ * @since 3.1 >+ */ >+public abstract class AbstractTaskRepositoryPageContribution { >+ >+ /** >+ * A listener interface that should be implemented by classes wishing to be notified of changes that occur within >+ * the contribution. >+ * >+ * @since 3.1 >+ */ >+ public interface Listener { >+ >+ /** >+ * Called when the state of the contribution changes such that validation should be performed >+ * >+ * @param contribution >+ * the contribution that changed >+ * >+ * @see ITaskRepositoryPageContribution#validate(IProgressMonitor) >+ */ >+ public void validationRequired(AbstractTaskRepositoryPageContribution contribution); >+ >+ } >+ >+ private final List<Listener> listeners = new CopyOnWriteArrayList<Listener>(); >+ >+ private final String title; >+ >+ private final String description; >+ >+ private TaskRepository repository; >+ >+ private String connectorKind; >+ >+ private String id; >+ >+ /** >+ * >+ * @param title >+ * the title of the contribution, as displayed to the user, usually used as a section heading >+ * @param description >+ * the description of the contribution, as displayed to the user, typically as a tool-tip >+ * @since 3.1 >+ */ >+ protected AbstractTaskRepositoryPageContribution(String title, String description) { >+ this.title = title; >+ this.description = description; >+ this.id = ""; >+ } >+ >+ /** >+ * Initialize the contribution >+ * >+ * @param connectorKind >+ * the kind of connector for which this is a contribution >+ * @param repository >+ * the repository for which this contribution was created, or null if the repository is not yet available >+ * @since 3.1 >+ */ >+ public void init(String connectorKind, TaskRepository repository) { >+ this.connectorKind = connectorKind; >+ this.repository = repository; >+ } >+ >+ /** >+ * Add a listener to this contribution. The contribution must notify the listener at the appropriate times, for >+ * example when a setting has changed in the UI. >+ * >+ * @see #removeListener(Listener) >+ * @since 3.1 >+ */ >+ public void addListener(Listener listener) { >+ listeners.add(listener); >+ } >+ >+ /** >+ * Remove a listener from this contribution. >+ * >+ * @see #addListener(Listener) >+ * @since 3.1 >+ */ >+ public void removeListener(Listener listener) { >+ listeners.remove(listener); >+ } >+ >+ /** >+ * @see IDialogPage#createControl(Composite) >+ * @since 3.1 >+ */ >+ public abstract Control createControl(Composite parent); >+ >+ /** >+ * @see IDialogPage#getTitle() >+ * @since 3.1 >+ */ >+ public String getTitle() { >+ return title; >+ } >+ >+ /** >+ * @see IDialogPage#getDescription() >+ * @since 3.1 >+ */ >+ public String getDescription() { >+ return description; >+ } >+ >+ /** >+ * @see IWizardPage#isPageComplete() >+ * @since 3.1 >+ */ >+ public abstract boolean isPageComplete(); >+ >+ /** >+ * @see IWizardPage#canFlipToNextPage() >+ * @since 3.1 >+ */ >+ public abstract boolean canFlipToNextPage(); >+ >+ /** >+ * Validate the settings of the contribution. Contributions should expect this method to be called often and should >+ * thus return quickly. Always called on the UI thread. >+ * >+ * @return the status (errors) on the contribution, or null if there are none. A MultiStatus should be used to >+ * return multiple error messages or warnings. >+ * @since 3.1 >+ */ >+ public abstract IStatus validate(); >+ >+ /** >+ * Apply the settings in the contribution to the given repository. >+ * >+ * @param repository >+ * the repository to which settings should be applied >+ * >+ * @see ITaskRepositoryPage#applyTo(TaskRepository) >+ * @since 3.1 >+ */ >+ public abstract void applyTo(TaskRepository repository); >+ >+ /** >+ * Requests a validation. >+ * >+ * @see #validate() >+ * @since 3.1 >+ */ >+ protected void fireValidationRequired() { >+ for (Listener l : listeners) { >+ l.validationRequired(this); >+ } >+ } >+ >+ /** >+ * Returns the repository for which this contribution was created, or null if it was created for a new repository. >+ * >+ * @since 3.1 >+ */ >+ protected final TaskRepository getRepository() { >+ return repository; >+ } >+ >+ /** >+ * Returns the kind of connector for which this contribution was created. >+ * >+ * @since 3.1 >+ */ >+ protected final String getConnectorKind() { >+ return connectorKind; >+ } >+ >+ void setId(String id) { >+ Assert.isNotNull(id); >+ this.id = id; >+ } >+ >+ /** >+ * Returns the id as it is declared in the contribution extension point. >+ */ >+ public final String getId() { >+ return id; >+ } >+} >Index: src/org/eclipse/mylyn/tasks/ui/wizards/AbstractTaskRepositoryPage.java >=================================================================== >RCS file: src/org/eclipse/mylyn/tasks/ui/wizards/AbstractTaskRepositoryPage.java >diff -N src/org/eclipse/mylyn/tasks/ui/wizards/AbstractTaskRepositoryPage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/tasks/ui/wizards/AbstractTaskRepositoryPage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,395 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2008 David Green 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: >+ * David Green - initial API and implementation >+ * Tasktop Technologies - improvement >+ *******************************************************************************/ >+ >+package org.eclipse.mylyn.tasks.ui.wizards; >+ >+import java.util.ArrayList; >+import java.util.Collections; >+import java.util.Comparator; >+import java.util.List; >+ >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.IExtension; >+import org.eclipse.core.runtime.IExtensionPoint; >+import org.eclipse.core.runtime.IExtensionRegistry; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.MultiStatus; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.jface.dialogs.IMessageProvider; >+import org.eclipse.jface.layout.GridDataFactory; >+import org.eclipse.jface.util.SafeRunnable; >+import org.eclipse.jface.wizard.WizardPage; >+import org.eclipse.mylyn.commons.core.StatusHandler; >+import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin; >+import org.eclipse.mylyn.tasks.core.TaskRepository; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.ui.forms.events.ExpansionAdapter; >+import org.eclipse.ui.forms.events.ExpansionEvent; >+import org.eclipse.ui.forms.widgets.ExpandableComposite; >+import org.eclipse.ui.forms.widgets.FormToolkit; >+ >+/** >+ * An abstract base class for repository settings page that supports the <code>taskRepositoryPageContribution</code> >+ * extension point. >+ * >+ * {@link ITaskRepositoryPage} implementations are encouraged to extend {@link AbstractRepositorySettingsPage} if >+ * possible as it provides a standard UI for managing server settings. >+ * >+ * @see AbstractRepositorySettingsPage >+ * @author David Green >+ * @author Steffen Pingel >+ * @since 3.1 >+ */ >+public abstract class AbstractTaskRepositoryPage extends WizardPage implements ITaskRepositoryPage { >+ >+ private static final String KIND = "connectorKind"; >+ >+ private static final String TASK_REPOSITORY_PAGE_CONTRIBUTION = "taskRepositoryPageContribution"; >+ >+ private static final String TASK_REPOSITORY_PAGE_CONTRIBUTION_EXTENSION = "org.eclipse.mylyn.tasks.ui.taskRepositoryPageContribution"; >+ >+ private static final Comparator<AbstractTaskRepositoryPageContribution> CONTRIBUTION_COMPARATOR = new ContributionComparator(); >+ >+ private final TaskRepository repository; >+ >+ private final List<AbstractTaskRepositoryPageContribution> contributions; >+ >+ FormToolkit toolkit; >+ >+ private Composite compositeContainer; >+ >+ private final AbstractTaskRepositoryPageContribution.Listener contributionListener = new AbstractTaskRepositoryPageContribution.Listener() { >+ public void validationRequired(AbstractTaskRepositoryPageContribution contribution) { >+ validatePageSettings(); >+ } >+ }; >+ >+ /** >+ * @since 3.1 >+ */ >+ public AbstractTaskRepositoryPage(String title, String description, TaskRepository repository) { >+ super(title); >+ if (repository != null && !repository.getConnectorKind().equals(getConnectorKind())) { >+ throw new IllegalArgumentException("connectorKind of repository does not match connectorKind of page"); >+ } >+ this.repository = repository; >+ this.contributions = new ArrayList<AbstractTaskRepositoryPageContribution>(); >+ setTitle(title); >+ setDescription(description); >+ } >+ >+ /** >+ * Get the kind of connector supported by this page. >+ * >+ * @return the kind of connector, never null >+ * @since 3.1 >+ */ >+ public abstract String getConnectorKind(); >+ >+ @Override >+ public void dispose() { >+ if (toolkit != null) { >+ toolkit.dispose(); >+ toolkit = null; >+ } >+ super.dispose(); >+ } >+ >+ public void createControl(Composite parent) { >+ toolkit = new FormToolkit(TasksUiPlugin.getDefault().getFormColors(parent.getDisplay())); >+ >+ compositeContainer = new Composite(parent, SWT.NULL); >+ GridLayout layout = new GridLayout(1, true); >+ compositeContainer.setLayout(layout); >+ >+ createContents(compositeContainer); >+ >+ setControl(compositeContainer); >+ } >+ >+ /** >+ * Creates the contents of the page. Subclasses may override this method to change where the contributions are >+ * added. >+ * >+ * @since 3.1 >+ */ >+ protected void createContents(Composite parent) { >+ createSettingControls(parent); >+ createContributionControls(parent); >+ } >+ >+ /** >+ * Creates the controls of this page. >+ * >+ * @since 3.1 >+ */ >+ protected abstract void createSettingControls(Composite parent); >+ >+ @Override >+ public boolean isPageComplete() { >+ return super.isPageComplete() && conributionsIsPageComplete(); >+ } >+ >+ @Override >+ public boolean canFlipToNextPage() { >+ return super.canFlipToNextPage() && contributionsCanFlipToNextPage(); >+ } >+ >+ private boolean contributionsCanFlipToNextPage() { >+ for (AbstractTaskRepositoryPageContribution contribution : contributions) { >+ if (!contribution.canFlipToNextPage()) { >+ return false; >+ } >+ } >+ return true; >+ } >+ >+ private boolean conributionsIsPageComplete() { >+ for (AbstractTaskRepositoryPageContribution contribution : contributions) { >+ if (!contribution.isPageComplete()) { >+ return false; >+ } >+ } >+ return true; >+ } >+ >+ /** >+ * Subclasses should only call this method if they override {@link #createContents(Composite)}. >+ * >+ * @param parentControl >+ * the container into which the contributions will create their UI >+ * @since 3.1 >+ */ >+ protected void createContributionControls(final Composite parentControl) { >+ contributions.clear(); >+ contributions.addAll(findApplicableContributors()); >+ >+ if (!contributions.isEmpty()) { >+ final List<AbstractTaskRepositoryPageContribution> badContributions = new ArrayList<AbstractTaskRepositoryPageContribution>(); >+ for (final AbstractTaskRepositoryPageContribution contribution : contributions) { >+ SafeRunnable.run(new SafeRunnable() { >+ public void run() throws Exception { >+ contribution.init(getConnectorKind(), repository); >+ contribution.addListener(contributionListener); >+ } >+ >+ @Override >+ public void handleException(Throwable e) { >+ badContributions.add(contribution); >+ StatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, >+ "Problems occured when initializing contribution \"" + contribution.getId() + "\"", e)); >+ } >+ }); >+ } >+ contributions.removeAll(badContributions); >+ >+ Collections.sort(contributions, CONTRIBUTION_COMPARATOR); >+ >+ for (final AbstractTaskRepositoryPageContribution contribution : contributions) { >+ final ExpandableComposite section = toolkit.createExpandableComposite(parentControl, >+ ExpandableComposite.COMPACT | ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR); >+ section.clientVerticalSpacing = 0; >+ section.setBackground(parentControl.getBackground()); >+ section.setFont(parentControl.getFont()); >+ section.addExpansionListener(new ExpansionAdapter() { >+ @Override >+ public void expansionStateChanged(ExpansionEvent e) { >+ getControl().getShell().pack(); >+ } >+ }); >+ section.setText(contribution.getTitle()); >+ section.setToolTipText(contribution.getDescription()); >+ >+ GridDataFactory.fillDefaults().grab(true, false).applyTo(section); >+ >+ SafeRunnable.run(new SafeRunnable() { >+ public void run() throws Exception { >+ Composite sectionContentsContainer = toolkit.createComposite(section); >+ sectionContentsContainer.setBackground(parentControl.getBackground()); >+ contribution.createControl(sectionContentsContainer); >+ section.setClient(sectionContentsContainer); >+ } >+ >+ @Override >+ public void handleException(Throwable e) { >+ section.dispose(); >+ StatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, >+ "Problems occured when creating control for contribution \"" + contribution.getId() >+ + "\"", e)); >+ } >+ }); >+ } >+ } >+ } >+ >+ /** >+ * Validate the settings of this page, not including contributions. This method should not be called directly by >+ * page implementations. Always run on a UI thread. >+ * >+ * @return the status, or null if there are no messages. >+ * @see #validatePageSettings() >+ * @since 3.1 >+ */ >+ protected abstract IStatus validate(); >+ >+ /** >+ * Overriding methods should call <code>super.applyTo(repository)</code> >+ * >+ * @since 3.1 >+ */ >+ public void applyTo(TaskRepository repository) { >+ applyContributionSettingsTo(repository); >+ } >+ >+ private void applyContributionSettingsTo(TaskRepository repository) { >+ for (AbstractTaskRepositoryPageContribution contribution : contributions) { >+ contribution.applyTo(repository); >+ } >+ } >+ >+ /** >+ * Returns a status if there is a message to display, otherwise null. >+ */ >+ private IStatus computeValidation() { >+ final MultiStatus cumulativeResult = new MultiStatus(TasksUiPlugin.ID_PLUGIN, IStatus.OK, "Validation failed", >+ null); >+ >+ // validate the page >+ IStatus result = validate(); >+ if (result != null) { >+ cumulativeResult.add(result); >+ } >+ >+ // validate contributions >+ for (final AbstractTaskRepositoryPageContribution contribution : contributions) { >+ SafeRunnable.run(new SafeRunnable() { >+ public void run() throws Exception { >+ IStatus result = contribution.validate(); >+ if (result != null) { >+ cumulativeResult.add(result); >+ } >+ } >+ >+ @Override >+ public void handleException(Throwable e) { >+ StatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, >+ "Problems occured when validating contribution \"" + contribution.getId() + "\"", e)); >+ } >+ }); >+ } >+ >+ return cumulativeResult; >+ } >+ >+ /** >+ * Validate all settings in the page including contributions. This method should be called whenever a setting is >+ * changed on the page. >+ * >+ * The results of validation are applied and the buttons of the page are updated. >+ * >+ * @see #validate(IProgressMonitor) >+ * @see #applyValidationResult(IStatus[]) >+ */ >+ private void validatePageSettings() { >+ IStatus validationStatus = computeValidation(); >+ applyValidationResult(validationStatus); >+ getWizard().getContainer().updateButtons(); >+ } >+ >+ /** >+ * Apply the results of validation to the page. The implementation finds the most {@link IStatus#getSeverity() >+ * severe} status and {@link #setMessage(String, int) applies the message} to the page. >+ * >+ * @param status >+ * the status of the validation, or null >+ */ >+ private void applyValidationResult(IStatus status) { >+ if (status == null || status.isOK()) { >+ setMessage(null, IMessageProvider.INFORMATION); >+ setErrorMessage(null); >+ } else { >+ // find the most severe status >+ int messageType; >+ switch (status.getSeverity()) { >+ case IStatus.OK: >+ case IStatus.INFO: >+ messageType = IMessageProvider.INFORMATION; >+ break; >+ case IStatus.WARNING: >+ messageType = IMessageProvider.WARNING; >+ break; >+ case IStatus.ERROR: >+ default: >+ messageType = IMessageProvider.ERROR; >+ break; >+ } >+ setErrorMessage(null); >+ setMessage(status.getMessage(), messageType); >+ } >+ } >+ >+ private List<AbstractTaskRepositoryPageContribution> findApplicableContributors() { >+ List<AbstractTaskRepositoryPageContribution> contributors = new ArrayList<AbstractTaskRepositoryPageContribution>(); >+ >+ IExtensionRegistry registry = Platform.getExtensionRegistry(); >+ >+ IExtensionPoint editorExtensionPoint = registry.getExtensionPoint(TASK_REPOSITORY_PAGE_CONTRIBUTION_EXTENSION); >+ IExtension[] editorExtensions = editorExtensionPoint.getExtensions(); >+ for (IExtension extension : editorExtensions) { >+ IConfigurationElement[] elements = extension.getConfigurationElements(); >+ for (IConfigurationElement element : elements) { >+ if (element.getName().equals(TASK_REPOSITORY_PAGE_CONTRIBUTION)) { >+ String kind = element.getAttribute(KIND); >+ if (kind == null || kind.length() == 0 || kind.equals(getConnectorKind())) { >+ String id = element.getAttribute("id"); >+ try { >+ if (id == null || id.length() == 0) { >+ throw new IllegalStateException(TASK_REPOSITORY_PAGE_CONTRIBUTION + "/@id is required"); >+ } >+ Object contributor = element.createExecutableExtension("class"); >+ AbstractTaskRepositoryPageContribution pageContributor = (AbstractTaskRepositoryPageContribution) contributor; >+ pageContributor.setId(id); >+ contributors.add(pageContributor); >+ } catch (Exception e) { >+ StatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, "Could not load " >+ + TASK_REPOSITORY_PAGE_CONTRIBUTION + " '" + id + "' from plug-in " >+ + element.getContributor().getName(), e)); >+ } >+ } >+ } >+ } >+ } >+ >+ return contributors; >+ } >+ >+ private static class ContributionComparator implements Comparator<AbstractTaskRepositoryPageContribution> { >+ >+ public int compare(AbstractTaskRepositoryPageContribution o1, AbstractTaskRepositoryPageContribution o2) { >+ if (o1 == o2) { >+ return 0; >+ } >+ String s1 = o1.getTitle(); >+ String s2 = o2.getTitle(); >+ int i = s1.compareTo(s2); >+ if (i == 0) { >+ i = o1.getId().compareTo(o2.getId()); >+ } >+ return i; >+ } >+ >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 244653
:
110475
|
110476
|
110514
|
110515
|
110516
|
110517
|
110730
|
110731
|
112848
|
112849
|
112850
|
115338
|
115339
|
116062
|
116063
|
116387
|
116778
|
116865
| 116890 |
117734