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

The following examples show how to use org.eclipse.ui.IWorkbenchPart#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: AbstractInfoView.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
	if (part.equals(this))
		return;

	fLastSelectionProvider= part;

	if (fLinking)
		computeAndSetInput(part);
}
 
Example 2
Source File: JavaScriptLightWeightEditor.java    From typescript.java with MIT License 4 votes vote down vote up
protected boolean isActivePart() {
	IWorkbenchPart part = getActivePart();
	return part != null && part.equals(this);
}
 
Example 3
Source File: JavaEditor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
protected boolean isActivePart() {
	IWorkbenchPart part= getActivePart();
	return part != null && part.equals(this);
}
 
Example 4
Source File: JavaBrowsingPart.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
	if (!needsToProcessSelectionChanged(part))
		return;

	if (fToggleLinkingAction.isChecked() && (part instanceof IEditorPart)) {
		setSelectionFromEditor(part, selection);
		return;
	}

	// Set selection
	Object selectedElement= getSingleElementFromSelection(selection);

	if (selectedElement != null && (part == null || part.equals(fPreviousSelectionProvider)) && selectedElement.equals(fPreviousSelectedElement))
		return;

	fPreviousSelectedElement= selectedElement;

	Object currentInput= getViewer().getInput();
	if (selectedElement != null && selectedElement.equals(currentInput)) {
		IJavaElement elementToSelect= findElementToSelect(selectedElement);
		if (elementToSelect != null && getTypeComparator().compare((IJavaElement) selectedElement, elementToSelect) < 0)
			setSelection(new StructuredSelection(elementToSelect), true);
		else if (elementToSelect == null && (this instanceof MembersView)) {
			setSelection(StructuredSelection.EMPTY, true);
			fPreviousSelectedElement= StructuredSelection.EMPTY;
		}
		fPreviousSelectionProvider= part;
		return;
	}

	// Clear input if needed
	if (part != fPreviousSelectionProvider && selectedElement != null && !selectedElement.equals(currentInput) && isInputResetBy(selectedElement, currentInput, part)) {
		if (!isAncestorOf(selectedElement, currentInput))
			setInput(null);
		fPreviousSelectionProvider= part;
		return;
	} else if (selection != null && selection.isEmpty() && !isInputResetBy(part)) {
		fPreviousSelectionProvider= part;
		return;
	} else if (selectedElement == null && part == fPreviousSelectionProvider) {
		setInput(null);
		fPreviousSelectionProvider= part;
		return;
	}
	fPreviousSelectionProvider= part;

	// Adjust input and set selection and
	adjustInputAndSetSelection(selectedElement);
}
 
Example 5
Source File: TabbedPropertySheetPage.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Handle the part activated event.
 *
 * @param part
 *            the new activated part.
 */
protected void handlePartActivated(IWorkbenchPart part) {
	/*
	 * The properties view has been activated and the current page is this
	 * instance of TabbedPropertySheetPage
	 */
	boolean thisActivated = part instanceof PropertySheet
		&& ((PropertySheet) part).getCurrentPage() == this;

	/*
	 * When the active part changes and the part does not provide a
	 * selection that affects this property sheet page, the PropertySheet
	 * does not send us a selectionChanged() event. We need to be informed
	 * of these events since we want to send aboutToBeHidden() and
	 * aboutToBeShown() when the property sheet is hidden or shown.
	 */
       if (!thisActivated && !part.equals(contributor)
               && !part.getSite().getId().equals(contributor.getContributorId())) {
		/*
		 * Is the part is a IContributedContentsView for the contributor,
		 * for example, outline view.
		 */
		IContributedContentsView view = Adapters.adapt(part, IContributedContentsView.class);
		if (view == null
			|| (view.getContributingPart() != null && !view
				.getContributingPart().equals(contributor))) {
			if (activePropertySheet) {
				if (currentTab != null) {
					currentTab.aboutToBeHidden();
				}
				activePropertySheet = false;
			}
			return;
		}
	}
	if (!activePropertySheet && currentTab != null) {
		currentTab.aboutToBeShown();
		currentTab.refresh();
	}
	activePropertySheet = true;
}