View | Details | Raw Unified | Return to bug 111637 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/gmf/runtime/common/ui/action/actions/RepeatActionHandler.java (-112 lines)
Removed Link Here
1
/******************************************************************************
2
 * Copyright (c) 2002, 2003 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *    IBM Corporation - initial API and implementation 
10
 ****************************************************************************/
11
12
package org.eclipse.gmf.runtime.common.ui.action.actions;
13
14
import org.eclipse.core.runtime.IProgressMonitor;
15
import org.eclipse.core.runtime.NullProgressMonitor;
16
import org.eclipse.swt.widgets.Event;
17
import org.eclipse.ui.IWorkbenchPart;
18
19
import org.eclipse.gmf.runtime.common.ui.action.ActionManagerChangeEvent;
20
import org.eclipse.gmf.runtime.common.ui.action.IActionManagerChangeListener;
21
import org.eclipse.gmf.runtime.common.ui.action.internal.actions.CommandManagerActionHandler;
22
23
/**
24
 * Represents an action handler that could be registered with a retargetable
25
 * (global) repeat action to repeat the last command that was run. This class
26
 * implements the <code>IActionManagerChangeListener</code> interface; hence its
27
 * instances will automatically refresh themselves when an action manager change
28
 * notification is received. Repeat action handlers would update the label
29
 * for a Repeat menu item based on the label for the action that was last run.
30
 * 
31
 * @author khussey
32
 * 
33
 * @see org.eclipse.gmf.runtime.common.ui.action.IActionManagerChangeListener
34
 */
35
public class RepeatActionHandler
36
	extends CommandManagerActionHandler
37
	implements IActionManagerChangeListener {
38
39
	/**
40
	 * Constructs a new repeat action handler for the specified workbench part.
41
	 * 
42
	 * @param workbenchPart The workbench part to which this repeat action
43
	 *                       handler applies.
44
	 */
45
	public RepeatActionHandler(IWorkbenchPart workbenchPart) {
46
		super(workbenchPart);
47
	}
48
49
	/* (non-Javadoc)
50
	 * @see org.eclipse.gmf.runtime.common.ui.action.AbstractActionHandler#setWorkbenchPart(org.eclipse.ui.IWorkbenchPart)
51
	 */
52
	protected void setWorkbenchPart(IWorkbenchPart workbenchPart) {
53
		if (getWorkbenchPart() != null){
54
			getActionManager().removeActionManagerChangeListener(this);
55
		}
56
		super.setWorkbenchPart(workbenchPart);
57
		if (getWorkbenchPart() != null){
58
			getActionManager().addActionManagerChangeListener(this);
59
		}
60
	}
61
62
	/**
63
	 * Handles an event indicating that an action manager has changed.
64
	 * 
65
	 * @param event The action manager change event to be handled.
66
	 * 
67
	 **/
68
	public void actionManagerChanged(ActionManagerChangeEvent event) {
69
		refresh();
70
	}
71
72
	/**
73
	 * Runs this repeat action handler, passing the triggering SWT event.
74
	 * 
75
	 * @param event The SWT event which triggered this action being run.
76
	 * 
77
	 */
78
	public final void runWithEvent(Event event) {
79
		run();
80
	}
81
82
	/**
83
	 * Refreshes the label and enabled state of this repeat action handler.
84
	 */
85
	public void refresh() {
86
		setEnabled(getActionManager().canRepeat());
87
		setText(getActionManager().getRepeatLabel());
88
	}
89
	
90
	/* (non-Javadoc)
91
	 * @see org.eclipse.jface.action.IAction#run()
92
	 */
93
	public void run() {
94
		doRun(new NullProgressMonitor());
95
	}
96
97
	/**
98
	 * Performs the actual work when this repeat action handler is run by asking
99
	 * the action manager to repeat the last action that was run.
100
	 */
101
	protected void doRun(IProgressMonitor progressMonitor) {
102
		getActionManager().repeat();
103
	}
104
	
105
	/* (non-Javadoc)
106
	 * @see org.eclipse.gmf.runtime.common.ui.action.AbstractActionHandler#isSelectionListener()
107
	 */
108
	protected boolean isSelectionListener() {
109
		return true;
110
	}
111
112
}
(-)src/org/eclipse/gmf/runtime/common/ui/action/internal/actions/CommandManagerActionHandler.java (-10 lines)
Lines 40-55 Link Here
40
        refresh();
40
        refresh();
41
    }
41
    }
42
42
43
    /**
44
     * Retrieves a Boolean indicating whether this action handler can be
45
     * repeated.
46
     * 
47
     * @return <code>false</code>.
48
     */
49
    public boolean isRepeatable() {
50
        return false;
51
    }
52
53
	/* (non-Javadoc)
43
	/* (non-Javadoc)
54
	 * @see org.eclipse.gmf.runtime.common.ui.action.AbstractActionHandler#isCommandStackListener()
44
	 * @see org.eclipse.gmf.runtime.common.ui.action.AbstractActionHandler#isCommandStackListener()
55
	 */
45
	 */
(-)src/org/eclipse/gmf/runtime/common/ui/action/internal/actions/global/GlobalRedoAction.java (-7 lines)
Lines 135-147 Link Here
135
		setText(label);
135
		setText(label);
136
    }
136
    }
137
137
138
    /* (non-Javadoc)
139
     * @see org.eclipse.gmf.runtime.common.ui.action.IRepeatableAction#isRepeatable()
140
     */
141
    public boolean isRepeatable() {
142
        return false;
143
    }
144
145
	/* (non-Javadoc)
138
	/* (non-Javadoc)
146
	 * @see org.eclipse.gmf.runtime.common.ui.action.AbstractActionHandler#isCommandStackListener()
139
	 * @see org.eclipse.gmf.runtime.common.ui.action.AbstractActionHandler#isCommandStackListener()
147
	 */
140
	 */
(-)src/org/eclipse/gmf/runtime/common/ui/action/internal/actions/global/GlobalSelectAllAction.java (-7 lines)
Lines 77-89 Link Here
77
        return GlobalActionId.SELECT_ALL;
77
        return GlobalActionId.SELECT_ALL;
78
    }
78
    }
79
79
80
    /* (non-Javadoc)
81
     * @see org.eclipse.gmf.runtime.common.ui.action.IRepeatableAction#isRepeatable()
82
     */
83
    public boolean isRepeatable() {
84
        return false;
85
    }
86
87
	/* (non-Javadoc)
80
	/* (non-Javadoc)
88
	 * @see org.eclipse.gmf.runtime.common.ui.action.AbstractActionHandler#isSelectionListener()
81
	 * @see org.eclipse.gmf.runtime.common.ui.action.AbstractActionHandler#isSelectionListener()
89
	 */
82
	 */
(-)src/org/eclipse/gmf/runtime/common/ui/action/internal/actions/global/GlobalUndoAction.java (-7 lines)
Lines 137-149 Link Here
137
		setText(label);
137
		setText(label);
138
	}
138
	}
139
139
140
    /**
141
     * @see org.eclipse.gmf.runtime.common.ui.action.IRepeatableAction#isRepeatable()
142
     */
143
    public boolean isRepeatable() {
144
        return false;
145
    }
146
147
	/* (non-Javadoc)
140
	/* (non-Javadoc)
148
	 * @see org.eclipse.gmf.runtime.common.ui.action.AbstractActionHandler#isCommandStackListener()
141
	 * @see org.eclipse.gmf.runtime.common.ui.action.AbstractActionHandler#isCommandStackListener()
149
	 */
142
	 */

Return to bug 111637