Revision: 75ae8a52cb8d Author: francois.ouellette01@xxxxxxxxx Date: Thu Jul 19 05:15:50 2012 Log: retrofit support for Java 6 and refine RecentDocument class http://code.google.com/p/brailleblaster/source/detail?r=75ae8a52cb8d Modified: /build.xml /src/main/org/brailleblaster/wordprocessor/RecentDocuments.java /src/main/org/brailleblaster/wordprocessor/UTD.java ======================================= --- /build.xml Wed Jul 18 22:18:57 2012 +++ /build.xml Thu Jul 19 05:15:50 2012 @@ -14,7 +14,7 @@ <target name="compile" depends="init"> <javac srcdir="${srcdir}" destdir="${builddir}" -includeantruntime="false" source="1.7" > +includeantruntime="false" source="1.6" target="1.6" > <classpath> <pathelement path="${classpath}"/> <pathelement location="${classpath}/swt.jar"/> =======================================--- /src/main/org/brailleblaster/wordprocessor/RecentDocuments.java Wed May 9 19:47:26 2012 +++ /src/main/org/brailleblaster/wordprocessor/RecentDocuments.java Thu Jul 19 05:15:50 2012
@@ -41,13 +41,16 @@ import org.eclipse.swt.*; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Monitor; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Combo; import org.brailleblaster.BBIni; +import org.brailleblaster.localization.LocaleHandler; import org.brailleblaster.util.Notify; /** @@ -65,6 +68,8 @@ private static final int MAX_NUM_FILES=50; private String fileSep; private DocumentManager dm; + // FO + LocaleHandler lh = new LocaleHandler(); RecentDocuments(final DocumentManager dm) { this.dm = dm; @@ -80,17 +85,36 @@ Display display = BBIni.getDisplay(); shell = new Shell (display, SWT.DIALOG_TRIM); shell.setText("Recent documents"); + // FO + Monitor primary = display.getPrimaryMonitor(); + Rectangle bounds = primary.getBounds(); + Rectangle rect = shell.getBounds(); + int x = bounds.x + ((bounds.width - rect.width) / 2) + 10; + int y = bounds.y + ((bounds.height - rect.height) / 2) + 10; + shell.setLocation (x, y); + GridLayout gridLayout = new GridLayout (); shell.setLayout (gridLayout); - combo = new Combo (shell, SWT.DROP_DOWN|SWT.READ_ONLY); + + combo = new Combo (shell, SWT.DROP_DOWN | SWT.READ_ONLY); + if (recentDocsArr.length > 25) { + combo.setVisibleItemCount(25); + } else { + combo.setVisibleItemCount(recentDocsArr.length); + } combo.setItems(recentDocsArr); + combo.select(0); GridData data = new GridData (); data.minimumWidth = 300; data.grabExcessHorizontalSpace = true; combo.setLayoutData(data); + Button open = new Button(shell, SWT.PUSH); shell.setDefaultButton(open); - open.setText("&Open"); + //Button cancel = new Button(shell, SWT.PUSH); + //cancel.setText(lh.localValue("buttonCancel")); + + open.setText(lh.localValue("&Open")); open.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { int key = combo.getSelectionIndex(); =======================================--- /src/main/org/brailleblaster/wordprocessor/UTD.java Wed Jul 18 22:18:57 2012 +++ /src/main/org/brailleblaster/wordprocessor/UTD.java Thu Jul 19 05:15:50 2012
@@ -60,7 +60,7 @@ * This class encapsulates handling of the Universal * TactileDocument Markup Language (UTDML); */ -class UTD { +class UTD { //static int pageCount; //static int pageCount2; @@ -160,6 +160,51 @@ element = (Element)newNode; elementName = element.getLocalName(); + if (elementName.contentEquals("head")) { + System.out.println("head"); + Element utdElement = findUtdMeta(element); + doUtdMeta (utdElement); // found it + + } else if (elementName.contentEquals("brl")) { + System.out.println("brl"); + if (i > 0) { + try{ + beforeBrlNode = newNode.getChild(i - 1); + } + catch(IndexOutOfBoundsException e ){+ //The brl child, newNode, may not have any grandchild of node + System.out.println("findBrlNodes: a brl Node does not have child, i = "+i );
+ beforeBrlNode = null; + return; + } + } else { + beforeBrlNode = null; + } + doBrlNode (element); + + } else if (elementName.contentEquals("p")) { + System.out.println("p"); + + for (int j = 0; j < node.getChildCount(); j++) { + // we need to dig down the element for the <brl> elements + Node pNode = node.getChild(j); + Element pElement = (Element)pNode; + for (int k = 0; k < pElement.getChildCount(); k++) { + Node bNode = pElement.getChild(k); + if (bNode instanceof Element) { + doBrlNode((Element)bNode); + } + } + } + + } else { + System.out.println("else"); + + findBrlNodes (element); // go one level down + } + + + /** switch with String works only with 1.7 switch (elementName) { case ("head"): { Element utdElement = findUtdMeta(element); @@ -186,7 +231,7 @@ // FO case ("p"): { for (int j = 0; j < node.getChildCount(); j++) {- /** we need to dig down the element for the <brl> elements **/
+ // we need to dig down the element for the <brl> elements Node pNode = node.getChild(j); Element pElement = (Element)pNode; for (int k = 0; k < pElement.getChildCount(); k++) { @@ -201,6 +246,7 @@ default : findBrlNodes (element); // go one level down } // end switch +**/ }