Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 74262 Details for
Bug 189518
support import/export of Task List queries
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Query import/export UI
query-import-export-ui-1_1.txt (text/plain), 10.32 KB, created by
Jevgeni Holodkov
on 2007-07-20 10:45:36 EDT
(
hide
)
Description:
Query import/export UI
Filename:
MIME Type:
Creator:
Jevgeni Holodkov
Created:
2007-07-20 10:45:36 EDT
Size:
10.32 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylyn.tasks.ui >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/plugin.xml,v >retrieving revision 1.254 >diff -u -r1.254 plugin.xml >--- plugin.xml 7 Jul 2007 01:38:37 -0000 1.254 >+++ plugin.xml 20 Jul 2007 14:43:54 -0000 >@@ -99,7 +99,7 @@ > class="org.eclipse.mylyn.internal.tasks.ui.wizards.TaskDataImportWizard" > icon="icons/eview16/task-list.gif" > id="org.eclipse.mylyn.tasks.ui.wizards.import" >- name="Task List"> >+ name="Task Data"> > <description> > Import task data files from file system. > </description> >@@ -342,7 +342,38 @@ > </or> > </enablement> > </action> >+ >+ <!-- <action >+ class="org.eclipse.mylyn.internal.tasks.ui.actions.QueryCloneAction" >+ definitionId="org.eclipse.ui.query.clone" >+ enablesFor="org.eclipse.mylyn.tasks.core.AbstractRepositoryQuery" >+ id="org.eclipse.mylyn.tasks.ui.actions.clone.query" >+ label="Clone Query..." >+ menubarPath="repository" >+ tooltip="Clone Repository Query"> >+ </action>--> >+ >+ <action >+ class="org.eclipse.mylyn.internal.tasks.ui.actions.QueryExportAction" >+ definitionId="org.eclipse.ui.query.export" >+ enablesFor="org.eclipse.mylyn.tasks.core.AbstractRepositoryQuery" >+ id="org.eclipse.mylyn.tasks.ui.actions.export.query" >+ label="Export Query..." >+ menubarPath="repository" >+ tooltip="Export Repository Query"> >+ </action> > >+ <action >+ class="org.eclipse.mylyn.internal.tasks.ui.actions.QueryImportAction" >+ definitionId="org.eclipse.ui.query.import" >+ enablesFor="*" >+ icon="icons/etool16/import.gif" >+ id="org.eclipse.mylyn.tasks.ui.actions.import.query" >+ label="Import Query..." >+ menubarPath="repository" >+ tooltip="Import Repository Query"> >+ </action> >+ > <action > class="org.eclipse.mylyn.internal.tasks.ui.actions.NewTaskAction" > enablesFor="*" >Index: src/org/eclipse/mylyn/internal/tasks/ui/actions/QueryImportAction.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/tasks/ui/actions/QueryImportAction.java >diff -N src/org/eclipse/mylyn/internal/tasks/ui/actions/QueryImportAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/tasks/ui/actions/QueryImportAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,90 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2007 Mylyn project committers and others. >+ * 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 >+ *******************************************************************************/ >+ >+package org.eclipse.mylyn.internal.tasks.ui.actions; >+ >+import java.io.File; >+import java.util.List; >+ >+import org.eclipse.jface.action.Action; >+import org.eclipse.jface.action.IAction; >+import org.eclipse.jface.dialogs.MessageDialog; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.mylyn.internal.tasks.ui.ITasksUiConstants; >+import org.eclipse.mylyn.tasks.core.AbstractRepositoryQuery; >+import org.eclipse.mylyn.tasks.ui.TasksUiPlugin; >+import org.eclipse.swt.widgets.FileDialog; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.ui.IViewActionDelegate; >+import org.eclipse.ui.IViewPart; >+import org.eclipse.ui.PlatformUI; >+ >+/** >+ * Makes able to select an exported query file and import it back to the system. >+ * @author Jevgeni Holodkov >+ */ >+public class QueryImportAction extends Action implements IViewActionDelegate { >+ >+ protected ISelection selection; >+ >+ public void init(IViewPart view) { >+ // ignore >+ } >+ >+ public void run(IAction action) { >+ run(); >+ } >+ >+ public void selectionChanged(IAction action, ISelection selection) { >+ // ignore >+ } >+ >+ >+ public void run() { >+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); >+ FileDialog dialog = new FileDialog(shell); >+ dialog.setFilterExtensions(new String[] { "*" + ITasksUiConstants.FILE_EXTENSION }); >+ >+ String path = dialog.open(); >+ if (path != null) { >+ File file = new File(path); >+ if (file.isFile()) { >+ List<AbstractRepositoryQuery> queries = TasksUiPlugin.getTaskListManager() >+ .getTaskListWriter() >+ .readQueries(file); >+ >+ if (queries.size() > 0) { >+ List<AbstractRepositoryQuery> badQueries = TasksUiPlugin.getTaskListManager().insertQueries(queries); >+ >+ // notify user about importing >+ String message = "The following queries were imported successfully: "; >+ for(AbstractRepositoryQuery imported : queries) { >+ if(!badQueries.contains(imported)) { >+ message += "\n" + imported.getHandleIdentifier(); >+ } >+ } >+ >+ if(badQueries.size() > 0) { >+ message += "\n\n These queries were not imported, since their repository was not found: "; >+ for (AbstractRepositoryQuery bad : badQueries) { >+ message += "\n" + bad.getHandleIdentifier(); >+ } >+ } >+ >+ MessageDialog.openInformation(shell, "Query Export Completed", message); >+ } else { >+ MessageDialog.openError(shell, "Query Export Error", >+ "The specified file is not an exported query. Please, check that you have provided the correct file."); >+ return; >+ } >+ } >+ } >+ return; >+ } >+ >+} >Index: src/org/eclipse/mylyn/internal/tasks/ui/actions/QueryExportAction.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/tasks/ui/actions/QueryExportAction.java >diff -N src/org/eclipse/mylyn/internal/tasks/ui/actions/QueryExportAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/tasks/ui/actions/QueryExportAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,109 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2007 Mylyn project committers and others. >+ * 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 >+ *******************************************************************************/ >+ >+package org.eclipse.mylyn.internal.tasks.ui.actions; >+ >+import java.io.File; >+import java.text.SimpleDateFormat; >+import java.util.ArrayList; >+import java.util.Date; >+import java.util.List; >+import java.util.Locale; >+ >+import org.eclipse.jface.action.Action; >+import org.eclipse.jface.action.IAction; >+import org.eclipse.jface.dialogs.MessageDialog; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.StructuredSelection; >+import org.eclipse.mylyn.internal.tasks.ui.ITasksUiConstants; >+import org.eclipse.mylyn.tasks.core.AbstractRepositoryQuery; >+import org.eclipse.mylyn.tasks.ui.TasksUiPlugin; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.widgets.FileDialog; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.ui.IViewActionDelegate; >+import org.eclipse.ui.IViewPart; >+import org.eclipse.ui.PlatformUI; >+ >+/** >+ * Makes able to export selected query to the file system. >+ * @author Jevgeni Holodkov >+ */ >+public class QueryExportAction extends Action implements IViewActionDelegate { >+ >+ protected ISelection selection; >+ >+ public void init(IViewPart view) { >+ // ignore >+ } >+ >+ public void run(IAction action) { >+ run(getSelectedQueries(selection)); >+ } >+ >+ public void selectionChanged(IAction action, ISelection selection) { >+ this.selection = selection; >+ List<AbstractRepositoryQuery> selectedQueries = getSelectedQueries(selection); >+ action.setEnabled(true); >+ if (selectedQueries.size() > 0) { >+ action.setEnabled(true); >+ } else { >+ action.setEnabled(false); >+ } >+ } >+ >+ @SuppressWarnings("unchecked") >+ protected List<AbstractRepositoryQuery> getSelectedQueries(ISelection newSelection) { >+ List<AbstractRepositoryQuery> selectedQueries = new ArrayList<AbstractRepositoryQuery>(); >+ if (selection instanceof StructuredSelection) { >+ List selectedObjects = ((StructuredSelection) selection).toList(); >+ for (Object selectedObject : selectedObjects) { >+ if (selectedObject instanceof AbstractRepositoryQuery) { >+ selectedQueries.add((AbstractRepositoryQuery)selectedObject); >+ } >+ } >+ } >+ return selectedQueries; >+ } >+ >+ >+ >+ public void run(List<AbstractRepositoryQuery> queries) { >+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); >+ FileDialog dialog = new FileDialog(shell, SWT.PRIMARY_MODAL | SWT.SAVE); >+ dialog.setFilterExtensions(new String[] { "*" + ITasksUiConstants.FILE_EXTENSION }); >+ if (queries.size() == 1) { >+ dialog.setFileName(queries.get(0).getHandleIdentifier()); >+ } else { >+ String fomratString = "yyyy-MM-dd"; >+ SimpleDateFormat format = new SimpleDateFormat(fomratString, Locale.ENGLISH); >+ String date = format.format(new Date()); >+ dialog.setFileName(date + "-exported-queries"); >+ } >+ >+ String path = dialog.open(); >+ if (path != null) { >+ File file = new File(path); >+ if (file.isDirectory()) { >+ MessageDialog.openError(shell, "Query Export Error", "Could not export query because specified location is a folder"); >+ return; >+ } >+ >+ // Prompt the user to confirm if save operation will cause an overwrite >+ if (file.exists()) { >+ if (!MessageDialog.openConfirm(shell, "Confirm File Replace", "The file " + file.getPath() >+ + " already exists. Do you want to overwrite it?")) { >+ return; >+ } >+ } >+ >+ TasksUiPlugin.getTaskListManager().getTaskListWriter().writeQueries(queries, file); >+ } >+ return; >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 189518
:
73436
|
73437
|
73863
|
73864
|
74255
|
74256
| 74262 |
74263
|
74311
|
75245
|
75246