p2izing the editor
[taxeditor.git] / eclipseprojects / eu.etaxonomy.taxeditor.prototype2 / src / eu / etaxonomy / taxeditor / prototype2 / view / MultiPageTaxonView.java
1 package eu.etaxonomy.taxeditor.prototype2.view;
2
3 import java.beans.PropertyChangeEvent;
4 import java.beans.PropertyChangeListener;
5
6 import org.eclipse.core.runtime.IProgressMonitor;
7 import org.eclipse.ui.IEditorInput;
8 import org.eclipse.ui.IEditorSite;
9 import org.eclipse.ui.PartInitException;
10 import org.eclipse.ui.part.MultiPageEditorPart;
11
12 import eu.etaxonomy.cdm.model.taxon.Taxon;
13
14 /**
15 *
16 * Generates the tabbed editor with Name view on top and tabs for
17 * "Facts", "Specimen", "Geography", etc.
18 *
19 * @author p.ciardelli
20 *
21 */
22 public class MultiPageTaxonView extends MultiPageEditorPart {
23
24 public static final String ID = "eu.etaxonomy.taxeditor.prototype2.view.multipagetaxonview";
25 private Taxon taxon;
26
27 @Override
28 protected void createPages() {
29
30 try {
31 addPage(0, new NameEditorView(), getEditorInput());
32 setPageText(0, "Name");
33
34 addPage(1, new NameEditorView(), getEditorInput());
35 setPageText(1, "Descriptive");
36
37 addPage(2, new NameEditorView(), getEditorInput());
38 setPageText(2, "Concepts");
39
40 addPage(3, new NameEditorView(), getEditorInput());
41 setPageText(3, "Geographic");
42
43 } catch (PartInitException e) {
44 // TODO Auto-generated catch block
45 e.printStackTrace();
46 }
47
48 // bindPartName();
49 }
50
51 @Override
52 public void doSave(IProgressMonitor monitor) {
53 // TODO Auto-generated method stub
54
55 }
56
57 @Override
58 public void doSaveAs() {
59 // TODO Auto-generated method stub
60
61 }
62
63 @Override
64 public boolean isSaveAsAllowed() {
65 // TODO Auto-generated method stub
66 return false;
67 }
68
69 @Override
70 public void init(IEditorSite site, IEditorInput input) throws PartInitException {
71
72 if (!(input instanceof IEditorInput))
73 throw new PartInitException(
74 "Invalid Input: Must be IFileEditorInput");
75
76 // Get taxon from editor input
77 if (input.getAdapter(Taxon.class) != null) {
78 taxon = (Taxon) input.getAdapter(Taxon.class);
79 } else {
80 taxon = null;
81 }
82
83 // Listen for name changes fired when taxon is saved;
84 // change tab for this taxon editor accordingly
85 taxon.addPropertyChangeListener("name", new PropertyChangeListener() {
86 public void propertyChange(PropertyChangeEvent e) {
87 setPartName(taxon.getName().getTitleCache());
88 }
89 });
90
91 // Any taxon that has been saved will by necessity have a name;
92 // only a new taxon will not
93 if (taxon.getName().getTitleCache() == null)
94 setPartName("New taxon");
95 else
96 setPartName(taxon.getName().getTitleCache());
97
98 setSite(site);
99 setInput(input);
100 }
101 }