eb46659b062d3f7ef4a890dc9259956df0a38cc4
[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 org.eclipse.core.databinding.DataBindingContext;
4 import org.eclipse.core.databinding.beans.BeansObservables;
5 import org.eclipse.core.runtime.IProgressMonitor;
6 import org.eclipse.ui.IEditorInput;
7 import org.eclipse.ui.IEditorSite;
8 import org.eclipse.ui.PartInitException;
9 import org.eclipse.ui.part.MultiPageEditorPart;
10
11 import eu.etaxonomy.cdm.model.name.TaxonName;
12
13 /**
14 *
15 * Generates the tabbed editor with Name view on top and tabs for
16 * "Facts", "Specimen", "Geography", etc.
17 *
18 * @author p.ciardelli
19 *
20 */
21 public class MultiPageTaxonView extends MultiPageEditorPart {
22
23 public static final String ID = "eu.etaxonomy.taxeditor.prototype2.view.multipagetaxonview";
24 private TaxonName taxonname;
25 private DataBindingContext bindingContext;
26
27 @Override
28 protected void createPages() {
29 try {
30 addPage(0, new NameEditorView(), getEditorInput());
31 setPageText(0, "Name");
32
33 // addPage(1, new EmptyEditorView(), new NameEditorInput(new TaxonName()));
34 // setPageText(1, "Facts");
35 //
36 // addPage(2, new EmptyEditorView(), new NameEditorInput(new TaxonName()));
37 // setPageText(2, "Specimen");
38 //
39 // addPage(3, new EmptyEditorView(), new NameEditorInput(new TaxonName()));
40 // setPageText(3, "Geographic");
41
42 } catch (PartInitException e) {
43 // TODO Auto-generated catch block
44 e.printStackTrace();
45 }
46 }
47
48 @Override
49 public void doSave(IProgressMonitor monitor) {
50 // TODO Auto-generated method stub
51
52 }
53
54 @Override
55 public void doSaveAs() {
56 // TODO Auto-generated method stub
57
58 }
59
60 @Override
61 public boolean isSaveAsAllowed() {
62 // TODO Auto-generated method stub
63 return false;
64 }
65
66 @Override
67 public void init(IEditorSite site, IEditorInput input) throws PartInitException {
68
69 if (!(input instanceof IEditorInput))
70 throw new PartInitException(
71 "Invalid Input: Must be IFileEditorInput");
72
73 if (input.getAdapter(TaxonName.class) != null) {
74 taxonname = (TaxonName) input.getAdapter(TaxonName.class);
75 } else {
76 taxonname = null;
77 }
78
79 // setPartName(taxonname.getName());
80
81 bindingContext = new DataBindingContext();
82 bindingContext.bindValue( BeansObservables.observeValue(this,"partName"),
83 BeansObservables.observeValue(taxonname,"name"),
84 null, null);
85
86 setSite(site);
87 setInput(input);
88 }
89 }