View | Details | Raw Unified | Return to bug 310059
Collapse All | Expand All

(-)src/org/eclipse/mylyn/internal/bugzilla/ui/search/BugzillaSearchPage.java (-42 / +76 lines)
Lines 65-70 Link Here
65
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
65
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
66
import org.eclipse.mylyn.tasks.core.RepositoryStatus;
66
import org.eclipse.mylyn.tasks.core.RepositoryStatus;
67
import org.eclipse.mylyn.tasks.core.TaskRepository;
67
import org.eclipse.mylyn.tasks.core.TaskRepository;
68
import org.eclipse.mylyn.tasks.ui.IQueryButtomButtons;
68
import org.eclipse.mylyn.tasks.ui.TasksUi;
69
import org.eclipse.mylyn.tasks.ui.TasksUi;
69
import org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositoryQueryPage;
70
import org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositoryQueryPage;
70
import org.eclipse.osgi.util.NLS;
71
import org.eclipse.osgi.util.NLS;
Lines 103-109 Link Here
103
 * @author Frank Becker
104
 * @author Frank Becker
104
 */
105
 */
105
@SuppressWarnings("restriction")
106
@SuppressWarnings("restriction")
106
public class BugzillaSearchPage extends AbstractRepositoryQueryPage implements Listener {
107
public class BugzillaSearchPage extends AbstractRepositoryQueryPage implements Listener, IQueryButtomButtons {
107
108
108
	private static final int HEIGHT_ATTRIBUTE_COMBO = 30;
109
	private static final int HEIGHT_ATTRIBUTE_COMBO = 30;
109
110
Lines 356-361 Link Here
356
357
357
	protected String[] chartFieldValues;
358
	protected String[] chartFieldValues;
358
359
360
	private Button clearFieldButton;
361
359
	// /** File containing saved queries */
362
	// /** File containing saved queries */
360
	// protected static SavedQueryFile input;
363
	// protected static SavedQueryFile input;
361
364
Lines 533-540 Link Here
533
		control.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
536
		control.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
534
537
535
		createOptionsGroup(control);
538
		createOptionsGroup(control);
536
		createButtons(control);
539
		if (inSearchContainer()) {
537
540
			createButtons(control);
541
		}
538
		Dialog.applyDialogFont(control);
542
		Dialog.applyDialogFont(control);
539
		setControl(control);
543
		setControl(control);
540
544
Lines 547-593 Link Here
547
		layout.marginWidth = 0;
551
		layout.marginWidth = 0;
548
		buttonComposite.setLayout(layout);
552
		buttonComposite.setLayout(layout);
549
		GridData g = new GridData(GridData.FILL_HORIZONTAL);
553
		GridData g = new GridData(GridData.FILL_HORIZONTAL);
550
		Button clearButton = new Button(buttonComposite, SWT.PUSH);
554
		clearFieldButton = new Button(buttonComposite, SWT.PUSH);
551
		clearButton.setText(Messages.BugzillaSearchPage_ClearFields);
555
		clearFieldButton.setText(Messages.BugzillaSearchPage_ClearFields);
552
		clearButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
556
		clearFieldButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
553
		clearButton.addSelectionListener(new SelectionAdapter() {
557
		clearFieldButton.addSelectionListener(new SelectionAdapter() {
554
			@Override
558
			@Override
555
			public void widgetSelected(SelectionEvent e) {
559
			public void widgetSelected(SelectionEvent e) {
556
				product.deselectAll();
560
				clearFields();
557
				component.deselectAll();
558
				version.deselectAll();
559
				target.deselectAll();
560
				status.deselectAll();
561
				resolution.deselectAll();
562
				severity.deselectAll();
563
				priority.deselectAll();
564
				hardware.deselectAll();
565
				os.deselectAll();
566
				summaryOperation.select(0);
567
				commentOperation.select(0);
568
				emailOperation.select(0);
569
570
				for (Button emailButton : emailButtons) {
571
					emailButton.setSelection(false);
572
				}
573
				summaryPattern.setText(""); //$NON-NLS-1$
574
				commentPattern.setText(""); //$NON-NLS-1$
575
				emailPattern.setText(""); //$NON-NLS-1$
576
				emailOperation2.select(0);
577
				for (Button element : emailButtons2) {
578
					element.setSelection(false);
579
				}
580
				emailPattern2.setText(""); //$NON-NLS-1$
581
				keywords.setText(""); //$NON-NLS-1$
582
				keywordsOperation.select(0);
583
				whiteboardPattern.setText(""); //$NON-NLS-1$
584
				whiteboardOperation.select(0);
585
				daysText.setText(""); //$NON-NLS-1$
586
587
				charts.clear();
588
				charts.add(0, new Chart());
589
				recreateChartControls();
590
591
			}
561
			}
592
		});
562
		});
593
563
Lines 2553-2556 Link Here
2553
		refreshChartControls();
2523
		refreshChartControls();
2554
		Dialog.applyDialogFont(chartSection);
2524
		Dialog.applyDialogFont(chartSection);
2555
	}
2525
	}
2526
2527
	public boolean canUpdateConfiguration() {
2528
		return true;
2529
	}
2530
2531
	public boolean needsUpdateConfiguration() {
2532
		return true;
2533
	}
2534
2535
	public void performUpdateConfiguration() {
2536
		if (getTaskRepository() != null) {
2537
			updateConfiguration(true);
2538
		}
2539
	}
2540
2541
	public boolean canClearFields() {
2542
		return true;
2543
	}
2544
2545
	public boolean needsClearFields() {
2546
		return true;
2547
	}
2548
2549
	public void performClearFields() {
2550
		clearFields();
2551
	}
2552
2553
	private void clearFields() {
2554
		product.deselectAll();
2555
		component.deselectAll();
2556
		version.deselectAll();
2557
		target.deselectAll();
2558
		status.deselectAll();
2559
		resolution.deselectAll();
2560
		severity.deselectAll();
2561
		priority.deselectAll();
2562
		hardware.deselectAll();
2563
		os.deselectAll();
2564
		summaryOperation.select(0);
2565
		commentOperation.select(0);
2566
		emailOperation.select(0);
2567
2568
		for (Button emailButton : emailButtons) {
2569
			emailButton.setSelection(false);
2570
		}
2571
		summaryPattern.setText(""); //$NON-NLS-1$
2572
		commentPattern.setText(""); //$NON-NLS-1$
2573
		emailPattern.setText(""); //$NON-NLS-1$
2574
		emailOperation2.select(0);
2575
		for (Button element : emailButtons2) {
2576
			element.setSelection(false);
2577
		}
2578
		emailPattern2.setText(""); //$NON-NLS-1$
2579
		keywords.setText(""); //$NON-NLS-1$
2580
		keywordsOperation.select(0);
2581
		whiteboardPattern.setText(""); //$NON-NLS-1$
2582
		whiteboardOperation.select(0);
2583
		daysText.setText(""); //$NON-NLS-1$
2584
2585
		charts.clear();
2586
		charts.add(0, new Chart());
2587
		recreateChartControls();
2588
	}
2589
2556
}
2590
}
(-)src/org/eclipse/mylyn/internal/provisional/commons/ui/dialogs/BottomButtonWizardDialog.java (+123 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 Frank Becker 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
 * Contributors:
9
 *     Frank Becker - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylyn.internal.provisional.commons.ui.dialogs;
13
14
import java.lang.reflect.InvocationTargetException;
15
import java.util.HashMap;
16
17
import org.eclipse.jface.dialogs.IDialogConstants;
18
import org.eclipse.jface.operation.IRunnableWithProgress;
19
import org.eclipse.jface.wizard.IWizard;
20
import org.eclipse.jface.wizard.WizardDialog;
21
import org.eclipse.swt.SWT;
22
import org.eclipse.swt.layout.GridData;
23
import org.eclipse.swt.layout.GridLayout;
24
import org.eclipse.swt.widgets.Composite;
25
import org.eclipse.swt.widgets.Control;
26
import org.eclipse.swt.widgets.Label;
27
import org.eclipse.swt.widgets.Shell;
28
29
/**
30
 * Wizard dialog for displaying additional button in the button bar. Based on ValidatableWizardDialog from Helen
31
 * Bershadskaya
32
 * 
33
 * @author Helen Bershadskaya
34
 * @author Frank Becker
35
 */
36
37
public abstract class BottomButtonWizardDialog extends WizardDialog {
38
39
	public BottomButtonWizardDialog(Shell parentShell, IWizard newWizard) {
40
		super(parentShell, newWizard);
41
	}
42
43
	abstract protected void createExtraButtons(Composite composite);
44
45
	abstract protected void updateExtraButtons();
46
47
	abstract protected boolean handleExtraButtonPressed(int buttonId);
48
49
	abstract protected HashMap<String, Boolean> saveAndSetEnabledStateMylyn();
50
51
	abstract protected void restoreEnabledStateMylyn(HashMap<String, Boolean> savedEnabledState);
52
53
	/**
54
	 * Overridden so we can add a validate button to the wizard button bar, if a repository settings page requires it.
55
	 * Validate button is added left justified at button bar bottom (next to help image).
56
	 */
57
	@Override
58
	protected Control createButtonBar(Composite parent) {
59
		Composite composite = new Composite(parent, SWT.NONE);
60
		GridLayout layout = new GridLayout();
61
		layout.numColumns = 0; // create 
62
		layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
63
		layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
64
		layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
65
		layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
66
67
		composite.setLayout(layout);
68
		composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
69
70
		// create help control if needed
71
		if (isHelpAvailable()) {
72
			createHelpControl(composite);
73
		}
74
75
		createExtraButtons(composite);
76
		Label filler = new Label(composite, SWT.NONE);
77
		filler.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
78
		((GridLayout) composite.getLayout()).numColumns++;
79
80
		super.createButtonsForButtonBar(composite);
81
82
		return composite;
83
	}
84
85
	/**
86
	 * Overridden so we can react to the validate button being pressed. This could have been done with a straight
87
	 * selection listener in the creation method above, but this is more consistent with how the other buttons work in
88
	 * the wizard dialog.
89
	 * 
90
	 * @since 3.1
91
	 */
92
	@Override
93
	protected void buttonPressed(int buttonId) {
94
		if (!handleExtraButtonPressed(buttonId)) {
95
			super.buttonPressed(buttonId);
96
		}
97
	}
98
99
	@Override
100
	public void updateButtons() {
101
		updateExtraButtons();
102
		super.updateButtons();
103
	}
104
105
	/**
106
	 * Overridden to be able to set proper state for our validate button
107
	 */
108
	@Override
109
	public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException,
110
			InterruptedException {
111
112
		HashMap<String, Boolean> savedEnabledState = null;
113
		try {
114
			savedEnabledState = saveAndSetEnabledStateMylyn();
115
			super.run(fork, cancelable, runnable);
116
		} finally {
117
			if (savedEnabledState != null) {
118
				restoreEnabledStateMylyn(savedEnabledState);
119
			}
120
		}
121
	}
122
123
}
(-)src/org/eclipse/mylyn/internal/provisional/commons/ui/dialogs/ValidatableWizardDialog.java (-91 / +33 lines)
Lines 11-31 Link Here
11
11
12
package org.eclipse.mylyn.internal.provisional.commons.ui.dialogs;
12
package org.eclipse.mylyn.internal.provisional.commons.ui.dialogs;
13
13
14
import java.lang.reflect.InvocationTargetException;
15
import java.util.HashMap;
14
import java.util.HashMap;
16
15
17
import org.eclipse.jface.dialogs.IDialogConstants;
18
import org.eclipse.jface.operation.IRunnableWithProgress;
19
import org.eclipse.jface.wizard.IWizard;
16
import org.eclipse.jface.wizard.IWizard;
20
import org.eclipse.jface.wizard.WizardDialog;
17
import org.eclipse.jface.wizard.WizardDialog;
21
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages;
18
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages;
22
import org.eclipse.swt.SWT;
23
import org.eclipse.swt.layout.GridData;
24
import org.eclipse.swt.layout.GridLayout;
25
import org.eclipse.swt.widgets.Button;
19
import org.eclipse.swt.widgets.Button;
26
import org.eclipse.swt.widgets.Composite;
20
import org.eclipse.swt.widgets.Composite;
27
import org.eclipse.swt.widgets.Control;
28
import org.eclipse.swt.widgets.Label;
29
import org.eclipse.swt.widgets.Shell;
21
import org.eclipse.swt.widgets.Shell;
30
22
31
/**
23
/**
Lines 33-39 Link Here
33
 * 
25
 * 
34
 * @author Helen Bershadskaya
26
 * @author Helen Bershadskaya
35
 */
27
 */
36
public class ValidatableWizardDialog extends WizardDialog {
28
public class ValidatableWizardDialog extends BottomButtonWizardDialog {
37
29
38
	private static final String VALIDATE_BUTTON_KEY = "validate"; //$NON-NLS-1$
30
	private static final String VALIDATE_BUTTON_KEY = "validate"; //$NON-NLS-1$
39
31
Lines 50-92 Link Here
50
	}
42
	}
51
43
52
	/**
44
	/**
53
	 * Overridden so we can add a validate button to the wizard button bar, if a repository settings page requires it.
45
	 * Modeled after WizardDialog.saveAndSetEnabledState(), but that one is private, so create our own
54
	 * Validate button is added left justified at button bar bottom (next to help image).
55
	 */
46
	 */
56
	@Override
47
	@Override
57
	protected Control createButtonBar(Composite parent) {
48
	protected HashMap<String, Boolean> saveAndSetEnabledStateMylyn() {
58
		Composite composite = new Composite(parent, SWT.NONE);
49
		HashMap<String, Boolean> savedEnabledState = null;
59
		GridLayout layout = new GridLayout();
50
		if (getShell() != null) {
60
		layout.numColumns = 0; // create 
51
			savedEnabledState = new HashMap<String, Boolean>();
61
		layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
52
			if (validateServerButton != null && validateServerButton.getShell() == getShell()) {
62
		layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
53
				savedEnabledState.put(VALIDATE_BUTTON_KEY, validateServerButton.getEnabled());
63
		layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
54
				validateServerButton.setEnabled(false);
64
		layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
55
			}
65
66
		composite.setLayout(layout);
67
		composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
68
69
		// create help control if needed
70
		if (isHelpAvailable()) {
71
			createHelpControl(composite);
72
		}
56
		}
57
		return savedEnabledState;
58
	}
73
59
60
	/**
61
	 * Modeled after WizardDialog.restoreEnabledState() and WizardDialog.restoreUIState() -- couldn't override those
62
	 * since they are private, so create our own. Currently only single button to work with, so don't create two
63
	 * separate methods
64
	 */
65
	@Override
66
	protected void restoreEnabledStateMylyn(HashMap<String, Boolean> savedEnabledState) {
67
		if (savedEnabledState != null) {
68
			Boolean savedValidateEnabledState = savedEnabledState.get(VALIDATE_BUTTON_KEY);
69
			if (validateServerButton != null && savedValidateEnabledState != null) {
70
				validateServerButton.setEnabled(savedValidateEnabledState);
71
			}
72
		}
73
	}
74
75
	@Override
76
	protected void createExtraButtons(Composite composite) {
74
		validateServerButton = createButton(composite, VALIDATE_BUTTON_ID,
77
		validateServerButton = createButton(composite, VALIDATE_BUTTON_ID,
75
				Messages.ValidatableWizardDialog_Validate_Button_Label, false);
78
				Messages.ValidatableWizardDialog_Validate_Button_Label, false);
76
		validateServerButton.setImage(CommonImages.getImage(CommonImages.VALIDATE));
79
		validateServerButton.setImage(CommonImages.getImage(CommonImages.VALIDATE));
77
		validateServerButton.setVisible(false);
80
		validateServerButton.setVisible(false);
78
		setButtonLayoutData(validateServerButton);
81
		setButtonLayoutData(validateServerButton);
79
		Label filler = new Label(composite, SWT.NONE);
80
		filler.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
81
		((GridLayout) composite.getLayout()).numColumns++;
82
83
		super.createButtonsForButtonBar(composite);
84
85
		return composite;
86
	}
82
	}
87
83
88
	@Override
84
	@Override
89
	public void updateButtons() {
85
	protected void updateExtraButtons() {
90
		if (getCurrentPage() instanceof IValidatable && ((IValidatable) getCurrentPage()).needsValidation()) {
86
		if (getCurrentPage() instanceof IValidatable && ((IValidatable) getCurrentPage()).needsValidation()) {
91
			if (!validateServerButton.isVisible()) {
87
			if (!validateServerButton.isVisible()) {
92
				validateServerButton.setVisible(true);
88
				validateServerButton.setVisible(true);
Lines 97-167 Link Here
97
				validateServerButton.setVisible(false);
93
				validateServerButton.setVisible(false);
98
			}
94
			}
99
		}
95
		}
100
		super.updateButtons();
101
	}
96
	}
102
97
103
	/**
104
	 * Overridden so we can react to the validate button being pressed. This could have been done with a straight
105
	 * selection listener in the creation method above, but this is more consistent with how the other buttons work in
106
	 * the wizard dialog.
107
	 * 
108
	 * @since 3.1
109
	 */
110
	@Override
98
	@Override
111
	protected void buttonPressed(int buttonId) {
99
	protected boolean handleExtraButtonPressed(int buttonId) {
112
		if (buttonId == VALIDATE_BUTTON_ID) {
100
		if (buttonId == VALIDATE_BUTTON_ID) {
113
			if (getCurrentPage() instanceof IValidatable) {
101
			if (getCurrentPage() instanceof IValidatable) {
114
				((IValidatable) getCurrentPage()).validate();
102
				((IValidatable) getCurrentPage()).validate();
115
			}
103
				return true;
116
		} else {
117
			super.buttonPressed(buttonId);
118
		}
119
	}
120
121
	/**
122
	 * Overridden to be able to set proper state for our validate button
123
	 */
124
	@Override
125
	public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException,
126
			InterruptedException {
127
128
		HashMap<String, Boolean> savedEnabledState = null;
129
		try {
130
			savedEnabledState = saveAndSetEnabledStateInternal();
131
			super.run(fork, cancelable, runnable);
132
		} finally {
133
			if (savedEnabledState != null) {
134
				restoreEnabledStateMylyn(savedEnabledState);
135
			}
136
		}
137
	}
138
139
	/**
140
	 * Modeled after super.saveAndSetEnabledState(), but that one is private, so create our own
141
	 */
142
	private HashMap<String, Boolean> saveAndSetEnabledStateInternal() {
143
		HashMap<String, Boolean> savedEnabledState = null;
144
		if (getShell() != null) {
145
			savedEnabledState = new HashMap<String, Boolean>();
146
			if (validateServerButton != null && validateServerButton.getShell() == getShell()) {
147
				savedEnabledState.put(VALIDATE_BUTTON_KEY, validateServerButton.getEnabled());
148
				validateServerButton.setEnabled(false);
149
			}
150
		}
151
		return savedEnabledState;
152
	}
153
154
	/**
155
	 * Modeled after super.restoreEnabledState() and super.restoreUIState() -- couldn't override those since they are
156
	 * private, so create our own. Currently only single button to work with, so don't create two separate methods
157
	 */
158
	private void restoreEnabledStateMylyn(HashMap<String, Boolean> savedEnabledState) {
159
		if (savedEnabledState != null) {
160
			Boolean savedValidateEnabledState = savedEnabledState.get(VALIDATE_BUTTON_KEY);
161
			if (validateServerButton != null && savedValidateEnabledState != null) {
162
				validateServerButton.setEnabled(savedValidateEnabledState);
163
			}
104
			}
164
		}
105
		}
106
		return false;
165
	}
107
	}
166
108
167
}
109
}
(-)META-INF/MANIFEST.MF (-1 / +1 lines)
Lines 2-8 Link Here
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %Bundle-Name
3
Bundle-Name: %Bundle-Name
4
Bundle-SymbolicName: org.eclipse.mylyn.tasks.ui;singleton:=true
4
Bundle-SymbolicName: org.eclipse.mylyn.tasks.ui;singleton:=true
5
Bundle-Version: 3.5.0.qualifier
5
Bundle-Version: 3.6.0.qualifier
6
Bundle-Activator: org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin
6
Bundle-Activator: org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin
7
Require-Bundle: org.eclipse.ui,
7
Require-Bundle: org.eclipse.ui,
8
 org.eclipse.compare,
8
 org.eclipse.compare,
(-)src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java (-2 / +2 lines)
Lines 57-63 Link Here
57
import org.eclipse.jface.viewers.TreeViewer;
57
import org.eclipse.jface.viewers.TreeViewer;
58
import org.eclipse.jface.window.Window;
58
import org.eclipse.jface.window.Window;
59
import org.eclipse.jface.wizard.IWizard;
59
import org.eclipse.jface.wizard.IWizard;
60
import org.eclipse.jface.wizard.WizardDialog;
61
import org.eclipse.mylyn.commons.core.CoreUtil;
60
import org.eclipse.mylyn.commons.core.CoreUtil;
62
import org.eclipse.mylyn.commons.core.StatusHandler;
61
import org.eclipse.mylyn.commons.core.StatusHandler;
63
import org.eclipse.mylyn.internal.monitor.ui.MonitorUiPlugin;
62
import org.eclipse.mylyn.internal.monitor.ui.MonitorUiPlugin;
Lines 86-91 Link Here
86
import org.eclipse.mylyn.internal.tasks.ui.wizards.MultiRepositoryAwareWizard;
85
import org.eclipse.mylyn.internal.tasks.ui.wizards.MultiRepositoryAwareWizard;
87
import org.eclipse.mylyn.internal.tasks.ui.wizards.NewAttachmentWizardDialog;
86
import org.eclipse.mylyn.internal.tasks.ui.wizards.NewAttachmentWizardDialog;
88
import org.eclipse.mylyn.internal.tasks.ui.wizards.NewTaskWizardInternal;
87
import org.eclipse.mylyn.internal.tasks.ui.wizards.NewTaskWizardInternal;
88
import org.eclipse.mylyn.internal.tasks.ui.wizards.QueryWizardDialog;
89
import org.eclipse.mylyn.internal.tasks.ui.wizards.TaskAttachmentWizard;
89
import org.eclipse.mylyn.internal.tasks.ui.wizards.TaskAttachmentWizard;
90
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
90
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
91
import org.eclipse.mylyn.tasks.core.IRepositoryElement;
91
import org.eclipse.mylyn.tasks.core.IRepositoryElement;
Lines 691-697 Link Here
691
691
692
			Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
692
			Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
693
			if (wizard != null && shell != null && !shell.isDisposed()) {
693
			if (wizard != null && shell != null && !shell.isDisposed()) {
694
				WizardDialog dialog = new WizardDialog(shell, wizard) {
694
				QueryWizardDialog dialog = new QueryWizardDialog(shell, wizard) {
695
					private static final String DIALOG_SETTINGS = "EditQueryWizardWizard"; //$NON-NLS-1$
695
					private static final String DIALOG_SETTINGS = "EditQueryWizardWizard"; //$NON-NLS-1$
696
696
697
					@Override
697
					@Override
(-)src/org/eclipse/mylyn/internal/tasks/ui/wizards/Messages.java (+4 lines)
Lines 274-277 Link Here
274
	public static String LocalRepositorySettingsPage_Configure_the_local_repository;
274
	public static String LocalRepositorySettingsPage_Configure_the_local_repository;
275
275
276
	public static String LocalRepositorySettingsPage_Local_Repository_Settings;
276
	public static String LocalRepositorySettingsPage_Local_Repository_Settings;
277
278
	public static String QueryWizardDialog_Clear_Fields;
279
280
	public static String QueryWizardDialog_Update_Attributes_from_Repository;
277
}
281
}
(-)src/org/eclipse/mylyn/internal/tasks/ui/wizards/QueryWizardDialog.java (+135 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 Tasktop Technologies 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
 * Contributors:
9
 *     Tasktop Technologies - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylyn.internal.tasks.ui.wizards;
13
14
import java.util.HashMap;
15
16
import org.eclipse.jface.wizard.IWizard;
17
import org.eclipse.mylyn.internal.provisional.commons.ui.dialogs.BottomButtonWizardDialog;
18
import org.eclipse.mylyn.tasks.ui.IQueryButtomButtons;
19
import org.eclipse.mylyn.tasks.ui.TasksUiImages;
20
import org.eclipse.swt.widgets.Button;
21
import org.eclipse.swt.widgets.Composite;
22
import org.eclipse.swt.widgets.Shell;
23
24
public class QueryWizardDialog extends BottomButtonWizardDialog {
25
26
	private static final String UPDATE_BUTTON_KEY = "update"; //$NON-NLS-1$
27
28
	private static final String CLEAR_BUTTON_KEY = "clear"; //$NON-NLS-1$
29
30
	private static final int UPDATE_BUTTON_ID = 2001;
31
32
	private static final int CLEAR_BUTTON_ID = 2002;
33
34
	private Button updateButton;
35
36
	private Button clearButton;
37
38
	public QueryWizardDialog(Shell parentShell, IWizard newWizard) {
39
		super(parentShell, newWizard);
40
		setHelpAvailable(false);
41
	}
42
43
	@Override
44
	protected void createExtraButtons(Composite composite) {
45
		clearButton = createButton(composite, CLEAR_BUTTON_ID, Messages.QueryWizardDialog_Clear_Fields, false);
46
		clearButton.setVisible(false);
47
		setButtonLayoutData(clearButton);
48
		updateButton = createButton(composite, UPDATE_BUTTON_ID,
49
				Messages.QueryWizardDialog_Update_Attributes_from_Repository, false);
50
		updateButton.setImage(TasksUiImages.REPOSITORY_UPDATE_CONFIGURATION.createImage());
51
		updateButton.setVisible(false);
52
		setButtonLayoutData(updateButton);
53
	}
54
55
	@Override
56
	protected void updateExtraButtons() {
57
		if (getCurrentPage() instanceof IQueryButtomButtons) {
58
			if (((IQueryButtomButtons) getCurrentPage()).needsClearFields()) {
59
				if (!clearButton.isVisible()) {
60
					clearButton.setVisible(true);
61
				}
62
				clearButton.setEnabled(((IQueryButtomButtons) getCurrentPage()).canClearFields());
63
			} else {
64
				if (clearButton != null && clearButton.isVisible()) {
65
					clearButton.setVisible(false);
66
				}
67
			}
68
			if (((IQueryButtomButtons) getCurrentPage()).needsUpdateConfiguration()) {
69
				if (!updateButton.isVisible()) {
70
					updateButton.setVisible(true);
71
				}
72
				updateButton.setEnabled(((IQueryButtomButtons) getCurrentPage()).canUpdateConfiguration());
73
			} else {
74
				if (updateButton != null && updateButton.isVisible()) {
75
					updateButton.setVisible(false);
76
				}
77
			}
78
		}
79
	}
80
81
	@Override
82
	protected boolean handleExtraButtonPressed(int buttonId) {
83
		if (buttonId == CLEAR_BUTTON_ID) {
84
			if (getCurrentPage() instanceof IQueryButtomButtons) {
85
				((IQueryButtomButtons) getCurrentPage()).performClearFields();
86
				return true;
87
			}
88
		} else if (buttonId == UPDATE_BUTTON_ID) {
89
			if (getCurrentPage() instanceof IQueryButtomButtons) {
90
				((IQueryButtomButtons) getCurrentPage()).performUpdateConfiguration();
91
				return true;
92
			}
93
		}
94
		return false;
95
	}
96
97
	/**
98
	 * Modeled after WizardDialog.saveAndSetEnabledState(), but that one is private, so create our own
99
	 */
100
	@Override
101
	protected HashMap<String, Boolean> saveAndSetEnabledStateMylyn() {
102
		HashMap<String, Boolean> savedEnabledState = null;
103
		if (getShell() != null) {
104
			savedEnabledState = new HashMap<String, Boolean>();
105
			if (clearButton != null && clearButton.getShell() == getShell()) {
106
				savedEnabledState.put(CLEAR_BUTTON_KEY, clearButton.getEnabled());
107
				clearButton.setEnabled(false);
108
			}
109
			if (updateButton != null && updateButton.getShell() == getShell()) {
110
				savedEnabledState.put(UPDATE_BUTTON_KEY, updateButton.getEnabled());
111
				updateButton.setEnabled(false);
112
			}
113
		}
114
		return savedEnabledState;
115
	}
116
117
	/**
118
	 * Modeled after WizardDialog.restoreEnabledState() and WizardDialog.restoreUIState() -- couldn't override those
119
	 * since they are private, so create our own. Currently only single button to work with, so don't create two
120
	 * separate methods
121
	 */
122
	@Override
123
	protected void restoreEnabledStateMylyn(HashMap<String, Boolean> savedEnabledState) {
124
		if (savedEnabledState != null) {
125
			Boolean savedValidateEnabledState = savedEnabledState.get(CLEAR_BUTTON_KEY);
126
			if (clearButton != null && savedValidateEnabledState != null) {
127
				clearButton.setEnabled(savedValidateEnabledState);
128
			}
129
			savedValidateEnabledState = savedEnabledState.get(UPDATE_BUTTON_KEY);
130
			if (updateButton != null && savedValidateEnabledState != null) {
131
				updateButton.setEnabled(savedValidateEnabledState);
132
			}
133
		}
134
	}
135
}
(-)src/org/eclipse/mylyn/internal/tasks/ui/wizards/messages.properties (+2 lines)
Lines 151-153 Link Here
151
151
152
LocalRepositorySettingsPage_Configure_the_local_repository=Configure the local repository
152
LocalRepositorySettingsPage_Configure_the_local_repository=Configure the local repository
153
LocalRepositorySettingsPage_Local_Repository_Settings=Local Repository Settings
153
LocalRepositorySettingsPage_Local_Repository_Settings=Local Repository Settings
154
QueryWizardDialog_Clear_Fields=Clear Fields
155
QueryWizardDialog_Update_Attributes_from_Repository=Update Attributes from Repository
(-)src/org/eclipse/mylyn/tasks/ui/IQueryButtomButtons.java (+31 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 Tasktop Technologies 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
 * Contributors:
9
 *     Tasktop Technologies - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylyn.tasks.ui;
13
14
/**
15
 * @since 3.6
16
 */
17
public interface IQueryButtomButtons {
18
19
	public boolean canUpdateConfiguration();
20
21
	public boolean needsUpdateConfiguration();
22
23
	public void performUpdateConfiguration();
24
25
	public boolean canClearFields();
26
27
	public boolean needsClearFields();
28
29
	public void performClearFields();
30
31
}
(-)src/org/eclipse/mylyn/tasks/ui/wizards/TaskRepositoryWizardDialog.java (-90 / +44 lines)
Lines 11-42 Link Here
11
11
12
package org.eclipse.mylyn.tasks.ui.wizards;
12
package org.eclipse.mylyn.tasks.ui.wizards;
13
13
14
import java.lang.reflect.InvocationTargetException;
15
import java.util.HashMap;
14
import java.util.HashMap;
16
15
17
import org.eclipse.jface.dialogs.IDialogConstants;
18
import org.eclipse.jface.operation.IRunnableWithProgress;
19
import org.eclipse.jface.wizard.IWizard;
16
import org.eclipse.jface.wizard.IWizard;
20
import org.eclipse.jface.wizard.WizardDialog;
17
import org.eclipse.jface.wizard.WizardDialog;
21
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages;
18
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages;
19
import org.eclipse.mylyn.internal.provisional.commons.ui.dialogs.BottomButtonWizardDialog;
22
import org.eclipse.mylyn.internal.tasks.ui.wizards.Messages;
20
import org.eclipse.mylyn.internal.tasks.ui.wizards.Messages;
23
import org.eclipse.mylyn.tasks.ui.TasksUiImages;
21
import org.eclipse.mylyn.tasks.ui.TasksUiImages;
24
import org.eclipse.swt.SWT;
25
import org.eclipse.swt.layout.GridData;
26
import org.eclipse.swt.layout.GridLayout;
27
import org.eclipse.swt.widgets.Button;
22
import org.eclipse.swt.widgets.Button;
28
import org.eclipse.swt.widgets.Composite;
23
import org.eclipse.swt.widgets.Composite;
29
import org.eclipse.swt.widgets.Control;
30
import org.eclipse.swt.widgets.Label;
31
import org.eclipse.swt.widgets.Shell;
24
import org.eclipse.swt.widgets.Shell;
32
25
33
/**
26
/**
34
 * Wizard dialog for displaying repository settings page. Necessary so we can add a validate button in the button bar.
27
 * Wizard dialog for displaying repository settings page. Necessary so we can add a validate button in the button bar.
35
 * 
28
 * 
36
 * @author Helen Bershadskaya
29
 * @author Helen Bershadskaya
30
 * @author Frank Becker
37
 * @since 3.1
31
 * @since 3.1
38
 */
32
 */
39
public class TaskRepositoryWizardDialog extends WizardDialog {
33
public class TaskRepositoryWizardDialog extends BottomButtonWizardDialog {
40
34
41
	private static final String VALIDATE_BUTTON_KEY = "validate"; //$NON-NLS-1$
35
	private static final String VALIDATE_BUTTON_KEY = "validate"; //$NON-NLS-1$
42
36
Lines 54-98 Link Here
54
	}
48
	}
55
49
56
	/**
50
	/**
57
	 * Overridden so we can add a validate button to the wizard button bar, if a repository settings page requires it.
51
	 * Modeled after super.saveAndSetEnabledState(), but that one is private, so create our own
58
	 * Validate button is added left justified at button bar bottom (next to help image).
59
	 * 
52
	 * 
60
	 * @since 3.1
53
	 * @since 3.6
61
	 */
54
	 */
62
	@Override
55
	@Override
63
	protected Control createButtonBar(Composite parent) {
56
	protected HashMap<String, Boolean> saveAndSetEnabledStateMylyn() {
64
		Composite composite = new Composite(parent, SWT.NONE);
57
		HashMap<String, Boolean> savedEnabledState = null;
65
		GridLayout layout = new GridLayout();
58
		if (getShell() != null) {
66
		layout.numColumns = 0; // create 
59
			savedEnabledState = new HashMap<String, Boolean>();
67
		layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
60
			if (validateServerButton != null && validateServerButton.getShell() == getShell()) {
68
		layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
61
				savedEnabledState.put(VALIDATE_BUTTON_KEY, validateServerButton.getEnabled());
69
		layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
62
				validateServerButton.setEnabled(false);
70
		layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
63
			}
71
72
		composite.setLayout(layout);
73
		composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
74
75
		// create help control if needed
76
		if (isHelpAvailable()) {
77
			createHelpControl(composite);
78
		}
64
		}
65
		return savedEnabledState;
66
	}
79
67
68
	/**
69
	 * Modeled after super.restoreEnabledState() and super.restoreUIState() -- couldn't override those since they are
70
	 * private, so create our own. Currently only single button to work with, so don't create two separate methods
71
	 * 
72
	 * @since 3.6
73
	 */
74
	@Override
75
	protected void restoreEnabledStateMylyn(HashMap<String, Boolean> savedEnabledState) {
76
		if (savedEnabledState != null) {
77
			Boolean savedValidateEnabledState = savedEnabledState.get(VALIDATE_BUTTON_KEY);
78
			if (validateServerButton != null && savedValidateEnabledState != null) {
79
				validateServerButton.setEnabled(savedValidateEnabledState);
80
			}
81
		}
82
	}
83
84
	/**
85
	 * @since 3.6
86
	 */
87
	@Override
88
	protected void createExtraButtons(Composite composite) {
80
		validateServerButton = createButton(composite, VALIDATE_BUTTON_ID,
89
		validateServerButton = createButton(composite, VALIDATE_BUTTON_ID,
81
				Messages.AbstractRepositorySettingsPage_Validate_Settings, false);
90
				Messages.AbstractRepositorySettingsPage_Validate_Settings, false);
82
		validateServerButton.setImage(CommonImages.getImage(TasksUiImages.REPOSITORY_VALIDATE));
91
		validateServerButton.setImage(CommonImages.getImage(TasksUiImages.REPOSITORY_VALIDATE));
83
		validateServerButton.setVisible(false);
92
		validateServerButton.setVisible(false);
84
		setButtonLayoutData(validateServerButton);
93
		setButtonLayoutData(validateServerButton);
85
		Label filler = new Label(composite, SWT.NONE);
86
		filler.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
87
		((GridLayout) composite.getLayout()).numColumns++;
88
89
		super.createButtonsForButtonBar(composite);
90
91
		return composite;
92
	}
94
	}
93
95
96
	/**
97
	 * @since 3.6
98
	 */
94
	@Override
99
	@Override
95
	public void updateButtons() {
100
	protected void updateExtraButtons() {
96
		if (getCurrentPage() instanceof AbstractRepositorySettingsPage
101
		if (getCurrentPage() instanceof AbstractRepositorySettingsPage
97
				&& ((AbstractRepositorySettingsPage) getCurrentPage()).needsValidation()) {
102
				&& ((AbstractRepositorySettingsPage) getCurrentPage()).needsValidation()) {
98
103
Lines 105-174 Link Here
105
				validateServerButton.setVisible(false);
110
				validateServerButton.setVisible(false);
106
			}
111
			}
107
		}
112
		}
108
		super.updateButtons();
109
	}
113
	}
110
114
111
	/**
115
	/**
112
	 * Overridden so we can react to the validate button being pressed. This could have been done with a straight
116
	 * @since 3.6
113
	 * selection listener in the creation method above, but this is more consistent with how the other buttons work in
114
	 * the wizard dialog.
115
	 * 
116
	 * @since 3.1
117
	 */
117
	 */
118
	@Override
118
	@Override
119
	protected void buttonPressed(int buttonId) {
119
	protected boolean handleExtraButtonPressed(int buttonId) {
120
		if (buttonId == VALIDATE_BUTTON_ID) {
120
		if (buttonId == VALIDATE_BUTTON_ID) {
121
			if (getCurrentPage() instanceof AbstractRepositorySettingsPage) {
121
			if (getCurrentPage() instanceof AbstractRepositorySettingsPage) {
122
				((AbstractRepositorySettingsPage) getCurrentPage()).validateSettings();
122
				((AbstractRepositorySettingsPage) getCurrentPage()).validateSettings();
123
			}
123
				return true;
124
		} else {
125
			super.buttonPressed(buttonId);
126
		}
127
	}
128
129
	/**
130
	 * Overridden to be able to set proper state for our validate button
131
	 */
132
	@Override
133
	public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException,
134
			InterruptedException {
135
136
		HashMap<String, Boolean> savedEnabledState = null;
137
		try {
138
			savedEnabledState = saveAndSetEnabledStateMylyn();
139
			super.run(fork, cancelable, runnable);
140
		} finally {
141
			if (savedEnabledState != null) {
142
				restoreEnabledStateMylyn(savedEnabledState);
143
			}
144
		}
145
	}
146
147
	/**
148
	 * Modeled after super.saveAndSetEnabledState(), but that one is private, so create our own
149
	 */
150
	private HashMap<String, Boolean> saveAndSetEnabledStateMylyn() {
151
		HashMap<String, Boolean> savedEnabledState = null;
152
		if (getShell() != null) {
153
			savedEnabledState = new HashMap<String, Boolean>();
154
			if (validateServerButton != null && validateServerButton.getShell() == getShell()) {
155
				savedEnabledState.put(VALIDATE_BUTTON_KEY, validateServerButton.getEnabled());
156
				validateServerButton.setEnabled(false);
157
			}
158
		}
159
		return savedEnabledState;
160
	}
161
162
	/**
163
	 * Modeled after super.restoreEnabledState() and super.restoreUIState() -- couldn't override those since they are
164
	 * private, so create our own. Currently only single button to work with, so don't create two separate methods
165
	 */
166
	private void restoreEnabledStateMylyn(HashMap<String, Boolean> savedEnabledState) {
167
		if (savedEnabledState != null) {
168
			Boolean savedValidateEnabledState = savedEnabledState.get(VALIDATE_BUTTON_KEY);
169
			if (validateServerButton != null && savedValidateEnabledState != null) {
170
				validateServerButton.setEnabled(savedValidateEnabledState);
171
			}
124
			}
172
		}
125
		}
126
		return false;
173
	}
127
	}
174
}
128
}

Return to bug 310059