use of com.twinsoft.convertigo.beans.mobile.components.PageComponent in project convertigo by convertigo.
the class MobilePageSegmentValidator method isValid.
@Override
public String isValid(Object value) {
if (page != null) {
String segment = value.toString();
if (segment.isEmpty()) {
return "The segment must not be empty!";
}
if (segment.startsWith("/")) {
return "The segment must not start with \"/\"!";
}
if (segment.endsWith("/")) {
return "The segment must not end with \"/\"!";
}
Pattern pattern = Pattern.compile("\\$\\{(.*)\\}");
Matcher matcher = pattern.matcher(segment);
if (matcher.find()) {
return "The segment must not contain symbols!";
}
try {
new URI("http://example.com/" + segment);
} catch (Exception e) {
return "The segment is not valid!";
}
ApplicationComponent app = page.getApplication();
if (app != null) {
for (PageComponent p : app.getPageComponentList()) {
if (!p.equals(page)) {
if (toParamPath(p.getSegment()).equals(toParamPath(segment))) {
if (p.getSegment().equals(segment))
return "Segment \"" + p.getSegment() + "\" already exists for the application!";
else
return "A similar segment \"" + p.getSegment() + "\" already exists for the application!";
}
if (p.getName().equals(segment)) {
return "Segment \"" + segment + "\" is invalid: It must not be the name of another page!";
}
}
}
}
}
return null;
}
use of com.twinsoft.convertigo.beans.mobile.components.PageComponent 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.PageComponent in project convertigo by convertigo.
the class MobileComponentImportVariablesAction method run.
public void run() {
Display display = Display.getDefault();
Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
Shell shell = getParentShell();
shell.setCursor(waitCursor);
try {
ProjectExplorerView explorerView = getProjectExplorerView();
if (explorerView != null) {
TreeObject treeObject = explorerView.getFirstSelectedTreeObject();
Object databaseObject = treeObject.getObject();
if (databaseObject != null) {
if (databaseObject instanceof UIDynamicAction) {
UIDynamicAction dynAction = (UIDynamicAction) databaseObject;
IonBean ionBean = ((UIDynamicAction) dynAction).getIonBean();
if (ionBean != null) {
// Case of CallSequenceAction
if (ionBean.getName().equals("CallSequenceAction")) {
Object value = ionBean.getProperty("requestable").getValue();
if (!value.equals(false)) {
String target = value.toString();
if (!target.isEmpty()) {
try {
String projectName = target.substring(0, target.indexOf('.'));
String sequenceName = target.substring(target.indexOf('.') + 1);
Project p = Engine.theApp.databaseObjectsManager.getProjectByName(projectName);
Sequence sequence = p.getSequenceByName(sequenceName);
int size = sequence.numberOfVariables();
for (int i = 0; i < size; i++) {
RequestableVariable variable = (RequestableVariable) sequence.getVariable(i);
if (variable != null) {
String variableName = variable.getName();
if (dynAction.getVariable(variableName) == null) {
if (!StringUtils.isNormalized(variableName))
throw new EngineException("Variable name is not normalized : \"" + variableName + "\".");
UIControlVariable uiVariable = new UIControlVariable();
uiVariable.setName(variableName);
uiVariable.setComment(variable.getDescription());
uiVariable.setVarSmartType(new MobileSmartSourceType(variable.getDefaultValue().toString()));
dynAction.addUIComponent(uiVariable);
uiVariable.bNew = true;
uiVariable.hasChanged = true;
dynAction.hasChanged = true;
}
}
}
} catch (Exception e) {
}
}
}
} else // Case of InvokeAction
if (ionBean.getName().equals("InvokeAction")) {
UIDynamicInvoke dynInvoke = (UIDynamicInvoke) databaseObject;
UIActionStack stack = dynInvoke.getTargetSharedAction();
if (stack != null) {
for (UIStackVariable variable : stack.getVariables()) {
String variableName = variable.getName();
if (dynAction.getVariable(variableName) == null) {
if (!StringUtils.isNormalized(variableName))
throw new EngineException("Variable name is not normalized : \"" + variableName + "\".");
UIControlVariable uiVariable = new UIControlVariable();
uiVariable.setName(variableName);
uiVariable.setComment(variable.getComment());
MobileSmartSourceType msst = new MobileSmartSourceType();
msst.setMode(MobileSmartSourceType.Mode.SCRIPT);
msst.setSmartValue(variable.getVariableValue());
uiVariable.setVarSmartType(msst);
dynAction.addUIComponent(uiVariable);
uiVariable.bNew = true;
uiVariable.hasChanged = true;
dynAction.hasChanged = true;
}
}
}
}
if (dynAction.hasChanged) {
IScriptComponent main = dynAction.getMainScriptComponent();
if (main != null) {
if (main instanceof ApplicationComponent) {
((ApplicationComponent) main).markApplicationAsDirty();
}
if (main instanceof PageComponent) {
((PageComponent) main).markPageAsDirty();
}
}
explorerView.reloadTreeObject(treeObject);
StructuredSelection structuredSelection = new StructuredSelection(treeObject);
ConvertigoPlugin.getDefault().getPropertiesView().selectionChanged((IWorkbenchPart) explorerView, structuredSelection);
}
}
} else if (databaseObject instanceof UIUseShared) {
UIUseShared useShared = (UIUseShared) databaseObject;
UISharedComponent sharedComp = useShared.getTargetSharedComponent();
if (sharedComp != null) {
for (UICompVariable variable : sharedComp.getVariables()) {
String variableName = variable.getName();
if (useShared.getVariable(variableName) == null) {
if (!StringUtils.isNormalized(variableName))
throw new EngineException("Variable name is not normalized : \"" + variableName + "\".");
UIControlVariable uiVariable = new UIControlVariable();
uiVariable.setName(variableName);
uiVariable.setComment(variable.getComment());
MobileSmartSourceType msst = new MobileSmartSourceType();
msst.setMode(MobileSmartSourceType.Mode.SCRIPT);
msst.setSmartValue(variable.getVariableValue());
uiVariable.setVarSmartType(msst);
useShared.addUIComponent(uiVariable);
uiVariable.bNew = true;
uiVariable.hasChanged = true;
useShared.hasChanged = true;
}
}
if (useShared.hasChanged) {
IScriptComponent main = useShared.getMainScriptComponent();
if (main != null) {
if (main instanceof ApplicationComponent) {
((ApplicationComponent) main).markApplicationAsDirty();
}
if (main instanceof PageComponent) {
((PageComponent) main).markPageAsDirty();
}
}
explorerView.reloadTreeObject(treeObject);
StructuredSelection structuredSelection = new StructuredSelection(treeObject);
ConvertigoPlugin.getDefault().getPropertiesView().selectionChanged((IWorkbenchPart) explorerView, structuredSelection);
}
}
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to add variables to action !");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.beans.mobile.components.PageComponent in project convertigo by convertigo.
the class EnableMobilePageComponentAction method run.
public void run() {
Display display = Display.getDefault();
Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
Shell shell = getParentShell();
shell.setCursor(waitCursor);
try {
ProjectExplorerView explorerView = getProjectExplorerView();
if (explorerView != null) {
DatabaseObjectTreeObject treeObject = null;
PageComponent component = null;
TreeObject[] treeObjects = explorerView.getSelectedTreeObjects();
for (int i = treeObjects.length - 1; i >= 0; i--) {
treeObject = (DatabaseObjectTreeObject) treeObjects[i];
if (treeObject instanceof MobilePageComponentTreeObject) {
MobilePageComponentTreeObject componentTreeObject = (MobilePageComponentTreeObject) treeObject;
component = (PageComponent) componentTreeObject.getObject();
component.setEnabled(true);
componentTreeObject.setEnabled(true);
componentTreeObject.hasBeenModified(true);
TreeObjectEvent treeObjectEvent = new TreeObjectEvent(componentTreeObject, "isEnabled", false, true);
explorerView.fireTreeObjectPropertyChanged(treeObjectEvent);
}
}
explorerView.refreshSelectedTreeObjects();
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to enable page!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.beans.mobile.components.PageComponent in project convertigo by convertigo.
the class SetMobileRootPageAction method run.
public void run() {
Display display = Display.getDefault();
Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
Shell shell = getParentShell();
shell.setCursor(waitCursor);
try {
ProjectExplorerView explorerView = getProjectExplorerView();
if (explorerView != null) {
MobilePageComponentTreeObject pageTreeObject = (MobilePageComponentTreeObject) explorerView.getFirstSelectedTreeObject();
PageComponent page = (PageComponent) pageTreeObject.getObject();
ApplicationComponent application = (ApplicationComponent) page.getParent();
MobilePageComponentTreeObject rootPageTreeObject = null;
PageComponent rootPage = application.getRootPage();
if (rootPage != null) {
rootPageTreeObject = (MobilePageComponentTreeObject) explorerView.findTreeObjectByUserObject(rootPage);
}
application.setRootPage(page);
application.markRootAsDirty();
if (rootPageTreeObject != null) {
rootPageTreeObject.isDefault = false;
rootPageTreeObject.hasBeenModified(true);
}
pageTreeObject.isDefault = true;
pageTreeObject.hasBeenModified(true);
// Updating the tree
explorerView.refreshTreeObject(pageTreeObject.getParentDatabaseObjectTreeObject());
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to set page to root one!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
Aggregations