/** * Make all tableaux associated with this effigy and any effigies it contains visible by raising * or deiconifying them. If there is no tableau contained directly by this effigy, then create one * by calling createPrimaryTableau() in the configuration. * * @return The first tableau encountered, or a new one if there are none. */ public Tableau showTableaux() { Iterator effigies = entityList(Effigy.class).iterator(); while (effigies.hasNext()) { Effigy effigy = (Effigy) effigies.next(); effigy.showTableaux(); } Iterator tableaux = entityList(Tableau.class).iterator(); Tableau result = null; while (tableaux.hasNext()) { Tableau tableau = (Tableau) tableaux.next(); tableau.show(); if (result == null) { result = tableau; } } if (result == null) { // Create a new tableau. Configuration configuration = (Configuration) toplevel(); result = configuration.createPrimaryTableau(this); } return result; }
/** * Create a tableau for the specified effigy. The tableau will be created with a new unique name * with the specified effigy as its container. * * @param effigy The model effigy. * @return A tableau for the effigy, or null if one cannot be created. * @exception Exception If the factory should be able to create a Tableau for the effigy, but * something goes wrong. */ @Override public Tableau createTableau(Effigy effigy) throws Exception { Configuration configuration = (Configuration) effigy.toplevel(); TDLModule model = (TDLModule) ((PtolemyEffigy) effigy).getModel(); FSMActor controller = ((TDLModuleDirector) model.getDirector()).getController(); return configuration.openModel(controller); }
/** * Close the given tableau when the Java GUI thread is not busy. * * @param tableau The tableau to be closed. */ public static void closeTableau(final Tableau tableau) { Effigy effigy = (Effigy) tableau.getContainer(); if (effigy != null) { try { effigy.setContainer(null); } catch (KernelException e) { // Ignore if we can't remove the effigy from its // container. } } if (effigy instanceof PtolemyEffigy) { PtolemyEffigy ptolemyEffigy = (PtolemyEffigy) effigy; ptolemyEffigy.setModel(null); } SwingUtilities.invokeLater( new Runnable() { @Override public void run() { tableau.close(); } }); }
/** * Close all tableaux contained by this effigy, and by any effigies it contains. * * @return False if the user cancels on a save query, and true if all tableaux are successfully * closed. */ public boolean closeTableaux() { Iterator effigies = entityList(Effigy.class).iterator(); while (effigies.hasNext()) { Effigy effigy = (Effigy) effigies.next(); if (!effigy.closeTableaux()) { return false; } } Iterator tableaux = entityList(Tableau.class).iterator(); while (tableaux.hasNext()) { Tableau tableau = (Tableau) tableaux.next(); if (!tableau.close()) { return false; } } return true; }
/** * If the argument is the <i>uri</i> parameter, then read the specified URL and parse the data * contained in it. * * @param attribute The attribute that changed. * @exception IllegalActionException If the URL cannot be read or if the data is malformed. */ public void attributeChanged(Attribute attribute) throws IllegalActionException { // The superclass does some handling of the url attribute. super.attributeChanged(attribute); if (attribute == uri) { try { URL urlToRead = uri.getURL(); if (urlToRead != null) { read(urlToRead); } } catch (IOException ex) { throw new IllegalActionException(this, null, ex, "Failed to read data: " + ex.getMessage()); } } }
/** * Create an instance of CaseGraphTableau for the specified effigy, if it is an effigy for an * instance of FSMActor. * * @param effigy The effigy for an FSMActor. * @return A new CaseGraphTableau, if the effigy is a PtolemyEffigy that references an FSMActor, * or null otherwise. * @exception Exception If an exception occurs when creating the tableau. */ public Tableau createTableau(Effigy effigy) throws Exception { if (!(effigy instanceof PtolemyEffigy)) { return null; } NamedObj model = ((PtolemyEffigy) effigy).getModel(); if (model instanceof Case) { // Check to see whether this factory contains a // default library. LibraryAttribute library = (LibraryAttribute) getAttribute("_library", LibraryAttribute.class); CaseGraphTableau tableau = new CaseGraphTableau((PtolemyEffigy) effigy, effigy.uniqueName("tableau"), library); return tableau; } else { return null; } }
/** * Find the effigy associated with the top level of the object, and if not found but the top level * has a ContainmentExtender attribute, use that attribute to find the containment extender of the * top level and continue the search. * * @param object The object. * @return The effigy, or null if not found. * @exception IllegalActionException If attributes cannot be retrieved, or the container that an * attribute points to is invalid. * @deprecated Use ptolemy.actor.gui.Effigy.findToplevelEffigy() instead */ public static Effigy findToplevelEffigy(NamedObj object) throws IllegalActionException { // actor.lib.hoc.ExecuteActor was calling this method in // ptera.EventUtils, which meant that hoc depended on ptera. return Effigy.findToplevelEffigy(object); }