Search in sources :

Example 1 with TemplateTreeObject

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

the class ProjectExplorerView method addTemplates.

private void addTemplates(Sheet sheet, DatabaseObjectTreeObject treeObject) {
    TemplateTreeObject templateTreeObject;
    String xslFileName = sheet.getUrl();
    try {
        // Refresh project resource
        IProject project = ConvertigoPlugin.getDefault().getProjectPluginResource(sheet.getProject().getName());
        IFile file = project.getFile(new Path(xslFileName));
        if (file.exists()) {
            Document doc = parseXslFile(file);
            NodeList nl = doc.getElementsByTagName("xsl:include");
            for (int i = 0; i < nl.getLength(); i++) {
                Node node = nl.item(i);
                NamedNodeMap attributes = node.getAttributes();
                Node href = attributes.getNamedItem("href");
                String name = href.getNodeValue();
                // do not add includes statring by ../ as there are system includes
                if (!name.startsWith("../")) {
                    templateTreeObject = new TemplateTreeObject(viewer, "[" + name.substring(name.lastIndexOf('/') + 1, name.lastIndexOf('.')) + "]", name);
                    treeObject.addChild(templateTreeObject);
                }
            }
        }
    } catch (CoreException e) {
        ConvertigoPlugin.logInfo("Error opening Ressources for project '" + sheet.getProject().getName() + "': " + e.getMessage());
    } catch (Exception ee) {
        ConvertigoPlugin.logInfo("Error Parsing XSL file '" + xslFileName + "': " + ee.getMessage());
    }
}
Also used : Path(org.eclipse.core.runtime.Path) IFile(org.eclipse.core.resources.IFile) NamedNodeMap(org.w3c.dom.NamedNodeMap) CoreException(org.eclipse.core.runtime.CoreException) TemplateTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TemplateTreeObject) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Document(org.w3c.dom.Document) IProject(org.eclipse.core.resources.IProject) Point(org.eclipse.swt.graphics.Point) IOException(java.io.IOException) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) InvocationTargetException(java.lang.reflect.InvocationTargetException) EngineException(com.twinsoft.convertigo.engine.EngineException)

Example 2 with TemplateTreeObject

use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TemplateTreeObject 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)

Aggregations

TemplateTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TemplateTreeObject)2 DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)1 DesignDocumentFunctionTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentFunctionTreeObject)1 DesignDocumentViewTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentViewTreeObject)1 FolderTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject)1 HandlersDeclarationTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.HandlersDeclarationTreeObject)1 PropertyTableColumnTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableColumnTreeObject)1 PropertyTableRowTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject)1 PropertyTableTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableTreeObject)1 ResourceTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ResourceTreeObject)1 TraceTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TraceTreeObject)1 UnloadedProjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UnloadedProjectTreeObject)1 VariableTreeObject2 (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.VariableTreeObject2)1 EngineException (com.twinsoft.convertigo.engine.EngineException)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 IFile (org.eclipse.core.resources.IFile)1 IProject (org.eclipse.core.resources.IProject)1 CoreException (org.eclipse.core.runtime.CoreException)1 Path (org.eclipse.core.runtime.Path)1