1 /*******************************************************************************
2 * Copyright (c) 2002 International Business Machines Corp. and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v0.5
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v05.html
9 * IBM Corporation - initial API and implementation
10 ******************************************************************************/
11 package net.sourceforge.phpdt.internal.ui.actions;
13 import java.util.HashMap;
16 import org.eclipse.jface.viewers.IStructuredSelection;
17 import org.eclipse.jface.dialogs.IDialogConstants;
18 import org.eclipse.jface.dialogs.InputDialog;
20 import org.eclipse.core.resources.IMarker;
21 import org.eclipse.core.resources.IResource;
22 import org.eclipse.core.runtime.CoreException;
23 import org.eclipse.core.runtime.IAdaptable;
25 import org.eclipse.ui.IWorkbenchSite;
26 import org.eclipse.ui.help.WorkbenchHelp;
27 import org.eclipse.ui.texteditor.MarkerUtilities;
28 import org.eclipse.ui.views.tasklist.TaskPropertiesDialog;
30 //import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
31 import net.sourceforge.phpdt.internal.ui.util.ExceptionHandler;
33 import net.sourceforge.phpdt.ui.actions.SelectionDispatchAction;
35 public class AddTaskAction extends SelectionDispatchAction {
37 public AddTaskAction(IWorkbenchSite site) {
40 // WorkbenchHelp.setHelp(this, IJavaHelpContextIds.ADD_TASK_ACTION);
43 protected void selectionChanged(IStructuredSelection selection) {
44 setEnabled(getElement(selection) != null);
47 protected void run(IStructuredSelection selection) {
48 IResource resource= getElement(selection);
52 TaskPropertiesDialog dialog= new TaskPropertiesDialog(getShell());
53 dialog.setResource(resource);
57 private IResource getElement(IStructuredSelection selection) {
58 if (selection.size() != 1)
61 Object element= selection.getFirstElement();
62 if (!(element instanceof IAdaptable))
64 return (IResource)((IAdaptable)element).getAdapter(IResource.class);