01: package com.xoetrope.editor.eclipse.survey;
02:
03: import java.awt.BorderLayout;
04: import java.awt.Frame;
05: import java.awt.Panel;
06: import java.io.File;
07:
08: import org.eclipse.core.resources.IFile;
09: import org.eclipse.core.resources.IResourceChangeEvent;
10: import org.eclipse.core.resources.IResourceChangeListener;
11: import org.eclipse.core.runtime.IPath;
12: import org.eclipse.core.runtime.IProgressMonitor;
13: import org.eclipse.swt.SWT;
14: import org.eclipse.swt.awt.SWT_AWT;
15: import org.eclipse.swt.widgets.Composite;
16: import org.eclipse.ui.IEditorInput;
17: import org.eclipse.ui.IEditorSite;
18: import org.eclipse.ui.IFileEditorInput;
19: import org.eclipse.ui.PartInitException;
20: import org.eclipse.ui.part.EditorPart;
21:
22: import com.xoetrope.carousel.survey.XSurveyEditorFrame;
23:
24: /**
25: * Wrapper for the Survey Editor
26: *
27: */
28: public class XSurveyEditor extends EditorPart implements
29: IResourceChangeListener {
30: private XSurveyEditorFrame surveyEditorFrame;
31:
32: public void doSave(IProgressMonitor monitor) {
33: // TODO Auto-generated method stub
34: }
35:
36: public void doSaveAs() {
37: // TODO Auto-generated method stub
38: }
39:
40: /**
41: * Returns the currently selected survey file.
42: * @return currently selected survey file.
43: */
44: private File getSurveyFile() {
45: IEditorInput editorInput = getEditorInput();
46: if (!(editorInput instanceof IFileEditorInput))
47: return null;
48: IFile ifile = ((IFileEditorInput) editorInput).getFile();
49: IPath ipath = ifile.getLocation();
50: return ipath.toFile();
51: }
52:
53: public boolean isSaveAsAllowed() {
54: // TODO Auto-generated method stub
55: return false;
56: }
57:
58: public void resourceChanged(IResourceChangeEvent event) {
59: // TODO Auto-generated method stub
60:
61: }
62:
63: public void init(IEditorSite site, IEditorInput input)
64: throws PartInitException {
65: setSite(site);
66: setInput(input);
67: }
68:
69: public boolean isDirty() {
70: return false;
71: }
72:
73: public void createPartControl(Composite parent) {
74: File surveyFile = getSurveyFile();
75: surveyEditorFrame = new XSurveyEditorFrame(false,
76: "SurveyEditor", surveyFile);
77:
78: Composite panelProxy = new Composite(parent, SWT.EMBEDDED);
79:
80: Frame awtFrame = SWT_AWT.new_Frame(panelProxy);
81: awtFrame.setLayout(new BorderLayout());
82:
83: Panel root = new Panel();
84: root.setLayout(new BorderLayout());
85: root.add(surveyEditorFrame.getContentPane(),
86: BorderLayout.CENTER);
87: awtFrame.add(root);
88: }
89:
90: public void setFocus() {
91: }
92:
93: }
|