Search in sources :

Example 1 with ICompareInputLabelProvider

use of org.eclipse.compare.ICompareInputLabelProvider in project tdq-studio-se by Talend.

the class ModelElementCompareEditorLauncher method open.

@Override
public void open(IPath file) {
    try {
        // final EObject snapshot = ModelUtils.load(file.toFile(), new ResourceSetImpl());
        // if (snapshot instanceof ComparisonResourceSnapshot) {
        CompareConfiguration comapreConfiguration = new CompareConfiguration();
        comapreConfiguration.setDefaultLabelProvider(new ICompareInputLabelProvider() {

            @Override
            public Image getAncestorImage(Object input) {
                return null;
            }

            @Override
            public String getAncestorLabel(Object input) {
                // $NON-NLS-1$
                return "";
            }

            @Override
            public Image getLeftImage(Object input) {
                return null;
            }

            @Override
            public String getLeftLabel(Object input) {
                // $NON-NLS-1$
                String showLabel = Messages.getString("ModelElementCompareEditorLauncher.LocalStructure", connectionName);
                if (compareEachOther) {
                    // $NON-NLS-1$
                    showLabel = Messages.getString("ModelElementCompareEditorLauncher.FirstElement");
                }
                return showLabel;
            }

            @Override
            public Image getRightImage(Object input) {
                return null;
            }

            @Override
            public String getRightLabel(Object input) {
                // $NON-NLS-1$
                String showLabel = Messages.getString("ModelElementCompareEditorLauncher.DistantStructure");
                if (compareEachOther) {
                    // $NON-NLS-1$
                    showLabel = Messages.getString("ModelElementCompareEditorLauncher.SecondElement");
                }
                return showLabel;
            }

            @Override
            public Image getImage(Object element) {
                return null;
            }

            @Override
            public String getText(Object element) {
                // $NON-NLS-1$
                return Messages.getString("ModelElementCompareEditorLauncher.TextLabel");
            }

            @Override
            public void addListener(ILabelProviderListener listener) {
            // needn't to do anything ???
            }

            @Override
            public void dispose() {
            // needn't to do anything ???
            }

            @Override
            public boolean isLabelProperty(Object element, String property) {
                return false;
            }

            @Override
            public void removeListener(ILabelProviderListener listener) {
            // needn't to do anything ???
            }
        });
        // ModelElementCompareEditorInput compEditorInput = new ModelElementCompareEditorInput(
        // (ComparisonResourceSnapshot) snapshot, comapreConfiguration, selectedObject);
        // MOD mzhao bug 8581 Add the specific title for comparison
        // editor.
        // $NON-NLS-1$
        String editorTitle = Messages.getString("ModelElementCompareEditorLauncher.Compare");
        if (selectedObject instanceof IFile) {
            editorTitle = PrvResourceFileHelper.getInstance().findProvider((IFile) selectedObject).getName();
        } else if (selectedObject instanceof IFolderNode) {
            editorTitle = ((ModelElement) ((IFolderNode) selectedObject).getParent()).getName();
        } else if (selectedObject instanceof Catalog) {
            editorTitle = ((Catalog) selectedObject).getName();
        } else if (selectedObject instanceof IRepositoryViewObject) {
            editorTitle = ((ConnectionItem) ((IRepositoryViewObject) selectedObject).getProperty().getItem()).getConnection().getName();
        } else if (selectedObject instanceof Connection) {
            editorTitle = ((Connection) selectedObject).getName();
        }
    // compEditorInput.setTitle(editorTitle);
    // CompareUI.openCompareEditor(compEditorInput);
    // compEditorInput.hookLeftPanelContextMenu(compareEachOther);
    // compEditorInput.hookToolBar(compareEachOther);
    // }
    // } catch (IOException e) {
    } catch (Exception e) {
        // Fichier non lisible
        System.out.println(e);
        assert false;
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) CompareConfiguration(org.eclipse.compare.CompareConfiguration) ICompareInputLabelProvider(org.eclipse.compare.ICompareInputLabelProvider) Connection(org.talend.core.model.metadata.builder.connection.Connection) Image(org.eclipse.swt.graphics.Image) Catalog(orgomg.cwm.resource.relational.Catalog) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) IFolderNode(org.talend.dq.nodes.foldernode.IFolderNode) ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject)

Aggregations

CompareConfiguration (org.eclipse.compare.CompareConfiguration)1 ICompareInputLabelProvider (org.eclipse.compare.ICompareInputLabelProvider)1 IFile (org.eclipse.core.resources.IFile)1 ILabelProviderListener (org.eclipse.jface.viewers.ILabelProviderListener)1 Image (org.eclipse.swt.graphics.Image)1 Connection (org.talend.core.model.metadata.builder.connection.Connection)1 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)1 IFolderNode (org.talend.dq.nodes.foldernode.IFolderNode)1 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)1 Catalog (orgomg.cwm.resource.relational.Catalog)1