[brailleblaster] Re: 5 new revisions pushed by sahel.ma...@xxxxxxxxx on 2014-07-31 18:56 GMT

  • From: "Vic Beckley" <vic.beckley3@xxxxxxxxx>
  • To: <brailleblaster@xxxxxxxxxxxxx>
  • Date: Thu, 31 Jul 2014 16:25:20 -0400

Brandon,

 

Thanks for the help. I assumed that was what it would do. It seems to work very 
well so far. It is really a nice feature.

 

Do boxlines work with multiple elements selected? It seems to put each element 
in a separate box. I would like to be able to select several paragraphs and 
apply a boxline style to the group of elements. What I mean is have only one 
box surrounding the group of paragraphs. Is this possible? Is it possible or 
planned?

 

 

Best regards from Ohio,

 

Vic

 

From: brailleblaster-bounce@xxxxxxxxxxxxx 
[mailto:brailleblaster-bounce@xxxxxxxxxxxxx] On Behalf Of Brandon Roller
Sent: Thursday, July 31, 2014 3:30 PM
To: brailleblaster@xxxxxxxxxxxxx
Subject: [brailleblaster] Re: 5 new revisions pushed by sahel.ma...@xxxxxxxxx 
on 2014-07-31 18:56 GMT

 

Let's say you highlighted three paragraphs and selected heading 2 in the style 
panel.  It would apply heading 2 styles to all three.

 

On Thu, Jul 31, 2014 at 3:02 PM, Vic Beckley <vic.beckley3@xxxxxxxxx> wrote:

What exactly is "multi select styles?" How do you use it?


Best regards from Ohio,

Vic

-----Original Message-----
From: brailleblaster-bounce@xxxxxxxxxxxxx
[mailto:brailleblaster-bounce@xxxxxxxxxxxxx] On Behalf Of
brailleblaster@xxxxxxxxxxxxxx
Sent: Thursday, July 31, 2014 2:57 PM
To: brailleblaster@xxxxxxxxxxxxx
Subject: [brailleblaster] 5 new revisions pushed by sahel.ma...@xxxxxxxxx on
2014-07-31 18:56 GMT

5 new revisions:

Revision: 9b58e3b359cf
Branch:   default
Author:   Sahel "sahel.mastoureshgh@xxxxxxxxx"
Date:     Thu Jul 24 20:04:42 2014 UTC
Log:      Reverting some of files second time
http://code.google.com/p/brailleblaster/source/detail?r=9b58e3b359cf

Revision: d5bb11f3fb3b
Branch:   default
Author:   Sahel "sahel.mastoureshgh@xxxxxxxxx"
Date:     Thu Jul 31 15:34:17 2014 UTC
Log:      Adding multi select style
http://code.google.com/p/brailleblaster/source/detail?r=d5bb11f3fb3b

Revision: b1edff6fec3e
Branch:   default
Author:   Sahel "sahel.mastoureshgh@xxxxxxxxx"
Date:     Thu Jul 31 15:38:44 2014 UTC
Log:      commited before mereging
http://code.google.com/p/brailleblaster/source/detail?r=b1edff6fec3e

Revision: 30910e3d2f45
Branch:   default
Author:   Sahel "sahel.mastoureshgh@xxxxxxxxx"
Date:     Thu Jul 31 18:51:41 2014 UTC
Log:      Fixed merge conflicts
http://code.google.com/p/brailleblaster/source/detail?r=30910e3d2f45

Revision: 1e17b7a92010
Branch:   default
Author:   Sahel "sahel.mastoureshgh@xxxxxxxxx"
Date:     Thu Jul 31 18:54:23 2014 UTC
Log:      Fixed merge conflicts second
http://code.google.com/p/brailleblaster/source/detail?r=1e17b7a92010

============================================================================
==
Revision: 9b58e3b359cf
Branch:   default
Author:   Sahel "sahel.mastoureshgh@xxxxxxxxx"
Date:     Thu Jul 24 20:04:42 2014 UTC
Log:      Reverting some of files second time
http://code.google.com/p/brailleblaster/source/detail?r=9b58e3b359cf

Modified:
  /src/main/org/brailleblaster/perspectives/braille/views/wp/TextView.java

=======================================
---
/src/main/org/brailleblaster/perspectives/braille/views/wp/TextView.java

Thu Jul 24 19:01:54 2014 UTC
+++
/src/main/org/brailleblaster/perspectives/braille/views/wp/TextView.java

Thu Jul 24 20:04:42 2014 UTC
@@ -103,8 +103,6 @@
        private PaintObjectListener paintObjListener;
        private int originalStart, originalEnd;
        private TextMapElement currentElement;
-       int startSelection;
-       int endSelection;

        public TextView (Manager manager, Group documentWindow,
BBSemanticsTable
table) {
                super (manager, documentWindow, LEFT_MARGIN, RIGHT_MARGIN,
TOP_MARGIN,
BOTTOM_MARGIN, table);
@@ -119,16 +117,7 @@
                view.addSelectionListener(selectionListener = new
SelectionAdapter(){
                        @Override
                        public void widgetSelected(SelectionEvent e) {
-
                                selectionArray = view.getSelectionRanges();
-                               //Added this part for start and end of text
selection
-                               for (int i = 0; i < selectionArray.length-1;
i++) {
-                                       startSelection=selectionArray[i];
-
endSelection=selectionArray[i]+selectionArray[i+1];
-
-
-                            }
-                                System.out.println(startSelection+"
"+endSelection);
                                if(selectionArray[1] > 0){
                                        setSelection(selectionArray[0],
selectionArray[1]);
                                        currentChar = ' ';

============================================================================
==
Revision: d5bb11f3fb3b
Branch:   default
Author:   Sahel "sahel.mastoureshgh@xxxxxxxxx"
Date:     Thu Jul 31 15:34:17 2014 UTC
Log:      Adding multi select style
http://code.google.com/p/brailleblaster/source/detail?r=d5bb11f3fb3b

Modified:
  /src/main/org/brailleblaster/perspectives/braille/Manager.java
  /src/main/org/brailleblaster/perspectives/braille/views/wp/TextView.java

=======================================
--- /src/main/org/brailleblaster/perspectives/braille/Manager.java      Thu
Jul
24 19:35:48 2014 UTC
+++ /src/main/org/brailleblaster/perspectives/braille/Manager.java      Thu
Jul
31 15:34:17 2014 UTC
@@ -36,6 +36,11 @@
  import java.io.File;
  import java.io.IOException;
  import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Set;

  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
@@ -55,6 +60,8 @@
  import
org.brailleblaster.perspectives.braille.document.BBSemanticsTable.Styles;
  import
org.brailleblaster.perspectives.braille.document.BBSemanticsTable.StylesType
;
  import org.brailleblaster.perspectives.braille.document.BrailleDocument;
+import
org.brailleblaster.perspectives.braille.mapping.elements.BrlOnlyMapElement;
+import
org.brailleblaster.perspectives.braille.mapping.elements.PageMapElement;
  import org.brailleblaster.perspectives.braille.mapping.elements.Range;
  import
org.brailleblaster.perspectives.braille.mapping.elements.SectionElement;
  import
org.brailleblaster.perspectives.braille.mapping.elements.TextMapElement;
@@ -806,52 +813,126 @@
                else
                        braille.positionScrollbar(text.view.getTopIndex());
        }
+       /***
+     * Get parent style of the current TextMapElement
+     * @param current
+     * @param message
+     * @return
+     */
+       private Element parentStyle(TextMapElement current, Message message)
{
+               Element parent = document.getParent(current.n, true);
+               message.put("previousStyle",
styles.get(styles.getKeyFromAttribute(parent)));
+               document.changeSemanticAction(message,
current.parentElement());
+               message.put("style",
styles.get(styles.getKeyFromAttribute(parent)));
+               return parent;
+
+       }
+       /***
+        * Handle style for all cases
+        * @param message
+        */

-       private void handleUpdateStyle(Message message){
-               if(document.getDOM() != null && text.view.getText().length()
> 0){
+       private void handleUpdateStyle(Message message) {
+               if (document.getDOM() != null &&
text.view.getText().length() > 0) {
                        group.setRedraw(false);
-                       Element parent =
document.getParent(list.getCurrent().n, true);
+                       if (message.getValue("multiSelect").equals(false)) {
+                               handleStyleCursorSelected(message);

-                       message.put("previousStyle",
styles.get(styles.getKeyFromAttribute(parent)));
-                       document.changeSemanticAction(message,
list.getCurrent().parentElement());
-                       message.put("style",
styles.get(styles.getKeyFromAttribute(parent)));
-                       ArrayList<TextMapElement> itemList =
list.findTextMapElements(list.getCurrentIndex(), parent, true);
+                       } else {
+                               handleStyleMultiSelected(message);
+                       }
+
+               } else
+                       new Notify(lh.localValue("nothingToApply"));
+       }
+       /***
+        * Handle style if user just move cursor
+        * @param message
+        */
+       private void handleStyleCursorSelected(Message message) {
+               Element parent = parentStyle(list.getCurrent(), message);
+               ArrayList<TextMapElement> itemList =
list.findTextMapElements(
+                               list.getCurrentIndex(), parent, true);
+               adjustStyle(itemList, message);
+
+       }
+       /***
+        * Apply styles to selected text for multiple elements
+        * @param start
+        * @param end
+        * @param message
+        */
+       private void handleStyleMultiSelected(Message message){

-                       int start = list.indexOf(itemList.get(0));
-                       int end = list.indexOf(itemList.get(itemList.size()
- 1));
-                       int origPos =
list.get(list.getNodeIndex(itemList.get(0))).start;
-                       if(start > 0){
-                               message.put("prev", list.get(start -
1).end);
-                               message.put("braillePrev", list.get(start -

1).brailleList.getLast().end);
+               int start=text.getSelectedText()[0];
+               int end=text.getSelectedText()[1];
+
+               Set<TextMapElement> itemSet = getElementSelected(start,
end);
+
+               Iterator<TextMapElement> itr = itemSet.iterator();
+               while (itr.hasNext())
+               {
+                       TextMapElement tempElement= itr.next();
+
+
if(tempElement.parentElement().getAttributeValue("semantics").contains("styl
e")
||
tempElement.parentElement().getAttributeValue("semantics").contains("action"
))
+                       {
+                               Message styleMessage = new Message(null);
+                               styleMessage.put("Style",
message.getValue("Style"));
+                               Element parent = parentStyle(tempElement,
styleMessage);
+
+                               ArrayList<TextMapElement> itemList =
list.findTextMapElements(list.getNodeIndex(tempElement), parent, true);
+                               adjustStyle( itemList,styleMessage);
                        }
-                       else {
-                               message.put("prev", -1);
-                               message.put("braillePrev", -1);
-                       }
-
-                       if(end < list.size() - 1){
-                               message.put("next", list.get(end +
1).start);
-                               message.put("brailleNext",  list.get(end +
1).brailleList.getFirst().start);
-                       }
-                       else {
-                               message.put("next", -1);
-                               message.put("brailleNext", -1);
-                       }
-
-                       text.adjustStyle(message, itemList);
-                       braille.adjustStyle(message, itemList);
-
-                       if(message.contains("linesBeforeOffset"))
-                               list.shiftOffsetsFromIndex(start,
(Integer)message.getValue("linesBeforeOffset"),
(Integer)message.getValue("linesBeforeOffset"), origPos);
-                       if(message.contains("linesAfterOffset") &&
list.size() > 1 && end <
list.size() - 1)
-                               list.shiftOffsetsFromIndex(end + 1,
(Integer)message.getValue("linesAfterOffset"),
(Integer)message.getValue("linesAfterOffset"), origPos);
+               }
+
+       }
+       /***
+        * Adjust style of elements in the list base on previous and next
element
+        * @param itemList : all selected items which we want style to be
applied
+        * @param message : passing information regarding styles
+        */

-                       treeView.adjustItemStyle(list.getCurrent());
-                       group.setRedraw(true);
+       private void adjustStyle(ArrayList<TextMapElement> itemList, Message

message) {
+               int start = list.indexOf(itemList.get(0));
+               int end = list.indexOf(itemList.get(itemList.size() - 1));
+               int origPos =
list.get(list.getNodeIndex(itemList.get(0))).start;
+               if (start > 0) {
+                       message.put("prev", list.get(start - 1).end);
+                       message.put("braillePrev",
+                                       list.get(start -
1).brailleList.getLast().end);
+               } else {
+                       message.put("prev", -1);
+                       message.put("braillePrev", -1);
                }
-               else
-                       new Notify(lh.localValue("nothingToApply"));
+
+               if (end < list.size() - 1) {
+                       message.put("next", list.get(end + 1).start);
+                       message.put("brailleNext",
+                                       list.get(end +
1).brailleList.getFirst().start);
+               } else {
+                       message.put("next", -1);
+                       message.put("brailleNext", -1);
+               }
+
+               text.adjustStyle(message, itemList);
+               braille.adjustStyle(message, itemList);
+
+               if (message.contains("linesBeforeOffset"))
+                       list.shiftOffsetsFromIndex(start,
+                                       (Integer)
message.getValue("linesBeforeOffset"),
+                                       (Integer)
message.getValue("linesBeforeOffset"), origPos);
+               if (message.contains("linesAfterOffset") && list.size() > 1
+                               && end < list.size() - 1)
+                       list.shiftOffsetsFromIndex(end + 1,
+                                       (Integer)
message.getValue("linesAfterOffset"),
+                                       (Integer)
message.getValue("linesAfterOffset"), origPos);
+
+               treeView.adjustItemStyle(list.getCurrent());
+               group.setRedraw(true);
+
        }
+
+

        public void saveAs(){
                BBFileDialog dialog = new BBFileDialog(wp.getShell(),
SWT.SAVE,
arch.getFileTypes(), arch.getFileExtensions());
@@ -1199,6 +1280,37 @@
                else
                        return null;
        }
+       /***
+        * Return all elements that selected in text
+        * @param start :start location of where text selected
+        * @param end:  where selection ended
+        * @return: Set of all element where in selection
+        */
+       public Set<TextMapElement> getElementSelected(int start, int end) {
+
+               Set<TextMapElement> elementSelectedSet = new
LinkedHashSet<TextMapElement>();
+               Set<Element> parentElement = new LinkedHashSet<Element>();
+               int j=start;
+               while( j < end) {
+                       TextMapElement t = getElementInRange(j);
+
+                       if ((t != null) && (!((t instanceof
BrlOnlyMapElement )||(t instanceof
PageMapElement)))) {
+                               Element currentParent =
document.getParent(t.n, true);
+
if(!(parentElement.contains(currentParent))){
+                                       parentElement.add(currentParent);
+                                       elementSelectedSet.add(t);
+                               }
+
+                               j=t.end+1;
+
+                       }
+                       else
+                       {
+                           j=j+1;
+                       }
+               }
+               return elementSelectedSet;
+       }

        public TextMapElement getElementInBrailleRange(int offset){
                Message m = new Message(null);
=======================================
---
/src/main/org/brailleblaster/perspectives/braille/views/wp/TextView.java

Thu Jul 24 20:04:42 2014 UTC
+++
/src/main/org/brailleblaster/perspectives/braille/views/wp/TextView.java

Thu Jul 31 15:34:17 2014 UTC
@@ -103,6 +103,7 @@
        private PaintObjectListener paintObjListener;
        private int originalStart, originalEnd;
        private TextMapElement currentElement;
+       private boolean multiSelected;

        public TextView (Manager manager, Group documentWindow,
BBSemanticsTable
table) {
                super (manager, documentWindow, LEFT_MARGIN, RIGHT_MARGIN,
TOP_MARGIN,
BOTTOM_MARGIN, table);
@@ -110,6 +111,7 @@
                this.spaceBeforeText = 0;
                this.spaceAfterText = 0;
                this.manager = manager;
+               multiSelected=false;
        }

        @Override
@@ -119,7 +121,7 @@
                        public void widgetSelected(SelectionEvent e) {
                                selectionArray = view.getSelectionRanges();
                                if(selectionArray[1] > 0){
-                                       setSelection(selectionArray[0],
selectionArray[1]);
+                                       multiSelected=true;
                                        currentChar = ' ';
                                        if(currentChanges > 0)
                                                sendUpdate();
@@ -1755,4 +1757,19 @@
                spaceBeforeText = 0;
           spaceBeforeText = 0;
         }
+       public int[] getSelectedText()
+       {
+               int [] temp=new int[2];
+               if(selectionArray!=null){
+                  temp[0]=selectionArray[0];
+                  temp[1]=selectionArray[0]+selectionArray[1];
+               }
+               return temp;
+       }
+
+       public boolean isMultiSelected() {
+               return multiSelected;
+       }
+
+
  }

============================================================================
==
Revision: b1edff6fec3e
Branch:   default
Author:   Sahel "sahel.mastoureshgh@xxxxxxxxx"
Date:     Thu Jul 31 15:38:44 2014 UTC
Log:      commited before mereging
http://code.google.com/p/brailleblaster/source/detail?r=b1edff6fec3e

Modified:
  /src/main/org/brailleblaster/archiver/NimasArchiver.java

/src/main/org/brailleblaster/perspectives/braille/stylepanel/StyleManager.ja
va

=======================================
--- /src/main/org/brailleblaster/archiver/NimasArchiver.java    Thu Jul 24
19:10:40 2014 UTC
+++ /src/main/org/brailleblaster/archiver/NimasArchiver.java    Thu Jul 31
15:38:44 2014 UTC
@@ -85,7 +85,7 @@

                // Segment the single NIMAS file. This will make rendering
                // faster in certain perspectives.
-               writeNimasSegments();
+               //writeNimasSegments();

                currentConfig = getAutoCfg("nimas"); // Nimas document.
                filterNames = new String[] {"XML", "XML Zip", "BRF",
"UTDML"};
=======================================
---
/src/main/org/brailleblaster/perspectives/braille/stylepanel/StyleManager.ja
va
Thu Jul  3 16:07:57 2014 UTC
+++
/src/main/org/brailleblaster/perspectives/braille/stylepanel/StyleManager.ja
va
Thu Jul 31 15:38:44 2014 UTC
@@ -102,8 +102,18 @@
      public void apply(String item){
        Message m = new Message(BBEvent.UPDATE_STYLE);
        Styles style = semanticsTable.get(item);
+
        if(style != null){
                m.put("Style", style);
+               if(dm.getText().isMultiSelected()==true)
+               {
+                       m.put("multiSelect", true);
+               }
+               else
+               {
+                       m.put("multiSelect", false);
+
+               }
                dm.dispatch(m);
        }
      }

============================================================================
==
Revision: 30910e3d2f45
Branch:   default
Author:   Sahel "sahel.mastoureshgh@xxxxxxxxx"
Date:     Thu Jul 31 18:51:41 2014 UTC
Log:      Fixed merge conflicts
http://code.google.com/p/brailleblaster/source/detail?r=30910e3d2f45

Modified:
  /src/main/org/brailleblaster/archiver/NimasArchiver.java
  /src/main/org/brailleblaster/perspectives/braille/Manager.java

/src/main/org/brailleblaster/perspectives/braille/stylepanel/StyleManager.ja
va
  /src/main/org/brailleblaster/perspectives/braille/views/wp/TextView.java

=======================================
--- /src/main/org/brailleblaster/archiver/NimasArchiver.java    Thu Jul 31
15:38:44 2014 UTC
+++ /src/main/org/brailleblaster/archiver/NimasArchiver.java    Thu Jul 31
18:51:41 2014 UTC
@@ -30,26 +30,12 @@

  package org.brailleblaster.archiver;

-import java.io.BufferedOutputStream;
  import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
  import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.io.StringWriter;
  import java.util.ArrayList;
-import java.util.HashMap;
  import java.util.HashSet;
  import java.util.Set;

-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-
  import nu.xom.Attribute;
  import nu.xom.Builder;
  import nu.xom.Document;
@@ -58,17 +44,12 @@
  import nu.xom.Nodes;
  import nu.xom.ParsingException;
  import nu.xom.ValidityException;
-import nu.xom.XPathContext;
-import nu.xom.converters.DOMConverter;
-import nu.xom.xslt.XSLException;
-import nu.xom.xslt.XSLTransform;

  import org.brailleblaster.BBIni;
  import org.brailleblaster.document.BBDocument;
  import org.brailleblaster.util.FileUtils;
  import org.brailleblaster.util.Notify;
  import org.brailleblaster.util.Zipper;
-import org.w3c.dom.DOMImplementation;


////////////////////////////////////////////////////////////////////////////
//////
  // Prepares Nimas Archive for opening.
@@ -76,21 +57,27 @@


        Set <String> allPaths;
-
+       // The number of documents we COULD have if wrote them all to disk.
+       int numPotentialFiles = 0;

        NimasArchiver(String docToPrepare) {
+
                super(docToPrepare);
+
+               currentConfig = getAutoCfg("nimas"); // Nimas document.
+               filterNames = new String[] {"XML", "XML Zip", "BRF",
"UTDML"};
+               filterExtensions = new String[] {"*.xml", "*.zip", "*.brf",
"*.utd"};
+               allPaths = new HashSet<String>();
+
+               // Unzip file if needed.
                if(docToPrepare.endsWith(".zip"))
                        unzip(docToPrepare);

                // Segment the single NIMAS file. This will make rendering
                // faster in certain perspectives.
-               //writeNimasSegments();
-
-               currentConfig = getAutoCfg("nimas"); // Nimas document.
-               filterNames = new String[] {"XML", "XML Zip", "BRF",
"UTDML"};
-               filterExtensions = new String[] {"*.xml", "*.zip", "*.brf",
"*.utd"};
-               allPaths=new HashSet<String>();
+
+               // Write the first file to disk.
+               wrtieToDisk(0);
        }

        @Override
@@ -100,7 +87,7 @@
                        path = workingDocPath;

                if(fu.createXMLFile(doc.getNewXML(), path)){
-                       String tempSemFile = BBIni.getTempFilesPath() +
BBIni.getFileSep() +
fu.getFileName(path) + ".sem";
+                       String tempSemFile = BBIni.getTempFilesPath() +
BBIni.getFileSep() +
fu.getFileName(path) + ".sem";
                        copySemanticsFile(tempSemFile, fu.getPath(path) +
BBIni.getFileSep() +
fu.getFileName(path) + ".sem");
                }
                else {
@@ -131,6 +118,7 @@
                String sp = BBIni.getFileSep();
                String tempOutPath = BBIni.getTempFilesPath() +
filePath.substring(filePath.lastIndexOf(sp), filePath.lastIndexOf(".")) +
sp;
                workingDocPath = unzipr.Unzip(filePath, tempOutPath);
+
                // Store paths.
                zippedPath = filePath;
        }
@@ -194,7 +182,30 @@
                arch.save(doc, path);
                return arch;
        }
+
+
////////////////////////////////////////////////////////////////////////////
/////
+       // Clears the list of path indices so we can once again create them
on
the fly.
+       // Needed when we save a nimas file. We have to delete all of the
temp
files,
+       // zip, then recreate them for the user.
+       public void resetDuplicatePathList() {
+               allPaths.clear();
+       }

+
////////////////////////////////////////////////////////////////////////////
/////
+       // Resets the path list(resetDuplicatePathList()), and writes a
+       // chunked document to disk using the specified index.
+       public void resetThenWrite(int idx) {
+               resetDuplicatePathList();
+               wrtieToDisk(idx);
+       }
+
+
////////////////////////////////////////////////////////////////////////////
/////
+       // Returns the number of potential files we would have
+       // if all of them were written to disk.
+       public int getNumPotentialFiles() {
+               return numPotentialFiles;
+       }
+
        /***
         * Write to the disk once at time if the file is not there already
         * @param index
@@ -203,20 +214,23 @@
        public String wrtieToDisk(int index){
                // Build string path.
                String outPath = workingDocPath.substring(0,
workingDocPath.lastIndexOf(BBIni.getFileSep())) + BBIni.getFileSep() +
Integer.toString(index) + ".xml";
-               if(!(allPaths.contains(Integer.toString(index)))){
+               if( !(allPaths.contains(Integer.toString(index))) ){

-                       Document curDoc=manageNimas(index);
+                       // Break up document by level1 elements and retrieve
the current one.
+                       Document curDoc = manageNimas(index);
+
                        // Create file utility for saving our xml files.
                        FileUtils fu = new FileUtils();

                        // Write file.
                        fu.createXMLFile( curDoc, outPath );
                        allPaths.add(Integer.toString(index));
+
+                       // Add this file to the temp list so it will be
deleted later.
+                       tempList.add(outPath);
                }

                return outPath;
-
-
        }

      /***
@@ -231,14 +245,39 @@
                File temp = new File(sourcePath);
                //get all level1 element
                Nodes allNode=getLevel1();
+
+               // Store the number of files we would create if we
+               // ran through all of the indices.
+               numPotentialFiles = allNode.size();
+
                if (index<allNode.size()){
                        Node node=allNode.get(index);
                        currentDoc=breakDocument(temp,node);
+               }
+
+               // Get the number of <img> elements.
+               if(getImgCountList().size() == 0)
+               {
+                       // Go through every <level1> element, and count the
+                       // images.
+                       for(int curLvl1 = 0; curLvl1 < allNode.size();
curLvl1++)
+                       {
+                               // Add the count.
+                               Node nd = allNode.get(curLvl1);
+                               addToNumImgsList( new
Document((Element)nd.copy()), curLvl1);
+                       }

+                       // Save paths to files that we may create.
+                       // Fill list.
+                       if(epubFileList.size() == 0) {
+                               for(int curF = 0; curF < numPotentialFiles;
curF++) {
+
epubFileList.add(workingDocPath.substring(0,
workingDocPath.lastIndexOf(BBIni.getFileSep())) + BBIni.getFileSep() +
Integer.toString(curF) + ".xml");
+                               }
+                       }
                }

-               return currentDoc;

+               return currentDoc;
        }


@@ -359,60 +398,60 @@
        }


////////////////////////////////////////////////////////////////////////////
/
-       // Writes segmented NIMAS documents to disc and returns a list of
their
+       // Writes segmented NIMAS documents to disk and returns a list of
their
        // paths.
-       public ArrayList<String> writeNimasSegments()
-       {
-        // Grab list of documents after breaking them up by level1's.
-        ArrayList<Document> docs = manageNimas();
-
-           // Create file utility for saving our xml files.
-               FileUtils fu = new FileUtils();
-
-               // Path to xsl file. Add three slashes to avoid BS.
-       String xslPath = "file:///" + BBIni.getProgramDataPath() +
BBIni.getFileSep() + "xsl" + BBIni.getFileSep() + "dtb2005html.xsl";
+//     public ArrayList<String> writeNimasSegments()
+//     {
+//        // Grab list of documents after breaking them up by level1's.
+//        ArrayList<Document> docs = manageNimas();
+//
+//         // Create file utility for saving our xml files.
+//             FileUtils fu = new FileUtils();
+//
+//             // Path to xsl file. Add three slashes to avoid BS.
+//     String xslPath = "file:///" + BBIni.getProgramDataPath() +
BBIni.getFileSep() + "xsl" + BBIni.getFileSep() + "dtb2005html.xsl";
+////
+////           // Build the xsl document.
+//     Document xslDoc = null;
+//             Builder builder = new Builder();
+//        try { xslDoc = builder.build(xslPath); }
+//        catch (ValidityException e1) { e1.printStackTrace(); }
+//        catch (ParsingException e1) { e1.printStackTrace(); }
+//        catch (IOException e1) { e1.printStackTrace(); }
+//
+//        // Create the transform.
+//        XSLTransform xslt = null;
+//        try { xslt = new XSLTransform(xslDoc); }
+//        catch (XSLException e1) { e1.printStackTrace(); }
  //
-//     // Build the xsl document.
-       Document xslDoc = null;
-               Builder builder = new Builder();
-        try { xslDoc = builder.build(xslPath); }
-        catch (ValidityException e1) { e1.printStackTrace(); }
-        catch (ParsingException e1) { e1.printStackTrace(); }
-        catch (IOException e1) { e1.printStackTrace(); }
-
-        // Create the transform.
-        XSLTransform xslt = null;
-        try { xslt = new XSLTransform(xslDoc); }
-        catch (XSLException e1) { e1.printStackTrace(); }
-
-        // Loop through the documents, write to file, count images in each.
-        for(int curDoc = 0; curDoc < docs.size(); curDoc++)
-        {
-               // Finally transform the document.
-            Nodes newDocNodes = null;
-                       try { newDocNodes = xslt.transform( docs.get(curDoc)
); }
-                       catch (XSLException e) { e.printStackTrace(); }
-            Document transformedDoc = XSLTransform.toDocument(newDocNodes);
-
-               // Build string path.
-               String outPath = workingDocPath.substring(0,
workingDocPath.lastIndexOf(BBIni.getFileSep())) + BBIni.getFileSep() +
Integer.toString(curDoc) + ".xhtml";
-
-               // Add path to list.
-               epubFileList.add(outPath);
-
-               // Count the images in this document.
-               addToNumImgsList(docs.get(curDoc));
-
-               // Write file.
-               fu.createXMLFile( transformedDoc, outPath );
-//             fu.createXMLFile( docs.get(curDoc), outPath );
-
-        } // for(int curDoc...
-
-        // Create the opf file.
-        return epubFileList;
-
-       } // writeNimasSegments()
+//        // Loop through the documents, write to file, count images in
each.
+//        for(int curDoc = 0; curDoc < docs.size(); curDoc++)
+//        {
+//             // Finally transform the document.
+//            Nodes newDocNodes = null;
+//                     try { newDocNodes = xslt.transform( docs.get(curDoc)
); }
+//                     catch (XSLException e) { e.printStackTrace(); }
+//            Document transformedDoc =
XSLTransform.toDocument(newDocNodes);
+//
+//             // Build string path.
+//             String outPath = workingDocPath.substring(0,
workingDocPath.lastIndexOf(BBIni.getFileSep())) + BBIni.getFileSep() +
Integer.toString(curDoc) + ".xhtml";
+//
+//             // Add path to list.
+//             epubFileList.add(outPath);
+//
+//             // Count the images in this document.
+//             addToNumImgsList(docs.get(curDoc));
+//
+//             // Write file.
+//             fu.createXMLFile( transformedDoc, outPath );
+////                   fu.createXMLFile( docs.get(curDoc), outPath );
+//
+//        } // for(int curDoc...
+//
+//        // Create the opf file.
+//        return epubFileList;
+//
+//     } // writeNimasSegments()


////////////////////////////////////////////////////////////////////////////
/
        // Helper: Uses list created with manageNimas() to create an OPF
file for
=======================================
--- /src/main/org/brailleblaster/perspectives/braille/Manager.java      Thu
Jul
31 15:34:17 2014 UTC
+++ /src/main/org/brailleblaster/perspectives/braille/Manager.java      Thu
Jul
31 18:51:41 2014 UTC
@@ -749,8 +749,7 @@
            if (arch.getCurrentConfig().equals("epub.cfg")){
                text.insertNewNode(list.get(posList.get(posList.size() -
1)).end,"aside");
            }
-           else{
-
+           else{
                    text.insertNewNode(list.get(posList.get(posList.size() -

1)).end,"prodnote");
            }

@@ -837,12 +836,11 @@
                        group.setRedraw(false);
                        if (message.getValue("multiSelect").equals(false)) {
                                handleStyleCursorSelected(message);
-
                        } else {
                                handleStyleMultiSelected(message);
                        }
-
-               } else
+               }
+               else
                        new Notify(lh.localValue("nothingToApply"));
        }
        /***
@@ -853,7 +851,7 @@
                Element parent = parentStyle(list.getCurrent(), message);
                ArrayList<TextMapElement> itemList =
list.findTextMapElements(
                                list.getCurrentIndex(), parent, true);
-               adjustStyle(itemList, message);
+               adjustStyle(itemList, message,parent);

        }
        /***
@@ -881,7 +879,7 @@
                                Element parent = parentStyle(tempElement,
styleMessage);

                                ArrayList<TextMapElement> itemList =
list.findTextMapElements(list.getNodeIndex(tempElement), parent, true);
-                               adjustStyle( itemList,styleMessage);
+                               adjustStyle( itemList,styleMessage,parent);
                        }
                }

@@ -892,7 +890,7 @@
         * @param message : passing information regarding styles
         */

-       private void adjustStyle(ArrayList<TextMapElement> itemList, Message

message) {
+       private void adjustStyle(ArrayList<TextMapElement> itemList, Message

message,Element parent) {
                int start = list.indexOf(itemList.get(0));
                int end = list.indexOf(itemList.get(itemList.size() - 1));
                int origPos =
list.get(list.getNodeIndex(itemList.get(0))).start;
@@ -928,11 +926,84 @@
                                        (Integer)
message.getValue("linesAfterOffset"), origPos);

                treeView.adjustItemStyle(list.getCurrent());
+
if(((Styles)message.getValue("Style")).getName().equals("boxline"))
+                       createBoxline(parent, message, itemList);
                group.setRedraw(true);

        }


+
+       /** Wraps a block level element in the appropriate tag then
translates
and adds boxline brl top and bottom nodes
+        * @param p: parent of text nodes, the block element to be wrapped
in a
boxline
+        * @param m: message passed to views containing offset positions
+        * @param itemList: arraylist containing text nodes of the block
element
+        */
+       private void createBoxline(Element p, Message m,
ArrayList<TextMapElement> itemList){
+               Element wrapper = document.wrapElement(p, "boxline");
+               if(wrapper != null){
+                       Element boxline =
document.translateElement((Element)wrapper.copy());
+                       System.out.println(boxline.toXML().toString());
+                       int startPos = list.indexOf(itemList.get(0));
+
+                       //find start position
+                       int start, brailleStart;
+                       if(m.contains("previousStyle") &&
((Styles)m.getValue("previousStyle")).contains(StylesType.linesBefore)){
+                               start = (Integer)m.getValue("prev");
+                               brailleStart =
(Integer)m.getValue("braillePrev");
+                       }
+                       else {
+                               start = itemList.get(0).start;
+                               brailleStart =
itemList.get(0).brailleList.getFirst().start;
+                       }
+
+                       //insert top boxline
+                       wrapper.insertChild(boxline.removeChild(0), 0);
+                       BrlOnlyMapElement b1 =  new
BrlOnlyMapElement(wrapper.getChild(0),
(Element)wrapper);
+                       b1.setOffsets(start, start + b1.textLength());
+                       b1.setBrailleOffsets(brailleStart, brailleStart +
b1.getText().length());
+                       vi.addElementToSection(list, b1, startPos);
+
+                       //set text
+                       text.insertText(start, list.get(startPos).getText()
+ "\n");
+                       braille.insertText(brailleStart,
list.get(startPos).brailleList.getFirst().value() + "\n");
+                       list.shiftOffsetsFromIndex(startPos + 1,
list.get(startPos).getText().length() + 1,
list.get(startPos).brailleList.getFirst().value().length() + 1,
list.get(startPos + 1).start);
+
+                       //find end position
+                       int endPos =
list.indexOf(itemList.get(itemList.size() - 1)) + 1;
+                       int end, brailleEnd;
+                       if(m.contains("previousStyle") &&
((Styles)m.getValue("previousStyle")).contains(StylesType.linesAfter)){
+                               end = (Integer)m.getValue("next") +
b1.getText().length() + 1;
+                               brailleEnd =
(Integer)m.getValue("brailleNext") +
b1.getText().length() + 1;
+                       }
+                       else {
+                               end = list.get(endPos - 1).end;
+                               brailleEnd = itemList.get(itemList.size() -

1).brailleList.getLast().end;
+                       }
+
+                       //insert bottom boxline
+
wrapper.appendChild(boxline.removeChild(boxline.getChildCount() - 1));
+                       BrlOnlyMapElement b2 =  new
BrlOnlyMapElement(wrapper.getChild(wrapper.getChildCount() - 1),
(Element)wrapper);
+                       b2.setOffsets(end + 1, end + 1 + b2.textLength());
+                       b2.setBrailleOffsets(brailleEnd + 1, brailleEnd + 1
+
b2.getText().length());
+                       vi.addElementToSection(list, b2, endPos);
+
+                       //set text
+                       text.insertText(end, "\n" +
list.get(endPos).getText());
+                       braille.insertText(brailleEnd, "\n" +
list.get(endPos).brailleList.getFirst().value());
+                       list.shiftOffsetsFromIndex(endPos + 1,
list.get(endPos).getText().length() + 1,
list.get(endPos).brailleList.getFirst().value().length() + 1,
list.get(endPos).start);
+
+                       //remove items from tree
+                       for(int i = 0; i < itemList.size(); i++){
+                               treeView.removeItem(itemList.get(i), new
Message(null));
+                       }
+
+                       //add aside or sidebar to tree
+                       treeView.newTreeItem(list.get(startPos),
treeView.getSelectionIndex(),
0);
+
handleSetCurrent(Message.createSetCurrentMessage(Sender.TREE,
list.get(list.getCurrentIndex() + 1).start, false));
+
dispatch(Message.createUpdateCursorsMessage(Sender.TREE));
+               }
+       }

        public void saveAs(){
                BBFileDialog dialog = new BBFileDialog(wp.getShell(),
SWT.SAVE,
arch.getFileTypes(), arch.getFileExtensions());
=======================================
---
/src/main/org/brailleblaster/perspectives/braille/stylepanel/StyleManager.ja
va
Thu Jul 31 15:38:44 2014 UTC
+++
/src/main/org/brailleblaster/perspectives/braille/stylepanel/StyleManager.ja
va
Thu Jul 31 18:51:41 2014 UTC
@@ -50,7 +50,7 @@
  public class StyleManager{

      private StyleTable table;
-    private EditPanel editor;
+    private StylePanel editor;
      private String configFile;
      Manager dm;
      TextMapElement t;
@@ -83,7 +83,10 @@
        lastSelection = table.getTable().getSelectionIndex();
        String style = table.getTable().getSelection()[0].getText(1);
        this.table.dispose();
-       editor = new EditStyleView(this, dm.getGroup(),
semanticsTable.get(style));
+       if(semanticsTable.get(style).getName().equals("boxline"))
+               editor = new EditBoxLineView(this, dm.getGroup(),
semanticsTable.get(style));
+       else
+               editor = new EditStyleView(this, dm.getGroup(),
semanticsTable.get(style));
        dm.setTabList();
      }

@@ -102,7 +105,7 @@
      public void apply(String item){
        Message m = new Message(BBEvent.UPDATE_STYLE);
        Styles style = semanticsTable.get(item);
-
+
        if(style != null){
                m.put("Style", style);
                if(dm.getText().isMultiSelected()==true)
=======================================
---
/src/main/org/brailleblaster/perspectives/braille/views/wp/TextView.java

Thu Jul 31 15:34:17 2014 UTC
+++
/src/main/org/brailleblaster/perspectives/braille/views/wp/TextView.java

Thu Jul 31 18:51:41 2014 UTC
@@ -826,7 +826,7 @@
                        handleLineWrap(start, reformattedText, margin,
style.contains(StylesType.firstLineIndent));
                }

-               if(isFirst(n) && style.contains(StylesType.firstLineIndent))
+               if(!(list.get(listIndex) instanceof BrlOnlyMapElement) &&
isFirst(n) &&
style.contains(StylesType.firstLineIndent))
                        setFirstLineIndent(start, style);

                if(style.contains(StylesType.format))
@@ -1515,86 +1515,89 @@
                //Get previous style for comparison on adding or removing
lines before
or after
                Styles style = (Styles)m.getValue("style");
                Styles previousStyle = (Styles)m.getValue("previousStyle");
-
+               boolean boxline = style.getName().equals("boxline");
+
                setListenerLock(true);
                //Reset indent, alignment, and emphasis
-               view.setLineIndent(view.getLineAtOffset(start),
getLineNumber(start,
view.getTextRange(start, (end - start))), 0);
-               view.setLineAlignment(view.getLineAtOffset(start),
getLineNumber(start,
view.getTextRange(start, (end - start))), SWT.LEFT);
-               setFontStyleRange(start, end - start, new StyleRange());
+               if(!boxline){
+                       view.setLineIndent(view.getLineAtOffset(start),
getLineNumber(start,
view.getTextRange(start, (end - start))), 0);
+                       view.setLineAlignment(view.getLineAtOffset(start),
getLineNumber(start,
view.getTextRange(start, (end - start))), SWT.LEFT);
+                       setFontStyleRange(start, end - start, new
StyleRange());

-               if(!style.contains(StylesType.linesBefore) &&
previousStyle.contains(StylesType.linesBefore))
-                       removeLinesBefore(m);
+                       if(!style.contains(StylesType.linesBefore) &&
previousStyle.contains(StylesType.linesBefore))
+                               removeLinesBefore(m);

-               if(!style.contains(StylesType.linesAfter) &&
previousStyle.contains(StylesType.linesAfter))
-                       removeLinesAfter(m);
+                       if(!style.contains(StylesType.linesAfter) &&
previousStyle.contains(StylesType.linesAfter))
+                               removeLinesAfter(m);
+               }
+
                start = (Integer)m.getValue("start");
                end = (Integer)m.getValue("end");
                int prev = (Integer)m.getValue("prev");
                int next = (Integer)m.getValue("next");
-
-               for (Entry<StylesType, Object> entry : style.getEntrySet())
{
-                       switch(entry.getKey()){
-                               case linesBefore:
-                                       int linesBeforeOffset;
-                                       if(start != prev){
-                                               view.replaceTextRange(prev,
(start - prev), "");
-                                               length = start - prev;
-                                       }
-                                       spaces =
Integer.valueOf((String)entry.getValue());
+               if(!boxline){
+                       for (Entry<StylesType, Object> entry :
style.getEntrySet()) {
+                               switch(entry.getKey()){
+                                       case linesBefore:
+                                               int linesBeforeOffset;
+                                               if(start != prev){
+
view.replaceTextRange(prev, (start - prev), "");
+                                                       length = start -
prev;
+                                               }
+                                               spaces =
Integer.valueOf((String)entry.getValue());

-                                       textBefore =
makeInsertionString(spaces,'\n');
-                                       linesBeforeOffset = spaces - length;
+                                               textBefore =
makeInsertionString(spaces,'\n');
+                                               linesBeforeOffset = spaces -
length;

-                                       insertBefore(start - (start - prev),
textBefore);
-                                       m.put("linesBeforeOffset",
linesBeforeOffset);
-                                       start += linesBeforeOffset;
-                                       end += linesBeforeOffset;
-                                       if(next != -1)
-                                               next += linesBeforeOffset;
-                                       break;
-                               case linesAfter:
-                                       length = 0;
-                                       int linesAfterOffset;
-                                       if(end != next && next != 0){
-                                               view.replaceTextRange(end,
(next - end), "");
-                                               length = next - end;
-                                       }
+                                               insertBefore(start - (start
- prev), textBefore);
+                                               m.put("linesBeforeOffset",
linesBeforeOffset);
+                                               start += linesBeforeOffset;
+                                               end += linesBeforeOffset;
+                                               if(next != -1)
+                                                       next +=
linesBeforeOffset;
+                                               break;
+                                       case linesAfter:
+                                               length = 0;
+                                               int linesAfterOffset;
+                                               if(end != next && next !=
0){
+
view.replaceTextRange(end, (next - end), "");
+                                                       length = next - end;
+                                               }

-                                       spaces =
Integer.valueOf((String)entry.getValue());
-                                       textBefore =
makeInsertionString(spaces,'\n');
-                                       insertBefore(end, textBefore);
-                                       linesAfterOffset = spaces - length;
-                                       m.put("linesAfterOffset",
linesAfterOffset);
-                                       break;
-                               case format:
-                                       setAlignment(start, end, style);
-                                       break;
-                               case firstLineIndent:
-
if(Integer.valueOf((String)entry.getValue()) > 0 ||
style.contains(StylesType.leftMargin))
-                                               setFirstLineIndent(start,
style);
-                                       break;
-                               case leftMargin:
-
if(style.contains(StylesType.firstLineIndent))
-                                               handleLineWrap(start,
view.getTextRange(start, (end - start)),
Integer.valueOf((String)entry.getValue()), true);
-                                       else
-                                               handleLineWrap(start,
view.getTextRange(start, (end - start)),
Integer.valueOf((String)entry.getValue()), false);
-                                       break;
+                                               spaces =
Integer.valueOf((String)entry.getValue());
+                                               textBefore =
makeInsertionString(spaces,'\n');
+                                               insertBefore(end,
textBefore);
+                                               linesAfterOffset = spaces -
length;
+                                               m.put("linesAfterOffset",
linesAfterOffset);
+                                               break;
+                                       case format:
+                                               setAlignment(start, end,
style);
+                                               break;
+                                       case firstLineIndent:
+
if(Integer.valueOf((String)entry.getValue()) > 0 ||
style.contains(StylesType.leftMargin))
+
setFirstLineIndent(start, style);
+                                               break;
+                                       case leftMargin:
+
if(style.contains(StylesType.firstLineIndent))
+
handleLineWrap(start, view.getTextRange(start, (end - start)),
Integer.valueOf((String)entry.getValue()), true);
+                                               else
+
handleLineWrap(start, view.getTextRange(start, (end - start)),
Integer.valueOf((String)entry.getValue()), false);
+                                               break;
+                                       default:
+                                               break;
+                               }

-                               default:
-                                       break;
-                       }
-
-                       int offset = (Integer)m.getValue("offset");
+                               int offset = (Integer)m.getValue("offset");

-                       //inline elements may have different emphasis, so
all must be check
seperately
-                       for(int i = 0; i < list.size(); i++){
-                               Styles nodeStyle =
stylesTable.makeStylesElement(list.get(i).parentElement(), list.get(i).n);
-                               if(nodeStyle.contains(StylesType.emphasis))
-                                       setFontStyleRange(list.get(i).start
+ offset, (list.get(i).end +
offset) - (list.get(i).start + offset),
(StyleRange)nodeStyle.get(StylesType.emphasis));
+                               //inline elements may have different
emphasis, so all must be check
seperately
+                               for(int i = 0; i < list.size(); i++){
+                                       Styles nodeStyle =
stylesTable.makeStylesElement(list.get(i).parentElement(), list.get(i).n);
+
if(nodeStyle.contains(StylesType.emphasis))
+
setFontStyleRange(list.get(i).start + offset, (list.get(i).end +
offset) - (list.get(i).start + offset),
(StyleRange)nodeStyle.get(StylesType.emphasis));
+                               }
                        }
-
+                       setListenerLock(false);
                }
-               setListenerLock(false);
        }

        //private helper method used by adjust style

============================================================================
==
Revision: 1e17b7a92010
Branch:   default
Author:   Sahel "sahel.mastoureshgh@xxxxxxxxx"
Date:     Thu Jul 31 18:54:23 2014 UTC
Log:      Fixed merge conflicts second
http://code.google.com/p/brailleblaster/source/detail?r=1e17b7a92010

Modified:
  /src/main/org/brailleblaster/perspectives/braille/views/wp/TextView.java

=======================================
---
/src/main/org/brailleblaster/perspectives/braille/views/wp/TextView.java

Thu Jul 31 18:51:41 2014 UTC
+++
/src/main/org/brailleblaster/perspectives/braille/views/wp/TextView.java

Thu Jul 31 18:54:23 2014 UTC
@@ -103,7 +103,12 @@
        private PaintObjectListener paintObjListener;
        private int originalStart, originalEnd;
        private TextMapElement currentElement;
+
+       int startSelection;
+       int endSelection;
+
        private boolean multiSelected;
+

        public TextView (Manager manager, Group documentWindow,
BBSemanticsTable
table) {
                super (manager, documentWindow, LEFT_MARGIN, RIGHT_MARGIN,
TOP_MARGIN,
BOTTOM_MARGIN, table);
@@ -119,7 +124,16 @@
                view.addSelectionListener(selectionListener = new
SelectionAdapter(){
                        @Override
                        public void widgetSelected(SelectionEvent e) {
+
                                selectionArray = view.getSelectionRanges();
+                               //Added this part for start and end of text
selection
+                               for (int i = 0; i < selectionArray.length-1;
i++) {
+                                       startSelection=selectionArray[i];
+
endSelection=selectionArray[i]+selectionArray[i+1];
+
+
+                            }
+                                System.out.println(startSelection+"
"+endSelection);
                                if(selectionArray[1] > 0){
                                        multiSelected=true;
                                        currentChar = ' ';



 

Other related posts: