API specifications of NAB framework June 21, 2006 |
Contents
![]() ![]() |
Chapter 4 Explanations of Implementation Examples (Sample Tools) |
The NAB interface can be called from an Eclipse view (high-level) in a certain operational sequence depending on the toolkit used in NAB Framework. This section explains cases of calling the NAB interface in samples using processing involving the NAB plug-in for MWT.
After processing by NAB Framework begins, toolkit instances such as the window creation process must be created first. NtkManager as shown in this sample must be accessed first by the singleton interface to access the NTK application. Properties belonging to the NTK instance are accessed through the instance management module INtkInstanceManager acquired by NtkManager.getNtkInstanceManager().
//The NTK in the model used by another thread can be locked //by using INtkContext through the context handling module. NtkManager.getNtkContext().lock(); //Instance management module INtkInstanceManager iman = NtkManager.getNtkInstanceManager(); //Creates an instance with the class name specified for the instance and the specified instance name. long inst = iman.getNewInstance(className,windowName,0); if (inst == 0){ //Cannot be created return; } //Sets properties of the created instance. iman.setProperty(inst,"x",0); iman.setProperty(inst,"y",0); iman.setProperty(inst,"width",400); iman.setProperty(inst,"height",400); iman.setupInstance(inst); //Registers the top window instance (as the root parent). NtkManager.getNtkInstanceManager().setInstanceId(Ntk.NTK_SET_ROOT_INSTANCE,inst); //Releases the lock. NtkManager.getNtkContext().unlock();
The following process is used for access to acquire property values of the selected instance among instances arranged in a window, such as when instances in a window are being arranged visually using the editor view after the window is created:
//The NTK in the model used by another thread can be locked //by using INtkContext through the context handling module. INtkContext context = NtkManager.getNtkContext(); context.lock(); //Starts with ROOT_ID at the start of retrieval of the selected instance. long selectedId = Ntk.NTK_ROOT_INSTANCE_ID; INtkInstanceManager iman = NtkManager.getNtkInstanceManager(); while(true){ //Acquires the ID of the next selected instance. long selectedNext = iman.getInstanceId(selectedId, Ntk.NTK_NEXT_SELECTED_INSTANCE_ID, 0); if (selectedNext == 0){ //0 if it does not exist break; } //Starts with ROOT_PROPERTY_ID at the start of acquisition of properties belonging to the instance. long propId = Ntk.NTK_ROOT_PROPERTY_ID; //Acquires the property ID by looping. while(true){ //Acquires the next property ID. long propNextId = iman.getInstanceId(selectedId, Ntk.NTK_NEXT_PROPERTY_ID, propId); if (propNextId == 0){ //0 if it does not exist break; } //Acquires the property name String propName = iman.getInstanceData(propNextId, Ntk.NTK_PROPERTY_NAME, 0,Ntk.NTK_EN_UTF8); //Acquires the property value. String value = iman.getInstanceData(propNextId, Ntk.NTK_PROPERTY_TITLE, 0,Ntk.NTK_EN_UTF8); //Acquires the property type. String propType = iman.getInstanceData(propNextId, Ntk.NTK_PROPERTY_TYPE, 0, Ntk.NTK_EN_UTF8); //Acquires the next property. propId = propNextId; } //Acquires the next instance. selectedId = selectedNext; } context.unlock();
//The NTK in the model used by another thread can be locked //by using INtkContext through the context handling module. INtkContext context = NtkManager.getNtkContext(); context.lock(); //Starts with ROOT_ID at the start of retrieval of the selected instance. long selectedId = Ntk.NTK_ROOT_INSTANCE_ID; INtkInstanceManager iman = NtkManager.getNtkInstanceManager(); while(true){ //Acquires the ID of the next selected instance long selectedNext = iman.getInstanceId(selectedId, Ntk.NTK_NEXT_SELECTED_INSTANCE_ID, 0); if (selectedNext == 0){ //0 if it does not exist break; } //Starts with ROOT_PROCEDURE_ID at the start of acquisition of the procedure belonging to the instance. long procId = Ntk.NTK_ROOT_PROCEDURE_ID; while(true){ long procNext = iman.getInstanceId(targetInstId, Ntk.NTK_NEXT_PROCEDURE_ID, procId); if (procNext == 0){ break; } //Acquires the event (trigger) number. long triggerNumber = iman.getTrigger(procNext); //Acquires the event name (trigger). String triggerName = triggerTable.getTriggerName(procNumber); //Acquires the procedure name. String procName = iman.getProcedureName(procNext); //Acquires the next procedure. procId = procNext; } //Acquires the next instance. selectedId = selectedNext; } context.unlock();
The following process saves an edited toolkit to a file and creates and builds the source code:
//Acquires INtkProjectManager through NtkManager. INtkProjectManager pman = NtkManager.getNtkProjectManager(); //Creates the source code required for building an application. pman.createCurrentNtkProjectSources(); //Builds the source code. pman.createCurrentNtkProjectSources();
Settings and changes can also be made through INtkProjectManager, of course, and this includes editing NTK project data and setting the save destination for this data.
Contents
![]() ![]() |