Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 8816df2884787d5302d48992e19bf8ec86c507a3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.commands;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;

/**
 * A command to be used with the Eclipse Commands Framework.
 * This command allows to close all diagrams in the folder, except the currently openened one.
 *
 * @author cedric dumoulin
 *
 */
public class CloseOtherDiagramsCommand extends AbstractHandler {

	/**
	 * Check if the Command is enabled.
	 */
	@Override
	public void setEnabled(Object evaluationContext) {
		setBaseEnabled(new PageContext(evaluationContext).getOpenPageCount() > 1);
	}

	/**
	 * Execute the command. This method is called when the action is triggered.
	 *
	 */
	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException {
		PageContext context = new PageContext(event);

		if (context.isValid() && (context.getOpenPageCount() > 1)) {
			context.pageManager.closeOtherPages(context.currentPageIdentifier);
		}

		return null;
	}

}

Back to the top