use of com.twinsoft.convertigo.beans.mobile.components.MobileComponent 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());
}
}
Document doc = browser.mainFrame().get().document().get();
MobileComponent mc = mobileComponent;
if (mc instanceof UIUseShared) {
UISharedComponent uisc = ((UIUseShared) mc).getTargetSharedComponent();
if (uisc != null) {
try {
mc = uisc.getUIComponentList().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.mobile.components.MobileComponent in project convertigo by convertigo.
the class ApplicationComponentEditor method highlightPoint.
private void highlightPoint(int x, int y) {
Node node = browser.mainFrame().get().inspect(x, y).node().get();
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.beans.mobile.components.MobileComponent in project convertigo by convertigo.
the class MobilePickerContentProvider method getChildren.
@Override
public Object[] getChildren(Object parentElement) {
if (parentElement instanceof TVObject) {
return ((TVObject) parentElement).children.toArray();
} else if (parentElement instanceof MobileComponent) {
MobileComponent mobileComponent = (MobileComponent) parentElement;
Project project = mobileComponent.getProject();
ProjectExplorerView projectExplorerView = ConvertigoPlugin.getDefault().getProjectExplorerView();
List<String> projectNames = Engine.theApp.databaseObjectsManager.getAllProjectNamesList();
Map<String, Set<String>> map = mobileComponent.getApplication().getInfoMap();
TVObject root = new TVObject("root", mobileComponent, null);
if (filter.equals(Filter.Action)) {
TVObject tvi = root.add(new TVObject("actions"));
TVObject tvEvents = tvi.add(new TVObject("events"));
TVObject tvControls = tvi.add(new TVObject("controls"));
addActions(tvi, mobileComponent);
if (tvEvents.isEmpty()) {
tvi.remove(tvEvents);
}
if (tvControls.isEmpty()) {
tvi.remove(tvControls);
}
}
if (filter.equals(Filter.Shared)) {
TVObject tvi = root.add(new TVObject("shared"));
addSharedComponents(tvi, mobileComponent);
}
if (filter.equals(Filter.Sequence)) {
TVObject tvs = root.add(new TVObject("sequences"));
for (String projectName : projectNames) {
try {
Project p = projectExplorerView.getProject(projectName);
boolean isReferenced = !p.getName().equals(project.getName());
addSequences(map, tvs, isReferenced ? p : project, isReferenced);
} catch (Exception e) {
}
}
}
if (filter.equals(Filter.Database)) {
TVObject tvd = root.add(new TVObject("databases"));
for (String projectName : projectNames) {
try {
Project p = projectExplorerView.getProject(projectName);
boolean isReferenced = !p.getName().equals(project.getName());
addFsObjects(map, tvd, isReferenced ? p : project, isReferenced);
} catch (Exception e) {
}
}
}
if (filter.equals(Filter.Iteration)) {
TVObject tvi = root.add(new TVObject("iterations"));
addIterations(tvi, mobileComponent);
}
if (filter.equals(Filter.Form)) {
TVObject tvi = root.add(new TVObject("forms"));
addForms(tvi, mobileComponent);
}
if (filter.equals(Filter.Global)) {
TVObject tvi = root.add(new TVObject("globals"));
addGlobals(tvi, mobileComponent.getApplication());
}
return root.children.toArray();
} else if (parentElement instanceof JSONObject) {
JSONObject jsonObject = (JSONObject) parentElement;
TVObject root = new TVObject("root", jsonObject, null);
addJsonObjects(root);
return root.children.toArray();
}
return new Object[0];
}
use of com.twinsoft.convertigo.beans.mobile.components.MobileComponent in project convertigo by convertigo.
the class MobileComponentTreeObject method closeAllEditors.
public void closeAllEditors(boolean save) {
MobileComponent mc = getObject();
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
if (activePage != null) {
IEditorReference[] editorRefs = activePage.getEditorReferences();
for (int i = 0; i < editorRefs.length; i++) {
IEditorReference editorRef = (IEditorReference) editorRefs[i];
try {
IEditorInput editorInput = editorRef.getEditorInput();
if (editorInput != null && editorInput instanceof ComponentFileEditorInput) {
if (((ComponentFileEditorInput) editorInput).is(mc) || ((ComponentFileEditorInput) editorInput).isChildOf(mc)) {
activePage.closeEditor(editorRef.getEditor(false), save);
}
}
} catch (Exception e) {
}
}
}
}
use of com.twinsoft.convertigo.beans.mobile.components.MobileComponent in project convertigo by convertigo.
the class SharedComponentWizard method doFinish.
private void doFinish(IProgressMonitor monitor) throws CoreException {
UISharedComponent uisc = null;
UIUseShared uius = null;
try {
if (page1 != null) {
shared_comp_name = page1.getSharedComponentName();
keep_original = page1.keepComponent();
}
if (page2 != null) {
dlg_map = page2.getVariableMap();
}
// Create shared component
uisc = createSharedComponent();
monitor.setTaskName("SharedComponent created");
monitor.worked(1);
// Create UseShared
uius = createUseShared(uisc.getQName());
monitor.setTaskName("UseShared component created");
monitor.worked(1);
// Disable or Remove selected databaseObject(s)
for (DatabaseObject dbo : objectList) {
UIComponent uic = (UIComponent) dbo;
if (keep_original) {
uic.setEnabled(false);
uic.hasChanged = true;
} else {
MobileComponent mc = (MobileComponent) uic.getParent();
if (mc instanceof ApplicationComponent) {
ApplicationComponent parent = (ApplicationComponent) mc;
parent.remove(uic);
parent.hasChanged = true;
} else if (mc instanceof PageComponent) {
PageComponent parent = (PageComponent) mc;
parent.remove(uic);
parent.hasChanged = true;
} else if (mc instanceof UIComponent) {
UIComponent parent = (UIComponent) mc;
parent.remove(uic);
parent.hasChanged = true;
}
}
}
// Set newBean to new shared component
newBean = uisc;
} catch (Exception e) {
try {
if (uisc != null) {
uisc.getParent().remove(uisc);
}
if (uius != null) {
uius.getParent().remove(uius);
}
} catch (Exception ex) {
}
String message = "Unable to create a new object from class '" + this.className + "'.";
ConvertigoPlugin.logException(e, message);
newBean = null;
}
}
Aggregations