Project

General

Profile

« Previous | Next » 

Revision 7e11e39b

Added by Katja Luther over 6 years ago

fix problem with more than one inline reference

View differences:

eu.etaxonomy.taxeditor.cdmlib/.classpath
12 12
	<classpathentry exported="true" kind="lib" path="lib/cdmlib-commons-4.13.0-SNAPSHOT.jar"/>
13 13
	<classpathentry exported="true" kind="lib" path="lib/cdmlib-ext-4.13.0-SNAPSHOT.jar"/>
14 14
	<classpathentry exported="true" kind="lib" path="lib/cdmlib-io-4.13.0-SNAPSHOT.jar"/>
15
	<classpathentry exported="true" kind="lib" path="lib/cdmlib-model-4.13.0-SNAPSHOT.jar"/>
15
	<classpathentry exported="true" kind="lib" path="lib/cdmlib-model-4.13.0-SNAPSHOT.jar" sourcepath="C:/Users/k.luther/.m2/repository/eu/etaxonomy/cdmlib-model/4.13.0-SNAPSHOT/cdmlib-model-4.13.0-SNAPSHOT-sources.jar"/>
16 16
	<classpathentry exported="true" kind="lib" path="lib/cdmlib-persistence-4.13.0-SNAPSHOT.jar"/>
17 17
	<classpathentry exported="true" kind="lib" path="lib/cdmlib-print-4.13.0-SNAPSHOT.jar"/>
18 18
	<classpathentry exported="true" kind="lib" path="lib/cdmlib-remote-4.13.0-SNAPSHOT.jar"/>
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/NameHelper.java
9 9

  
10 10
package eu.etaxonomy.taxeditor.model;
11 11

  
12
import javax.sql.rowset.spi.SyncFactory;
13

  
12 14
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
13 15
import eu.etaxonomy.cdm.model.name.TaxonName;
16
import eu.etaxonomy.cdm.model.taxon.Synonym;
14 17
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
15 18

  
16 19
/**
......
65 68
			if (fullTitle != null){  //should never be null
66 69
				fullTitle = fullTitle.replaceAll("(\\r|\\n|\\r\\n)", "");  //replaces LineBreaks, maybe we should include U+000C, U+0085, U+2028, U+2029 which are also linebreaks according to UNICODE stardard.
67 70
			}
71
			
68 72
			return fullTitle;
69 73
		}
70 74
		return "";
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/AppModelId.java
124 124
	public static final String POPUPMENU_EU_ETAXONOMY_TAXEDITOR_STORE_POPUPMENU_DATASOURCEVIEW = "eu.etaxonomy.taxeditor.store.popupmenu.datasourceview";
125 125
	public static final String POPUPMENU_EU_ETAXONOMY_TAXEDITOR_STORE_POPUPMENU_FEATURETREEEDITOR = "eu.etaxonomy.taxeditor.store.popupmenu.featureTreeEditor";
126 126
	public static final String POPUPMENU_EU_ETAXONOMY_TAXEDITOR_STORE_POPUPMENU_TERMEDITOR = "eu.etaxonomy.taxeditor.store.popupmenu.termeditor";
127
	public static final String PARTDESCRIPTOR_BULKEDITOR_EDITOR = "bulkeditor.editor";
127 128
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/RichTextWithLabelElement.java
272 272
	        	for (IntextReference inref: inrefs){
273 273
	        		
274 274
	        		if (inref.getTarget() == null){
275
	        			break;
275
	        			continue;
276 276
	        		}
277 277
	        		
278
	        		inLineString = RichtextHelper.findInlineString(convertedString,  inref.toInlineString(".*"));
279
	        		innerText = RichtextHelper.findInText(inLineString, "(<cdm:.+>)(.+)(</cdm:.+>)");
278
	        		inLineString = RichtextHelper.findInlineString(convertedString,  inref.toInlineString("(.+?)"));
279
	        		innerText = RichtextHelper.findInText(inLineString, "(<cdm:.+>)(.+?)(</cdm:.+>)");
280 280
	        		if (innerText != null){
281 281
	        			htmlString = RichtextHelper.createHtml(inref, innerText);
282 282
	        		}else{
......
291 291
	        		}
292 292
	        		
293 293
	        	}
294
	        	text.setText(convertedString);
294
	        	
295 295
	        	if(!converted){
296 296
	        		System.err.println("There is a problem with the language string and an intextrefernce.");
297
	        	}else{
298
	        		text.setText(convertedString);
297 299
	        	}
298 300
	        	
299 301
        	}
......
341 343
        		htmlString = findHtmlString(text.getText(), inref);
342 344
        		System.out.println("html"+htmlString);
343 345
        		if (htmlString != null){
344
        			innerText = RichtextHelper.findInText(htmlString, "(.+>)(.*)(</span>)");
346
        			innerText = RichtextHelper.findInText(htmlString, "(.+>)(.*?)(</span>)");
345 347
        			inLineString = RichtextHelper.createCdmMarkUp(inref, innerText);
346 348
        			
347 349
        			convertedString = convertedString.replace(htmlString, inLineString);
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/IntextReferenceDetailElement.java
23 23
import eu.etaxonomy.taxeditor.ui.element.ILanguageStringProvider;
24 24
import eu.etaxonomy.taxeditor.ui.element.LanguageRichTextWithLabel;
25 25
import eu.etaxonomy.taxeditor.ui.element.LanguageStringWithLabelElement;
26
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
26 27
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
27 28
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
29
import eu.etaxonomy.taxeditor.util.RichtextHelper;
28 30

  
29 31
public class IntextReferenceDetailElement extends AbstractEntityCollectionElement<IntextReference>	{
30 32
	
31 33
	private ILanguageStringProvider langStringElement;
32 34
	protected EntitySelectionElement<Reference> selection_reference;
35
	TextWithLabelElement label;
33 36

  
34 37
	public IntextReferenceDetailElement(CdmFormFactory formFactory, AbstractFormSection section, IntextReference entity, ILanguageStringProvider textElement,
35 38
			SelectionListener removeListener, Color backgroundColor, int style) {
......
72 75
				selection_reference.setEntity((Reference)entity.getTarget());
73 76
			}
74 77
		}
78
		
79
		label = formFactory.createTextWithLabelElement(element, "Label", null, style);
80
		if (entity.getReferencedEntity() != null){
81
			String text = entity.getReferencedEntity().getText();
82
			label.setText(RichtextHelper.findInnerText(text, entity));
83
		}
84
		
75 85
		Button setButton = formFactory.createButton(this.getLayoutComposite(), "Set IntextReference", SWT.NONE);
76 86
  	  
77 87
		setButton.addSelectionListener(new SelectionAdapter() { 
......
84 94
  			}
85 95
  			
86 96
  			//System.out.println(langStringElement.getText());
87
  			IntextReference intextRef = IntextReferenceHelper.addIntextReference((IIntextReferenceTarget)selection_reference.getSelection(), (IIntextReferencable)entity, point.x, point.y);
88
  			setEntity(intextRef);
97
  			IntextReference intextRef = IntextReferenceHelper.addIntextReference((IIntextReferenceTarget)selection_reference.getSelection(), entity, point.x, point.y);
98
//  			setEntity(intextRef);
89 99
  			getLangStringElement().setLanguageString((LanguageString)intextRef.getReferencedEntity()) ;
100
//  			label.setText(intextRef.getReferencedEntity().getText().substring(intextRef.getStartPos(), intextRef.getEndPos()));
90 101
  			firePropertyChangeEvent(new CdmPropertyChangeEvent(this, e));
91 102
  			
92 103
 			
......
94 105
  	   } 
95 106
  	  }); 
96 107
		
108
		
97 109
	}
98 110

  
99 111
	@Override
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/util/RichtextHelper.java
69 69
    	Matcher matcher = pattern.matcher(text);
70 70
    	if (matcher.find())
71 71
    	{
72
    		String result0 = matcher.group();
72 73
    		String result = matcher.group(1);
74
    		String result2 = matcher.group(2);
73 75
    	    return matcher.group(2);
74 76
    	}
75 77
    	return null;
......
79 81
    	return inRef.toInlineString(innerText);
80 82
    	
81 83
    }
84
    
85
    public static String findInnerText(String text, IntextReference inRef){
86
    	String innerText = null;
87
    	if (inRef.getTarget() != null){
88
	    	String inLineString = RichtextHelper.findInlineString(text,  inRef.toInlineString("(.*?)"));
89
	    	innerText = RichtextHelper.findInText(inLineString, "(<cdm:.+>)(.+)(</cdm:.+>)");
90
    	}
91
		return innerText;
92
    }
82 93
}

Also available in: Unified diff