Search in sources :

Example 46 with RepositoryContext

use of org.talend.core.context.RepositoryContext in project tdq-studio-se by Talend.

the class DQRepositoryViewLabelProvider method getImage.

@Override
public Image getImage(Object element) {
    Image image = super.getImage(element);
    if (element instanceof IRepositoryNode) {
        IRepositoryNode node = (IRepositoryNode) element;
        if (node instanceof ReportAnalysisRepNode) {
            image = ImageLib.getImage(ImageLib.ANALYSIS_OBJECT);
        } else if (node instanceof ExchangeCategoryRepNode || node instanceof ExchangeComponentRepNode) {
            image = ImageLib.getImage(ImageLib.EXCHANGE);
        } else if (node instanceof RecycleBinRepNode) {
            image = ImageLib.getImage(ImageLib.RECYCLEBIN_EMPTY);
        } else {
            IRepositoryViewObject viewObject = node.getObject();
            ENodeType type = node.getType();
            if (type.equals(ENodeType.SYSTEM_FOLDER)) {
                if (EResourceConstant.REFERENCED_PROJECT.getName().equals(node.getProperties(EProperties.LABEL))) {
                    image = ImageLib.getImage(ImageLib.REFERENCED_PROJECT);
                } else {
                    String label = viewObject.getLabel();
                    if (label.equals(EResourceConstant.DATA_PROFILING.getName())) {
                        image = ImageLib.getImage(ImageLib.DATA_PROFILING);
                    } else if (label.equals(EResourceConstant.METADATA.getName())) {
                        image = ImageLib.getImage(ImageLib.METADATA);
                    } else if (node instanceof DBConnectionFolderRepNode) {
                        image = ImageLib.getImage(ImageLib.CONNECTION);
                    } else if (label.equals(EResourceConstant.FILEDELIMITED.getName())) {
                        image = ImageLib.getImage(ImageLib.FILE_DELIMITED);
                    } else if (label.equals(EResourceConstant.LIBRARIES.getName())) {
                        image = ImageLib.getImage(ImageLib.LIBRARIES);
                    } else if (label.equals(EResourceConstant.EXCHANGE.getName())) {
                        image = ImageLib.getImage(ImageLib.EXCHANGE);
                    } else if (label.equals(EResourceConstant.HADOOP_CLUSTER.getName())) {
                        image = ImageLib.getImage(ImageLib.HADOOP_CLUSTER);
                    } else if (label.equals(EResourceConstant.CONTEXT.getName())) {
                        image = ImageLib.getImage(ImageLib.CONTEXT);
                    } else {
                        image = ImageLib.getImage(ImageLib.FOLDERNODE_IMAGE);
                    }
                }
            } else if (type.equals(ENodeType.SIMPLE_FOLDER)) {
                image = ImageLib.getImage(ImageLib.FOLDERNODE_IMAGE);
            } else if (type.equals(ENodeType.REFERENCED_PROJECT)) {
                image = ImageLib.getImage(ImageLib.REFERENCED_PROJECT);
            } else if (type.equals(ENodeType.REPOSITORY_ELEMENT)) {
                // TDQ-7560 when the image is a overlay image,use originalImageName to get the corresponding one.
                String originalImageName = null;
                if (node instanceof DBConnectionRepNode) {
                    originalImageName = ImageLib.TD_DATAPROVIDER;
                    if (!RepositoryNodeHelper.isSupportedConnection(node) || isNeedAddDriverConnection(node)) {
                        image = ImageLib.createErrorIcon(originalImageName);
                    } else if (isInvalidJDBCConnection(node)) {
                        image = ImageLib.createInvalidIcon(originalImageName);
                    } else {
                        image = ImageLib.getImage(originalImageName);
                    }
                } else if (node instanceof DFConnectionRepNode) {
                    originalImageName = ImageLib.FILE_DELIMITED;
                } else if (node instanceof AnalysisRepNode) {
                    originalImageName = ImageLib.ANALYSIS_OBJECT;
                    image = addWarnIconIfNeeded(node, originalImageName);
                } else if (node instanceof ReportRepNode) {
                    originalImageName = ImageLib.REPORT_OBJECT;
                    image = addWarnIconIfNeeded(node, originalImageName);
                } else if (node instanceof SysIndicatorDefinitionRepNode) {
                    originalImageName = ImageLib.IND_DEFINITION;
                } else if (node instanceof PatternRepNode) {
                    originalImageName = ImageLib.PATTERN_REG;
                } else if (node instanceof RuleRepNode) {
                    if (((RuleRepNode) node).getRule() instanceof MatchRuleDefinition) {
                        originalImageName = ImageLib.MATCH_RULE_ICON;
                    } else {
                        originalImageName = ImageLib.DQ_RULE;
                    }
                } else if (node instanceof SourceFileRepNode) {
                    originalImageName = ImageLib.SOURCE_FILE;
                } else if (node instanceof HadoopClusterConnectionRepNode) {
                    originalImageName = ImageLib.HADOOP_CLUSTER;
                } else if (node instanceof HDFSOfHCConnectionNode) {
                    originalImageName = ImageLib.HDFS;
                } else if (node instanceof HiveOfHCConnectionNode) {
                    originalImageName = ImageLib.HIVE_LINK;
                } else if (node instanceof ExchangeCategoryRepNode || node instanceof ExchangeComponentRepNode) {
                    originalImageName = ImageLib.EXCHANGE;
                } else if (node instanceof ContextRepNode) {
                    originalImageName = ImageLib.CONTEXT;
                } else if (node instanceof RepositoryNode) {
                    // MOD qiongli 2011-1-18 get image for nodes in recycle bin
                    Image imageNode = getImageByContentType((RepositoryNode) node);
                    if (image != null) {
                        image = imageNode;
                    }
                }
                if (originalImageName != null && !(node instanceof DBConnectionRepNode || node instanceof AnalysisRepNode || node instanceof ReportRepNode)) {
                    image = ImageLib.getImage(originalImageName);
                }
                // exchange folder did not contain viewObject.
                if (viewObject != null) {
                    // MOD yyi 2011-04-07 19696: "Lock element"
                    ERepositoryStatus status = ProxyRepositoryFactory.getInstance().getStatus(viewObject);
                    Context ctx = CoreRuntimePlugin.getInstance().getContext();
                    RepositoryContext rc = (RepositoryContext) ctx.getProperty(Context.REPOSITORY_CONTEXT_KEY);
                    // will be enhanced later by TDI-29265.
                    if (rc.isEditableAsReadOnly()) {
                        if (status == ERepositoryStatus.LOCK_BY_USER) {
                            status = ERepositoryStatus.DEFAULT;
                        }
                    }
                    if (ERepositoryStatus.DEFAULT != status && originalImageName != null) {
                        if (ERepositoryStatus.LOCK_BY_USER == status) {
                            image = ImageLib.createLockedByOwnIcon(originalImageName);
                        } else if (ERepositoryStatus.LOCK_BY_OTHER == status) {
                            image = ImageLib.createLockedByOtherIcon(originalImageName);
                        }
                    }
                }
            } else if (type.equals(ENodeType.TDQ_REPOSITORY_ELEMENT)) {
                if (node instanceof DBCatalogRepNode) {
                    image = ImageLib.getImage(ImageLib.CATALOG);
                } else if (node instanceof DBSchemaRepNode) {
                    image = ImageLib.getImage(ImageLib.SCHEMA);
                } else if (node instanceof DBTableFolderRepNode) {
                    image = ImageLib.getImage(ImageLib.FOLDERNODE_IMAGE);
                } else if (node instanceof DBViewFolderRepNode) {
                    image = ImageLib.getImage(ImageLib.FOLDERNODE_IMAGE);
                } else if (node instanceof DBTableRepNode || node instanceof DFTableRepNode) {
                    image = ImageLib.getImage(ImageLib.TABLE);
                } else if (node instanceof DBViewRepNode) {
                    image = ImageLib.getImage(ImageLib.VIEW);
                } else if (node instanceof DBColumnRepNode) {
                    if (((DBColumnRepNode) node).isKey()) {
                        image = ImageLib.getImage(ImageLib.PK_COLUMN);
                    } else {
                        image = ImageLib.getImage(ImageLib.TD_COLUMN);
                    }
                } else if (node instanceof DFColumnRepNode) {
                    image = ImageLib.getImage(ImageLib.TD_COLUMN);
                } else if (node instanceof DBColumnFolderRepNode || node instanceof DFColumnFolderRepNode) {
                    image = ImageLib.getImage(ImageLib.FOLDERNODE_IMAGE);
                } else if (node instanceof JrxmlTempleteRepNode) {
                    image = ImageLib.getImage(ImageLib.JRXML_ICON);
                }
            }
        }
    }
    return image;
}
Also used : DBConnectionRepNode(org.talend.dq.nodes.DBConnectionRepNode) ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) RepositoryContext(org.talend.core.context.RepositoryContext) HDFSOfHCConnectionNode(org.talend.dq.nodes.hadoopcluster.HDFSOfHCConnectionNode) MatchRuleDefinition(org.talend.dataquality.rules.MatchRuleDefinition) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) Image(org.eclipse.swt.graphics.Image) SourceFileRepNode(org.talend.dq.nodes.SourceFileRepNode) DBViewFolderRepNode(org.talend.dq.nodes.DBViewFolderRepNode) DBCatalogRepNode(org.talend.dq.nodes.DBCatalogRepNode) ReportRepNode(org.talend.dq.nodes.ReportRepNode) ExchangeComponentRepNode(org.talend.dataprofiler.core.ui.exchange.ExchangeComponentRepNode) SysIndicatorDefinitionRepNode(org.talend.dq.nodes.SysIndicatorDefinitionRepNode) DFTableRepNode(org.talend.dq.nodes.DFTableRepNode) DBConnectionFolderRepNode(org.talend.dq.nodes.DBConnectionFolderRepNode) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode) PatternRepNode(org.talend.dq.nodes.PatternRepNode) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext) Context(org.talend.core.context.Context) RepositoryContext(org.talend.core.context.RepositoryContext) DBTableFolderRepNode(org.talend.dq.nodes.DBTableFolderRepNode) DFColumnFolderRepNode(org.talend.dq.nodes.DFColumnFolderRepNode) DBSchemaRepNode(org.talend.dq.nodes.DBSchemaRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) HiveOfHCConnectionNode(org.talend.dq.nodes.hadoopcluster.HiveOfHCConnectionNode) RuleRepNode(org.talend.dq.nodes.RuleRepNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) JrxmlTempleteRepNode(org.talend.dq.nodes.JrxmlTempleteRepNode) RecycleBinRepNode(org.talend.dq.nodes.RecycleBinRepNode) DBColumnFolderRepNode(org.talend.dq.nodes.DBColumnFolderRepNode) DFColumnRepNode(org.talend.dq.nodes.DFColumnRepNode) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) ExchangeCategoryRepNode(org.talend.dataprofiler.core.ui.exchange.ExchangeCategoryRepNode) ReportAnalysisRepNode(org.talend.dq.nodes.ReportAnalysisRepNode) AnalysisRepNode(org.talend.dq.nodes.AnalysisRepNode) DFConnectionRepNode(org.talend.dq.nodes.DFConnectionRepNode) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ENodeType(org.talend.repository.model.IRepositoryNode.ENodeType) HadoopClusterConnectionRepNode(org.talend.dq.nodes.hadoopcluster.HadoopClusterConnectionRepNode) ReportAnalysisRepNode(org.talend.dq.nodes.ReportAnalysisRepNode) ContextRepNode(org.talend.dq.nodes.ContextRepNode)

Example 47 with RepositoryContext

use of org.talend.core.context.RepositoryContext in project tdq-studio-se by Talend.

the class RepositoryNodeBuilder method getFolderHelper.

/**
 * create a Local folder Helper
 *
 * @return Local Folder helper
 *
 * @deprecated use {@link AbstractEMFRepositoryFactory#getFolderHelper()} instead.
 */
@Deprecated
public FolderHelper getFolderHelper() {
    RepositoryContext repositoryContext = (RepositoryContext) CoreRuntimePlugin.getInstance().getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY);
    Project project = null;
    FolderHelper folderHelper = null;
    if (repositoryContext != null) {
        project = repositoryContext.getProject();
        if (project != null) {
            folderHelper = LocalFolderHelper.createInstance(project.getEmfProject(), repositoryContext.getUser());
        }
    }
    return folderHelper;
}
Also used : Project(org.talend.core.model.general.Project) RepositoryContext(org.talend.core.context.RepositoryContext) LocalFolderHelper(org.talend.repository.localprovider.model.LocalFolderHelper) FolderHelper(org.talend.core.repository.model.FolderHelper)

Example 48 with RepositoryContext

use of org.talend.core.context.RepositoryContext in project tdq-studio-se by Talend.

the class UnitTestBuildHelper method initRepositoryContext.

private static void initRepositoryContext(Project project) {
    RepositoryContext repositoryContext = new RepositoryContext();
    Context ctx = CoreRuntimePlugin.getInstance().getContext();
    ctx.putProperty(Context.REPOSITORY_CONTEXT_KEY, repositoryContext);
    repositoryContext.setUser(project.getAuthor());
    repositoryContext.setClearPassword(project.getLabel());
    repositoryContext.setProject(project);
    repositoryContext.setFields(new HashMap<String, String>());
    // repositoryContext.getFields().put(IProxyRepositoryFactory.BRANCH_SELECTION + "_" + project.getTechnicalLabel(), ""); //$NON-NLS-1$ //$NON-NLS-2$
    ProjectManager.getInstance().setMainProjectBranch(project, null);
    ReponsitoryContextBridge.initialized(project.getEmfProject(), project.getAuthor());
// MOD zshen for bug tdq-4757 remove this init from corePlugin.start() to here because the initLocal command of
// commandLine
// SqlExplorerUtils.getDefault().initSqlExplorerRootProject();
}
Also used : RepositoryContext(org.talend.core.context.RepositoryContext) Context(org.talend.core.context.Context) RepositoryContext(org.talend.core.context.RepositoryContext)

Example 49 with RepositoryContext

use of org.talend.core.context.RepositoryContext in project tdq-studio-se by Talend.

the class AbstractCommonActionProviderTest method beforeAllTests.

@BeforeClass
public static void beforeAllTests() {
    Context ctx = CoreRuntimePlugin.getInstance().getContext();
    RepositoryContext repositoryContext = (RepositoryContext) ctx.getProperty(Context.REPOSITORY_CONTEXT_KEY);
    if (repositoryContext != null) {
        originalProject = repositoryContext.getProject();
    }
    repositoryFactory = new LocalRepositoryFactory();
}
Also used : AnalysisContext(org.talend.dataquality.analysis.AnalysisContext) ActionContext(org.eclipse.ui.actions.ActionContext) Context(org.talend.core.context.Context) RepositoryContext(org.talend.core.context.RepositoryContext) RepositoryContext(org.talend.core.context.RepositoryContext) LocalRepositoryFactory(org.talend.repository.localprovider.model.LocalRepositoryFactory) BeforeClass(org.junit.BeforeClass)

Example 50 with RepositoryContext

use of org.talend.core.context.RepositoryContext in project tdq-studio-se by Talend.

the class AbstractCommonActionProviderTest method afterAllTests.

@AfterClass
public static void afterAllTests() {
    repositoryFactory = null;
    if (originalProject != null) {
        Context ctx = CoreRuntimePlugin.getInstance().getContext();
        RepositoryContext repositoryContext = (RepositoryContext) ctx.getProperty(Context.REPOSITORY_CONTEXT_KEY);
        repositoryContext.setProject(originalProject);
    }
}
Also used : AnalysisContext(org.talend.dataquality.analysis.AnalysisContext) ActionContext(org.eclipse.ui.actions.ActionContext) Context(org.talend.core.context.Context) RepositoryContext(org.talend.core.context.RepositoryContext) RepositoryContext(org.talend.core.context.RepositoryContext) AfterClass(org.junit.AfterClass)

Aggregations

RepositoryContext (org.talend.core.context.RepositoryContext)53 Context (org.talend.core.context.Context)28 Project (org.talend.core.model.general.Project)18 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)14 PersistenceException (org.talend.commons.exception.PersistenceException)11 User (org.talend.core.model.properties.User)8 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)7 IProject (org.eclipse.core.resources.IProject)6 AnalysisContext (org.talend.dataquality.analysis.AnalysisContext)6 ECodeLanguage (org.talend.core.language.ECodeLanguage)5 IRepositoryFactory (org.talend.core.repository.model.IRepositoryFactory)5 IRepositoryNodeConfiguration (org.talend.mdm.repository.core.IRepositoryNodeConfiguration)5 IRepositoryNodeResourceProvider (org.talend.mdm.repository.core.IRepositoryNodeResourceProvider)5 Property (org.talend.core.model.properties.Property)4 RecycleBinNodeConfiguration (org.talend.mdm.repository.core.impl.recyclebin.RecycleBinNodeConfiguration)4 File (java.io.File)3 IOException (java.io.IOException)3 ResourceBundle (java.util.ResourceBundle)3 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 ImageRegistry (org.eclipse.jface.resource.ImageRegistry)3