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 74482 Details for
Bug 189514
allow import/export and cloning of 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]
Clone query UI
query-cloning-ui-1_0.txt (text/plain), 8.66 KB, created by
Jevgeni Holodkov
on 2007-07-24 12:10:36 EDT
(
hide
)
Description:
Clone query UI
Filename:
MIME Type:
Creator:
Jevgeni Holodkov
Created:
2007-07-24 12:10:36 EDT
Size:
8.66 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylyn.tasks.ui >Index: src/org/eclipse/mylyn/tasks/ui/TaskListManager.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskListManager.java,v >retrieving revision 1.102 >diff -u -r1.102 TaskListManager.java >--- src/org/eclipse/mylyn/tasks/ui/TaskListManager.java 24 Jul 2007 05:59:41 -0000 1.102 >+++ src/org/eclipse/mylyn/tasks/ui/TaskListManager.java 24 Jul 2007 16:08:21 -0000 >@@ -1206,9 +1206,6 @@ > public List<AbstractRepositoryQuery> insertQueries(List<AbstractRepositoryQuery> queries) { > List<AbstractRepositoryQuery> badQueries = new ArrayList<AbstractRepositoryQuery>(); > >- String patternStr = "\\[(\\d+)\\]$"; // all string that end with [x], where x is a number >- Pattern pattern = Pattern.compile(patternStr); >- > for (AbstractRepositoryQuery query : queries) { > > TaskRepository repository = TasksUiPlugin.getRepositoryManager().getRepository( >@@ -1218,31 +1215,8 @@ > continue; > } > >- // resolve name conflict >- { >- Set<AbstractRepositoryQuery> existingQueries = getTaskList().getQueries(); >- Map<String, AbstractRepositoryQuery> queryMap = new HashMap<String, AbstractRepositoryQuery>(); >- for (AbstractRepositoryQuery existingQuery : existingQueries) { >- queryMap.put(existingQuery.getHandleIdentifier(), existingQuery); >- } >- >- // suggest a new handle if needed >- String handle = query.getHandleIdentifier(); >- >- while (queryMap.get(handle) != null) { >- Matcher matcher = pattern.matcher(handle); >- boolean matchFound = matcher.find(); >- if (matchFound) { >- // increment index >- int index = Integer.parseInt(matcher.group(1)); >- index++; >- handle = matcher.replaceAll("[" + index + "]"); >- } else { >- handle += "[1]"; >- } >- } >- query.setHandleIdentifier(handle); >- } >+ String handle = resolveIdentifiersConflict(query); >+ query.setHandleIdentifier(handle); > > // add query > TasksUiPlugin.getTaskListManager().getTaskList().addQuery(query); >@@ -1258,4 +1232,41 @@ > return badQueries; > } > >+ /** >+ * Utility method that checks, if there is already a query with the same identifier. >+ * @param query >+ * @return a handle, that is not in conflict with any existed one in the system. If there were no >+ * conflict in the beginning, then the query's own identifier is returned. If there were, then >+ * the suffix [x] is applied the query's identifier, where x is a number. >+ */ >+ public String resolveIdentifiersConflict(AbstractRepositoryQuery query) { >+ String patternStr = "\\[(\\d+)\\]$"; // all string that end with [x], where x is a number >+ Pattern pattern = Pattern.compile(patternStr); >+ >+ // resolve name conflict >+ Set<AbstractRepositoryQuery> existingQueries = getTaskList().getQueries(); >+ Map<String, AbstractRepositoryQuery> queryMap = new HashMap<String, AbstractRepositoryQuery>(); >+ for (AbstractRepositoryQuery existingQuery : existingQueries) { >+ queryMap.put(existingQuery.getHandleIdentifier(), existingQuery); >+ } >+ >+ // suggest a new handle if needed >+ String handle = query.getHandleIdentifier(); >+ >+ while (queryMap.get(handle) != null) { >+ Matcher matcher = pattern.matcher(handle); >+ boolean matchFound = matcher.find(); >+ if (matchFound) { >+ // increment index >+ int index = Integer.parseInt(matcher.group(1)); >+ index++; >+ handle = matcher.replaceAll("[" + index + "]"); >+ } else { >+ handle += "[1]"; >+ } >+ } >+ >+ return handle; >+ } >+ > } >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/plugin.xml,v >retrieving revision 1.255 >diff -u -r1.255 plugin.xml >--- plugin.xml 24 Jul 2007 05:59:41 -0000 1.255 >+++ plugin.xml 24 Jul 2007 16:08:20 -0000 >@@ -343,7 +343,7 @@ > </enablement> > </action> > >- <!-- <action >+ <action > class="org.eclipse.mylyn.internal.tasks.ui.actions.QueryCloneAction" > definitionId="org.eclipse.ui.query.clone" > enablesFor="org.eclipse.mylyn.tasks.core.AbstractRepositoryQuery" >@@ -351,7 +351,7 @@ > label="Clone Query..." > menubarPath="repository" > tooltip="Clone Repository Query"> >- </action>--> >+ </action> > > <action > class="org.eclipse.mylyn.internal.tasks.ui.actions.QueryExportAction" >Index: src/org/eclipse/mylyn/internal/tasks/ui/actions/QueryCloneAction.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/tasks/ui/actions/QueryCloneAction.java >diff -N src/org/eclipse/mylyn/internal/tasks/ui/actions/QueryCloneAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/tasks/ui/actions/QueryCloneAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,99 @@ >+/******************************************************************************* >+ * 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.util.ArrayList; >+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.jface.viewers.StructuredSelection; >+import org.eclipse.mylyn.internal.tasks.ui.ITasksUiConstants; >+import org.eclipse.mylyn.monitor.core.StatusHandler; >+import org.eclipse.mylyn.tasks.core.AbstractRepositoryQuery; >+import org.eclipse.mylyn.tasks.ui.AbstractRepositoryConnectorUi; >+import org.eclipse.mylyn.tasks.ui.TasksUiPlugin; >+import org.eclipse.ui.IViewActionDelegate; >+import org.eclipse.ui.IViewPart; >+import org.eclipse.ui.PlatformUI; >+import org.w3c.dom.Document; >+ >+/** >+ * Allow to clone a selected query. >+ * >+ * @author Jevgeni Holodkov >+ */ >+public class QueryCloneAction extends Action implements IViewActionDelegate { >+ >+ protected ISelection selection; >+ >+ public void init(IViewPart view) { >+ // ignore >+ } >+ >+ public void run(IAction action) { >+ run(getSelectedQuery(selection)); >+ } >+ >+ public void selectionChanged(IAction action, ISelection selection) { >+ this.selection = selection; >+ AbstractRepositoryQuery selectedQuery = getSelectedQuery(selection); >+ action.setEnabled(true); >+ if (selectedQuery != null) { >+ action.setEnabled(true); >+ } else { >+ action.setEnabled(false); >+ } >+ } >+ >+ protected AbstractRepositoryQuery getSelectedQuery(ISelection newSelection) { >+ if (selection instanceof StructuredSelection) { >+ // allow to select only one element >+ if (((StructuredSelection) selection).size() == 1) { >+ Object selectedObject = ((StructuredSelection) selection).getFirstElement(); >+ if (selectedObject instanceof AbstractRepositoryQuery) { >+ return (AbstractRepositoryQuery) selectedObject; >+ } >+ } >+ } >+ return null; >+ } >+ >+ public void run(AbstractRepositoryQuery selectedQuery) { >+ if (selectedQuery == null) { >+ MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), >+ ITasksUiConstants.TITLE_DIALOG, "No query selected."); >+ return; >+ } >+ >+ List<AbstractRepositoryQuery> queries = new ArrayList<AbstractRepositoryQuery>(); >+ queries.add(selectedQuery); >+ >+ Document queryDoc = TasksUiPlugin.getTaskListManager().getTaskListWriter().createQueryDocument(queries); >+ List<AbstractRepositoryQuery> clonedQueries = TasksUiPlugin.getTaskListManager() >+ .getTaskListWriter() >+ .readQueryDocument(queryDoc); >+ >+ if (clonedQueries.size() > 0) { >+ for (AbstractRepositoryQuery query : clonedQueries) { >+ String handle = TasksUiPlugin.getTaskListManager().resolveIdentifiersConflict(query); >+ query.setHandleIdentifier(handle); >+ AbstractRepositoryConnectorUi connectorUi = TasksUiPlugin.getConnectorUi(query.getRepositoryKind()); >+ connectorUi.openEditQueryDialog(query); >+ } >+ } else { >+ // cannot happen >+ StatusHandler.fail(new IllegalStateException(selectedQuery.toString()), "Query cloning did not succeeded.", true); >+ 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 189514
: 74482 |
74483