01: package net.refractions.udig.printing.ui.internal.editor;
02:
03: import net.refractions.udig.printing.model.Box;
04: import net.refractions.udig.printing.model.BoxPrinter;
05: import net.refractions.udig.printing.model.impl.BoxImpl;
06: import net.refractions.udig.printing.ui.internal.BoxFactory;
07: import net.refractions.udig.printing.ui.internal.PrintingPlugin;
08:
09: import org.eclipse.core.runtime.CoreException;
10: import org.eclipse.gef.requests.CreationFactory;
11:
12: public class BoxCreationFactory implements CreationFactory {
13:
14: private BoxFactory factory;
15:
16: public BoxCreationFactory(BoxFactory factory) {
17: this .factory = factory;
18: }
19:
20: public Object getNewObject() {
21:
22: BoxPrinter object;
23: try {
24: object = factory.createBox();
25: } catch (CoreException e) {
26: PrintingPlugin.log("", e); //$NON-NLS-1$
27: return null;
28: }
29: if (object instanceof Box) {
30: return object;
31: }
32:
33: Box box = new BoxImpl();
34: box.setBoxPrinter(object);
35: object.setBox(box);
36:
37: return box;
38: }
39:
40: public Object getObjectType() {
41: return factory.getType();
42: }
43:
44: }
|