001    /**
002     * <copyright> 
003     *
004     * Copyright (c) 2002-2006 IBM Corporation and others.
005     * All rights reserved.   This program and the accompanying materials
006     * are made available under the terms of the Eclipse Public License v1.0
007     * which accompanies this distribution, and is available at
008     * http://www.eclipse.org/legal/epl-v10.html
009     * 
010     * Contributors: 
011     *   IBM - Initial API and implementation
012     *
013     * </copyright>
014     *
015     * $Id: UnexecutableCommand.java,v 1.3 2006/12/05 20:19:54 emerks Exp $
016     */
017    package org.eclipse.emf.common.command;
018    
019    
020    import org.eclipse.emf.common.CommonPlugin;
021    
022    
023    /**
024     * A singleton {@link UnexecutableCommand#INSTANCE} that cannot execute.
025     */
026    public class UnexecutableCommand extends AbstractCommand 
027    {
028      /**
029       * The one instance of this object.
030       */
031      public static final UnexecutableCommand INSTANCE = new UnexecutableCommand();
032    
033      /**
034       * Only one private instance is created.
035       */
036      private UnexecutableCommand() 
037      {
038        super
039          (CommonPlugin.INSTANCE.getString("_UI_UnexecutableCommand_label"), 
040           CommonPlugin.INSTANCE.getString("_UI_UnexecutableCommand_description"));
041      }
042    
043      /**
044       * Returns <code>false</code>.
045       * @return <code>false</code>.
046       */
047      @Override
048      public boolean canExecute() 
049      {
050        return false;
051      }
052    
053      /**
054       * Throws an exception if it should ever be called.
055       * @exception UnsupportedOperationException always.
056       */
057      public void execute() 
058      {
059        throw 
060          new UnsupportedOperationException
061            (CommonPlugin.INSTANCE.getString("_EXC_Method_not_implemented", new String [] { this.getClass().getName() + ".execute()" }));
062      }
063    
064      /**
065       * Returns <code>false</code>.
066       * @return <code>false</code>.
067       */
068      @Override
069      public boolean canUndo() 
070      {
071        return false;
072      }
073    
074      /**
075       * Throws an exception if it should ever be called.
076       * @exception UnsupportedOperationException always.
077       */
078      public void redo() 
079      {
080        throw 
081          new UnsupportedOperationException
082            (CommonPlugin.INSTANCE.getString("_EXC_Method_not_implemented", new String [] { this.getClass().getName() + ".redo()" }));
083      }
084    }