Package de.innovationgate.eclipse.editors.models

Source Code of de.innovationgate.eclipse.editors.models.WGASchemaDefinitionLabelProvider

/*******************************************************************************
* Copyright (c) 2009, 2010 Innovation Gate GmbH.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
*     Innovation Gate GmbH - initial API and implementation
******************************************************************************/

package de.innovationgate.eclipse.editors.models;

import org.eclipse.jface.resource.FontRegistry;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.IFontDecorator;
import org.eclipse.jface.viewers.IFontProvider;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.texteditor.AddMarkerAction;

import de.innovationgate.eclipse.editors.Plugin;
import de.innovationgate.eclipse.editors.design.dialogs.AddContentTypeMetaDefinitionDialog;
import de.innovationgate.webgate.api.schemadef.WGAreaDefinition;
import de.innovationgate.webgate.api.schemadef.WGContentItemDefinition;
import de.innovationgate.webgate.api.schemadef.WGContentTypeDefinition;
import de.innovationgate.webgate.api.schemadef.WGLanguageDefinition;
import de.innovationgate.webgate.api.schemadef.WGMetaFieldDefinition;
import de.innovationgate.webgate.api.schemadef.WGSchemaDocumentDefinition;

public class WGASchemaDefinitionLabelProvider implements ILabelProvider, IColorProvider, IFontProvider {

    public Image getImage(Object node) {
        if (node instanceof String) {
            return Plugin.getDefault().getImageRegistry().get(Plugin.IMAGE_SCHEMADEFINITION_CATEGORY);
        } else if (node instanceof WGContentTypeDefinition) {
            return Plugin.getDefault().getImageRegistry().get(Plugin.IMAGE_CONTENT_TYPE_DEFINITION);
        } else if (node instanceof WGContentItemDefinition) {
            return Plugin.getDefault().getImageRegistry().get(Plugin.IMAGE_CONTENT_ITEM_DEFINITION);
        } else if (node instanceof WGMetaFieldDefinition) {
            return Plugin.getDefault().getImageRegistry().get(Plugin.IMAGE_METAFIELD_DEFINITION);
        } else if (node instanceof WGAreaDefinition) {
            return Plugin.getDefault().getImageRegistry().get(Plugin.IMAGE_AREA_DEFINITION);
        } else if (node instanceof WGLanguageDefinition) {
            return Plugin.getDefault().getImageRegistry().get(Plugin.IMAGE_LANGUAGE_DEFINITION);
        }
        return null;
    }

    public String getText(Object node) {
        if (node instanceof String) {
            return (String)node;
        } else if (node instanceof WGSchemaDocumentDefinition) {
            WGSchemaDocumentDefinition def = (WGSchemaDocumentDefinition) node;
            return def.getName();
        } else if (node instanceof WGContentItemDefinition) {
            WGContentItemDefinition def = (WGContentItemDefinition) node;
            return def.getName();
        } else if (node instanceof WGMetaFieldDefinition) {
            WGMetaFieldDefinition def = (WGMetaFieldDefinition) node;
            return AddContentTypeMetaDefinitionDialog.METADATA_DEFINITION_LABELS.get(def.getName());
        }
        return null;
    }

    public void addListener(ILabelProviderListener arg0) {
        // TODO Auto-generated method stub

    }

    public void dispose() {
        // TODO Auto-generated method stub

    }

    public boolean isLabelProperty(Object arg0, String arg1) {
        // TODO Auto-generated method stub
        return false;
    }

    public void removeListener(ILabelProviderListener arg0) {
        // TODO Auto-generated method stub

    }

    public Color getBackground(Object node) {
        if (node instanceof String) {
            return new Color(Display.getCurrent(), 200,200,200);
        }
        return null;
    }

    public Color getForeground(Object arg0) {
        // TODO Auto-generated method stub
        return null;
    }

    public Font getFont(Object element) {
        if (element instanceof String) {
            FontData[] fds = JFaceResources.getFontRegistry().defaultFont().getFontData();
            for (FontData data : fds) {
                data.setStyle(SWT.BOLD);
            }
            return new Font(Display.getCurrent(), fds);
        }
        return null;
    }

   

}
TOP

Related Classes of de.innovationgate.eclipse.editors.models.WGASchemaDefinitionLabelProvider

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.