[brailleblaster] [brailleblaster.newdesign] push by brandon....@xxxxxxxxx - Updated checkSemantics method on 2013-05-27 00:31 GMT

  • From: brailleblaster@xxxxxxxxxxxxxx
  • To: brailleblaster@xxxxxxxxxxxxx
  • Date: Mon, 27 May 2013 00:31:27 +0000

Revision: 549fb48f54b8
Branch:   default
Author:   Brandon Roller <brandon.r.roller@xxxxxxxxx>
Date:     Sun May 26 17:29:42 2013
Log:      Updated checkSemantics method
http://code.google.com/p/brailleblaster/source/detail?r=549fb48f54b8&repo=newdesign

Modified:
 /src/main/org/brailleblaster/mapping/MapList.java
 /src/main/org/brailleblaster/wordprocessor/BBDocument.java
 /src/main/org/brailleblaster/wordprocessor/DocumentManager.java

=======================================
--- /src/main/org/brailleblaster/mapping/MapList.java Fri May 24 05:08:30 2013 +++ /src/main/org/brailleblaster/mapping/MapList.java Sun May 26 17:29:42 2013
@@ -441,6 +441,7 @@
                                if(textList.get(i).equals(this.get(j).n)){
                                        itemList.add(this.get(j));
                                        pos = j + 1;
+                                       break;
                                }
                        }
                }
=======================================
--- /src/main/org/brailleblaster/wordprocessor/BBDocument.java Fri May 24 05:08:30 2013 +++ /src/main/org/brailleblaster/wordprocessor/BBDocument.java Sun May 26 17:29:42 2013
@@ -35,6 +35,7 @@
 import java.io.InputStream;
 import java.io.StringReader;
 import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
 import java.util.logging.Level;
 import java.util.logging.Logger;

@@ -65,9 +66,11 @@
        private FileUtils fu = new FileUtils();
        static Logger logger = BBIni.getLogger();;
        private DocumentManager dm;
+       private ArrayList<String>missingSemanticsList;

        public BBDocument(DocumentManager dm){
                this.dm = dm;
+               this.missingSemanticsList = new ArrayList<String>();
        }

public boolean startDocument (InputStream inputStream, String configFile, String configSettings) throws Exception {
@@ -505,4 +508,25 @@

                m.put("diff", diff);
        }
+
+       public void checkSemantics(Element e){
+ if(!e.getLocalName().equals("meta") && e.getAttributeValue("semantics") == null){ + //Notify errorMessage = new Notify("No semantic attribute exists for element \"" + e.getLocalName() + "\". Please consider editing the configuration files.");
+                       Attribute attr = new Attribute("semantics", 
"style,para");
+                       e.addAttribute(attr);
+                       
if(!this.missingSemanticsList.contains(e.getLocalName()))
+                               this.missingSemanticsList.add(e.getLocalName());
+               }
+       }
+
+       public void notifyUser(){
+               if(this.missingSemanticsList.size() > 0){
+ String text = "No semantic attribute exists for the following element(s): \n";
+                       for(int i = 0; i < this.missingSemanticsList.size(); 
i++){
+                               text += this.missingSemanticsList.get(i) + "\n";
+                       }
+ text += "Please check your document and consider editing the configuration files.";
+                       new Notify(text);
+               }
+       }
 }
=======================================
--- /src/main/org/brailleblaster/wordprocessor/DocumentManager.java Fri May 24 05:08:30 2013 +++ /src/main/org/brailleblaster/wordprocessor/DocumentManager.java Sun May 26 17:29:42 2013
@@ -241,7 +241,8 @@
                                this.documentName = fileName;
                                setTabTitle(fileName);
                                
this.treeView.setRoot(this.document.getRootElement(), this);
-                               initializeViews(this.document.getRootElement());
+                               initializeViews(this.document.getRootElement());
+                               this.document.notifyUser();
                                //list.getLast().brailleList.removeLast();
this.text.view.replaceTextRange(this.text.view.getCharCount() - 1, 1, ""); this.braille.view.replaceTextRange(this.braille.view.getCharCount() - 1, 1, "");
@@ -276,7 +277,7 @@
                        }
                        else {
if(current.getChild(i) instanceof Element && !((Element)current.getChild(i)).getLocalName().equals("pagenum")){
-                                       
checkSemantics((Element)current.getChild(i));
+                                       
this.document.checkSemantics((Element)current.getChild(i));
                                        initializeViews(current.getChild(i));
                                }
                                else if(!(current.getChild(i) instanceof 
Element)) {

Other related posts:

  • » [brailleblaster] [brailleblaster.newdesign] push by brandon....@xxxxxxxxx - Updated checkSemantics method on 2013-05-27 00:31 GMT - brailleblaster