1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.ui.workbench.editor;
14 import org.eclipse.jface.resource.ImageDescriptor;
15 import org.eclipse.ui.IEditorInput;
16 import org.eclipse.ui.PartInitException;
17 import org.eclipse.ui.WorkbenchException;
18 import org.simantics.utils.ui.ErrorLogger;
19 import org.simantics.utils.ui.workbench.WorkbenchUtils;
22 * @author Tuukka Lehtonen
24 public abstract class AbstractEditorAdapter implements EditorAdapter, Prioritized {
26 protected String name;
28 protected ImageDescriptor icon;
30 protected int priority;
32 public AbstractEditorAdapter(String name) {
36 public AbstractEditorAdapter(String name, ImageDescriptor icon) {
40 public AbstractEditorAdapter(String name, ImageDescriptor icon, int priority) {
43 this.priority = priority;
46 public String getName() {
50 public ImageDescriptor getIcon() {
55 public int getPriority() {
60 public void setPriority(int priority) {
61 this.priority = priority;
64 protected void setIcon(ImageDescriptor icon) {
68 protected void openEditorWithId(String editorId, IEditorInput input) throws PartInitException {
69 WorkbenchUtils.openEditor(editorId, input);
72 protected void openEditorWithIdInPerspective(String editorId, IEditorInput input, String perspectiveId)
73 throws WorkbenchException {
75 WorkbenchUtils.showPerspective(perspectiveId);
76 } catch (WorkbenchException e) {
77 ErrorLogger.getDefault().logError("Could not open perspective with ID'" + perspectiveId + "'.", e);
80 openEditorWithId(editorId, input);