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 137170 Details for
Bug 248490
The I'm Feeling Lucky Task (Random Task)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Patch
patch_248490.txt (text/plain), 8.38 KB, created by
Jakub Jurkiewicz
on 2009-05-26 11:27:21 EDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Jakub Jurkiewicz
Created:
2009-05-26 11:27:21 EDT
Size:
8.38 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylyn.tasks.ui >Index: src/org/eclipse/mylyn/internal/tasks/ui/actions/ActivateTaskDialogAction.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/ActivateTaskDialogAction.java,v >retrieving revision 1.18 >diff -u -r1.18 ActivateTaskDialogAction.java >--- src/org/eclipse/mylyn/internal/tasks/ui/actions/ActivateTaskDialogAction.java 7 Dec 2008 02:43:31 -0000 1.18 >+++ src/org/eclipse/mylyn/internal/tasks/ui/actions/ActivateTaskDialogAction.java 26 May 2009 15:22:39 -0000 >@@ -36,7 +36,7 @@ > > @Override > public void run(IAction action) { >- TaskSelectionDialog dlg = new TaskSelectionDialog(window.getShell()); >+ TaskSelectionDialogWithRandomOption dlg = new TaskSelectionDialogWithRandomOption(window.getShell()); > dlg.setTitle(Messages.ActivateTaskDialogAction_Activate_Task); > dlg.setMessage(Messages.ActivateTaskDialogAction_Select_a_task_to_activate__); > >Index: src/org/eclipse/mylyn/internal/tasks/ui/actions/Messages.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/Messages.java,v >retrieving revision 1.11 >diff -u -r1.11 Messages.java >--- src/org/eclipse/mylyn/internal/tasks/ui/actions/Messages.java 11 May 2009 18:12:52 -0000 1.11 >+++ src/org/eclipse/mylyn/internal/tasks/ui/actions/Messages.java 26 May 2009 15:22:39 -0000 >@@ -231,6 +231,8 @@ > > public static String TaskSelectionDialog_Open_with_Browser; > >+ public static String TaskSelectionDialog_Random_Task; >+ > public static String TaskSelectionDialog_Scanning_tasks; > > public static String TaskSelectionDialog_Search_for_tasks; >Index: src/org/eclipse/mylyn/internal/tasks/ui/actions/TaskSelectionDialog.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/TaskSelectionDialog.java,v >retrieving revision 1.50 >diff -u -r1.50 TaskSelectionDialog.java >--- src/org/eclipse/mylyn/internal/tasks/ui/actions/TaskSelectionDialog.java 7 Dec 2008 02:43:32 -0000 1.50 >+++ src/org/eclipse/mylyn/internal/tasks/ui/actions/TaskSelectionDialog.java 26 May 2009 15:22:40 -0000 >@@ -505,14 +505,26 @@ > }); > } > >+ createAdditionalButtons(composite); >+ > Label filler = new Label(composite, SWT.NONE); > filler.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL)); > layout.numColumns++; >- super.createButtonsForButtonBar(composite); // cancel button >+ super.createButtonsForButtonBar(composite); // cancel button > > return composite; > } > >+ /** >+ * Allows to add new buttons at the bottom of this dialog next to New Task button >+ * >+ * @param parent >+ * the parent composite to contain the button bar >+ */ >+ protected void createAdditionalButtons(Composite parent) { >+ // we don't want to add any new button >+ } >+ > @Override > protected Control createExtendedContentArea(Composite parent) { > if (!showExtendedOpeningOptions) { >@@ -722,7 +734,8 @@ > if (item instanceof ITask) { > return Status.OK_STATUS; > } >- return new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, Messages.TaskSelectionDialog_Selected_item_is_not_a_task); >+ return new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, >+ Messages.TaskSelectionDialog_Selected_item_is_not_a_task); > } > > } >Index: src/org/eclipse/mylyn/internal/tasks/ui/actions/messages.properties >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/messages.properties,v >retrieving revision 1.12 >diff -u -r1.12 messages.properties >--- src/org/eclipse/mylyn/internal/tasks/ui/actions/messages.properties 11 May 2009 18:12:52 -0000 1.12 >+++ src/org/eclipse/mylyn/internal/tasks/ui/actions/messages.properties 26 May 2009 15:22:40 -0000 >@@ -139,6 +139,7 @@ > TaskSelectionDialog_Edit_Active_Working_Set_=&Edit Active Working Set... > TaskSelectionDialog_New_Task_=&New Task... > TaskSelectionDialog_Open_with_Browser=Open with &Browser >+TaskSelectionDialog_Random_Task=&Random Task > TaskSelectionDialog_Scanning_tasks=Scanning tasks > TaskSelectionDialog_Search_for_tasks=Search for tasks > TaskSelectionDialog_Select_Working_Set_=Select &Working Set... >Index: src/org/eclipse/mylyn/internal/tasks/ui/actions/TaskSelectionDialogWithRandomOption.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/tasks/ui/actions/TaskSelectionDialogWithRandomOption.java >diff -N src/org/eclipse/mylyn/internal/tasks/ui/actions/TaskSelectionDialogWithRandomOption.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/tasks/ui/actions/TaskSelectionDialogWithRandomOption.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,90 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2008 Tasktop Technologies 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 >+ * >+ * Contributors: >+ * Tasktop Technologies - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylyn.internal.tasks.ui.actions; >+ >+import java.util.ArrayList; >+import java.util.Collection; >+import java.util.List; >+import java.util.Random; >+ >+import org.eclipse.jface.dialogs.IDialogConstants; >+import org.eclipse.mylyn.internal.tasks.core.AbstractTask; >+import org.eclipse.mylyn.internal.tasks.core.DateRange; >+import org.eclipse.mylyn.internal.tasks.core.TaskList; >+import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin; >+import org.eclipse.mylyn.tasks.core.ITask; >+import org.eclipse.mylyn.tasks.core.ITask.PriorityLevel; >+import org.eclipse.mylyn.tasks.ui.TasksUi; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Shell; >+ >+public class TaskSelectionDialogWithRandomOption extends TaskSelectionDialog { >+ >+ private Button randomTaskButton; >+ >+ private static final int RANDOM_ID = IDialogConstants.CLIENT_ID + 1; >+ >+ public TaskSelectionDialogWithRandomOption(Shell parent) { >+ super(parent); >+ // ignore >+ } >+ >+ @Override >+ protected void createAdditionalButtons(Composite parent) { >+ >+ randomTaskButton = createButton(parent, RANDOM_ID, Messages.TaskSelectionDialog_Random_Task, false); >+ randomTaskButton.addSelectionListener(new SelectionListener() { >+ >+ TaskList taskList = TasksUiPlugin.getTaskList(); >+ >+ private final Collection<AbstractTask> allTasks = new ArrayList<AbstractTask>(); >+ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ // ignore >+ } >+ >+ public void widgetSelected(SelectionEvent e) { >+ >+ allTasks.addAll(taskList.getAllTasks()); >+ >+ List<AbstractTask> potentialTasks = new ArrayList<AbstractTask>(); >+ for (AbstractTask task : allTasks) { >+ DateRange scheduledForDate = task.getScheduledForDate(); >+ if (!task.getSynchronizationState().isIncoming()) { //don't consider tasks with incomings >+ if (scheduledForDate == null >+ || !TasksUiPlugin.getTaskActivityManager().isScheduledForThisWeek(scheduledForDate)) { //don't consider tasks scheduled for current week >+ potentialTasks.add(task); >+ if (task.getPriority().equals(PriorityLevel.P4) >+ || task.getPriority().equals(PriorityLevel.P5)) { //tasks with low priority have more chances to be chosen >+ potentialTasks.add(task); >+ } >+ } >+ } >+ } >+ >+ if (potentialTasks.size() == 0) { >+ potentialTasks.addAll(allTasks); >+ } >+ >+ int randomTaskIndex = new Random().nextInt(potentialTasks.size()); >+ ITask randomTask = potentialTasks.get(randomTaskIndex); >+ >+ TasksUi.getTaskActivityManager().activateTask(randomTask); //activate the chosen task >+ close(); //close the dialog >+ } >+ }); >+ } >+ >+}
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 Raw
Actions:
View
Attachments on
bug 248490
:
114552
|
114553
|
134941
|
134942
| 137170 |
137414