First stabs at JFace Text functionality. Test TextViewer on NameEditorView divided...
authorp.ciardelli <p.ciardelli@localhost>
Tue, 4 Dec 2007 15:49:52 +0000 (15:49 +0000)
committerp.ciardelli <p.ciardelli@localhost>
Tue, 4 Dec 2007 15:49:52 +0000 (15:49 +0000)
.gitattributes
eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/controller/FullNamePartitionScanner.java [new file with mode: 0644]
eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/controller/FullNameTextViewerConfig.java [new file with mode: 0644]
eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/controller/PropertySheetValueLabelProvider.java
eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/view/CarduusEditorView.java
eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/view/FullNameTextViewer.java [new file with mode: 0644]
eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/view/MultiPageTaxonView.java
eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/view/NameEditorView.java
eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/view/PropertySheetValueEditingSupport.java
eclipseprojects/eu.etaxonomy.taxeditor.prototype2/src/eu/etaxonomy/taxeditor/prototype2/view/PropertySheetViewer.java

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