Search in sources :

Example 1 with Design

use of edu.cmu.cs.hcii.cogtool.model.Design in project cogtool by cogtool.

the class SWTTreeProjectSelectionState method setSelectedCell.

/**
     * Support for selecting a cell
     */
public void setSelectedCell(TreeItem item, TreeColumn column) {
    if ((item != null) && (column != null)) {
        AUndertaking t = (AUndertaking) item.getData();
        Design d = (Design) column.getData();
        if ((t != null) && (d != null)) {
            deselectAll();
            selectedColumns.add(column);
            selectedItems.put(t, item);
            raiseAlert(new ProjectSelectionChange(this, tree.indexOf(column), item, true));
        }
    }
}
Also used : Design(edu.cmu.cs.hcii.cogtool.model.Design) AUndertaking(edu.cmu.cs.hcii.cogtool.model.AUndertaking)

Example 2 with Design

use of edu.cmu.cs.hcii.cogtool.model.Design in project cogtool by cogtool.

the class ProjectUI method showContextMenu.

// Override to set the correct context menu on the frame
//    item  item-selected column design  where          selection to use
//(a)  ok        n/a        ok     ok    cell           temporary cell
//(b)  ok        yes        ok    null   task           normal selection
//(c)  ok        no         ok    null   task           temporary task
//(d)  ok        n/a       null    n/a   right of cells temporary task
//(e) null       n/a        ok     ok    design         temporary design
//(f) null       n/a        ok    null   bottom-left    no selection
//(g) null       n/a       null    n/a   bottom-right   no selection
// TODO: dfm -- make the code match the above!!!!!
@Override
public void showContextMenu(int x, int y) {
    // Clear any stale state
    contextSelection.deselectAll();
    // Check which region of the frame was hit
    TreeItem item = tree.getItem(new Point(x, y));
    TreeColumn column = findColumn(x);
    // See if the context invocation was made beyond all designs
    if (column == null) {
        if (item == null) {
            // see (g) above
            showContextMenu();
        } else {
            // see (d) above
            selectOverBox(item.getBounds());
            contextSelection.addSelectedTask((AUndertaking) item.getData());
            showContextMenu(contextSelection, View.CONTEXT);
        }
    } else // If not, the invocation occurred somewhere within the table
    {
        Design design = (Design) column.getData();
        // Detect a context invocation in the table header/footer
        if (item == null) {
            // Detect a context invocation under the "tasks" heading
            if (design == null) {
                // see (f) above
                showContextMenu();
            } else // Otherwise the invocation lies under a design heading
            {
                // see (e) above
                // TODO: Really?  What if something else was selected?
                selectOverBox(computeColumnArea(column));
                contextSelection.setSelectedDesign(design);
                showContextMenu(contextSelection, View.CONTEXT);
            }
        } else // Detect a context invocation inside the table body
        {
            AUndertaking undertaking = (AUndertaking) item.getData();
            // Check for context invocation under the "tasks" column
            if (design == null) {
                // Set up the contextual selection state as necessary
                if (selection.isTaskSelected(undertaking)) {
                    // see (b) above
                    showContextMenu();
                } else {
                    // see (c) above
                    selectOverBox(item.getBounds());
                    contextSelection.addSelectedTask(undertaking);
                    showContextMenu(contextSelection, View.CONTEXT);
                }
            } else // Otherwise at the intersection of a task and a design
            {
                // see (a) above
                selection.setSelectedCell(item, column);
                Rectangle bounds = item.getBounds(tree.indexOf(column));
                if (OSUtils.MACOSX) {
                    // XXX: DIRTY HACK TO fix SWT bug.
                    bounds.y -= 1;
                    bounds.height += 1;
                }
                selectOverBox(bounds);
                // TODO: instead of the following, pass undertaking and
                //       design in to showContextMenuForIntersection()
                Menu contextMenu = view.getContextMenuForIntersection(project, undertaking, design);
                // Set up the contextual selection state as necessary
                contextSelection.setSelectedDesign(design);
                contextSelection.addSelectedTask(undertaking);
                setViewEnabledState(contextSelection, ListenerIdentifierMap.CONTEXT);
                contextMenu.setVisible(true);
            }
        }
    }
}
Also used : Design(edu.cmu.cs.hcii.cogtool.model.Design) TreeItem(org.eclipse.swt.widgets.TreeItem) TreeColumn(org.eclipse.swt.widgets.TreeColumn) AUndertaking(edu.cmu.cs.hcii.cogtool.model.AUndertaking) Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point) Menu(org.eclipse.swt.widgets.Menu)

Example 3 with Design

use of edu.cmu.cs.hcii.cogtool.model.Design in project cogtool by cogtool.

the class ProjectUI method createPredicates.

// setUpDragAndDrop
protected void createPredicates() {
    requiresRegenerationPredicate = new ProjectSelectionPredicate(project) {

        @Override
        protected boolean isSatisfiedBy(Design design, AUndertaking t) {
            TaskApplication ta = project.getTaskApplication(t, design);
            if (ta != null) {
                Demonstration demo = ta.getDemonstration();
                return demo.isObsolete();
            }
            return false;
        }
    };
    hasComputableScriptsPredicate = new ProjectSelectionPredicate(project) {

        @Override
        protected boolean isSatisfiedBy(Design design, AUndertaking t) {
            TaskApplication taskApp = project.getTaskApplication(t, design);
            if (taskApp != null) {
                IPredictionAlgo activeAlg = taskApp.determineActiveAlgorithm(project);
                APredictionResult result = taskApp.getResult(taskApp.getFirstModelGenerator(), activeAlg);
                if ((result != null) && !result.canBeRecomputed()) {
                    return false;
                }
                return taskApp.hasComputableScript() && !taskApp.getDemonstration().isInvalid();
            }
            return project.getDefaultAlgo() == SNIFACTPredictionAlgo.ONLY;
        }
    };
    hasComputedResultPredicate = new ProjectSelectionPredicate(project) {

        @Override
        protected boolean isSatisfiedBy(Design design, AUndertaking t) {
            TaskApplication taskApp = project.getTaskApplication(t, design);
            return ((taskApp != null) && taskApp.hasComputedResult());
        }
    };
    hasResultStepsPredicate = new ProjectSelectionPredicate(project) {

        @Override
        protected boolean isSatisfiedBy(Design design, AUndertaking t) {
            TaskApplication taskApp = project.getTaskApplication(t, design);
            return (taskApp != null) && taskApp.hasResultSteps();
        }
    };
    hasScriptsPredicate = new ProjectSelectionPredicate(project) {

        @Override
        protected boolean isSatisfiedBy(Design design, AUndertaking t) {
            TaskApplication taskApp = project.getTaskApplication(t, design);
            return (taskApp != null) && taskApp.hasScript();
        }
    };
    hasTracesPredicate = new ProjectSelectionPredicate(project) {

        @Override
        protected boolean isSatisfiedBy(Design design, AUndertaking t) {
            TaskApplication taskApp = project.getTaskApplication(t, design);
            return (taskApp != null) && taskApp.hasResultTraces();
        }
    };
    hasMultipleScriptsPredicate = new ProjectSelectionPredicate(project) {

        protected int numScripts = 0;

        @Override
        protected void resetState() {
            numScripts = 0;
        }

        @Override
        protected boolean isSatisfiedBy(Design design, AUndertaking t) {
            TaskApplication taskApp = project.getTaskApplication(t, design);
            if (taskApp != null) {
                Iterator<CognitiveModelGenerator> modelGens = taskApp.getModelGenerators();
                while (modelGens.hasNext()) {
                    CognitiveModelGenerator modelGen = modelGens.next();
                    Script script = taskApp.getScript(modelGen);
                    if (script != null) {
                        if (++numScripts > 1) {
                            return true;
                        }
                    }
                }
            }
            return false;
        }
    };
}
Also used : Design(edu.cmu.cs.hcii.cogtool.model.Design) Script(edu.cmu.cs.hcii.cogtool.model.Script) IPredictionAlgo(edu.cmu.cs.hcii.cogtool.model.IPredictionAlgo) AUndertaking(edu.cmu.cs.hcii.cogtool.model.AUndertaking) Iterator(java.util.Iterator) APredictionResult(edu.cmu.cs.hcii.cogtool.model.APredictionResult) TaskApplication(edu.cmu.cs.hcii.cogtool.model.TaskApplication) CognitiveModelGenerator(edu.cmu.cs.hcii.cogtool.model.CognitiveModelGenerator) Demonstration(edu.cmu.cs.hcii.cogtool.model.Demonstration) ProjectSelectionPredicate(edu.cmu.cs.hcii.cogtool.ui.ProjectSelectionState.ProjectSelectionPredicate) Point(org.eclipse.swt.graphics.Point)

Example 4 with Design

use of edu.cmu.cs.hcii.cogtool.model.Design in project cogtool by cogtool.

the class ProjectController method createOpenDictionaryAction.

protected IListenerAction createOpenDictionaryAction() {
    return new IListenerAction() {

        public Class<?> getParameterClass() {
            return ProjectSelectionState.class;
        }

        public boolean performAction(Object prms) {
            ProjectSelectionState seln = (ProjectSelectionState) prms;
            Design design = seln.getSelectedDesign();
            if (design != null) {
                openDictionaryEditor(design);
            }
            return true;
        }
    };
}
Also used : Design(edu.cmu.cs.hcii.cogtool.model.Design) ITaskDesign(edu.cmu.cs.hcii.cogtool.model.Project.ITaskDesign) IListenerAction(edu.cmu.cs.hcii.cogtool.util.IListenerAction) ProjectSelectionState(edu.cmu.cs.hcii.cogtool.ui.ProjectSelectionState)

Example 5 with Design

use of edu.cmu.cs.hcii.cogtool.model.Design in project cogtool by cogtool.

the class ProjectController method createDuplicateDesignAction.

protected IListenerAction createDuplicateDesignAction() {
    return new IListenerAction() {

        public Class<?> getParameterClass() {
            return DesignSelectionState.class;
        }

        public boolean performAction(Object prms) {
            DesignSelectionState seln = (DesignSelectionState) prms;
            Design design = seln.getSelectedDesign();
            // Can only duplicate if a design is currently selected.
            if (design == null) {
                interaction.protestNoSelection();
                return false;
            }
            // Determine new name
            String copyName = NamedObjectUtil.makeNameUnique(design.getName(), project.getDesigns());
            Design designCopy = design.duplicate(copyName);
            ISimilarityDictionary dict = (ISimilarityDictionary) design.getAttribute(WidgetAttributes.DICTIONARY_ATTR);
            if (!NullSafe.equals(dict, WidgetAttributes.NO_DICTIONARY)) {
                designCopy.setAttribute(WidgetAttributes.DICTIONARY_ATTR, dict.duplicate());
            }
            ProjectCmd.addNewDesign(project, designCopy, seln.getSelectedDesign(), DUPLICATE_DESIGN, undoMgr);
            Map<ITaskDesign, TaskApplication> associatedTAs = project.taskApplicationsForDesign(design);
            duplicateTaskApplications(designCopy, associatedTAs);
            return true;
        }
    };
}
Also used : Design(edu.cmu.cs.hcii.cogtool.model.Design) ITaskDesign(edu.cmu.cs.hcii.cogtool.model.Project.ITaskDesign) ITaskDesign(edu.cmu.cs.hcii.cogtool.model.Project.ITaskDesign) IListenerAction(edu.cmu.cs.hcii.cogtool.util.IListenerAction) TaskApplication(edu.cmu.cs.hcii.cogtool.model.TaskApplication) ISimilarityDictionary(edu.cmu.cs.hcii.cogtool.model.ISimilarityDictionary) DesignSelectionState(edu.cmu.cs.hcii.cogtool.ui.DesignSelectionState)

Aggregations

Design (edu.cmu.cs.hcii.cogtool.model.Design)64 ITaskDesign (edu.cmu.cs.hcii.cogtool.model.Project.ITaskDesign)42 IListenerAction (edu.cmu.cs.hcii.cogtool.util.IListenerAction)29 AUndertaking (edu.cmu.cs.hcii.cogtool.model.AUndertaking)28 TaskApplication (edu.cmu.cs.hcii.cogtool.model.TaskApplication)21 ProjectSelectionState (edu.cmu.cs.hcii.cogtool.ui.ProjectSelectionState)20 IOException (java.io.IOException)12 Script (edu.cmu.cs.hcii.cogtool.model.Script)10 TaskGroup (edu.cmu.cs.hcii.cogtool.model.TaskGroup)10 DoublePoint (edu.cmu.cs.hcii.cogtool.model.DoublePoint)9 DesignSelectionState (edu.cmu.cs.hcii.cogtool.ui.DesignSelectionState)9 RcvrIOException (edu.cmu.cs.hcii.cogtool.util.RcvrIOException)9 Demonstration (edu.cmu.cs.hcii.cogtool.model.Demonstration)7 IPredictionAlgo (edu.cmu.cs.hcii.cogtool.model.IPredictionAlgo)7 AUndoableEdit (edu.cmu.cs.hcii.cogtool.util.AUndoableEdit)7 File (java.io.File)7 Iterator (java.util.Iterator)7 Point (org.eclipse.swt.graphics.Point)7 CompoundUndoableEdit (edu.cmu.cs.hcii.cogtool.util.CompoundUndoableEdit)6 ISimilarityDictionary (edu.cmu.cs.hcii.cogtool.model.ISimilarityDictionary)5