blob: 970b0b55341f0c5707f97397db6e30406f40232a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
/*******************************************************************************
* Copyright (c) 2009 Tasktop Technologies.
* 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:
* Tasktop Technologies - initial API and implementation
*******************************************************************************/
package org.eclipse.mylyn.internal.tasks.ui.commands;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.mylyn.internal.discovery.ui.wizards.ConnectorDiscoveryWizard;
import org.eclipse.mylyn.internal.provisional.commons.ui.WorkbenchUtil;
import org.eclipse.mylyn.internal.tasks.ui.ITasksUiPreferenceConstants;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
/**
* A command that causes the {@link ConnectorDiscoveryWizard} to appear in a dialog.
*
* @author David Green
* @author Steffen Pingel
*/
public class ShowTasksConnectorDiscoveryWizardCommandHandler extends AbstractHandler {
private static final String ID_P2_INSTALL_UI = "org.eclipse.equinox.p2.ui.sdk/org.eclipse.equinox.p2.ui.sdk.install"; //$NON-NLS-1$
public Object execute(ExecutionEvent event) throws ExecutionException {
// check to make sure that the p2 install ui is enabled
if (WorkbenchUtil.allowUseOf(ID_P2_INSTALL_UI)) {
ConnectorDiscoveryWizard wizard = new ConnectorDiscoveryWizard();
WizardDialog dialog = new WizardDialog(WorkbenchUtil.getShell(), wizard) {
@Override
protected void createButtonsForButtonBar(Composite parent) {
super.createButtonsForButtonBar(parent);
((GridLayout) parent.getLayout()).numColumns++;
final Button button = new Button(parent, SWT.CHECK);
button.setSelection(TasksUiPlugin.getDefault()
.getPreferenceStore()
.getBoolean(ITasksUiPreferenceConstants.SERVICE_MESSAGES_ENABLED));
button.setText("Notify when new connectors are available");
button.setFont(JFaceResources.getDialogFont());
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
TasksUiPlugin.getDefault()
.getPreferenceStore()
.setValue(ITasksUiPreferenceConstants.SERVICE_MESSAGES_ENABLED,
button.getSelection());
}
});
button.moveAbove(null);
}
};
dialog.open();
} else {
MessageDialog.openWarning(WorkbenchUtil.getShell(), "Install Connectors",
"Unable to launch connector install since the required platform support is not available.");
}
return null;
}
}
|