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;
14 import org.eclipse.core.runtime.IProgressMonitor;
15 import org.eclipse.ui.IEditorInput;
16 import org.eclipse.ui.IEditorSite;
17 import org.eclipse.ui.PartInitException;
18 import org.eclipse.ui.part.MultiPageEditorPart;
19 import org.simantics.db.Session;
22 * @author Tuukka Lehtonen
24 public abstract class MultiPageResourceEditorPart extends MultiPageEditorPart implements IResourceEditorPart {
26 ResourceEditorSupport support;
29 public final void doSave(IProgressMonitor monitor) {
33 public final void doSaveAs() {
37 public final boolean isSaveAsAllowed() {
42 public IResourceEditorInput getResourceInput() {
43 return (IResourceEditorInput) getEditorInput();
47 public void init(IEditorSite site, IEditorInput input) throws PartInitException {
48 if (!(input instanceof IResourceEditorInput))
49 throw new PartInitException("Invalid input: must be IResourceEditorInput");
50 super.init(site, input);
51 support = new ResourceEditorSupport(this);
53 // Set initial part name according to the name given by IEditorInput
54 setPartName(getEditorInput().getName());
58 public void dispose() {
63 @SuppressWarnings("rawtypes")
65 public Object getAdapter(Class adapter) {
66 if (adapter == Session.class && support != null)
67 return support.getSession();
68 return super.getAdapter(adapter);
71 protected Session getSession() {
72 return support.getSession();