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.forms.editor.FormEditor;
19 import org.simantics.db.Session;
20 import org.simantics.db.management.ISessionContext;
21 import org.simantics.ui.SimanticsUI;
24 * @author Tuukka Lehtonen
26 public abstract class ResourceFormEditor extends FormEditor implements IResourceEditorPart {
28 ResourceEditorSupport support;
29 boolean disposed = false;
32 public final void doSave(IProgressMonitor monitor) {
36 public final void doSaveAs() {
40 public final boolean isSaveAsAllowed() {
45 public IResourceEditorInput getResourceInput() {
46 return (IResourceEditorInput) getEditorInput();
50 public void init(IEditorSite site, IEditorInput input) throws PartInitException {
51 if (!(input instanceof IResourceEditorInput))
52 throw new PartInitException("Invalid input: must be IResourceEditorInput");
53 super.init(site, input);
54 support = new ResourceEditorSupport(this);
56 // Set initial part name according to the name given by IEditorInput
57 setPartName(getEditorInput().getName());
59 Session session = SimanticsUI.peekSession();
60 if (session != null) {
62 new TitleRequest(site.getId(), getResourceInput()),
63 new TitleUpdater(site.getShell().getDisplay(), this::setPartName, () -> disposed));
68 public void dispose() {
74 protected ISessionContext getSessionContext() {
75 return support.getSessionContext();
78 protected Session getSession() {
79 return support.getSession();