View Javadoc

1   /* ======================================
2    * Copyright (c) 2004-2005 Achim Nierbeck
3    * All rights reserved.
4    *
5    * You may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *       http://www.gnu.org/licenses/lgpl.html
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   * ======================================
16   */
17  
18  /* DoubleClickAction.java
19   * $Revision: 1.3 $
20   * Date 14.12.2005
21   * 
22   * $Author: nierbeck $ 
23   * $Date: 2006/02/02 21:29:37 $ 
24   * 
25   */
26  
27  package de.nierbeck.timeTrack.actions;
28  
29  import org.eclipse.jface.action.IAction;
30  import org.eclipse.jface.dialogs.MessageDialog;
31  import org.eclipse.jface.viewers.ISelection;
32  import org.eclipse.jface.viewers.IStructuredSelection;
33  import org.eclipse.jface.viewers.TableViewer;
34  import org.eclipse.swt.widgets.Shell;
35  import org.eclipse.ui.IObjectActionDelegate;
36  import org.eclipse.ui.IWorkbenchPart;
37  
38  import de.nierbeck.timeTrack.model.impl.EntryTypeImpl;
39  import de.nierbeck.timeTrack.views.EditEntryDialog;
40  
41  /***
42   * Action class for DoubleClick Action
43   * 
44   * @author Achim
45   * 
46   */
47  public class DoubleClickAction implements IObjectActionDelegate {
48  
49  	private TableViewer tableViewer;
50  
51  	/***
52  	 * Constructor for DoubleClickAction.
53  	 */
54  	public DoubleClickAction() {
55  		super();
56  	}
57  
58  	/***
59  	 * Constructor for DoubleClickAction taking the TableViewer.
60  	 * 
61  	 * @param tbv - the Tableviewer
62  	 */
63  	public DoubleClickAction(TableViewer tbv) {
64  		super();
65  		this.tableViewer = tbv;
66  	}
67  
68  	/***
69  	 * @param action - does nothing
70  	 * @param targetPart - does nothing
71  	 * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
72  	 */
73  	public void setActivePart(IAction action, IWorkbenchPart targetPart) {
74  	}
75  
76  	/***
77  	 * @param action - the given Action runing on 
78  	 * @see IActionDelegate#run(IAction)
79  	 */
80  	public final void run(IAction action) {
81  		Shell shell = new Shell();
82  		MessageDialog.openInformation(shell, "TimeTrack Plug-in",
83  				"New Action was executed.");
84  	}
85  
86  	/***
87  	 * @param selection - the Selection on which this method runs
88  	 */
89  	public final void run(ISelection selection) {
90  		Shell shell = new Shell();
91  		EntryTypeImpl obj = (EntryTypeImpl) ((IStructuredSelection) selection)
92  				.getFirstElement();
93  		EditEntryDialog dialog = new EditEntryDialog(shell, obj);
94  		dialog.open();
95  		tableViewer.refresh(obj);
96  	}
97  
98  	/***
99  	 * @param action - does nothing
100 	 * @param selection - does nothing
101 	 * @see IActionDelegate#selectionChanged(IAction, ISelection)
102 	 */
103 	public void selectionChanged(IAction action, ISelection selection) {
104 	}
105 
106 }