Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 150663 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/mylyn/internal/team/ui/preferences/FocusedTeamPreferencePage.java (+2 lines)
Lines 33-38 Link Here
33
 */
33
 */
34
public class FocusedTeamPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
34
public class FocusedTeamPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
35
35
36
	public final static String PAGE_ID = "org.eclipse.mylyn.team.ui.ui.preferences";
37
	
36
	private Button manageChangeSets;
38
	private Button manageChangeSets;
37
39
38
	private Text commitTemplate = null;
40
	private Text commitTemplate = null;
(-)META-INF/MANIFEST.MF (-1 / +3 lines)
Lines 21-27 Link Here
21
 org.eclipse.compare,
21
 org.eclipse.compare,
22
 org.eclipse.mylyn.monitor.core,
22
 org.eclipse.mylyn.monitor.core,
23
 org.eclipse.mylyn,
23
 org.eclipse.mylyn,
24
 org.eclipse.ui.navigator.resources
24
 org.eclipse.ui.navigator.resources,
25
 org.eclipse.ui,
26
 org.eclipse.ui.forms
25
Eclipse-LazyStart: true
27
Eclipse-LazyStart: true
26
Export-Package: org.eclipse.mylyn.internal.team.ui,
28
Export-Package: org.eclipse.mylyn.internal.team.ui,
27
 org.eclipse.mylyn.internal.team.ui.actions,
29
 org.eclipse.mylyn.internal.team.ui.actions,
(-)plugin.xml (+10 lines)
Lines 255-259 Link Here
255
       <adapter type="org.eclipse.mylyn.tasks.core.ILinkedTaskInfo"/>
255
       <adapter type="org.eclipse.mylyn.tasks.core.ILinkedTaskInfo"/>
256
    </factory>
256
    </factory>
257
  </extension>
257
  </extension>
258
   <extension
259
         point="org.eclipse.ui.propertyPages">
260
      <page
261
            adaptable="true"
262
            class="org.eclipse.mylyn.internal.team.ui.properties.ProjectTeamPage"
263
            id="org.eclipse.mylyn.tasks.ui.properties.pages.project.team"
264
            name="Mylyn Team"
265
            objectClass="org.eclipse.core.resources.IProject">
266
      </page>
267
   </extension>
258
	
268
	
259
</plugin>
269
</plugin>
(-)src/org/eclipse/mylyn/internal/team/ui/ContextChangeSet.java (-2 / +17 lines)
Lines 14-19 Link Here
14
import java.util.List;
14
import java.util.List;
15
import java.util.Set;
15
import java.util.Set;
16
16
17
import org.eclipse.core.resources.IProject;
17
import org.eclipse.core.resources.IResource;
18
import org.eclipse.core.resources.IResource;
18
import org.eclipse.core.resources.ResourcesPlugin;
19
import org.eclipse.core.resources.ResourcesPlugin;
19
import org.eclipse.core.resources.mapping.ResourceMapping;
20
import org.eclipse.core.resources.mapping.ResourceMapping;
Lines 21-26 Link Here
21
import org.eclipse.core.runtime.IAdaptable;
22
import org.eclipse.core.runtime.IAdaptable;
22
import org.eclipse.core.runtime.Platform;
23
import org.eclipse.core.runtime.Platform;
23
import org.eclipse.mylyn.context.core.ContextCorePlugin;
24
import org.eclipse.mylyn.context.core.ContextCorePlugin;
25
import org.eclipse.mylyn.internal.team.ui.properties.TeamPropertiesLinkProvider;
24
import org.eclipse.mylyn.monitor.core.InteractionEvent;
26
import org.eclipse.mylyn.monitor.core.InteractionEvent;
25
import org.eclipse.mylyn.resources.ResourcesUiBridgePlugin;
27
import org.eclipse.mylyn.resources.ResourcesUiBridgePlugin;
26
import org.eclipse.mylyn.tasks.core.AbstractTask;
28
import org.eclipse.mylyn.tasks.core.AbstractTask;
Lines 36-41 Link Here
36
38
37
/**
39
/**
38
 * @author Mik Kersten
40
 * @author Mik Kersten
41
 * @author Steffen Pingel
39
 */
42
 */
40
public class ContextChangeSet extends CVSActiveChangeSet/*ActiveChangeSet*/implements IAdaptable {
43
public class ContextChangeSet extends CVSActiveChangeSet/*ActiveChangeSet*/implements IAdaptable {
41
44
Lines 89-96 Link Here
89
92
90
	@Override
93
	@Override
91
	public String getComment() {
94
	public String getComment() {
92
		String template = FocusedTeamUiPlugin.getDefault().getPreferenceStore().getString(
95
		String template = null;
93
				FocusedTeamUiPlugin.COMMIT_TEMPLATE);
96
		IResource[] resources = getResources();
97
		if (resources.length > 0) {
98
			IProject project = resources[0].getProject();
99
			if (project != null && project.isAccessible()) {
100
				TeamPropertiesLinkProvider provider = new TeamPropertiesLinkProvider();
101
				template = provider.getCommitCommentTemplate(project);
102
			}
103
		}
104
105
		if (template == null) {
106
			template = FocusedTeamUiPlugin.getDefault().getPreferenceStore().getString(
107
					FocusedTeamUiPlugin.COMMIT_TEMPLATE);
108
		}
94
		return FocusedTeamUiPlugin.getDefault().getCommitTemplateManager().generateComment(task, template);
109
		return FocusedTeamUiPlugin.getDefault().getCommitTemplateManager().generateComment(task, template);
95
	}
110
	}
96
111
(-)src/org/eclipse/mylyn/internal/team/ui/properties/ProjectTeamPage.java (+220 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2007 Mylyn project committers and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *******************************************************************************/
8
9
package org.eclipse.mylyn.internal.team.ui.properties;
10
11
import org.eclipse.core.resources.IProject;
12
import org.eclipse.core.resources.IResource;
13
import org.eclipse.jface.fieldassist.IContentProposalProvider;
14
import org.eclipse.jface.fieldassist.IControlContentAdapter;
15
import org.eclipse.jface.fieldassist.IControlCreator;
16
import org.eclipse.jface.fieldassist.TextContentAdapter;
17
import org.eclipse.jface.layout.GridDataFactory;
18
import org.eclipse.jface.preference.PreferenceDialog;
19
import org.eclipse.jface.resource.JFaceColors;
20
import org.eclipse.mylyn.internal.team.ui.FocusedTeamUiPlugin;
21
import org.eclipse.mylyn.internal.team.ui.preferences.FocusedTeamPreferencePage;
22
import org.eclipse.mylyn.internal.team.ui.templates.TemplateHandlerContentProposalProvider;
23
import org.eclipse.swt.SWT;
24
import org.eclipse.swt.events.ModifyEvent;
25
import org.eclipse.swt.events.ModifyListener;
26
import org.eclipse.swt.events.SelectionAdapter;
27
import org.eclipse.swt.events.SelectionEvent;
28
import org.eclipse.swt.graphics.Font;
29
import org.eclipse.swt.layout.GridData;
30
import org.eclipse.swt.layout.GridLayout;
31
import org.eclipse.swt.widgets.Button;
32
import org.eclipse.swt.widgets.Composite;
33
import org.eclipse.swt.widgets.Control;
34
import org.eclipse.swt.widgets.Label;
35
import org.eclipse.swt.widgets.Text;
36
import org.eclipse.ui.dialogs.PreferencesUtil;
37
import org.eclipse.ui.dialogs.PropertyPage;
38
import org.eclipse.ui.fieldassist.ContentAssistField;
39
import org.eclipse.ui.forms.events.HyperlinkAdapter;
40
import org.eclipse.ui.forms.events.HyperlinkEvent;
41
import org.eclipse.ui.forms.widgets.Hyperlink;
42
43
/**
44
 * @author Rob Elves
45
 * @author Steffen Pingel
46
 * @see Adapted from org.eclipse.ui.internal.ide.dialogs.ProjectReferencePage
47
 */
48
@SuppressWarnings("deprecation")
49
public class ProjectTeamPage extends PropertyPage {
50
51
	private IProject project;
52
53
	private boolean modified = false;
54
55
	private Button useProjectSettings;
56
57
	private Text commitTemplateText;
58
59
	private Composite propertiesComposite;
60
61
	private Hyperlink configurationHyperlink;
62
63
	private Label label;
64
65
	public ProjectTeamPage() {
66
		noDefaultAndApplyButton();
67
	}
68
69
	@Override
70
	protected Control createContents(Composite parent) {
71
		Font font = parent.getFont();
72
73
		Composite composite = new Composite(parent, SWT.NONE);
74
		GridLayout layout = new GridLayout();
75
		composite.setLayout(layout);
76
		composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
77
		composite.setFont(font);
78
79
		createDescription(composite);
80
		createPropertiesControl(composite);
81
82
		initialize();
83
84
		return composite;
85
	}
86
87
	private void createDescription(Composite parent) {
88
		Composite composite = new Composite(parent, SWT.NONE);
89
		composite.setFont(parent.getFont());
90
		GridLayout layout = new GridLayout();
91
		layout.marginHeight = 0;
92
		layout.marginWidth = 0;
93
		layout.numColumns = 2;
94
		composite.setLayout(layout);
95
		composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
96
97
		useProjectSettings = new Button(composite, SWT.CHECK);
98
		useProjectSettings.addSelectionListener(new SelectionAdapter() {
99
			@Override
100
			public void widgetSelected(SelectionEvent e) {
101
				modified = true;
102
				setPropertiesEnabled(useProjectSettings.getSelection());
103
			}
104
		});
105
		useProjectSettings.setText("Enable project specific settings");
106
		GridDataFactory.fillDefaults().grab(true, false).applyTo(useProjectSettings);
107
108
		configurationHyperlink = new Hyperlink(composite, SWT.NONE);
109
		configurationHyperlink.setUnderlined(true);
110
		configurationHyperlink.setText("Configure workspace");
111
		configurationHyperlink.addHyperlinkListener(new HyperlinkAdapter() {
112
113
			public void linkActivated(HyperlinkEvent e) {
114
				PreferenceDialog dlg = PreferencesUtil.createPreferenceDialogOn(getShell(),
115
						FocusedTeamPreferencePage.PAGE_ID, new String[] { FocusedTeamPreferencePage.PAGE_ID }, null);
116
				dlg.open();
117
			}
118
		});
119
120
		Label horizontalLine = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
121
		horizontalLine.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1));
122
		horizontalLine.setFont(composite.getFont());
123
	}
124
125
	private void setPropertiesEnabled(boolean enabled) {
126
		propertiesComposite.setEnabled(enabled);
127
		for (Control child : propertiesComposite.getChildren()) {
128
			child.setEnabled(enabled);
129
		}
130
		commitTemplateText.setEnabled(enabled);
131
		
132
		configurationHyperlink.setEnabled(!enabled);
133
		if (!enabled) {
134
			configurationHyperlink.setForeground(JFaceColors.getHyperlinkText(getShell().getDisplay()));
135
		} else {
136
			configurationHyperlink.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_FOREGROUND));
137
		}
138
	}
139
140
	private void createPropertiesControl(Composite parent) {
141
		propertiesComposite = new Composite(parent, SWT.NONE);
142
		propertiesComposite.setFont(parent.getFont());
143
		GridLayout layout = new GridLayout();
144
		layout.marginHeight = 0;
145
		layout.marginWidth = 0;
146
		layout.numColumns = 1;
147
		propertiesComposite.setLayout(layout);
148
		propertiesComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
149
150
		label = new Label(propertiesComposite, SWT.NONE);
151
		label.setText("Commit Comment Template");
152
153
		String completedTemplate = ""; //getPreferenceStore().getString(FocusedTeamUiPlugin.COMMIT_TEMPLATE);
154
		commitTemplateText = addTemplateField(propertiesComposite, completedTemplate,
155
				new TemplateHandlerContentProposalProvider());
156
	}
157
158
	@SuppressWarnings("deprecation")
159
	private Text addTemplateField(final Composite parent, final String text, IContentProposalProvider provider) {
160
		IControlContentAdapter adapter = new TextContentAdapter();
161
		IControlCreator controlCreator = new IControlCreator() {
162
			public Control createControl(Composite parent, int style) {
163
				Text control = new Text(parent, style);
164
				control.setText(text);
165
				control.addModifyListener(new ModifyListener() {
166
					public void modifyText(ModifyEvent e) {
167
						modified = true;
168
					}
169
				});
170
				return control;
171
			}
172
		};
173
174
		ContentAssistField field = new ContentAssistField(parent, SWT.BORDER | SWT.MULTI, controlCreator, adapter,
175
				provider, null, new char[] { '$' });
176
177
		GridData gd = new GridData();
178
		gd.heightHint = 60;
179
		gd.horizontalAlignment = GridData.FILL;
180
		gd.grabExcessHorizontalSpace = true;
181
		gd.verticalAlignment = GridData.CENTER;
182
		gd.grabExcessVerticalSpace = false;
183
		field.getLayoutControl().setLayoutData(gd);
184
185
		return (Text) field.getControl();
186
	}
187
188
	private void initialize() {
189
		project = (IProject) getElement().getAdapter(IResource.class);
190
191
		TeamPropertiesLinkProvider provider = new TeamPropertiesLinkProvider();
192
		String template = provider.getCommitCommentTemplate(project);
193
		if (template == null) {
194
			useProjectSettings.setSelection(false);
195
			setPropertiesEnabled(false);
196
			commitTemplateText.setText(FocusedTeamUiPlugin.getDefault().getPreferenceStore().getString(
197
					FocusedTeamUiPlugin.COMMIT_TEMPLATE));
198
		} else {
199
			useProjectSettings.setSelection(true);
200
			setPropertiesEnabled(true);
201
			commitTemplateText.setText(template);
202
		}
203
	}
204
205
	@Override
206
	public boolean performOk() {
207
		if (!modified) {
208
			return true;
209
		}
210
211
		TeamPropertiesLinkProvider provider = new TeamPropertiesLinkProvider();
212
		if (useProjectSettings.getSelection()) {
213
			provider.setCommitCommentTemplate(project, commitTemplateText.getText());
214
		} else {
215
			provider.setCommitCommentTemplate(project, null);
216
		}
217
218
		return true;
219
	}
220
}
(-)src/org/eclipse/mylyn/internal/team/ui/properties/TeamPropertiesLinkProvider.java (+71 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2007 Mylyn project committers and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *******************************************************************************/
8
9
package org.eclipse.mylyn.internal.team.ui.properties;
10
11
import org.eclipse.core.resources.IProject;
12
import org.eclipse.core.resources.IResource;
13
import org.eclipse.core.resources.ProjectScope;
14
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
15
import org.eclipse.core.runtime.preferences.IScopeContext;
16
import org.eclipse.mylyn.internal.team.ui.FocusedTeamUiPlugin;
17
import org.eclipse.mylyn.monitor.core.StatusHandler;
18
import org.osgi.service.prefs.BackingStoreException;
19
20
/**
21
 * Retrieves team settings from project properties.
22
 * 
23
 * @author Eugene Kuleshov
24
 * @author Steffen Pingel
25
 */
26
public class TeamPropertiesLinkProvider {
27
28
	private static final String PROJECT_COMMIT_COMMENT_TEMPLATE = "commit.comment.template";
29
30
	public boolean canAccessProperties(IResource resource) {
31
		IProject project = resource.getProject();
32
		return project != null && project.isAccessible();
33
	}
34
35
	public String getCommitCommentTemplate(IResource resource) {
36
		if (!canAccessProperties(resource)) {
37
			return null;
38
		}
39
40
		IScopeContext projectScope = new ProjectScope(resource.getProject());
41
		IEclipsePreferences projectNode = projectScope.getNode(FocusedTeamUiPlugin.PLUGIN_ID);
42
		if (projectNode != null) {
43
			return projectNode.get(PROJECT_COMMIT_COMMENT_TEMPLATE, null);
44
		}
45
		return null;
46
	}
47
48
	public boolean setCommitCommentTemplate(IResource resource, String commitCommentTemplate) {
49
		if (!canAccessProperties(resource)) {
50
			return false;
51
		}
52
53
		IScopeContext projectScope = new ProjectScope(resource.getProject());
54
		IEclipsePreferences projectNode = projectScope.getNode(FocusedTeamUiPlugin.PLUGIN_ID);
55
		if (projectNode != null) {
56
			if (commitCommentTemplate != null) {
57
				projectNode.put(PROJECT_COMMIT_COMMENT_TEMPLATE, commitCommentTemplate);
58
			} else {
59
				projectNode.remove(PROJECT_COMMIT_COMMENT_TEMPLATE);
60
			}
61
			try {
62
				projectNode.flush();
63
				return true;
64
			} catch (BackingStoreException e) {
65
				StatusHandler.fail(e, "Failed to save commit comment template for project", false);
66
			}
67
		}
68
		return false;
69
	}
70
71
}

Return to bug 150663