/** * Adds a new macro to the parent kernel. */ @Override public void addMacro(Macro macro) { parentKernel.addMacro(macro); }
private void endMacro() { // cons now holds a reference to the macroConstruction macro.initMacro(cons, macroInputLabels, macroOutputLabels); // ad the newly built macro to the kernel origKernel.addMacro(macro); // update construction resets the nearto relations in macro, so "outer // world" won't affect it cons.updateConstruction(true); // set kernel and construction back to the original values initKernelVars(); }
/** * Switches the application to macro editing mode * * @param editMacro * Tool to be edited * @author Zbynek Konecny * @version 2010-05-26 */ public void openMacro(Macro editMacro) { for (int i = 0; i < editMacro.getKernel().getMacroNumber(); i++) { if (editMacro.getKernel().getMacro(i) == editMacro) { break; } kernel.addMacro(editMacro.getKernel().getMacro(i)); } String allXml = getXML(); String header = allXml.substring(0, allXml.indexOf("<construction")); String footer = allXml.substring(allXml.indexOf("</construction>"), allXml.length()); StringBuilder sb = new StringBuilder(); editMacro.getXML(sb); String macroXml = sb.toString(); String newXml = header + macroXml.substring(macroXml.indexOf("<construction"), macroXml.indexOf("</construction>")) + footer; this.macro = editMacro; setXML(newXml, true); }
/** * Will delete all Macros and add all macros in order * * @param macros * the Macros to be added */ public void addMacros(Object[] macros) { // update order of macros: // remove all macros from kernel and add them again in new order Kernel kernel = app.getKernel(); // since all Macros are removed and added back, the Assignments have // also be added again so: // keeping "pointers" on the Assignments in the Exercise to put them // in Place afterwards (the Exercise checks if they are still valid) Exercise ex = app.getKernel().getExercise(); ArrayList<Assignment> assignments = new ArrayList<>( ex.getParts()); kernel.removeAllMacros(); for (Object obj : macros) { kernel.addMacro((Macro) obj); } for (Assignment assignment : assignments) { ex.addAssignment(assignment); } }
kernel.addMacro(newTool);