Révision 3076
tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/OpenBiblio.java (revision 3076) | ||
---|---|---|
40 | 40 |
import org.txm.objects.Text; |
41 | 41 |
import org.txm.rcp.commands.OpenBrowser; |
42 | 42 |
import org.txm.rcp.editors.TXMBrowser; |
43 |
import org.txm.rcp.editors.TXMWebBrowserEditor; |
|
43 | 44 |
import org.txm.rcp.messages.TXMUIMessages; |
44 | 45 |
import org.txm.rcp.swt.dialog.ComboDialog; |
45 | 46 |
import org.txm.searchengine.cqp.corpus.CQPCorpus; |
47 |
|
|
46 | 48 |
/** |
47 | 49 |
* Open a text edition from: a main corpus : the first text of the maincorpus a |
48 | 50 |
* sub-corpus : the first text of the subcorpus a partition : the user must |
49 | 51 |
* choose one of the text used in the partition |
50 | 52 |
* |
51 | 53 |
* note: unplugged for now |
52 |
*
|
|
54 |
* |
|
53 | 55 |
* @author mdecorde. |
54 | 56 |
*/ |
55 | 57 |
public class OpenBiblio extends AbstractHandler { |
56 |
|
|
58 |
|
|
57 | 59 |
/** The Constant ID. */ |
58 | 60 |
public final static String ID = "org.txm.rcp.commands.base.OpenBiblio"; //$NON-NLS-1$ |
59 |
|
|
61 |
|
|
60 | 62 |
/** The lastopenedfile. */ |
61 | 63 |
public static String lastopenedfile; |
62 |
|
|
64 |
|
|
63 | 65 |
/** The textids. */ |
64 | 66 |
private ArrayList<String> textids; |
65 |
|
|
66 |
/* (non-Javadoc) |
|
67 |
|
|
68 |
/* |
|
69 |
* (non-Javadoc) |
|
67 | 70 |
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
68 | 71 |
*/ |
69 | 72 |
@Override |
70 | 73 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
71 |
|
|
74 |
|
|
72 | 75 |
IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); |
73 |
|
|
76 |
|
|
74 | 77 |
Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell(); |
75 |
|
|
78 |
|
|
76 | 79 |
if (selection.getFirstElement() instanceof CQPCorpus) { |
77 | 80 |
CQPCorpus corpus = (CQPCorpus) selection.getFirstElement(); |
78 |
|
|
79 |
textids = new ArrayList<String>(corpus.getProject().getTextsID()); |
|
80 |
if (textids.size() == 0) |
|
81 |
{ |
|
81 |
|
|
82 |
textids = new ArrayList<>(corpus.getProject().getTextsID()); |
|
83 |
if (textids.size() == 0) { |
|
82 | 84 |
System.out.println(NLS.bind(TXMUIMessages.noTextInCorpusColonP0, corpus.getName())); |
83 | 85 |
return null; |
84 | 86 |
} |
85 |
|
|
87 |
|
|
86 | 88 |
ComboDialog dialog = new ComboDialog(shell, TXMUIMessages.selectTextId, textids, textids.get(0)); |
87 |
if (dialog.open() == Window.OK) |
|
88 |
{ |
|
89 |
if (dialog.open() == Window.OK) { |
|
89 | 90 |
String textid = dialog.getSelectedValue(); |
90 | 91 |
openBiblio(corpus, textid); |
91 | 92 |
} |
92 | 93 |
} |
93 |
else if (selection.getFirstElement() instanceof Text) |
|
94 |
{ |
|
94 |
else if (selection.getFirstElement() instanceof Text) { |
|
95 | 95 |
Text text = (Text) selection.getFirstElement(); |
96 | 96 |
openBiblio(text); |
97 | 97 |
} |
98 | 98 |
return null; |
99 | 99 |
} |
100 |
|
|
100 |
|
|
101 | 101 |
/** |
102 | 102 |
* Open biblio. |
103 | 103 |
* |
... | ... | |
105 | 105 |
* @param textid the textid |
106 | 106 |
* @return the object |
107 | 107 |
*/ |
108 |
public Object openBiblio(CQPCorpus corpus, String textid ) {
|
|
109 |
|
|
108 |
public Object openBiblio(CQPCorpus corpus, String textid) { |
|
109 |
|
|
110 | 110 |
Text text = corpus.getProject().getText(textid); |
111 | 111 |
if (text == null) { |
112 | 112 |
System.out.println(NLS.bind(TXMUIMessages.couldNotFindTextP0InCorpusP1, textid, corpus.getName())); |
113 | 113 |
return null; |
114 | 114 |
} |
115 |
|
|
115 |
|
|
116 | 116 |
return openBiblio(text); |
117 | 117 |
} |
118 |
|
|
118 |
|
|
119 | 119 |
/** |
120 | 120 |
* Open biblio. |
121 | 121 |
* |
... | ... | |
123 | 123 |
* @return the object |
124 | 124 |
*/ |
125 | 125 |
public Object openBiblio(Text text) { |
126 |
|
|
127 |
if (text == null) |
|
128 |
{ |
|
126 |
|
|
127 |
if (text == null) { |
|
129 | 128 |
return null; |
130 | 129 |
} |
131 | 130 |
if (text.getBiblioPath() == null) { |
... | ... | |
138 | 137 |
return null; |
139 | 138 |
} |
140 | 139 |
TXMBrowser attachedBrowserEditor = OpenBrowser.openEdition(url); |
141 |
//attachedBrowserEditor.setCorpus(text.getCorpus()); |
|
140 |
// attachedBrowserEditor.setCorpus(text.getCorpus());
|
|
142 | 141 |
return null; |
143 | 142 |
} |
144 |
|
|
145 |
} |
|
143 |
|
|
144 |
} |
Formats disponibles : Unified diff