Example usage for org.eclipse.jdt.core IJavaElement getHandleIdentifier

List of usage examples for org.eclipse.jdt.core IJavaElement getHandleIdentifier

Introduction

In this page you can find the example usage for org.eclipse.jdt.core IJavaElement getHandleIdentifier.

Prototype

String getHandleIdentifier();

Source Link

Document

Returns a string representation of this element handle.

Usage

From source file:org.eclipse.mylyn.internal.sandbox.bridge.bugs.BugzillaSearchManager.java

License:Open Source License

/**
 * Remove a landmark from the hash//  w  w  w . jav  a  2  s .c  om
 * 
 * @param removed
 *            This landmark to remove (IJavaElement)
 */
public void removeFromLandmarksHash(IJavaElement removed) {
    landmarksHash.remove(removed.getHandleIdentifier());
}

From source file:org.eclipse.mylyn.internal.sandbox.bridge.bugs.BugzillaSearchManager.java

License:Open Source License

/**
 * Remove all of the landmarks from the hash that are in the list
 * //from  w ww  . j  a v  a2 s .c  o m
 * @param removed
 *            This list of landmarks to remove (IJavaElements)
 */
public void removeFromLandmarksHash(List<IJavaElement> removed) {

    for (IJavaElement je : removed) {
        landmarksHash.remove(je.getHandleIdentifier());
    }
}

From source file:org.eclipse.mylyn.internal.sandbox.ui.InterestInducingProblemListener.java

License:Open Source License

public void problemsChanged(IResource[] changedResources, boolean isMarkerChange) {
    try {//from w  w  w. ja v  a 2 s . c  o  m
        if (!ContextCore.getContextManager().isContextActive()) {
            return;
        } else {
            for (IResource resource : changedResources) {
                if (resource instanceof IFile) {
                    IJavaElement javaElement = (IJavaElement) resource.getAdapter(IJavaElement.class);
                    if (javaElement != null) {
                        IInteractionElement element = ContextCore.getContextManager()
                                .getElement(javaElement.getHandleIdentifier());
                        if (!javaStructureBridge.containsProblem(element)) {
                            ((InteractionContextManager) ContextCore.getContextManager())
                                    .removeErrorPredictedInterest(element.getHandleIdentifier(),
                                            JavaStructureBridge.CONTENT_TYPE, true);
                        } else {
                            ((InteractionContextManager) ContextCore.getContextManager())
                                    .addErrorPredictedInterest(element.getHandleIdentifier(),
                                            JavaStructureBridge.CONTENT_TYPE, true);
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        StatusHandler.log(
                new Status(IStatus.ERROR, JavaUiBridgePlugin.ID_PLUGIN, "Could not update marker change", e));
    }
}

From source file:org.eclipse.mylyn.java.tests.InteractionContextManagerTest.java

License:Open Source License

public void testPropagation() throws JavaModelException, Exception {
    IMethod m1 = type1.createMethod("void m1() { }", null, true, null);
    IInteractionElement node = ContextCore.getContextManager().getElement(m1.getHandleIdentifier());
    assertFalse(node.getInterest().isInteresting());

    InteractionEvent event = new InteractionEvent(InteractionEvent.Kind.MANIPULATION,
            new JavaStructureBridge().getContentType(), m1.getHandleIdentifier(), "source");
    ContextCorePlugin.getContextManager().processInteractionEvent(event, true);

    node = ContextCore.getContextManager().getElement(m1.getHandleIdentifier());
    assertTrue(node.getInterest().isInteresting());

    project.build();//w  ww. j  av  a2s. c o  m
    IJavaElement parent = m1.getParent();
    IInteractionElement parentNode = ContextCore.getContextManager().getElement(parent.getHandleIdentifier());
    assertFalse(parentNode.getInterest().isInteresting());

    InteractionEvent selectionEvent = new InteractionEvent(InteractionEvent.Kind.SELECTION,
            new JavaStructureBridge().getContentType(), m1.getHandleIdentifier(), "source");
    ContextCorePlugin.getContextManager().processInteractionEvent(selectionEvent, true);
    parentNode = ContextCore.getContextManager().getElement(parent.getHandleIdentifier());
    assertTrue(parentNode.getInterest().isInteresting());
}

From source file:org.eclipse.mylyn.java.tests.InteractionContextManagerTest.java

License:Open Source License

public void testIncremenOfParentDoi() throws JavaModelException, Exception {
    IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
    IMethod m1 = type1.createMethod("void m1() { }", null, true, null);
    IInteractionElement node = ContextCore.getContextManager().getElement(m1.getHandleIdentifier());
    assertFalse(node.getInterest().isInteresting());

    StructuredSelection sm1 = new StructuredSelection(m1);
    monitor.selectionChanged(part, sm1);
    node = ContextCore.getContextManager().getElement(m1.getHandleIdentifier());
    assertTrue(node.getInterest().isInteresting());

    project.build();/*w  w  w  .  j  av a2  s.  c  o m*/
    IJavaElement parent = m1.getParent();
    @SuppressWarnings("unused")
    int level = 1;
    do {
        level++;
        IInteractionElement parentNode = ContextCore.getContextManager()
                .getElement(parent.getHandleIdentifier());
        if (!(parent instanceof JavaModel)) {
            assertEquals("failed on: " + parent.getClass(), node.getInterest().getValue(),
                    parentNode.getInterest().getValue());
        }
        parent = parent.getParent();
    } while (parent != null);
}

From source file:org.eclipse.mylyn.java.tests.InteractionContextManagerTest.java

License:Open Source License

public void testIncremenOfParentDoiAfterForcedDecay() throws JavaModelException, Exception {
    IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
    IMethod m1 = type1.createMethod("void m1() { }", null, true, null);
    IMethod m2 = type1.createMethod("void m2() { }", null, true, null);
    IInteractionElement node = ContextCore.getContextManager().getElement(m1.getHandleIdentifier());
    assertFalse(node.getInterest().isInteresting());

    monitor.selectionChanged(part, new StructuredSelection(m1));
    node = ContextCore.getContextManager().getElement(m1.getHandleIdentifier());
    assertTrue(node.getInterest().isInteresting());

    // make all the parents interest propated to have negative interest
    IJavaElement parent = m1.getParent();
    @SuppressWarnings("unused")
    int level = 1;
    do {//from   www.  ja  v  a 2s.  c  om
        level++;
        IInteractionElement parentNode = ContextCore.getContextManager()
                .getElement(parent.getHandleIdentifier());
        if (!(parent instanceof JavaModel)) {
            assertTrue(parentNode.getInterest().isInteresting());
            ContextCore.getContextManager().processInteractionEvent(mockInterestContribution(
                    parentNode.getHandleIdentifier(), -2 * parentNode.getInterest().getValue()));
            IInteractionElement updatedParent = ContextCore.getContextManager()
                    .getElement(parent.getHandleIdentifier());
            assertFalse(updatedParent.getInterest().isInteresting());
        }
        parent = parent.getParent();
    } while (parent != null);

    //      assertFalse(node.getInterest().isInteresting());

    // select the element, should propagate up
    monitor.selectionChanged(part, new StructuredSelection(m2));
    monitor.selectionChanged(part, new StructuredSelection(m1));
    node = ContextCore.getContextManager().getElement(m1.getHandleIdentifier());
    assertTrue(node.getInterest().isInteresting());

    project.build();
    parent = m1.getParent();
    level = 1;
    do {
        level++;
        IInteractionElement parentNode = ContextCore.getContextManager()
                .getElement(parent.getHandleIdentifier());
        if (!(parent instanceof JavaModel)) {
            assertTrue(parentNode.getInterest().isInteresting());
            //            assertEquals("failed on: " + parent.getClass(), node.getInterest().getValue(), parentNode.getInterest()
            //                  .getValue());
        }
        parent = parent.getParent();
    } while (parent != null);
}

From source file:org.eclipse.mylyn.java.ui.DoiViewerFilter.java

License:Open Source License

public boolean select(Viewer viewer, Object parentElement, Object object) {
    if (!filterUninterestingEnabled)
        return true;

    if (object instanceof ProblemMarker) {
        ProblemMarker problemMarker = (ProblemMarker) object;
        if (problemMarker.getSeverity() == IMarker.SEVERITY_ERROR) {
            return true;
        } else {//www.  j ava  2 s .  co  m
            object = JavaUiUtil.getJavaElement(problemMarker); // TODO: don't reassing
        }
    }

    if (object instanceof IJavaElement) {
        IJavaElement element = (IJavaElement) object;
        //            if (element instanceof IJavaProject) {
        //                return true;
        //            } else if (element instanceof PackageFragmentRoot && !(element instanceof JarPackageFragmentRoot)) {
        //                return true;
        //          } else if (element instanceof PackageFragment && !acceptPackageFragment((PackageFragment)element)) {
        //                return false;
        //          } else if (element instanceof IPackageDeclaration ||
        //                     element instanceof IImportContainer) {
        //              return false;
        //            } else 
        if (ContextCorePlugin.getTaskscapeManager().isTempRaised(element.getParent().getHandleIdentifier())) {
            return true;
        } else {
            if (isDeclaration(element) && filterDeclarationsEnabled) {
                return false;
            } else if (!filterUninterestingEnabled) {
                return true;
            } else {
                ITaskscapeNode info = ContextCorePlugin.getTaskscapeManager()
                        .getDoi(element.getHandleIdentifier());
                return info != null && info.getDegreeOfInterest().getDegreeOfInterest().isInteresting();
            }
        }
    } else if (object instanceof File) {
        ITaskscapeNode info = ContextCorePlugin.getTaskscapeManager()
                .getDoi(((File) object).getFullPath().toPortableString());
        boolean interesting = info != null && info.getDegreeOfInterest().getDegreeOfInterest().isInteresting();
        if (!filterUninterestingEnabled) {
            return true;
        } else {
            return !(((File) object).getName().charAt(0) == '.') && interesting;
        }
    } else if (object instanceof ClassPathContainer) {
        ClassPathContainer container = (ClassPathContainer) object;
        return true;
    } else {
        return false;
    }
}

From source file:org.eclipse.mylyn.java.ui.editor.AutoFoldingStructureProvider.java

License:Open Source License

private void computeAdditions(IJavaElement element, Map map) {
    boolean createProjection = false;
    boolean collapse = false;
    switch (element.getElementType()) {
    case IJavaElement.IMPORT_CONTAINER:
        collapse = true;//w  w w . jav  a2  s .c  o m
        //                collapse= fAllowCollapsing && fCollapseImportContainer;
        createProjection = true;
        break;
    case IJavaElement.TYPE:
        if (isInnerType((IType) element)) {
            IMylarElement node = ContextCorePlugin.getContextManager()
                    .getElement(element.getHandleIdentifier());
            if (!MylarUiPlugin.getDefault().isGlobalFoldingEnabled()) {
                collapse = false;
            } else if (node == null || node.getInterest().isInteresting()) {
                collapse = false;
            } else {
                collapse = true;
            }
            createProjection = true;
            break;
        }
        //                collapse= fAllowCollapsing && fCollapseInnerTypes && isInnerType((IType) element);
        createProjection = true;
        break;
    case IJavaElement.METHOD:
        IMylarElement node = ContextCorePlugin.getContextManager().getElement(element.getHandleIdentifier());
        if (!MylarUiPlugin.getDefault().isGlobalFoldingEnabled()) {
            collapse = false;
        } else if (node == null || node.getInterest().isInteresting()) {
            collapse = false;
        } else {
            collapse = true;
        }
        createProjection = true;
        break;
    default:
        collapse = true;
        //                collapse= fAllowCollapsing && fCollapseMethods;
        //                createProjection= true;
        //                break;
    }

    if (createProjection) {
        IRegion[] regions = computeProjectionRanges(element);
        if (regions != null) {
            // comments
            for (int i = 0; i < regions.length - 1; i++) {
                Position position = createProjectionPosition(regions[i], null);
                boolean commentCollapse;
                if (position != null) {
                    if (i == 0 && (regions.length > 2 || fHasHeaderComment) && element == fFirstType) {
                        commentCollapse = fAllowCollapsing && fCollapseHeaderComments;
                    } else {
                        commentCollapse = fAllowCollapsing && fCollapseJavadoc;
                    }
                    map.put(new JavaProjectionAnnotation(element, commentCollapse, true), position);
                }
            }
            // code
            Position position = createProjectionPosition(regions[regions.length - 1], element);
            if (position != null)
                map.put(new JavaProjectionAnnotation(element, collapse, false), position);
        }
    }
}

From source file:org.eclipse.mylyn.java.ui.views.MylarProblemView.java

License:Open Source License

public Color getForeground(Object element) {
    ProblemMarker marker = (ProblemMarker) element;
    IJavaElement javaElement = JavaUiUtil.getJavaElement(marker);
    if (javaElement != null) {
        ITaskscapeNode node = ContextCorePlugin.getTaskscapeManager()
                .getNode(javaElement.getHandleIdentifier());
        return UiUtil.getForegroundForElement(node);
    } else {/*  w ww . j  ava2  s.c o  m*/
        return null;
    }
    //      return MylarUiPlugin.getDefault().getColorMap().TEXT;
}

From source file:org.eclipse.mylyn.java.ui.views.MylarProblemView.java

License:Open Source License

public Color getBackground(Object element) {
    ProblemMarker marker = (ProblemMarker) element;
    IJavaElement javaElement = JavaUiUtil.getJavaElement(marker);
    if (javaElement != null) {
        ITaskscapeNode node = ContextCorePlugin.getTaskscapeManager()
                .getNode(javaElement.getHandleIdentifier());
        return UiUtil.getBackgroundForElement(node);
    } else {/*from   w  w  w  .jav a2s . c o m*/
        return null;
    }
}