Copyright (C) 2000, Geert Vernaeve. All Rights Reserved.
package gve.calc.packaging; import gve.calc.formula.*;
This class describes a Part subclass.
public abstract class PartDescriptor { // Name of the class this object describes. // Should not include the package name (so "Matrix" and // not "blah.bleh.math.Matrix") public String name;
When set to true, the stack window adds an entry named "New " to the "Insert" menu. When the user activates that entry, the generateNew() method is called.
public boolean isTerminal = false; public PartDescriptor(String name) { this.name = name; }
This method should generate a new object of the given Part subclass. Next, it should replace the dummy in the formula by calling view.getFormula().replace(dummy,xxx) where xxx is the freshly created object. If you want, you can then position the cursor at a convenient place in the formula (e.g. see the Matrix PartDescriptor).
public void generateNew(Part dummy,FormulaView view) { Formula f = view.getFormula(); f.replace(dummy,genNew()); }
A simpler version of generateNew() where we don't need to position the cursor. This is often the case, because after generateNew(), the fresh part's cursor is activated
public Part genNew() { return null; } }