use of com.twinsoft.convertigo.beans.ngx.components.PageComponent in project convertigo by convertigo.
the class NgxPageComponentTreeObject method editPageTsFile.
public void editPageTsFile() {
final PageComponent page = (PageComponent) getObject();
try {
// Refresh project resource
String projectName = page.getProject().getName();
IProject project = ConvertigoPlugin.getDefault().getProjectPluginResource(projectName);
project.refreshLocal(IResource.DEPTH_INFINITE, null);
// Close editor
String filePath = page.getProject().getMobileBuilder().getTempTsRelativePath(page);
IFile file = project.getFile(filePath);
closeComponentFileEditor(file);
// Write temporary file
page.getProject().getMobileBuilder().writePageTempTs(page);
file.refreshLocal(IResource.DEPTH_ZERO, null);
// Open file in editor
if (file.exists()) {
IEditorInput input = new ComponentFileEditorInput(file, page);
if (input != null) {
IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(file.getName());
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
String editorId = desc.getId();
IEditorPart editorPart = activePage.openEditor(input, editorId);
addMarkers(file, editorPart);
editorPart.addPropertyListener(new IPropertyListener() {
boolean isFirstChange = false;
@Override
public void propertyChanged(Object source, int propId) {
if (source instanceof ITextEditor) {
if (propId == IEditorPart.PROP_DIRTY) {
if (!isFirstChange) {
isFirstChange = true;
return;
}
isFirstChange = false;
ITextEditor editor = (ITextEditor) source;
IDocumentProvider dp = editor.getDocumentProvider();
IDocument doc = dp.getDocument(editor.getEditorInput());
FormatedContent scriptContent = new FormatedContent(MobileBuilder.getMarkers(doc.get()));
NgxPageComponentTreeObject.this.setPropertyValue("scriptContent", scriptContent);
}
}
}
});
}
}
} catch (Exception e) {
ConvertigoPlugin.logException(e, "Unable to open typescript file for page '" + page.getName() + "'!");
}
}
use of com.twinsoft.convertigo.beans.ngx.components.PageComponent in project convertigo by convertigo.
the class NgxPageComponentTreeObject method rename.
@Override
public boolean rename(String newName, boolean bDialog) {
PageComponent page = getObject();
String oldName = page.getName();
boolean isRenamed = super.rename(newName, bDialog);
if (isRenamed && !oldName.equals(newName)) {
String oldSegment = page.getSegment();
if (oldSegment.equals(PageComponent.SEGMENT_PREFIX + oldName.toLowerCase())) {
// path-to-<page_name>
page.setSegment(oldSegment.replace(oldName.toLowerCase(), newName.toLowerCase()));
Engine.logEngine.debug("For page renamed to \"" + newName + "\", segment has been replaced with \"" + page.getSegment() + "\"");
}
}
return isRenamed;
}
use of com.twinsoft.convertigo.beans.ngx.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.ngx.components.PageComponent in project convertigo by convertigo.
the class SetNgxRootPageAction 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) {
NgxPageComponentTreeObject pageTreeObject = (NgxPageComponentTreeObject) explorerView.getFirstSelectedTreeObject();
PageComponent page = (PageComponent) pageTreeObject.getObject();
ApplicationComponent application = (ApplicationComponent) page.getParent();
NgxPageComponentTreeObject rootPageTreeObject = null;
PageComponent rootPage = application.getRootPage();
if (rootPage != null) {
rootPageTreeObject = (NgxPageComponentTreeObject) 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();
}
}
use of com.twinsoft.convertigo.beans.ngx.components.PageComponent in project convertigo by convertigo.
the class DisableNgxPageComponentAction 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 NgxPageComponentTreeObject) {
NgxPageComponentTreeObject componentTreeObject = GenericUtils.cast(treeObject);
component = (PageComponent) componentTreeObject.getObject();
component.setEnabled(false);
componentTreeObject.setEnabled(false);
componentTreeObject.hasBeenModified(true);
TreeObjectEvent treeObjectEvent = new TreeObjectEvent(componentTreeObject, "isEnabled", true, false);
explorerView.fireTreeObjectPropertyChanged(treeObjectEvent);
}
}
explorerView.refreshSelectedTreeObjects();
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to disable page!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
Aggregations