Révision 2321
| tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/handlers/ComputeCA.java (revision 2321) | ||
|---|---|---|
| 27 | 27 |
// |
| 28 | 28 |
package org.txm.ca.rcp.handlers; |
| 29 | 29 |
|
| 30 |
import javax.swing.SwingUtilities; |
|
| 31 |
|
|
| 32 | 30 |
import org.eclipse.core.commands.ExecutionEvent; |
| 33 | 31 |
import org.eclipse.core.commands.ExecutionException; |
| 34 | 32 |
import org.eclipse.jface.dialogs.MessageDialog; |
| ... | ... | |
| 40 | 38 |
import org.eclipse.ui.handlers.HandlerUtil; |
| 41 | 39 |
import org.txm.ca.core.functions.CA; |
| 42 | 40 |
import org.txm.ca.rcp.editors.CAEditor; |
| 43 |
import org.txm.ca.rcp.editors.CAParametersDialog; |
|
| 44 | 41 |
import org.txm.ca.rcp.messages.CAUIMessages; |
| 45 | 42 |
import org.txm.core.messages.TXMCoreMessages; |
| 46 | 43 |
import org.txm.index.core.functions.PartitionIndex; |
| ... | ... | |
| 49 | 46 |
import org.txm.rcp.TXMWindows; |
| 50 | 47 |
import org.txm.rcp.editors.TXMResultEditorInput; |
| 51 | 48 |
import org.txm.rcp.handlers.BaseAbstractHandler; |
| 52 |
import org.txm.rcp.messages.TXMUIMessages; |
|
| 53 | 49 |
import org.txm.searchengine.cqp.corpus.Partition; |
| 54 | 50 |
import org.txm.searchengine.cqp.corpus.Property; |
| 55 |
import org.txm.searchengine.cqp.corpus.WordProperty; |
|
| 56 | 51 |
import org.txm.utils.logger.Log; |
| 57 | 52 |
import org.txm.utils.logger.MessageBox; |
| 58 | 53 |
|
| ... | ... | |
| 65 | 60 |
* |
| 66 | 61 |
*/ |
| 67 | 62 |
public class ComputeCA extends BaseAbstractHandler {
|
| 68 |
|
|
| 69 |
|
|
| 63 |
|
|
| 64 |
|
|
| 70 | 65 |
@Override |
| 71 | 66 |
public Object execute(ExecutionEvent event) throws ExecutionException {
|
| 72 |
|
|
| 67 |
|
|
| 73 | 68 |
if (!this.checkStatsEngine()) {
|
| 74 | 69 |
return null; |
| 75 | 70 |
} |
| 76 |
|
|
| 71 |
|
|
| 77 | 72 |
final IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event); |
| 78 | 73 |
final Object selection = this.getCorporaViewSelectedObject(event); |
| 79 |
|
|
| 74 |
|
|
| 80 | 75 |
try {
|
| 81 |
System.out.println(CAUIMessages.creatingCA);
|
|
| 82 |
|
|
| 76 |
Log.info(CAUIMessages.creatingCA);
|
|
| 77 |
|
|
| 83 | 78 |
LexicalTable lexicalTable = null; |
| 84 | 79 |
CA ca = null; |
| 85 |
|
|
| 80 |
|
|
| 86 | 81 |
// Reopening an existing result |
| 87 | 82 |
if (selection instanceof CA) {
|
| 88 | 83 |
ca = (CA) selection; |
| ... | ... | |
| 91 | 86 |
else {
|
| 92 | 87 |
// Creating from Partition |
| 93 | 88 |
if (selection instanceof Partition) {
|
| 94 |
|
|
| 89 |
|
|
| 95 | 90 |
final Partition partition = (Partition) selection; |
| 96 | 91 |
partition.compute(false); |
| 97 | 92 |
// not enough parts error |
| 98 | 93 |
if (partition.getPartsCount() < 4) {
|
| 99 | 94 |
Display.getDefault().syncExec(new Runnable() {
|
| 100 |
|
|
| 95 |
|
|
| 101 | 96 |
@Override |
| 102 | 97 |
public void run() {
|
| 103 |
MessageDialog d = new MessageDialog(window.getShell(), TXMCoreMessages.error_error2, null, NLS.bind(CAUIMessages.canNotComputeFactorialAnalysisWithOnlyP0PartsTheMinimumIs4Parts, partition.getPartsCount()), 0, new String[] { TXMCoreMessages.common_ok }, 0);
|
|
| 98 |
|
|
| 99 |
MessageDialog d = new MessageDialog(window.getShell(), TXMCoreMessages.error_error2, null, NLS.bind( |
|
| 100 |
CAUIMessages.canNotComputeFactorialAnalysisWithOnlyP0PartsTheMinimumIs4Parts, partition.getPartsCount()), 0, new String[] { TXMCoreMessages.common_ok }, 0);
|
|
| 104 | 101 |
d.open(); |
| 105 | 102 |
} |
| 106 | 103 |
}); |
| 107 | 104 |
return null; |
| 108 | 105 |
} |
| 109 |
|
|
| 106 |
|
|
| 110 | 107 |
// FIXME: SJ: temporary version before we fix the problems listed below |
| 111 |
// lexicalTable = new LexicalTable(partition);
|
|
| 112 |
// lexicalTable.setParameters((WordProperty) partition.getCorpus().getDefaultProperty(), 20, 200, null);
|
|
| 113 |
// ca = new CA(lexicalTable);
|
|
| 114 |
|
|
| 108 |
// lexicalTable = new LexicalTable(partition);
|
|
| 109 |
// lexicalTable.setParameters((WordProperty) partition.getCorpus().getDefaultProperty(), 20, 200, null);
|
|
| 110 |
// ca = new CA(lexicalTable);
|
|
| 111 |
|
|
| 115 | 112 |
// FIXME: SJ: new version, creating a, empty LT and an empty CA |
| 116 | 113 |
// does not work at this time because of some problems in CAEditor (refreshing and components creation + eigenvalues computing) |
| 117 | 114 |
lexicalTable = new LexicalTable(partition); |
| ... | ... | |
| 123 | 120 |
lexicalTable = new LexicalTable(index); |
| 124 | 121 |
|
| 125 | 122 |
if (index.getPartition().getPartsCount() < 4) {
|
| 126 |
// FIXME: remove this swing code that freeze the UI, need to use SWT in main thread
|
|
| 123 |
// FIXME: SJ: remove this swing code that freezes the UI, need to use SWT in main thread
|
|
| 127 | 124 |
MessageBox.error(CAUIMessages.canNotComputeCAOnLexicalTableWithLessThan4Columns); |
| 128 | 125 |
return null; |
| 129 | 126 |
} |
| 130 | 127 |
if (index.hasBeenComputedOnce() && index.getAllLines().size() < 4) {
|
| 131 |
// FIXME: remove this swing code that freeze the UI, need to use SWT in main thread
|
|
| 128 |
// FIXME: SJ: remove this swing code that freezes the UI, need to use SWT in main thread
|
|
| 132 | 129 |
MessageBox.error(CAUIMessages.canNotComputeCAWithLessThan4RowsInTheTable); |
| 133 | 130 |
return null; |
| 134 | 131 |
} |
| 135 |
|
|
| 132 |
|
|
| 136 | 133 |
Log.info(NLS.bind(CAUIMessages.computingCorrespondenceAnalysisOnP0WithPropertyP1, index, property)); |
| 137 | 134 |
ca = new CA(lexicalTable); |
| 138 | 135 |
} |
| ... | ... | |
| 140 | 137 |
else if (selection instanceof LexicalTable) {
|
| 141 | 138 |
lexicalTable = (LexicalTable) selection; |
| 142 | 139 |
Property property = lexicalTable.getProperty(); |
| 143 |
|
|
| 140 |
|
|
| 144 | 141 |
Log.info(NLS.bind(CAUIMessages.computingCorrespondenceAnalysisOnP0WithPropertyP1, lexicalTable, property)); |
| 145 |
|
|
| 142 |
|
|
| 146 | 143 |
if (lexicalTable.hasBeenComputedOnce() && lexicalTable.getNColumns() < 4) {
|
| 147 | 144 |
// FIXME: remove this swing code that freeze the UI, need to use SWT in main thread |
| 148 | 145 |
MessageBox.error(CAUIMessages.canNotComputeCAOnLexicalTableWithLessThan4Columns); |
| ... | ... | |
| 153 | 150 |
MessageBox.error(CAUIMessages.canNotComputeCAWithLessThan4RowsInTheTable); |
| 154 | 151 |
return null; |
| 155 | 152 |
} |
| 156 |
|
|
| 153 |
|
|
| 157 | 154 |
ca = new CA(lexicalTable); |
| 158 | 155 |
} |
| 159 |
|
|
| 156 |
|
|
| 160 | 157 |
// show the lexical table only if the command was called from a lexical table |
| 161 |
if(!(selection instanceof LexicalTable)) {
|
|
| 158 |
if (!(selection instanceof LexicalTable)) {
|
|
| 162 | 159 |
lexicalTable.setVisible(false); |
| 163 | 160 |
} |
| 164 |
|
|
| 161 |
|
|
| 165 | 162 |
} |
| 166 |
|
|
| 167 |
// FIXME: should be done in the CAEditor |
|
| 168 |
// compute the CA |
|
| 169 |
//ca.compute(); |
|
| 170 |
|
|
| 163 |
|
|
| 171 | 164 |
try {
|
| 172 | 165 |
Log.fine(CAUIMessages.loadingCorrespondenceAnalysisResults); |
| 173 |
|
|
| 166 |
|
|
| 174 | 167 |
TXMResultEditorInput<CA> editorInput = new TXMResultEditorInput<CA>(ca); |
| 175 | 168 |
IWorkbenchPage page = TXMWindows.getActivePage(); |
| 176 | 169 |
StatusLine.setMessage(CAUIMessages.openingTheCorrespondenceAnalysisResults); |
| ... | ... | |
| 190 | 183 |
} |
| 191 | 184 |
return null; |
| 192 | 185 |
} |
| 193 |
|
|
| 194 |
} |
|
| 186 |
|
|
| 187 |
} |
|
Formats disponibles : Unified diff