Search in sources :

Example 1 with UISharedRegularComponent

use of com.twinsoft.convertigo.beans.ngx.components.UISharedRegularComponent in project convertigo by convertigo.

the class SharedComponentWizard method doFinish.

private void doFinish(IProgressMonitor monitor) throws CoreException {
    UISharedRegularComponent 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;
    }
}
Also used : UISharedRegularComponent(com.twinsoft.convertigo.beans.ngx.components.UISharedRegularComponent) ApplicationComponent(com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent) UIUseShared(com.twinsoft.convertigo.beans.ngx.components.UIUseShared) UIComponent(com.twinsoft.convertigo.beans.ngx.components.UIComponent) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) PageComponent(com.twinsoft.convertigo.beans.ngx.components.PageComponent) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException) MobileComponent(com.twinsoft.convertigo.beans.ngx.components.MobileComponent)

Example 2 with UISharedRegularComponent

use of com.twinsoft.convertigo.beans.ngx.components.UISharedRegularComponent in project convertigo by convertigo.

the class SharedComponentWizard method createSharedComponent.

private UISharedRegularComponent createSharedComponent() throws Exception {
    UIComponent uic = (UIComponent) getFirstInList();
    UISharedRegularComponent uisc = new UISharedRegularComponent();
    uisc.setName(shared_comp_name);
    uisc.hasChanged = true;
    uisc.bNew = true;
    // must be added before copy/paste !
    uic.getApplication().add(uisc);
    for (DatabaseObject dbo : objectList) {
        ConvertigoPlugin.clipboardManagerSystem.reset();
        ConvertigoPlugin.clipboardManagerSystem.isCopy = true;
        String sXml = ConvertigoPlugin.clipboardManagerSystem.copy(dbo);
        ConvertigoPlugin.clipboardManagerSystem.paste(sXml, uisc, false);
    }
    updateMobileSmartSources(uisc);
    for (String name : dlg_map.keySet()) {
        String value = getVariablesDefaultValue(name);
        uisc.add(createCompVariable(dlg_map.get(name), value));
    }
    return uisc;
}
Also used : UISharedRegularComponent(com.twinsoft.convertigo.beans.ngx.components.UISharedRegularComponent) UIComponent(com.twinsoft.convertigo.beans.ngx.components.UIComponent) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject)

Aggregations

DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)2 UIComponent (com.twinsoft.convertigo.beans.ngx.components.UIComponent)2 UISharedRegularComponent (com.twinsoft.convertigo.beans.ngx.components.UISharedRegularComponent)2 ApplicationComponent (com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent)1 MobileComponent (com.twinsoft.convertigo.beans.ngx.components.MobileComponent)1 PageComponent (com.twinsoft.convertigo.beans.ngx.components.PageComponent)1 UIUseShared (com.twinsoft.convertigo.beans.ngx.components.UIUseShared)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 CoreException (org.eclipse.core.runtime.CoreException)1