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-2003 Sun
 * Microsystems, Inc. All Rights Reserved.
 */

package org.netbeans.test.gui.web.util;

import org.netbeans.jellytools.nodes.Node;
import org.netbeans.jellytools.nodes.FilesystemNode;
import org.netbeans.jellytools.Bundle;
import org.netbeans.jellytools.NbDialogOperator;
import org.netbeans.jellytools.RepositoryTabOperator;
import org.netbeans.jellytools.WizardOperator;
import org.netbeans.jellytools.actions.MountLocalAction;
import org.netbeans.jellytools.actions.Action;

import org.netbeans.jemmy.operators.JButtonOperator;
import org.netbeans.jemmy.operators.JTextFieldOperator;
import org.netbeans.jemmy.Waiter;


import java.io.File;

public class CommonUtils {

    private static String alternateViewTitle =  "Mount Web Module"; //NOI18N
    private static String fSep = System.getProperty("file.separator");
    private static String iSep = "|";

    public CommonUtils() {
    }

    public static void handleDialogAfterNewWebModule() {
	try {
	    NbDialogOperator dialog = new NbDialogOperator(alternateViewTitle);
	    dialog.ok();
	}catch(Exception e) {
	    System.out.println("Alternate dialog not found");
	}
    }
    
    public static boolean isExplorerItemExist(String path) {
	RepositoryNodeWaitable rnw = new RepositoryNodeWaitable(path);
        Waiter w = new Waiter(rnw);
        try {
            w.waitAction(rnw);
        } catch (Exception e) {
	    return false;
        }
	return true;
    }
    public static boolean mountLocalDirectory(String path) {
	try {
	    File folder = new File(path);
	    if(!folder.exists()) {
		folder.mkdirs(); //Create new with all necessary subfolders
	    }
	    FilesystemNode fn = new FilesystemNode("");
	    fn.select();

	    /*Workaround for MountLocalAction;
	    String popupPath = Bundle.getString("org.netbeans.core.actions.Bundle", "CTL_Mount")
                                           + "|"
                                           + Bundle.getString("org.netbeans.core.Bundle", "Templates/Mount/org-netbeans-core-ExLocalFileSystem.settings");
	    new Action(null,popupPath).performPopup(fn);
	    */
	    new MountLocalAction().performPopup(fn);
	    WizardOperator wo = new  WizardOperator("New Wizard - Local Directory"); //NOI18N
	    JTextFieldOperator jtf = new JTextFieldOperator(wo,0);
	    jtf.setText(""); 
	    jtf.enterText(path);
	    wo.finish();
	}catch(Exception e) {
	    e.printStackTrace();
	    return false;
	}
	return true;
    }

    public static String handleConfirmChangesDialog(boolean must) {
	String dialogTitle = "Confirm Changes"; // NOI18N
	try {
	    NbDialogOperator dialog = new NbDialogOperator(dialogTitle);
	    new JButtonOperator(dialog, "Process All").push(); // NOI18N
	}catch(Exception e) {
	    if(must) {
		e.printStackTrace();
		return "Exception during handling \"Confirm Changes\" dialog";
	    }else {
		return null;
	    }
	}
	if(!must) {
	    return "Looks like  \"Confirm Changes\" dialog appears in wrong case";
	}
	return null;
    }
}









... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 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.