1
|
1 package de.mpg.mpiwg.itgroup.digilib.plugin.editors;
|
|
2
|
|
3
|
9
|
4 import info.textgrid.lab.linkeditor.mip.gui.ImagePanel;
|
|
5
|
1
|
6 import java.io.IOException;
|
|
7 import java.net.URL;
|
20
|
8 import java.util.ArrayList;
|
|
9 import java.util.List;
|
1
|
10 import java.util.Observable;
|
|
11 import java.util.Observer;
|
|
12
|
20
|
13 import org.apache.axis2.databinding.types.soapencoding.Array;
|
1
|
14 import org.eclipse.core.resources.IResourceChangeEvent;
|
|
15 import org.eclipse.core.resources.IResourceChangeListener;
|
|
16 import org.eclipse.core.runtime.CoreException;
|
|
17 import org.eclipse.core.runtime.IProgressMonitor;
|
20
|
18 import org.eclipse.jface.viewers.ISelection;
|
|
19 import org.eclipse.jface.viewers.ISelectionChangedListener;
|
|
20 import org.eclipse.jface.viewers.ISelectionProvider;
|
|
21 import org.eclipse.jface.viewers.SelectionChangedEvent;
|
|
22 import org.eclipse.jface.viewers.StructuredSelection;
|
1
|
23 import org.eclipse.swt.SWT;
|
|
24 import org.eclipse.swt.custom.ScrolledComposite;
|
|
25 import org.eclipse.swt.graphics.Cursor;
|
|
26 import org.eclipse.swt.layout.GridLayout;
|
|
27 import org.eclipse.swt.widgets.Composite;
|
|
28 import org.eclipse.ui.IEditorInput;
|
|
29 import org.eclipse.ui.IEditorSite;
|
20
|
30 import org.eclipse.ui.IPageLayout;
|
|
31 import org.eclipse.ui.IViewPart;
|
|
32 import org.eclipse.ui.IWorkbenchPage;
|
|
33 import org.eclipse.ui.IWorkbenchPartSite;
|
1
|
34 import org.eclipse.ui.PartInitException;
|
|
35 import org.eclipse.ui.part.EditorPart;
|
20
|
36 import org.eclipse.ui.views.properties.IPropertySheetPage;
|
|
37 import org.eclipse.ui.views.properties.PropertySheet;
|
|
38 import org.eclipse.ui.views.properties.PropertySheetPage;
|
1
|
39 import org.jdom.JDOMException;
|
|
40
|
|
41 import de.mpg.mpiwg.itgroup.digilib.digiImage.DigiImage;
|
|
42 import de.mpg.mpiwg.itgroup.digilib.digiImage.DigiImageController;
|
|
43 import de.mpg.mpiwg.itgroup.digilib.digiImage.DigiImageParameter;
|
|
44 import de.mpg.mpiwg.itgroup.digilib.digiImage.DigiNav;
|
|
45 import de.mpg.mpiwg.itgroup.indexMeta.Utils.ParseIndexMeta;
|
|
46
|
|
47 /**
|
9
|
48 * Displays an image with digilib an allows image manipulation on the image.
|
1
|
49 *
|
|
50 * @author dwinter
|
|
51 *
|
|
52 */
|
20
|
53 public class DigilibLinkEditorPart extends EditorPart implements IResourceChangeListener,Observer{
|
1
|
54
|
|
55 private Composite mainComposite;
|
|
56 private ScrolledComposite sc;
|
20
|
57 //private ISelection selection;
|
|
58 //private List<ISelectionChangedListener> selectionChangeListener = new ArrayList<ISelectionChangedListener>();
|
|
59 private Object propertySheetPage;
|
1
|
60
|
|
61 public void resourceChanged(IResourceChangeEvent event) {
|
|
62 // TODO Auto-generated method stub
|
|
63
|
|
64 }
|
|
65
|
|
66 @Override
|
|
67 public void doSave(IProgressMonitor monitor) {
|
|
68 // TODO Auto-generated method stub
|
|
69
|
|
70 }
|
|
71
|
|
72 @Override
|
|
73 public void doSaveAs() {
|
|
74 // TODO Auto-generated method stub
|
|
75
|
|
76 }
|
|
77
|
|
78 @Override
|
|
79 public void init(IEditorSite site, IEditorInput input)
|
|
80 throws PartInitException {
|
|
81 setInput(input);
|
|
82 setSite(site);
|
|
83
|
|
84 }
|
|
85
|
|
86 @Override
|
|
87 public boolean isDirty() {
|
|
88 // TODO Auto-generated method stub
|
|
89 return false;
|
|
90 }
|
|
91
|
|
92 @Override
|
|
93 public boolean isSaveAsAllowed() {
|
|
94 // TODO Auto-generated method stub
|
|
95 return false;
|
|
96 }
|
|
97
|
|
98 @Override
|
|
99 public void createPartControl(Composite frame) {
|
|
100
|
|
101 sc = new ScrolledComposite(frame, SWT.H_SCROLL | SWT.V_SCROLL);
|
|
102 mainComposite = new Composite(sc,SWT.None);
|
|
103
|
|
104 GridLayout imageLayout = new GridLayout(2,false);
|
|
105 mainComposite.setLayout(imageLayout);
|
|
106 sc.setContent(mainComposite);
|
|
107 //sc.setMinSize(400, 400);
|
|
108
|
9
|
109
|
1
|
110
|
|
111 DigilibLinkEditorInput input= (DigilibLinkEditorInput) getEditorInput();
|
|
112 String path="";
|
|
113 if (input.getType()==DigilibLinkEditorInput.INDEX_META){
|
|
114 ParseIndexMeta im;
|
|
115 try {
|
9
|
116 im = new ParseIndexMeta(input.getFile());
|
1
|
117 } catch (JDOMException e) {
|
|
118 // TODO Auto-generated catch block
|
|
119 e.printStackTrace();
|
|
120 return;
|
|
121 } catch (IOException e) {
|
|
122 // TODO Auto-generated catch block
|
|
123 e.printStackTrace();
|
|
124 return;
|
|
125 } catch (CoreException e) {
|
|
126 // TODO Auto-generated catch block
|
|
127 e.printStackTrace();
|
|
128 return;
|
|
129 }
|
|
130 try {
|
|
131 path=im.getImagePath();
|
|
132 } catch (JDOMException e) {
|
|
133 // TODO Auto-generated catch block
|
|
134 e.printStackTrace();
|
|
135 return;
|
|
136 }
|
|
137 if (path==null)
|
|
138 return;
|
|
139 } else {
|
|
140 //TODO: issue warning that type cannot be solved.
|
|
141 return;
|
|
142 }
|
|
143
|
|
144
|
|
145 path=path.replace("/mpiwg/online", "");
|
|
146 DigiImageParameter dp = new DigiImageParameter(path);
|
|
147 dp.setDh(500);
|
|
148 dp.setDw(500);
|
|
149
|
|
150
|
|
151 DigiImage digiImage = new DigiImage(mainComposite, SWT.BORDER, dp);
|
|
152 DigiImageController digiImageController = new DigiImageController(digiImage);
|
|
153 //imageComp.setBackgroundImage(img);
|
9
|
154 DigiNav digiNav = new DigiNav(mainComposite,SWT.NONE,digiImageController);
|
1
|
155
|
20
|
156 getSite().setSelectionProvider(digiImage);
|
|
157 digiImage.setSelection(new StructuredSelection(digiImage));
|
|
158
|
1
|
159 sc.setMinSize(mainComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
|
|
160 sc.setExpandHorizontal(true);
|
|
161 sc.setExpandVertical(true);
|
|
162 sc.layout();
|
|
163 DigilibLinkEditorObservable.INSTANCE.addObserver(this);
|
|
164
|
20
|
165 //setSelection( digiImage);
|
1
|
166 }
|
|
167
|
|
168 @Override
|
|
169 public void setFocus() {
|
|
170 // TODO Auto-generated method stub
|
|
171
|
|
172 }
|
|
173
|
|
174 public void update(Observable o, Object arg) {
|
|
175 if (DigiImage.class.isInstance(arg)){
|
|
176 mainComposite.pack();
|
|
177 sc.setMinSize(mainComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
|
|
178 sc.layout();
|
20
|
179
|
|
180
|
|
181 //refresh the property view.
|
|
182 IWorkbenchPage page = getSite().getPage();
|
|
183
|
|
184 IViewPart view = page.findView(IPageLayout.ID_PROP_SHEET);
|
|
185
|
|
186 ((PropertySheetPage)((PropertySheet)view).getCurrentPage()).refresh();
|
1
|
187 //sc.pack();
|
20
|
188
|
1
|
189 } else if (Integer.class.isInstance(arg)){
|
|
190 int b = (Integer) arg;
|
|
191
|
|
192 Cursor waitCursor = new Cursor(mainComposite.getDisplay(),b);
|
|
193 mainComposite.setCursor(waitCursor);
|
|
194
|
|
195
|
|
196 }
|
|
197
|
20
|
198
|
1
|
199 }
|
20
|
200
|
|
201 // public void addSelectionChangedListener(ISelectionChangedListener listener) {
|
|
202 // selectionChangeListener.add(listener);
|
|
203 //
|
|
204 // }
|
|
205 //
|
|
206 // public ISelection getSelection() {
|
|
207 // // TODO Auto-generated method stub
|
|
208 // return selection;
|
|
209 // }
|
|
210 //
|
|
211 // public void removeSelectionChangedListener(
|
|
212 // ISelectionChangedListener listener) {
|
|
213 // selectionChangeListener.remove(listener);
|
|
214 //
|
|
215 // }
|
|
216 //
|
|
217 // public void setSelection(ISelection selection) {
|
|
218 // this.selection=selection;
|
|
219 // for (ISelectionChangedListener sl: selectionChangeListener){
|
|
220 //
|
|
221 // SelectionChangedEvent event = new SelectionChangedEvent(this, selection);
|
|
222 // sl.selectionChanged(event);
|
|
223 // }
|
|
224 //
|
|
225 // }
|
1
|
226
|
|
227
|
|
228
|
|
229 }
|