Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/commands/ShowTasksConnectorDiscoveryWizardCommandHandler.java')
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/commands/ShowTasksConnectorDiscoveryWizardCommandHandler.java76
1 files changed, 76 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/commands/ShowTasksConnectorDiscoveryWizardCommandHandler.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/commands/ShowTasksConnectorDiscoveryWizardCommandHandler.java
new file mode 100644
index 000000000..970b0b553
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/commands/ShowTasksConnectorDiscoveryWizardCommandHandler.java
@@ -0,0 +1,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;
+ }
+}

Back to the top