Search in sources :

Example 41 with PageComponent

use of com.twinsoft.convertigo.beans.mobile.components.PageComponent 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

PageComponent (com.twinsoft.convertigo.beans.mobile.components.PageComponent)41 IPageComponent (com.twinsoft.convertigo.beans.core.IPageComponent)20 EngineException (com.twinsoft.convertigo.engine.EngineException)16 File (java.io.File)15 ApplicationComponent (com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent)14 IOException (java.io.IOException)11 UIComponent (com.twinsoft.convertigo.beans.mobile.components.UIComponent)9 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)8 UISharedComponent (com.twinsoft.convertigo.beans.mobile.components.UISharedComponent)6 UIUseShared (com.twinsoft.convertigo.beans.mobile.components.UIUseShared)6 ArrayList (java.util.ArrayList)6 IApplicationComponent (com.twinsoft.convertigo.beans.core.IApplicationComponent)5 Project (com.twinsoft.convertigo.beans.core.Project)4 Contributor (com.twinsoft.convertigo.beans.mobile.components.Contributor)4 UIActionStack (com.twinsoft.convertigo.beans.mobile.components.UIActionStack)4 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)4 TreeObjectEvent (com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeObjectEvent)4 HashMap (java.util.HashMap)4 JSONObject (org.codehaus.jettison.json.JSONObject)4 Cursor (org.eclipse.swt.graphics.Cursor)4