Search in sources :

Example 6 with DesignSelectionState

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

the class ProjectController method createEditDesignAction.

// interactToRenameTask
// Action for EditDesign
protected IListenerAction createEditDesignAction() {
    return new IListenerAction() {

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

        public boolean performAction(Object prms) {
            DesignSelectionState selection = (DesignSelectionState) prms;
            //                FrameUIModel.LoadingTime = 0;
            //                long start = System.currentTimeMillis();
            //                System.out.println("\nEditDesign:" + start + " { ");
            Design selectedDesign = selection.getSelectedDesign();
            // Can only edit a selected design.
            if (selectedDesign != null) {
                // Open or create a window for the selected design
                DesignEditorController.openController(selectedDesign, project);
                return true;
            }
            interaction.protestNoSelection();
            return false;
        }
    };
}
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) DesignSelectionState(edu.cmu.cs.hcii.cogtool.ui.DesignSelectionState)

Example 7 with DesignSelectionState

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

the class ProjectController method createDeleteDesignAction.

// createInitiateTaskRenameAction
// Action for DeleteDesign
protected IListenerAction createDeleteDesignAction() {
    return new IListenerAction() {

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

        public boolean performAction(Object prms) {
            DesignSelectionState selection = (DesignSelectionState) prms;
            Design selectedDesign = selection.getSelectedDesign();
            // Can only delete if a design is currently selected.
            if (selectedDesign != null) {
                if (interaction.confirmDeleteDesign(selectedDesign)) {
                    // Delete selected design, without copying
                    // to the clipboard.
                    deleteDesign(selectedDesign, null);
                    return true;
                }
            } else {
                interaction.protestNoSelection();
            }
            return false;
        }
    };
}
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) DesignSelectionState(edu.cmu.cs.hcii.cogtool.ui.DesignSelectionState)

Example 8 with DesignSelectionState

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

the class ProjectController method createAddDesignDevicesAction.

// createNewDesignAction2
protected IListenerAction createAddDesignDevicesAction() {
    return new IListenerAction() {

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

        public boolean performAction(Object prms) {
            DesignSelectionState selection = (DesignSelectionState) prms;
            Design design = selection.getSelectedDesign();
            if (design != null) {
                return DesignCmd.addDevices(project, design, interaction);
            }
            interaction.protestNoSelection();
            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) DesignSelectionState(edu.cmu.cs.hcii.cogtool.ui.DesignSelectionState)

Example 9 with DesignSelectionState

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

the class ProjectController method createCopyDesignAction.

// Action for CopyDesign
protected IListenerAction createCopyDesignAction() {
    return new IListenerAction() {

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

        public boolean performAction(Object prms) {
            DesignSelectionState seln = (DesignSelectionState) prms;
            Design design = seln.getSelectedDesign();
            // Can only copy if a design is currently selected.
            if (design != null) {
                try {
                    ObjectSaver s = CogToolClipboard.startClipboardDesignSave(project, CogToolClipboard.SAVE_TO_CLIPBOARD);
                    saveDesignToClipboard(design, s);
                    s.finish();
                    interaction.setStatusMessage(DESIGN_COPIED);
                    return true;
                } catch (IOException e) {
                    throw new RcvrClipboardException(e);
                } catch (OutOfMemoryError error) {
                    throw new RcvrOutOfMemoryException("Copying Design", error);
                }
            } else {
                interaction.protestNoSelection();
            }
            return false;
        }
    };
}
Also used : Design(edu.cmu.cs.hcii.cogtool.model.Design) ITaskDesign(edu.cmu.cs.hcii.cogtool.model.Project.ITaskDesign) ObjectSaver(edu.cmu.cs.hcii.cogtool.util.ObjectSaver) IListenerAction(edu.cmu.cs.hcii.cogtool.util.IListenerAction) RcvrOutOfMemoryException(edu.cmu.cs.hcii.cogtool.util.RcvrOutOfMemoryException) RcvrClipboardException(edu.cmu.cs.hcii.cogtool.util.RcvrClipboardException) IOException(java.io.IOException) RcvrIOException(edu.cmu.cs.hcii.cogtool.util.RcvrIOException) DesignSelectionState(edu.cmu.cs.hcii.cogtool.ui.DesignSelectionState)

Example 10 with DesignSelectionState

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

the class ProjectController method createImportWebCrawlAction.

protected IListenerAction createImportWebCrawlAction() {
    return new IListenerAction() {

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

        public boolean performAction(Object prms) {
            DesignSelectionState selection = (DesignSelectionState) prms;
            ProjectInteraction.IWebCrawlImport importParms = interaction.requestWebCrawlParms(project, WebCrawler.DEFAULT_MAX_TO_CRAWL);
            if (importParms != null) {
                String designName = importParms.getDesignName();
                Design design;
                if (designName == null) {
                    ProjectInteraction.DesignRequestData requestData = requestNewDesignParms(false);
                    if (requestData == null) {
                        // canceled!
                        return false;
                    }
                    design = new Design(requestData.designName, requestData.deviceTypes);
                } else {
                    design = project.getDesign(designName);
                }
                int defaultDepth = importParms.getDefaultDepth();
                List<URLCrawlEntry> urls = importParms.getURLsToCrawl();
                if ((urls == null) || (urls.size() == 0)) {
                    interaction.reportProblem(ImportWebCrawlThread.IMPORT_WEB_CRAWL, noURLsToCrawlError);
                    return false;
                }
                // If new, indicate that the work thread should add the
                // new design to the project when it completes;
                // -1 indicates that the design is *not* new.
                int beforeIndex = ImportWebCrawlThread.EXISTING_DESIGN;
                if (designName == null) {
                    Design selectedDesign = selection.getSelectedDesign();
                    beforeIndex = (selectedDesign != null) ? (project.getDesigns().indexOf(selectedDesign) + 1) : project.getDesigns().size();
                }
                ImportWebCrawlThread workThread = new ImportWebCrawlThread(interaction, undoMgr, project, design, beforeIndex, importParms.getMaxPages(), defaultDepth, urls, importParms.pruneSameURLs(), importParms.getBrowserWidth(), importParms.getBrowserHeight(), importParms.captureImages());
                ThreadManager.startNewThread(workThread);
                return true;
            }
            return false;
        }
    };
}
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) URLCrawlEntry(edu.cmu.cs.hcii.cogtool.model.URLCrawlEntry) ProjectInteraction(edu.cmu.cs.hcii.cogtool.ui.ProjectInteraction) DesignSelectionState(edu.cmu.cs.hcii.cogtool.ui.DesignSelectionState) DoublePoint(edu.cmu.cs.hcii.cogtool.model.DoublePoint)

Aggregations

DesignSelectionState (edu.cmu.cs.hcii.cogtool.ui.DesignSelectionState)10 Design (edu.cmu.cs.hcii.cogtool.model.Design)9 ITaskDesign (edu.cmu.cs.hcii.cogtool.model.Project.ITaskDesign)9 IListenerAction (edu.cmu.cs.hcii.cogtool.util.IListenerAction)9 ProjectInteraction (edu.cmu.cs.hcii.cogtool.ui.ProjectInteraction)3 ObjectSaver (edu.cmu.cs.hcii.cogtool.util.ObjectSaver)2 RcvrClipboardException (edu.cmu.cs.hcii.cogtool.util.RcvrClipboardException)2 RcvrIOException (edu.cmu.cs.hcii.cogtool.util.RcvrIOException)2 RcvrOutOfMemoryException (edu.cmu.cs.hcii.cogtool.util.RcvrOutOfMemoryException)2 IOException (java.io.IOException)2 DeviceType (edu.cmu.cs.hcii.cogtool.model.DeviceType)1 DoublePoint (edu.cmu.cs.hcii.cogtool.model.DoublePoint)1 ISimilarityDictionary (edu.cmu.cs.hcii.cogtool.model.ISimilarityDictionary)1 ImportConverter (edu.cmu.cs.hcii.cogtool.model.ImportConverter)1 TaskApplication (edu.cmu.cs.hcii.cogtool.model.TaskApplication)1 URLCrawlEntry (edu.cmu.cs.hcii.cogtool.model.URLCrawlEntry)1 RcvrImportException (edu.cmu.cs.hcii.cogtool.util.RcvrImportException)1 File (java.io.File)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1