[brailleblaster] [brailleblaster.newdesign] push by brandon....@xxxxxxxxx - Added Progress Bar on 2013-05-21 19:28 GMT

  • From: brailleblaster@xxxxxxxxxxxxxx
  • To: brailleblaster@xxxxxxxxxxxxx
  • Date: Tue, 21 May 2013 19:28:51 +0000

Revision: 503a8f9edcdf
Branch:   default
Author:   Brandon Roller <brandon.r.roller@xxxxxxxxx>
Date:     Tue May 21 12:26:32 2013
Log:      Added Progress Bar
http://code.google.com/p/brailleblaster/source/detail?r=503a8f9edcdf&repo=newdesign

Modified:
 /src/main/org/brailleblaster/abstractClasses/AbstractView.java
 /src/main/org/brailleblaster/mapping/MapList.java
 /src/main/org/brailleblaster/views/TextView.java
 /src/main/org/brailleblaster/views/TreeView.java
 /src/main/org/brailleblaster/wordprocessor/BBDocument.java
 /src/main/org/brailleblaster/wordprocessor/BBEvent.java
 /src/main/org/brailleblaster/wordprocessor/BBStatusBar.java
 /src/main/org/brailleblaster/wordprocessor/DocumentManager.java
 /src/main/org/brailleblaster/wordprocessor/Message.java
 /src/main/org/brailleblaster/wordprocessor/WPManager.java

=======================================
--- /src/main/org/brailleblaster/abstractClasses/AbstractView.java Wed May 15 11:28:27 2013 +++ /src/main/org/brailleblaster/abstractClasses/AbstractView.java Tue May 21 12:26:32 2013
@@ -50,8 +50,8 @@
        public boolean hasChanged = false;
        protected int total;
        protected int spaceBeforeText, spaceAfterText;
-       public int positionFromStart, cursorOffset;
-       public static int currentLine, words;
+       public int positionFromStart, cursorOffset, words;
+       public static int currentLine;
        protected boolean locked;
        protected static int currentAlignment;

@@ -160,27 +160,9 @@
                }
        }

-       public int getWordCount(){
-               String text = view.getText();
-               int wordCount = 0;
-               int i = 0;
-               while(i < text.length() && text.charAt(i) == ' '){
-                       i++;
-               }
-
-               for(;i < text.length(); i++){
-                       if(text.charAt(i) == ' '){
-                               wordCount++;
-                               while(i < text.length() && text.charAt(i) == ' 
'){
-                                       i++;
-                               }
-                       }
-               }
-
-               if(text.charAt(text.length() - 1) == ' ')
-                       wordCount--;
-
-               return wordCount;
+       public int getWordCount(String text){
+               String [] tokens = text.split(" ");
+               return tokens.length;
        }

        protected void setListenerLock(boolean setting){
=======================================
--- /src/main/org/brailleblaster/mapping/MapList.java Mon May 20 05:35:47 2013 +++ /src/main/org/brailleblaster/mapping/MapList.java Tue May 21 12:26:32 2013
@@ -1,3 +1,31 @@
+/* BrailleBlaster Braille Transcription Application
+  *
+  * Copyright (C) 2010, 2012
+  * ViewPlus Technologies, Inc. www.viewplus.com
+  * and
+  * Abilitiessoft, Inc. www.abilitiessoft.com
+  * All rights reserved
+  *
+  * This file may contain code borrowed from files produced by various
+  * Java development teams. These are gratefully acknoledged.
+  *
+  * This file is free software; you can redistribute it and/or modify it
+  * under the terms of the Apache 2.0 License, as given at
+  * http://www.apache.org/licenses/
+  *
+  * This file is distributed in the hope that it will be useful, but
+  * WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
+  * See the Apache 2.0 License for more details.
+  *
+  * You should have received a copy of the Apache 2.0 License along with
+  * this program; see the file LICENSE.txt
+  * If not, see
+  * http://www.apache.org/licenses/
+  *
+  * Maintained by John J. Boyer john.boyer@xxxxxxxxxxxxxxxxx
+*/
+
 package org.brailleblaster.mapping;

 import java.util.ArrayList;
@@ -21,7 +49,7 @@
                this.dm = dm;
        }

-       public int findClosest(Message message){
+       public int findClosest(Message message, int low, int high){
                int location = (Integer)message.getValue("offset");
int nodeIndex = getNodeIndex((TextMapElement)message.getValue("selection"));

@@ -31,54 +59,64 @@
                else if(location >= this.getLast().end){
                        return this.indexOf(this.getLast());
                }
-
-               for(int i = 0; i < this.size(); i++){
-                       if(location >= this.get(i).start && location <= 
this.get(i).end){
-                               if(location == this.get(i).end && location == 
this.get(i + 1).start){
-                                       if(checkForSpace(i)){
-                                               return i + 1;
-                                       }
-
-                                       if(i == nodeIndex){
-                                               return i;
-                                       }
-                                       else if( i + 1 == nodeIndex) {
-                                               return i + 1;
-                                       }
+
+               int mid = low  + ((high - low) / 2);
+
+               TextMapElement currentElement = this.get(mid);
+               if(location >= currentElement.start && location <= 
currentElement.end){
+ if(location == currentElement.end && location == this.get(mid + 1).start){
+                               if(checkForSpace(mid)){
+                                       return mid + 1;
                                }
-                               else{
-                                       return i;
+
+                               if(mid == nodeIndex){
+                                       return mid;
+                               }
+                               else if( mid + 1 == nodeIndex) {
+                                       return mid + 1;
                                }
                        }
-                       else if(location > this.get(i).end && location < 
this.get(i + 1).start){
-                               if(location - this.get(i).end > this.get(i + 
1).start - location){
-                                       return i;
+                       else{
+                               return mid;
+                       }
+               }
+ else if(location > currentElement.end && location < this.get(mid + 1).start){
+                       if(location - currentElement.end > this.get(mid + 
1).start - location){
+                               return mid;
+                       }
+ else if(location - currentElement.end < this.get(mid + 1).start - location){
+                               return mid + 1;
+                       }
+                       else {
+                               if(mid == nodeIndex){
+                                       return mid;
                                }
-                               else if(location - this.get(i).end < this.get(i 
+ 1).start - location){
-                                       return i + 1;
+                               else if( mid + 1 == nodeIndex) {
+                                       return mid + 1;
                                }
                                else {
-                                       if(i == nodeIndex){
-                                               return i;
-                                       }
-                                       else if( i + 1 == nodeIndex) {
-                                               return i + 1;
-                                       }
-                                       else {
-                                               return i;
-                                       }
+                                       return mid;
                                }
                        }
                }

-               return -1;
+               if(low > high){
+                       return -1;
+               }
+               else if(location < this.get(mid).start)
+                       return findClosest(message, low, mid - 1);
+               else
+                       return findClosest(message, mid + 1, high);
        }

        private boolean checkForSpace(int index){
+               if(this.get(index).n.getValue().length() == 0)
+                       return true;
+
char firstChar = this.get(index).n.getValue().charAt(this.get(index).n.getValue().length() - 1);
-
-               if(this.get(index + 1).n.getValue().length() > 0){
-                       char nextChar =  this.get(index + 
1).n.getValue().charAt(0);
+               String nextElementText = this.get(index + 1).n.getValue();
+               if(nextElementText.length() > 0){
+                       char nextChar =  nextElementText.charAt(0);
                        if( firstChar == ' ' && nextChar != ' '){
                                return true;
                        }
@@ -175,38 +213,42 @@
        }

        public void checkList(){
-               for(int i = 0; i < this.size() - 1; i++){
-                       if(this.get(i).start == this.get(i + 1).start){
-                               Message m = new Message(BBEvent.REMOVE_NODE);
-                               m.put("index", i);
-                               m.put("length",  
this.get(i).n.getValue().length());
-                               System.out.println("Node 1:\t" + 
this.get(i).n.getValue());
-                               System.out.println("Node 2:\t" + this.get(i + 
1).n.getValue());
-                               this.dm.dispatch(m);
-                               break;
+               if(this.currentIndex != -1){
+                       int index = this.currentIndex;
+                       int next = index + 1;
+                       int previous = index - 1;
+
+                       if(next < this.size()){
+                               if(this.get(index).start == 
this.get(next).start){
+                                       Message m = new 
Message(BBEvent.REMOVE_NODE);
+                                       m.put("index", index);
+                                       m.put("length",  
this.get(index).n.getValue().length());
+                                       System.out.println("Node 1:\t" + 
this.get(index).n.getValue());
+                                       System.out.println("Node 2:\t" + 
this.get(next).n.getValue());
+                                       this.dm.dispatch(m);
+                               }
                        }
-               }

-               for(int i = 1; i < this.size() - 2; i++){
- if(this.get(i - 1).start + this.get(i - 1).n.getValue().length() + 1 == this.get(i + 1).start && this.get(i).n.getValue().length() == 0){
-                               Message m = new Message(BBEvent.REMOVE_NODE);
-                               m.put("index", i);
-                               m.put("length",  
this.get(i).n.getValue().length());
-                               System.out.println("Node 1:\t" + 
this.get(i).n.getValue());
-                               System.out.println("Node 2:\t" + this.get(i + 
1).n.getValue());
-                               this.dm.dispatch(m);
-                               break;
+                       if(previous >= 0 && next < this.size()){
+ if(this.get(previous).start + this.get(previous).n.getValue().length() + 1 == this.get(next).start && this.get(index).n.getValue().length() == 0){
+                                       Message m = new 
Message(BBEvent.REMOVE_NODE);
+                                       m.put("index", index);
+                                       m.put("length",  
this.get(index).n.getValue().length());
+                                       System.out.println("Node 1:\t" + 
this.get(index).n.getValue());
+                                       System.out.println("Node 2:\t" + 
this.get(next).n.getValue());
+                                       this.dm.dispatch(m);
+                               }
                        }
-               }

- if(this.size() > 0 && this.get(this.size() - 1).n.getValue().length() == 0){ - if(this.get(this.size() - 1).start == this.prevEnd || this.get(this.size() - 1).start == 0){
-                               Message m = new Message(BBEvent.REMOVE_NODE);
-                               m.put("index", this.size() - 1);
-                               m.put("length",  this.get(this.size() - 
1).n.getValue().length());
- System.out.println("Node 1:\t" + this.get(this.size() - 1).n.getValue());
-                               System.out.println("Node 2:\t none");
-                               this.dm.dispatch(m);
+ if(this.size() > 0 && this.get(this.size() - 1).n.getValue().length() == 0){ + if(this.get(this.size() - 1).start == this.prevEnd || this.get(this.size() - 1).start == 0){
+                                       Message m = new 
Message(BBEvent.REMOVE_NODE);
+                                       m.put("index", this.size() - 1);
+                                       m.put("length",  this.get(this.size() - 
1).n.getValue().length());
+ System.out.println("Node 1:\t" + this.get(this.size() - 1).n.getValue());
+                                       System.out.println("Node 2:\t none");
+                                       this.dm.dispatch(m);
+                               }
                        }
                }
        }
@@ -317,7 +359,7 @@

        public void getCurrentNodeData(Message m){
                if(this.current == null){
-                       int index = findClosest(m);
+                       int index = findClosest(m, 0, this.size() - 1);
                        setCurrent(index);
                }

=======================================
--- /src/main/org/brailleblaster/views/TextView.java Wed May 15 11:28:27 2013 +++ /src/main/org/brailleblaster/views/TextView.java Tue May 21 12:26:32 2013
@@ -79,7 +79,7 @@
        private TraverseListener traverseListener;
        private MouseListener mouseListener;
        private int originalStart, originalEnd;
-
+
        public TextView (Group documentWindow, BBSemanticsTable table) {
                super (documentWindow, 16, 57, 0, 100);
                this.stylesTable = table;
@@ -115,7 +115,7 @@
                                        selectAll();
                                }

- if(oldCursorPosition == currentStart && oldCursorPosition != previousEnd && e.character == SWT.BS && view.getLineAlignment(view.getLineAtOffset(currentStart)) != SWT.LEFT){ + if(oldCursorPosition == currentStart && oldCursorPosition != previousEnd && e.character == SWT.BS && view.getLineAlignment(view.getLineAtOffset(currentStart)) != SWT.LEFT ){
                                        Message message = new 
Message(BBEvent.ADJUST_ALIGNMENT);
                                        message.put("sender", "text");
if(view.getLineAlignment(view.getLineAtOffset(currentStart)) == SWT.RIGHT){
@@ -174,10 +174,7 @@
                                        
view.setCaretOffset((Integer)message.getValue("start"));
                                }

-                               Message statusMessage = new 
Message(BBEvent.UPDATE_STATUSBAR);
- statusMessage.put("line", "Line: " + String.valueOf(view.getLineAtOffset(view.getCaretOffset()) + 1) + " Words: " + words);
-                               dm.dispatch(statusMessage);
-                               currentLine = 
view.getLineAtOffset(view.getCaretOffset());
+                               sendStatusBarUpdate(dm);
                        }

                        @Override
@@ -207,11 +204,7 @@
                                }

                                if(view.getLineAtOffset(view.getCaretOffset()) 
!= currentLine){
-                                       Message message = new 
Message(BBEvent.UPDATE_STATUSBAR);
-                                       words = getWordCount();
- message.put("line", "Line: " + String.valueOf(view.getLineAtOffset(view.getCaretOffset()) + 1) + " Words: " + words);
-                                       dm.dispatch(message);
-                                       currentLine = 
view.getLineAtOffset(view.getCaretOffset());
+                                       sendStatusBarUpdate(dm);
                                }
                        }
                });
@@ -260,7 +253,7 @@
                                }
                        }
                });
-
+
                setListenerLock(false);
        }

@@ -280,6 +273,8 @@
                        updateMessage.put("length", originalEnd - 
originalStart);
                //      updateMessage.put("length", currentChanges);
                        dm.dispatch(updateMessage);
+                       words += (Integer)updateMessage.getValue("diff");
+                       sendStatusBarUpdate(dm);
                        currentChanges = 0;
                        textChanged = false;
                        restoreStyleState(currentStart);
@@ -325,6 +320,13 @@
                        nextStart += position;
                }
        }
+
+       private void sendStatusBarUpdate(DocumentManager dm){
+               Message statusMessage = new Message(BBEvent.UPDATE_STATUSBAR);
+ statusMessage.put("line", "Line: " + String.valueOf(view.getLineAtOffset(view.getCaretOffset()) + 1) + " Words: " + words);
+               dm.dispatch(statusMessage);
+               currentLine = view.getLineAtOffset(view.getCaretOffset());
+       }

        protected void setViewData(Message message){
                currentStart = (Integer)message.getValue("start");
@@ -334,6 +336,7 @@

                originalStart = currentStart;
                originalEnd = currentEnd;
+
                if(currentStart < view.getCharCount()){
                        range = getStyleRange();
                }
@@ -376,6 +379,7 @@
                this.spaceBeforeText = 0;
                this.escapeChars = 0;
                view.setCaretOffset(0);
+               words += getWordCount(n.getValue());
        }

        public void reformatText(Node n, Message message, DocumentManager dm){
@@ -644,6 +648,9 @@
                                sendUpdate(dm);
                                setCurrent(dm);
                        }
+                       else {
+                               setCurrent(dm);
+                       }
                }
                setListenerLock(false);
        }
=======================================
--- /src/main/org/brailleblaster/views/TreeView.java Mon May 20 05:35:47 2013 +++ /src/main/org/brailleblaster/views/TreeView.java Tue May 21 12:26:32 2013
@@ -75,7 +75,7 @@

        public TreeView(final DocumentManager dm, Group documentWindow){
                super(documentWindow, 0, 15, 0, 100);
-               this.tree = new Tree(view, SWT.NONE);
+               this.tree = new Tree(view, SWT.VIRTUAL | SWT.NONE);

                view.addFocusListener(new FocusListener(){
                        @Override
@@ -286,7 +286,7 @@

        private void searchTree(TreeItem item, TextMapElement t, Message m){
                boolean found = false;
-
+
                for(int i = 0; i < item.getItemCount() && !found; i++){
                        
if(((TreeItemData)item.getItem(i).getData()).textMapList != null){
                                ArrayList<TextMapElement>list = 
getList(item.getItem(i));
@@ -365,34 +365,36 @@

        private void resetTree(TreeItem currentItem){
                ArrayList<TreeItem>previousParents = new ArrayList<TreeItem>();
-               previousParents.add(previousItem);
-               TreeItem parent = previousItem.getParentItem();
+
+               if(!previousItem.isDisposed()){
+                       previousParents.add(previousItem);
+                       TreeItem parent = previousItem.getParentItem();

-               while(parent != null){
-                       previousParents.add(parent);
-                       parent = parent.getParentItem();
-               }
+                       while(parent != null){
+                               previousParents.add(parent);
+                               parent = parent.getParentItem();
+                       }

-               parent = currentItem.getParentItem();
-               boolean match = false;
-               int location = -1;
+                       parent = currentItem.getParentItem();
+                       boolean match = false;
+                       int location = -1;

-               while(parent != null && !match){
-                       for(int i = 0; i < previousParents.size(); i++){
-                               if(previousParents.get(i).equals(parent)){
-                                       match = true;
-                                       location = i - 1;
+                       while(parent != null && !match){
+                               for(int i = 0; i < previousParents.size(); i++){
+                                       
if(previousParents.get(i).equals(parent)){
+                                               match = true;
+                                               location = i - 1;
+                                       }
                                }
+                               parent = parent.getParentItem();
                        }
-                       parent = parent.getParentItem();
-               }
-
-               if(match){
-                       for(int i = location; i >= 0; i--){
-                               previousParents.get(i).setExpanded(false);
+
+                       if(match){
+                               for(int i = location; i >= 0; i--){
+                                       
previousParents.get(i).setExpanded(false);
+                               }
                        }
                }
-
        }

        public void clearTree(){
=======================================
--- /src/main/org/brailleblaster/wordprocessor/BBDocument.java Thu May 16 06:56:05 2013 +++ /src/main/org/brailleblaster/wordprocessor/BBDocument.java Tue May 21 12:26:32 2013
@@ -1,3 +1,31 @@
+/* BrailleBlaster Braille Transcription Application
+  *
+  * Copyright (C) 2010, 2012
+  * ViewPlus Technologies, Inc. www.viewplus.com
+  * and
+  * Abilitiessoft, Inc. www.abilitiessoft.com
+  * All rights reserved
+  *
+  * This file may contain code borrowed from files produced by various
+  * Java development teams. These are gratefully acknoledged.
+  *
+  * This file is free software; you can redistribute it and/or modify it
+  * under the terms of the Apache 2.0 License, as given at
+  * http://www.apache.org/licenses/
+  *
+  * This file is distributed in the hope that it will be useful, but
+  * WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
+  * See the Apache 2.0 License for more details.
+  *
+  * You should have received a copy of the Apache 2.0 License along with
+  * this program; see the file LICENSE.txt
+  * If not, see
+  * http://www.apache.org/licenses/
+  *
+  * Maintained by John J. Boyer john.boyer@xxxxxxxxxxxxxxxxx
+*/
+
 package org.brailleblaster.wordprocessor;

 import java.io.File;
@@ -130,6 +158,7 @@
                String text = (String)message.getValue("newText");
                text = text.replace("\n", "");
                message.put("newText", text);
+               calculateDifference(list.getCurrent().n.getValue(), text, 
message);
                changeTextNode(list.getCurrent().n, text);

                if(text.equals("") || isWhitespace(text)){
@@ -466,4 +495,16 @@
                File f = new File(filePath);
                f.delete();
        }
+
+ private void calculateDifference(String oldString, String newString, Message m){
+               String [] tokens1 = oldString.split(" ");
+               String [] tokens2 = newString.split(" ");
+
+               int diff = tokens2.length - tokens1.length;
+               if(newString.equals("")){
+                       diff = 0 - tokens1.length;
+               }
+
+               m.put("diff", diff);
+       }
 }
=======================================
--- /src/main/org/brailleblaster/wordprocessor/BBEvent.java Mon May 20 05:35:47 2013 +++ /src/main/org/brailleblaster/wordprocessor/BBEvent.java Tue May 21 12:26:32 2013
@@ -1,5 +1,33 @@
+/* BrailleBlaster Braille Transcription Application
+  *
+  * Copyright (C) 2010, 2012
+  * ViewPlus Technologies, Inc. www.viewplus.com
+  * and
+  * Abilitiessoft, Inc. www.abilitiessoft.com
+  * All rights reserved
+  *
+  * This file may contain code borrowed from files produced by various
+  * Java development teams. These are gratefully acknoledged.
+  *
+  * This file is free software; you can redistribute it and/or modify it
+  * under the terms of the Apache 2.0 License, as given at
+  * http://www.apache.org/licenses/
+  *
+  * This file is distributed in the hope that it will be useful, but
+  * WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
+  * See the Apache 2.0 License for more details.
+  *
+  * You should have received a copy of the Apache 2.0 License along with
+  * this program; see the file LICENSE.txt
+  * If not, see
+  * http://www.apache.org/licenses/
+  *
+  * Maintained by John J. Boyer john.boyer@xxxxxxxxxxxxxxxxx
+*/
 package org.brailleblaster.wordprocessor;

+//Enumeration used by Message class used by the DocumentManager to redirect messages between views
 public enum BBEvent {
        INCREMENT,
        DECREMENT,
=======================================
--- /src/main/org/brailleblaster/wordprocessor/BBStatusBar.java Fri May 10 09:06:10 2013 +++ /src/main/org/brailleblaster/wordprocessor/BBStatusBar.java Tue May 21 12:26:32 2013
@@ -50,5 +50,14 @@
        void setText (String text) {
                statusBar.setText (text);
        }
+
+       void resetLocation(int left, int right, int bottom){
+               FormData data = (FormData)this.statusBar.getLayoutData();
+               data.left = new FormAttachment(left);
+               data.right = new FormAttachment(right);
+               data.bottom = new FormAttachment(bottom);
+               statusBar.setLayoutData (data);
+               this.statusBar.getParent().layout();
+       }
 }

=======================================
--- /src/main/org/brailleblaster/wordprocessor/DocumentManager.java Mon May 20 05:35:47 2013 +++ /src/main/org/brailleblaster/wordprocessor/DocumentManager.java Tue May 21 12:26:32 2013
@@ -108,7 +108,7 @@

this.tabList = new Control[]{this.treeView.view, this.text.view, this.braille.view};
                this.group.setTabList(this.tabList);
-               this.wp.getStatusBar().setText("Words: " + 0);
+       //      this.wp.getStatusBar().setText("Words: " + 0);

                logger = BBIni.getLogger();

@@ -234,20 +234,24 @@

                try{
if(this.document.startDocument(workingFilePath, "preferences.cfg", null)){
-                               this.wp.getStatusBar().setText("Loading");
+                               this.wp.getStatusBar().resetLocation(6,100,100);
+                               this.wp.getProgressBar().start();
+                               this.wp.getStatusBar().setText("Loading...");
                                this.documentName = fileName;
                                setTabTitle(fileName);
                                
this.treeView.setRoot(this.document.getRootElement(), this);
                                initializeViews(this.document.getRootElement());
                                //list.getLast().brailleList.removeLast();
+ this.text.view.replaceTextRange(this.text.view.getCharCount() - 1, 1, ""); + this.braille.view.replaceTextRange(this.braille.view.getCharCount() - 1, 1, "");
                                this.text.initializeListeners(this);
                                this.braille.initializeListeners(this);
- this.text.view.replaceTextRange(this.text.view.getCharCount() - 1, 1, ""); - this.braille.view.replaceTextRange(this.braille.view.getCharCount() - 1, 1, "");
                                this.text.hasChanged = false;
                                this.braille.hasChanged = false;
                                this.wp.checkToolbarSettings();
-                               this.wp.getStatusBar().setText("Words: " + 
this.text.getWordCount());
+                               this.wp.getStatusBar().resetLocation(0,100,100);
+                               this.wp.getProgressBar().stop();
+                               this.wp.getStatusBar().setText("Words: " 
+this.text.words);
                        }
                        else {
                                System.out.println("The Document Base document tree 
is empty");
@@ -300,12 +304,14 @@
                switch(message.type){
                        case INCREMENT:
                                list.incrementCurrent(message);
-                               this.treeView.setSelection(list.getCurrent(), 
message, this);
+                               if(list.size() > 0)
+                                       
this.treeView.setSelection(list.getCurrent(), message, this);
                                resetCursorData();
                                break;
                        case DECREMENT:
                                list.decrementCurrent(message);
-                               this.treeView.setSelection(list.getCurrent(), 
message, this);
+                               if(list.size() > 0)
+                                       
this.treeView.setSelection(list.getCurrent(), message, this);
                                resetCursorData();
                                break;
                        case UPDATE_CURSORS:
@@ -342,7 +348,7 @@
                                }
                                else {
message.put("selection", this.treeView.getSelection(list.getCurrent()));
-                                       index = list.findClosest(message);
+                                       index = list.findClosest(message, 0, 
list.size() - 1);
                                        if(index == -1){
                                                
list.getCurrentNodeData(message);
                                                
this.treeView.setSelection(list.getCurrent(), message, this);
@@ -358,9 +364,11 @@
                        case GET_CURRENT:
message.put("selection", this.treeView.getSelection(list.getCurrent()));
                                list.getCurrentNodeData(message);
-                               this.treeView.setSelection(list.getCurrent(), 
message, this);
+                               if(list.size() > 0)
+                                       
this.treeView.setSelection(list.getCurrent(), message, this);
                                break;
                        case TEXT_DELETION:
+                               list.checkList();
                                if((Integer)message.getValue("deletionType") == 
SWT.BS){
                                        
if(list.hasBraille(list.getCurrentIndex())){
this.braille.removeWhitespace(list.getCurrent().brailleList.getFirst().start + (Integer)message.getValue("length"), (Integer)message.getValue("length"));
@@ -388,7 +396,7 @@
                                list.get(index).brailleList.clear();
                                this.treeView.removeItem(list.get(index), 
message);
                                list.remove(index);
-                               System.out.println("Item removed");
+                               System.out.println("Item removed");
                                if(list.size() == 0)
                                        this.text.removeListeners();
                                break;
=======================================
--- /src/main/org/brailleblaster/wordprocessor/Message.java Mon May 20 05:35:47 2013 +++ /src/main/org/brailleblaster/wordprocessor/Message.java Tue May 21 12:26:32 2013
@@ -1,7 +1,36 @@
+/* BrailleBlaster Braille Transcription Application
+  *
+  * Copyright (C) 2010, 2012
+  * ViewPlus Technologies, Inc. www.viewplus.com
+  * and
+  * Abilitiessoft, Inc. www.abilitiessoft.com
+  * All rights reserved
+  *
+  * This file may contain code borrowed from files produced by various
+  * Java development teams. These are gratefully acknoledged.
+  *
+  * This file is free software; you can redistribute it and/or modify it
+  * under the terms of the Apache 2.0 License, as given at
+  * http://www.apache.org/licenses/
+  *
+  * This file is distributed in the hope that it will be useful, but
+  * WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
+  * See the Apache 2.0 License for more details.
+  *
+  * You should have received a copy of the Apache 2.0 License along with
+  * this program; see the file LICENSE.txt
+  * If not, see
+  * http://www.apache.org/licenses/
+  *
+  * Maintained by John J. Boyer john.boyer@xxxxxxxxxxxxxxxxx
+*/
+
 package org.brailleblaster.wordprocessor;

 import java.util.HashMap;

+//Passes data between different views and the parent DocumentManager class
 public class Message {
        public BBEvent type;
        HashMap<String, Object> args;
=======================================
--- /src/main/org/brailleblaster/wordprocessor/WPManager.java Mon May 20 05:35:47 2013 +++ /src/main/org/brailleblaster/wordprocessor/WPManager.java Tue May 21 12:26:32 2013
@@ -59,6 +59,7 @@
     private FormData location;
     private BBMenu bbMenu;
     private BBStatusBar statusBar;
+    private BBProgressBar pb;
     private BBToolBar toolBar;
     private LinkedList<DocumentManager> managerList;
     private StyleManager sm;
@@ -83,6 +84,7 @@
            this.folder.setLayoutData (this.location);

            this.statusBar = new BBStatusBar(this.shell);
+           this.pb = new BBProgressBar(this.shell);
            this.bbMenu = new BBMenu(this);

                this.sm = new StyleManager(this);
@@ -104,8 +106,7 @@
                                int index = folder.getSelectionIndex();
                                if(managerList.size() > 0){
                                        
if(managerList.get(index).text.view.getCharCount() > 0) {
-                                               int wordCount = 
managerList.get(index).text.getWordCount();
-                                               statusBar.setText("Words: " + 
wordCount);
+                                               statusBar.setText("Words: " + 
managerList.get(index).text.words);
                                        }
                                        else
                                                statusBar.setText("Words: " + 
0);
@@ -211,6 +212,10 @@
     public BBMenu getMainMenu() {
        return bbMenu;
     }
+
+    public BBProgressBar getProgressBar(){
+       return this.pb;
+    }

     public StyleManager getStyleManager() {
        return sm;

Other related posts:

  • » [brailleblaster] [brailleblaster.newdesign] push by brandon....@xxxxxxxxx - Added Progress Bar on 2013-05-21 19:28 GMT - brailleblaster