1
|
1 package de.mpg.mpiwg.itgroup.digilib.plugin.editors;
|
|
2
|
|
3
|
|
4 import java.io.IOException;
|
|
5 import java.util.Observable;
|
|
6 import java.util.Observer;
|
|
7
|
|
8 import org.eclipse.core.runtime.CoreException;
|
|
9 import org.eclipse.core.runtime.IProgressMonitor;
|
20
|
10 import org.eclipse.jface.viewers.StructuredSelection;
|
1
|
11 import org.eclipse.swt.SWT;
|
|
12 import org.eclipse.swt.custom.ScrolledComposite;
|
|
13 import org.eclipse.swt.graphics.Cursor;
|
|
14 import org.eclipse.swt.layout.GridLayout;
|
|
15 import org.eclipse.swt.widgets.Composite;
|
|
16 import org.eclipse.ui.IEditorInput;
|
|
17 import org.eclipse.ui.IEditorSite;
|
20
|
18 import org.eclipse.ui.IPageLayout;
|
|
19 import org.eclipse.ui.IViewPart;
|
|
20 import org.eclipse.ui.IWorkbenchPage;
|
1
|
21 import org.eclipse.ui.PartInitException;
|
|
22 import org.eclipse.ui.part.EditorPart;
|
20
|
23 import org.eclipse.ui.views.properties.PropertySheet;
|
|
24 import org.eclipse.ui.views.properties.PropertySheetPage;
|
1
|
25 import org.jdom.JDOMException;
|
|
26
|
|
27 import de.mpg.mpiwg.itgroup.digilib.digiImage.DigiImage;
|
|
28 import de.mpg.mpiwg.itgroup.digilib.digiImage.DigiImageController;
|
|
29 import de.mpg.mpiwg.itgroup.digilib.digiImage.DigiImageParameter;
|
|
30 import de.mpg.mpiwg.itgroup.digilib.digiImage.DigiNav;
|
|
31 import de.mpg.mpiwg.itgroup.indexMeta.Utils.ParseIndexMeta;
|
|
32
|
|
33 /**
|
9
|
34 * Displays an image with digilib an allows image manipulation on the image.
|
1
|
35 *
|
|
36 * @author dwinter
|
|
37 *
|
|
38 */
|
21
|
39 public class DigilibLinkEditorPart extends EditorPart implements Observer{
|
1
|
40
|
|
41 private Composite mainComposite;
|
|
42 private ScrolledComposite sc;
|
|
43 @Override
|
|
44 public void doSave(IProgressMonitor monitor) {
|
|
45 // TODO Auto-generated method stub
|
|
46
|
|
47 }
|
|
48
|
|
49 @Override
|
|
50 public void doSaveAs() {
|
|
51 // TODO Auto-generated method stub
|
|
52
|
|
53 }
|
|
54
|
|
55 @Override
|
|
56 public void init(IEditorSite site, IEditorInput input)
|
|
57 throws PartInitException {
|
|
58 setInput(input);
|
|
59 setSite(site);
|
|
60
|
|
61 }
|
|
62
|
|
63 @Override
|
|
64 public boolean isDirty() {
|
|
65 // TODO Auto-generated method stub
|
|
66 return false;
|
|
67 }
|
|
68
|
|
69 @Override
|
|
70 public boolean isSaveAsAllowed() {
|
|
71 // TODO Auto-generated method stub
|
|
72 return false;
|
|
73 }
|
|
74
|
|
75 @Override
|
|
76 public void createPartControl(Composite frame) {
|
|
77
|
|
78 sc = new ScrolledComposite(frame, SWT.H_SCROLL | SWT.V_SCROLL);
|
|
79 mainComposite = new Composite(sc,SWT.None);
|
|
80
|
|
81 GridLayout imageLayout = new GridLayout(2,false);
|
|
82 mainComposite.setLayout(imageLayout);
|
|
83 sc.setContent(mainComposite);
|
|
84 //sc.setMinSize(400, 400);
|
|
85
|
9
|
86
|
1
|
87
|
|
88 DigilibLinkEditorInput input= (DigilibLinkEditorInput) getEditorInput();
|
|
89 String path="";
|
|
90 if (input.getType()==DigilibLinkEditorInput.INDEX_META){
|
|
91 ParseIndexMeta im;
|
|
92 try {
|
9
|
93 im = new ParseIndexMeta(input.getFile());
|
1
|
94 } catch (JDOMException e) {
|
|
95 // TODO Auto-generated catch block
|
|
96 e.printStackTrace();
|
|
97 return;
|
|
98 } catch (IOException e) {
|
|
99 // TODO Auto-generated catch block
|
|
100 e.printStackTrace();
|
|
101 return;
|
|
102 } catch (CoreException e) {
|
|
103 // TODO Auto-generated catch block
|
|
104 e.printStackTrace();
|
|
105 return;
|
|
106 }
|
|
107 try {
|
|
108 path=im.getImagePath();
|
|
109 } catch (JDOMException e) {
|
|
110 // TODO Auto-generated catch block
|
|
111 e.printStackTrace();
|
|
112 return;
|
|
113 }
|
|
114 if (path==null)
|
|
115 return;
|
|
116 } else {
|
|
117 //TODO: issue warning that type cannot be solved.
|
|
118 return;
|
|
119 }
|
|
120
|
|
121
|
|
122 path=path.replace("/mpiwg/online", "");
|
|
123 DigiImageParameter dp = new DigiImageParameter(path);
|
|
124 dp.setDh(500);
|
|
125 dp.setDw(500);
|
|
126
|
|
127
|
|
128 DigiImage digiImage = new DigiImage(mainComposite, SWT.BORDER, dp);
|
|
129 DigiImageController digiImageController = new DigiImageController(digiImage);
|
|
130 //imageComp.setBackgroundImage(img);
|
24
|
131 new DigiNav(mainComposite,SWT.NONE,digiImageController);
|
1
|
132
|
20
|
133 getSite().setSelectionProvider(digiImage);
|
|
134 digiImage.setSelection(new StructuredSelection(digiImage));
|
|
135
|
1
|
136 sc.setMinSize(mainComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
|
|
137 sc.setExpandHorizontal(true);
|
|
138 sc.setExpandVertical(true);
|
|
139 sc.layout();
|
|
140 DigilibLinkEditorObservable.INSTANCE.addObserver(this);
|
|
141
|
20
|
142 //setSelection( digiImage);
|
1
|
143 }
|
|
144
|
|
145 @Override
|
|
146 public void setFocus() {
|
|
147 // TODO Auto-generated method stub
|
|
148
|
|
149 }
|
|
150
|
|
151 public void update(Observable o, Object arg) {
|
|
152 if (DigiImage.class.isInstance(arg)){
|
|
153 mainComposite.pack();
|
|
154 sc.setMinSize(mainComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
|
|
155 sc.layout();
|
20
|
156
|
|
157
|
|
158 //refresh the property view.
|
|
159 IWorkbenchPage page = getSite().getPage();
|
|
160
|
|
161 IViewPart view = page.findView(IPageLayout.ID_PROP_SHEET);
|
|
162
|
|
163 ((PropertySheetPage)((PropertySheet)view).getCurrentPage()).refresh();
|
1
|
164 //sc.pack();
|
20
|
165
|
1
|
166 } else if (Integer.class.isInstance(arg)){
|
|
167 int b = (Integer) arg;
|
|
168
|
|
169 Cursor waitCursor = new Cursor(mainComposite.getDisplay(),b);
|
|
170 mainComposite.setCursor(waitCursor);
|
|
171
|
|
172 }
|
|
173
|
20
|
174
|
1
|
175 }
|
20
|
176
|
1
|
177
|
|
178
|
|
179 }
|