use of org.eclipse.swt.widgets.TableItem in project cogtool by cogtool.
the class ScriptViewerUI method showSelectionContextMenu.
/**
* Mouse event occurred on the table, use the selected item to
* display an appropriate menu.
*
*/
public void showSelectionContextMenu(int x, int y) {
contextSelection.deselectAll();
Table historyTable = view.getHistoryTable();
org.eclipse.swt.graphics.Point atPoint = historyTable.toControl(x, y);
TableItem ti = historyTable.getItem(atPoint);
if ((ti != null) && (ti.getData() instanceof DefaultModelGeneratorState)) {
contextSelection.setSelectedState((DefaultModelGeneratorState) ti.getData());
} else {
// this is the result Step, so no selection
historyTable.select(historyTable.getItemCount() - 1);
}
showContextMenu(contextSelection, true);
}
use of org.eclipse.swt.widgets.TableItem in project cogtool by cogtool.
the class ScriptViewerUI method getSelectedScript.
protected Script getSelectedScript(DefaultModelGeneratorState stepState) {
SWTList swtList = view.getScriptEditorList();
if (stepState == null) {
TaskGroup group = (TaskGroup) task;
List<AUndertaking> tasks = group.getUndertakings();
int numTasks = tasks.size();
for (int i = numTasks - 1; i >= 0; i--) {
AUndertaking t = tasks.get(i);
TaskApplication ta = project.getTaskApplication(t, design);
if (ta != null) {
return ta.getOnlyScript();
}
}
}
TableItem item = swtList.getItemList().get(stepState);
return (Script) item.getData(SWTListGroupScript.SCRIPT_DATA_KEY);
}
use of org.eclipse.swt.widgets.TableItem in project cogtool by cogtool.
the class DictionaryEditorUI method updateView.
protected void updateView() {
Table dictTable = view.getDictTable();
int selectionCount = 0;
try {
selectionCount = dictTable.getSelectionCount();
} catch (SWTException e) {
return;
}
if (selectionCount == 1) {
int index = dictTable.getSelectionIndex();
DictEntry entry = dictionary.getEntry(index);
if (entry != null) {
String url = null;
String space = null;
if (entry.algorithm instanceof ISitedTermSimilarity) {
url = ((ISitedTermSimilarity) entry.algorithm).getContextSite();
view.setURLEnabled(true);
view.setSpaceEnabled(false);
} else if (entry.algorithm instanceof LSASimilarity) {
LSASimilarity lsa = (LSASimilarity) entry.algorithm;
space = lsa.getSpace();
url = lsa.getURL();
if (url == null) {
url = LSASimilarity.DEFAULT_LSA_URL;
}
view.setURLEnabled(true);
view.setSpaceEnabled(true);
} else if (entry.algorithm instanceof GensimLSASimilarity) {
GensimLSASimilarity lsa = (GensimLSASimilarity) entry.algorithm;
space = lsa.getSpace();
url = lsa.getURL();
if (url == null) {
url = GensimLSASimilarity.DEFAULT_LSA_URL;
}
view.setURLEnabled(true);
view.setSpaceEnabled(true);
} else {
view.setURLEnabled(false);
view.setSpaceEnabled(false);
}
view.setURL(url);
view.setSpace(space);
} else {
TableItem row = dictTable.getItem(index);
Combo c = (Combo) row.getData();
int seln = c.getSelectionIndex();
boolean isLSA = (seln == DictionaryEditorUIModel.LSA_INDEX);
view.setURLEnabled((seln == DictionaryEditorUIModel.GOOGLE_WORD_INDEX) || (seln == DictionaryEditorUIModel.GOOGLE_PHRASE_INDEX) || isLSA);
view.setSpaceEnabled(isLSA);
}
} else {
// disable if 0 or more than 1 are selected
view.setURL(null);
view.setSpace(null);
view.setURLEnabled(false);
view.setSpaceEnabled(false);
}
}
use of org.eclipse.swt.widgets.TableItem in project cogtool by cogtool.
the class SWTList method addListItem.
/**
* Add a new item to the list at the specified index
* The item is automatically selected.
* @param newListItem Expects a String
* @param index Specifies the insertion point.
*/
public void addListItem(Object newListItem, int index) {
verifyTable();
if (newListItem == null) {
throw new IllegalArgumentException("Cannot add null to the list");
}
TableItem item = new TableItem(table, SWT.NONE, index);
itemMap.put(newListItem, item);
item.setData(newListItem);
doItemAction(item);
setRowContents(item);
}
use of org.eclipse.swt.widgets.TableItem in project cogtool by cogtool.
the class SWTList method setListItemHighlighted.
/**
* Uses an int index, to set the current selected item.
*
* If the passed in an index that is not in the list, a
* NoSuchElementException is thrown
*
* @param frameName
*/
public void setListItemHighlighted(int listItemIndex) {
verifyTable();
TableItem item = table.getItem(listItemIndex);
if (item != null) {
setTableItemSelected(item);
}
}
Aggregations