use of com.twinsoft.convertigo.engine.helpers.WalkHelper in project convertigo by convertigo.
the class DatabaseObjectsManager method symbolsProjectCheckUndefined.
public boolean symbolsProjectCheckUndefined(String projectName) throws Exception {
final Project project = getOriginalProjectByName(projectName, false);
if (project == null) {
return false;
}
if (project.undefinedGlobalSymbols) {
project.undefinedGlobalSymbols = false;
new WalkHelper() {
@Override
protected void walk(DatabaseObject databaseObject) throws Exception {
if (databaseObject.isSymbolError()) {
project.undefinedGlobalSymbols = true;
} else {
super.walk(databaseObject);
}
}
}.init(project);
}
return project.undefinedGlobalSymbols;
}
use of com.twinsoft.convertigo.engine.helpers.WalkHelper in project convertigo by convertigo.
the class ApplicationComponentEditor method highlightPoint.
private void highlightPoint(int x, int y) {
x = c8oBrowser.fixDPI(x);
y = c8oBrowser.fixDPI(y);
Node node = browser.mainFrame().get().inspect(x, y).node().orElse(null);
while (!(node == null || node instanceof Element)) {
node = node.parent().orElse(null);
}
while (node != null) {
Element element = (Element) node;
if (element.equals(exHighlightElement)) {
return;
}
exHighlightElement = element;
String classes = element.attributeValue("class");
Matcher mPriority = pPriority.matcher(classes);
if (mPriority.find()) {
try {
node = null;
long priority = Long.parseLong(mPriority.group(1));
new WalkHelper() {
@Override
protected void walk(DatabaseObject databaseObject) throws Exception {
if (databaseObject instanceof UIUseShared) {
UISharedComponent uisc = ((UIUseShared) databaseObject).getTargetSharedComponent();
if (uisc != null) {
databaseObject = uisc;
}
} else if (databaseObject instanceof UIDynamicInvoke) {
UIDynamicInvoke uidi = (UIDynamicInvoke) databaseObject;
UIActionStack uisa = uidi.getTargetSharedAction();
if (uisa != null) {
if (!uidi.isRecursive()) {
databaseObject = uisa;
}
}
}
if (databaseObject.priority == priority) {
throw new DatabaseObjectFoundException(databaseObject);
}
super.walk(databaseObject);
}
}.init(applicationEditorInput.application);
} catch (DatabaseObjectFoundException e) {
DatabaseObject databaseObject = e.getDatabaseObject();
c8oBrowser.getDisplay().asyncExec(() -> ConvertigoPlugin.getDefault().getProjectExplorerView().objectSelected(new CompositeEvent(databaseObject)));
if (databaseObject instanceof MobileComponent && !databaseObject.equals(exHighlightMobileComponent)) {
highlightComponent(exHighlightMobileComponent = (MobileComponent) databaseObject, false);
}
} catch (Exception e) {
e.printStackTrace();
}
} else {
node = node.parent().orElse(null);
while (!(node == null || node instanceof Element)) {
node = node.parent().orElse(null);
}
}
}
}
use of com.twinsoft.convertigo.engine.helpers.WalkHelper in project convertigo by convertigo.
the class ApplicationComponentEditor method highlightPoint.
private void highlightPoint(int x, int y) {
x = c8oBrowser.fixDPI(x);
y = c8oBrowser.fixDPI(y);
Node node = browser.mainFrame().get().inspect(x, y).node().orElse(null);
while (!(node == null || node instanceof Element)) {
node = node.parent().orElse(null);
}
if (node == null) {
return;
}
Object shadowHost = c8oBrowser.executeFunctionAndReturnValue("_c8o_getShadowHost", node);
if (shadowHost != null && shadowHost instanceof Element) {
node = (Element) shadowHost;
}
while (node != null) {
Element element = (Element) node;
if (element.equals(exHighlightElement)) {
return;
}
exHighlightElement = element;
String classes = element.attributeValue("class");
Matcher mPriority = pPriority.matcher(classes);
if (mPriority.find()) {
try {
node = null;
long priority = Long.parseLong(mPriority.group(1));
new WalkHelper() {
@Override
protected void walk(DatabaseObject databaseObject) throws Exception {
if (databaseObject instanceof UISharedComponent) {
UISharedComponent uisc = (UISharedComponent) databaseObject;
if (uisc != null) {
databaseObject = uisc;
}
} else if (databaseObject instanceof UIUseShared) {
UISharedComponent uisc = ((UIUseShared) databaseObject).getTargetSharedComponent();
if (uisc != null) {
databaseObject = uisc;
}
} else if (databaseObject instanceof UIDynamicInvoke) {
UIDynamicInvoke uidi = (UIDynamicInvoke) databaseObject;
UIActionStack uisa = uidi.getTargetSharedAction();
if (uisa != null) {
if (!uidi.isRecursive()) {
databaseObject = uisa;
}
}
}
if (databaseObject.priority == priority) {
throw new DatabaseObjectFoundException(databaseObject);
}
super.walk(databaseObject);
}
}.init(applicationEditorInput.application);
} catch (DatabaseObjectFoundException e) {
DatabaseObject databaseObject = e.getDatabaseObject();
if (databaseObject instanceof MobileComponent && !databaseObject.equals(exHighlightMobileComponent)) {
if (dragStartMobileComponent != null) {
DatabaseObject ancestor = databaseObject;
while (dragStartMobileComponent != ancestor && ancestor != null) {
ancestor = ancestor.getParent();
}
if (dragStartMobileComponent == ancestor) {
return;
}
}
c8oBrowser.getDisplay().asyncExec(() -> ConvertigoPlugin.getDefault().getProjectExplorerView().objectSelected(new CompositeEvent(databaseObject)));
highlightComponent(exHighlightMobileComponent = (MobileComponent) databaseObject, false);
}
} catch (Exception e) {
e.printStackTrace();
}
} else {
node = node.parent().orElse(null);
while (!(node == null || node instanceof Element)) {
node = node.parent().orElse(null);
}
}
}
}
use of com.twinsoft.convertigo.engine.helpers.WalkHelper in project convertigo by convertigo.
the class UIDynamicAnimate method getAnimatableId.
private String getAnimatableId() {
if (!identifiable.isEmpty()) {
String p_name = identifiable.substring(0, identifiable.indexOf('.'));
Project project = this.getProject();
if (project != null) {
Project p = null;
try {
// p = p_name.equals(project.getName()) ? project: Engine.theApp.databaseObjectsManager.getOriginalProjectByName(p_name);
p = Engine.theApp.referencedProjectManager.importProjectFrom(project, p_name);
} catch (Exception e) {
Engine.logBeans.warn("(UIDynamicAnimate) For \"" + this.toString() + "\", targeted project \"" + p_name + "\" is missing !");
}
if (p != null) {
Map<String, DatabaseObject> map = new HashMap<String, DatabaseObject>();
try {
new WalkHelper() {
@Override
protected void walk(DatabaseObject databaseObject) throws Exception {
map.put(databaseObject.getQName(), databaseObject);
super.walk(databaseObject);
}
}.init(p);
DatabaseObject animatable = map.get(identifiable);
if (animatable != null && animatable instanceof UIElement) {
return ((UIElement) animatable).getIdentifier();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
return "";
}
use of com.twinsoft.convertigo.engine.helpers.WalkHelper in project convertigo by convertigo.
the class ClipboardManager method cutAndPaste.
public void cutAndPaste(final DatabaseObject object, DatabaseObject parentDatabaseObject) throws ConvertigoException {
// Verifying if a sheet with the same browser does not already exist
if (object instanceof Sheet) {
String browser = ((Sheet) object).getBrowser();
Sheet sheet = null;
if (parentDatabaseObject instanceof ScreenClass) {
sheet = ((ScreenClass) parentDatabaseObject).getLocalSheet(browser);
} else if (parentDatabaseObject instanceof RequestableObject) {
sheet = ((RequestableObject) parentDatabaseObject).getSheet(browser);
}
if (sheet != null) {
throw new EngineException("You cannot cut and paste the sheet because a sheet is already defined for the browser \"" + browser + "\" in the screen class \"" + parentDatabaseObject.getName() + "\".");
}
}
if (object instanceof Step) {
if (object instanceof ThenStep) {
throw new EngineException("You cannot cut the \"Then\" step");
}
if (object instanceof ElseStep) {
throw new EngineException("You cannot cut the \"Else\" step");
}
}
if (object instanceof Statement) {
if (object instanceof ThenStatement)
throw new EngineException("You cannot cut the \"Then\" statement");
if (object instanceof ElseStatement)
throw new EngineException("You cannot cut the \"Else\" statement");
}
// Verify object is accepted for paste
if (!DatabaseObjectsManager.acceptDatabaseObjects(parentDatabaseObject, object)) {
throw new EngineException("You cannot cut and paste to a " + parentDatabaseObject.getClass().getSimpleName() + " a database object of type " + object.getClass().getSimpleName());
}
if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.MobileComponent) {
if (!com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.acceptDatabaseObjects(parentDatabaseObject, object)) {
throw new EngineException("You cannot cut and paste to a " + parentDatabaseObject.getClass().getSimpleName() + " a database object of type " + object.getClass().getSimpleName());
}
if (!com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.isTplCompatible(parentDatabaseObject, object)) {
String tplVersion = com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.getTplRequired(object);
throw new EngineException("Template project " + tplVersion + " compatibility required");
}
} else if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.MobileComponent) {
if (!com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.acceptDatabaseObjects(parentDatabaseObject, object)) {
throw new EngineException("You cannot cut and paste to a " + parentDatabaseObject.getClass().getSimpleName() + " a database object of type " + object.getClass().getSimpleName());
}
if (!com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.isTplCompatible(parentDatabaseObject, object)) {
String tplVersion = com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.getTplRequired(object);
throw new EngineException("Template project " + tplVersion + " compatibility required");
}
}
// Verify if a child object with same name exist
boolean bContinue = true;
boolean bIncName = false;
String dboName = object.getName();
while (bContinue) {
try {
if (bIncName) {
dboName = DatabaseObject.incrementName(dboName);
object.setName(dboName);
}
new WalkHelper() {
boolean root = true;
boolean find = false;
@Override
protected boolean before(DatabaseObject databaseObject, Class<? extends DatabaseObject> dboClass) {
boolean isInstance = dboClass.isInstance(object);
find |= isInstance;
return isInstance;
}
@Override
protected void walk(DatabaseObject databaseObject) throws Exception {
if (root) {
root = false;
if (databaseObject instanceof Project) {
if (object instanceof Connector && ((Connector) object).isDefault) {
throw new EngineException("You cannot cut the default connector to another project");
}
} else if (databaseObject instanceof Connector) {
if (object instanceof ScreenClass) {
throw new EngineException("You cannot cut the default screen class to another connector");
} else if (object instanceof Transaction && ((Transaction) object).isDefault) {
throw new EngineException("You cannot cut the default transaction to another connector");
}
} else if (databaseObject instanceof ScreenClass) {
if (object instanceof Criteria && databaseObject.getParent() instanceof Connector) {
throw new EngineException("You cannot cut the criterion of default screen class");
}
} else if (databaseObject instanceof MobileObject) {
if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent) {
if (object instanceof com.twinsoft.convertigo.beans.mobile.components.PageComponent) {
com.twinsoft.convertigo.beans.mobile.components.PageComponent pc = GenericUtils.cast(object);
if (pc.isRoot) {
throw new EngineException("You cannot cut the root page to another application");
}
}
} else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent) {
if (object instanceof com.twinsoft.convertigo.beans.ngx.components.PageComponent) {
com.twinsoft.convertigo.beans.ngx.components.PageComponent pc = GenericUtils.cast(object);
if (pc.isRoot) {
throw new EngineException("You cannot cut the root page to another application");
}
}
}
}
super.walk(databaseObject);
if (!find) {
throw new EngineException("You cannot cut and paste to a " + databaseObject.getClass().getSimpleName() + " a database object of type " + object.getClass().getSimpleName());
}
} else {
if (object != databaseObject && object.getName().equalsIgnoreCase(databaseObject.getName())) {
throw new ObjectWithSameNameException("Unable to cut the object because an object with the same name already exists in target.");
}
}
}
}.init(parentDatabaseObject);
bContinue = false;
} catch (ObjectWithSameNameException e) {
bIncName = true;
} catch (EngineException e) {
throw e;
} catch (Exception e) {
throw new EngineException("Exception in cutAndPaste", e);
}
}
move(object, parentDatabaseObject);
}
Aggregations