Search in sources :

Example 21 with Dialog

use of java.awt.Dialog in project enclojure by EricThorsen.

the class AddClojureWatchAction method performAction.

public void performAction() {
    ResourceBundle bundle = NbBundle.getBundle(AddClojureWatchAction.class);
    JPanel panel = new JPanel();
    // NOI18N
    panel.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_WatchPanel"));
    JTextField textField;
    // NOI18N
    JLabel textLabel = new JLabel(bundle.getString("CTL_Watch_Name"));
    textLabel.setBorder(new EmptyBorder(0, 0, 0, 10));
    panel.setLayout(new BorderLayout());
    panel.setBorder(new EmptyBorder(11, 12, 1, 11));
    // NOI18N
    panel.add("West", textLabel);
    // NOI18N
    panel.add("Center", textField = new JTextField(25));
    // NOI18N
    textField.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_CTL_Watch_Name"));
    textField.setBorder(new CompoundBorder(textField.getBorder(), new EmptyBorder(2, 0, 2, 0)));
    textLabel.setDisplayedMnemonic(// NOI18N
    bundle.getString("CTL_Watch_Name_Mnemonic").charAt(0));
    //Utils.getELIdentifier();
    String t = null;
    //        Utils.log("Watch: ELIdentifier = " + t);
    boolean isScriptlet = Utils.isScriptlet();
    LOG.log(Level.FINEST, "Watch: isScriptlet: " + isScriptlet);
    if ((t == null) && (isScriptlet)) {
        t = Utils.getJavaIdentifier();
        LOG.log(Level.FINEST, "Watch: javaIdentifier = " + t);
    }
    if (t != null) {
        textField.setText(t);
    } else {
        textField.setText(watchHistory);
    }
    textField.selectAll();
    textLabel.setLabelFor(textField);
    textField.requestFocus();
    org.openide.DialogDescriptor dd = new org.openide.DialogDescriptor(panel, // NOI18N
    bundle.getString("CTL_Watch_Title"));
    dd.setHelpCtx(new HelpCtx("debug.add.watch"));
    Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
    dialog.setVisible(true);
    dialog.dispose();
    if (dd.getValue() != org.openide.DialogDescriptor.OK_OPTION)
        return;
    String watch = textField.getText();
    if ((watch == null) || (watch.trim().length() == 0)) {
        return;
    }
    String s = watch;
    int i = s.indexOf(';');
    while (i > 0) {
        String ss = s.substring(0, i).trim();
        if (ss.length() > 0)
            DebuggerManager.getDebuggerManager().createWatch(ss);
        s = s.substring(i + 1);
        i = s.indexOf(';');
    }
    s = s.trim();
    if (s.length() > 0)
        DebuggerManager.getDebuggerManager().createWatch(s);
    watchHistory = watch;
// open watches view
//        new WatchesAction ().actionPerformed (null); TODO
}
Also used : JPanel(javax.swing.JPanel) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) BorderLayout(java.awt.BorderLayout) Dialog(java.awt.Dialog) HelpCtx(org.openide.util.HelpCtx) ResourceBundle(java.util.ResourceBundle) CompoundBorder(javax.swing.border.CompoundBorder) EmptyBorder(javax.swing.border.EmptyBorder)

Example 22 with Dialog

use of java.awt.Dialog in project enclojure by EricThorsen.

the class ClojureWatchesActionsProvider method customize.

private static void customize(Watch w) {
    WatchPanel wp = new WatchPanel(w.getExpression());
    JComponent panel = wp.getPanel();
    org.openide.DialogDescriptor dd = new org.openide.DialogDescriptor(panel, // NOI18N 
    NbBundle.getMessage(// NOI18N 
    ClojureWatchesActionsProvider.class, // NOI18N 
    "CTL_Edit_Watch_Dialog_Title", w.getExpression()));
    dd.setHelpCtx(new HelpCtx("debug.add.watch"));
    Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
    dialog.setVisible(true);
    dialog.dispose();
    if (dd.getValue() != org.openide.DialogDescriptor.OK_OPTION)
        return;
    w.setExpression(wp.getExpression());
}
Also used : Dialog(java.awt.Dialog) HelpCtx(org.openide.util.HelpCtx)

Example 23 with Dialog

use of java.awt.Dialog in project ats-framework by Axway.

the class SwingElementLocator method findElement.

@SuppressWarnings("unchecked")
private static <T extends Component> T findElement(UiElement uiElement) {
    SwingDriverInternal driver = (SwingDriverInternal) uiElement.getUiDriver();
    ContainerFixture<? extends Container> containerFixture = driver.getActiveContainerFixture();
    Class<? extends Component> componentClass = null;
    String exactClassName = uiElement.getElementProperties().getProperty("class");
    if (exactClassName != null) {
        try {
            componentClass = (Class<? extends Component>) SwingElementLocator.class.getClassLoader().loadClass(exactClassName);
        } catch (ClassNotFoundException ex) {
            throw new ElementNotFoundException("Could not load UI Component class named " + exactClassName + ". Probably it is not in the classpath or the name is invalid. Cause message: " + ex.getMessage(), ex);
        }
    } else {
        componentClass = componentsMap.get(uiElement.getClass());
    }
    try {
        boolean requireVisible = true;
        if (uiElement.getElementProperty("visible") != null) {
            requireVisible = Boolean.parseBoolean(uiElement.getElementProperty("visible").trim());
        }
        // Finding components by their associated labels ( someJLabel.setLabelFor( someComponent ) )
        if (uiElement.getElementProperty("label") != null) {
            return (T) containerFixture.robot.finder().findByLabel(containerFixture.component(), uiElement.getElementProperty("label"), componentClass, requireVisible);
        }
        return (T) SwingElementFinder.find(containerFixture.robot, containerFixture.component(), buildLocator(componentClass, uiElement.getElementProperties(), requireVisible, uiElement.getPropertyNamesToUseForMatch()));
    } catch (ComponentLookupException cle) {
        if (cle.getMessage().startsWith("Found more than one ")) {
            throw new MoreThanOneSuchElementException(cle.getMessage() + "\n" + uiElement.toString(), cle);
        }
        Window win = driver.getWindowFixture().component();
        Container currentContainer = containerFixture.component();
        String winTitle;
        if (win instanceof Dialog) {
            winTitle = "'" + ((Dialog) win).getTitle() + "'";
        } else if (win instanceof Frame) {
            winTitle = "'" + ((Frame) win).getTitle() + "'";
        } else {
            winTitle = "N/A";
        }
        String containerMsg = null;
        if (win.equals(currentContainer)) {
            containerMsg = "[same as window]";
        }
        if (log.isDebugEnabled()) {
            // more verbose trace
            throw new ElementNotFoundException(uiElement.toString() + " not found.\n" + "Current container: " + (containerMsg != null ? containerMsg : currentContainer.toString()) + "\n" + "Current window: window title " + winTitle + "( details: " + win.toString() + ")", cle);
        } else {
            // /light message
            throw new ElementNotFoundException(uiElement.toString() + " not found.\n" + "Current container name: " + (containerMsg != null ? containerMsg : currentContainer.getName()) + "\n" + "Current window: window title " + winTitle, cle);
        }
    }
}
Also used : Window(java.awt.Window) Frame(java.awt.Frame) JInternalFrame(javax.swing.JInternalFrame) SwingDriverInternal(com.axway.ats.uiengine.internal.driver.SwingDriverInternal) ElementNotFoundException(com.axway.ats.uiengine.exceptions.ElementNotFoundException) ComponentLookupException(org.fest.swing.exception.ComponentLookupException) MoreThanOneSuchElementException(com.axway.ats.uiengine.exceptions.MoreThanOneSuchElementException) Container(java.awt.Container) Dialog(java.awt.Dialog)

Example 24 with Dialog

use of java.awt.Dialog in project ats-framework by Axway.

the class SwingElementLocator method getWindowFixture.

/**
     * Change window by specified name.
     * For internal use
     * @param driver Swing driver
     * @param windowTitle if null look for any visible window
     * @param isDialog
     * @return the {@link ContainerFinxture}
     */
public static WindowFixture<?> getWindowFixture(SwingDriverInternal driver, final String windowTitle, boolean isDialog) throws ElementNotFoundException {
    WindowFixture<?> windowFixture = driver.getWindowFixture();
    Robot robot = null;
    if (windowFixture != null) {
        // use the current robot instance
        robot = windowFixture.robot;
    } else {
        robot = BasicRobot.robotWithCurrentAwtHierarchy();
    }
    try {
        if (windowTitle != null) {
            if (isDialog) {
                windowFixture = WindowFinder.findDialog(new GenericTypeMatcher<Dialog>(Dialog.class) {

                    protected boolean isMatching(Dialog dialog) {
                        return windowTitle.equals(dialog.getTitle()) && dialog.isShowing();
                    }
                }).withTimeout(UiEngineConfigurator.getInstance().getElementStateChangeDelay()).using(robot);
            } else {
                windowFixture = WindowFinder.findFrame(new GenericTypeMatcher<Frame>(Frame.class) {

                    protected boolean isMatching(Frame frame) {
                        return windowTitle.equals(frame.getTitle()) && frame.isShowing();
                    }
                }).withTimeout(UiEngineConfigurator.getInstance().getElementStateChangeDelay()).using(robot);
            }
        } else {
            if (isDialog) {
                windowFixture = WindowFinder.findDialog(new GenericTypeMatcher<Dialog>(Dialog.class) {

                    protected boolean isMatching(Dialog dialog) {
                        return dialog.isShowing();
                    }
                }).withTimeout(UiEngineConfigurator.getInstance().getElementStateChangeDelay()).using(robot);
            } else {
                windowFixture = WindowFinder.findFrame(new GenericTypeMatcher<Frame>(Frame.class) {

                    protected boolean isMatching(Frame frame) {
                        if (log.isTraceEnabled()) {
                            log.trace("WindowFinder isMatching(): Title: " + frame.getTitle() + ", Frame + " + frame + ", Owner: " + frame.getOwner());
                        }
                        // owner == null - top frame. Two independent frames are both considered a top ones
                        return frame.isShowing() && frame.getOwner() == null;
                    }
                }).withTimeout(UiEngineConfigurator.getInstance().getElementStateChangeDelay()).using(robot);
            }
        }
        return windowFixture;
    } catch (WaitTimedOutError wtoe) {
        throw new ElementNotFoundException("Unable to find " + (isDialog ? "dialog" : "frame") + (windowTitle != null ? " with title '" + windowTitle + "'" : " without title specified (null passed)"), wtoe);
    }
}
Also used : Frame(java.awt.Frame) JInternalFrame(javax.swing.JInternalFrame) Dialog(java.awt.Dialog) ElementNotFoundException(com.axway.ats.uiengine.exceptions.ElementNotFoundException) WaitTimedOutError(org.fest.swing.exception.WaitTimedOutError) Robot(org.fest.swing.core.Robot) BasicRobot(org.fest.swing.core.BasicRobot) GenericTypeMatcher(org.fest.swing.core.GenericTypeMatcher)

Example 25 with Dialog

use of java.awt.Dialog in project EnrichmentMapApp by BaderLab.

the class FileBrowser method browseForRootFolderMac.

private Optional<File> browseForRootFolderMac(Component parent) {
    final String property = System.getProperty("apple.awt.fileDialogForDirectories");
    System.setProperty("apple.awt.fileDialogForDirectories", "true");
    try {
        FileDialog chooser;
        if (parent instanceof Dialog)
            chooser = new FileDialog((Dialog) parent, "Choose Root Folder", FileDialog.LOAD);
        else if (parent instanceof Frame)
            chooser = new FileDialog((Frame) parent, "Choose Root Folder", FileDialog.LOAD);
        else
            throw new IllegalArgumentException("parent must be Dialog or Frame");
        chooser.setDirectory(getCurrentDirectory().getAbsolutePath());
        chooser.setModal(true);
        chooser.setLocationRelativeTo(parent);
        chooser.setVisible(true);
        String file = chooser.getFile();
        String dir = chooser.getDirectory();
        if (file == null || dir == null) {
            return Optional.empty();
        }
        setCurrentDirectory(new File(dir));
        return Optional.of(new File(dir + File.separator + file));
    } finally {
        if (property != null) {
            System.setProperty("apple.awt.fileDialogForDirectories", property);
        }
    }
}
Also used : Frame(java.awt.Frame) FileDialog(java.awt.FileDialog) Dialog(java.awt.Dialog) FileDialog(java.awt.FileDialog) File(java.io.File)

Aggregations

Dialog (java.awt.Dialog)34 Frame (java.awt.Frame)19 Window (java.awt.Window)8 JButton (javax.swing.JButton)5 Container (java.awt.Container)4 Graphics (java.awt.Graphics)4 Panel (java.awt.Panel)4 JInternalFrame (javax.swing.JInternalFrame)4 JPanel (javax.swing.JPanel)4 ElementNotFoundException (com.axway.ats.uiengine.exceptions.ElementNotFoundException)3 BorderLayout (java.awt.BorderLayout)3 Point (java.awt.Point)3 ActionEvent (java.awt.event.ActionEvent)3 ActionListener (java.awt.event.ActionListener)3 WindowAdapter (java.awt.event.WindowAdapter)3 WindowEvent (java.awt.event.WindowEvent)3 DialogControls (org.gephi.datalab.spi.DialogControls)3 AttributeColumnsManipulatorUI (org.gephi.datalab.spi.columns.AttributeColumnsManipulatorUI)3 DialogDescriptor (org.openide.DialogDescriptor)3 Button (java.awt.Button)2