Examples of JavaEditor


Examples of org.eclipse.jdt.internal.ui.javaeditor.JavaEditor

   * Test an event on a normal Java type (not anonymous, not inner class). This
   * event should not be filtered on save.
   */
  @Test
  public void testFilter_existingElement_typeNormal() throws Exception {
    JavaEditor editor = closeAndOpenEditor();
    String className = unit.getTypes()[0].getElementName();
    int offset = getDocument(editor).get().indexOf(className);
    int len = className.length();
    editor.getSelectionProvider().setSelection(new TextSelection(offset, len));

    IJavaElement element = getElementAtOffset(editor);
    assertEquals(IJavaElement.TYPE, element.getElementType());

    long preStart = System.currentTimeMillis();
View Full Code Here

Examples of org.eclipse.jdt.internal.ui.javaeditor.JavaEditor

   * instead of showing a user spent x amount of time on the field, we show that
   * a user spent x amount of time on the field's parent type.
   */
  @Test
  public void testFilter_exsitingElement_field() throws Exception {
    JavaEditor editor = closeAndOpenEditor();
    IDocument document = getDocument(editor);
    String fieldName = "aFieldName";
    String methodText = format("private int %s = 1;", fieldName);
    int offset = document.get().indexOf("{") + 1;
    int len = 0;
    document.replace(offset, len, methodText);

    offset = document.get().indexOf(fieldName);
    len = fieldName.length();
    editor.getSelectionProvider().setSelection(new TextSelection(offset, len));

    IJavaElement element = getElementAtOffset(editor);
    assertEquals(IJavaElement.FIELD, element.getElementType());

    long preStart = System.currentTimeMillis();
View Full Code Here

Examples of org.eclipse.jdt.internal.ui.javaeditor.JavaEditor

  /**
   * Tests when the user becomes inactive.
   */
  @Test
  public void testUserInactive() throws Exception {
    JavaEditor editor = closeAndOpenEditor();

    // Set the editor to select the package declaration:
    int offset = getDocument(editor).get().indexOf(pkg.getElementName());
    int len = pkg.getElementName().length();
    editor.getSelectionProvider().setSelection(new TextSelection(offset, len));

    // Run the tracker to capture the event:
    long preStart = System.currentTimeMillis();
    tracker.setEnabled(true);
    long postStart = System.currentTimeMillis();
View Full Code Here

Examples of org.eclipse.jdt.internal.ui.javaeditor.JavaEditor

  /**
   * Tests when the window lose focus.
   */
  @Test
  public void testWindowDeactivated() throws Exception {
    JavaEditor editor = closeAndOpenEditor();

    // Set the editor to select the package declaration:
    int offset = getDocument(editor).get().indexOf(pkg.getElementName());
    int len = pkg.getElementName().length();
    editor.getSelectionProvider().setSelection(new TextSelection(offset, len));

    // Run the tracker to capture the event:
    long preStart = System.currentTimeMillis();
    tracker.setEnabled(true);
    long postStart = System.currentTimeMillis();
View Full Code Here

Examples of org.eclipse.jdt.internal.ui.javaeditor.JavaEditor

   * Tests that events are recorded properly with the different states of the
   * window.
   */
  @Test
  public void testWindowDeactivatedThenActivated() throws Exception {
    JavaEditor editor = closeAndOpenEditor();

    // Set the editor to select the package declaration:
    int offset = getDocument(editor).get().indexOf(pkg.getElementName());
    int len = pkg.getElementName().length();
    editor.getSelectionProvider().setSelection(new TextSelection(offset, len));

    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    try {
      // Now run the tracker to capture the event:
      long preStart = System.currentTimeMillis();
View Full Code Here

Examples of org.eclipse.jdt.internal.ui.javaeditor.JavaEditor

     * @param end the end
     */
    private void highlightSource(IEditorPart editor, Integer start, Integer end) {
        // jump to position in file
        if (editor instanceof JavaEditor) {
            JavaEditor javaEditor = (JavaEditor) editor;
            // javaEditor.collapseMembers();
            final ISelectionProvider selectionProvider = javaEditor.getSelectionProvider();

            // get designated document
            IDocumentProvider documentProvider = javaEditor.getDocumentProvider();
            IDocument document = documentProvider.getDocument(javaEditor.getEditorInput());

            // change selection
            final ISelection selection = new TextSelection(document, start - 1, end - start + 1);
            final IWorkbench workbench = PlatformUI.getWorkbench();
            Display display = workbench.getDisplay();
View Full Code Here

Examples of org.eclipse.jdt.internal.ui.javaeditor.JavaEditor

      IDocument document = getDocument();
      if (document == null)
        return false; // can't compute

      JavaEditor editor = fEditor;
      Point selectedRange = null;
      if (editor == null || (selectedRange = editor.getCachedSelectedRange()) == null)
        return false; // can't compute

      try {
        IJavaElementDelta[] affectedChildren = delta.getAffectedChildren();
        if (affectedChildren.length == 1 &&
View Full Code Here

Examples of org.eclipse.jdt.internal.ui.javaeditor.JavaEditor

  private ProjectionAnnotationModel getModel() {
    return (ProjectionAnnotationModel) fEditor.getAdapter(ProjectionAnnotationModel.class);
  }

  private IDocument getDocument() {
    JavaEditor editor = fEditor;
    if (editor == null)
      return null;

    IDocumentProvider provider = editor.getDocumentProvider();
    if (provider == null)
      return null;

    return provider.getDocument(editor.getEditorInput());
  }
View Full Code Here

Examples of org.eclipse.jdt.internal.ui.javaeditor.JavaEditor

  private ProjectionAnnotationModel getModel() {
    return (ProjectionAnnotationModel) fEditor.getAdapter(ProjectionAnnotationModel.class);
  }

  private IDocument getDocument() {
    JavaEditor editor = fEditor;
    if (editor == null)
      return null;

    IDocumentProvider provider = editor.getDocumentProvider();
    if (provider == null)
      return null;

    return provider.getDocument(editor.getEditorInput());
  }
View Full Code Here

Examples of org.eclipse.jdt.internal.ui.javaeditor.JavaEditor

      IDocument document = getDocument();
      if (document == null)
        return false; // can't compute

      JavaEditor editor = fEditor;
      Point selectedRange = null;
      if (editor == null || (selectedRange = editor.getCachedSelectedRange()) == null)
        return false; // can't compute

      try {
        IJavaElementDelta[] affectedChildren = delta.getAffectedChildren();
        if (affectedChildren.length == 1 &&
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.