01: package org.drools.eclipse.editors;
02:
03: /*
04: * Copyright 2006 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.ScalableFigure;
20: import org.eclipse.gef.editparts.ZoomManager;
21: import org.eclipse.gef.ui.actions.ZoomInAction;
22:
23: /**
24: * Similar to ZoomInAction but adds setZoomManager(..) functionality.
25: *
26: * ZoomInAction2 provides default constructor for initializing
27: * ZoomInAction without the need for ZoomManager.
28: *
29: * Please note that ZoomInAction2 is not very functional until it has
30: * correct zoomManager set by setZoomManager(ZoomManager manager).<br/>
31: *
32: * setZoomManager(ZoomManager manager) can be used several times.
33: *
34: * @author Ahti Kitsik
35: *
36: */
37: public class ZoomInAction2 extends ZoomInAction {
38:
39: final private static ZoomManager FAKE_ZOOM_MANAGER = new ZoomManager(
40: (ScalableFigure) null, null);
41:
42: /**
43: * Default constructor to allow ZoomInActions without specified
44: * ZoomManager.
45: */
46: public ZoomInAction2() {
47: super (FAKE_ZOOM_MANAGER);
48: }
49:
50: /**
51: * Replaces existing zoomManager with the new one.
52: *
53: * Implementation is null-safe.
54: *
55: * @param newManager new zoom manager
56: */
57: public void setZoomManager(ZoomManager newManager) {
58:
59: if (zoomManager != null) {
60: zoomManager.removeZoomListener(this);
61: }
62:
63: zoomManager = newManager;
64:
65: if (zoomManager != null) {
66: zoomManager.addZoomListener(this);
67: }
68:
69: }
70:
71: }
|