From 32bf324f54b0b891632fc07dc1d4ccbdb8061486 Mon Sep 17 00:00:00 2001 From: "p.ciardelli" Date: Tue, 4 Dec 2007 15:49:52 +0000 Subject: [PATCH] First stabs at JFace Text functionality. Test TextViewer on NameEditorView divided up into partitions by word; some partitioning, damage repair info syso'ed. --- .gitattributes | 3 + .../controller/FullNamePartitionScanner.java | 79 ++++++++++++ .../controller/FullNameTextViewerConfig.java | 71 +++++++++++ .../PropertySheetValueLabelProvider.java | 2 +- .../prototype2/view/CarduusEditorView.java | 6 +- .../prototype2/view/FullNameTextViewer.java | 115 ++++++++++++++++++ .../prototype2/view/MultiPageTaxonView.java | 8 +- .../prototype2/view/NameEditorView.java | 103 ++++++---------- .../PropertySheetValueEditingSupport.java | 2 +- .../prototype2/view/PropertySheetViewer.java | 8 +- 10 files changed, 321 insertions(+), 76 deletions(-) create mode 100644 eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/controller/FullNamePartitionScanner.java create mode 100644 eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/controller/FullNameTextViewerConfig.java create mode 100644 eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/view/FullNameTextViewer.java diff --git a/.gitattributes b/.gitattributes index 94aa0d009..c6a47b128 100644 --- a/.gitattributes +++ b/.gitattributes @@ -181,6 +181,8 @@ eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/pro eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/ApplicationWorkbenchAdvisor.java -text eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/ApplicationWorkbenchWindowAdvisor.java -text eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/Perspective.java -text +eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/controller/FullNamePartitionScanner.java -text +eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/controller/FullNameTextViewerConfig.java -text eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/controller/OpenNameEditorAction.java -text eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/controller/PropertySheetContentProvider.java -text eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/controller/PropertySheetValueLabelProvider.java -text @@ -193,6 +195,7 @@ eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/pro eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/view/CarduusEditorView.java -text eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/view/EditNameProperties.java -text eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/view/EmptyEditorView.java -text +eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/view/FullNameTextViewer.java -text eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/view/MoveDialogView.java -text eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/view/MultiPageTaxonView.java -text eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/view/MyCompletionProcessor.java -text diff --git a/eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/controller/FullNamePartitionScanner.java b/eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/controller/FullNamePartitionScanner.java new file mode 100644 index 000000000..59065bd55 --- /dev/null +++ b/eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/controller/FullNamePartitionScanner.java @@ -0,0 +1,79 @@ +package eu.etaxonomy.taxeditor.prototype2.controller; + +import org.eclipse.jface.text.rules.ICharacterScanner; +import org.eclipse.jface.text.rules.IPredicateRule; +import org.eclipse.jface.text.rules.IToken; +import org.eclipse.jface.text.rules.IWordDetector; +import org.eclipse.jface.text.rules.RuleBasedPartitionScanner; +import org.eclipse.jface.text.rules.Token; +import org.eclipse.jface.text.rules.WordRule; + +public class FullNamePartitionScanner extends RuleBasedPartitionScanner { + public final static String SINGLE_WORD = "__single_word"; + public final static String[] PARTITION_TYPES = {SINGLE_WORD}; + + public FullNamePartitionScanner() + { + super(); + + IPredicateRule[] rules = new IPredicateRule[1]; + + IToken word = new Token(SINGLE_WORD); + rules[0] = new WordPredicateRule (word); + + setPredicateRules(rules); + } + + class WordPredicateRule extends WordRule implements IPredicateRule { + + private IToken fSuccessToken; + + public WordPredicateRule(IToken successToken) { + super(new IWordDetector() { + + public boolean isWordPart(char c) { + return !Character.isWhitespace(c); + } + + public boolean isWordStart(char c) { + return !Character.isWhitespace(c); + } + + }); + this.fSuccessToken = successToken; + } + + public IToken evaluate(ICharacterScanner scanner, boolean resume) { + return super.evaluate(scanner); + } + + public IToken evaluate(ICharacterScanner scanner) { + + StringBuffer fBuffer= new StringBuffer(); + + int c = scanner.read(); + if (c != ICharacterScanner.EOF && fDetector.isWordStart((char) c)) { + if (fColumn == UNDEFINED || (fColumn == scanner.getColumn() - 1)) { + + fBuffer.setLength(0); + do { + fBuffer.append((char) c); + c= scanner.read(); + } while (c != ICharacterScanner.EOF && fDetector.isWordPart((char) c)); + scanner.unread(); + + return fSuccessToken; + } + } + + scanner.unread(); + return Token.UNDEFINED; + } + + + public IToken getSuccessToken() { + return fSuccessToken; + } + + } +} diff --git a/eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/controller/FullNameTextViewerConfig.java b/eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/controller/FullNameTextViewerConfig.java new file mode 100644 index 000000000..9b843e77f --- /dev/null +++ b/eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/controller/FullNameTextViewerConfig.java @@ -0,0 +1,71 @@ +package eu.etaxonomy.taxeditor.prototype2.controller; + +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.presentation.IPresentationReconciler; +import org.eclipse.jface.text.presentation.PresentationReconciler; +import org.eclipse.jface.text.rules.DefaultDamagerRepairer; +import org.eclipse.jface.text.rules.IToken; +import org.eclipse.jface.text.rules.RuleBasedScanner; +import org.eclipse.jface.text.source.ISourceViewer; +import org.eclipse.jface.text.source.SourceViewerConfiguration; + +public class FullNameTextViewerConfig extends SourceViewerConfiguration { + + /** + * Whenever a change is made to the document, a notification is sent to the + * IPresentationDamager for each content type in the affected area of the document. + * The IPresentationDamager in turn returns an IRegion indicating the area of the + * document which needs to be rebuilt as a result of the change. This information is + * then passed on to the IPresentationRepairer, which is responsible for reapplying + * the textual presentation for the affected region. + * + * This all probably sounds quite complicated. Fortunately you probably won't ever need + * to implement any of these classes yourself. JFace Text provides a + * DefaultDamagerRepairer which does the job both of the IPresentationDamager and the + * IPresentationRepairer. It also provides a PresentationReconciler class which performs + * the co-ordination role we described earlier. + * + * ... + * + * If you understand document partitioning then you are in a very good position to understand + * syntax highlighting in a JFace Text application. Essentially, syntax highlighting involves + * dividing a partition into tokens, each of which has its own text display attributes. The + * standard mechanism for doing this also involves the use of the already familiar tokens, + * scanners and rules. + * + **/ + public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) + { + PresentationReconciler reconciler = new PresentationReconciler(); + + DefaultDamagerRepairer dr = new DefaultDamagerRepairer(new FullNameScanner()); +// reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE); +// reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE); + reconciler.setDamager(dr, FullNamePartitionScanner.SINGLE_WORD); + reconciler.setRepairer(dr, FullNamePartitionScanner.SINGLE_WORD); + + return reconciler; + } + + class FullNameScanner extends RuleBasedScanner { + + IToken currentToken; + + int count = 0; + + public IToken nextToken() + { + IToken token = super.nextToken(); +// if (currentToken == CDATA_START || currentToken == CDATA_TEXT && token != CDATA_END) +// { +// this.currentToken = CDATA_TEXT; +// return CDATA_TEXT; +// } + count++; + if (token.isEOF()) + System.out.println("Count: " + count); + this.currentToken = token; + return token; + } + } +} diff --git a/eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/controller/PropertySheetValueLabelProvider.java b/eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/controller/PropertySheetValueLabelProvider.java index a86b6ce4a..051a13b4f 100644 --- a/eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/controller/PropertySheetValueLabelProvider.java +++ b/eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/controller/PropertySheetValueLabelProvider.java @@ -52,7 +52,7 @@ public class PropertySheetValueLabelProvider extends ColumnLabelProvider { IObservableValue observeNodeValue = ((PropertySheetNode) element).getObserveValue(); if (observeNodeValue != null) { - Assert.isTrue(bindingContext != null, + Assert.isNotNull(bindingContext, "Label provider: PropertySheetViewer's binding context must be explicitly set."); TreeItemColumnAsBean itemColumn = new TreeItemColumnAsBean((TreeItem) cell.getItem(),1); diff --git a/eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/view/CarduusEditorView.java b/eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/view/CarduusEditorView.java index 9e1d53f6d..51c31d8f8 100644 --- a/eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/view/CarduusEditorView.java +++ b/eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/view/CarduusEditorView.java @@ -345,9 +345,9 @@ public class CarduusEditorView extends EditorPart { SourceViewer sourceviewer = new SourceViewer(composite, null, SWT.WRAP | SWT.FULL_SELECTION); sourceviewer.setAnnotationHover(null); styledText = sourceviewer.getTextWidget(); - final GridData gd_styledText = new GridData(SWT.FILL, SWT.TOP, true, false); - gd_styledText.heightHint = 41; - gd_styledText.widthHint = 450; + final GridData gd_styledText = new GridData(SWT.FILL, SWT.FILL, true, true); +// gd_styledText.heightHint = 41; +// gd_styledText.widthHint = 450; styledText.setLayoutData(gd_styledText); sourceviewer.setDocument(doc); sourceviewer.configure(new MySourceViewerConfig()); diff --git a/eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/view/FullNameTextViewer.java b/eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/view/FullNameTextViewer.java new file mode 100644 index 000000000..0aa4bd46f --- /dev/null +++ b/eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/view/FullNameTextViewer.java @@ -0,0 +1,115 @@ +package eu.etaxonomy.taxeditor.prototype2.view; + +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.Document; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.IDocumentPartitioner; +import org.eclipse.jface.text.ITypedRegion; +import org.eclipse.jface.text.rules.FastPartitioner; +import org.eclipse.jface.text.rules.IPartitionTokenScanner; +import org.eclipse.jface.text.rules.RuleBasedPartitionScanner; +import org.eclipse.jface.text.source.SourceViewer; +import org.eclipse.swt.widgets.Composite; + +import eu.etaxonomy.taxeditor.prototype2.controller.FullNamePartitionScanner; + +/** + * Creates zero-length partitions for Genus, Specific Epithet, etc., then fills them + * as data is added. + * + * Partitions are databound to their respective model properties. + * + * @author p.ciardelli + * + */ +public class FullNameTextViewer extends SourceViewer { + + FullNameTextViewer(Composite parent, int styles) { + super(parent, null, styles); // null -> no vertical ruler + + final Document document = new Document("word1 'asdf' {asdfn} eiuakljnp word3\nlkasdjflkajsdf\n"); + + // replacing call to FullNamePartitionScanner because all we want i + final IDocumentPartitioner partitioner = new NamePartitioner( + new FullNamePartitionScanner(), FullNamePartitionScanner.PARTITION_TYPES); +// final IDocumentPartitioner partitioner = new NamePartitioner( +// new RuleBasedPartitionScanner(), new String[] {}); + + partitioner.connect(document); + document.setDocumentPartitioner(partitioner); + this.setDocument(document); // put this back in nameeditorview so that it functions more like TextViewer + +// this.getControl().addKeyListener(new KeyListener() { +// +// public void keyPressed(KeyEvent e) { +// ((NamePartitioner) partitioner).printPartitions(document); +// +// } +// +// public void keyReleased(KeyEvent e) { +// // TODO Auto-generated method stub +// +// } +// +// }); + + }; + + class NamePartitioner extends FastPartitioner { + + public ITypedRegion[] computePartitioning(int offset, int length, boolean includeZeroLengthPartitions) { + + // shows that only current partition is sent to computePartitioning + System.out.println("offset:" + offset + ", length: " + length); + + // how can i detect a new partition? + // when i'm inside a token, compute partitioning does not get called + + ITypedRegion[] regions = super.computePartitioning(offset, length, includeZeroLengthPartitions); + System.out.println("partitions: " + regions.length); + System.out.println("----------------------------------"); + + return regions; + } + + public NamePartitioner(IPartitionTokenScanner scanner, + String[] legalContentTypes) { + super(scanner, legalContentTypes); + } + + public void connect(IDocument document, boolean delayInitialise) + { + super.connect(document, delayInitialise); + printPartitions(document); + } + + public void printPartitions(IDocument document) { + StringBuffer buffer = new StringBuffer(); + + ITypedRegion[] partitions = computePartitioning(0, document.getLength()); + int wordcount = 0; + for (int i = 0; i < partitions.length; i++) { + try { + if (partitions[i].getType() == FullNamePartitionScanner.SINGLE_WORD) + wordcount++; + buffer.append("Partition type: " + + partitions[i].getType() + + ", offset: " + partitions[i].getOffset() + + ", length: " + partitions[i].getLength()); + buffer.append("\n"); + buffer.append("Text:\n"); + buffer.append(document.get(partitions[i].getOffset(), + partitions[i].getLength())); + buffer.append("\n---------------------------\n\n\n"); + } catch (BadLocationException e) { + e.printStackTrace(); + } + } + buffer.append("Word partitions: " + wordcount); + System.out.print(buffer); + } + + } + + +} diff --git a/eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/view/MultiPageTaxonView.java b/eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/view/MultiPageTaxonView.java index eb46659b0..89113df11 100644 --- a/eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/view/MultiPageTaxonView.java +++ b/eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/view/MultiPageTaxonView.java @@ -76,13 +76,7 @@ public class MultiPageTaxonView extends MultiPageEditorPart { taxonname = null; } -// setPartName(taxonname.getName()); - - bindingContext = new DataBindingContext(); - bindingContext.bindValue( BeansObservables.observeValue(this,"partName"), - BeansObservables.observeValue(taxonname,"name"), - null, null); - + setPartName(taxonname.getName()); setSite(site); setInput(input); } diff --git a/eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/view/NameEditorView.java b/eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/view/NameEditorView.java index 5d22035cf..982927894 100644 --- a/eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/view/NameEditorView.java +++ b/eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/view/NameEditorView.java @@ -46,6 +46,7 @@ import com.swtdesigner.SWTResourceManager; import eu.etaxonomy.cdm.model.name.TaxonName; import eu.etaxonomy.taxeditor.prototype2.model.PropertySheetNode; import eu.etaxonomy.taxeditor.prototype2.view.MySourceViewerConfig; +import eu.etaxonomy.taxeditor.prototype2.controller.FullNameTextViewerConfig; import eu.etaxonomy.taxeditor.prototype2.controller.PropertySheetContentProvider; import eu.etaxonomy.taxeditor.prototype2.controller.PropertySheetValueLabelProvider; import eu.etaxonomy.taxeditor.prototype2.controller.SaveNameAction; @@ -135,7 +136,7 @@ public class NameEditorView extends EditorPart { // } // }); parent.setLayout(new GridLayout()); - Document doc = new Document(""); + final Label taxonomicallyIncludedInLabel = new Label(parent, SWT.NONE); taxonomicallyIncludedInLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); @@ -307,7 +308,7 @@ public class NameEditorView extends EditorPart { clickHereToText.setForeground(SWTResourceManager.getColor(192, 192, 192)); clickHereToText.setText(clickText); clickHereToText.setFont(SWTResourceManager.getFont("Georgia", 12, SWT.ITALIC)); - final GridData gd_clickHereToText = new GridData(SWT.FILL, SWT.CENTER, true, false); + final GridData gd_clickHereToText = new GridData(SWT.FILL, SWT.FILL, true, true); gd_clickHereToText.widthHint = 426; clickHereToText.setLayoutData(gd_clickHereToText); clickHereToText.addFocusListener(new FocusListener() { @@ -337,6 +338,7 @@ public class NameEditorView extends EditorPart { }); + // Construct PropertySheetViewer, with bindings to model layer PropertySheetViewer propertySheetViewer = new PropertySheetViewer(composite); propertySheetViewer.setBindingContext(bindingContext); @@ -348,67 +350,53 @@ public class NameEditorView extends EditorPart { new PropertySheetValueEditingSupport(propertySheetViewer)); propertySheetViewer.setInput(getPropertySheetNodes(taxonname)); + + // Construct name field(s) + FullNameTextViewer acceptedNameViewer = new FullNameTextViewer(composite, SWT.BORDER | SWT.WRAP | SWT.FULL_SELECTION | SWT.FILL); + acceptedNameViewer.getTextWidget().setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); + acceptedNameViewer.configure(new FullNameTextViewerConfig()); -// clickHereToText.addKeyListener(new KeyListener() { -// -// public void keyPressed(KeyEvent e) { -// dirtyBoy = true; -// isDirty(); -// -// } -// -// public void keyReleased(KeyEvent e) { -// // TODO Auto-generated method stub -// -// } -// -// }); - - //container.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY)); - - SourceViewer sourceviewer = new SourceViewer(composite, null, SWT.WRAP | SWT.FULL_SELECTION); - sourceviewer.setAnnotationHover(null); - styledText = sourceviewer.getTextWidget(); - final GridData gd_styledText = new GridData(SWT.FILL, SWT.TOP, true, false); - gd_styledText.heightHint = 41; - gd_styledText.widthHint = 450; - styledText.setLayoutData(gd_styledText); - sourceviewer.setDocument(doc); - sourceviewer.configure(new MySourceViewerConfig()); - sourceviewer.setTabsToSpacesConverter(null); +// SourceViewer sourceviewer = new SourceViewer(composite, null, SWT.BORDER | SWT.WRAP | SWT.FULL_SELECTION); +// sourceviewer.setAnnotationHover(null); +// styledText = sourceviewer.getTextWidget(); +// final GridData gd_styledText = new GridData(SWT.FILL, SWT.TOP, true, false); +// gd_styledText.heightHint = 41; +// gd_styledText.widthHint = 450; +// styledText.setLayoutData(gd_styledText); +// sourceviewer.setDocument(doc); +// sourceviewer.configure(new MySourceViewerConfig()); +// sourceviewer.setTabsToSpacesConverter(null); - populateForm(); + populateForm(); // will this be necessary if databinding is correctly set up? Text testeroo = new Text(composite, SWT.BORDER); testeroo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); bindingContext.bindValue( SWTObservables.observeText(testeroo, SWT.Modify), BeansObservables.observeValue(taxonname,"genus"), - null, null); + null, null); + + +// clickHereToText.addKeyListener(new KeyListener() { + // +// public void keyPressed(KeyEvent e) { +// dirtyBoy = true; +// isDirty(); +// +// } + // +// public void keyReleased(KeyEvent e) { +// // TODO Auto-generated method stub +// +// } +// +// }); + + //container.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY)); + } -// private void populateForm() { -// -// String fulltext = ""; -// -// if (taxonname.getGenus() != null) { -// fulltext = taxonname.getGenus(); -// } -// -// if (taxonname.getSpecificEpithet() != null) { -// fulltext += " " + taxonname.getSpecificEpithet(); -// } -// -// if (taxonname.getAuthorship() != null) { -// fulltext += " " + taxonname.getAuthorship(); -// } -// -//// txtPlay.setText(fulltext); -//// txtPlay.setToolTipText("Joe mama\njoe daddy\njoe gramammy"); -// -// this.setPartName(taxonname.getName()); -// } private void populateForm() { this.setPartName(taxonname.getName()); @@ -470,17 +458,6 @@ public class NameEditorView extends EditorPart { public boolean isSaveAsAllowed() { return false; } - - public void propertyChange(PropertyChangeEvent evt) { - this.taxonname = (TaxonName)evt.getNewValue(); - System.out.println(((TaxonName)evt.getNewValue()).getName()); - populateForm(); - - // for individual fields, do something like: - // if (evt.getPropertyName().equalsIgnoreCase("genus")) - // txtGenus.setText ... - } - private static void addDropDown(final ToolItem item, final Menu menu) { item.addListener(SWT.Selection, new Listener() { diff --git a/eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/view/PropertySheetValueEditingSupport.java b/eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/view/PropertySheetValueEditingSupport.java index 149fffe5e..749d0d36d 100644 --- a/eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/view/PropertySheetValueEditingSupport.java +++ b/eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/view/PropertySheetValueEditingSupport.java @@ -56,7 +56,7 @@ public class PropertySheetValueEditingSupport extends EditingSupport { IObservableValue observeNodeValue = node.getObserveValue(); if (observeNodeValue != null) { - Assert.isTrue(bindingContext != null, + Assert.isNotNull(bindingContext, "Editing support: PropertySheetViewer's binding context must be explicitly set."); IObservableValue observeCellValue = SWTObservables.observeText(cellEditor.getControl(), SWT.Modify); diff --git a/eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/view/PropertySheetViewer.java b/eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/view/PropertySheetViewer.java index 98213187c..c8e8014f0 100644 --- a/eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/view/PropertySheetViewer.java +++ b/eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/view/PropertySheetViewer.java @@ -10,6 +10,7 @@ import org.eclipse.jface.viewers.ViewerLabel; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.TreeColumn; import eu.etaxonomy.taxeditor.prototype2.model.PropertySheetNode; @@ -34,7 +35,7 @@ public class PropertySheetViewer extends TreeViewer { this.getTree().setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, true)); this.getTree().setLinesVisible(true); this.getTree().setHeaderVisible(false); - this.getTree().setSize(200, 300); + this.getTree().getVerticalBar().setEnabled(true); // create a column for property fields propertyFieldColumn = new TreeViewerColumn(this, SWT.NONE); @@ -50,6 +51,11 @@ public class PropertySheetViewer extends TreeViewer { propertyValueColumn = new TreeViewerColumn(this, SWT.NONE); propertyValueColumn.getColumn().setWidth(100); propertyValueColumn.getColumn().setMoveable(true); + + this.getTree().setSize(150, 300); +// propertyFieldColumn.getColumn().pack(); +// propertyValueColumn.getColumn().pack(); +// this.getTree().redraw(); } public TreeViewerColumn getPropertyFieldColumn() { -- 2.34.1