Search in sources :

Example 6 with AbstractItemEditorInput

use of org.talend.dataprofiler.core.ui.editor.AbstractItemEditorInput in project tdq-studio-se by Talend.

the class RenameTdqFolderAction method getFirstOpenedChild.

/*
     * MOD 20130530 TDQ-7143, when any items are opened under the current folder, should not let it be renamed
     */
@Override
protected String getFirstOpenedChild(IRepositoryNode node) {
    if (node.hasChildren()) {
        IWorkbenchPage page = getActivePage();
        IEditorReference[] editorReferences = page.getEditorReferences();
        List<String> openEditor = new ArrayList<String>();
        List<IRepositoryNode> children = node.getChildren();
        for (IEditorReference tmpInput : editorReferences) {
            try {
                IEditorInput editorInput = tmpInput.getEditorInput();
                if (editorInput instanceof AbstractItemEditorInput) {
                    AbstractItemEditorInput einput = (AbstractItemEditorInput) editorInput;
                    openEditor.add(einput.getItem().getProperty().getId());
                } else if (editorInput instanceof FileEditorInput) {
                    if (editorInput instanceof FileEditorInput) {
                        FileEditorInput fileInput = (FileEditorInput) editorInput;
                        for (IRepositoryNode currentNode : children) {
                            IFile nodeFile = RepositoryNodeHelper.getIFile(currentNode);
                            if (nodeFile != null && nodeFile.getFullPath().toString().equals(fileInput.getFile().getFullPath().toString())) {
                                return currentNode.getObject().getLabel();
                            }
                        }
                    }
                }
            } catch (PartInitException e) {
                ExceptionHandler.process(e, Level.WARN);
            }
        }
        for (IRepositoryNode currentNode : children) {
            if (currentNode.getType() == ENodeType.REPOSITORY_ELEMENT) {
                if (openEditor.contains(currentNode.getObject().getId())) {
                    return currentNode.getObject().getLabel();
                }
            } else if (currentNode.getType() == ENodeType.SIMPLE_FOLDER) {
                String childOpen = getFirstOpenedChild(currentNode);
                if (childOpen != null) {
                    return childOpen;
                }
            }
        }
    }
    return null;
}
Also used : IFile(org.eclipse.core.resources.IFile) IRepositoryNode(org.talend.repository.model.IRepositoryNode) AbstractItemEditorInput(org.talend.dataprofiler.core.ui.editor.AbstractItemEditorInput) ArrayList(java.util.ArrayList) IEditorReference(org.eclipse.ui.IEditorReference) FileEditorInput(org.eclipse.ui.part.FileEditorInput) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) IEditorInput(org.eclipse.ui.IEditorInput)

Aggregations

IEditorInput (org.eclipse.ui.IEditorInput)6 IEditorReference (org.eclipse.ui.IEditorReference)6 PartInitException (org.eclipse.ui.PartInitException)6 AbstractItemEditorInput (org.talend.dataprofiler.core.ui.editor.AbstractItemEditorInput)6 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)5 ArrayList (java.util.ArrayList)3 TreeItem (org.eclipse.swt.widgets.TreeItem)2 FileEditorInput (org.eclipse.ui.part.FileEditorInput)2 ConnectionItem (org.talend.core.model.properties.ConnectionItem)2 Item (org.talend.core.model.properties.Item)2 Property (org.talend.core.model.properties.Property)2 IRepositoryNode (org.talend.repository.model.IRepositoryNode)2 IFile (org.eclipse.core.resources.IFile)1 IPath (org.eclipse.core.runtime.IPath)1 IWorkbenchPartReference (org.eclipse.ui.IWorkbenchPartReference)1 OpenItemEditorAction (org.talend.dataprofiler.core.ui.action.actions.OpenItemEditorAction)1 CommonFormEditor (org.talend.dataprofiler.core.ui.editor.CommonFormEditor)1 AnalysisItemEditorInput (org.talend.dataprofiler.core.ui.editor.analysis.AnalysisItemEditorInput)1 DQRespositoryView (org.talend.dataprofiler.core.ui.views.DQRespositoryView)1