Search in sources :

Example 6 with Interaction

use of edu.cmu.cs.hcii.cogtool.ui.Interaction in project cogtool by cogtool.

the class DesignCmd method addDevices.

public static boolean addDevices(Project project, Design design, Interaction interaction) {
    Interaction.DesignRequestData requestData = requestAddDevices(project, design, interaction);
    if (requestData == null) {
        // canceled!
        return false;
    }
    Set<DeviceType> existingDevices = design.addDeviceTypes(requestData.deviceTypes);
    if (requestData.deviceTypes.equals(existingDevices)) {
        // nothing to do
        return true;
    }
    Iterator<DeviceType> addDevices = requestData.deviceTypes.iterator();
    while (addDevices.hasNext()) {
        DeviceType devType = addDevices.next();
        addDevice(design, devType, existingDevices);
    }
    return true;
}
Also used : DeviceType(edu.cmu.cs.hcii.cogtool.model.DeviceType) Interaction(edu.cmu.cs.hcii.cogtool.ui.Interaction)

Example 7 with Interaction

use of edu.cmu.cs.hcii.cogtool.ui.Interaction in project cogtool by cogtool.

the class Controller method assignActions.

/**
     * Registers the set of <code>IListenerAction</code> instances
     * that implement the semantic actions that are possible.
     * <p>
     * For this class, this consists of the actions that all windows support.
     *
     * @author mlh
     */
protected void assignActions() {
    UI ui = getUI();
    if (ui != null) {
        ui.setAction(CogToolLID.About, ui.popAboutBox());
        // Set "open" action
        ui.setAction(CogToolLID.OpenProject, new AListenerAction() {

            public boolean performAction(Object prms) {
                // open expects null in that case.
                if (!(prms instanceof DoublePoint)) {
                    prms = null;
                }
                // Ask the user to select a CogTool project to open
                File[] openLocs = getUI().getStandardInteraction().selectFileSources();
                return open((DoublePoint) prms, openLocs);
            }
        });
        ui.setAction(CogToolLID.OpenProjectFile, new IListenerAction() {

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

            public boolean performAction(Object actionParms) {
                File[] openLoc = { new File((String) actionParms) };
                return open(null, openLoc);
            }
        });
        // Set "new project" action
        ui.setAction(CogToolLID.NewProject, createNewProjectAction());
        // Set "quit/exit" action
        ui.setAction(CogToolLID.ExitApplication, createExitAction());
        ui.setAction(CogToolLID.ClearRecent, new AListenerAction() {

            public boolean performAction(Object actionParms) {
                CogToolPref.clearRecent();
                Interaction interaction = getUI().getStandardInteraction();
                interaction.setStatusMessage(L10N.get("AC.RecentClear", "Recent file data cleared."));
                return true;
            }
        });
    }
}
Also used : UI(edu.cmu.cs.hcii.cogtool.ui.UI) IListenerAction(edu.cmu.cs.hcii.cogtool.util.IListenerAction) Interaction(edu.cmu.cs.hcii.cogtool.ui.Interaction) AListenerAction(edu.cmu.cs.hcii.cogtool.util.AListenerAction) DoublePoint(edu.cmu.cs.hcii.cogtool.model.DoublePoint) File(java.io.File)

Aggregations

Interaction (edu.cmu.cs.hcii.cogtool.ui.Interaction)7 UI (edu.cmu.cs.hcii.cogtool.ui.UI)3 DoublePoint (edu.cmu.cs.hcii.cogtool.model.DoublePoint)2 AListenerAction (edu.cmu.cs.hcii.cogtool.util.AListenerAction)2 IListenerAction (edu.cmu.cs.hcii.cogtool.util.IListenerAction)2 File (java.io.File)2 IOException (java.io.IOException)2 DeviceType (edu.cmu.cs.hcii.cogtool.model.DeviceType)1 Project (edu.cmu.cs.hcii.cogtool.model.Project)1 GraphicsUtil (edu.cmu.cs.hcii.cogtool.util.GraphicsUtil)1 RcvrCannotUndoRedoException (edu.cmu.cs.hcii.cogtool.util.RcvrCannotUndoRedoException)1 RcvrIOException (edu.cmu.cs.hcii.cogtool.util.RcvrIOException)1 RcvrIOLoadException (edu.cmu.cs.hcii.cogtool.util.RcvrIOLoadException)1 RcvrIOSaveException (edu.cmu.cs.hcii.cogtool.util.RcvrIOSaveException)1 RcvrImageException (edu.cmu.cs.hcii.cogtool.util.RcvrImageException)1