1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.editors.win32;
\r
14 import org.eclipse.core.runtime.IProgressMonitor;
\r
15 import org.eclipse.swt.SWT;
\r
16 import org.eclipse.swt.layout.FillLayout;
\r
17 import org.eclipse.swt.layout.GridLayout;
\r
18 import org.eclipse.swt.ole.win32.OleAutomation;
\r
19 import org.eclipse.swt.ole.win32.OleClientSite;
\r
20 import org.eclipse.swt.ole.win32.OleFrame;
\r
21 import org.eclipse.swt.widgets.Composite;
\r
22 import org.eclipse.swt.widgets.Shell;
\r
23 import org.eclipse.ui.IEditorInput;
\r
24 import org.eclipse.ui.IEditorSite;
\r
25 import org.eclipse.ui.PartInitException;
\r
26 import org.eclipse.ui.part.EditorPart;
\r
27 import org.simantics.editors.win32.ole.EditorDefinition;
\r
28 import org.simantics.editors.win32.ole.OleController;
\r
32 * OLEEditor is a wrapper for Windows ActiveX components.
\r
34 * @author Marko Luukkainen <Marko.Luukkainen@vtt.fi>
\r
37 public class OLEEditor extends EditorPart {
\r
39 private OleFrame frame;
\r
40 private OleClientSite site;
\r
41 private OleAutomation auto;
\r
42 private OleController ctrl;
\r
44 private Shell fsShell;
\r
46 public OLEEditor() {
\r
51 public void doSave(IProgressMonitor monitor) {
\r
56 public void doSaveAs() {
\r
61 public void init(IEditorSite site, IEditorInput input)
\r
62 throws PartInitException {
\r
63 if (!(input instanceof OLEEditorInput))
\r
64 throw new PartInitException("Input must be OLEEditorInput");
\r
71 public boolean isDirty() {
\r
76 public boolean isSaveAsAllowed() {
\r
82 public void createPartControl(Composite parent) {
\r
83 OLEEditorInput input = (OLEEditorInput)getEditorInput();
\r
84 boolean fullscreen = input.isFullscreen();
\r
86 fsShell = new Shell(parent.getDisplay());
\r
88 fsShell.setLayout(new GridLayout(1,false));
\r
89 fsShell.setLayout(new FillLayout());
\r
90 parent = new Composite(fsShell,SWT.NONE);
\r
92 fsShell.setFullScreen(true);
\r
93 parent.setLayout(new FillLayout());
\r
97 EditorDefinition factory = input.getFactory();
\r
98 frame = new OleFrame(parent, SWT.NONE);
\r
100 if (factory.getProgID() == null || factory.useFileInput()) {
\r
101 site = new OleClientSite(frame,SWT.NONE,input.getFile());
\r
103 site = new OleClientSite(frame, SWT.NONE, factory.getProgID());
\r
104 auto = new OleAutomation(site);
\r
105 ctrl = factory.createController(frame, site, auto);
\r
109 setPartName(site.getProgramID() + " : " + input.getName());
\r
112 fsShell.layout(true, true);
\r
117 public void setFocus() {
\r
122 * Returns OleController of embedded OLE component. May return null.
\r
125 public OleController getController() {
\r
130 public void dispose() {
\r
134 if (fsShell != null)
\r
136 if (frame != null) {
\r