use of com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent in project convertigo by convertigo.
the class MobilePickerContentProvider method addSharedComponents.
private void addSharedComponents(TVObject tvi, Object object) {
if (object != null) {
List<? extends UIComponent> list = null;
if (object instanceof ApplicationComponent) {
list = ((ApplicationComponent) object).getSharedComponentList();
} else if (object instanceof UISharedComponent) {
list = new ArrayList<>(Arrays.asList((UISharedComponent) object));
}
if (list != null) {
for (UIComponent uic : list) {
if (uic instanceof UISharedComponent) {
// do not add to prevent selection on itself or children
if (uic.equals(selected)) {
return;
}
// do not add if not parent of selected (popped picker only)
boolean showInPicker = true;
if (selected != null && selected instanceof UIComponent) {
String selectedQName = ((UIComponent) selected).getQName();
String uicQName = uic.getQName() + ".";
if (!selectedQName.startsWith(uicQName)) {
showInPicker = false;
}
}
if (showInPicker) {
SourceData sd = null;
try {
sd = Filter.Shared.toSourceData(new JSONObject().put("priority", uic.priority));
} catch (JSONException e) {
e.printStackTrace();
}
tvi.add(new TVObject(uic.toString(), uic, sd));
}
}
}
}
}
}
use of com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent in project convertigo by convertigo.
the class MobileUIComponentTreeObject method editFunction.
private void editFunction(final UIComponent uic, final String functionMarker, final String propertyName) {
try {
IScriptComponent main = uic.getMainScriptComponent();
if (main == null) {
return;
}
// Refresh project resources for editor
String projectName = uic.getProject().getName();
IProject project = ConvertigoPlugin.getDefault().getProjectPluginResource(projectName);
project.refreshLocal(IResource.DEPTH_INFINITE, null);
// Close editor and Reopen it after file has been rewritten
String relativePath = uic.getProject().getMobileBuilder().getFunctionTempTsRelativePath(uic);
IFile file = project.getFile(relativePath);
if (!(uic instanceof UICustomAction)) {
closeComponentFileEditor(file);
}
if (main instanceof ApplicationComponent) {
if (uic.compareToTplVersion("7.5.2.0") < 0) {
ConvertigoPlugin.logError("The ability to use forms or actions inside a menu is avalaible since 7.5.2 version." + "\nPlease change your Template project for the 'mobilebuilder_tpl_7_5_2' template.", true);
return;
}
}
uic.getProject().getMobileBuilder().writeFunctionTempTsFile(uic, functionMarker);
file.refreshLocal(IResource.DEPTH_ZERO, null);
// Open file in editor
if (file.exists()) {
IEditorInput input = new ComponentFileEditorInput(file, uic);
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());
String marker = MobileBuilder.getMarker(doc.get(), functionMarker);
String content = MobileBuilder.getFormatedContent(marker, functionMarker);
FormatedContent formated = new FormatedContent(content);
MobileUIComponentTreeObject.this.setPropertyValue(propertyName, formated);
}
}
}
});
}
}
} catch (Exception e) {
ConvertigoPlugin.logException(e, "Unable to edit function for '" + uic.getName() + "' component!");
}
}
use of com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent in project convertigo by convertigo.
the class Ionic3Builder method getTempTsRelativePath.
@Override
public String getTempTsRelativePath(IApplicationComponent appComponent) throws EngineException {
ApplicationComponent app = (ApplicationComponent) appComponent;
try {
if (app != null) {
File appComponentTsFile = new File(ionicWorkDir, "src/app/app.component.temp.ts");
String filePath = appComponentTsFile.getPath().replace(projectDir.getPath(), File.separator);
return filePath;
}
} catch (Exception e) {
}
return null;
}
use of com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent in project convertigo by convertigo.
the class Ionic3Builder method pageRenamed.
@Override
public void pageRenamed(final IPageComponent pageComponent, final String oldName) throws EngineException {
PageComponent page = (PageComponent) pageComponent;
if (page != null && page.isEnabled() && initDone) {
synchronized (page) {
MobileApplication mobileApplication = project.getMobileApplication();
if (mobileApplication != null) {
ApplicationComponent application = (ApplicationComponent) mobileApplication.getApplicationComponent();
if (application != null) {
writePageSourceFiles(page);
writeAppSourceFiles(application);
deleteUselessDir(oldName);
moveFiles();
Engine.logEngine.trace("(MobileBuilder) Handled 'pageRenamed'");
}
}
}
}
}
use of com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent in project convertigo by convertigo.
the class Ionic3Builder method writeAppComponentTempTs.
@Override
public void writeAppComponentTempTs(final IApplicationComponent appComponent) throws EngineException {
ApplicationComponent app = (ApplicationComponent) appComponent;
try {
if (app != null) {
File appTsFile = new File(ionicWorkDir, "src/app/app.component.ts");
synchronized (writtenFiles) {
if (writtenFiles.contains(appTsFile)) {
File appTsFileTmp = toTmpFile(appTsFile);
if (appTsFileTmp.exists()) {
appTsFile = appTsFileTmp;
}
}
}
File tempTsFile = new File(ionicWorkDir, "src/app/app.component.temp.ts");
// Write file (do not need delay)
FileUtils.copyFile(appTsFile, tempTsFile);
}
} catch (Exception e) {
throw new EngineException("Unable to write ionic app component temp ts file", e);
}
}
Aggregations