Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 60bf0d9b306ea5c2e28ae3d6623e1e8ea1642b69 (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
52
53
54
55
56
57
58
59
60
61
/******************************************************************************* 
 * Copyright (c) 2016, 2017 Red Hat, Inc. 
 * Distributed under license by Red Hat, Inc. All rights reserved. 
 * This program is made available under the terms of the 
 * Eclipse Public License v1.0 which accompanies this distribution, 
 * and is available at http://www.eclipse.org/legal/epl-v10.html 
 * 
 * Contributors: 
 * Red Hat, Inc. - initial API and implementation 
 ******************************************************************************/ 
package org.eclipse.linuxtools.docker.reddeer.perspective;

import org.eclipse.reddeer.core.exception.CoreLayerException;
import org.eclipse.reddeer.swt.impl.button.PushButton;
import org.eclipse.reddeer.swt.impl.shell.DefaultShell;
import org.eclipse.reddeer.swt.impl.table.DefaultTable;
import org.eclipse.reddeer.swt.impl.toolbar.DefaultToolItem;

/**
 * Abstract parent for each Perspective implementation
 * 
 * @author vlado pakan
 * 
 */
public abstract class AbstractPerspective extends org.eclipse.reddeer.eclipse.ui.perspectives.AbstractPerspective {

	/**
	 * Constructs the perspective with a given label.
	 * 
	 * @param perspectiveLabel Perspective label
	 */
	public AbstractPerspective(String perspectiveLabel) {
		super(perspectiveLabel);
	}

	/**
	 * Opens the perspective.
	 */
	@Override
	public void open() {
		log.info("Open perspective: '" + getPerspectiveLabel() + "'");
		if (isOpened()){
			log.debug("Perspective '" + getPerspectiveLabel() + "' is already opened.");
		}
		else{
			log.debug("Tryyying to open perspective: '" + getPerspectiveLabel() + "'");
			new DefaultToolItem(new DefaultShell(),"Open Perspective").click();
			new DefaultShell("Open Perspective");
			DefaultTable table = new DefaultTable();
			try{
				// Try to select perspective label within available perspectives
				table.select(getPerspectiveLabel());
			} catch (CoreLayerException swtLayerException){
				// Try to select perspective label within available perspectives with "(default)" suffix
				table.select(getPerspectiveLabel() + " (default)");
			}
			new PushButton("Open").click();
		}
	}

}

Back to the top