Source Code Cross Referenced for TaskList.java in  » IDE-Eclipse » ui-ide » org » eclipse » ui » views » tasklist » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Eclipse » ui ide » org.eclipse.ui.views.tasklist 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*******************************************************************************
0002:         * Copyright (c) 2000, 2006 IBM Corporation and others.
0003:         * All rights reserved. This program and the accompanying materials
0004:         * are made available under the terms of the Eclipse Public License v1.0
0005:         * which accompanies this distribution, and is available at
0006:         * http://www.eclipse.org/legal/epl-v10.html
0007:         *
0008:         * Contributors:
0009:         *     IBM Corporation - initial API and implementation
0010:         *     Cagatay Kavukcuoglu <cagatayk@acm.org> - Filter for markers in same project
0011:         *     Sebastian Davids <sdavids@gmx.de> - Reordered menu items
0012:         *******************************************************************************/package org.eclipse.ui.views.tasklist;
0013:
0014:        import java.util.ArrayList;
0015:        import java.util.Arrays;
0016:        import java.util.Iterator;
0017:
0018:        import org.eclipse.core.resources.IFile;
0019:        import org.eclipse.core.resources.IMarker;
0020:        import org.eclipse.core.resources.IProject;
0021:        import org.eclipse.core.resources.IResource;
0022:        import org.eclipse.core.resources.IWorkspace;
0023:        import org.eclipse.core.resources.IWorkspaceRoot;
0024:        import org.eclipse.core.resources.ResourcesPlugin;
0025:        import org.eclipse.core.runtime.Assert;
0026:        import org.eclipse.core.runtime.CoreException;
0027:        import org.eclipse.core.runtime.IAdaptable;
0028:        import org.eclipse.core.runtime.Platform;
0029:        import org.eclipse.jface.action.Action;
0030:        import org.eclipse.jface.action.IMenuListener;
0031:        import org.eclipse.jface.action.IMenuManager;
0032:        import org.eclipse.jface.action.IToolBarManager;
0033:        import org.eclipse.jface.action.MenuManager;
0034:        import org.eclipse.jface.action.Separator;
0035:        import org.eclipse.jface.dialogs.ErrorDialog;
0036:        import org.eclipse.jface.dialogs.IDialogSettings;
0037:        import org.eclipse.jface.viewers.CellEditor;
0038:        import org.eclipse.jface.viewers.CheckboxCellEditor;
0039:        import org.eclipse.jface.viewers.ColumnLayoutData;
0040:        import org.eclipse.jface.viewers.ColumnPixelData;
0041:        import org.eclipse.jface.viewers.ColumnWeightData;
0042:        import org.eclipse.jface.viewers.ComboBoxCellEditor;
0043:        import org.eclipse.jface.viewers.IBasicPropertyConstants;
0044:        import org.eclipse.jface.viewers.ICellModifier;
0045:        import org.eclipse.jface.viewers.IOpenListener;
0046:        import org.eclipse.jface.viewers.ISelection;
0047:        import org.eclipse.jface.viewers.ISelectionChangedListener;
0048:        import org.eclipse.jface.viewers.ISelectionProvider;
0049:        import org.eclipse.jface.viewers.IStructuredSelection;
0050:        import org.eclipse.jface.viewers.ITableLabelProvider;
0051:        import org.eclipse.jface.viewers.LabelProvider;
0052:        import org.eclipse.jface.viewers.OpenEvent;
0053:        import org.eclipse.jface.viewers.SelectionChangedEvent;
0054:        import org.eclipse.jface.viewers.StructuredSelection;
0055:        import org.eclipse.jface.viewers.TableLayout;
0056:        import org.eclipse.jface.viewers.TableViewer;
0057:        import org.eclipse.jface.viewers.TextCellEditor;
0058:        import org.eclipse.swt.SWT;
0059:        import org.eclipse.swt.accessibility.ACC;
0060:        import org.eclipse.swt.accessibility.AccessibleControlAdapter;
0061:        import org.eclipse.swt.accessibility.AccessibleControlEvent;
0062:        import org.eclipse.swt.custom.BusyIndicator;
0063:        import org.eclipse.swt.custom.StackLayout;
0064:        import org.eclipse.swt.custom.TableEditor;
0065:        import org.eclipse.swt.dnd.Clipboard;
0066:        import org.eclipse.swt.dnd.DND;
0067:        import org.eclipse.swt.dnd.DragSourceAdapter;
0068:        import org.eclipse.swt.dnd.DragSourceEvent;
0069:        import org.eclipse.swt.dnd.DragSourceListener;
0070:        import org.eclipse.swt.dnd.TextTransfer;
0071:        import org.eclipse.swt.dnd.Transfer;
0072:        import org.eclipse.swt.events.HelpEvent;
0073:        import org.eclipse.swt.events.HelpListener;
0074:        import org.eclipse.swt.events.KeyAdapter;
0075:        import org.eclipse.swt.events.KeyEvent;
0076:        import org.eclipse.swt.events.SelectionAdapter;
0077:        import org.eclipse.swt.events.SelectionEvent;
0078:        import org.eclipse.swt.events.SelectionListener;
0079:        import org.eclipse.swt.graphics.Image;
0080:        import org.eclipse.swt.layout.GridLayout;
0081:        import org.eclipse.swt.widgets.Composite;
0082:        import org.eclipse.swt.widgets.Control;
0083:        import org.eclipse.swt.widgets.Item;
0084:        import org.eclipse.swt.widgets.Label;
0085:        import org.eclipse.swt.widgets.Menu;
0086:        import org.eclipse.swt.widgets.Table;
0087:        import org.eclipse.swt.widgets.TableColumn;
0088:        import org.eclipse.ui.IActionBars;
0089:        import org.eclipse.ui.IEditorInput;
0090:        import org.eclipse.ui.IEditorPart;
0091:        import org.eclipse.ui.IMemento;
0092:        import org.eclipse.ui.IPageLayout;
0093:        import org.eclipse.ui.IPartListener;
0094:        import org.eclipse.ui.ISharedImages;
0095:        import org.eclipse.ui.IViewSite;
0096:        import org.eclipse.ui.IWorkbenchActionConstants;
0097:        import org.eclipse.ui.IWorkbenchPart;
0098:        import org.eclipse.ui.PartInitException;
0099:        import org.eclipse.ui.PlatformUI;
0100:        import org.eclipse.ui.actions.ActionFactory;
0101:        import org.eclipse.ui.ide.IDE;
0102:        import org.eclipse.ui.ide.ResourceUtil;
0103:        import org.eclipse.ui.internal.views.tasklist.TaskListMessages;
0104:        import org.eclipse.ui.part.CellEditorActionHandler;
0105:        import org.eclipse.ui.part.IShowInSource;
0106:        import org.eclipse.ui.part.IShowInTargetList;
0107:        import org.eclipse.ui.part.MarkerTransfer;
0108:        import org.eclipse.ui.part.ShowInContext;
0109:        import org.eclipse.ui.part.ViewPart;
0110:        import org.eclipse.ui.plugin.AbstractUIPlugin;
0111:
0112:        /**
0113:         * Main class for the Task List view for displaying tasks and problem annotations
0114:         * on resources, and for opening an editor on the resource when the user commands.
0115:         * <p>
0116:         * This standard view has id <code>"org.eclipse.ui.views.TaskList"</code>.
0117:         * </p>
0118:         * <p>
0119:         * The workbench will automatically instantiate this class when a Task List
0120:         * view is needed for a workbench window. This class is not intended
0121:         * to be instantiated or subclassed by clients.
0122:         * </p>
0123:         */
0124:        public class TaskList extends ViewPart {
0125:
0126:            private Table table;
0127:
0128:            private TaskSorter comparator;
0129:
0130:            private CellEditor descriptionEditor;
0131:
0132:            private TableViewer viewer;
0133:
0134:            private TasksFilter filter = new TasksFilter();
0135:
0136:            private IMemento memento;
0137:
0138:            private boolean markerLimitExceeded;
0139:
0140:            private Composite parent;
0141:
0142:            private StackLayout stackLayout = new StackLayout();
0143:
0144:            private Composite compositeMarkerLimitExceeded;
0145:
0146:            private CellEditorActionHandler editorActionHandler;
0147:
0148:            private TaskAction newTaskAction;
0149:
0150:            private TaskAction copyTaskAction;
0151:
0152:            private TaskAction pasteTaskAction;
0153:
0154:            private TaskAction removeTaskAction;
0155:
0156:            private TaskAction purgeCompletedAction;
0157:
0158:            private TaskAction gotoTaskAction;
0159:
0160:            private TaskAction selectAllAction;
0161:
0162:            private ResolveMarkerAction resolveMarkerAction;
0163:
0164:            private TaskAction filtersAction;
0165:
0166:            private MarkCompletedAction markCompletedAction;
0167:
0168:            private TaskAction propertiesAction;
0169:
0170:            //sort by action
0171:            private Action sortByCategoryAction;
0172:
0173:            private Action sortByCompletedAction;
0174:
0175:            private Action sortByPriorityAction;
0176:
0177:            private Action sortByDescriptionAction;
0178:
0179:            private Action sortByResourceAction;
0180:
0181:            private Action sortByContainerAction;
0182:
0183:            private Action sortByLocationAction;
0184:
0185:            private Action sortByCreationTimeAction;
0186:
0187:            private Action sortAscendingAction;
0188:
0189:            private Action sortDescendingAction;
0190:
0191:            private Clipboard clipboard;
0192:
0193:            private static String[] tableColumnProperties = {
0194:                    IBasicPropertyConstants.P_IMAGE, IMarker.DONE,
0195:                    IMarker.PRIORITY, IMarker.MESSAGE,
0196:                    IMarkerConstants.P_RESOURCE_NAME,
0197:                    IMarkerConstants.P_CONTAINER_NAME,
0198:                    IMarkerConstants.P_LINE_AND_LOCATION };
0199:
0200:            // Persistance tags.
0201:            private static final String TAG_COLUMN = "column"; //$NON-NLS-1$
0202:
0203:            private static final String TAG_NUMBER = "number"; //$NON-NLS-1$
0204:
0205:            private static final String TAG_WIDTH = "width"; //$NON-NLS-1$
0206:
0207:            private static final String TAG_FILTER = "filter"; //$NON-NLS-1$
0208:
0209:            private static final String TAG_SELECTION = "selection"; //$NON-NLS-1$
0210:
0211:            private static final String TAG_ID = "id"; //$NON-NLS-1$
0212:
0213:            private static final String TAG_MARKER = "marker"; //$NON-NLS-1$
0214:
0215:            private static final String TAG_RESOURCE = "resource"; //$NON-NLS-1$
0216:
0217:            private static final String TAG_TOP_INDEX = "topIndex"; //$NON-NLS-1$
0218:
0219:            private static final String TAG_SORT_SECTION = "TaskListSortState"; //$NON-NLS-1$
0220:
0221:            static class TaskListLabelProvider extends LabelProvider implements 
0222:                    ITableLabelProvider {
0223:
0224:                private static String[] keys = {
0225:                        IBasicPropertyConstants.P_IMAGE,
0226:                        IMarkerConstants.P_COMPLETE_IMAGE,
0227:                        IMarkerConstants.P_PRIORITY_IMAGE, IMarker.MESSAGE,
0228:                        IMarkerConstants.P_RESOURCE_NAME,
0229:                        IMarkerConstants.P_CONTAINER_NAME,
0230:                        IMarkerConstants.P_LINE_AND_LOCATION };
0231:
0232:                public String getColumnText(Object element, int columnIndex) {
0233:                    if (columnIndex >= 3 && columnIndex <= 6) {
0234:                        return (String) MarkerUtil.getProperty(element,
0235:                                keys[columnIndex]);
0236:                    }
0237:                    return ""; //$NON-NLS-1$
0238:                }
0239:
0240:                public Image getColumnImage(Object element, int columnIndex) {
0241:                    if (columnIndex >= 0 && columnIndex <= 2) {
0242:                        return (Image) MarkerUtil.getProperty(element,
0243:                                keys[columnIndex]);
0244:                    }
0245:                    return null;
0246:                }
0247:            }
0248:
0249:            class SortByAction extends Action {
0250:
0251:                private int column;
0252:
0253:                /**
0254:                 * @param column
0255:                 */
0256:                public SortByAction(int column) {
0257:                    this .column = column;
0258:                }
0259:
0260:                public void run() {
0261:                    comparator.setTopPriority(column);
0262:                    updateSortingState();
0263:                    viewer.refresh();
0264:                    IDialogSettings workbenchSettings = getPlugin()
0265:                            .getDialogSettings();
0266:                    IDialogSettings settings = workbenchSettings
0267:                            .getSection(TAG_SORT_SECTION);
0268:                    if (settings == null) {
0269:                        settings = workbenchSettings
0270:                                .addNewSection(TAG_SORT_SECTION);
0271:                    }
0272:                    comparator.saveState(settings);
0273:                }
0274:            }
0275:
0276:            class SortDirectionAction extends Action {
0277:
0278:                private int direction;
0279:
0280:                /**
0281:                 * @param direction
0282:                 */
0283:                public SortDirectionAction(int direction) {
0284:                    this .direction = direction;
0285:                }
0286:
0287:                public void run() {
0288:                    comparator.setTopPriorityDirection(direction);
0289:                    updateSortingState();
0290:                    viewer.refresh();
0291:                    IDialogSettings workbenchSettings = getPlugin()
0292:                            .getDialogSettings();
0293:                    IDialogSettings settings = workbenchSettings
0294:                            .getSection(TAG_SORT_SECTION);
0295:                    if (settings == null) {
0296:                        settings = workbenchSettings
0297:                                .addNewSection(TAG_SORT_SECTION);
0298:                    }
0299:                    comparator.saveState(settings);
0300:                }
0301:            }
0302:
0303:            private String columnHeaders[] = {
0304:                    TaskListMessages.TaskList_headerIcon,
0305:                    TaskListMessages.TaskList_headerCompleted,
0306:                    TaskListMessages.TaskList_headerPriority,
0307:                    TaskListMessages.TaskList_headerDescription,
0308:                    TaskListMessages.TaskList_headerResource,
0309:                    TaskListMessages.TaskList_headerFolder,
0310:                    TaskListMessages.TaskList_headerLocation };
0311:
0312:            private ColumnLayoutData columnLayouts[] = {
0313:                    new ColumnPixelData(16, false, true),
0314:                    new ColumnPixelData(16, false, true),
0315:                    new ColumnPixelData(16, false, true),
0316:                    new ColumnWeightData(200), new ColumnWeightData(75),
0317:                    new ColumnWeightData(150), new ColumnWeightData(60) };
0318:
0319:            private IPartListener partListener = new IPartListener() {
0320:                public void partActivated(IWorkbenchPart part) {
0321:                    TaskList.this .partActivated(part);
0322:                }
0323:
0324:                public void partBroughtToTop(IWorkbenchPart part) {
0325:                }
0326:
0327:                public void partClosed(IWorkbenchPart part) {
0328:                    TaskList.this .partClosed(part);
0329:                }
0330:
0331:                public void partDeactivated(IWorkbenchPart part) {
0332:                }
0333:
0334:                public void partOpened(IWorkbenchPart part) {
0335:                }
0336:            };
0337:
0338:            private ISelectionChangedListener focusSelectionChangedListener = new ISelectionChangedListener() {
0339:                public void selectionChanged(SelectionChangedEvent event) {
0340:                    TaskList.this .focusSelectionChanged(event);
0341:                }
0342:            };
0343:
0344:            private IResource[] focusResources;
0345:
0346:            private IWorkbenchPart focusPart;
0347:
0348:            private ISelectionProvider focusSelectionProvider;
0349:
0350:            private ICellModifier cellModifier = new ICellModifier() {
0351:                public Object getValue(Object element, String property) {
0352:                    return MarkerUtil.getProperty(element, property);
0353:                }
0354:
0355:                public boolean canModify(Object element, String property) {
0356:                    return MarkerUtil.isEditable((IMarker) element);
0357:                }
0358:
0359:                /**
0360:                 * Modifies a marker as a result of a successfully completed direct editing.
0361:                 */
0362:                public void modify(Object element, String property, Object value) {
0363:                    Item item = (Item) element;
0364:                    IMarker marker = (IMarker) item.getData();
0365:                    setProperty(marker, property, value);
0366:                }
0367:            };
0368:
0369:            /**
0370:             * Creates a new task list view.
0371:             */
0372:            public TaskList() {
0373:                super ();
0374:            }
0375:
0376:            /**
0377:             * @param control
0378:             */
0379:            void addDragSupport(Control control) {
0380:
0381:                int operations = DND.DROP_COPY;
0382:                Transfer[] transferTypes = new Transfer[] {
0383:                        MarkerTransfer.getInstance(),
0384:                        TextTransfer.getInstance() };
0385:                DragSourceListener listener = new DragSourceAdapter() {
0386:                    public void dragSetData(DragSourceEvent event) {
0387:                        performDragSetData(event);
0388:                    }
0389:
0390:                    public void dragFinished(DragSourceEvent event) {
0391:                    }
0392:                };
0393:                viewer.addDragSupport(operations, transferTypes, listener);
0394:            }
0395:
0396:            void cancelEditing() {
0397:                getTableViewer().cancelEditing();
0398:            }
0399:
0400:            void createColumns() {
0401:                /**
0402:                 * This class handles selections of the column headers.
0403:                 * Selection of the column header will cause resorting
0404:                 * of the shown tasks using that column's sorter.
0405:                 * Repeated selection of the header will toggle
0406:                 * sorting order (ascending versus descending).
0407:                 */
0408:                SelectionListener headerListener = new SelectionAdapter() {
0409:                    /**
0410:                     * Handles the case of user selecting the
0411:                     * header area.
0412:                     * <p>If the column has not been selected previously,
0413:                     * it will set the sorter of that column to be
0414:                     * the current tasklist sorter. Repeated
0415:                     * presses on the same column header will
0416:                     * toggle sorting order (ascending/descending).
0417:                     */
0418:                    public void widgetSelected(SelectionEvent e) {
0419:                        // column selected - need to sort
0420:                        int column = table.indexOf((TableColumn) e.widget);
0421:                        if (column == comparator.getTopPriority()) {
0422:                            comparator.reverseTopPriority();
0423:                        } else {
0424:                            comparator.setTopPriority(column);
0425:                        }
0426:                        updateSortingState();
0427:                        viewer.refresh();
0428:                        IDialogSettings workbenchSettings = getPlugin()
0429:                                .getDialogSettings();
0430:                        IDialogSettings settings = workbenchSettings
0431:                                .getSection(TAG_SORT_SECTION);
0432:                        if (settings == null) {
0433:                            settings = workbenchSettings
0434:                                    .addNewSection(TAG_SORT_SECTION);
0435:                        }
0436:                        comparator.saveState(settings);
0437:                    }
0438:                };
0439:
0440:                if (memento != null) {
0441:                    //restore columns width
0442:                    IMemento children[] = memento.getChildren(TAG_COLUMN);
0443:                    if (children != null) {
0444:                        for (int i = 0; i < children.length; i++) {
0445:                            Integer val = children[i].getInteger(TAG_NUMBER);
0446:                            if (val != null) {
0447:                                int index = val.intValue();
0448:                                val = children[i].getInteger(TAG_WIDTH);
0449:                                if (val != null) {
0450:                                    columnLayouts[index] = new ColumnPixelData(
0451:                                            val.intValue(), true);
0452:                                }
0453:                            }
0454:                        }
0455:                    }
0456:                }
0457:
0458:                boolean text = "carbon".equals(SWT.getPlatform()); //$NON-NLS-1$
0459:                TableLayout layout = new TableLayout();
0460:                table.setLayout(layout);
0461:                table.setHeaderVisible(true);
0462:
0463:                for (int i = 0; i < columnHeaders.length; i++) {
0464:                    TableColumn tc = new TableColumn(table, SWT.NONE, i);
0465:
0466:                    if (!text && i == 1) {
0467:                        tc.setImage(MarkerUtil.getImage("header_complete")); //$NON-NLS-1$
0468:                    } else if (!text && i == 2) {
0469:                        tc.setImage(MarkerUtil.getImage("header_priority")); //$NON-NLS-1$
0470:                    } else {
0471:                        tc.setText(columnHeaders[i]);
0472:                    }
0473:
0474:                    if (text && (i == 1 || i == 2)) {
0475:                        tc.pack();
0476:                        columnLayouts[i] = new ColumnPixelData(Math.max(16, tc
0477:                                .getWidth()), false, true);
0478:                    }
0479:
0480:                    tc.setResizable(columnLayouts[i].resizable);
0481:                    layout.addColumnData(columnLayouts[i]);
0482:                    tc.addSelectionListener(headerListener);
0483:                }
0484:            }
0485:
0486:            /**
0487:             * Returns a string that summarizes the contents of the
0488:             * given markers.
0489:             */
0490:            static String createMarkerReport(IMarker[] markers) {
0491:                StringBuffer buf = new StringBuffer();
0492:                // Create the header
0493:                buf.append(TaskListMessages.TaskList_reportKind);
0494:                buf.append("\t"); //$NON-NLS-1$
0495:                buf.append(TaskListMessages.TaskList_reportStatus);
0496:                buf.append("\t"); //$NON-NLS-1$
0497:                buf.append(TaskListMessages.TaskList_reportPriority);
0498:                buf.append("\t"); //$NON-NLS-1$
0499:                buf.append(TaskListMessages.TaskList_headerDescription);
0500:                buf.append("\t"); //$NON-NLS-1$
0501:                buf.append(TaskListMessages.TaskList_headerResource);
0502:                buf.append("\t"); //$NON-NLS-1$
0503:                buf.append(TaskListMessages.TaskList_headerFolder);
0504:                buf.append("\t"); //$NON-NLS-1$
0505:                buf.append(TaskListMessages.TaskList_headerLocation);
0506:                buf.append(System.getProperty("line.separator")); //$NON-NLS-1$
0507:
0508:                // Create the report for the markers
0509:                for (int i = 0; i < markers.length; i++) {
0510:                    writeMarker(buf, markers[i]);
0511:                }
0512:                return buf.toString();
0513:            }
0514:
0515:            /**
0516:             * Writes a string representation of the given marker to the buffer.
0517:             */
0518:            static void writeMarker(StringBuffer buf, IMarker marker) {
0519:                buf.append(MarkerUtil.getKindText(marker));
0520:                buf.append("\t"); //$NON-NLS-1$
0521:                buf.append(MarkerUtil.getCompleteText(marker));
0522:                buf.append("\t"); //$NON-NLS-1$
0523:                buf.append(MarkerUtil.getPriorityText(marker));
0524:                buf.append("\t"); //$NON-NLS-1$
0525:                buf.append(MarkerUtil.getMessage(marker));
0526:                buf.append("\t"); //$NON-NLS-1$
0527:                buf.append(MarkerUtil.getResourceName(marker));
0528:                buf.append("\t"); //$NON-NLS-1$
0529:                buf.append(MarkerUtil.getContainerName(marker));
0530:                buf.append("\t"); //$NON-NLS-1$
0531:                buf.append(MarkerUtil.getLineAndLocation(marker));
0532:                buf.append(System.getProperty("line.separator")); //$NON-NLS-1$
0533:            }
0534:
0535:            /* package */
0536:            boolean isMarkerLimitExceeded() {
0537:                return markerLimitExceeded;
0538:            }
0539:
0540:            /* package */
0541:            void setMarkerLimitExceeded(boolean markerLimitExceeded) {
0542:                this .markerLimitExceeded = markerLimitExceeded;
0543:
0544:                if (markerLimitExceeded) {
0545:                    stackLayout.topControl = compositeMarkerLimitExceeded;
0546:                } else {
0547:                    stackLayout.topControl = table;
0548:                }
0549:
0550:                parent.layout();
0551:            }
0552:
0553:            /* (non-Javadoc)
0554:             * Method declared on IWorkbenchPart.
0555:             */
0556:            public void createPartControl(Composite parent) {
0557:                //	long t = System.currentTimeMillis();
0558:                createPartControl0(parent);
0559:                //	t = System.currentTimeMillis() - t;
0560:                //	System.out.println("TaskList.createPartControl: " + t + "ms");
0561:            }
0562:
0563:            private void createPartControl0(Composite parent) {
0564:                this .parent = parent;
0565:                clipboard = new Clipboard(parent.getDisplay());
0566:                createTable(parent);
0567:                viewer = new TableViewer(table);
0568:                viewer.setUseHashlookup(true);
0569:                createColumns();
0570:                makeActions();
0571:                fillActionBars();
0572:                addDragSupport(table);
0573:
0574:                compositeMarkerLimitExceeded = new Composite(parent, SWT.NONE);
0575:                compositeMarkerLimitExceeded.setLayout(new GridLayout());
0576:                Label labelMarkerLimitExceeded = new Label(
0577:                        compositeMarkerLimitExceeded, SWT.WRAP);
0578:                labelMarkerLimitExceeded
0579:                        .setText(TaskListMessages.TaskList_markerLimitExceeded);
0580:                parent.setLayout(stackLayout);
0581:                setMarkerLimitExceeded(false);
0582:
0583:                viewer.setContentProvider(new TaskListContentProvider(this ));
0584:                viewer.setLabelProvider(new TaskListLabelProvider());
0585:                if (memento != null) {
0586:                    //restore filter
0587:                    IMemento filterMem = memento.getChild(TAG_FILTER);
0588:                    if (filterMem != null) {
0589:                        getFilter().restoreState(filterMem);
0590:                    }
0591:                }
0592:
0593:                comparator = new TaskSorter();
0594:                IDialogSettings workbenchSettings = getPlugin()
0595:                        .getDialogSettings();
0596:                IDialogSettings settings = workbenchSettings
0597:                        .getSection(TAG_SORT_SECTION);
0598:                comparator.restoreState(settings);
0599:                viewer.setComparator(comparator);
0600:
0601:                //update the menu to indicate how task are currently sorted
0602:                updateSortingState();
0603:                viewer.setInput(getWorkspace().getRoot());
0604:                viewer
0605:                        .addSelectionChangedListener(new ISelectionChangedListener() {
0606:                            public void selectionChanged(
0607:                                    SelectionChangedEvent event) {
0608:                                TaskList.this .selectionChanged(event);
0609:                            }
0610:                        });
0611:                viewer.addOpenListener(new IOpenListener() {
0612:                    public void open(OpenEvent event) {
0613:                        gotoTaskAction.run();
0614:                    }
0615:                });
0616:                viewer.getControl().addKeyListener(new KeyAdapter() {
0617:                    public void keyPressed(KeyEvent e) {
0618:                        handleKeyPressed(e);
0619:                    }
0620:                });
0621:
0622:                //Add in some accessibility support to supplement the description that we already 
0623:                //get from the SWT table.
0624:                viewer.getControl().getAccessible()
0625:                        .addAccessibleControlListener(
0626:                                new AccessibleControlAdapter() {
0627:
0628:                                    /* (non-Javadoc)
0629:                                     * @see org.eclipse.swt.accessibility.AccessibleControlListener#getValue(org.eclipse.swt.accessibility.AccessibleControlEvent)
0630:                                     */
0631:                                    public void getValue(
0632:                                            AccessibleControlEvent e) {
0633:
0634:                                        int childIndex = e.childID;
0635:
0636:                                        if (childIndex == ACC.CHILDID_SELF) {
0637:                                            super .getValue(e);
0638:                                            return;
0639:                                        }
0640:                                        Object item = viewer
0641:                                                .getElementAt(childIndex);
0642:                                        if (item instanceof  IMarker) {
0643:                                            IMarker marker = (IMarker) item;
0644:
0645:                                            //If it is editable all we need is completeness
0646:                                            // the rest is found by the table accessibility
0647:                                            if (MarkerUtil.isEditable(marker)) {
0648:                                                e.result = MarkerUtil
0649:                                                        .getCompleteText(marker);
0650:                                            } else {
0651:                                                //Otherwise all it needs is severity
0652:                                                e.result = MarkerUtil
0653:                                                        .getKindText(marker);
0654:                                            }
0655:
0656:                                        } else {
0657:                                            super .getValue(e);
0658:                                            return;
0659:                                        }
0660:
0661:                                    }
0662:
0663:                                });
0664:
0665:                CellEditor editors[] = new CellEditor[columnHeaders.length];
0666:                editors[1] = new CheckboxCellEditor(table);
0667:                String[] priorities = new String[] {
0668:                        TaskListMessages.TaskList_high,
0669:                        TaskListMessages.TaskList_normal,
0670:                        TaskListMessages.TaskList_low };
0671:                editors[2] = new ComboBoxCellEditor(table, priorities,
0672:                        SWT.READ_ONLY);
0673:                editors[3] = descriptionEditor = new TextCellEditor(table);
0674:                viewer.setCellEditors(editors);
0675:                viewer.setCellModifier(cellModifier);
0676:                viewer.setColumnProperties(tableColumnProperties);
0677:
0678:                // Configure the context menu to be lazily populated on each pop-up.
0679:                MenuManager menuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$
0680:                menuMgr.setRemoveAllWhenShown(true);
0681:                menuMgr.addMenuListener(new IMenuListener() {
0682:                    public void menuAboutToShow(IMenuManager manager) {
0683:                        TaskList.this .fillContextMenu(manager);
0684:                    }
0685:                });
0686:                Menu menu = menuMgr.createContextMenu(table);
0687:                table.setMenu(menu);
0688:                // Be sure to register it so that other plug-ins can add actions.
0689:                getSite().registerContextMenu(menuMgr, viewer);
0690:
0691:                // Track selection in the page.
0692:                getSite().getPage().addPartListener(partListener);
0693:
0694:                // Add global action handlers.
0695:                editorActionHandler = new CellEditorActionHandler(getViewSite()
0696:                        .getActionBars());
0697:                editorActionHandler.addCellEditor(descriptionEditor);
0698:                editorActionHandler.setCopyAction(copyTaskAction);
0699:                editorActionHandler.setPasteAction(pasteTaskAction);
0700:                editorActionHandler.setDeleteAction(removeTaskAction);
0701:                editorActionHandler.setSelectAllAction(selectAllAction);
0702:
0703:                getViewSite().getActionBars().setGlobalActionHandler(
0704:                        ActionFactory.PROPERTIES.getId(), propertiesAction);
0705:
0706:                getSite().setSelectionProvider(viewer);
0707:
0708:                if (memento != null) {
0709:                    restoreState(memento);
0710:                }
0711:                memento = null;
0712:
0713:                // Set help on the view itself
0714:                viewer.getControl().addHelpListener(new HelpListener() {
0715:                    /*
0716:                     * @see HelpListener#helpRequested(HelpEvent)
0717:                     */
0718:                    public void helpRequested(HelpEvent e) {
0719:                        String contextId = null;
0720:                        // See if there is a context registered for the current selection
0721:                        IMarker marker = (IMarker) ((IStructuredSelection) getSelection())
0722:                                .getFirstElement();
0723:                        if (marker != null) {
0724:                            contextId = IDE.getMarkerHelpRegistry().getHelp(
0725:                                    marker);
0726:                        }
0727:
0728:                        if (contextId == null) {
0729:                            contextId = ITaskListHelpContextIds.TASK_LIST_VIEW;
0730:                        }
0731:
0732:                        getSite().getWorkbenchWindow().getWorkbench()
0733:                                .getHelpSystem().displayHelp(contextId);
0734:                    }
0735:                });
0736:
0737:                // Prime the status line and title.
0738:                updateStatusMessage();
0739:                updateTitle();
0740:            }
0741:
0742:            /**
0743:             * Creates the table control.
0744:             */
0745:            void createTable(Composite parent) {
0746:                table = new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL
0747:                        | SWT.MULTI | SWT.FULL_SELECTION);
0748:                table.setLinesVisible(true);
0749:                //table.setLayout(new TableLayout());
0750:
0751:                new TableEditor(table);
0752:            }
0753:
0754:            /* (non-Javadoc)
0755:             * Method declared on IWorkbenchPart.
0756:             */
0757:            public void dispose() {
0758:                super .dispose();
0759:                getSite().getPage().removePartListener(partListener);
0760:                if (focusSelectionProvider != null) {
0761:                    focusSelectionProvider
0762:                            .removeSelectionChangedListener(focusSelectionChangedListener);
0763:                    focusSelectionProvider = null;
0764:                }
0765:                focusPart = null;
0766:                if (editorActionHandler != null) {
0767:                    editorActionHandler.dispose();
0768:                    editorActionHandler = null;
0769:                }
0770:                if (clipboard != null) {
0771:                    clipboard.dispose();
0772:                }
0773:            }
0774:
0775:            /**
0776:             * Activates the editor on the given marker.
0777:             * 
0778:             * @param marker the marker to edit
0779:             */
0780:            public void edit(IMarker marker) {
0781:                viewer.editElement(marker, 3);
0782:            }
0783:
0784:            /**
0785:             * Fills the local tool bar and menu manager with actions.
0786:             */
0787:            void fillActionBars() {
0788:                IActionBars actionBars = getViewSite().getActionBars();
0789:                IMenuManager menu = actionBars.getMenuManager();
0790:                IMenuManager submenu = new MenuManager(
0791:                        TaskListMessages.SortByMenu_text);
0792:
0793:                menu.add(submenu);
0794:                submenu.add(sortByCategoryAction);
0795:                submenu.add(sortByCompletedAction);
0796:                submenu.add(sortByPriorityAction);
0797:                submenu.add(sortByDescriptionAction);
0798:                submenu.add(sortByResourceAction);
0799:                submenu.add(sortByContainerAction);
0800:                submenu.add(sortByLocationAction);
0801:                submenu.add(sortByCreationTimeAction);
0802:                submenu.add(new Separator());
0803:                submenu.add(sortAscendingAction);
0804:                submenu.add(sortDescendingAction);
0805:
0806:                menu.add(filtersAction);
0807:
0808:                IToolBarManager toolBar = actionBars.getToolBarManager();
0809:                toolBar.add(newTaskAction);
0810:                toolBar.add(removeTaskAction);
0811:                toolBar.add(filtersAction);
0812:            }
0813:
0814:            /**
0815:             * Contributes actions to the pop-up menu.
0816:             */
0817:            void fillContextMenu(IMenuManager menu) {
0818:                // update enabled state for actions that aren't updated in selectionChanged
0819:                IStructuredSelection selection = (IStructuredSelection) getSelection();
0820:                markCompletedAction.setEnabled(markCompletedAction
0821:                        .shouldEnable(selection));
0822:                resolveMarkerAction.setEnabled(resolveMarkerAction
0823:                        .shouldEnable(selection));
0824:
0825:                // add the actions to the menu
0826:                menu.add(newTaskAction);
0827:                menu.add(gotoTaskAction);
0828:                menu.add(new Separator());
0829:                menu.add(copyTaskAction);
0830:                menu.add(pasteTaskAction);
0831:                menu.add(removeTaskAction);
0832:                menu.add(new Separator());
0833:                menu.add(markCompletedAction);
0834:                menu.add(purgeCompletedAction);
0835:                menu.add(new Separator());
0836:                menu.add(resolveMarkerAction);
0837:                menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
0838:                menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS
0839:                        + "-end")); //$NON-NLS-1$
0840:                menu.add(propertiesAction);
0841:            }
0842:
0843:            /**
0844:             * The filter settings have changed.
0845:             * Refreshes the viewer and title bar.
0846:             */
0847:            void filterChanged() {
0848:
0849:                BusyIndicator.showWhile(viewer.getControl().getShell()
0850:                        .getDisplay(), new Runnable() {
0851:                    public void run() {
0852:                        // Filter has already been updated by dialog; just refresh.
0853:                        // Don't need to update labels for existing elements 
0854:                        // since changes to filter settings don't affect them.
0855:                        viewer.getControl().setRedraw(false);
0856:                        viewer.refresh(false);
0857:                        viewer.getControl().setRedraw(true);
0858:                        // update after refresh since the content provider caches summary info
0859:                        updateStatusMessage();
0860:                        updateTitle();
0861:                    }
0862:                });
0863:
0864:            }
0865:
0866:            void focusSelectionChanged(SelectionChangedEvent event) {
0867:                updateFocusResource(event.getSelection());
0868:            }
0869:
0870:            /* (non-Javadoc)
0871:             * @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
0872:             */
0873:            public Object getAdapter(Class adapter) {
0874:                if (adapter == IShowInSource.class) {
0875:                    return new IShowInSource() {
0876:                        public ShowInContext getShowInContext() {
0877:                            return new ShowInContext(null, getSelection());
0878:                        }
0879:                    };
0880:                }
0881:                if (adapter == IShowInTargetList.class) {
0882:                    return new IShowInTargetList() {
0883:                        public String[] getShowInTargetIds() {
0884:                            return new String[] { IPageLayout.ID_RES_NAV };
0885:                        }
0886:
0887:                    };
0888:                }
0889:                return super .getAdapter(adapter);
0890:            }
0891:
0892:            /**
0893:             * Returns a clipboard for cut/copy/paste actions.
0894:             * <p>
0895:             * May only be called after this part's viewer has been created.
0896:             * The clipboard is disposed when this part is disposed.
0897:             * </p>
0898:             * @return a clipboard
0899:             * @since 2.0
0900:             */
0901:            /*package*/
0902:            Clipboard getClipboard() {
0903:                return clipboard;
0904:            }
0905:
0906:            /**
0907:             * Returns the filter for the viewer.
0908:             */
0909:            TasksFilter getFilter() {
0910:                return filter;
0911:            }
0912:
0913:            /**
0914:             * Returns the UI plugin for the task list.
0915:             */
0916:            static AbstractUIPlugin getPlugin() {
0917:                return (AbstractUIPlugin) Platform
0918:                        .getPlugin(PlatformUI.PLUGIN_ID);
0919:            }
0920:
0921:            /**
0922:             * Returns the resource for which the task list is showing tasks.
0923:             *
0924:             * @return the resource, possibly the workspace root
0925:             */
0926:            public IResource getResource() {
0927:                if (showSelections()) {
0928:                    if (focusResources != null && focusResources.length >= 1
0929:                            && focusResources[0] != null) {
0930:                        return focusResources[0];
0931:                    }
0932:                }
0933:
0934:                return getWorkspace().getRoot();
0935:            }
0936:
0937:            /**
0938:             * Get the resources.
0939:             * 
0940:             * @return the resources
0941:             */
0942:            public IResource[] getResources() {
0943:                if (showSelections()) {
0944:                    if (focusResources != null) {
0945:                        return focusResources;
0946:                    }
0947:                }
0948:
0949:                return new IResource[] { getWorkspace().getRoot() };
0950:            }
0951:
0952:            /**
0953:             * Returns the resource depth which the task list is using to show tasks.
0954:             *
0955:             * @return an <code>IResource.DEPTH_*</code> constant
0956:             */
0957:            int getResourceDepth() {
0958:                if (showSelections() && !showChildrenHierarchy()) {
0959:                    return IResource.DEPTH_ZERO;
0960:                }
0961:
0962:                return IResource.DEPTH_INFINITE;
0963:            }
0964:
0965:            /**
0966:             * API method which returns the current selection.
0967:             *
0968:             * @return the current selection (element type: <code>IMarker</code>)
0969:             */
0970:            public ISelection getSelection() {
0971:                return viewer.getSelection();
0972:            }
0973:
0974:            /**
0975:             * Returns the message to display in the status line.
0976:             */
0977:            String getStatusMessage(IStructuredSelection selection) {
0978:                if (selection != null && selection.size() == 1) {
0979:                    IMarker marker = (IMarker) selection.getFirstElement();
0980:                    return MarkerUtil.getMessage(marker);
0981:                }
0982:
0983:                TaskListContentProvider provider = (TaskListContentProvider) viewer
0984:                        .getContentProvider();
0985:
0986:                if (selection != null && selection.size() > 1) {
0987:                    return provider.getStatusSummarySelected(selection);
0988:                }
0989:                return provider.getStatusSummaryVisible();
0990:            }
0991:
0992:            /**
0993:             * When created, new task instance is cached in
0994:             * order to keep it at the top of the list until
0995:             * first edited. This method returns it, or
0996:             * null if there is no task instance pending
0997:             * for first editing.
0998:             */
0999:            TableViewer getTableViewer() {
1000:                return viewer;
1001:            }
1002:
1003:            /**
1004:             * Returns the workspace.
1005:             */
1006:            IWorkspace getWorkspace() {
1007:                return ResourcesPlugin.getWorkspace();
1008:            }
1009:
1010:            /**
1011:             * Handles key events in viewer.
1012:             */
1013:            void handleKeyPressed(KeyEvent event) {
1014:                if (event.character == SWT.DEL && event.stateMask == 0
1015:                        && removeTaskAction.isEnabled()) {
1016:                    removeTaskAction.run();
1017:                }
1018:            }
1019:
1020:            /* (non-Javadoc)
1021:             * Method declared on IViewPart.
1022:             */
1023:            public void init(IViewSite site, IMemento memento)
1024:                    throws PartInitException {
1025:                super .init(site, memento);
1026:                this .memento = memento;
1027:            }
1028:
1029:            /**
1030:             * Returns whether we are interested in markers on the given resource.
1031:             */
1032:            boolean checkResource(IResource resource) {
1033:                if (!showSelections()) {
1034:                    return true;
1035:                }
1036:
1037:                IResource[] resources = getResources();
1038:                IResource resource2;
1039:
1040:                if (showOwnerProject()) {
1041:                    IProject project;
1042:
1043:                    for (int i = 0, l = resources.length; i < l; i++) {
1044:                        resource2 = resources[i];
1045:
1046:                        if (resource2 == null) {
1047:                            return true;
1048:                        }
1049:                        project = resource2.getProject();
1050:
1051:                        if (project == null
1052:                                || project.equals(resource.getProject())) {
1053:                            return true;
1054:                        }
1055:                    }
1056:                }
1057:
1058:                if (showChildrenHierarchy()) {
1059:                    for (int i = 0, l = resources.length; i < l; i++) {
1060:                        resource2 = resources[i];
1061:
1062:                        if (resource2 != null
1063:                                && resource2.getFullPath().isPrefixOf(
1064:                                        resource.getFullPath())) {
1065:                            return true;
1066:                        }
1067:                    }
1068:                } else {
1069:                    for (int i = 0, l = resources.length; i < l; i++) {
1070:                        resource2 = resources[i];
1071:
1072:                        if (resource.equals(resource2)) {
1073:                            return true;
1074:                        }
1075:                    }
1076:                }
1077:
1078:                return false;
1079:            }
1080:
1081:            /**
1082:             * Returns whether the given marker should be shown,
1083:             * given the current filter settings.
1084:             */
1085:            boolean shouldShow(IMarker marker) {
1086:                return checkResource(marker.getResource())
1087:                        && getFilter().select(marker);
1088:            }
1089:
1090:            /**
1091:             * Makes actions used in the local tool bar and
1092:             * popup menu.
1093:             */
1094:            void makeActions() {
1095:                ISharedImages sharedImages = PlatformUI.getWorkbench()
1096:                        .getSharedImages();
1097:
1098:                // goto
1099:                gotoTaskAction = new GotoTaskAction(this , "gotoFile"); //$NON-NLS-1$
1100:                gotoTaskAction.setText(TaskListMessages.GotoTask_text);
1101:                gotoTaskAction
1102:                        .setToolTipText(TaskListMessages.GotoTask_tooltip);
1103:                gotoTaskAction.setImageDescriptor(MarkerUtil
1104:                        .getImageDescriptor("gotoobj")); //$NON-NLS-1$
1105:                gotoTaskAction.setEnabled(false);
1106:
1107:                // new task
1108:                newTaskAction = new NewTaskAction(this , "newTask"); //$NON-NLS-1$
1109:                newTaskAction.setText(TaskListMessages.NewTask_text);
1110:                newTaskAction.setToolTipText(TaskListMessages.NewTask_tooltip);
1111:                newTaskAction.setImageDescriptor(MarkerUtil
1112:                        .getImageDescriptor("addtsk")); //$NON-NLS-1$
1113:                newTaskAction.setDisabledImageDescriptor(MarkerUtil
1114:                        .getImageDescriptor("addtsk_disabled")); //$NON-NLS-1$
1115:
1116:                // copy task
1117:                copyTaskAction = new CopyTaskAction(this , "copy"); //$NON-NLS-1$
1118:                copyTaskAction.setText(TaskListMessages.CopyTask_text);
1119:                copyTaskAction
1120:                        .setToolTipText(TaskListMessages.CopyTask_tooltip);
1121:                copyTaskAction.setEnabled(false);
1122:
1123:                // paste task
1124:                pasteTaskAction = new PasteTaskAction(this , "paste"); //$NON-NLS-1$
1125:                pasteTaskAction.setText(TaskListMessages.PasteTask_text);
1126:                pasteTaskAction
1127:                        .setToolTipText(TaskListMessages.PasteTask_tooltip);
1128:                pasteTaskAction.setEnabled(false);
1129:
1130:                // remove task
1131:                removeTaskAction = new RemoveTaskAction(this , "delete"); //$NON-NLS-1$
1132:                removeTaskAction.setText(TaskListMessages.RemoveTask_text);
1133:                removeTaskAction
1134:                        .setToolTipText(TaskListMessages.RemoveTask_tooltip);
1135:                removeTaskAction.setImageDescriptor(sharedImages
1136:                        .getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
1137:                removeTaskAction
1138:                        .setDisabledImageDescriptor(sharedImages
1139:                                .getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED));
1140:                removeTaskAction.setEnabled(false);
1141:
1142:                //mark completed task
1143:                markCompletedAction = new MarkCompletedAction(this ,
1144:                        "markCompleted"); //$NON-NLS-1$
1145:                markCompletedAction
1146:                        .setText(TaskListMessages.MarkCompleted_text);
1147:                markCompletedAction
1148:                        .setToolTipText(TaskListMessages.MarkCompleted_tooltip);
1149:                markCompletedAction.setEnabled(false);
1150:
1151:                //delete completed task
1152:                purgeCompletedAction = new PurgeCompletedAction(this ,
1153:                        "deleteCompleted"); //$NON-NLS-1$
1154:                purgeCompletedAction
1155:                        .setText(TaskListMessages.PurgeCompleted_text);
1156:                purgeCompletedAction
1157:                        .setToolTipText(TaskListMessages.PurgeCompleted_tooltip);
1158:                purgeCompletedAction.setImageDescriptor(sharedImages
1159:                        .getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
1160:                purgeCompletedAction.setEnabled(true);
1161:
1162:                // select all
1163:                selectAllAction = new SelectAllTasksAction(this , "selectAll"); //$NON-NLS-1$
1164:                selectAllAction.setText(TaskListMessages.SelectAll_text);
1165:                selectAllAction
1166:                        .setToolTipText(TaskListMessages.SelectAll_tooltip);
1167:
1168:                // resolutions
1169:                resolveMarkerAction = new ResolveMarkerAction(this , "resolve"); //$NON-NLS-1$
1170:                resolveMarkerAction.setText(TaskListMessages.Resolve_text);
1171:                resolveMarkerAction
1172:                        .setToolTipText(TaskListMessages.Resolve_tooltip);
1173:                resolveMarkerAction.setEnabled(false);
1174:
1175:                // Sort by ->	
1176:                sortByCategoryAction = new SortByAction(TaskSorter.TYPE);
1177:                sortByCategoryAction
1178:                        .setText(TaskListMessages.SortByCategory_text);
1179:                sortByCategoryAction
1180:                        .setToolTipText(TaskListMessages.SortByCategory_tooltip);
1181:                PlatformUI.getWorkbench().getHelpSystem().setHelp(
1182:                        sortByCategoryAction,
1183:                        ITaskListHelpContextIds.TASK_SORT_TYPE_ACTION);
1184:
1185:                sortByCompletedAction = new SortByAction(TaskSorter.COMPLETION);
1186:                sortByCompletedAction
1187:                        .setText(TaskListMessages.SortByCompleted_text);
1188:                sortByCompletedAction
1189:                        .setToolTipText(TaskListMessages.SortByCompleted_tooltip);
1190:                PlatformUI.getWorkbench().getHelpSystem().setHelp(
1191:                        sortByCompletedAction,
1192:                        ITaskListHelpContextIds.TASK_SORT_COMPLETED_ACTION);
1193:
1194:                sortByPriorityAction = new SortByAction(TaskSorter.PRIORITY);
1195:                sortByPriorityAction
1196:                        .setText(TaskListMessages.SortByPriority_text);
1197:                sortByPriorityAction
1198:                        .setToolTipText(TaskListMessages.SortByPriority_tooltip);
1199:                PlatformUI.getWorkbench().getHelpSystem().setHelp(
1200:                        sortByPriorityAction,
1201:                        ITaskListHelpContextIds.TASK_SORT_PRIORITY_ACTION);
1202:
1203:                sortByDescriptionAction = new SortByAction(
1204:                        TaskSorter.DESCRIPTION);
1205:                sortByDescriptionAction
1206:                        .setText(TaskListMessages.SortByDescription_text);
1207:                sortByDescriptionAction
1208:                        .setToolTipText(TaskListMessages.SortByDescription_tooltip);
1209:                PlatformUI.getWorkbench().getHelpSystem().setHelp(
1210:                        sortByDescriptionAction,
1211:                        ITaskListHelpContextIds.TASK_SORT_DESCRIPTION_ACTION);
1212:
1213:                sortByResourceAction = new SortByAction(TaskSorter.RESOURCE);
1214:                sortByResourceAction
1215:                        .setText(TaskListMessages.SortByResource_text);
1216:                sortByResourceAction
1217:                        .setToolTipText(TaskListMessages.SortByResource_tooltip);
1218:                PlatformUI.getWorkbench().getHelpSystem().setHelp(
1219:                        sortByResourceAction,
1220:                        ITaskListHelpContextIds.TASK_SORT_RESOURCE_ACTION);
1221:
1222:                sortByContainerAction = new SortByAction(TaskSorter.FOLDER);
1223:                sortByContainerAction
1224:                        .setText(TaskListMessages.SortByContainer_text);
1225:                sortByContainerAction
1226:                        .setToolTipText(TaskListMessages.SortByContainer_tooltip);
1227:                PlatformUI.getWorkbench().getHelpSystem().setHelp(
1228:                        sortByContainerAction,
1229:                        ITaskListHelpContextIds.TASK_SORT_FOLDER_ACTION);
1230:
1231:                sortByLocationAction = new SortByAction(TaskSorter.LOCATION);
1232:                sortByLocationAction
1233:                        .setText(TaskListMessages.SortByLocation_text);
1234:                sortByLocationAction
1235:                        .setToolTipText(TaskListMessages.SortByLocation_tooltip);
1236:                PlatformUI.getWorkbench().getHelpSystem().setHelp(
1237:                        sortByLocationAction,
1238:                        ITaskListHelpContextIds.TASK_SORT_LOCATION_ACTION);
1239:
1240:                sortByCreationTimeAction = new SortByAction(
1241:                        TaskSorter.CREATION_TIME);
1242:                sortByCreationTimeAction
1243:                        .setText(TaskListMessages.SortByCreationTime_text);
1244:                sortByCreationTimeAction
1245:                        .setToolTipText(TaskListMessages.SortByCreationTime_tooltip);
1246:                PlatformUI.getWorkbench().getHelpSystem().setHelp(
1247:                        sortByCreationTimeAction,
1248:                        ITaskListHelpContextIds.TASK_SORT_CREATION_TIME_ACTION);
1249:
1250:                sortAscendingAction = new SortDirectionAction(
1251:                        TaskSorter.ASCENDING);
1252:                sortAscendingAction
1253:                        .setText(TaskListMessages.SortAscending_text);
1254:                sortAscendingAction
1255:                        .setToolTipText(TaskListMessages.SortAscending_tooltip);
1256:                PlatformUI.getWorkbench().getHelpSystem().setHelp(
1257:                        sortAscendingAction,
1258:                        ITaskListHelpContextIds.TASK_SORT_ASCENDING_ACTION);
1259:
1260:                sortDescendingAction = new SortDirectionAction(
1261:                        TaskSorter.DESCENDING);
1262:                sortDescendingAction
1263:                        .setText(TaskListMessages.SortDescending_text);
1264:                sortDescendingAction
1265:                        .setToolTipText(TaskListMessages.SortDescending_tooltip);
1266:                PlatformUI.getWorkbench().getHelpSystem().setHelp(
1267:                        sortDescendingAction,
1268:                        ITaskListHelpContextIds.TASK_SORT_DESCENDING_ACTION);
1269:
1270:                // filters...
1271:                filtersAction = new FiltersAction(this , "filter"); //$NON-NLS-1$
1272:                filtersAction.setText(TaskListMessages.Filters_text);
1273:                filtersAction.setToolTipText(TaskListMessages.Filters_tooltip);
1274:                filtersAction.setImageDescriptor(MarkerUtil
1275:                        .getImageDescriptor("filter")); //$NON-NLS-1$
1276:
1277:                // properties
1278:                propertiesAction = new TaskPropertiesAction(this , "properties"); //$NON-NLS-1$
1279:                propertiesAction.setText(TaskListMessages.Properties_text);
1280:                propertiesAction
1281:                        .setToolTipText(TaskListMessages.Properties_tooltip);
1282:                propertiesAction.setEnabled(false);
1283:            }
1284:
1285:            /**
1286:             * The markers have changed.  Update the status line and title bar.
1287:             */
1288:            void markersChanged() {
1289:                updateStatusMessage();
1290:                updateTitle();
1291:            }
1292:
1293:            void partActivated(IWorkbenchPart part) {
1294:                if (part == focusPart) {
1295:                    return;
1296:                }
1297:
1298:                if (focusSelectionProvider != null) {
1299:                    focusSelectionProvider
1300:                            .removeSelectionChangedListener(focusSelectionChangedListener);
1301:                    focusSelectionProvider = null;
1302:                }
1303:
1304:                focusPart = part;
1305:                if (focusPart != null) {
1306:                    focusSelectionProvider = focusPart.getSite()
1307:                            .getSelectionProvider();
1308:                    if (focusSelectionProvider != null) {
1309:                        focusSelectionProvider
1310:                                .addSelectionChangedListener(focusSelectionChangedListener);
1311:                        updateFocusResource(focusSelectionProvider
1312:                                .getSelection());
1313:                    } else {
1314:                        updateFocusResource(null);
1315:                    }
1316:                }
1317:
1318:            }
1319:
1320:            void partClosed(IWorkbenchPart part) {
1321:                if (part != focusPart) {
1322:                    return;
1323:                }
1324:                if (focusSelectionProvider != null) {
1325:                    focusSelectionProvider
1326:                            .removeSelectionChangedListener(focusSelectionChangedListener);
1327:                    focusSelectionProvider = null;
1328:                }
1329:                focusPart = null;
1330:            }
1331:
1332:            /**
1333:             * The user is attempting to drag marker data.  Add the appropriate
1334:             * data to the event depending on the transfer type.
1335:             */
1336:            void performDragSetData(DragSourceEvent event) {
1337:                if (MarkerTransfer.getInstance()
1338:                        .isSupportedType(event.dataType)) {
1339:                    event.data = ((IStructuredSelection) viewer.getSelection())
1340:                            .toArray();
1341:                    return;
1342:                }
1343:                if (TextTransfer.getInstance().isSupportedType(event.dataType)) {
1344:                    Object[] data = ((IStructuredSelection) viewer
1345:                            .getSelection()).toArray();
1346:                    if (data != null) {
1347:                        IMarker[] markers = new IMarker[data.length];
1348:                        for (int i = 0; i < markers.length; i++) {
1349:                            markers[i] = (IMarker) data[i];
1350:                        }
1351:                        event.data = createMarkerReport(markers);
1352:                    }
1353:                    return;
1354:                }
1355:            }
1356:
1357:            void restoreState(IMemento memento) {
1358:                //restore selection
1359:                IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
1360:                IMemento selectionMem = memento.getChild(TAG_SELECTION);
1361:                if (selectionMem != null) {
1362:                    ArrayList selectionList = new ArrayList();
1363:                    IMemento markerMems[] = selectionMem
1364:                            .getChildren(TAG_MARKER);
1365:                    for (int i = 0; i < markerMems.length; i++) {
1366:                        try {
1367:                            long id = Long.parseLong(markerMems[i]
1368:                                    .getString(TAG_ID));
1369:                            IResource resource = root.findMember(markerMems[i]
1370:                                    .getString(TAG_RESOURCE));
1371:                            if (resource != null) {
1372:                                IMarker marker = resource.findMarker(id);
1373:                                if (marker != null) {
1374:                                    selectionList.add(marker);
1375:                                }
1376:                            }
1377:                        } catch (NumberFormatException e) {
1378:                        } catch (CoreException e) {
1379:                        }
1380:
1381:                    }
1382:                    viewer.setSelection(new StructuredSelection(selectionList));
1383:                }
1384:
1385:                Table table = viewer.getTable();
1386:                //restore vertical position
1387:                try {
1388:                    String topIndexStr = memento.getString(TAG_TOP_INDEX);
1389:                    table.setTopIndex(Integer.parseInt(topIndexStr));
1390:                } catch (NumberFormatException e) {
1391:                }
1392:            }
1393:
1394:            /* (non-Javadoc)
1395:             * Method declared on IViewPart.
1396:             */
1397:            public void saveState(IMemento memento) {
1398:                if (viewer == null) {
1399:                    if (this .memento != null) {
1400:                        memento.putMemento(this .memento);
1401:                    }
1402:                    return;
1403:                }
1404:
1405:                //save filter
1406:                getFilter().saveState(memento.createChild(TAG_FILTER));
1407:
1408:                //save columns width
1409:                Table table = viewer.getTable();
1410:                TableColumn columns[] = table.getColumns();
1411:                //check whether it has ever been layed out
1412:                //workaround for 1GDTU19: ITPUI:WIN2000 - Task list columns "collapsed" left
1413:                boolean shouldSave = false;
1414:                for (int i = 0; i < columns.length; i++) {
1415:                    if (columnLayouts[i].resizable
1416:                            && columns[i].getWidth() != 0) {
1417:                        shouldSave = true;
1418:                        break;
1419:                    }
1420:                }
1421:                if (shouldSave) {
1422:                    for (int i = 0; i < columns.length; i++) {
1423:                        if (columnLayouts[i].resizable) {
1424:                            IMemento child = memento.createChild(TAG_COLUMN);
1425:                            child.putInteger(TAG_NUMBER, i);
1426:                            child.putInteger(TAG_WIDTH, columns[i].getWidth());
1427:                        }
1428:                    }
1429:                }
1430:
1431:                //save selection
1432:                Object markers[] = ((IStructuredSelection) viewer
1433:                        .getSelection()).toArray();
1434:                if (markers.length > 0) {
1435:                    IMemento selectionMem = memento.createChild(TAG_SELECTION);
1436:                    for (int i = 0; i < markers.length; i++) {
1437:                        IMemento elementMem = selectionMem
1438:                                .createChild(TAG_MARKER);
1439:                        IMarker marker = (IMarker) markers[i];
1440:                        elementMem.putString(TAG_RESOURCE, marker.getResource()
1441:                                .getFullPath().toString());
1442:                        elementMem.putString(TAG_ID, String.valueOf(marker
1443:                                .getId()));
1444:                    }
1445:                }
1446:
1447:                //save vertical position
1448:                int topIndex = table.getTopIndex();
1449:                memento.putString(TAG_TOP_INDEX, String.valueOf(topIndex));
1450:            }
1451:
1452:            /**
1453:             * Handles marker selection change in the task list by updating availability of
1454:             * the actions in the local tool bar.
1455:             */
1456:            void selectionChanged(SelectionChangedEvent event) {
1457:                IStructuredSelection selection = (IStructuredSelection) event
1458:                        .getSelection();
1459:                updateStatusMessage(selection);
1460:                updateTitle();
1461:
1462:                updatePasteEnablement();
1463:
1464:                // If selection is empty, then disable copy, remove and goto.	
1465:                if (selection.isEmpty()) {
1466:                    copyTaskAction.setEnabled(false);
1467:                    removeTaskAction.setEnabled(false);
1468:                    gotoTaskAction.setEnabled(false);
1469:                    propertiesAction.setEnabled(false);
1470:                    return;
1471:                }
1472:
1473:                // Can only open properties for a single task at a time
1474:                propertiesAction.setEnabled(selection.size() == 1);
1475:
1476:                // Can always copy
1477:                copyTaskAction.setEnabled(true);
1478:
1479:                // Determine if goto should be enabled
1480:                IMarker selectedMarker = (IMarker) selection.getFirstElement();
1481:                boolean canJump = selection.size() == 1
1482:                        && selectedMarker.getResource().getType() == IResource.FILE;
1483:                gotoTaskAction.setEnabled(canJump);
1484:
1485:                // Determine if remove should be enabled
1486:                boolean canRemove = true;
1487:                for (Iterator markers = selection.iterator(); markers.hasNext();) {
1488:                    IMarker m = (IMarker) markers.next();
1489:                    if (!MarkerUtil.isEditable(m)) {
1490:                        canRemove = false;
1491:                        break;
1492:                    }
1493:                }
1494:                removeTaskAction.setEnabled(canRemove);
1495:
1496:                // if there is an active editor on the selection's input, tell
1497:                // the editor to goto the marker
1498:                if (canJump) {
1499:                    IEditorPart editor = getSite().getPage().getActiveEditor();
1500:                    if (editor != null) {
1501:                        IFile file = ResourceUtil.getFile(editor
1502:                                .getEditorInput());
1503:                        if (file != null) {
1504:                            if (selectedMarker.getResource().equals(file)) {
1505:                                IDE.gotoMarker(editor, selectedMarker);
1506:                            }
1507:                        }
1508:                    }
1509:                }
1510:            }
1511:
1512:            /* (non-Javadoc)
1513:             * Method declared on IWorkbenchPart.
1514:             */
1515:            public void setFocus() {
1516:                viewer.getControl().setFocus();
1517:            }
1518:
1519:            /**
1520:             * Sets the property on a marker to the given value.
1521:             */
1522:            void setProperty(IMarker marker, String property, Object value) {
1523:                if (MarkerUtil.getProperty(marker, property).equals(value)) {
1524:                    return;
1525:                }
1526:                try {
1527:                    if (property == tableColumnProperties[1]) { // Completed
1528:                        marker.setAttribute(IMarker.DONE, value);
1529:                    } else if (property == tableColumnProperties[2]) { // Priority
1530:                        // this property is used only by cell editor, where order is High, Normal, Low
1531:                        marker.setAttribute(IMarker.PRIORITY,
1532:                                IMarker.PRIORITY_HIGH
1533:                                        - ((Integer) value).intValue());
1534:                    } else if (property == tableColumnProperties[3]) { // Description
1535:                        marker.setAttribute(IMarker.MESSAGE, value);
1536:                        // Let's not refilter too lightly - see if it is needed
1537:                        //			TaskSorter sorter = (TaskSorter) viewer.getSorter();
1538:                        //			if (sorter != null && sorter.getColumnNumber() == 3) {
1539:                        //				viewer.refresh();
1540:                        //			}
1541:                    }
1542:                } catch (CoreException e) {
1543:                    String msg = TaskListMessages.TaskList_errorModifyingTask;
1544:                    ErrorDialog.openError(getSite().getShell(), msg, null, e
1545:                            .getStatus());
1546:                }
1547:            }
1548:
1549:            /**
1550:             * API method which sets the current selection of this viewer.
1551:             *
1552:             * @param selection a structured selection of <code>IMarker</code> objects
1553:             * @param reveal <code>true</code> to reveal the selection, <false> otherwise
1554:             */
1555:            public void setSelection(ISelection selection, boolean reveal) {
1556:                Assert.isTrue(selection instanceof  IStructuredSelection);
1557:                IStructuredSelection ssel = (IStructuredSelection) selection;
1558:
1559:                for (Iterator i = ssel.iterator(); i.hasNext();) {
1560:                    Assert.isTrue(i.next() instanceof  IMarker);
1561:                }
1562:
1563:                if (viewer != null) {
1564:                    viewer.setSelection(selection, reveal);
1565:                }
1566:            }
1567:
1568:            boolean showChildrenHierarchy() {
1569:                switch (getFilter().onResource) {
1570:                case TasksFilter.ON_ANY_RESOURCE:
1571:                case TasksFilter.ON_SELECTED_RESOURCE_AND_CHILDREN:
1572:                case TasksFilter.ON_ANY_RESOURCE_OF_SAME_PROJECT:
1573:                    // added by cagatayk@acm.org
1574:                case TasksFilter.ON_WORKING_SET:
1575:                default:
1576:                    return true;
1577:                case TasksFilter.ON_SELECTED_RESOURCE_ONLY:
1578:                    return false;
1579:                }
1580:            }
1581:
1582:            boolean showSelections() {
1583:                switch (getFilter().onResource) {
1584:                case TasksFilter.ON_SELECTED_RESOURCE_ONLY:
1585:                case TasksFilter.ON_SELECTED_RESOURCE_AND_CHILDREN:
1586:                case TasksFilter.ON_ANY_RESOURCE_OF_SAME_PROJECT:
1587:                    // added by cagatayk@acm.org
1588:                    return true;
1589:                case TasksFilter.ON_ANY_RESOURCE:
1590:                case TasksFilter.ON_WORKING_SET:
1591:                default:
1592:                    return false;
1593:                }
1594:            }
1595:
1596:            // showOwnerProject() added by cagatayk@acm.org 
1597:            boolean showOwnerProject() {
1598:                return getFilter().onResource == TasksFilter.ON_ANY_RESOURCE_OF_SAME_PROJECT;
1599:            }
1600:
1601:            /**
1602:             * Processes state change of the 'showSelections' switch.
1603:             * If true, it will resync with the saved input element.
1604:             * Otherwise, it will reconfigure to show all the
1605:             * problems/tasks in the workbench.
1606:             * 
1607:             * @param value the value
1608:             */
1609:            void toggleInputSelection(boolean value) {
1610:                /*
1611:                 if (value) {
1612:                 handleInput(inputSelection, false);
1613:                 } else {
1614:                 // detach from input and link to the workbench object
1615:                 handleInput(WorkbenchPlugin.getPluginWorkbench(), true);
1616:                 }
1617:                 updateTitle();
1618:                 */
1619:            }
1620:
1621:            /**
1622:             * If true, current input will be
1623:             * remembered and further selections will be
1624:             * ignored.
1625:             * 
1626:             * @param value the value
1627:             */
1628:            void toggleLockInput(boolean value) {
1629:                /*
1630:                 if (!value) {
1631:                 handleInput(inputSelection, false);
1632:                 lockedInput = null;
1633:                 } else {
1634:                 lockedInput = (IElement) getInput();
1635:                 }
1636:                 String lockedInputPath = "";
1637:                 if (lockedInput != null && lockedInput instanceof IResource) {
1638:                 IResource resource = (IResource) lockedInput;
1639:                 lockedInputPath = resource.getFullPath().toString();
1640:                 }
1641:                 IDialogStore store = WorkbenchPlugin.getDefault().getDialogStore();
1642:                 store.put(STORE_LOCKED_INPUT, lockedInputPath);
1643:                 updateTitle();
1644:                 */
1645:            }
1646:
1647:            /**
1648:             * Updates the focus resource, and refreshes if we're showing only tasks for the focus resource.
1649:             */
1650:            void updateFocusResource(ISelection selection) {
1651:                ArrayList list = new ArrayList();
1652:
1653:                if (selection instanceof  IStructuredSelection) {
1654:                    Iterator iterator = ((IStructuredSelection) selection)
1655:                            .iterator();
1656:                    while (iterator.hasNext()) {
1657:                        Object object = iterator.next();
1658:
1659:                        if (object instanceof  IAdaptable) {
1660:                            ITaskListResourceAdapter taskListResourceAdapter;
1661:                            Object adapter = ((IAdaptable) object)
1662:                                    .getAdapter(ITaskListResourceAdapter.class);
1663:                            if (adapter != null
1664:                                    && adapter instanceof  ITaskListResourceAdapter) {
1665:                                taskListResourceAdapter = (ITaskListResourceAdapter) adapter;
1666:                            } else {
1667:                                taskListResourceAdapter = DefaultTaskListResourceAdapter
1668:                                        .getDefault();
1669:                            }
1670:
1671:                            IResource resource = taskListResourceAdapter
1672:                                    .getAffectedResource((IAdaptable) object);
1673:                            if (resource != null) {
1674:                                list.add(resource);
1675:                            }
1676:                        }
1677:                    }
1678:                }
1679:
1680:                if (list.size() == 0 && focusPart instanceof  IEditorPart) {
1681:                    IEditorInput input = ((IEditorPart) focusPart)
1682:                            .getEditorInput();
1683:                    if (input != null) {
1684:                        IResource resource = ResourceUtil.getResource(input);
1685:                        if (resource != null) {
1686:                            list.add(resource);
1687:                        }
1688:                    }
1689:                }
1690:
1691:                int l = list.size();
1692:                if (l < 1) {
1693:                    return; // required to achieve lazy update behavior.
1694:                }
1695:
1696:                IResource[] resources = (IResource[]) list
1697:                        .toArray(new IResource[l]);
1698:                for (int i = 0; i < l; i++) {
1699:                    Assert.isNotNull(resources[i]);
1700:                }
1701:
1702:                if (!Arrays.equals(resources, focusResources)) {
1703:                    boolean updateNeeded = false;
1704:
1705:                    if (showOwnerProject()) {
1706:                        int m = focusResources == null ? 0
1707:                                : focusResources.length;
1708:                        if (l != m) {
1709:                            updateNeeded = true;
1710:                        } else {
1711:                            for (int i = 0; i < l; i++) {
1712:                                IProject oldProject = m < 1 ? null
1713:                                        : focusResources[0].getProject();
1714:                                IProject newProject = resources[0].getProject();
1715:                                boolean projectsEqual = (oldProject == null ? newProject == null
1716:                                        : oldProject.equals(newProject));
1717:                                if (!projectsEqual) {
1718:                                    updateNeeded = true;
1719:                                    break;
1720:                                }
1721:                            }
1722:                        }
1723:                    } else if (showSelections()) {
1724:                        updateNeeded = true;
1725:                    }
1726:
1727:                    // remember the focus resources even if update is not needed,
1728:                    // so that we know them if the filter settings change
1729:                    focusResources = resources;
1730:
1731:                    if (updateNeeded) {
1732:                        viewer.getControl().setRedraw(false);
1733:                        viewer.refresh();
1734:                        viewer.getControl().setRedraw(true);
1735:                        updateStatusMessage();
1736:                        updateTitle();
1737:                    }
1738:                }
1739:            }
1740:
1741:            /**
1742:             * Updates the enablement of the paste action
1743:             */
1744:            void updatePasteEnablement() {
1745:                // Paste if clipboard contains tasks
1746:                MarkerTransfer transfer = MarkerTransfer.getInstance();
1747:                IMarker[] markerData = (IMarker[]) getClipboard().getContents(
1748:                        transfer);
1749:                boolean canPaste = false;
1750:                if (markerData != null) {
1751:                    for (int i = 0; i < markerData.length; i++) {
1752:                        if (MarkerUtil
1753:                                .isMarkerType(markerData[i], IMarker.TASK)) {
1754:                            canPaste = true;
1755:                            break;
1756:                        }
1757:                    }
1758:                }
1759:                pasteTaskAction.setEnabled(canPaste);
1760:            }
1761:
1762:            /**
1763:             * Updates that message displayed in the status line.
1764:             */
1765:            void updateStatusMessage() {
1766:                ISelection selection = viewer.getSelection();
1767:
1768:                if (selection instanceof  IStructuredSelection) {
1769:                    updateStatusMessage((IStructuredSelection) selection);
1770:                } else {
1771:                    updateStatusMessage(null);
1772:                }
1773:            }
1774:
1775:            /**
1776:             * Updates that message displayed in the status line.
1777:             */
1778:            void updateStatusMessage(IStructuredSelection selection) {
1779:                String message = getStatusMessage(selection);
1780:                getViewSite().getActionBars().getStatusLineManager()
1781:                        .setMessage(message);
1782:            }
1783:
1784:            /**
1785:             * Updates the title of the view.  Should be called when filters change.
1786:             */
1787:            void updateTitle() {
1788:                TaskListContentProvider provider = (TaskListContentProvider) getTableViewer()
1789:                        .getContentProvider();
1790:                String summary = provider.getTitleSummary();
1791:                setContentDescription(summary);
1792:            }
1793:
1794:            /**
1795:             * Method updateSortingState.
1796:             */
1797:            void updateSortingState() {
1798:                int curColumn = comparator.getTopPriority();
1799:                sortByCategoryAction.setChecked(curColumn == TaskSorter.TYPE);
1800:                sortByCompletedAction
1801:                        .setChecked(curColumn == TaskSorter.COMPLETION);
1802:                sortByPriorityAction
1803:                        .setChecked(curColumn == TaskSorter.PRIORITY);
1804:                sortByDescriptionAction
1805:                        .setChecked(curColumn == TaskSorter.DESCRIPTION);
1806:                sortByResourceAction
1807:                        .setChecked(curColumn == TaskSorter.RESOURCE);
1808:                sortByContainerAction
1809:                        .setChecked(curColumn == TaskSorter.FOLDER);
1810:                sortByLocationAction
1811:                        .setChecked(curColumn == TaskSorter.LOCATION);
1812:                sortByCreationTimeAction
1813:                        .setChecked(curColumn == TaskSorter.CREATION_TIME);
1814:
1815:                int curDirection = comparator.getTopPriorityDirection();
1816:                sortAscendingAction
1817:                        .setChecked(curDirection == TaskSorter.ASCENDING);
1818:                sortDescendingAction
1819:                        .setChecked(curDirection == TaskSorter.DESCENDING);
1820:            }
1821:
1822:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.