alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

/*
 *                 Sun Public License Notice
 *
 * The contents of this file are subject to the Sun Public License
 * Version 1.0 (the "License"). You may not use this file except in
 * compliance with the License. A copy of the License is available at
 * http://www.sun.com/
 *
 * The Original Code is NetBeans. The Initial Developer of the Original
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004Sun
 * Microsystems, Inc. All Rights Reserved.
 */

package gui.action;

import java.awt.event.KeyEvent;
import java.awt.Component;
import java.awt.Point;
import javax.swing.text.Caret;

import org.netbeans.editor.BaseCaret;
import org.netbeans.modules.editor.java.JavaKit;
import org.netbeans.modules.editor.options.BaseOptions;
import org.netbeans.modules.editor.options.JavaOptions;
import org.netbeans.modules.java.settings.JavaSettings;
import org.netbeans.modules.web.core.syntax.JSPKit;
import org.netbeans.modules.web.core.syntax.JSPOptions;

import org.netbeans.jellytools.MainWindowOperator;
import org.netbeans.jellytools.EditorOperator;
import org.netbeans.jellytools.EditorWindowOperator;
import org.netbeans.jellytools.ProjectsTabOperator;
import org.netbeans.jellytools.nodes.Node;
import org.netbeans.jellytools.actions.ActionNoBlock;
import org.netbeans.jellytools.actions.Action.Shortcut;
import org.netbeans.jellytools.actions.OpenAction;

import org.netbeans.jemmy.operators.ComponentOperator;
import org.netbeans.jemmy.ComponentChooser;

/**
 * Test of java completion in opened source editor.
 *
 * @author  anebuzelsky@netbeans.org, mmirilovic@netbeans.org
 */
public class JavaCompletionInJspEditor extends testUtilities.PerformanceTestCase {
    
    /** Creates a new instance of JavaCompletionInEditor */
    public JavaCompletionInJspEditor(String testName) {
        super(testName);
        expectedTime = WINDOW_OPEN;
        WAIT_AFTER_OPEN = 1;
    }
    
    /** Creates a new instance of JavaCompletionInEditor */
    public JavaCompletionInJspEditor(String testName, String performanceDataName) {
        super(testName, performanceDataName);
        expectedTime = WINDOW_OPEN;
    }
    
    public String text;
    public Shortcut shcut;
    
    public void testScriptletCC() {
        WAIT_AFTER_OPEN = 6000;
        text = "<% request";
        //shcut = new Shortcut(KeyEvent.VK_SEMICOLON, KeyEvent.SHIFT_MASK);
        shcut = new Shortcut(KeyEvent.VK_DECIMAL);
        measureTime();
    }

    public void testExpressionCC() {
        WAIT_AFTER_OPEN = 6000;
        text = "<%= request";
        //shcut = new Shortcut(KeyEvent.VK_SEMICOLON, KeyEvent.SHIFT_MASK);
        shcut = new Shortcut(KeyEvent.VK_DECIMAL);
        measureTime();
    }
    
    public void testDeclarationCC() {
        WAIT_AFTER_OPEN = 6000;
        text = "<%! java";
        //shcut = new Shortcut(KeyEvent.VK_SEMICOLON, KeyEvent.SHIFT_MASK);
        shcut = new Shortcut(KeyEvent.VK_DECIMAL);
        measureTime();
    }
    
    public void testAllTags() {
        WAIT_AFTER_OPEN = 6000;
        text = "";
        //shcut = new Shortcut(KeyEvent.VK_SEMICOLON, KeyEvent.SHIFT_MASK);
        shcut = new Shortcut(KeyEvent.VK_COMMA, KeyEvent.SHIFT_MASK);
        measureTime();
    }
    
    public void testTagAttribute1() {
        WAIT_AFTER_OPEN = 6000;
        text = "<%@page ";
        //shcut = new Shortcut(KeyEvent.VK_SEMICOLON, KeyEvent.SHIFT_MASK);
        shcut = new Shortcut(KeyEvent.VK_SPACE, KeyEvent.CTRL_MASK);
        measureTime();
    }

    public void testTagAttribute2() {
        WAIT_AFTER_OPEN = 6000;
        text = " 1)
            editorOperator.delete(8,1,linelength-1);
        editorOperator.setCaretPositionToLine(8);
        // insert the initial text
        editorOperator.insert(text);
        // wait
        waitNoEvent(1000);
   }
    
    public ComponentOperator open(){
        // invoke the completion dialog
        //editorOperator.pushKey('.');
        new ActionNoBlock(null, null, shcut).perform(editorOperator);
        // wait for the completion window
        return new ComponentOperator(MainWindowOperator.getDefault(), new CodeCompletionSubchooser());
    }
    
    protected void shutdown() {
        turnBack();
        editorOperator.closeDiscard();
        super.shutdown();
    }
    

    /** SubChooser to determine codecompletion panel
     */
    private static final class CodeCompletionSubchooser implements ComponentChooser {

        public boolean checkComponent(Component comp) {
            return (comp instanceof org.netbeans.editor.ext.JDCPopupPanel);
        }

        public String getDescription() {
            return "org.netbeans.editor.ext.JDCPopupPanel";
        }
    }
}
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.