Search in sources :

Example 6 with DesignDocumentViewTreeObject

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

the class CreateDesignDocumentViewReduceAction method run.

public void run() {
    Display display = Display.getDefault();
    Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
    Shell shell = getParentShell();
    shell.setCursor(waitCursor);
    try {
        ProjectExplorerView explorerView = getProjectExplorerView();
        if (explorerView != null) {
            DesignDocumentViewTreeObject ddvto = (DesignDocumentViewTreeObject) explorerView.getFirstSelectedTreeObject();
            DesignDocumentFunctionTreeObject ddfto = ddvto.addReduce();
            DesignDocumentTreeObject ddto = (DesignDocumentTreeObject) ddvto.getParent().getParent();
            if (ddto.hasChanged()) {
                TreeParent treeParent = ddto.getParent();
                if (treeParent instanceof FolderTreeObject)
                    treeParent = treeParent.getParent();
                explorerView.objectChanged(new CompositeEvent(treeParent.getObject(), ddfto.getPath()));
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to create a reduce function!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : DesignDocumentFunctionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentFunctionTreeObject) Shell(org.eclipse.swt.widgets.Shell) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) DesignDocumentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentTreeObject) TreeParent(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent) DesignDocumentViewTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentViewTreeObject) Cursor(org.eclipse.swt.graphics.Cursor) FolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject) CompositeEvent(com.twinsoft.convertigo.eclipse.editors.CompositeEvent) Display(org.eclipse.swt.widgets.Display)

Example 7 with DesignDocumentViewTreeObject

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

the class ViewImageProvider method getImageData.

/**
 * Dispose all loaded images
 */
/*public static void dispose() {
		String imageName = null;
		Image image = null;
		for (Enumeration e = imagesCache.keys(); e.hasMoreElements(); ) {
			imageName = (String) e.nextElement();
			if (imageName != null) {
				image = (Image) imagesCache.get(imageName);
				imagesCache.put(imageName, null);
			}
			if (image != null)
				image.dispose();
		}
	}*/
private static ImageData getImageData(Image image, Object object) {
    ImageData imageData = image.getImageData();
    DatabaseObjectTreeObject databaseObjectTreeObject = null;
    if (object instanceof DatabaseObjectTreeObject) {
        databaseObjectTreeObject = (DatabaseObjectTreeObject) object;
    } else if (object instanceof PropertyTableTreeObject) {
        PropertyTableTreeObject table = (PropertyTableTreeObject) object;
        if (table != null) {
            databaseObjectTreeObject = (DatabaseObjectTreeObject) table.getTreeObjectOwner();
        }
    } else if (object instanceof PropertyTableRowTreeObject) {
        PropertyTableTreeObject table = ((PropertyTableRowTreeObject) object).getParentTable();
        if (table != null) {
            databaseObjectTreeObject = (DatabaseObjectTreeObject) table.getTreeObjectOwner();
        }
    } else if (object instanceof PropertyTableColumnTreeObject) {
        PropertyTableTreeObject table = ((PropertyTableColumnTreeObject) object).getParentTable();
        if (table != null) {
            databaseObjectTreeObject = (DatabaseObjectTreeObject) table.getTreeObjectOwner();
        }
    } else if (object instanceof FolderTreeObject) {
        FolderTreeObject t_folder = (FolderTreeObject) object;
        if (t_folder.getParent() instanceof DatabaseObjectTreeObject) {
            databaseObjectTreeObject = (DatabaseObjectTreeObject) t_folder.getParent();
        }
    } else if (object instanceof DesignDocumentViewTreeObject) {
        DesignDocumentViewTreeObject ddvto = (DesignDocumentViewTreeObject) object;
        if (ddvto != null) {
            databaseObjectTreeObject = (DatabaseObjectTreeObject) ddvto.getTreeObjectOwner();
        }
    } else if (object instanceof DesignDocumentFunctionTreeObject) {
        DesignDocumentFunctionTreeObject ddfto = (DesignDocumentFunctionTreeObject) object;
        if (ddfto != null) {
            databaseObjectTreeObject = (DatabaseObjectTreeObject) ddfto.getTreeObjectOwner();
        }
    }
    if (databaseObjectTreeObject != null) {
        // GIF style
        if (imageData.palette.colors != null) {
            for (int i = 0; i < imageData.palette.colors.length; i++) {
                if (i != imageData.transparentPixel) {
                    RGB rgb = imageData.palette.colors[i];
                    imageData.palette.colors[i] = changeHue(rgb, databaseObjectTreeObject);
                }
            }
        } else // PNG style and Linux
        {
            for (int i = 0; i < imageData.height; i++) {
                for (int j = 0; j < imageData.width; j++) {
                    RGB rgb = imageData.palette.getRGB(imageData.getPixel(j, i));
                    imageData.setPixel(j, i, imageData.palette.getPixel(changeHue(rgb, databaseObjectTreeObject)));
                }
            }
        }
    }
    return imageData;
}
Also used : PropertyTableRowTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject) DesignDocumentFunctionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentFunctionTreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) ImageData(org.eclipse.swt.graphics.ImageData) DesignDocumentViewTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentViewTreeObject) FolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject) RGB(org.eclipse.swt.graphics.RGB) PropertyTableColumnTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableColumnTreeObject) PropertyTableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableTreeObject)

Example 8 with DesignDocumentViewTreeObject

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

the class ViewLabelProvider method getImage.

@Override
public Image getImage(Object obj) {
    try {
        String iconName = "/com/twinsoft/convertigo/beans/core/images/default_color_16x16.png";
        Image image = null;
        if (obj instanceof UnloadedProjectTreeObject) {
            String imageKey = org.eclipse.ui.ide.IDE.SharedImages.IMG_OBJ_PROJECT_CLOSED;
            image = PlatformUI.getWorkbench().getSharedImages().getImage(imageKey);
        } else if (obj instanceof ResourceTreeObject) {
            ILabelProvider workbenchLabelProvider = WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider();
            image = workbenchLabelProvider.getImage(obj);
        } else if (obj instanceof FolderTreeObject) {
            String imageKey = ISharedImages.IMG_OBJ_FOLDER;
            image = PlatformUI.getWorkbench().getSharedImages().getImage(imageKey);
            FolderTreeObject t_folder = (FolderTreeObject) obj;
            if (t_folder.getParent() instanceof DatabaseObjectTreeObject) {
                DatabaseObjectTreeObject parent = (DatabaseObjectTreeObject) t_folder.getParent();
                if (!parent.isEnabled())
                    image = ViewImageProvider.getImageFromCache(imageKey + "_disable", image, obj);
                else if (parent.hasAncestorDisabled())
                    image = ViewImageProvider.getImageFromCache(imageKey + "_unreachable", image, obj);
            }
        } else if (obj instanceof TemplateTreeObject) {
            String imageKey = ISharedImages.IMG_OBJ_FILE;
            image = PlatformUI.getWorkbench().getSharedImages().getImage(imageKey);
        } else if (obj instanceof HandlersDeclarationTreeObject) {
            String imageKey = ISharedImages.IMG_OBJ_ELEMENT;
            image = PlatformUI.getWorkbench().getSharedImages().getImage(imageKey);
        } else if (obj instanceof TraceTreeObject) {
            String imageKey = ISharedImages.IMG_OBJ_ELEMENT;
            image = PlatformUI.getWorkbench().getSharedImages().getImage(imageKey);
        } else if (obj instanceof VariableTreeObject2) {
            VariableTreeObject2 variableTreeObject = (VariableTreeObject2) obj;
            iconName = MySimpleBeanInfo.getIconName(variableTreeObject.databaseObjectBeanInfo, BeanInfo.ICON_COLOR_16x16);
            if (iconName == null) {
                iconName = "/com/twinsoft/convertigo/beans/core/images/variable_color_16x16.png";
            }
            image = ViewImageProvider.getImageFromCache(iconName, variableTreeObject);
        } else if (obj instanceof DatabaseObjectTreeObject) {
            DatabaseObjectTreeObject databaseObjectTreeObject = (DatabaseObjectTreeObject) obj;
            iconName = MySimpleBeanInfo.getIconName(databaseObjectTreeObject.getObject(), BeanInfo.ICON_COLOR_16x16);
            image = ViewImageProvider.getImageFromCache(iconName, databaseObjectTreeObject);
        } else if (obj instanceof PropertyTableTreeObject) {
            iconName = "/com/twinsoft/convertigo/beans/core/images/bean_property_16x16.png";
            image = ViewImageProvider.getImageFromCache(iconName, (PropertyTableTreeObject) obj);
        } else if (obj instanceof PropertyTableRowTreeObject) {
            iconName = "/com/twinsoft/convertigo/beans/core/images/bean_property_16x16.png";
            image = ViewImageProvider.getImageFromCache(iconName, (PropertyTableRowTreeObject) obj);
        } else if (obj instanceof PropertyTableColumnTreeObject) {
            iconName = "/com/twinsoft/convertigo/beans/core/images/bean_property_16x16.png";
            image = ViewImageProvider.getImageFromCache(iconName, (PropertyTableColumnTreeObject) obj);
        } else if (obj instanceof DesignDocumentViewTreeObject) {
            iconName = "/com/twinsoft/convertigo/beans/couchdb/images/view_color_16x16.png";
            image = ViewImageProvider.getImageFromCache(iconName, (DesignDocumentViewTreeObject) obj);
        } else if (obj instanceof DesignDocumentFunctionTreeObject) {
            iconName = "/com/twinsoft/convertigo/beans/couchdb/images/function_color_16x16.png";
            image = ViewImageProvider.getImageFromCache(iconName, (DesignDocumentFunctionTreeObject) obj);
        } else {
            throw new IllegalArgumentException("Unexpected tree item object");
        }
        return image;
    } catch (Exception e) {
        String message = "Error while getting tree view item image for object [" + obj.getClass().getName() + "] " + obj.toString();
        ConvertigoPlugin.logException(e, message);
        String imageKey = ISharedImages.IMG_OBJ_ELEMENT;
        if (obj instanceof TreeParent) {
            imageKey = ISharedImages.IMG_OBJ_FOLDER;
        }
        return PlatformUI.getWorkbench().getSharedImages().getImage(imageKey);
    }
}
Also used : PropertyTableRowTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) TemplateTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TemplateTreeObject) DesignDocumentViewTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentViewTreeObject) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) Image(org.eclipse.swt.graphics.Image) DesignDocumentFunctionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentFunctionTreeObject) UnloadedProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UnloadedProjectTreeObject) HandlersDeclarationTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.HandlersDeclarationTreeObject) ResourceTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ResourceTreeObject) TraceTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TraceTreeObject) FolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject) VariableTreeObject2(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.VariableTreeObject2) PropertyTableColumnTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableColumnTreeObject) PropertyTableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableTreeObject)

Example 9 with DesignDocumentViewTreeObject

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

the class ViewExecuteSelectedAction method run.

@Override
public void run() {
    Display display = Display.getDefault();
    Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
    Shell shell = getParentShell();
    shell.setCursor(waitCursor);
    try {
        ProjectExplorerView explorerView = getProjectExplorerView();
        if (explorerView != null) {
            TreeObject treeObject = explorerView.getFirstSelectedTreeObject();
            if ((treeObject != null) && (treeObject instanceof DesignDocumentViewTreeObject)) {
                DesignDocumentViewTreeObject viewTreeObject = (DesignDocumentViewTreeObject) treeObject;
                DesignDocumentTreeObject ddto = (DesignDocumentTreeObject) viewTreeObject.getTreeObjectOwner();
                ConnectorTreeObject cto = (ConnectorTreeObject) ddto.getOwnerDatabaseObjectTreeObject();
                ProjectTreeObject projectTreeObject = cto.getProjectTreeObject();
                CouchDbConnector connector = (CouchDbConnector) cto.getObject();
                cto.openConnectorEditor();
                ConnectorEditor connectorEditor = projectTreeObject.getConnectorEditor(connector);
                if (connectorEditor != null) {
                    // activate connector's editor
                    getActivePage().activate(connectorEditor);
                    // set transaction's parameters
                    Transaction transaction = connector.getTransactionByName(CouchDbConnector.internalView);
                    ((GetViewTransaction) transaction).setViewname(viewTreeObject.getDocViewName());
                    Variable view_reduce = ((GetViewTransaction) transaction).getVariable(CouchParam.prefix + "reduce");
                    view_reduce.setValueOrNull(viewTreeObject.hasReduce() ? isReduceRequested() : false);
                    // execute view transaction
                    connectorEditor.getDocument(CouchDbConnector.internalView, isStubRequested());
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to execute the selected view!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) Variable(com.twinsoft.convertigo.beans.core.Variable) DesignDocumentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentTreeObject) DesignDocumentViewTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentViewTreeObject) Cursor(org.eclipse.swt.graphics.Cursor) ConnectorEditor(com.twinsoft.convertigo.eclipse.editors.connector.ConnectorEditor) CouchDbConnector(com.twinsoft.convertigo.beans.connectors.CouchDbConnector) ConnectorTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ConnectorTreeObject) Shell(org.eclipse.swt.widgets.Shell) GetViewTransaction(com.twinsoft.convertigo.beans.transactions.couchdb.GetViewTransaction) GetViewTransaction(com.twinsoft.convertigo.beans.transactions.couchdb.GetViewTransaction) Transaction(com.twinsoft.convertigo.beans.core.Transaction) DesignDocumentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentTreeObject) DesignDocumentViewTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentViewTreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) ConnectorTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ConnectorTreeObject) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject) Display(org.eclipse.swt.widgets.Display)

Aggregations

DesignDocumentViewTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentViewTreeObject)9 DesignDocumentTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentTreeObject)7 FolderTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject)6 DesignDocumentFunctionTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentFunctionTreeObject)5 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)5 Shell (org.eclipse.swt.widgets.Shell)5 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)4 DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)4 CompositeEvent (com.twinsoft.convertigo.eclipse.editors.CompositeEvent)3 TreeParent (com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent)3 ConnectorTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ConnectorTreeObject)3 ProjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 Cursor (org.eclipse.swt.graphics.Cursor)3 Display (org.eclipse.swt.widgets.Display)3 HandlersDeclarationTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.HandlersDeclarationTreeObject)2 PropertyTableColumnTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableColumnTreeObject)2 PropertyTableRowTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject)2 PropertyTableTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableTreeObject)2 CouchDbConnector (com.twinsoft.convertigo.beans.connectors.CouchDbConnector)1