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.editors.win32;
14 import org.eclipse.core.runtime.IProgressMonitor;
15 import org.eclipse.swt.SWT;
16 import org.eclipse.swt.layout.FillLayout;
17 import org.eclipse.swt.layout.GridLayout;
18 import org.eclipse.swt.ole.win32.OleAutomation;
19 import org.eclipse.swt.ole.win32.OleClientSite;
20 import org.eclipse.swt.ole.win32.OleFrame;
21 import org.eclipse.swt.widgets.Composite;
22 import org.eclipse.swt.widgets.Shell;
23 import org.eclipse.ui.IEditorInput;
24 import org.eclipse.ui.IEditorSite;
25 import org.eclipse.ui.PartInitException;
26 import org.eclipse.ui.part.EditorPart;
27 import org.simantics.editors.win32.ole.EditorDefinition;
28 import org.simantics.editors.win32.ole.OleController;
32 * OLEEditor is a wrapper for Windows ActiveX components.
34 * @author Marko Luukkainen <Marko.Luukkainen@vtt.fi>
37 public class OLEEditor extends EditorPart {
39 private OleFrame frame;
40 private OleClientSite site;
41 private OleAutomation auto;
42 private OleController ctrl;
44 private Shell fsShell;
51 public void doSave(IProgressMonitor monitor) {
56 public void doSaveAs() {
61 public void init(IEditorSite site, IEditorInput input)
62 throws PartInitException {
63 if (!(input instanceof OLEEditorInput))
64 throw new PartInitException("Input must be OLEEditorInput");
71 public boolean isDirty() {
76 public boolean isSaveAsAllowed() {
82 public void createPartControl(Composite parent) {
83 OLEEditorInput input = (OLEEditorInput)getEditorInput();
84 boolean fullscreen = input.isFullscreen();
86 fsShell = new Shell(parent.getDisplay());
88 fsShell.setLayout(new GridLayout(1,false));
89 fsShell.setLayout(new FillLayout());
90 parent = new Composite(fsShell,SWT.NONE);
92 fsShell.setFullScreen(true);
93 parent.setLayout(new FillLayout());
97 EditorDefinition factory = input.getFactory();
98 frame = new OleFrame(parent, SWT.NONE);
100 if (factory.getProgID() == null || factory.useFileInput()) {
101 site = new OleClientSite(frame,SWT.NONE,input.getFile());
103 site = new OleClientSite(frame, SWT.NONE, factory.getProgID());
104 auto = new OleAutomation(site);
105 ctrl = factory.createController(frame, site, auto);
109 setPartName(site.getProgramID() + " : " + input.getName());
112 fsShell.layout(true, true);
117 public void setFocus() {
122 * Returns OleController of embedded OLE component. May return null.
125 public OleController getController() {
130 public void dispose() {