Mercurial > hg > de.mpg.mpiwg.itgroup.digilib.core
comparison src/de/mpg/mpiwg/itgroup/digilib/digiImage/properties/DigiImagePropertySection.java @ 26:183c3e96f6c3
cleaned code
author | dwinter |
---|---|
date | Mon, 10 Jan 2011 12:01:25 +0100 |
parents | 6e7bb3467531 |
children | fbcf122a6a24 |
comparison
equal
deleted
inserted
replaced
25:6e7bb3467531 | 26:183c3e96f6c3 |
---|---|
1 package de.mpg.mpiwg.itgroup.digilib.digiImage.properties; | 1 package de.mpg.mpiwg.itgroup.digilib.digiImage.properties; |
2 | 2 |
3 import java.util.ArrayList; | |
4 import java.util.HashMap; | 3 import java.util.HashMap; |
5 import java.util.List; | |
6 import java.util.Map; | 4 import java.util.Map; |
7 | 5 |
8 import org.eclipse.jface.viewers.ISelection; | 6 import org.eclipse.jface.viewers.ISelection; |
9 import org.eclipse.jface.viewers.IStructuredSelection; | 7 import org.eclipse.jface.viewers.IStructuredSelection; |
10 import org.eclipse.swt.SWT; | 8 import org.eclipse.swt.SWT; |
11 import org.eclipse.swt.custom.CLabel; | 9 import org.eclipse.swt.custom.CLabel; |
12 import org.eclipse.swt.events.ModifyEvent; | |
13 import org.eclipse.swt.events.ModifyListener; | 10 import org.eclipse.swt.events.ModifyListener; |
14 import org.eclipse.swt.layout.FormAttachment; | 11 import org.eclipse.swt.layout.FormAttachment; |
15 import org.eclipse.swt.layout.FormData; | 12 import org.eclipse.swt.layout.FormData; |
16 import org.eclipse.swt.layout.GridLayout; | 13 import org.eclipse.swt.layout.GridLayout; |
17 import org.eclipse.swt.widgets.Button; | 14 import org.eclipse.swt.widgets.Button; |
18 import org.eclipse.swt.widgets.Composite; | 15 import org.eclipse.swt.widgets.Composite; |
19 import org.eclipse.swt.widgets.Table; | |
20 import org.eclipse.swt.widgets.Text; | 16 import org.eclipse.swt.widgets.Text; |
21 import org.eclipse.ui.IWorkbenchPart; | 17 import org.eclipse.ui.IWorkbenchPart; |
22 import org.eclipse.ui.views.properties.IPropertySource; | 18 import org.eclipse.ui.views.properties.IPropertySource; |
23 import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection; | 19 import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection; |
24 import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants; | 20 import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants; |
25 import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; | 21 import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; |
26 import org.eclipse.jface.util.Assert; | |
27 | 22 |
28 import de.mpg.mpiwg.itgroup.digilib.digiImage.DigiImage; | 23 import de.mpg.mpiwg.itgroup.digilib.digiImage.DigiImage; |
29 import de.mpg.mpiwg.itgroup.digilib.digiImage.DigiImageParameter; | 24 import de.mpg.mpiwg.itgroup.digilib.digiImage.DigiImageParameter; |
30 | 25 |
26 /** | |
27 * @author dwinter | |
28 * Shows the properties of a digiImage | |
29 * | |
30 */ | |
31 public class DigiImagePropertySection extends AbstractPropertySection { | 31 public class DigiImagePropertySection extends AbstractPropertySection { |
32 | 32 |
33 private DigiImage digiImage; | 33 private DigiImage digiImage; |
34 private Map<String,Text> texts = new HashMap<String,Text>(); | 34 private Map<String,Text> texts = new HashMap<String,Text>(); |
35 | 35 |
36 | 36 |
37 private Map<String,ModifyListener> listeners = new HashMap<String,ModifyListener>(); | 37 private Map<String,ModifyListener> listeners = new HashMap<String,ModifyListener>(); |
38 private Button button; | 38 private Button button; |
39 | 39 |
40 | 40 |
41 | |
42 | 41 |
43 | 42 /* (non-Javadoc) |
44 | 43 * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#createControls(org.eclipse.swt.widgets.Composite, org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage) |
44 */ | |
45 public void createControls(Composite parent, | 45 public void createControls(Composite parent, |
46 TabbedPropertySheetPage aTabbedPropertySheetPage) { | 46 TabbedPropertySheetPage aTabbedPropertySheetPage) { |
47 super.createControls(parent, aTabbedPropertySheetPage); | 47 super.createControls(parent, aTabbedPropertySheetPage); |
48 | 48 |
49 DigiImageParameter dp = new DigiImageParameter(""); | 49 DigiImageParameter dp = new DigiImageParameter(""); |
77 .createFlatFormComposite(parent); | 77 .createFlatFormComposite(parent); |
78 button = getWidgetFactory().createButton(composite, "redraw", SWT.None); | 78 button = getWidgetFactory().createButton(composite, "redraw", SWT.None); |
79 | 79 |
80 } | 80 } |
81 | 81 |
82 /* (non-Javadoc) | |
83 * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#setInput(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) | |
84 */ | |
82 public void setInput(IWorkbenchPart part, ISelection selection) { | 85 public void setInput(IWorkbenchPart part, ISelection selection) { |
83 super.setInput(part, selection); | 86 super.setInput(part, selection); |
84 | 87 |
85 Assert.isTrue(selection instanceof IStructuredSelection); | 88 //Assert.isTrue(selection instanceof IStructuredSelection); |
89 assert (IStructuredSelection.class.isInstance(selection)==true) : "wrong instance type"; | |
90 | |
86 Object input = ((IStructuredSelection) selection).getFirstElement(); | 91 Object input = ((IStructuredSelection) selection).getFirstElement(); |
87 Assert.isTrue(input instanceof DigiImage); | 92 //Assert.isTrue(input instanceof DigiImage); |
93 | |
94 assert (DigiImage.class.isInstance(input)==true) : "wrong instance type for input"; | |
88 this.digiImage = (DigiImage) input; | 95 this.digiImage = (DigiImage) input; |
89 | 96 |
90 Map<String, String> pms = digiImage.getParameter().createMapFromParameters(null); | 97 //Map<String, String> pms = digiImage.getParameter().createMapFromParameters(null); |
91 | 98 |
92 for(String key: digiImage.getParameter().createMapFromParameters(null).keySet()){ | 99 for(String key: digiImage.getParameter().createMapFromParameters(null).keySet()){ |
93 | 100 |
94 | 101 |
95 ModifyListener listener = new PropertyListener(key,digiImage); | 102 ModifyListener listener = new DigiImagePropertyListener(key,digiImage); |
96 | 103 |
97 texts.get(key).addModifyListener(listener); | 104 texts.get(key).addModifyListener(listener); |
98 listeners.put(key, listener); | 105 listeners.put(key, listener); |
99 } | 106 } |
100 button.addMouseListener(new RedrawButtonListener(digiImage,texts)); | 107 button.addMouseListener(new RedrawButtonListener(digiImage,texts)); |
101 | 108 |
102 } | 109 } |
103 | 110 |
111 /* (non-Javadoc) | |
112 * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#refresh() | |
113 */ | |
104 public void refresh() { | 114 public void refresh() { |
105 | 115 |
106 DigiImageProperties properties = (DigiImageProperties) digiImage | 116 DigiImageProperties properties = (DigiImageProperties) digiImage |
107 .getAdapter(IPropertySource.class); | 117 .getAdapter(IPropertySource.class); |
108 | 118 |
116 | 126 |
117 } | 127 } |
118 super.refresh(); | 128 super.refresh(); |
119 } | 129 } |
120 | 130 |
121 @Override | 131 |
122 public void aboutToBeShown() { | |
123 System.out.println("about to be shown"); | |
124 | |
125 | |
126 super.aboutToBeShown(); | |
127 } | |
128 } | 132 } |