Revision 2455

tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/handlers/___TextToConcordance.java (revision 2455)
50 50
 * 
51 51
 * @author mdecorde.
52 52
 */
53
// FIXME: SJ: to remove?
53 54
@Deprecated
54 55
public class ___TextToConcordance extends AbstractHandler {
55

  
56
	/* (non-Javadoc)
56
	
57
	/*
58
	 * (non-Javadoc)
57 59
	 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
58 60
	 */
59 61
	@Override
60 62
	public Object execute(ExecutionEvent event) throws ExecutionException {
61
		//System.out.println("Call TextToConcordance");
63
		// System.out.println("Call TextToConcordance");
62 64
		IWorkbenchWindow window;
63 65
		TXMResultEditorInput editorInput;
64 66
		window = HandlerUtil.getActiveWorkbenchWindow(event);
65
		//selection = HandlerUtil.getCurrentSelection(event);
67
		// selection = HandlerUtil.getCurrentSelection(event);
66 68
		
67 69
		IEditorPart editor = window.getActivePage().getActiveEditor();
68

  
70
		
69 71
		if (editor instanceof IEditionEditor) {
70 72
			
71
			//System.out.println(((TXMBrowser)editor).getWordIDsSelection());
72
			String query = ((IEditionEditor)editor).getTextSelection();
73
			// System.out.println(((TXMBrowser)editor).getWordIDsSelection());
74
			String query = ((IEditionEditor) editor).getTextSelection();
73 75
			if (query.length() == 0) {
74 76
				System.out.println("No text selection. Aborting.");
75 77
				return null;
76 78
			}
77 79
			query = fixQuery(query);
78 80
			
79
			CQPCorpus corpus = ((IEditionEditor)editor).getCorpus();
81
			CQPCorpus corpus = ((IEditionEditor) editor).getCorpus();
80 82
			Concordance concordance = new Concordance(corpus);
81 83
			concordance.setParameters(new CQLQuery(query), null, null, null, null, null, null, null, null, null, null);
82 84
			editorInput = new TXMResultEditorInput(concordance);
83

  
85
			
84 86
			IWorkbenchPage page = window.getActivePage();
85 87
			try {
86 88
				ConcordanceEditor conceditor = (ConcordanceEditor) page
87 89
						.openEditor(editorInput, "ConcordanceEditor"); //$NON-NLS-1$
88
			} catch (PartInitException e) {
89
				System.err.println("Error: "+e.getLocalizedMessage());
90 90
			}
91
			catch (PartInitException e) {
92
				System.err.println("Error: " + e.getLocalizedMessage());
93
			}
91 94
		}
92 95
		return null;
93 96
	}
94 97
	
95 98
	public static String fixQuery(String query) {
96
		query = "\""+query.replaceAll("\"", "\\\"");//.replaceAll("("+TokenizerClasses.regPunct+")", " $1 ");
97
		query = query.replaceAll(" +", "\" \"")+"\"";
99
		query = "\"" + query.replaceAll("\"", "\\\"");// .replaceAll("("+TokenizerClasses.regPunct+")", " $1 ");
100
		query = query.replaceAll(" +", "\" \"") + "\"";
98 101
		return query;
99 102
	}
100 103
}

Also available in: Unified diff