01: package org.drools.eclipse.flow.common.editor;
02:
03: /*
04: * Copyright 2005 JBoss Inc
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: import org.eclipse.draw2d.LightweightSystem;
20: import org.eclipse.draw2d.MarginBorder;
21: import org.eclipse.draw2d.Viewport;
22: import org.eclipse.draw2d.parts.ScrollableThumbnail;
23: import org.eclipse.draw2d.parts.Thumbnail;
24: import org.eclipse.gef.LayerConstants;
25: import org.eclipse.gef.editparts.ScalableRootEditPart;
26: import org.eclipse.jface.viewers.ISelection;
27: import org.eclipse.jface.viewers.ISelectionChangedListener;
28: import org.eclipse.jface.viewers.StructuredSelection;
29: import org.eclipse.swt.SWT;
30: import org.eclipse.swt.widgets.Canvas;
31: import org.eclipse.swt.widgets.Composite;
32: import org.eclipse.swt.widgets.Control;
33: import org.eclipse.ui.part.Page;
34: import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
35:
36: /**
37: * Common implementation of an outline page.
38: *
39: * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris Verlaenen</a>
40: */
41: public class OverviewOutlinePage extends Page implements
42: IContentOutlinePage {
43:
44: private Canvas overview;
45: private ScalableRootEditPart rootEditPart;
46: private Thumbnail thumbnail;
47:
48: public OverviewOutlinePage(ScalableRootEditPart rootEditPart) {
49: this .rootEditPart = rootEditPart;
50: }
51:
52: public void addSelectionChangedListener(
53: ISelectionChangedListener listener) {
54: }
55:
56: public void createControl(Composite parent) {
57: overview = new Canvas(parent, SWT.NONE);
58: LightweightSystem lws = new LightweightSystem(overview);
59: thumbnail = new ScrollableThumbnail((Viewport) rootEditPart
60: .getFigure());
61: thumbnail.setBorder(new MarginBorder(3));
62: thumbnail.setSource(rootEditPart
63: .getLayer(LayerConstants.PRINTABLE_LAYERS));
64: lws.setContents(thumbnail);
65: }
66:
67: public void dispose() {
68: if (null != thumbnail) {
69: thumbnail.deactivate();
70: }
71: super .dispose();
72: }
73:
74: public Control getControl() {
75: return overview;
76: }
77:
78: public ISelection getSelection() {
79: return StructuredSelection.EMPTY;
80: }
81:
82: public void removeSelectionChangedListener(
83: ISelectionChangedListener listener) {
84: }
85:
86: public void setFocus() {
87: if (getControl() != null) {
88: getControl().setFocus();
89: }
90: }
91:
92: public void setSelection(ISelection selection) {
93: }
94: }
|