KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > ecore > sdo > action > BeginLoggingAction


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2003-2004 IBM Corporation and others.
5  * All rights reserved. This program and the accompanying materials
6  * are made available under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution, and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors:
11  * IBM - Initial API and implementation
12  *
13  * </copyright>
14  *
15  * $Id: BeginLoggingAction.java,v 1.2 2005/06/08 06:21:18 nickb Exp $
16  */

17 package org.eclipse.emf.ecore.sdo.action;
18
19
20 import org.eclipse.jface.action.IAction;
21 import org.eclipse.jface.viewers.ISelection;
22 import org.eclipse.jface.viewers.IStructuredSelection;
23 import org.eclipse.ui.IActionDelegate;
24 import org.eclipse.ui.actions.ActionDelegate;
25
26 import commonj.sdo.ChangeSummary;
27
28
29 /**
30  *
31  */

32 public class BeginLoggingAction
33   extends ActionDelegate
34   implements IActionDelegate
35 {
36   protected ChangeSummary changeSummary;
37
38   public BeginLoggingAction()
39   {
40   }
41
42   public void run(IAction action)
43   {
44     changeSummary.beginLogging();
45   }
46
47   public void selectionChanged(IAction action, ISelection selection)
48   {
49     if (selection instanceof IStructuredSelection)
50     {
51       Object JavaDoc object = ((IStructuredSelection)selection).getFirstElement();
52       if (object instanceof ChangeSummary)
53       {
54         changeSummary = (ChangeSummary)object;
55         if (!changeSummary.isLogging())
56         {
57           action.setEnabled(true);
58           return;
59         }
60       }
61     }
62     changeSummary = null;
63     action.setEnabled(false);
64   }
65
66 }
67
Popular Tags