KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > common > command > UnexecutableCommand


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2002-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: UnexecutableCommand.java,v 1.2 2005/06/08 05:44:08 nickb Exp $
16  */

17 package org.eclipse.emf.common.command;
18
19
20 import org.eclipse.emf.common.CommonPlugin;
21
22
23 /**
24  * A singleton {@link UnexecutableCommand#INSTANCE} that cannot execute.
25  */

26 public class UnexecutableCommand extends AbstractCommand
27 {
28   /**
29    * The one instance of this object.
30    */

31   public static final UnexecutableCommand INSTANCE = new UnexecutableCommand();
32
33   /**
34    * Only one private instance is created.
35    */

36   private UnexecutableCommand()
37   {
38     super
39       (CommonPlugin.INSTANCE.getString("_UI_UnexecutableCommand_label"),
40        CommonPlugin.INSTANCE.getString("_UI_UnexecutableCommand_description"));
41   }
42
43   /**
44    * Returns <code>false</code>.
45    * @return <code>false</code>.
46    */

47   public boolean canExecute()
48   {
49     return false;
50   }
51
52   /**
53    * Throws an exception if it should ever be called.
54    * @exception UnsupportedOperationException always.
55    */

56   public void execute()
57   {
58     throw
59       new UnsupportedOperationException JavaDoc
60         (CommonPlugin.INSTANCE.getString("_EXC_Method_not_implemented", new String JavaDoc [] { this.getClass().getName() + ".execute()" }));
61   }
62
63   /**
64    * Returns <code>false</code>.
65    * @return <code>false</code>.
66    */

67   public boolean canUndo()
68   {
69     return false;
70   }
71
72   /**
73    * Throws an exception if it should ever be called.
74    * @exception UnsupportedOperationException always.
75    */

76   public void redo()
77   {
78     throw
79       new UnsupportedOperationException JavaDoc
80         (CommonPlugin.INSTANCE.getString("_EXC_Method_not_implemented", new String JavaDoc [] { this.getClass().getName() + ".redo()" }));
81   }
82 }
83
Popular Tags