Search in sources :

Example 6 with TableItem

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);
}
Also used : Table(org.eclipse.swt.widgets.Table) TableItem(org.eclipse.swt.widgets.TableItem) DefaultModelGeneratorState(edu.cmu.cs.hcii.cogtool.model.DefaultModelGeneratorState)

Example 7 with TableItem

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);
}
Also used : SWTList(edu.cmu.cs.hcii.cogtool.view.SWTList) Script(edu.cmu.cs.hcii.cogtool.model.Script) SWTListGroupScript(edu.cmu.cs.hcii.cogtool.view.SWTListGroupScript) AUndertaking(edu.cmu.cs.hcii.cogtool.model.AUndertaking) TableItem(org.eclipse.swt.widgets.TableItem) TaskApplication(edu.cmu.cs.hcii.cogtool.model.TaskApplication) TaskGroup(edu.cmu.cs.hcii.cogtool.model.TaskGroup)

Example 8 with TableItem

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);
    }
}
Also used : Table(org.eclipse.swt.widgets.Table) SWTException(org.eclipse.swt.SWTException) TableItem(org.eclipse.swt.widgets.TableItem) DictEntry(edu.cmu.cs.hcii.cogtool.model.ISimilarityDictionary.DictEntry) GensimLSASimilarity(edu.cmu.cs.hcii.cogtool.model.GensimLSASimilarity) LSASimilarity(edu.cmu.cs.hcii.cogtool.model.LSASimilarity) Combo(org.eclipse.swt.widgets.Combo) ISitedTermSimilarity(edu.cmu.cs.hcii.cogtool.model.ISitedTermSimilarity) Point(org.eclipse.swt.graphics.Point) GensimLSASimilarity(edu.cmu.cs.hcii.cogtool.model.GensimLSASimilarity)

Example 9 with TableItem

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);
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem)

Example 10 with TableItem

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);
    }
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem)

Aggregations

TableItem (org.eclipse.swt.widgets.TableItem)323 Point (org.eclipse.swt.graphics.Point)76 Table (org.eclipse.swt.widgets.Table)58 SelectionEvent (org.eclipse.swt.events.SelectionEvent)56 ArrayList (java.util.ArrayList)46 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)40 GridData (org.eclipse.swt.layout.GridData)40 Composite (org.eclipse.swt.widgets.Composite)34 HashMap (java.util.HashMap)33 GridLayout (org.eclipse.swt.layout.GridLayout)33 Map (java.util.Map)31 TableColumn (org.eclipse.swt.widgets.TableColumn)31 List (java.util.List)27 HashSet (java.util.HashSet)25 Rectangle (org.eclipse.swt.graphics.Rectangle)23 Button (org.eclipse.swt.widgets.Button)23 Label (org.eclipse.swt.widgets.Label)22 TreeItem (org.eclipse.swt.widgets.TreeItem)17 Constraint (com.cubrid.common.core.common.model.Constraint)16 TableEditor (org.eclipse.swt.custom.TableEditor)16