Search in sources :

Example 46 with ScreenClass

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

Example 47 with ScreenClass

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

the class DatabaseObjectDeleteAction method delete.

private void delete(DatabaseObject databaseObject) throws EngineException, IOException {
    if (databaseObject instanceof Connector) {
        if (((Connector) databaseObject).isDefault) {
            throw new EngineException("Cannot delete the default connector!");
        }
        String projectName = databaseObject.getParent().getName();
        deleteResourcesFolder(projectName, "soap-templates", databaseObject.getName());
        deleteResourcesFolder(projectName, "Traces", databaseObject.getName());
    } else if (databaseObject instanceof Transaction) {
        if (((Transaction) databaseObject).isDefault) {
            throw new EngineException("Cannot delete the default transaction!");
        }
    } else if (databaseObject instanceof ScreenClass) {
        if ((databaseObject.getParent()) instanceof Project) {
            throw new EngineException("Cannot delete the root screen class!");
        }
    } else if (databaseObject instanceof Statement) {
        if ((databaseObject instanceof ThenStatement) || (databaseObject instanceof ElseStatement)) {
            throw new EngineException("Cannot delete this statement!");
        }
    } else if (databaseObject instanceof Step) {
        if ((databaseObject instanceof ThenStep) || (databaseObject instanceof ElseStep)) {
            throw new EngineException("Cannot delete this step!");
        }
    } else if (databaseObject instanceof MobilePlatform) {
        MobilePlatform mobilePlatform = (MobilePlatform) databaseObject;
        File resourceFolder = mobilePlatform.getResourceFolder();
        if (resourceFolder.exists()) {
        // MessageBox messageBox = new MessageBox(getParentShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
        // messageBox.setMessage("Do you want to delete the whole resource folder \"" + mobilePlatform.getRelativeResourcePath() + "\"?");
        // messageBox.setText("Delete the \""+resourceFolder.getName()+"\" folder?");
        // if (messageBox.open() == SWT.YES) {
        // FileUtils.deleteQuietly(resourceFolder);
        // }
        }
    } else if (databaseObject instanceof PageComponent) {
        if (((PageComponent) databaseObject).isRoot) {
            throw new EngineException("Cannot delete the root page!");
        }
    }
    if (databaseObject instanceof Project) {
        // Deleted project will be backup, car will be deleted to avoid its deployment at engine restart
        // Engine.theApp.databaseObjectsManager.deleteProject(databaseObject.getName());
        Engine.theApp.databaseObjectsManager.deleteProjectAndCar(databaseObject.getName());
    // ConvertigoPlugin.getDefault().deleteProjectPluginResource(databaseObject.getName());
    } else {
        databaseObject.delete();
    }
    if (databaseObject instanceof CouchDbConnector) {
        CouchDbConnector couchDbConnector = (CouchDbConnector) databaseObject;
        String db = couchDbConnector.getDatabaseName();
        if (!db.isEmpty()) {
        // MessageBox messageBox = new MessageBox(getParentShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
        // messageBox.setMessage("Do you want to delete the \""+db+"\" database from the CouchDb server?");
        // messageBox.setText("Delete the database?");
        // if (messageBox.open() == SWT.YES) {
        // couchDbConnector.getCouchClient().deleteDatabase(db);
        // }
        }
    }
// ConvertigoPlugin.logDebug("The object \"" + databaseObject.getQName() + "\" has been deleted from the database repository!");
}
Also used : Connector(com.twinsoft.convertigo.beans.core.Connector) CouchDbConnector(com.twinsoft.convertigo.beans.connectors.CouchDbConnector) ElseStep(com.twinsoft.convertigo.beans.steps.ElseStep) ScreenClass(com.twinsoft.convertigo.beans.core.ScreenClass) ElseStatement(com.twinsoft.convertigo.beans.statements.ElseStatement) ThenStatement(com.twinsoft.convertigo.beans.statements.ThenStatement) Statement(com.twinsoft.convertigo.beans.core.Statement) EngineException(com.twinsoft.convertigo.engine.EngineException) ThenStatement(com.twinsoft.convertigo.beans.statements.ThenStatement) ThenStep(com.twinsoft.convertigo.beans.steps.ThenStep) Step(com.twinsoft.convertigo.beans.core.Step) ElseStep(com.twinsoft.convertigo.beans.steps.ElseStep) CouchDbConnector(com.twinsoft.convertigo.beans.connectors.CouchDbConnector) PageComponent(com.twinsoft.convertigo.beans.mobile.components.PageComponent) ThenStep(com.twinsoft.convertigo.beans.steps.ThenStep) Project(com.twinsoft.convertigo.beans.core.Project) MobilePlatform(com.twinsoft.convertigo.beans.core.MobilePlatform) Transaction(com.twinsoft.convertigo.beans.core.Transaction) ElseStatement(com.twinsoft.convertigo.beans.statements.ElseStatement) File(java.io.File)

Aggregations

ScreenClass (com.twinsoft.convertigo.beans.core.ScreenClass)47 JavelinConnector (com.twinsoft.convertigo.beans.connectors.JavelinConnector)17 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)16 Transaction (com.twinsoft.convertigo.beans.core.Transaction)16 EngineException (com.twinsoft.convertigo.engine.EngineException)15 Connector (com.twinsoft.convertigo.beans.core.Connector)14 HtmlConnector (com.twinsoft.convertigo.beans.connectors.HtmlConnector)13 Statement (com.twinsoft.convertigo.beans.core.Statement)13 JavelinScreenClass (com.twinsoft.convertigo.beans.screenclasses.JavelinScreenClass)10 IOException (java.io.IOException)10 Step (com.twinsoft.convertigo.beans.core.Step)9 HandlerStatement (com.twinsoft.convertigo.beans.statements.HandlerStatement)9 Criteria (com.twinsoft.convertigo.beans.core.Criteria)8 HtmlTransaction (com.twinsoft.convertigo.beans.transactions.HtmlTransaction)8 Project (com.twinsoft.convertigo.beans.core.Project)7 ScHandlerStatement (com.twinsoft.convertigo.beans.statements.ScHandlerStatement)7 ArrayList (java.util.ArrayList)7 Sheet (com.twinsoft.convertigo.beans.core.Sheet)6 FunctionStatement (com.twinsoft.convertigo.beans.statements.FunctionStatement)6 ElseStep (com.twinsoft.convertigo.beans.steps.ElseStep)6