/** * Open a dialog to edit the target. * * @param e The event. */ public void actionPerformed(ActionEvent e) { try { // Determine which entity was selected for the look inside action. super.actionPerformed(e); NamedObj target = getTarget(); if (target == null) { return; } // Create a dialog for configuring the object. // First, identify the top parent frame. Frame parent = getFrame(); openDialog(parent, target); } catch (Throwable throwable) { // Giotto code generator on giotto/demo/Hierarchy/Hierarchy.xml // was throwing an exception here that was not being displayed // in the UI. MessageHandler.error("Failed to open a dialog to edit the target.", throwable); } }
/** * Process the edit icon command. * * @param e The event. */ public void actionPerformed(ActionEvent e) { if (_configuration == null) { MessageHandler.error("Cannot edit icon without a configuration."); return; } // Determine which entity was selected for the action. super.actionPerformed(e); final NamedObj object = getTarget(); // Do this as a change request since it may add a new icon. ChangeRequest request = new ChangeRequest(this, "Edit Custom Icon") { protected void _execute() throws Exception { EditorIcon icon = null; List iconList = object.attributeList(EditorIcon.class); if (iconList.size() > 0) { // Get the last icon. icon = (EditorIcon) iconList.get(iconList.size() - 1); } if (icon == null) { icon = new EditorIcon(object, "_icon"); } else if (icon instanceof XMLIcon) { // There is an icon currently that is not custom. // Without trashing the _iconDescription, we can remove // this icon and replace it. icon.setContainer(null); icon = new EditorIcon(object, "_icon"); // Propagate this to derived objects, being // careful to not trash their custom icons // if they have them. However, there is a trickiness. // They may not have a custom icon, but rather have // an instance of XMLIcon. We have to remove that // first. Iterator derivedObjects = object.getDerivedList().iterator(); while (derivedObjects.hasNext()) { NamedObj derived = (NamedObj) derivedObjects.next(); // See whether it has an icon. EditorIcon derivedIcon = null; List derivedIconList = derived.attributeList(EditorIcon.class); if (derivedIconList.size() > 0) { // Get the last icon. derivedIcon = (EditorIcon) derivedIconList.get(derivedIconList.size() - 1); } if (derivedIcon instanceof XMLIcon) { // There is an icon currently that is not custom. // Without trashing the _iconDescription, we can // remove // this icon and replace it. derivedIcon.setContainer(null); } } // Now it is safe to propagate. icon.propagateExistence(); } _configuration.openModel(icon); } }; object.requestChange(request); }