use of org.eclipse.swt.widgets.Table in project cogtool by cogtool.
the class DictionaryEditorView method layOutWidgets.
protected void layOutWidgets(Composite parent) {
nameLabel = new Label(parent, SWT.NONE);
dictTable = new Table(parent, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
dictTable.setLinesVisible(true);
dictTable.setHeaderVisible(true);
dictTable.setEnabled(true);
dictTable.addListener(SWT.MeasureItem, new Listener() {
public void handleEvent(Event event) {
event.height = OSUtils.MACOSX ? 28 : 25;
}
});
TableColumn goalColumn = new TableColumn(dictTable, SWT.NONE);
goalColumn.setText(GOAL_HEADER);
goalColumn.setResizable(true);
goalColumn.setWidth(DictionaryEditorView.COL_WIDTH);
TableColumn searchColumn = new TableColumn(dictTable, SWT.NONE);
searchColumn.setText(SEARCH_HEADER);
searchColumn.setResizable(true);
searchColumn.setWidth(DictionaryEditorView.COL_WIDTH);
TableColumn similarityColumn = new TableColumn(dictTable, SWT.RIGHT);
similarityColumn.setText(SIMIL_HEADER);
similarityColumn.setResizable(true);
similarityColumn.setWidth(DictionaryEditorView.COL_WIDTH);
TableColumn algColumn = new TableColumn(dictTable, SWT.NONE);
algColumn.setText(ALG_HEADER);
algColumn.setResizable(false);
algColumn.setWidth(DictionaryEditorView.COL_WIDTH);
TableColumn dateColumn = new TableColumn(dictTable, SWT.NONE);
dateColumn.setText(DATE_HEADER);
dateColumn.setResizable(true);
dateColumn.setWidth(DictionaryEditorView.COL_WIDTH);
urlLabel = new Label(parent, SWT.NONE);
urlLabel.setText(SITE_LABEL);
urlText = new View.PerformActionText(parent, SWT.SINGLE | SWT.BORDER) {
@Override
protected boolean doChangeAction() {
return performChangeURL();
}
};
urlText.setEnabled(false);
spaceLabel = new Label(parent, SWT.NONE);
spaceLabel.setText(SPACE_LABEL);
spaceCombo = new View.PerformActionCombo(parent, SWT.DROP_DOWN | SWT.BORDER) {
@Override
protected boolean doChangeAction() {
return performChangeSpace();
}
};
spaceCombo.setItems(LSASimilarity.KNOWN_SPACES);
spaceCombo.setEnabled(false);
FormData formData = new FormData();
formData.left = new FormAttachment(0, 5);
formData.top = new FormAttachment(0, 5);
nameLabel.setLayoutData(formData);
formData = new FormData();
formData.left = new FormAttachment(0, 20);
formData.top = new FormAttachment(nameLabel, 5);
formData.right = new FormAttachment(100, -20);
formData.height = 350;
dictTable.setLayoutData(formData);
formData = new FormData();
formData.left = new FormAttachment(0, 5);
formData.top = new FormAttachment(dictTable, 5);
spaceLabel.setLayoutData(formData);
formData = new FormData();
formData.left = new FormAttachment(spaceLabel, 5);
formData.top = new FormAttachment(dictTable, 5);
spaceCombo.setLayoutData(formData);
formData = new FormData();
formData.left = new FormAttachment(urlLabel, 5);
formData.top = new FormAttachment(spaceCombo, 5, SWT.BOTTOM);
formData.right = new FormAttachment(100, -15);
urlText.setLayoutData(formData);
formData = new FormData();
formData.left = new FormAttachment(0, 5);
formData.top = new FormAttachment(urlText.getOuter(), 0, SWT.CENTER);
formData.right = new FormAttachment(spaceLabel, 0, SWT.RIGHT);
urlLabel.setLayoutData(formData);
}
use of org.eclipse.swt.widgets.Table in project cogtool by cogtool.
the class SEDemoView method layOutWindow.
/**
* Lay out the window including the interactionDrawing editor
* @param edit
*
* @param tableCallback
*/
public void layOutWindow(int deviceTypes, SWTListMultiColumn rowRenderer) {
Shell shell = getShell();
// Set up the layouts
shell.setLayout(new FormLayout());
// Create a group for the properties on the history
historyProperties = new Group(shell, SWT.NONE);
historyProperties.setLayout(new FormLayout());
if (editable) {
// Create the delete Item button
deleteItem = new Button(historyProperties, SWT.PUSH);
deleteItem.setText(L10N.get("SE.DeleteStep", "Delete Step"));
deleteItem.addSelectionListener(new SWTWidgetChangeHandler(SEDemoLID.Delete));
lIDMap.addWidget(SEDemoLID.Delete, deleteItem, ListenerIdentifierMap.NORMAL);
// this.regenerateItem = new Button(this.historyProperties, SWT.PUSH);
// this.regenerateItem.setText(L10N.get("SE.RegenerateScript",
// "Regenerate Script"));
// this.regenerateItem.addSelectionListener(
// new SWTWidgetChangeHandler(SEDemoLID.RegenerateScript));
//
// this.lIDMap.addWidget(SEDemoLID.RegenerateScript,
// this.regenerateItem,
// ListenerIdentifierMap.NORMAL);
// Create the compute button
computeItem = new Button(historyProperties, SWT.PUSH);
computeItem.setText(COMPUTE);
computeItem.addSelectionListener(new SWTWidgetChangeHandler(SEDemoLID.RecomputeScript));
lIDMap.addWidget(SEDemoLID.RecomputeScript, computeItem, ListenerIdentifierMap.NORMAL);
}
// Script
scriptStepListLabel = new Label(historyProperties, SWT.CENTER);
String scriptStepLabel = scriptStepListTitle;
if (!editable) {
scriptStepLabel += " (" + VIEW_ONLY + ")";
scriptStepListLabel.setBackground(NONEDITABLE_COLOR);
}
scriptStepListLabel.setText(scriptStepLabel);
Table scriptStepTable = new Table(historyProperties, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);
scriptStepTable.setFont(FontUtils.SYMBOL_FONT);
scriptSteps = rowRenderer;
scriptSteps.setTable(scriptStepTable);
scriptSteps.setColumnTitles(columnTitles);
if (editable) {
addHandOnKeyboardToStart(deviceTypes, historyProperties);
}
predictionResult = new Label(shell, SWT.LEFT);
FormData editorData = new FormData();
editorData.top = new FormAttachment(0, 5);
editorData.left = new FormAttachment(0, 5);
editorData.bottom = new FormAttachment(100, -5);
Label predictionLabel = new Label(shell, SWT.LEFT);
predictionLabel.setText(predictionTitle);
predictionLabel.setFont(PREDICTION_LABEL_FONT);
Button showVisButton = new Button(shell, SWT.PUSH);
FormData data = new FormData();
data.top = new FormAttachment(showVisButton, 0, SWT.CENTER);
data.left = new FormAttachment(historyProperties, 5, SWT.LEFT);
predictionLabel.setLayoutData(data);
data = new FormData();
data.top = new FormAttachment(showVisButton, 0, SWT.CENTER);
data.left = new FormAttachment(predictionLabel, 5, SWT.RIGHT);
data.right = new FormAttachment(showVisButton, 0, SWT.LEFT);
predictionResult.setLayoutData(data);
showVisButton.setText(SHOW_VISUALIZATION);
data = new FormData();
data.top = new FormAttachment(0, 10);
data.right = new FormAttachment(historyProperties, 0, SWT.RIGHT);
showVisButton.setLayoutData(data);
showVisButton.addSelectionListener(new SWTWidgetChangeHandler(SEDemoLID.ShowModelVisualization));
lIDMap.addWidget(SEDemoLID.ShowModelVisualization, showVisButton, ListenerIdentifierMap.NORMAL);
data = new FormData();
data.top = new FormAttachment(showVisButton, 2, SWT.BOTTOM);
data.right = new FormAttachment(100, -5);
data.bottom = new FormAttachment(100, -5);
SashUtility.createVerticalSash(getShell(), MIN_DRAWING_AREA_WIDTH, HISTORY_LIST_WIDTH, SWT.RIGHT, editor.bodyComposite, editorData, historyProperties, data);
// Layout contents of widgetGroup
data = new FormData();
data.top = new FormAttachment(predictionLabel, 0, SWT.BOTTOM);
data.left = new FormAttachment(scriptStepTable, 0, SWT.LEFT);
data.right = new FormAttachment(scriptStepTable, 0, SWT.RIGHT);
scriptStepListLabel.setLayoutData(data);
data = new FormData();
data.top = new FormAttachment(scriptStepListLabel, 5, SWT.BOTTOM);
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(100, 0);
positionStartLocParms(data);
scriptStepTable.setLayoutData(data);
if (editable) {
data = new FormData();
data.left = new FormAttachment(scriptStepTable, 0, SWT.LEFT);
data.right = new FormAttachment(scriptStepTable, 0, SWT.RIGHT);
data.bottom = new FormAttachment(computeItem, 0, SWT.TOP);
deleteItem.setLayoutData(data);
// data = new FormData();
// data.left = new FormAttachment(scriptStepTable, 0, SWT.LEFT);
// data.right = new FormAttachment(scriptStepTable, 0, SWT.RIGHT);
// data.bottom = new FormAttachment(this.computeItem, 0 , SWT.TOP);
// this.regenerateItem.setLayoutData(data);
data = new FormData();
// use 0 here, since internal frame is set to -05, fix internal frame
data.bottom = new FormAttachment(100, 0);
data.left = new FormAttachment(scriptStepTable, 0, SWT.LEFT);
data.right = new FormAttachment(scriptStepTable, 0, SWT.RIGHT);
computeItem.setLayoutData(data);
layOutPropertiesPane(editor.propertiesComposite);
}
}
use of org.eclipse.swt.widgets.Table in project cogtool by cogtool.
the class SEDemoUI 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.Table 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.Table 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);
}
}
Aggregations