Revision: 676d2d13d7e0 Branch: default Author: cmyers@xxxxxxxxxxxxxxxxx Date: Thu Jan 16 00:14:11 2014 UTCLog: ImgDesc cleanup. Refactored undo. ImgDescView/Menu/Controller code sonsolidated.
http://code.google.com/p/brailleblaster/source/detail?r=676d2d13d7e0 Modified: /dist/programData/liblouisutdml/lbu_files/nemeth.cfg/src/main/org/brailleblaster/perspectives/imageDescriber/ImageDescriberController.java /src/main/org/brailleblaster/perspectives/imageDescriber/UIComponents/ImageDescriberMenu.java /src/main/org/brailleblaster/perspectives/imageDescriber/document/ImageDescriber.java /src/main/org/brailleblaster/perspectives/imageDescriber/views/ImageDescriberView.java
=======================================--- /dist/programData/liblouisutdml/lbu_files/nemeth.cfg Tue Jun 19 16:11:04 2012 UTC +++ /dist/programData/liblouisutdml/lbu_files/nemeth.cfg Thu Jan 16 00:14:11 2014 UTC
@@ -1,7 +1,8 @@ cellsperline 32 +paperHeight 11 +paperWidth 11.5 braillePages no mathexprtable nemeth.ctb editTable nemeth_edit.ctb internetAccess no semanticFiles *,nemeth.sem - =======================================--- /src/main/org/brailleblaster/perspectives/imageDescriber/ImageDescriberController.java Thu Jan 9 16:22:23 2014 UTC +++ /src/main/org/brailleblaster/perspectives/imageDescriber/ImageDescriberController.java Thu Jan 16 00:14:11 2014 UTC
@@ -251,8 +251,9 @@ } // If the document came from a zip file, then rezip it. - if(zippedPath.length() > 0) - zipDocument(); + if(zippedPath != null) + if(zippedPath.length() > 0) + zipDocument(); documentEdited = false; } @@ -358,17 +359,21 @@ public void setImageToPrevious(){ // Change main image to previous element image. imgDesc.prevImageElement(); + + // Set image preview. idv.setMainImage(); // Get prodnote text/image description. idv.setTextBox(); - //imgDescTextBox.setText( imgDesc.getCurProdText() ); // Show current image index and name. setImageInfo();- //imgDescShell.setText("Image Describer - " + imgDesc.getCurrentElementIndex() + " - " + imgDesc.currentImageElement().getAttributeValue("src") );
+ // Set alt text. idv.setAltBox(imgDesc.getCurElmAttribute("alt")); + + // Scroll browser to current image. + idv.scrollBrowserToCurImg(); } public void setImageToNext(){ @@ -377,43 +382,36 @@ //Change current image in dialog. idv.setMainImage(); - /* - Image curElmImage = imgDesc.getCurElementImage(); - if(curElmImage != null)- mainImage.setImage( imgHelper.createScaledImage(curElmImage, imageWidth, imageHeight) );
- else- mainImage.setImage( imgHelper.createScaledImage(new Image(null, BBIni.getProgramDataPath() + BBIni.getFileSep() + "images" + BBIni.getFileSep() + "imageMissing.png"),
- imageWidth, imageHeight) ); - */ // Get prodnote text/image description. idv.setTextBox(); - - //imgDescTextBox.setText( imgDesc.getCurProdText() ); // Show current image index and name. setImageInfo();- //imgDescShell.setText("Image Describer - " + imgDesc.getCurrentElementIndex() + " - " + imgDesc.currentImageElement().getAttributeValue("src") );
+ // Set alt text. idv.setAltBox(imgDesc.getCurElmAttribute("alt")); + + // Scroll browser to current image. + idv.scrollBrowserToCurImg(); + } + + // Undo-es current element/image changes. + public void undo() + { + // Undo the changes. + imgDesc.undoCurDescAndAlt(); + // Get prodnote text/image description. + idv.setTextBox(); + // Set alt text. + idv.setAltBox(imgDesc.getCurElmAttribute("alt")); + } public void apply(){ imgDesc.setDescription(idv.getTextBoxValue(), null, null, null); setDocumentEdited(true); } - - public void cancel(){ - // Warn user that all changes will be discarded.- if(idv.msgBx("Warning", "This will discard all changes, even the ones you Apply'd. Continue?") == true)
- { - // Copy original elements back into main list. "Undo!" - imgDesc.copyUndo2MainList(); - - // Close the dialog without committing changes. - //imgDescShell.close(); - } - } public void applyToAll(){ // Warn user before doing this. It could take a while. =======================================--- /src/main/org/brailleblaster/perspectives/imageDescriber/UIComponents/ImageDescriberMenu.java Wed Dec 18 21:49:15 2013 UTC +++ /src/main/org/brailleblaster/perspectives/imageDescriber/UIComponents/ImageDescriberMenu.java Thu Jan 16 00:14:11 2014 UTC
@@ -20,7 +20,7 @@ //editMenu Menu editMenu;- MenuItem editItem, prevItem, nextItem, applyItem, undoAllItem, applyToAllItem, clearAllItem; + MenuItem editItem, prevItem, nextItem, applyItem, undoItem, applyToAllItem, clearAllItem;
public ImageDescriberMenu(final WPManager wp, ImageDescriberController idc) {
super(wp); @@ -136,24 +136,13 @@ }); // nextBtn.addSelectionListener...) - applyItem = new MenuItem(editMenu, SWT.PUSH); - applyItem.setText(lh.localValue("&Apply")); - applyItem.addSelectionListener(new SelectionAdapter() { + undoItem = new MenuItem(editMenu, SWT.PUSH); + undoItem.setText(lh.localValue("&Undo")); + undoItem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - currentController.apply(); - // Set image's description. - //imgDesc.setCurElmProd(imgDescTextBox.getText(), null, null, null); - //idd.setDocumentEdited(true); - } // widgetSelected() - }); // applyBtn.addSelectionListener... - - undoAllItem = new MenuItem(editMenu, SWT.PUSH); - undoAllItem.setText(lh.localValue("&Undo All")); - undoAllItem.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - currentController.cancel(); + // Undo current element changes. + currentController.undo(); } // widgetSelected() }); // undoAllItem.addSelectionListener... =======================================--- /src/main/org/brailleblaster/perspectives/imageDescriber/document/ImageDescriber.java Thu Jan 9 16:22:23 2014 UTC +++ /src/main/org/brailleblaster/perspectives/imageDescriber/document/ImageDescriber.java Thu Jan 16 00:14:11 2014 UTC
@@ -82,6 +82,10 @@ Nodes imgs = null; // For grabbing the first <img> element. boolean grabFirstImage = true; + // Description for undo. + String undoDesc; + String undoAlt; +// Image describer context helps us handle element manipulation in a generic way.
ImageDescriberContext imgContext = new ImageDescriberContext(); @@ -191,44 +195,6 @@ } // int getNumImgElements()///////////////////////////////////////////////////////////////////////////
- // Copies prodnote text to undo list. - public void copyMain2UndoList() - { - // Clear prodnote text copy list. - prodCopyList.clear(); - - // Helps with string copies. - StringBuilder sb = null; - - // Copy current prodnotes into our undo list. - for(int curItem = 0; curItem < imgElmList.size(); curItem++) - { - if(getDescAtIndex(curItem) != null) - sb = new StringBuilder( getDescAtIndex(curItem) ); - else - sb = new StringBuilder( "" ); - - // Add this to string. - prodCopyList.add( sb.toString() ); - } - - } // copyMain2UndoList() -- ///////////////////////////////////////////////////////////////////////////
- // Copies all old prodnotes to - public void copyUndo2MainList() - { - // Replace every item changed with the original that was in the DOM. - for(int curItem = 0; curItem < imgElmList.size(); curItem++) { - - // Set prod note. - setDescAtIndex(curItem, prodCopyList.get(curItem), null, null, null); - - } // for(int curItem... - - } // copyUndo2MainList() -- ///////////////////////////////////////////////////////////////////////////
// Recursively moves through xml tree and adds <img> nodes to list. // Also builds image path list. public void fillImgList(Element e) @@ -280,11 +246,6 @@ curImgElement = imgElmList.get(curTag); // Wrap in container element appropriate for the document type. -// if( hasImgGrpParent(curImgElement) == false) { -// curImgElement = wrapInImgGrp( curImgElement ); -// imgElmList.set(curTag, curImgElement); -// -// } // if( hasImgGrpParent(... if( imgContext.hasContainer(curImgElement) == false ) { curImgElement = imgContext.addContainer(curImgElement); imgElmList.set(curTag, curImgElement); @@ -312,9 +273,6 @@ } // for(int... - - // Copy into our temp list for a potential future undo... - copyMain2UndoList(); } // fillImgList_XPath() @@ -370,6 +328,16 @@ } // convertSVG2JPG()///////////////////////////////////////////////////////////////////////////
+ // Sets the description and alt text to their previous values. + public void undoCurDescAndAlt() + { + // Set description and alt text. + setDescription(undoDesc, null, null, null); + setCurElmImgAttributes(null, null, undoAlt); + + } // elementUndo ++ ///////////////////////////////////////////////////////////////////////////
// Returns the next <img> element that was found in the xml doc. public Element nextImageElement() { @@ -387,17 +355,15 @@ // Set current element. curImgElement = imgElmList.get(curElementIndex); - // Wrap in <imggroup> -// if( hasImgGrpParent(curImgElement) == false) { -// curImgElement = wrapInImgGrp( curImgElement ); -// imgElmList.set(curElementIndex, curImgElement); -// -// } // if( hasImgGrpParent(... - + // Wrap image in an appropriate container. if( imgContext.hasContainer(curImgElement) == false ) { curImgElement = imgContext.addContainer(curImgElement); imgElmList.set(curElementIndex, curImgElement); } + + // Set undo strings. + undoDesc = getCurDescription(); + undoAlt = getCurElmAttribute("alt"); // Return current <img> element. return curImgElement; @@ -420,31 +386,20 @@ // Set current element. curImgElement = imgElmList.get(curElementIndex); + // Set undo strings. + undoDesc = getCurDescription(); + undoAlt = getCurElmAttribute("alt"); + // Return current <img> element. return curImgElement; } // PrevImageElement()///////////////////////////////////////////////////////////////////////////
- // Returns true if the current image has an <imggroup> parent. - // False otherwise. - public boolean hasImgGrpParent(Element e) - { - System.out.println("Called hasImgGrpParent()"); - - // If the parent is <imggroup>, return true.- if( ((nu.xom.Element)(e.getParent())).getLocalName().compareTo("imggroup") == 0 )
- return true; - else - return false; - - } // HasImgGrpParent(Element e) -- ///////////////////////////////////////////////////////////////////////////
// Traverses xml tree until it finds the next <img>. public Element getNextImageElement(Element e) { - + // Get next image element. curDocIndex++; if( e.getClass().getName().compareTo("nu.xom.Element") == 0) { if( e.getLocalName().compareTo("img") == 0 ) { @@ -457,8 +412,10 @@ return e; } // if(curDocIndex > furthestDocIndex) - } - } + + } // local name == img + + } // if xom element // Element newImgElement = null; @@ -594,13 +551,6 @@public void setCurElmImgAttributes(String tagID, String tagSRC, String tagALT)
{ // Set attribute values. -// if(tagID != null) -// curImgElement.getAttribute("id").setValue(tagID); -// if(tagSRC != null) -// curImgElement.getAttribute("src").setValue(tagSRC); -// if(tagALT != null) -// curImgElement.getAttribute("alt").setValue(tagALT); - imgContext.setAttribute(curImgElement, "id", tagID); imgContext.setAttribute(curImgElement, "src", tagSRC); imgContext.setAttribute(curImgElement, "alt", tagALT); @@ -630,12 +580,6 @@ if( ch.getLocalName().compareTo("img") == 0 ) { // Set attribute values. -// if(tagID != null) -// ch.getAttribute("id").setValue(tagID); -// if(tagSRC != null) -// ch.getAttribute("src").setValue(tagSRC); -// if(tagALT != null) -// ch.getAttribute("alt").setValue(tagALT); imgContext.setAttribute(ch, "id", tagID); imgContext.setAttribute(ch, "src", tagSRC); imgContext.setAttribute(ch, "alt", tagALT); @@ -650,41 +594,12 @@ } // setElementAttributesAtIndex()///////////////////////////////////////////////////////////////////////////
- // Checks for a <prodnote> and returns true if it exists for this node. + // Checks for a description and returns true if it exists for this node. // False otherwise. // - // Notes: Element MUST be a child of a <imggroup> + // Notes: Element MUST be a child of an image group of sorts. public boolean hasDescElm(Element e) { - /* - // Get parent of <img> element. - nu.xom.Node parNode = e.getParent(); - - /////////////////////////// - - // Find <prodnote>. - Element ch = null; - for(int curC = 0; curC < parNode.getChildCount(); curC++) { - // Make sure this is an element and not a comment or something crazy.- if( parNode.getChild(curC).getClass().getName().compareTo("nu.xom.Element") == 0) {
- - // Get the element. - ch = (Element)parNode.getChild(curC); - if( ch.getLocalName().compareTo("prodnote") == 0 ) { - - // Found it. Return true. - return true; - - } // if( ch.getLocalName()... - - } // if element and not comment. - - } // for(int curC = 0... - - // Return false if we made it here... no prodnote. - return false; - - */ return imgContext.hasDescElement(e); } // hasProdNote() @@ -695,42 +610,6 @@ // text. public String getCurDescription() { - /* - // String for <prodnote> text. - String prodText = "NO PRODNOTE/NO DESCRIPTION."; - - // Get parent of <img> element. - nu.xom.Node parNode = curImgElement.getParent(); - - /////////////////////////// - - // Find <prodnote>. - Element ch = null; - for(int curC = 0; curC < parNode.getChildCount(); curC++) {- if( parNode.getChild(curC).getClass().getName().compareTo("nu.xom.Element") == 0) {
- ch = (Element)parNode.getChild(curC); - if( ch.getLocalName().compareTo("prodnote") == 0 ) { - - // If no children, add one. - if(ch.getChildCount() == 0) - ch.appendChild( new nu.xom.Text("ADD DESCRIPTION!") ); - - // Get text. - prodText = ch.getChild(0).getValue(); - - // Found it. Break. - break; - - } // if( ch.getLocalName()... - - } // If child is an element... - - } // for(int curC = 0... - - // Return <prodnote> text. - return prodText; - */ - // If there are no images, just return null. if(numImgElms < 1) return null; @@ -745,42 +624,6 @@ // contained no text. public String getDescAtIndex(int index) { - /* - // Get parent of <img> element. - nu.xom.Node parNode = imgElmList.get(index).getParent(); - - // String for <prodnote> text. - String prodText = "NO PRODNOTE/NO DESCRIPTION."; - - /////////////////////////// - - // Find <prodnote>. - Element ch = null; - for(int curC = 0; curC < parNode.getChildCount(); curC++) {- if( parNode.getChild(curC).getClass().getName().compareTo("nu.xom.Element") == 0) {
- ch = (Element)parNode.getChild(curC); - if( ch.getLocalName().compareTo("prodnote") == 0 ) { - - // If no children, add one. - if(ch.getChildCount() == 0) - ch.appendChild( new nu.xom.Text("ADD DESCRIPTION!") ); - - // Get text. - prodText = ch.getChild(0).getValue(); - - // Found it. Break. - break; - - } // if( ch.getLocalName()... - - } // if element, and not comment... - - } // for(int curC = 0... - - // Return <prodnote> text. - return prodText; - */ - // If there are no images, just return null. if(numImgElms < 1) return null; @@ -795,61 +638,6 @@ // to get to <prodnote>. Pass null to args you don't want modified.public void setDescription(String text, String tagID, String tagIMGREF, String tagRENDER)
{ - /* - // Get parent of <img> element. - nu.xom.Node parNode = curImgElement.getParent(); - - /////////////////////////// - - // Find <prodnote>. - Element ch = null; - int curC = 0; - for( ; curC < parNode.getChildCount(); curC++) { - ch = (Element)parNode.getChild(curC); - if( ch.getLocalName().compareTo("prodnote") == 0 ) { - - // Found it. Break. - break; - - } // if( ch.getLocalName()... - - } // for(int curC = 0... - - ///////////////////////// - - // If <prodnote> didn't exist, create it. - if(curC == parNode.getChildCount()) - { - // TODO: Create prodnote. - } - - ///////////////////////// - - // Set text value. - if(text != null) - { - // If no children, add one. Else, replace the one already there. - if(ch.getChildCount() == 0) - ch.appendChild( new nu.xom.Text(text) ); - else { - nu.xom.Node oldNode = ch.getChild(0); - nu.xom.Node newNode = new nu.xom.Text(text); - ch.replaceChild(oldNode, newNode); - } - - } // if(text != null) - - /////////////////////////// - - // Set attributes. - if(tagID != null) - ch.getAttribute("id").setValue(tagID); - if(tagIMGREF != null) - ch.getAttribute("imgref").setValue(tagIMGREF); - if(tagRENDER != null) - ch.getAttribute("render").setValue(tagRENDER); - */ - imgContext.setDescription(curImgElement, text); imgContext.setAttribute(curImgElement, "id", tagID); imgContext.setAttribute(curImgElement, "src", tagIMGREF); @@ -863,70 +651,6 @@ // Notes: Must already be wrapped in <imggroup>public void setDescAtIndex(int index, String text, String tagID, String tagIMGREF, String tagRENDER)
{ - /* - // Get parent of element at index. - // It should be an <imggroup> element. - Node parNode = imgElmList.get(index).getParent(); - - // Find <prodnote>. - Element ch = null; - int curC = 0; - for( ; curC < parNode.getChildCount(); curC++) { - ch = (Element)parNode.getChild(curC); - if( ch.getLocalName().compareTo("prodnote") == 0 ) { - - // Found it. Break. - break; - - } // if( ch.getLocalName()... - - } // for(int curC = 0... - - ///////////////////////// - - // If <prodnote> didn't exist, create it. - if(curC == parNode.getChildCount()) - { -// // Create prodnote element. -// Element prodElm = new Element("prodnote", nameSpace); -// -// // Add <prodnote> attributes. -// prodElm.addAttribute( new Attribute("id", "TODO!") ); -// prodElm.addAttribute( new Attribute("imgref", idValue) ); -// prodElm.addAttribute( new Attribute("render", "required") ); -// -// // If no children, add one. -// if(ch.getChildCount() == 0) -// ch.appendChild( new nu.xom.Text("ADD DESCRIPTION!") ); - } - - ///////////////////////// - - // Set text value. - if(text != null) - { - // If no children, add one. Else, replace the one already there. - if(ch.getChildCount() == 0) - ch.appendChild( new nu.xom.Text(text) ); - else { - nu.xom.Node oldNode = ch.getChild(0); - nu.xom.Node newNode = new nu.xom.Text(text); - ch.replaceChild(oldNode, newNode); - } - - } // if(text != null) - - /////////////////////////// - - // Set attributes. - if(tagID != null) - ch.getAttribute("id").setValue(tagID); - if(tagIMGREF != null) - ch.getAttribute("imgref").setValue(tagIMGREF); - if(tagRENDER != null) - ch.getAttribute("render").setValue(tagRENDER); - */ - imgContext.setDescription(imgElmList.get(index), text); imgContext.setAttribute(imgElmList.get(index), "id", tagID); imgContext.setAttribute(imgElmList.get(index), "src", tagIMGREF); @@ -939,17 +663,18 @@ public void disposeImages() { // Loop through them all and delete. - for(int curImg = 0; curImg < imgFileList.size(); curImg++) - if(imgFileList.get(curImg) != null) - imgFileList.get(curImg).dispose(); + for(int curImg = 0; curImg < imgFileList.size(); curImg++) + if(imgFileList.get(curImg) != null) + imgFileList.get(curImg).dispose(); } // disposeImages() - public void resetCurrentIndex(){ + public void resetCurrentIndex() { curElementIndex = -1; } - public ArrayList<Element> getImageList(){ + public ArrayList<Element> getImageList() { return imgElmList; } + } // public class ImageDescriber { =======================================--- /src/main/org/brailleblaster/perspectives/imageDescriber/views/ImageDescriberView.java Thu Jan 9 16:22:23 2014 UTC +++ /src/main/org/brailleblaster/perspectives/imageDescriber/views/ImageDescriberView.java Thu Jan 16 00:14:11 2014 UTC
@@ -37,61 +37,12 @@ import org.eclipse.swt.widgets.Text; public class ImageDescriberView { - // UI Positioning and Sizes. - // Buttons. - int defBtnW = 100; - int defBtnH = 50; - int prevBtnX = 0; - int prevBtnY = 0; - int prevBtnW = defBtnW; - int prevBtnH = defBtnH; - int nextBtnX = prevBtnW + prevBtnX + 1; - int nextBtnY = 0; - int nextBtnW = defBtnW; - int nextBtnH = defBtnH; - int applyBtnX = nextBtnW + nextBtnX + 1; - int applyBtnY = 0; - int applyBtnW = defBtnW; - int applyBtnH = defBtnH; - int okayBtnX = applyBtnW + applyBtnX + 1; - int okayBtnY = 0; - int okayBtnW = defBtnW; - int okayBtnH = defBtnH; - int undoBtnX = okayBtnW + okayBtnX + 1; - int undoBtnY = 0; - int undoBtnW = defBtnW; - int undoBtnH = defBtnH; - int applyAllBtnX = 0; // Apply All. - int applyAllBtnY = okayBtnY + okayBtnH + 1; - int applyAllBtnW = defBtnW; - int applyAllBtnH = defBtnH; - int clearAllBtnX = 0; // Clear All. - int clearAllBtnY = applyAllBtnY + applyAllBtnH + 1; - int clearAllBtnW = defBtnW; - int clearAllBtnH = defBtnH; - // Overall dialog. - int dialogWidth = 1000; - int dialogHeight = 700; - // Main image. - int imageOffsetX = 0; - int imageOffsetY = 250; int imageWidth = 500; int imageHeight = 500; // Client Area. int clientWidth = -1; int clientHeight = -1; - - // Text box. - int txtBoxX = 0; - int txtBoxY = 55; - int txtBoxW = 400; - int txtBoxH = 150; - // Browser. - int browserX = 505; - int browserY = 0; - int browserW = -1; - int browserH = -1; // True if usr hit okay. False if cancel. boolean msgBxBool = false; @@ -127,35 +78,13 @@ // Create previous button. prevBtn = new Button(group, SWT.PUSH); prevBtn.setText("Previous"); - //prevBtn.setBounds(prevBtnX, prevBtnY, prevBtnW, prevBtnH); setFormData(prevBtn, 0, 7, 0, 5); prevBtn.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - // Change main image to previous element image. - imgDesc.prevImageElement(); - - //Change current image in dialog. - setMainImage(); - - // Get description and alt text. - oldDescText = imgDesc.getCurDescription(); - oldAltText = imgDesc.getCurElmAttribute("alt"); - - // Get prodnote text/image description. - setTextBox( oldDescText ); - - // Get alt attribute. - if(oldAltText != null) - altBox.setText(oldAltText); - - idd.setImageInfo(); - // Show current image index and name.- //imgDescShell.setText("Image Describer - " + imgDesc.getCurrentElementIndex() + " - " + imgDesc.currentImageElement().getAttributeValue("src") );
- - // Scroll the browser widget to the current image. - scrollBrowserToCurImg(); + // Move to previous element. + idd.setImageToPrevious(); } // widgetSelected() @@ -164,35 +93,13 @@ // Create next button. nextBtn = new Button(group, SWT.PUSH); nextBtn.setText("Next"); - //nextBtn.setBounds(nextBtnX, nextBtnY, nextBtnW, nextBtnH); setFormData(nextBtn, 7, 14, 0, 5); nextBtn.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - // Change main image to next element image. - imgDesc.nextImageElement(); - - // Change current image in dialog. - setMainImage(); - - // Get description and alt text. - oldDescText = imgDesc.getCurDescription(); - oldAltText = imgDesc.getCurElmAttribute("alt"); - - // Get prodnote text/image description. - setTextBox( oldDescText ); - - // Get alt attribute. - if(oldAltText != null) - altBox.setText(oldAltText); - - idd.setImageInfo(); - //Show current image index and name.- // imgDescShell.setText("Image Describer - " + imgDesc.getCurrentElementIndex() + " - " + imgDesc.currentImageElement().getAttributeValue("src") );
- - // Scroll the browser widget to the current image. - scrollBrowserToCurImg(); + // Move to next element. + idd.setImageToNext(); } // widgetSelected() @@ -201,18 +108,13 @@ // Create undo button. undoBtn = new Button(group, SWT.PUSH); undoBtn.setText("Undo"); - //undoBtn.setBounds(undoBtnX, undoBtnY, undoBtnW, undoBtnH); setFormData(undoBtn, 28, 35, 0, 5); undoBtn.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - // Get prodnote text/image description. - setTextBox( oldDescText ); - - // Get alt attribute. - if(oldAltText != null) - altBox.setText(oldAltText); + // Undo current element changes. + idd.undo(); } // widgetSelected() @@ -222,7 +124,6 @@ // to what was in the notes. applyToAllBtn = new Button(group, SWT.PUSH); applyToAllBtn.setText("Apply To All");- //applyToAllBtn.setBounds(applyAllBtnX, applyAllBtnY, applyAllBtnW, applyAllBtnH);
setFormData(applyToAllBtn, 35, 42, 0, 5); applyToAllBtn.addSelectionListener(new SelectionAdapter() { @Override @@ -256,6 +157,7 @@ } // for(int curImg... idd.setDocumentEdited(true); + } // if msgBx == true } // widgetSelected() @@ -265,7 +167,6 @@ // Clear all button. Clears the prodnote and alt attribute. clearAllBtn = new Button(group, SWT.PUSH); clearAllBtn.setText("Clear All");- //clearAllBtn.setBounds(clearAllBtnX, clearAllBtnY, clearAllBtnW, clearAllBtnH);
setFormData(clearAllBtn, 42, 49, 0, 5); clearAllBtn.addSelectionListener(new SelectionAdapter() { @Override @@ -329,7 +230,6 @@ // Create image description text box. imgDescTextBox = new Text(group, SWT.BORDER | SWT.MULTI | SWT.WRAP); - //imgDescTextBox.setBounds(txtBoxX, txtBoxY, txtBoxW, txtBoxH); setFormData(imgDescTextBox, 0, 49, 9, 40); imgDescTextBox.addModifyListener(new ModifyListener() { @Override @@ -345,33 +245,29 @@ // Setup main image. mainImage = new Label(group, SWT.CENTER | SWT.BORDER);- //mainImage.setBounds(imageOffsetX, imageOffsetY, imageWidth, imageHeight);
setFormData(mainImage, 0, 49, 40, 100); setMainImage(); - // Show current image index and name.- //imgDescShell.setText( "Image Describer - " + imgDesc.getCurrentElementIndex() + " - " + imgDesc.currentImageElement().getAttributeValue("src") );
- - ////////////////// - // Browser Widget. - // Setup browser window. browser = new Browser(group, SWT.BORDER ); setBrowser(); } // public void createUIelements() + // Set text in image description text box UI. public void setTextBox(){ // Get prodnote text/image description. if(imgDesc.getImageList().size() > 0) imgDescTextBox.setText( imgDesc.getCurDescription() ); } + // Get text in alt box UI. public String getAltBox() { return altBox.getText(); } + // Set text in alt box. public void setAltBox(String str) { if(str == null) @@ -448,12 +344,10 @@ // Set url. browser.setUrl( idd.getWorkingPath().replaceAll(".xml", ".html") ); // Set browser bounds. - //browser.setBounds(browserX, browserY, browserW, browserH); setFormData(browser, 49, 100, 0, 100); } else { // Set browser bounds. - //browser.setBounds(browserX, browserY, browserW, browserH);browser.setText("<h1>Empty Document</h1><h1>Browser View Currently Disabled</h1>");
setFormData(browser, 49, 100, 0, 100); } @@ -461,7 +355,7 @@ //////////////////////////////////////////////////////////// // Scrolls browser view to current image. - void scrollBrowserToCurImg() + public void scrollBrowserToCurImg() { // Get the index of the current element. String indexStr = Integer.toString( imgDesc.getCurrentElementIndex() ); @@ -481,59 +375,13 @@ { // Screen resolution. Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - - // Overall dialog. - dialogWidth = (int)(screenSize.getWidth() * 0.70f); - dialogHeight = (int)(screenSize.getWidth() * 0.70f); // Client Area. clientWidth = group.getShell().getBounds().width; clientHeight = group.getShell().getBounds().height; - // Buttons. - defBtnW = dialogWidth / 15; - defBtnH = dialogHeight / 25; - prevBtnX = 0; - prevBtnY = 0; - prevBtnW = defBtnW; - prevBtnH = defBtnH; - nextBtnX = prevBtnW + prevBtnX + 1; - nextBtnY = 0; - nextBtnW = defBtnW; - nextBtnH = defBtnH; - applyBtnX = nextBtnW + nextBtnX + 1; - applyBtnY = 0; - applyBtnW = defBtnW; - applyBtnH = defBtnH; - okayBtnX = applyBtnW + applyBtnX + 1; - okayBtnY = 0; - okayBtnW = defBtnW; - okayBtnH = defBtnH; - undoBtnX = okayBtnW + okayBtnX + 1; - undoBtnY = 0; - undoBtnW = defBtnW; - undoBtnH = defBtnH; - applyAllBtnX = 0; // Apply All. - applyAllBtnY = okayBtnY + okayBtnH + 1; - applyAllBtnW = clientWidth / 12; - applyAllBtnH = defBtnH; - clearAllBtnX = applyAllBtnX + clientWidth / 12; // Clear All. - clearAllBtnY = applyAllBtnY; - clearAllBtnW = clientWidth / 12; - clearAllBtnH = defBtnH; - // Text box. - txtBoxX = 0; - txtBoxY = applyAllBtnY + applyAllBtnH + 1; - txtBoxW = clientWidth / 3; - txtBoxH = clientHeight / 4; // Main image. - imageOffsetX = 0; - imageOffsetY = txtBoxY + txtBoxH + 5; imageWidth = clientWidth / 3; imageHeight = clientWidth / 3; - // Browser. - browserX = imageWidth + 10; - browserY = 0; - browserW = clientWidth / 2; - browserH = clientHeight; + } // public void resizeUI() @@ -630,13 +478,7 @@ if(imgDesc.getImageList().size() > 0) enabled = true; - - // prevBtn.setEnabled(enabled); - // nextBtn.setEnabled(enabled); - // applyBtn.setEnabled(enabled); - // cancelBtn.setEnabled(enabled); - // applyToAllBtn.setEnabled(enabled); - // clearAllBtn.setEnabled(enabled); + imgDescTextBox.setEditable(enabled); }