Search in sources :

Example 1 with Table

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);
}
Also used : FormData(org.eclipse.swt.layout.FormData) Table(org.eclipse.swt.widgets.Table) Listener(org.eclipse.swt.widgets.Listener) Label(org.eclipse.swt.widgets.Label) Event(org.eclipse.swt.widgets.Event) TableColumn(org.eclipse.swt.widgets.TableColumn) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 2 with Table

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);
    }
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Group(org.eclipse.swt.widgets.Group) Shell(org.eclipse.swt.widgets.Shell) Table(org.eclipse.swt.widgets.Table) Button(org.eclipse.swt.widgets.Button) Label(org.eclipse.swt.widgets.Label) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 3 with Table

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

Example 4 with Table

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

Example 5 with Table

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);
    }
}
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)

Aggregations

Table (org.eclipse.swt.widgets.Table)770 GridData (org.eclipse.swt.layout.GridData)368 Composite (org.eclipse.swt.widgets.Composite)325 TableColumn (org.eclipse.swt.widgets.TableColumn)324 TableViewer (org.eclipse.jface.viewers.TableViewer)303 GridLayout (org.eclipse.swt.layout.GridLayout)255 TableItem (org.eclipse.swt.widgets.TableItem)210 SelectionEvent (org.eclipse.swt.events.SelectionEvent)204 Label (org.eclipse.swt.widgets.Label)179 Button (org.eclipse.swt.widgets.Button)161 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)145 Point (org.eclipse.swt.graphics.Point)138 Text (org.eclipse.swt.widgets.Text)102 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)96 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)95 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)89 FillLayout (org.eclipse.swt.layout.FillLayout)87 Shell (org.eclipse.swt.widgets.Shell)82 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)81 Event (org.eclipse.swt.widgets.Event)80