Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: daf9d4290928cfccdf7f56ed54b23b5e1fbf0d0e (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
40
41
42
43
44
45
46
47
48
49
50
51
/*****************************************************************************
 * Copyright (c) 2019 CEA LIST and others.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *   Patrick Tessier (CEA LIST) - Initial API and implementation
 *
 *****************************************************************************/

package org.eclipse.papyrus.infra.core.sasheditor.api;

import org.eclipse.papyrus.infra.core.sasheditor.editor.IMultiPageEditorPart;
import org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer;

/**
 * this class provides to the developer an access point to have access to open/ closed editor
 *
 */
public class EditorAccessFunction {

	/**
	 * Shortcut to get the SashContainer from the multipage editor, for example papyrus.
	 *
	 * @param multiPageEditorPart
	 * @return null or the ISashWindowsContainer
	 */
	public static ISashWindowsContainer getSashContainerFromEditor(IMultiPageEditorPart multiPageEditorPart) {
		return multiPageEditorPart.getAdapter(ISashWindowsContainer.class);
	}

	/**
	 * getActivePage from a multipage Editor
	 *
	 * @param multiPageEditorPart
	 * @return null or the activeEditor
	 */
	public static IPapyrusEditor getActiveEditor(IMultiPageEditorPart multiPageEditorPart) {
		ISashWindowsContainer sashContainer = getSashContainerFromEditor(multiPageEditorPart);
		if ((sashContainer != null) && !sashContainer.isDisposed()) {
			IPapyrusEditor activePage = sashContainer.getActiveSashWindowsPage();
			return activePage;
		}
		return null;
	}
}

Back to the top