Java Code Examples for org.eclipse.ui.IEditorInput#equals()

The following examples show how to use org.eclipse.ui.IEditorInput#equals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CrossflowMatchingStrategy.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
/**
* @generated
*/
public boolean matches(IEditorReference editorRef, IEditorInput input) {
	IEditorInput editorInput;
	try {
		editorInput = editorRef.getEditorInput();
	} catch (PartInitException e) {
		return false;
	}

	if (editorInput.equals(input)) {
		return true;
	}
	if (editorInput instanceof URIEditorInput && input instanceof URIEditorInput) {
		return ((URIEditorInput) editorInput).getURI().equals(((URIEditorInput) input).getURI());
	}
	return false;
}
 
Example 2
Source File: TypeScriptMergeViewer.java    From typescript.java with MIT License 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public Object getAdapter(Class adapter) {
	if (adapter == ITextEditorExtension3.class) {
		IEditorInput activeInput = (IEditorInput) super.getAdapter(IEditorInput.class);
		if (activeInput != null) {
			for (Iterator<TypeScriptEditorAdapter> iterator = fEditor.values().iterator(); iterator.hasNext();) {
				TypeScriptEditorAdapter editor = iterator.next();
				if (activeInput.equals(editor.getEditorInput()))
					return editor;
			}
		}
		return null;
	}
	return super.getAdapter(adapter);
}
 
Example 3
Source File: TmfOpenTraceHelper.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Returns the editor with the specified input. Returns null if there is no
 * opened editor with that input. If restore is requested, the method finds and
 * returns the editor even if it is not restored yet after a restart.
 *
 * @param input
 *            the editor input
 * @param restore
 *            true if the editor should be restored
 * @return an editor with input equals to <code>input</code>
 */
private static IEditorPart findEditor(IEditorInput input, boolean restore) {
    final IWorkbench wb = PlatformUI.getWorkbench();
    final IWorkbenchPage activePage = wb.getActiveWorkbenchWindow().getActivePage();
    for (IEditorReference editorReference : activePage.getEditorReferences()) {
        try {
            IEditorInput editorInput = editorReference.getEditorInput();
            if (editorInput.equals(input)) {
                return editorReference.getEditor(restore);
            }
        } catch (PartInitException e) {
            // do nothing
        }
    }
    return null;
}
 
Example 4
Source File: BaseEditor.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @return true if the editor passed as a parameter has the same input as this editor.
 */
@Override
public boolean hasSameInput(IBaseEditor edit) {
    IEditorInput thisInput = this.getEditorInput();
    IEditorInput otherInput = (IEditorInput) edit.getEditorInput();
    if (thisInput == null || otherInput == null) {
        return false;
    }

    if (thisInput == otherInput || thisInput.equals(otherInput)) {
        return true;
    }

    IResource r1 = thisInput.getAdapter(IResource.class);
    IResource r2 = otherInput.getAdapter(IResource.class);
    if (r1 == null || r2 == null) {
        return false;
    }
    if (r1.equals(r2)) {
        return true;
    }
    return false;
}
 
Example 5
Source File: ProcessMatchingStrategy.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
* @generated
*/
public boolean matches(IEditorReference editorRef, IEditorInput input) {
	IEditorInput editorInput;
	try {
		editorInput = editorRef.getEditorInput();
	} catch (PartInitException e) {
		return false;
	}

	if (editorInput.equals(input)) {
		return true;
	}
	if (editorInput instanceof URIEditorInput && input instanceof URIEditorInput) {
		return ((URIEditorInput) editorInput).getURI().equals(((URIEditorInput) input).getURI());
	}
	return false;
}
 
Example 6
Source File: PackageExplorerPart.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private boolean inputIsSelected(IEditorInput input) {
	IStructuredSelection selection= (IStructuredSelection)fViewer.getSelection();
	if (selection.size() != 1)
		return false;

	IEditorInput selectionAsInput= EditorUtility.getEditorInput(selection.getFirstElement());
	return input.equals(selectionAsInput);
}
 
Example 7
Source File: JavaMergeViewer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Object getAdapter(Class adapter) {
	if (adapter == ITextEditorExtension3.class) {
		IEditorInput activeInput= (IEditorInput)super.getAdapter(IEditorInput.class);
		if (activeInput != null) {
			for (Iterator<CompilationUnitEditorAdapter> iterator= fEditor.values().iterator(); iterator.hasNext();) {
				CompilationUnitEditorAdapter editor= iterator.next();
				if (activeInput.equals(editor.getEditorInput()))
					return editor;
			}
		}
		return null;
	}
	return super.getAdapter(adapter);
}
 
Example 8
Source File: ClassFileEditor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private boolean isEqualInput(IEditorInput input1, IEditorInput input2) {
	return input1 != null && input1.equals(input2);
}
 
Example 9
Source File: IDeduplication.java    From e4macs with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Compare two editor instances
 * @param a
 * @param b
 * @return true if different editor instances are looking at the same content 
 * @throws PartInitException
 */
public static boolean editorsMatch(IEditorReference a, IEditorInput ai, IEditorReference b) throws PartInitException {
	return (a != b  && ai.equals(b.getEditorInput()));
}