diff options
author | Andre Weinand | 2003-07-14 10:11:20 +0000 |
---|---|---|
committer | Andre Weinand | 2003-07-14 10:11:20 +0000 |
commit | 05279658ce8ad129c07fad69c592312953fe6e3d (patch) | |
tree | d21ee051937355204a6d7649d406791441b67d95 /examples | |
parent | f9111254c8c37a425eded63485c92f9e309ee828 (diff) | |
download | eclipse.platform.team-05279658ce8ad129c07fad69c592312953fe6e3d.tar.gz eclipse.platform.team-05279658ce8ad129c07fad69c592312953fe6e3d.tar.xz eclipse.platform.team-05279658ce8ad129c07fad69c592312953fe6e3d.zip |
reformattedv20030714
Diffstat (limited to 'examples')
11 files changed, 280 insertions, 261 deletions
diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/Mapping.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/Mapping.java index e8197ab0e..da2515562 100644 --- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/Mapping.java +++ b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/Mapping.java @@ -87,6 +87,5 @@ public class Mapping { return XMLStructureCreator.ROOT_ID + XMLStructureCreator.SIGN_SEPARATOR + element + XMLStructureCreator.SIGN_SEPARATOR; else return XMLStructureCreator.ROOT_ID + XMLStructureCreator.SIGN_SEPARATOR + signature + XMLStructureCreator.SIGN_SEPARATOR + element + XMLStructureCreator.SIGN_SEPARATOR; - } } diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/OrderedMatching.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/OrderedMatching.java index 8648a0d92..6d4849fb1 100644 --- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/OrderedMatching.java +++ b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/OrderedMatching.java @@ -22,181 +22,195 @@ public class OrderedMatching extends AbstractMatching { public OrderedMatching() { super(); } - + protected int orderedMath(XMLNode x, XMLNode y) { //assumes x and y have children + Object[] xc= x.getChildren(); + Object[] yc= y.getChildren(); -// boolean old_isw= fIgnoreStartsWith; -// fIgnoreStartsWith= true; - - //both x and y have children - Object[] xc = x.getChildren(); - Object[] yc = y.getChildren(); - ArrayList xc_elementsAL= new ArrayList(); ArrayList xc_attrsAL= new ArrayList(); ArrayList yc_elementsAL= new ArrayList(); ArrayList yc_attrsAL= new ArrayList(); - + //find attributes and elements and put them in xc_elementsAL and xc_attrsAL, respectively for (int i= 0; i < xc.length; i++) { XMLNode x_i= (XMLNode) xc[i]; if (x_i.getXMLType().equals(XMLStructureCreator.TYPE_ELEMENT)) { xc_elementsAL.add(x_i); - } else if (x_i.getXMLType().equals(XMLStructureCreator.TYPE_ATTRIBUTE)) { + } else if ( + x_i.getXMLType().equals(XMLStructureCreator.TYPE_ATTRIBUTE)) { xc_attrsAL.add(x_i); } } //do the same for yc for (int i= 0; i < yc.length; i++) { - XMLNode y_i= (XMLNode) yc[i]; + XMLNode y_i= (XMLNode) yc[i]; if (y_i.getXMLType().equals(XMLStructureCreator.TYPE_ELEMENT)) { yc_elementsAL.add(y_i); - } else if (y_i.getXMLType().equals(XMLStructureCreator.TYPE_ATTRIBUTE)) { + } else if ( + y_i.getXMLType().equals(XMLStructureCreator.TYPE_ATTRIBUTE)) { yc_attrsAL.add(y_i); } } - + Object[] xc_elements= xc_elementsAL.toArray(); Object[] yc_elements= yc_elementsAL.toArray(); - ArrayList DTMatching= new ArrayList();//Mathing to be added to Entry in fDT_Matchings - int distance = 0;//distance to be added to entry in fDT + ArrayList DTMatching= new ArrayList(); + // Matching to be added to Entry in fDT_Matchings + int distance= 0; //distance to be added to entry in fDT - //perform unordered matching on attributes - //this updates fDT and fDT_Matchings - if (xc_attrsAL.size() > 0 || yc_attrsAL.size()> 0) { + // perform unordered matching on attributes + // this updates fDT and fDT_Matchings + if (xc_attrsAL.size() > 0 || yc_attrsAL.size() > 0) { if (xc_attrsAL.size() == 0) distance += yc_attrsAL.size(); else if (yc_attrsAL.size() == 0) distance += xc_attrsAL.size(); else { //unorderedMatch(x, y, xc_attrs, yc_attrs); -// distance += fDT[indexOfLN(x)][indexOfRN(y)]; -// DTMatching= fDT_Matchings[indexOfLN(x)][indexOfRN(y)]; + // distance += fDT[indexOfLN(x)][indexOfRN(y)]; + // DTMatching= fDT_Matchings[indexOfLN(x)][indexOfRN(y)]; distance= handleAttributes(xc_attrsAL, yc_attrsAL, DTMatching); } } //perform ordered matching on element children, i.e. number them in order of appearance - + /* start new */ - distance= handleRangeDifferencer(xc_elements, yc_elements, DTMatching, distance); + distance= + handleRangeDifferencer( + xc_elements, + yc_elements, + DTMatching, + distance); /* end new */ - + /* start: Naive ordered compare /* -// int minlength= (xc_elements.length > yc_elements.length)?yc_elements.length:xc_elements.length; -// for (int i= 0; i < minlength; i++) { -// distance += dist((XMLNode) xc_elements[i], (XMLNode) yc_elements[i]); -// DTMatching.add(new Match( (XMLNode)xc_elements[i], (XMLNode)yc_elements[i])); -// } -// if (xc_elements.length > yc_elements.length) { -// for (int i= minlength; i < xc_elements.length; i++) { -// distance += countNodes((XMLNode) xc_elements[i]); -// } -// } else if (xc_elements.length < yc_elements.length) { -// for (int i= minlength; i < yc_elements.length; i++) { -// distance += countNodes((XMLNode) yc_elements[i]); -// } -// } + // int minlength= (xc_elements.length > yc_elements.length)?yc_elements.length:xc_elements.length; + // for (int i= 0; i < minlength; i++) { + // distance += dist((XMLNode) xc_elements[i], (XMLNode) yc_elements[i]); + // DTMatching.add(new Match( (XMLNode)xc_elements[i], (XMLNode)yc_elements[i])); + // } + // if (xc_elements.length > yc_elements.length) { + // for (int i= minlength; i < xc_elements.length; i++) { + // distance += countNodes((XMLNode) xc_elements[i]); + // } + // } else if (xc_elements.length < yc_elements.length) { + // for (int i= minlength; i < yc_elements.length; i++) { + // distance += countNodes((XMLNode) yc_elements[i]); + // } + // } /* end: Naive ordered compare */ - -// fIgnoreStartsWith= old_isw; - - fDT[indexOfLN(x)][indexOfRN(y)] = distance; - fDT_Matchings[indexOfLN(x)][indexOfRN(y)] = DTMatching; + + fDT[indexOfLN(x)][indexOfRN(y)]= distance; + fDT_Matchings[indexOfLN(x)][indexOfRN(y)]= DTMatching; return distance; } - /* matches two trees according to paper "X-Diff", p. 16 */ - public void match(XMLNode LeftTree, XMLNode RightTree, boolean rightTreeIsAncestor, IProgressMonitor monitor) throws InterruptedException { + public void match( + XMLNode LeftTree, + XMLNode RightTree, + boolean rightTreeIsAncestor, + IProgressMonitor monitor) + throws InterruptedException { - fNLeft = new Vector();//numbering LeftTree: Mapping nodes in LeftTree to numbers to be used as array indexes - fNRight = new Vector();//numbering RightTree: Mapping nodes in RightTree to numbers to be used as array indexes + fNLeft= new Vector(); + //numbering LeftTree: Mapping nodes in LeftTree to numbers to be used as array indexes + fNRight= new Vector(); + //numbering RightTree: Mapping nodes in RightTree to numbers to be used as array indexes numberNodes(LeftTree, fNLeft); numberNodes(RightTree, fNRight); - fDT = new int[fNLeft.size()][fNRight.size()]; - fDT_Matchings = new ArrayList[fNLeft.size()][fNRight.size()]; - for (int i=0; i<fDT.length; i++) { - fDT[i] = new int[fNRight.size()]; - for (int j=0; j<fDT[0].length; j++) { - fDT[i][j] = NO_ENTRY; + fDT= new int[fNLeft.size()][fNRight.size()]; + fDT_Matchings= new ArrayList[fNLeft.size()][fNRight.size()]; + for (int i= 0; i < fDT.length; i++) { + fDT[i]= new int[fNRight.size()]; + for (int j= 0; j < fDT[0].length; j++) { + fDT[i][j]= NO_ENTRY; } } - dist(LeftTree,RightTree); -// /* mark matchings on LeftTree and RightTree */ - fMatches = new Vector(); - if ( !LeftTree.getSignature().equals(RightTree.getSignature()) ) { + dist(LeftTree, RightTree); + // /* mark matchings on LeftTree and RightTree */ + fMatches= new Vector(); + if (!LeftTree.getSignature().equals(RightTree.getSignature())) { //matching is empty } else { - fMatches.add(new Match(LeftTree,RightTree)); - for (int i_M = 0; i_M<fMatches.size(); i_M++) { - Match m = (Match) fMatches.elementAt(i_M); - if ( !isLeaf(m.fx) && !isLeaf(m.fy) ) { -// if (fDT_Matchings[ indexOfLN(m.fx) ][ indexOfRN(m.fy) ] == null) -// System.out.println("Error: ID not unique for " + m.fx.getId()); -// else -// fMatches.addAll(fDT_Matchings[ indexOfLN(m.fx) ][ indexOfRN(m.fy) ]); - if (fDT_Matchings[ indexOfLN(m.fx) ][ indexOfRN(m.fy) ] != null) - fMatches.addAll(fDT_Matchings[ indexOfLN(m.fx) ][ indexOfRN(m.fy) ]); + fMatches.add(new Match(LeftTree, RightTree)); + for (int i_M= 0; i_M < fMatches.size(); i_M++) { + Match m= (Match) fMatches.elementAt(i_M); + if (!isLeaf(m.fx) && !isLeaf(m.fy)) { + // if (fDT_Matchings[ indexOfLN(m.fx) ][ indexOfRN(m.fy) ] == null) + // System.out.println("Error: ID not unique for " + m.fx.getId()); + // else + // fMatches.addAll(fDT_Matchings[ indexOfLN(m.fx) ][ indexOfRN(m.fy) ]); + if (fDT_Matchings[indexOfLN(m.fx)][indexOfRN(m.fy)] + != null) + fMatches.addAll( + fDT_Matchings[indexOfLN(m.fx)][indexOfRN(m.fy)]); } } } //end of Step2 /* Renumber Id of Nodes to follow Matches. Or for ancestor, copy over Id to ancestor */ if (rightTreeIsAncestor) { - for (ListIterator it_M = fMatches.listIterator(); it_M.hasNext(); ) { - Match m = (Match) it_M.next(); + for (ListIterator it_M= fMatches.listIterator(); it_M.hasNext();) { + Match m= (Match) it_M.next(); if (m.fx != null && m.fy != null) m.fy.setId(m.fx.getId()); } } else { - int newId = 0; - for (ListIterator it_M = fMatches.listIterator(); it_M.hasNext(); newId++) { - Match m = (Match) it_M.next(); + int newId= 0; + for (ListIterator it_M= fMatches.listIterator(); + it_M.hasNext(); + newId++) { + Match m= (Match) it_M.next(); if (m.fx != null) m.fx.setId(Integer.toString(newId)); if (m.fy != null) m.fy.setId(Integer.toString(newId)); -// System.out.println("Matching: "+ ((m.fx != null)?m.fx.getOrigId():"null")+" -> "+((m.fx != null)?m.fx.getId():"null")+" , "+((m.fy != null)?m.fy.getOrigId():"null")+" -> "+((m.fy != null)?m.fy.getId():"null")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + // System.out.println("Matching: "+ ((m.fx != null)?m.fx.getOrigId():"null")+" -> "+((m.fx != null)?m.fx.getId():"null")+" , "+((m.fy != null)?m.fy.getOrigId():"null")+" -> "+((m.fy != null)?m.fy.getId():"null")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ } } //if (monitor != null) monitor.done(); } - - public int handleAttributes(ArrayList xc_attrs, ArrayList yc_attrs, ArrayList DTMatching) { + + public int handleAttributes( + ArrayList xc_attrs, + ArrayList yc_attrs, + ArrayList DTMatching) { int distance= 0; - x_for: - for (Iterator iter_xc= xc_attrs.iterator(); iter_xc.hasNext(); ) { + x_for : for ( + Iterator iter_xc= xc_attrs.iterator(); iter_xc.hasNext();) { XMLNode x_attr= (XMLNode) iter_xc.next(); String x_attr_name= x_attr.getName(); - for (Iterator iter_yc= yc_attrs.iterator(); iter_yc.hasNext(); ) { + for (Iterator iter_yc= yc_attrs.iterator(); iter_yc.hasNext();) { XMLNode y_attr= (XMLNode) iter_yc.next(); if (y_attr.getName().equals(x_attr_name)) { if (!y_attr.getValue().equals(x_attr.getValue())) distance += 1; - DTMatching.add( new Match( x_attr, y_attr ) ); + DTMatching.add(new Match(x_attr, y_attr)); yc_attrs.remove(y_attr); continue x_for; } } - DTMatching.add( new Match( x_attr, null) ); + DTMatching.add(new Match(x_attr, null)); distance += 1; } - - for (Iterator iter_yc= yc_attrs.iterator(); iter_yc.hasNext(); ) { - DTMatching.add( new Match( null, (XMLNode) iter_yc.next()) ); + + for (Iterator iter_yc= yc_attrs.iterator(); iter_yc.hasNext();) { + DTMatching.add(new Match(null, (XMLNode) iter_yc.next())); distance += 1; } - + return distance; } - + protected int handleXandYnotLeaves(XMLNode x, XMLNode y) { /* handle entries as ordered*/ return orderedMath(x, y); diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/SelectMatcherAction.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/SelectMatcherAction.java index 03d122efb..f9f72ca50 100644 --- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/SelectMatcherAction.java +++ b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/SelectMatcherAction.java @@ -16,19 +16,16 @@ class SelectMatcherAction extends Action { private XMLStructureViewer fViewer; private String fDesc; - - /** - * Create a new instance of this class - */ + public SelectMatcherAction(String desc, XMLStructureViewer viewer) { - fViewer = viewer; - fDesc = desc; + fViewer= viewer; + fDesc= desc; setText(fDesc); setToolTipText(fDesc); } public void run() { - ((XMLStructureCreator)fViewer.getStructureCreator()).setIdMap(fDesc); + ((XMLStructureCreator) fViewer.getStructureCreator()).setIdMap(fDesc); fViewer.contentChanged(); } } diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLChildren.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLChildren.java index 172dab08a..c823f868f 100644 --- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLChildren.java +++ b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLChildren.java @@ -17,14 +17,13 @@ import org.eclipse.jface.text.IDocument; /** XMLNode that has children elements */ public class XMLChildren extends XMLNode { - public int children;//counts the number of children - public HashMap childElements;//Maps the name of XML child elements to their # of occurence + public int children; // counts the number of children + public HashMap childElements; // maps the name of XML child elements to their # of occurence public XMLChildren(String XMLType, String id, String value, String signature, IDocument doc, int start, int length) { - super(XMLType,id,value,signature,doc,start,length); - children=0; + super(XMLType, id, value, signature, doc, start, length); + children= 0; childElements = new HashMap(); } - } diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareAddIdMapDialog.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareAddIdMapDialog.java index 85f899d37..956e114b3 100644 --- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareAddIdMapDialog.java +++ b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareAddIdMapDialog.java @@ -40,26 +40,27 @@ public class XMLCompareAddIdMapDialog extends StatusDialog { public XMLCompareAddIdMapDialog(Shell parent, IdMap idmap, HashMap idmaps, HashMap idmapsInternal, HashMap idextensiontoname, boolean edit) { super(parent); - fEdit = edit; + fEdit= edit; if (fEdit) setTitle(XMLCompareMessages.getString("XMLCompareAddIdMapDialog.editTitle")); //$NON-NLS-1$ else setTitle(XMLCompareMessages.getString("XMLCompareAddIdMapDialog.newTitle")); //$NON-NLS-1$ - fIdMap = idmap; - fIdMaps = idmaps; + fIdMap= idmap; + fIdMaps= idmaps; fIdMapsInternal= idmapsInternal; fIdExtensionToName= idextensiontoname; } -/** - * Creates and returns the contents of the upper part - * of the dialog (above the button bar). - * - * Subclasses should override. - * - * @param the parent composite to contain the dialog area - * @return the dialog area control - */ + + /** + * Creates and returns the contents of the upper part + * of the dialog (above the button bar). + * + * Subclasses should override. + * + * @param the parent composite to contain the dialog area + * @return the dialog area control + */ protected Control createDialogArea(Composite ancestor) { Composite composite= (Composite) super.createDialogArea(ancestor); @@ -105,9 +106,9 @@ public class XMLCompareAddIdMapDialog extends StatusDialog { return composite; } -/** - * Validate user input - */ + /** + * Validate user input + */ private void doValidation() { StatusInfo status= new StatusInfo(); String newText= fIdMapText.getText(); @@ -128,13 +129,13 @@ public class XMLCompareAddIdMapDialog extends StatusDialog { } updateStatus(status); } -/** - * Notifies that the ok button of this dialog has been pressed. - */ + + /** + * Notifies that the ok button of this dialog has been pressed. + */ protected void okPressed() { fIdMap.setName(fIdMapText.getText()); fIdMap.setExtension(fIdMapExtText.getText().toLowerCase()); super.okPressed(); } - -}
\ No newline at end of file +} diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditCopyIdMapDialog.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditCopyIdMapDialog.java index 3131061d0..d9d3a3ebe 100644 --- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditCopyIdMapDialog.java +++ b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditCopyIdMapDialog.java @@ -33,30 +33,31 @@ public class XMLCompareEditCopyIdMapDialog extends StatusDialog { private Text fIdMapText; private String fResult; -/** - * Constructs a new edit copy mapping dialog. - */ + /** + * Constructs a new edit copy mapping dialog. + */ public XMLCompareEditCopyIdMapDialog(Shell parent, IdMap idmap, HashMap idmaps, HashMap idmapsInternal) { super(parent); setTitle(XMLCompareMessages.getString("XMLCompareEditCopyIdMapDialog.title")); //$NON-NLS-1$ - fIdMaps = idmaps; + fIdMaps= idmaps; fIdMapsInternal= idmapsInternal; } public String getResult() { return fResult; } -/** - * Creates and returns the contents of the upper part - * of the dialog (above the button bar). - * - * Subclasses should override. - * - * @param the parent composite to contain the dialog area - * @return the dialog area control - */ + + /** + * Creates and returns the contents of the upper part + * of the dialog (above the button bar). + * + * Subclasses should override. + * + * @param the parent composite to contain the dialog area + * @return the dialog area control + */ protected Control createDialogArea(Composite ancestor) { Composite composite= (Composite) super.createDialogArea(ancestor); @@ -90,9 +91,9 @@ public class XMLCompareEditCopyIdMapDialog extends StatusDialog { return composite; } -/** - * Validate user input - */ + /** + * Validate user input + */ private void doValidation() { StatusInfo status= new StatusInfo(); String newText= fIdMapText.getText(); @@ -104,12 +105,12 @@ public class XMLCompareEditCopyIdMapDialog extends StatusDialog { status.setError(XMLCompareMessages.getString("XMLCompareEditCopyIdMapDialog.error.nameExists")); //$NON-NLS-1$ updateStatus(status); } -/** - * Notifies that the ok button of this dialog has been pressed. - */ + + /** + * Notifies that the ok button of this dialog has been pressed. + */ protected void okPressed() { - fResult = fIdMapText.getText(); + fResult= fIdMapText.getText(); super.okPressed(); } - }
\ No newline at end of file diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditMappingDialog.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditMappingDialog.java index 51147358c..69fb73838 100644 --- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditMappingDialog.java +++ b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditMappingDialog.java @@ -47,24 +47,25 @@ public class XMLCompareEditMappingDialog extends StatusDialog { setShellStyle(shellStyle | SWT.MAX | SWT.RESIZE); - fEdit = edit; + fEdit= edit; if (fEdit) setTitle(XMLCompareMessages.getString("XMLCompareEditMappingDialog.editTitle")); //$NON-NLS-1$ else setTitle(XMLCompareMessages.getString("XMLCompareEditMappingDialog.newTitle")); //$NON-NLS-1$ fMapping= mapping; - fIdmapHM = idmapHM; + fIdmapHM= idmapHM; } -/** - * Creates and returns the contents of the upper part - * of the dialog (above the button bar). - * - * Subclasses should override. - * - * @param the parent composite to contain the dialog area - * @return the dialog area control - */ + + /** + * Creates and returns the contents of the upper part + * of the dialog (above the button bar). + * + * Subclasses should override. + * + * @param the parent composite to contain the dialog area + * @return the dialog area control + */ protected Control createDialogArea(Composite ancestor) { Composite composite= (Composite) super.createDialogArea(ancestor); @@ -95,8 +96,8 @@ public class XMLCompareEditMappingDialog extends StatusDialog { fSignatureText= new Text(inner, SWT.BORDER); fSignatureText.setText(fMapping.getSignature()); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.widthHint = convertWidthInCharsToPixels(50); + GridData data= new GridData(GridData.FILL_HORIZONTAL); + data.widthHint= convertWidthInCharsToPixels(50); fSignatureText.setLayoutData(data); fSignatureText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e){ @@ -126,62 +127,63 @@ public class XMLCompareEditMappingDialog extends StatusDialog { return composite; } -/** - * Validate user input - */ + /** + * Validate user input + */ private void doValidation() { StatusInfo status= new StatusInfo(); - String text = fElementText.getText(); - String mappingKey = Mapping.getKey(fSignatureText.getText(), text); - String errormsg = ""; //$NON-NLS-1$ - boolean isError = false; + String text= fElementText.getText(); + String mappingKey= Mapping.getKey(fSignatureText.getText(), text); + String errormsg= ""; //$NON-NLS-1$ + boolean isError= false; if (text.length() == 0) { - errormsg = XMLCompareMessages.getString("XMLCompareEditMappingDialog.error.noname"); //$NON-NLS-1$ - isError = true; + errormsg= XMLCompareMessages.getString("XMLCompareEditMappingDialog.error.noname"); //$NON-NLS-1$ + isError= true; } else if (XMLComparePreferencePage.containsInvalidCharacters(text)) { - if (errormsg == "") errormsg = XMLCompareMessages.getString("XMLCompareEditMappingDialog.error.invalidname"); //$NON-NLS-2$ //$NON-NLS-1$ - isError = true; + if (errormsg == "") errormsg= XMLCompareMessages.getString("XMLCompareEditMappingDialog.error.invalidname"); //$NON-NLS-2$ //$NON-NLS-1$ + isError= true; } else if (!fEdit && fIdmapHM != null && fIdmapHM.containsKey(mappingKey)) { - if (errormsg == "") errormsg = XMLCompareMessages.getString("XMLCompareEditMappingDialog.error.mappingExists"); //$NON-NLS-2$ //$NON-NLS-1$ - isError = true; + if (errormsg == "") errormsg= XMLCompareMessages.getString("XMLCompareEditMappingDialog.error.mappingExists"); //$NON-NLS-2$ //$NON-NLS-1$ + isError= true; } - text = fSignatureText.getText(); + text= fSignatureText.getText(); if (XMLComparePreferencePage.containsInvalidCharacters(text)) { - if (errormsg == "") errormsg = XMLCompareMessages.getString("XMLCompareEditMappingDialog.error.invalidsignature"); //$NON-NLS-2$ //$NON-NLS-1$ - isError = true; + if (errormsg == "") errormsg= XMLCompareMessages.getString("XMLCompareEditMappingDialog.error.invalidsignature"); //$NON-NLS-2$ //$NON-NLS-1$ + isError= true; } - text = fIdAttributeText.getText(); + text= fIdAttributeText.getText(); if (text.length() == 0) - isError = true; + isError= true; else if (XMLComparePreferencePage.containsInvalidCharacters(text)) { - if (errormsg == "") errormsg = XMLCompareMessages.getString("XMLCompareEditMappingDialog.error.invalididattribute"); //$NON-NLS-2$ //$NON-NLS-1$ - isError = true; + if (errormsg == "") errormsg= XMLCompareMessages.getString("XMLCompareEditMappingDialog.error.invalididattribute"); //$NON-NLS-2$ //$NON-NLS-1$ + isError= true; } if (isError) status.setError(errormsg); updateStatus(status); } -/** - * Notifies that the ok button of this dialog has been pressed. - */ + + /** + * Notifies that the ok button of this dialog has been pressed. + */ protected void okPressed() { fMapping.setElement(fElementText.getText()); fMapping.setSignature(fSignatureText.getText()); - String idtext = fIdAttributeText.getText(); + String idtext= fIdAttributeText.getText(); if (fIdTypeChildBodyButton.getSelection()) { - idtext = new Character(XMLStructureCreator.ID_TYPE_BODY) + idtext; + idtext= new Character(XMLStructureCreator.ID_TYPE_BODY) + idtext; } fMapping.setIdAttribute(idtext); super.okPressed(); } private void createIdSourceGroup(Composite composite) { - Label titleLabel = new Label(composite, SWT.NONE); + Label titleLabel= new Label(composite, SWT.NONE); titleLabel.setText(XMLCompareMessages.getString("XMLCompareEditMappingDialog.idtype")); //$NON-NLS-1$ titleLabel.setToolTipText(XMLCompareMessages.getString("XMLCompareEditMappingDialog.idtype.tooltip")); //$NON-NLS-1$ - Composite buttonComposite = new Composite(composite, SWT.LEFT); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; + Composite buttonComposite= new Composite(composite, SWT.LEFT); + GridLayout layout= new GridLayout(); + layout.numColumns= 2; buttonComposite.setLayout(layout); composite.setData(new GridData()); @@ -190,12 +192,12 @@ public class XMLCompareEditMappingDialog extends StatusDialog { fIdTypeAttributeButton.setToolTipText(XMLCompareMessages.getString("XMLCompareEditMappingDialog.idtype.attribute.tooltip")); //$NON-NLS-1$ //child body button - fIdTypeChildBodyButton = createRadioButton(buttonComposite, XMLCompareMessages.getString("XMLComparePreference.idtype.child_body")); //$NON-NLS-1$ + fIdTypeChildBodyButton= createRadioButton(buttonComposite, XMLCompareMessages.getString("XMLComparePreference.idtype.child_body")); //$NON-NLS-1$ fIdTypeChildBodyButton.setToolTipText(XMLCompareMessages.getString("XMLCompareEditMappingDialog.idtype.childbody.tooltip")); //$NON-NLS-1$ - String idtext = fMapping.getIdAttribute(); + String idtext= fMapping.getIdAttribute(); if (fEdit && idtext.charAt(0) == XMLStructureCreator.ID_TYPE_BODY) { - idtext = idtext.substring(1,idtext.length()); + idtext= idtext.substring(1,idtext.length()); fIdTypeChildBodyButton.setSelection(true); } else fIdTypeAttributeButton.setSelection(true); @@ -204,9 +206,9 @@ public class XMLCompareEditMappingDialog extends StatusDialog { } private Button createRadioButton(Composite parent, String label) { - Button button = new Button(parent, SWT.RADIO | SWT.LEFT); + Button button= new Button(parent, SWT.RADIO | SWT.LEFT); button.setText(label); - GridData data = new GridData(); + GridData data= new GridData(); button.setLayoutData(data); return button; } diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditOrderedDialog.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditOrderedDialog.java index ea9b37daa..5fb35230a 100644 --- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditOrderedDialog.java +++ b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditOrderedDialog.java @@ -37,9 +37,9 @@ public class XMLCompareEditOrderedDialog extends StatusDialog { private Text fElementText; private Text fSignatureText; -/** - * Constructs a new edit mapping dialog. - */ + /** + * Constructs a new edit mapping dialog. + */ public XMLCompareEditOrderedDialog(Shell parent, Mapping mapping, ArrayList idmapAL, boolean edit) { super(parent); @@ -47,24 +47,25 @@ public class XMLCompareEditOrderedDialog extends StatusDialog { setShellStyle(shellStyle | SWT.MAX | SWT.RESIZE); - fEdit = edit; + fEdit= edit; if (fEdit) setTitle(XMLCompareMessages.getString("XMLCompareEditOrderedDialog.editTitle")); //$NON-NLS-1$ else setTitle(XMLCompareMessages.getString("XMLCompareEditOrderedDialog.newTitle")); //$NON-NLS-1$ fMapping= mapping; - fIdmapAL = idmapAL; + fIdmapAL= idmapAL; } -/** - * Creates and returns the contents of the upper part - * of the dialog (above the button bar). - * - * Subclasses should override. - * - * @param the parent composite to contain the dialog area - * @return the dialog area control - */ + + /** + * Creates and returns the contents of the upper part + * of the dialog (above the button bar). + * + * Subclasses should override. + * + * @param the parent composite to contain the dialog area + * @return the dialog area control + */ protected Control createDialogArea(Composite ancestor) { Composite composite= (Composite) super.createDialogArea(ancestor); @@ -95,8 +96,8 @@ public class XMLCompareEditOrderedDialog extends StatusDialog { fSignatureText= new Text(inner, SWT.BORDER); fSignatureText.setText(fMapping.getSignature()); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.widthHint = convertWidthInCharsToPixels(50); + GridData data= new GridData(GridData.FILL_HORIZONTAL); + data.widthHint= convertWidthInCharsToPixels(50); fSignatureText.setLayoutData(data); fSignatureText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e){ @@ -109,40 +110,40 @@ public class XMLCompareEditOrderedDialog extends StatusDialog { return composite; } -/** - * Validate user input - */ + /** + * Validate user input + */ private void doValidation() { StatusInfo status= new StatusInfo(); - String text = fElementText.getText(); - String mappingKey = Mapping.getKey(fSignatureText.getText(), text); - String errormsg = ""; //$NON-NLS-1$ - boolean isError = false; + String text= fElementText.getText(); + String mappingKey= Mapping.getKey(fSignatureText.getText(), text); + String errormsg= ""; //$NON-NLS-1$ + boolean isError= false; if (text.length() == 0) { - errormsg = XMLCompareMessages.getString("XMLCompareEditMappingDialog.error.noname"); //$NON-NLS-1$ - isError = true; + errormsg= XMLCompareMessages.getString("XMLCompareEditMappingDialog.error.noname"); //$NON-NLS-1$ + isError= true; } else if (XMLComparePreferencePage.containsInvalidCharacters(text)) { - if (errormsg == "") errormsg = XMLCompareMessages.getString("XMLCompareEditMappingDialog.error.invalidname"); //$NON-NLS-2$ //$NON-NLS-1$ - isError = true; + if (errormsg == "") errormsg= XMLCompareMessages.getString("XMLCompareEditMappingDialog.error.invalidname"); //$NON-NLS-2$ //$NON-NLS-1$ + isError= true; } else if (!fEdit && fIdmapAL.contains(mappingKey)) { - if (errormsg == "") errormsg = XMLCompareMessages.getString("XMLCompareEditOrderedDialog.error.orderedExists"); //$NON-NLS-1$ //$NON-NLS-2$ - isError = true; + if (errormsg == "") errormsg= XMLCompareMessages.getString("XMLCompareEditOrderedDialog.error.orderedExists"); //$NON-NLS-1$ //$NON-NLS-2$ + isError= true; } - text = fSignatureText.getText(); + text= fSignatureText.getText(); if (XMLComparePreferencePage.containsInvalidCharacters(text)) { - if (errormsg == "") errormsg = XMLCompareMessages.getString("XMLCompareEditMappingDialog.error.invalidsignature"); //$NON-NLS-2$ //$NON-NLS-1$ - isError = true; + if (errormsg == "") errormsg= XMLCompareMessages.getString("XMLCompareEditMappingDialog.error.invalidsignature"); //$NON-NLS-2$ //$NON-NLS-1$ + isError= true; } if (isError) status.setError(errormsg); updateStatus(status); } -/** - * Notifies that the ok button of this dialog has been pressed. - */ + + /** + * Notifies that the ok button of this dialog has been pressed. + */ protected void okPressed() { fMapping.setElement(fElementText.getText()); fMapping.setSignature(fSignatureText.getText()); super.okPressed(); } - }
\ No newline at end of file diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareMessages.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareMessages.java index 3bf4161c5..79969d570 100644 --- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareMessages.java +++ b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareMessages.java @@ -15,8 +15,7 @@ import java.util.ResourceBundle; public class XMLCompareMessages { - private static final String BUNDLE_NAME = "org.eclipse.compare.examples.xml.xmlcompare"; //$NON-NLS-1$ - //$NON-NLS-1$ + private static final String BUNDLE_NAME= "org.eclipse.compare.examples.xml.xmlcompare"; //$NON-NLS-1$ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); @@ -31,4 +30,4 @@ public class XMLCompareMessages { return '!' + key + '!'; } } -}
\ No newline at end of file +} diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLNode.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLNode.java index b527fdb3f..91ea36cf3 100644 --- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLNode.java +++ b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLNode.java @@ -20,7 +20,7 @@ import org.eclipse.swt.graphics.Image; * Objects that make up the parse tree. */ public class XMLNode extends DocumentRangeNode implements ITypedElement { - + private String fValue; private String fName; private String fSignature; @@ -29,40 +29,43 @@ public class XMLNode extends DocumentRangeNode implements ITypedElement { private String fXMLType; private boolean fUsesIDMAP; private boolean fOrderedChild; - - public int bodies;//counts the number of bodies - + + public int bodies; // counts the number of bodies + public XMLNode(String XMLType, String id, String value, String signature, IDocument doc, int start, int length) { super(0, id, doc, start, length); - fXMLType = XMLType; + fXMLType= XMLType; fValue= value; fSignature= signature; fOrigId= id; - if (XMLStructureCreator.DEBUG_MODE) System.out.println("Created XMLNode with XMLType: "+XMLType+", id: "+id+", value: "+value+", signature: " +fSignature); //$NON-NLS-1$ //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ - bodies=0; - fUsesIDMAP = false; + if (XMLStructureCreator.DEBUG_MODE) + System.out.println("Created XMLNode with XMLType: " + XMLType + ", id: " + id + ", value: " + value + ", signature: " + fSignature); //$NON-NLS-1$ //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ + bodies= 0; + fUsesIDMAP= false; fOrderedChild= false; } void setValue(String value) { - fValue = value; + fValue= value; } String getValue() { return fValue; - } + } + /** * @see ITypedElement#getName */ public String getName() { if (fName != null) - return fName; + return fName; return this.getId(); } - + public void setName(String name) { - fName = name; + fName= name; } + /** * Every xml node is of type "txt" so that the builtin TextMergeViewer is used automatically. * @see ITypedElement#getType @@ -70,7 +73,7 @@ public class XMLNode extends DocumentRangeNode implements ITypedElement { public String getType() { return "txt"; //$NON-NLS-1$ } - + public void setIsOrderedChild(boolean isOrderedChild) { fOrderedChild= isOrderedChild; } @@ -79,43 +82,47 @@ public class XMLNode extends DocumentRangeNode implements ITypedElement { */ public Image getImage() { if (fOrderedChild) - return CompareUI.getImage(XMLPlugin.IMAGE_TYPE_PREFIX + XMLStructureCreator.TYPE_ELEMENT + XMLPlugin.IMAGE_TYPE_ORDERED_SUFFIX); + return CompareUI.getImage( + XMLPlugin.IMAGE_TYPE_PREFIX + + XMLStructureCreator.TYPE_ELEMENT + + XMLPlugin.IMAGE_TYPE_ORDERED_SUFFIX); else - return CompareUI.getImage(XMLPlugin.IMAGE_TYPE_PREFIX + getXMLType()); + return CompareUI.getImage( + XMLPlugin.IMAGE_TYPE_PREFIX + getXMLType()); } - + public void setParent(XMLNode parent0) { - this.parent = parent0; + this.parent= parent0; } - + public XMLNode getParent() { return this.parent; } - + String getXMLType() { return fXMLType; } - + String getSignature() { return fSignature; } - + void setOrigId(String id) { fOrigId= id; } - + public String getOrigId() { return fOrigId; } - + public void setUsesIDMAP(boolean b) { - fUsesIDMAP = b; + fUsesIDMAP= b; } - + public boolean usesIDMAP() { return fUsesIDMAP; } - + //for tests public boolean testEquals(Object obj) { if (obj instanceof XMLNode) { @@ -136,30 +143,32 @@ public class XMLNode extends DocumentRangeNode implements ITypedElement { return false; if (obj instanceof XMLNode) { XMLNode n= (XMLNode) obj; - if (getXMLType().equals(XMLStructureCreator.TYPE_ATTRIBUTE) && n.getXMLType().equals(XMLStructureCreator.TYPE_ATTRIBUTE)) + if (getXMLType().equals(XMLStructureCreator.TYPE_ATTRIBUTE) + && n.getXMLType().equals(XMLStructureCreator.TYPE_ATTRIBUTE)) return true; Object[] children= getChildren(); Object[] n_children= n.getChildren(); //if both nodes have no children, return true; - if ( (children == null || children.length <= 0) && (n_children == null || n_children.length <= 0) ) + if ((children == null || children.length <= 0) + && (n_children == null || n_children.length <= 0)) return true; //now at least one of the two nodes has children; /* so if one of the two nodes has no children, or they don't have the same number of children, * return false; */ - if ( (children == null || children.length <= 0) || (n_children == null || n_children.length <= 0) - || (children.length != n_children.length ) ) + if ((children == null || children.length <= 0) + || (n_children == null || n_children.length <= 0) + || (children.length != n_children.length)) return false; //now both have children and the same number of children for (int i= 0; i < children.length; i++) { /* if the subtree rooted at children[i] is not equal to the subtree rooted at n_children[i], * return false */ - if ( !((XMLNode)children[i]).subtreeEquals(n_children[i]) ) + if (!((XMLNode) children[i]).subtreeEquals(n_children[i])) return false; } } return true; } - } diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLStructureViewer.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLStructureViewer.java index 390d5c20e..205fb28ed 100644 --- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLStructureViewer.java +++ b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLStructureViewer.java @@ -64,13 +64,13 @@ public class XMLStructureViewer extends StructureDiffViewer { private HashMap fOrderedElements; protected static final char SIGN_SEPARATOR= XMLStructureCreator.SIGN_SEPARATOR; + /** * Creates a new viewer for the given SWT tree control with the specified configuration. * * @param tree the tree control * @param configuration the configuration for this viewer */ - class XMLSorter extends ViewerSorter { ArrayList fOrdered; @@ -137,9 +137,6 @@ public class XMLStructureViewer extends StructureDiffViewer { } } - - - public XMLStructureViewer(Tree tree, CompareConfiguration configuration) { super(tree, configuration); initialize(); |