public void run(IMarker marker) { if (uuid == null) return; UUID id = UUID.fromString(uuid); ServoyProject servoyProject = ServoyModelManager.getServoyModelManager().getServoyModel().getServoyProject(solutionName); if (servoyProject == null) return; try { IPersist persist = servoyProject.getEditingPersist(id); if (persist == null) return; IPersist parent = persist.getAncestor(parentTypeId); if (parent == null && parentTypeId == IRepository.TABLENODES && dataSource != null) { parent = servoyProject.getEditingSolution().getOrCreateTableNode(dataSource); } if (parent == null) return; MethodTemplate template = MethodTemplate.getTemplate(ScriptMethod.class, eventName); if (template == null) return; MethodArgument signature = template.getSignature(); if (signature == null) return; Map<String, String> substitutions = null; if (dataSource != null) substitutions = Collections.singletonMap("dataSource", dataSource); ScriptMethod method = NewMethodAction.createNewMethod( UIUtils.getActiveShell(), parent, eventName, true, null, null, substitutions, null, null); if (method != null) { PropertyDescriptor descriptor = new PropertyDescriptor(eventName, persist.getClass()); descriptor.getWriteMethod().invoke(persist, new Integer(method.getID())); servoyProject.saveEditingSolutionNodes(new IPersist[] {parent}, true); } } catch (Exception e) { ServoyLog.logError(e); } }
public void run(IMarker marker) { if (solutionName != null) { ServoyProject servoyProject = ServoyModelManager.getServoyModelManager() .getServoyModel() .getServoyProject(solutionName); if (servoyProject != null) { Solution solution = servoyProject.getEditingSolution(); if (solution != null) { solution.setSolutionType(SolutionMetaData.WEB_CLIENT_ONLY); try { servoyProject.saveEditingSolutionNodes(new IPersist[] {solution}, false); } catch (RepositoryException e) { ServoyLog.logError(e); } } } } }