Search in sources :

Example 31 with DatabaseObject

use of com.twinsoft.convertigo.beans.core.DatabaseObject in project convertigo by convertigo.

the class ComponentExplorerComposite method addLabelEx.

private void addLabelEx(Component component, boolean bSelected) {
    String category = component.getGroup();
    if ("".equals(category)) {
        composite = composites[0];
    } else {
        for (int i = 0; i < items.length; i++) {
            if (items[i].getText().equals(category)) {
                composite = composites[i];
            }
        }
    }
    final CLabel label = new CLabel(composite, SWT.NONE);
    Image image = null;
    try {
        image = ConvertigoPlugin.getDefault().getIconFromPath(component.getImagePath(), BeanInfo.ICON_COLOR_32x32);
    } catch (Exception e) {
    }
    label.setImage(image);
    label.setText(component.getLabel());
    label.setAlignment(SWT.LEFT);
    label.setToolTipText(RegexpUtils.removeTag.matcher(getShortDescription(component)).replaceAll(""));
    label.setCursor(handCursor);
    label.setLayoutData(new RowData());
    objectsMap.put(label, component);
    if (bSelected) {
        currentSelectedObject = label;
    }
    // DND support for Mobile palette
    if (wizardPage == null) {
        Transfer[] types = new Transfer[] { PaletteSourceTransfer.getInstance() };
        int operations = DND.DROP_COPY | DND.DROP_MOVE;
        DragSource source = new DragSource(label, operations);
        source.setTransfer(types);
        source.addDragListener(new DragSourceAdapter() {

            @Override
            public void dragStart(DragSourceEvent event) {
                try {
                    if (currentSelectedObject != null && !currentSelectedObject.isDisposed()) {
                        currentSelectedObject.setForeground(label.getForeground());
                        currentSelectedObject.setBackground(label.getBackground());
                    }
                    currentSelectedObject = label;
                    currentSelectedObject.setForeground(FOREGROUND_SELECTED_COLOR);
                    currentSelectedObject.setBackground(BACKGROUND_SELECTED_COLOR);
                    Component c = (Component) objectsMap.get(label);
                    DatabaseObject dbo = ComponentManager.createBeanFromHint(c);
                    if (dbo != null) {
                        String sXml = ClipboardAction.dnd.copy(dbo);
                        if (sXml != null) {
                            event.doit = true;
                            PaletteSourceTransfer.getInstance().setPaletteSource(new PaletteSource(sXml));
                        }
                    } else {
                        throw new Exception("Invalid database object : null");
                    }
                } catch (Exception e) {
                    ConvertigoPlugin.logException(e, "Cannot drag");
                }
            }
        });
    }
    label.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseUp(MouseEvent e) {
            CLabel label = (CLabel) e.getSource();
            if (currentSelectedObject == label)
                return;
            if (currentSelectedObject != null && !currentSelectedObject.isDisposed()) {
                currentSelectedObject.setForeground(label.getForeground());
                currentSelectedObject.setBackground(label.getBackground());
            }
            currentSelectedObject = (CLabel) e.getSource();
            ConvertigoPlugin.logDebug("currentSelectedObject: '" + currentSelectedObject.getText() + "'.");
            currentSelectedObject.setForeground(FOREGROUND_SELECTED_COLOR);
            currentSelectedObject.setBackground(BACKGROUND_SELECTED_COLOR);
            Component currentSelectedComponent = getCurrentSelectedComponent();
            if (currentSelectedComponent != null) {
                updateHelpText(currentSelectedComponent);
            }
        }

        @Override
        public void mouseDoubleClick(MouseEvent e) {
            currentSelectedObject = (CLabel) e.getSource();
            if (wizardPage != null) {
                wizardPage.setPageComplete(true);
                ((ComponentExplorerWizardPage) wizardPage).showNextPage();
            }
        }
    });
    ConvertigoPlugin.logDebug("Loaded '" + component.getLabel() + "'.");
}
Also used : CLabel(org.eclipse.swt.custom.CLabel) DragSourceAdapter(org.eclipse.swt.dnd.DragSourceAdapter) MouseEvent(org.eclipse.swt.events.MouseEvent) MouseAdapter(org.eclipse.swt.events.MouseAdapter) DragSource(org.eclipse.swt.dnd.DragSource) Image(org.eclipse.swt.graphics.Image) Point(org.eclipse.swt.graphics.Point) DragSourceEvent(org.eclipse.swt.dnd.DragSourceEvent) RowData(org.eclipse.swt.layout.RowData) Transfer(org.eclipse.swt.dnd.Transfer) PaletteSourceTransfer(com.twinsoft.convertigo.eclipse.dnd.PaletteSourceTransfer) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) PaletteSource(com.twinsoft.convertigo.eclipse.dnd.PaletteSource) Component(com.twinsoft.convertigo.beans.ngx.components.dynamic.Component)

Example 32 with DatabaseObject

use of com.twinsoft.convertigo.beans.core.DatabaseObject in project convertigo by convertigo.

the class LearnScreenClassWizard method performFinish.

public boolean performFinish() {
    String screenClassName = null;
    String criteriaName = null;
    XPath criteria = null;
    try {
        DatabaseObject parentObject = page2.getParentObject();
        if (parentObject != null) {
            // create new screen class
            htmlScreenClass = new HtmlScreenClass();
            if (htmlScreenClass != null) {
                screenClassName = page2.getScreenClassName();
                if (!StringUtils.isNormalized(screenClassName))
                    throw new EngineException("Screenclass name is not normalized : \"" + screenClassName + "\".");
                htmlScreenClass.setName(screenClassName);
                htmlScreenClass.hasChanged = true;
                htmlScreenClass.priority = parentObject.priority + 1;
                parentObject.add(htmlScreenClass);
                ConvertigoPlugin.logInfo("New screen class named '" + screenClassName + "' has been added!");
                Engine.logBeans.debug("New screen class named '" + screenClassName + "' has been added!", null);
            }
            if (htmlScreenClass != null) {
                criteria = new XPath();
                if (criteria != null) {
                    criteriaName = criteria.getName();
                    criteria.hasChanged = true;
                    try {
                        htmlScreenClass.add(criteria);
                        ConvertigoPlugin.logInfo("New criteria named '" + criteriaName + "' has been added!");
                        Engine.logBeans.debug("New criteria named '" + criteriaName + "' has been added!", null);
                    } catch (EngineException e) {
                        throw e;
                    }
                }
            }
        }
    } catch (EngineException e) {
        String message = "Unable to create new screenclass class!";
        ConvertigoPlugin.logException(e, message);
    }
    return true;
}
Also used : XPath(com.twinsoft.convertigo.beans.common.XPath) EngineException(com.twinsoft.convertigo.engine.EngineException) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) HtmlScreenClass(com.twinsoft.convertigo.beans.screenclasses.HtmlScreenClass)

Example 33 with DatabaseObject

use of com.twinsoft.convertigo.beans.core.DatabaseObject in project convertigo by convertigo.

the class ComponentInfoWizardPage method dialogChanged.

private void dialogChanged(boolean increment) {
    DatabaseObject dbo = ((ComponentExplorerWizardPage) getWizard().getPage("ComponentExplorerWizardPage")).getCreatedBean();
    if (dbo != null) {
        String name = getBeanName();
        if (name.length() == 0) {
            updateStatus("Name must be specified");
            return;
        }
        if (!StringUtils.isNormalized(name)) {
            updateStatus("Name must be normalized.\nDon't start with number and don't use non ASCII caracters.");
            return;
        }
        Matcher m = Pattern.compile("\\d+$").matcher("");
        boolean sameName;
        do {
            sameName = false;
            try {
                dbo.setName(name);
            } catch (ObjectWithSameNameException e) {
                if (!increment) {
                    updateStatus("Name already used by siblings");
                    return;
                }
                sameName = true;
                m.reset(name);
                if (m.find()) {
                    name = name.substring(0, m.start()) + (Integer.parseInt(m.group()) + 1);
                } else {
                    name = name + "_1";
                }
                setBeanName(name);
            } catch (EngineException e) {
                updateStatus("Name could not be set on bean");
                return;
            } catch (NullPointerException e) {
                updateStatus("New Bean has not been instanciated");
                return;
            }
        } while (sameName);
    }
    updateStatus(null);
}
Also used : ObjectWithSameNameException(com.twinsoft.convertigo.engine.ObjectWithSameNameException) Matcher(java.util.regex.Matcher) EngineException(com.twinsoft.convertigo.engine.EngineException) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject)

Example 34 with DatabaseObject

use of com.twinsoft.convertigo.beans.core.DatabaseObject in project convertigo by convertigo.

the class SharedComponentWizard method computeSharedComponentName.

private void computeSharedComponentName() {
    DatabaseObject firstDbo = getFirstInList();
    String dbo_qname = sizeOfList() > 1 ? firstDbo.getParent().getQName() + "_Group" : firstDbo.getQName();
    String app_qname = ((UIComponent) firstDbo).getApplication().getQName();
    dbo_qname = dbo_qname.replace(app_qname + ".", "");
    shared_comp_name = StringUtils.normalize(dbo_qname);
}
Also used : DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject)

Example 35 with DatabaseObject

use of com.twinsoft.convertigo.beans.core.DatabaseObject 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)

Aggregations

DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)296 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)98 DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)97 EngineException (com.twinsoft.convertigo.engine.EngineException)88 Shell (org.eclipse.swt.widgets.Shell)46 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)45 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)43 Cursor (org.eclipse.swt.graphics.Cursor)42 Display (org.eclipse.swt.widgets.Display)42 Sequence (com.twinsoft.convertigo.beans.core.Sequence)41 Project (com.twinsoft.convertigo.beans.core.Project)38 CoreException (org.eclipse.core.runtime.CoreException)36 IOException (java.io.IOException)35 Step (com.twinsoft.convertigo.beans.core.Step)33 ActionModel (com.twinsoft.convertigo.engine.studio.ActionModel)33 TreeParent (com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent)31 Element (org.w3c.dom.Element)30 ObjectsFolderTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject)27 StepTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StepTreeObject)27 PartInitException (org.eclipse.ui.PartInitException)26