Search in sources :

Example 6 with ScreenClassTreeObject

use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ScreenClassTreeObject in project convertigo by convertigo.

the class CreateTagNameFromSelectionZoneAction method run.

public void run() {
    Display display = Display.getDefault();
    Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
    Shell shell = getParentShell();
    shell.setCursor(waitCursor);
    try {
        final ProjectExplorerView explorerView = getProjectExplorerView();
        IWorkbenchPart wpart = getActivePart();
        if ((explorerView != null) && (wpart != null) && (wpart instanceof ConnectorEditor)) {
            ConnectorEditor connectorEditor = (ConnectorEditor) wpart;
            ConnectorEditorPart connectorEditorPart = connectorEditor.getConnectorEditorPart();
            AbstractConnectorComposite connectorComposite = connectorEditorPart.getConnectorComposite();
            if ((connectorComposite != null) && (connectorComposite instanceof JavelinConnectorComposite)) {
                final Javelin javelin = ((JavelinConnectorComposite) connectorComposite).getJavelin();
                ScreenClass currentScreenClass = ((JavelinConnector) connectorEditorPart.getConnector()).getCurrentScreenClass();
                Engine.theApp.fireObjectDetected(new EngineEvent(currentScreenClass));
                final ScreenClassTreeObject lastDetectedScreenClassTreeObject = explorerView.getLastDetectedScreenClassTreeObject();
                if (lastDetectedScreenClassTreeObject != null) {
                    final ScreenClass lastDetectedScreenClass = (ScreenClass) lastDetectedScreenClassTreeObject.getObject();
                    final TagName tagName = new TagName();
                    final InputDialog dlg = new InputDialog(shell, "New TagName", "Please enter a tag name :", "_configure_a_tag_name_", null);
                    if (dlg.open() == Window.OK) {
                        display.asyncExec(new Runnable() {

                            public void run() {
                                try {
                                    String name = dlg.getValue();
                                    Rectangle zone = javelin.getSelectionZone();
                                    tagName.setTagName(StringUtils.normalize(name));
                                    tagName.setSelectionScreenZone(new XMLRectangle(zone.x, zone.y, zone.width, zone.height));
                                    tagName.setSelectionAttribute(javelin.getCharAttribute(zone.x, zone.y));
                                    tagName.setSelectionType("");
                                    tagName.hasChanged = true;
                                    tagName.bNew = true;
                                    lastDetectedScreenClass.addExtractionRule(tagName);
                                    explorerView.reloadTreeObject(lastDetectedScreenClassTreeObject);
                                } catch (Exception e) {
                                    ConvertigoPlugin.logException(e, "Unable to create screen class from selection zone!");
                                }
                                javelin.setSelectionZone(new Rectangle(0, 0, 0, 0));
                            }
                        });
                    } else {
                        javelin.setSelectionZone(new Rectangle(0, 0, 0, 0));
                    }
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to create screen class from selection zone!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) InputDialog(org.eclipse.jface.dialogs.InputDialog) TagName(com.twinsoft.convertigo.beans.common.TagName) ScreenClass(com.twinsoft.convertigo.beans.core.ScreenClass) AbstractConnectorComposite(com.twinsoft.convertigo.eclipse.editors.connector.AbstractConnectorComposite) JavelinConnectorComposite(com.twinsoft.convertigo.eclipse.editors.connector.JavelinConnectorComposite) Rectangle(java.awt.Rectangle) XMLRectangle(com.twinsoft.convertigo.beans.common.XMLRectangle) Javelin(com.twinsoft.twinj.Javelin) Cursor(org.eclipse.swt.graphics.Cursor) ConnectorEditor(com.twinsoft.convertigo.eclipse.editors.connector.ConnectorEditor) ConnectorEditorPart(com.twinsoft.convertigo.eclipse.editors.connector.ConnectorEditorPart) JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) Shell(org.eclipse.swt.widgets.Shell) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) ScreenClassTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ScreenClassTreeObject) XMLRectangle(com.twinsoft.convertigo.beans.common.XMLRectangle) EngineEvent(com.twinsoft.convertigo.engine.EngineEvent) Display(org.eclipse.swt.widgets.Display)

Aggregations

ScreenClassTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ScreenClassTreeObject)6 ScreenClass (com.twinsoft.convertigo.beans.core.ScreenClass)5 JavelinConnector (com.twinsoft.convertigo.beans.connectors.JavelinConnector)4 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)3 DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)3 IPropertyTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject)3 XMLVector (com.twinsoft.convertigo.beans.common.XMLVector)2 HtmlConnector (com.twinsoft.convertigo.beans.connectors.HtmlConnector)2 Connector (com.twinsoft.convertigo.beans.core.Connector)2 Statement (com.twinsoft.convertigo.beans.core.Statement)2 Transaction (com.twinsoft.convertigo.beans.core.Transaction)2 FunctionStatement (com.twinsoft.convertigo.beans.statements.FunctionStatement)2 JavelinTransaction (com.twinsoft.convertigo.beans.transactions.JavelinTransaction)2 AbstractConnectorComposite (com.twinsoft.convertigo.eclipse.editors.connector.AbstractConnectorComposite)2 ConnectorEditor (com.twinsoft.convertigo.eclipse.editors.connector.ConnectorEditor)2 ConnectorEditorPart (com.twinsoft.convertigo.eclipse.editors.connector.ConnectorEditorPart)2 JavelinConnectorComposite (com.twinsoft.convertigo.eclipse.editors.connector.JavelinConnectorComposite)2 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)2 MobileUIComponentTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileUIComponentTreeObject)2 NgxUIComponentTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxUIComponentTreeObject)2