Java Code Examples for org.openide.DialogDisplayer#getDefault()

The following examples show how to use org.openide.DialogDisplayer#getDefault() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlobFieldTableCellEditor.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void displayErrorOpenImage(String messageProperty) {
    DialogDisplayer dd = DialogDisplayer.getDefault();

    String messageMsg = NbBundle.getMessage(BlobFieldTableCellEditor.class,
            messageProperty);
    String titleMsg = NbBundle.getMessage(BlobFieldTableCellEditor.class,
            "openImageError.title");                                //NOI18N

    NotifyDescriptor nd = new NotifyDescriptor(
            messageMsg,
            titleMsg,
            NotifyDescriptor.OK_CANCEL_OPTION,
            NotifyDescriptor.WARNING_MESSAGE,
            new Object[]{NotifyDescriptor.CANCEL_OPTION},
            NotifyDescriptor.CANCEL_OPTION);

    dd.notifyLater(nd);
}
 
Example 2
Source File: SetupUtil.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static void commonTearDown() throws Exception {
    DialogDisplayer dd = DialogDisplayer.getDefault();
    if (dd instanceof DialogDisplayerNotifier) {
        ((DialogDisplayerNotifier)dd).removeAllListeners();
    }
    
    MockServices.setServices();
}
 
Example 3
Source File: InstallerReadPageTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void doEncodingTest(String encoding, String metaTag) throws Exception {
    //String kun = "Žluťoučký kůň";
    String kun = "\u017Dlu\u0165ou\u010Dky k\u016F\u0148";
    String utf8 = 
        "<html><head>" +
        metaTag +
        "</head>" +
        "<body>" +
        "<form action='http://anna.nbextras.org/analytics/upload.jsp' method='post'>" +
        "  <input name='submit' value='" + kun + "' type='hidden'> </input>" +
        "</form>" +
        "</body></html>";
    ByteArrayInputStream is = new ByteArrayInputStream(utf8.getBytes(encoding));
    
    MemoryURL.registerURL("memory://kun.html", is);
    
    DialogDisplayer d = DialogDisplayer.getDefault();
    assertTrue(d instanceof DD);
    boolean res = Installer.displaySummary("KUN", true, false,true);
    assertFalse("Close options was pressed", res);
    assertNotNull("DD.d assigned", DD.d);
    
    List<Object> data = Arrays.asList(DD.d.getOptions());
    assertEquals("Two objects: " + data, 2, DD.d.getOptions().length);
    assertEquals("First is jbutton", JButton.class, DD.d.getOptions()[0].getClass());
    JButton b = (JButton)DD.d.getOptions()[0];
    
    assertEquals("It has the right localized text", kun, b.getText());

    assertFalse(EventQueue.isDispatchThread());
    EventQueue.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            JPanel jp = (JPanel) DD.d.getMessage();
            JScrollPane pane = (JScrollPane) jp.getComponent(0); //pane at idx 0
            Component c = pane.getViewport().getView();
            assertEquals("Dimension is small", new Dimension(350, 50), c.getPreferredSize());
        }
    });
    
}
 
Example 4
Source File: DialogDisplayerImpl.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public static void returnFromNotify(Object value) {
    Object o = DialogDisplayer.getDefault();
    Assert.assertEquals("My class", DialogDisplayerImpl.class, o.getClass());
    toReturn = value;
}
 
Example 5
Source File: BlobFieldTableCellEditor.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void displayError(File f, Exception ex, boolean read) {
    DialogDisplayer dd = DialogDisplayer.getDefault();

    String errorObjectMsg;
    String messageMsg;
    String titleMsg;

    if (ex instanceof SQLException) {
        errorObjectMsg = NbBundle.getMessage(BlobFieldTableCellEditor.class,
                "lobErrorObject.database");
    } else {
        errorObjectMsg = NbBundle.getMessage(BlobFieldTableCellEditor.class,
                "lobErrorObject.file");
    }

    if (!read) {
        titleMsg = NbBundle.getMessage(BlobFieldTableCellEditor.class,
                "blobSaveToFileError.title");
        messageMsg = NbBundle.getMessage(BlobFieldTableCellEditor.class,
                "blobSaveToFileError.message",
                errorObjectMsg,
                f.getAbsolutePath(),
                ex.getLocalizedMessage());
    } else {
        titleMsg = NbBundle.getMessage(BlobFieldTableCellEditor.class,
                "blobReadFromFileError.title");
        messageMsg = NbBundle.getMessage(BlobFieldTableCellEditor.class,
                "blobReadFromFileError.message",
                errorObjectMsg,
                f.getAbsolutePath(),
                ex.getLocalizedMessage());
    }

    NotifyDescriptor nd = new NotifyDescriptor(
            messageMsg,
            titleMsg,
            NotifyDescriptor.OK_CANCEL_OPTION,
            NotifyDescriptor.WARNING_MESSAGE,
            new Object[]{NotifyDescriptor.CANCEL_OPTION},
            NotifyDescriptor.CANCEL_OPTION);

    dd.notifyLater(nd);
}
 
Example 6
Source File: ClobFieldTableCellEditor.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void displayError(File f, Exception ex, boolean read) {
    DialogDisplayer dd = DialogDisplayer.getDefault();

    String errorObjectMsg;
    String messageMsg;
    String titleMsg;

    if (ex instanceof SQLException) {
        errorObjectMsg = NbBundle.getMessage(ClobFieldTableCellEditor.class,
                "lobErrorObject.database");
    } else {
        errorObjectMsg = NbBundle.getMessage(ClobFieldTableCellEditor.class,
                "lobErrorObject.file");
    }

    if (!read) {
        titleMsg = NbBundle.getMessage(ClobFieldTableCellEditor.class,
                "clobSaveToFileError.title");
        messageMsg = NbBundle.getMessage(ClobFieldTableCellEditor.class,
                "clobSaveToFileError.message",
                errorObjectMsg,
                f.getAbsolutePath(),
                ex.getLocalizedMessage());
    } else {
        titleMsg = NbBundle.getMessage(ClobFieldTableCellEditor.class,
                "clobReadFromFileError.title");
        messageMsg = NbBundle.getMessage(ClobFieldTableCellEditor.class,
                "clobReadFromFileError.message",
                errorObjectMsg,
                f.getAbsolutePath(),
                ex.getLocalizedMessage());
    }

    NotifyDescriptor nd = new NotifyDescriptor(
            messageMsg,
            titleMsg,
            NotifyDescriptor.OK_CANCEL_OPTION,
            NotifyDescriptor.WARNING_MESSAGE,
            new Object[]{NotifyDescriptor.CANCEL_OPTION},
            NotifyDescriptor.CANCEL_OPTION);

    dd.notifyLater(nd);
}