redoaction.java

来自「对eclipse gef进行封装,可以生成图形化编辑器」· Java 代码 · 共 76 行

JAVA
76
字号
/*******************************************************************************
 * $Header: /cvsroot/EOS6/work_dir/niegy/com.primeton.studio.gef.ui/src/com/primeton/studio/gef/ui/properties/RedoAction.java,v 1.1 2006/11/17 03:15:13 niegy Exp $
 * $Revision: 1.1 $
 * $Date: 2006/11/17 03:15:13 $
 *
 *==============================================================================
 *
 * Copyright (c) 2001-2006 Primeton Technologies, Ltd.
 * All rights reserved. 
 * 
 * Created on 2006-10-26
 *******************************************************************************/


package com.primeton.studio.gef.ui.properties;

import java.text.MessageFormat;

import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.CommandStack;
import org.eclipse.gef.internal.GEFMessages;
import org.eclipse.jface.action.Action;

/**
 * TODO此处填写 class 信息
 *
 * @author niegy (mailto:niegy@primeton.com)
 */
/*
 * 修改历史
 * $Log: RedoAction.java,v $
 * Revision 1.1  2006/11/17 03:15:13  niegy
 * create
 * 
 */
public class RedoAction extends Action {
    private CommandStack cmdStack;

    public RedoAction(CommandStack commandStack)
    {
        cmdStack = commandStack;
    }

    protected boolean calculateEnabled()
    {
        return cmdStack.canRedo();
    }

    protected String getLabelForCommand(Command command)
    {
        if(command == null)
            return "";
        if(command.getLabel() == null)
            return "";
        else
            return command.getLabel();
    }

    public void run()
    {
        cmdStack.redo();
    }

    protected void refresh()
    {
        Command redoCmd = cmdStack.getRedoCommand();
        setToolTipText(MessageFormat.format(GEFMessages.RedoAction_Tooltip, new Object[] {
            getLabelForCommand(redoCmd)
        }).trim());
        setText(MessageFormat.format(GEFMessages.RedoAction_Label, new Object[] {
            getLabelForCommand(redoCmd)
        }).trim());
        setEnabled(calculateEnabled());
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?