|
Lines 11-18
Link Here
|
| 11 |
import org.eclipse.core.commands.AbstractHandler; |
11 |
import org.eclipse.core.commands.AbstractHandler; |
| 12 |
import org.eclipse.core.commands.ExecutionEvent; |
12 |
import org.eclipse.core.commands.ExecutionEvent; |
| 13 |
import org.eclipse.core.commands.ExecutionException; |
13 |
import org.eclipse.core.commands.ExecutionException; |
|
|
14 |
import org.eclipse.jface.dialogs.MessageDialogWithToggle; |
| 15 |
import org.eclipse.jface.preference.IPreferenceStore; |
| 16 |
import org.eclipse.jface.window.Window; |
| 17 |
import org.eclipse.jface.wizard.IWizard; |
| 18 |
import org.eclipse.jface.wizard.Wizard; |
| 14 |
import org.eclipse.jface.wizard.WizardDialog; |
19 |
import org.eclipse.jface.wizard.WizardDialog; |
| 15 |
import org.eclipse.mylyn.internal.tasks.ui.wizards.NewRepositoryWizard; |
20 |
import org.eclipse.mylyn.internal.tasks.ui.wizards.NewRepositoryWizard; |
|
|
21 |
import org.eclipse.mylyn.tasks.core.TaskRepository; |
| 22 |
import org.eclipse.mylyn.tasks.ui.AbstractRepositoryConnectorUi; |
| 23 |
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin; |
| 16 |
import org.eclipse.swt.widgets.Shell; |
24 |
import org.eclipse.swt.widgets.Shell; |
| 17 |
import org.eclipse.ui.PlatformUI; |
25 |
import org.eclipse.ui.PlatformUI; |
| 18 |
|
26 |
|
|
Lines 20-41
Link Here
|
| 20 |
* Handles the "add task repository" command |
28 |
* Handles the "add task repository" command |
| 21 |
* |
29 |
* |
| 22 |
* @author Willian Mitsuda |
30 |
* @author Willian Mitsuda |
|
|
31 |
* @author Balazs Brinkus (bug 174473) |
| 23 |
*/ |
32 |
*/ |
| 24 |
public class AddTaskRepositoryHandler extends AbstractHandler { |
33 |
public class AddTaskRepositoryHandler extends AbstractHandler { |
| 25 |
|
34 |
|
|
|
35 |
private static final String PREF_ADD_QUERY = "org.eclipse.mylyn.internal.tasks.add.query"; |
| 36 |
|
| 26 |
@Override |
37 |
@Override |
| 27 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
38 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
| 28 |
String param = event.getParameter("org.eclipse.mylyn.tasks.command.taskRepositoryId"); |
39 |
String param = event.getParameter("org.eclipse.mylyn.tasks.command.taskRepositoryId"); |
| 29 |
NewRepositoryWizard wizard = new NewRepositoryWizard(param); |
40 |
|
|
|
41 |
NewRepositoryWizard repositoryWizard = new NewRepositoryWizard(param); |
| 30 |
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); |
42 |
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); |
| 31 |
if (shell != null && !shell.isDisposed()) { |
43 |
if (shell != null && !shell.isDisposed()) { |
| 32 |
WizardDialog dialog = new WizardDialog(shell, wizard); |
44 |
WizardDialog repositoryDialog = new WizardDialog(shell, repositoryWizard); |
| 33 |
dialog.create(); |
45 |
repositoryDialog.create(); |
| 34 |
dialog.getShell().setText("Add Task Repository"); |
46 |
repositoryDialog.getShell().setText("Add Task Repository"); |
| 35 |
dialog.setBlockOnOpen(true); |
47 |
repositoryDialog.setBlockOnOpen(true); |
| 36 |
dialog.open(); |
48 |
repositoryDialog.open(); |
|
|
49 |
|
| 50 |
if (repositoryDialog.getReturnCode() == Window.OK) { |
| 51 |
|
| 52 |
IPreferenceStore preferenceStore = TasksUiPlugin.getDefault().getPreferenceStore(); |
| 53 |
|
| 54 |
if (!preferenceStore.getBoolean(PREF_ADD_QUERY)) { |
| 55 |
MessageDialogWithToggle messageDialog = MessageDialogWithToggle.openYesNoQuestion( |
| 56 |
PlatformUI.getWorkbench().getDisplay().getActiveShell(), "Add new query", |
| 57 |
"Would you like to add query for this repository?", "Do not show again", false, |
| 58 |
preferenceStore, PREF_ADD_QUERY); |
| 59 |
preferenceStore.setValue(PREF_ADD_QUERY, messageDialog.getToggleState()); |
| 60 |
|
| 61 |
if (messageDialog.getReturnCode() == 2) { |
| 62 |
TaskRepository taskRepository = repositoryWizard.getRepository(); |
| 63 |
|
| 64 |
AbstractRepositoryConnectorUi connectorUi = TasksUiPlugin.getConnectorUi(taskRepository.getConnectorKind()); |
| 65 |
IWizard queryWizard = connectorUi.getQueryWizard(taskRepository, null); |
| 66 |
((Wizard) queryWizard).setForcePreviousAndNextButtons(true); |
| 67 |
|
| 68 |
WizardDialog queryDialog = new WizardDialog(shell, queryWizard); |
| 69 |
queryDialog.create(); |
| 70 |
queryDialog.setTitle("Add Repository Query"); |
| 71 |
queryDialog.setBlockOnOpen(true); |
| 72 |
queryDialog.open(); |
| 73 |
} |
| 74 |
} |
| 75 |
} |
| 76 |
|
| 37 |
} |
77 |
} |
|
|
78 |
|
| 38 |
return null; |
79 |
return null; |
| 39 |
} |
80 |
} |
| 40 |
|
|
|
| 41 |
} |
81 |
} |