use of com.twinsoft.convertigo.beans.ngx.components.UIUseShared 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.beans.ngx.components.UIUseShared in project convertigo by convertigo.
the class ApplicationComponentEditor method highlightComponent.
public void highlightComponent(MobileComponent mobileComponent, boolean selectPage) {
C8oBrowser.run(() -> {
if (selectPage && mobileComponent instanceof UIComponent) {
PageComponent pageComponent = ((UIComponent) mobileComponent).getPage();
if (pageComponent != null) {
selectPage(pageComponent.getSegment());
}
}
});
C8oBrowser.run(() -> {
Document doc = browser.mainFrame().get().document().get();
MobileComponent mc = mobileComponent;
if (mc instanceof UISharedComponent) {
UISharedComponent uisc = (UISharedComponent) mc;
if (uisc != null) {
try {
mc = uisc.getDisplayableComponentList().get(0);
} catch (IndexOutOfBoundsException ioobe) {
}
}
} else if (mc instanceof UIUseShared) {
UISharedComponent uisc = ((UIUseShared) mc).getTargetSharedComponent();
if (uisc != null) {
try {
mc = uisc.getDisplayableComponentList().get(0);
} catch (IndexOutOfBoundsException ioobe) {
}
}
}
while (doc.findElementsByClassName("class" + mc.priority).isEmpty()) {
DatabaseObject parent = mc.getParent();
if (parent instanceof MobileComponent) {
mc = (MobileComponent) parent;
} else {
return;
}
}
c8oBrowser.executeJavaScriptAndReturnValue("_c8o_highlight_class('class" + mc.priority + "');");
});
}
use of com.twinsoft.convertigo.beans.ngx.components.UIUseShared in project convertigo by convertigo.
the class SharedComponentWizard method createUseShared.
private UIUseShared createUseShared(String qname) throws Exception {
UIUseShared uius = new UIUseShared();
uius.setSharedComponentQName(qname);
uius.hasChanged = true;
uius.bNew = true;
for (String name : dlg_map.keySet()) {
String value = ovarMap.get(name).keySet().iterator().next();
uius.add(createUseVariable(dlg_map.get(name), value));
}
UIComponent uic = (UIComponent) getLastInList();
MobileComponent mc = (MobileComponent) uic.getParent();
if (mc instanceof ApplicationComponent) {
ApplicationComponent parent = (ApplicationComponent) mc;
parent.add((DatabaseObject) uius, uic.priority);
} else if (mc instanceof PageComponent) {
PageComponent parent = (PageComponent) mc;
parent.add((DatabaseObject) uius, uic.priority);
} else if (mc instanceof UIComponent) {
UIComponent parent = (UIComponent) mc;
parent.add((DatabaseObject) uius, uic.priority);
}
return uius;
}
Aggregations