Search in sources :

Example 1 with GenericFileFilter

use of maspack.util.GenericFileFilter in project artisynth_core by artisynth.

the class MenuBarHandler method actionPerformed.

/**
 * action performed to process all the menu and button actions in this class
 */
public void actionPerformed(ActionEvent event) {
    String cmd = event.getActionCommand();
    // Scripts menu
    if (isScriptMenuItem(event.getSource())) {
        String scriptName = myMain.getScriptName(cmd);
        runScript(scriptName);
    } else if (cmd.equals("load script from file")) {
        JFileChooser fileChooser = new JFileChooser();
        fileChooser.setCurrentDirectory(ArtisynthPath.getWorkingDir());
        FileFilter jythonFilter = new GenericFileFilter(new String[] { "py", "jy" }, "Jython files");
        fileChooser.addChoosableFileFilter(jythonFilter);
        fileChooser.setFileFilter(jythonFilter);
        int result = fileChooser.showOpenDialog(myFrame);
        if (result == JFileChooser.APPROVE_OPTION) {
            File selectedFile = fileChooser.getSelectedFile();
            runScript(selectedFile.getAbsolutePath());
        }
    } else // 
    if (myMain.isDemoClassName(cmd)) {
        ModelInfo mi = new ModelInfo(myMain.getDemoClassName(cmd), cmd, null);
        doLoadModelSafely(mi);
    } else // 
    if (cmd.equals("Clear model")) {
        doClearModel();
    } else if (cmd.equals("New blank MechModel")) {
        doBlankMechmodel();
    } else if (cmd.equals("Save model")) {
        doSaveModel();
    } else if (cmd.equals("Save model as ...")) {
        doSaveModelAs();
    } else if (cmd.equals("Reload model")) {
        doReloadModel();
    } else if (cmd.equals("Load model ...")) {
        doLoadModel();
    } else if (cmd.equals("Load from class ...")) {
        doLoadFromClass();
    } else if (cmd.equals("Switch workspace ...")) {
        doSwitchWorkspace();
    } else if (cmd.equals("Open MATLAB connection")) {
        doOpenMatlab();
    } else if (cmd.equals("Close MATLAB connection")) {
        doCloseMatlab();
    } else if (cmd.equals("Load probes ...")) {
        doLoadProbes();
    } else if (cmd.equals("Save probes")) {
        doSaveProbes();
    } else if (cmd.equals("Save probes as ...")) {
        doSaveProbesAs();
    } else if (cmd.equals("Load probes from ...")) {
        newLoadProbesFrom();
    } else if (cmd.equals("Save probes new")) {
        newSaveProbes();
    } else if (cmd.equals("Save probes in ...")) {
        newSaveProbesIn();
    } else if (cmd.equals("Save viewer image ...")) {
        saveViewerImage();
    } else if (cmd.equals("Quit")) {
        myMain.quit();
    } else // 
    if (cmd.equals("Add input probe")) {
        doAddInputProbe();
    } else if (cmd.equals("Add output probe")) {
        doAddOutputProbe();
    } else if (cmd.equals("Add control panel")) {
        doAddControlPanel();
    } else if (cmd.equals("Load control panel")) {
        doLoadControlPanel();
    } else if (cmd.equals("Print selection")) {
        SelectionManager sm = myMain.getSelectionManager();
        for (ModelComponent c : sm.getCurrentSelection()) {
            System.out.println(ComponentUtils.getPathName(c));
        }
    } else if (cmd.equals("Undo")) {
        doUndoCommand();
    } else // 
    if (cmd.equals("Background color")) {
        setBackgroundColor();
    } else if (cmd.equals("Selection color")) {
        setSelectionColor();
    } else if (cmd.equals("Enable selection highlighting")) {
        setSelectionColorEnabled(true);
    } else if (cmd.equals("Disable selection highlighting")) {
        setSelectionColorEnabled(false);
    } else if (cmd.equals("Visual display rate")) {
        setVisualDisplayRate();
    } else if (cmd.equals("Real-time scaling")) {
        setRealTimeScaling();
    } else if (cmd.equals("Mouse Preferences ...")) {
        openMouseSettingsDialog();
    } else if (cmd.equals("Init draggers in world coords")) {
        myMain.setInitDraggersInWorldCoords(true);
    } else if (cmd.equals("Init draggers in local coords")) {
        myMain.setInitDraggersInWorldCoords(false);
    } else if (cmd.equals("Enable articulated transforms")) {
        myMain.setArticulatedTransformsEnabled(true);
    } else if (cmd.equals("Disable articulated transforms")) {
        myMain.setArticulatedTransformsEnabled(false);
    } else // }
    if (cmd.equals("PullController properties ...")) {
        showPullControllerPropertyDialog();
    } else if (cmd.equals("PullController render props ...")) {
        showPullControllerRenderPropsDialog();
    } else // 
    if (cmd.equals("Center view on selection")) {
        myMain.centerViewOnSelection();
    } else if (cmd.equals("Hide timeline")) {
        myMain.setTimelineVisible(false);
        isTimelineVisible = false;
    } else if (cmd.equals("Show timeline")) {
        myMain.setTimelineVisible(true);
        isTimelineVisible = true;
    } else if (cmd.equals("Reset view")) {
        GLViewer v = myMain.getViewer();
        v.setAxialView(v.getAxialView());
        v.autoFit();
    } else if (cmd.equals("Perspective view")) {
        myMain.getViewer().setOrthographicView(false);
    } else if (cmd.equals("Orthographic view")) {
        myMain.getViewer().setOrthographicView(true);
    } else if (cmd.equals("Hide Jython console")) {
        setJythonConsoleVisible(false);
    } else if (cmd.equals("Show Jython console")) {
        setJythonConsoleVisible(true);
    } else if (cmd.equals("Show Inverse panel")) {
        myMain.getInverseManager().showInversePanel(myMain.getRootModel(), InverseManager.findInverseController());
    } else if (cmd.equals("Hide Inverse panel")) {
        myMain.getInverseManager().hideInversePanel();
    } else if (cmd.equals("Show movie panel")) {
        myFrame.getMain().getViewer().getCanvas().display();
        myMain.getMovieMaker().showDialog(myFrame);
    } else if (cmd.equals("Hide movie panel")) {
        // TODO: this isn't implemented yet because we need to set
        // this up as an action
        myMain.getMovieMaker().closeDialog();
    } else if (cmd.equals("Show empty components in navpanel")) {
        myFrame.getNavPanel().setHideEmptyComponents(false);
    } else if (cmd.equals("Hide empty components in navpanel")) {
        myFrame.getNavPanel().setHideEmptyComponents(true);
    } else if (cmd.equals("New viewer")) {
        myMain.createViewerFrame();
    } else if (cmd.equals("Clear traces")) {
        myMain.getRootModel().clearTraces();
    } else if (cmd.equals("Disable all tracing")) {
        myMain.getRootModel().disableAllTracing();
    } else if (cmd.equals("Remove traces")) {
        RemoveComponentsCommand rmCmd = new RemoveComponentsCommand("remove traces", myMain.getRootModel().getTracingProbes());
        myMain.getUndoManager().saveStateAndExecute(rmCmd);
        myMain.rerender();
    } else if (cmd.equals("Set traces visible")) {
        myMain.getRootModel().setTracingProbesVisible(true);
        myMain.rerender();
    } else if (cmd.equals("Set traces invisible")) {
        myMain.getRootModel().setTracingProbesVisible(false);
        myMain.rerender();
    } else if (cmd.equals("Hide viewer toolbar")) {
        isToolbarVisible = false;
        detachViewerToolbar(toolbarPanel);
    } else if (cmd.equals("Show viewer toolbar")) {
        isToolbarVisible = true;
        attachViewerToolbar(toolbarPanel);
    } else if (cmd.equals("Merge control panels")) {
        myMain.getRootModel().mergeAllControlPanels(true);
    } else if (cmd.equals("Separate control panels")) {
        myMain.getRootModel().mergeAllControlPanels(false);
    } else if (cmd.equals("Show progress")) {
        spawnProgressBar();
    } else // 
    if (cmd.equals("About ArtiSynth")) {
        myFrame.displayAboutArtisynth();
    } else if (cmd.equals("About the current model")) {
        myFrame.displayAboutModel(myMain.getRootModel());
    } else if (cmd.equals("Keybindings")) {
        myFrame.displayKeybindings();
    } else // 
    if (cmd.equals("Hide NavBar")) {
        myFrame.getNavPanel().setStatus(!myFrame.getNavPanel().getStatus());
        myFrame.refreshSplitPane();
        navBarButton.setToolTipText("Show Navbar");
        navBarButton.setActionCommand("Show Navbar");
    } else if (cmd.equals("Show Navbar")) {
        myFrame.getNavPanel().setStatus(!myFrame.getNavPanel().getStatus());
        myFrame.refreshSplitPane();
        navBarButton.setToolTipText("Hide NavBar");
        navBarButton.setActionCommand("Hide NavBar");
    } else if (cmd.equals("Re-render")) {
        myMain.rerender();
    } else if (cmd.equals("Reset")) {
        myMain.getScheduler().reset();
    } else if (cmd.equals("Rewind")) {
        myMain.getScheduler().rewind();
    } else if (cmd.equals("Play")) {
        myMain.getScheduler().play();
    } else if (cmd.equals("Pause")) {
        myMain.getScheduler().pause();
    } else if (cmd.equals("Single step")) {
        myMain.getScheduler().step();
    } else if (cmd.equals("Fast forward")) {
        myMain.getScheduler().fastForward();
    } else if (cmd.equals("cancel")) {
        return;
    } else {
        throw new InternalErrorException("Unimplemented command: " + cmd);
    }
}
Also used : SelectionManager(artisynth.core.gui.selectionManager.SelectionManager) GLViewer(maspack.render.GL.GLViewer) JFileChooser(javax.swing.JFileChooser) ModelComponent(artisynth.core.modelbase.ModelComponent) RemoveComponentsCommand(artisynth.core.gui.editorManager.RemoveComponentsCommand) GenericFileFilter(maspack.util.GenericFileFilter) InternalErrorException(maspack.util.InternalErrorException) ExtensionFileFilter(artisynth.core.util.ExtensionFileFilter) GenericFileFilter(maspack.util.GenericFileFilter) FileFilter(javax.swing.filechooser.FileFilter) File(java.io.File)

Aggregations

RemoveComponentsCommand (artisynth.core.gui.editorManager.RemoveComponentsCommand)1 SelectionManager (artisynth.core.gui.selectionManager.SelectionManager)1 ModelComponent (artisynth.core.modelbase.ModelComponent)1 ExtensionFileFilter (artisynth.core.util.ExtensionFileFilter)1 File (java.io.File)1 JFileChooser (javax.swing.JFileChooser)1 FileFilter (javax.swing.filechooser.FileFilter)1 GLViewer (maspack.render.GL.GLViewer)1 GenericFileFilter (maspack.util.GenericFileFilter)1 InternalErrorException (maspack.util.InternalErrorException)1