use of com.twinsoft.convertigo.beans.ngx.components.PageComponent in project convertigo by convertigo.
the class NgxApplicationComponentTreeObject method treeObjectAdded.
@Override
public void treeObjectAdded(TreeObjectEvent treeObjectEvent) {
super.treeObjectAdded(treeObjectEvent);
TreeObject treeObject = (TreeObject) treeObjectEvent.getSource();
String propertyName = (String) treeObjectEvent.propertyName;
propertyName = ((propertyName == null) ? "" : propertyName);
if (treeObject instanceof DatabaseObjectTreeObject) {
DatabaseObjectTreeObject doto = (DatabaseObjectTreeObject) treeObject;
DatabaseObject dbo = doto.getObject();
try {
// we add a page to this app
if (dbo instanceof PageComponent && getObject().equals(dbo.getParent())) {
PageComponent page = (PageComponent) dbo;
if (page.bNew) {
page.markPageAsDirty();
}
}
} catch (Exception e) {
}
}
}
use of com.twinsoft.convertigo.beans.ngx.components.PageComponent in project convertigo by convertigo.
the class NgxPageComponentTreeObject method getNamedSourceSelector.
@Override
public NamedSourceSelector getNamedSourceSelector() {
return new NamedSourceSelector() {
@Override
Object thisTreeObject() {
return NgxPageComponentTreeObject.this;
}
@Override
protected List<String> getPropertyNamesForSource(Class<?> c) {
List<String> list = new ArrayList<String>();
if (getObject() instanceof PageComponent) {
if (ProjectTreeObject.class.isAssignableFrom(c) || MobileApplicationTreeObject.class.isAssignableFrom(c) || NgxApplicationComponentTreeObject.class.isAssignableFrom(c) || NgxUIComponentTreeObject.class.isAssignableFrom(c)) {
list.add("startMenu");
list.add("endMenu");
}
}
return list;
}
@Override
protected boolean isNamedSource(String propertyName) {
if (getObject() instanceof PageComponent) {
return "startMenu".equals(propertyName) || "endMenu".equals(propertyName);
}
return false;
}
@Override
public boolean isSelectable(String propertyName, Object nsObject) {
if (getObject() instanceof PageComponent) {
if ("startMenu".equals(propertyName) || "endMenu".equals(propertyName)) {
PageComponent pc = getObject();
if (nsObject instanceof UIDynamicMenu) {
return (((UIDynamicMenu) nsObject).getProject().equals(pc.getProject()));
}
}
}
return false;
}
@Override
protected void handleSourceCleared(String propertyName) {
// nothing to do
}
@Override
protected void handleSourceRenamed(String propertyName, String oldName, String newName) {
if (isNamedSource(propertyName)) {
boolean hasBeenRenamed = false;
String pValue = (String) getPropertyValue(propertyName);
if (pValue != null && pValue.startsWith(oldName)) {
String _pValue = newName + pValue.substring(oldName.length());
if (!pValue.equals(_pValue)) {
if (getObject() instanceof PageComponent) {
if ("startMenu".equals(propertyName)) {
getObject().setStartMenu(_pValue);
hasBeenRenamed = true;
}
if ("endMenu".equals(propertyName)) {
getObject().setEndMenu(_pValue);
hasBeenRenamed = true;
}
}
}
}
if (hasBeenRenamed) {
hasBeenModified(true);
ConvertigoPlugin.projectManager.getProjectExplorerView().updateTreeObject(NgxPageComponentTreeObject.this);
// refresh editors (e.g labels in combobox)
getDescriptors();
TreeObjectEvent treeObjectEvent = new TreeObjectEvent(NgxPageComponentTreeObject.this, propertyName, "", "");
ConvertigoPlugin.projectManager.getProjectExplorerView().fireTreeObjectPropertyChanged(treeObjectEvent);
}
}
}
};
}
use of com.twinsoft.convertigo.beans.ngx.components.PageComponent in project convertigo by convertigo.
the class NgxBuilder method pageStyleChanged.
@Override
public synchronized void pageStyleChanged(final IPageComponent pageComponent) throws EngineException {
PageComponent page = (PageComponent) pageComponent;
if (page != null && page.isEnabled() && initDone) {
writePageStyle(page);
moveFiles();
Engine.logEngine.trace("(MobileBuilder) Handled 'pageStyleChanged'");
}
}
use of com.twinsoft.convertigo.beans.ngx.components.PageComponent in project convertigo by convertigo.
the class NgxBuilder method updateSourceFiles.
private void updateSourceFiles() throws EngineException {
try {
MobileApplication mobileApplication = project.getMobileApplication();
if (mobileApplication != null) {
ApplicationComponent application = (ApplicationComponent) mobileApplication.getApplicationComponent();
if (application != null) {
String appTplVersion = application.requiredTplVersion();
if (compareVersions(tplVersion, appTplVersion) >= 0) {
for (PageComponent page : getEnabledPages(application)) {
writePageSourceFiles(page);
}
writeAppSourceFiles(application);
removeUselessPages(application);
Engine.logEngine.trace("(MobileBuilder) Application source files updated for ionic project '" + project.getName() + "'");
} else {
cleanDirectories();
throw new EngineException("Template project minimum " + appTplVersion + " is required for this project.\n" + "You can change template by configuring the 'Template project' property of your project's 'Application' object.\n" + "Then, be sure to update the project node modules packages (Application Right Click->Update packages and execute) \n");
}
}
}
} catch (EngineException e) {
throw e;
} catch (Exception e) {
throw new EngineException("Unable to update application source files for ionic project '" + project.getName() + "'", e);
}
}
use of com.twinsoft.convertigo.beans.ngx.components.PageComponent in project convertigo by convertigo.
the class NgxBuilder method writeAppPackageJson.
private void writeAppPackageJson(ApplicationComponent app) throws EngineException {
try {
if (app != null) {
Map<String, String> pkg_dependencies = new HashMap<>();
// Menus contributors
for (Contributor contributor : app.getContributors()) {
pkg_dependencies.putAll(contributor.getPackageDependencies());
}
// Pages contributors
List<PageComponent> pages = forceEnable ? app.getPageComponentList() : getEnabledPages(app);
for (PageComponent page : pages) {
List<Contributor> contributors = page.getContributors();
for (Contributor contributor : contributors) {
pkg_dependencies.putAll(contributor.getPackageDependencies());
}
}
File appPkgJsonTpl = new File(ionicTplDir, "package.json");
String mContent = FileUtils.readFileToString(appPkgJsonTpl, "UTF-8");
mContent = mContent.replaceAll("../DisplayObjects", "../../DisplayObjects");
JSONObject jsonPackage = new JSONObject(mContent);
JSONObject jsonDependencies = jsonPackage.getJSONObject("dependencies");
for (String pkg : pkg_dependencies.keySet()) {
jsonDependencies.put(pkg, pkg_dependencies.get(pkg));
if (!existPackage(pkg)) {
setNeedPkgUpdate(true);
}
}
boolean addNode = !jsonDependencies.has("@types/node");
if (addNode) {
try {
String version = new JSONObject(FileUtils.readFileToString(new File(ionicTplDir, "version.json"), "utf-8")).getString("version");
addNode = version.matches("7\\.[0-7]\\..*");
} catch (Exception e) {
}
if (addNode) {
jsonDependencies.put("@types/node", "12.0.10");
}
}
File appPkgJson = new File(ionicWorkDir, "package.json");
writeFile(appPkgJson, jsonPackage.toString(2), "UTF-8");
if (initDone) {
Engine.logEngine.trace("(MobileBuilder) Ionic package json file generated");
}
}
} catch (Exception e) {
throw new EngineException("Unable to write ionic package json file", e);
}
}
Aggregations