Java Code Examples for org.openide.NotifyDescriptor#CLOSED_OPTION

The following examples show how to use org.openide.NotifyDescriptor#CLOSED_OPTION . 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: Util.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static boolean showDialog(String displayName, List<ParameterInfo> allParams, 
        Document targetDoc) {
    if (!allParams.isEmpty()) {
        boolean showParamTypes = Util.isJava(targetDoc) || Util.isJsp(targetDoc);
        CodeSetupPanel panel = new CodeSetupPanel(allParams, showParamTypes);

        DialogDescriptor desc = new DialogDescriptor(panel,
                NbBundle.getMessage(CodeSetupPanel.class,
                "LBL_CustomizeSaasService", displayName));

        Dialog d = DialogDisplayer.getDefault().createDialog(desc);
        panel.setDialog(d);
        d.setVisible(true);
        Object response = (desc.getValue() != null) ? desc.getValue() : NotifyDescriptor.CLOSED_OPTION;
        if (response.equals(NotifyDescriptor.CANCEL_OPTION) ||
                response.equals(NotifyDescriptor.CLOSED_OPTION)) {
            return false;
        }
    }
    return true;
}
 
Example 2
Source File: ProfilerDialogs.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static Object stringToNDOption(String string) {
    if (string == null) {
        return null;
    }

    if (string.equals("CANCEL_OPTION")) { //NOI18N

        return NotifyDescriptor.CANCEL_OPTION;
    } else if (string.equals("CLOSED_OPTION")) { //NOI18N

        return NotifyDescriptor.CLOSED_OPTION;
    } else if (string.equals("NO_OPTION")) { //NOI18N

        return NotifyDescriptor.NO_OPTION;
    } else if (string.equals("OK_OPTION")) { //NOI18N

        return NotifyDescriptor.OK_OPTION;
    } else if (string.equals("YES_OPTION")) { //NOI18N

        return NotifyDescriptor.YES_OPTION;
    }

    return null;
}
 
Example 3
Source File: ProfilerDialogs.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
private static Object stringToNDOption(String string) {
    if (string == null) {
        return null;
    }

    if (string.equals("CANCEL_OPTION")) { //NOI18N

        return NotifyDescriptor.CANCEL_OPTION;
    } else if (string.equals("CLOSED_OPTION")) { //NOI18N

        return NotifyDescriptor.CLOSED_OPTION;
    } else if (string.equals("NO_OPTION")) { //NOI18N

        return NotifyDescriptor.NO_OPTION;
    } else if (string.equals("OK_OPTION")) { //NOI18N

        return NotifyDescriptor.OK_OPTION;
    } else if (string.equals("YES_OPTION")) { //NOI18N

        return NotifyDescriptor.YES_OPTION;
    }

    return null;
}
 
Example 4
Source File: NbErrorManagerUserQuestionTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testUserQuestionExceptionDisplayedCancel() throws Exception {
    class UQE extends UserQuestionException {
        UQE() {
            super("HelloTest");
        }
        
        boolean confirm;
        @Override
        public void confirmed() throws IOException {
            confirm = true;
        }

        @Override
        public String getLocalizedMessage() {
            return "Reboot?";
        }
    }
    MockDD.reply = NotifyDescriptor.CLOSED_OPTION;
    
    UQE ex = new UQE();
    Exceptions.printStackTrace(ex);
    
    waitEDT();

    assertNotNull("Dialog created", MockDD.lastDescriptor);
    assertEquals("Message is localized text", "Reboot?", MockDD.lastDescriptor.getMessage());
    assertFalse("The message has not been confirmed", ex.confirm);
}
 
Example 5
Source File: Deadlock60917Test.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public Object notify(org.openide.NotifyDescriptor descriptor) {
try {
	// we need to get into EQ - as the regular DialogDescriptor does
	waitEQ();
} catch (Exception ex) {
	ex.printStackTrace();
}
return NotifyDescriptor.CLOSED_OPTION;
     }
 
Example 6
Source File: ProfilerDialogs.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static String ndOptionToString(Object option) {
    if (option == NotifyDescriptor.CANCEL_OPTION) {
        return "CANCEL_OPTION"; // NOI18N
    } else if (option == NotifyDescriptor.CLOSED_OPTION) {
        return "CLOSED_OPTION"; // NOI18N
    } else if (option == NotifyDescriptor.NO_OPTION) {
        return "NO_OPTION"; // NOI18N
    } else if (option == NotifyDescriptor.OK_OPTION) {
        return "OK_OPTION"; // NOI18N
    } else if (option == NotifyDescriptor.YES_OPTION) {
        return "YES_OPTION"; // NOI18N
    }

    return null;
}
 
Example 7
Source File: TemplateChooserPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void storeSettings(WizardDescriptor wd) {
    Object value = wd.getValue();
    
    if ( NotifyDescriptor.CANCEL_OPTION != value &&
         NotifyDescriptor.CLOSED_OPTION != value ) {        
        try { 

            Project newProject = gui.getProject ();
            project = newProject;
            wd.putProperty(ProjectChooserFactory.WIZARD_KEY_PROJECT, newProject);
            
            if (gui.getTemplate () == null) {
                return ;
            }
            
            if (wd instanceof TemplateWizard) {
                ((TemplateWizard)wd).setTemplate( DataObject.find( gui.getTemplate() ) );
            } else {
                wd.putProperty( ProjectChooserFactory.WIZARD_KEY_TEMPLATE, gui.getTemplate () );
            }
        }
        catch( DataObjectNotFoundException e ) {
            ErrorManager.getDefault().notify (e);
        }
    }
}
 
Example 8
Source File: ProfilerDialogs.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
private static String ndOptionToString(Object option) {
    if (option == NotifyDescriptor.CANCEL_OPTION) {
        return "CANCEL_OPTION"; // NOI18N
    } else if (option == NotifyDescriptor.CLOSED_OPTION) {
        return "CLOSED_OPTION"; // NOI18N
    } else if (option == NotifyDescriptor.NO_OPTION) {
        return "NO_OPTION"; // NOI18N
    } else if (option == NotifyDescriptor.OK_OPTION) {
        return "OK_OPTION"; // NOI18N
    } else if (option == NotifyDescriptor.YES_OPTION) {
        return "YES_OPTION"; // NOI18N
    }

    return null;
}
 
Example 9
Source File: CloneableEditorSupportCOSRedirectorTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public Object notify(NotifyDescriptor descriptor) {
    return NotifyDescriptor.CLOSED_OPTION;
}
 
Example 10
Source File: WritablePreferences131128Test.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public Object notify(NotifyDescriptor descriptor) {
    notifyCalled = true;
    return NotifyDescriptor.CLOSED_OPTION;
}
 
Example 11
Source File: InstallerReadPageTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public Object notify(NotifyDescriptor descriptor) {
    assertNull(d);
    d = descriptor;
    return NotifyDescriptor.CLOSED_OPTION;
}
 
Example 12
Source File: InstallerLittleTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public Object notify(NotifyDescriptor descriptor) {
    assertNull(d);
    d = descriptor;
    return NotifyDescriptor.CLOSED_OPTION;
}
 
Example 13
Source File: InstallerInitTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public Object notify(NotifyDescriptor descriptor) {
    assertNull(d);
    d = descriptor;
    return NotifyDescriptor.CLOSED_OPTION;
}
 
Example 14
Source File: NbPresenter.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void actionPerformed(ActionEvent evt) {
    boolean isAqua = "Aqua".equals (UIManager.getLookAndFeel().getID()) || //NOI18N
                    "true".equalsIgnoreCase (System.getProperty ("xtest.looks_as_mac"));

    Object pressedOption = evt.getSource();
    // handle ESCAPE
    if (ESCAPE_COMMAND.equals (evt.getActionCommand ())) {
        MenuElement[] selPath = MenuSelectionManager.defaultManager().getSelectedPath();
        // part of #130919 fix - handle ESC key well in dialogs with menus
        if (selPath == null || selPath.length == 0) {
            pressedOption = NotifyDescriptor.CLOSED_OPTION;
        } else {
            MenuSelectionManager.defaultManager().clearSelectedPath();
            return ;
        }
    } else {
        // handle buttons
        if (evt.getSource() == stdHelpButton) {
            showHelp(currentHelp);
            return;
        }

        Object[] options = descriptor.getOptions();
        if (isAqua && options != null) {
            Arrays.sort (options, NbPresenter.this);
        }

        if (
        options != null &&
        currentPrimaryButtons != null &&
        options.length == (currentPrimaryButtons.length -
            ((currentHelp != null) ? 1 : 0))
        ) {
            int offset = currentHelp != null && isAqua ?
                -1 : 0;
            for (int i = 0; i < currentPrimaryButtons.length; i++) {
                if (evt.getSource() == currentPrimaryButtons[i]) {
                    pressedOption = options[i + offset];
                }
            }
        }

        options = descriptor.getAdditionalOptions();
        if (isAqua && options != null) {
            Arrays.sort (options, NbPresenter.this);
        }

        if (
        options != null &&
        currentSecondaryButtons != null &&
        options.length == currentSecondaryButtons.length
        ) {
            for (int i = 0; i < currentSecondaryButtons.length; i++) {
                if (evt.getSource() == currentSecondaryButtons[i]) {
                    pressedOption = options[i];
                }
            }
        }

        if (evt.getSource() == stdYesButton) {
            pressedOption = NotifyDescriptor.YES_OPTION;
        } else if (evt.getSource() == stdNoButton) {
            pressedOption = NotifyDescriptor.NO_OPTION;
        } else if (evt.getSource() == stdCancelButton) {
            pressedOption = NotifyDescriptor.CANCEL_OPTION;
        } else if (evt.getSource() == stdClosedButton) {
            pressedOption = NotifyDescriptor.CLOSED_OPTION;
        } else if (evt.getSource() == stdOKButton) {
            pressedOption = NotifyDescriptor.OK_OPTION;
        }
    }

    descriptor.setValue(pressedOption);

    ActionListener al = getButtonListener();
    if (al != null) {

        if (pressedOption == evt.getSource()) {
            al.actionPerformed(evt);
        } else {
            al.actionPerformed(new ActionEvent(
            pressedOption, evt.getID(), evt.getActionCommand(), evt.getModifiers()
            ));
        }
    }

    Object[] arr = getClosingOptions();
    if (arr == null || pressedOption == NotifyDescriptor.CLOSED_OPTION) {
        // all options should close
        dispose();
    } else {
        java.util.List l = java.util.Arrays.asList(arr);

        if (l.contains(pressedOption)) {
            dispose();
        }
    }
}
 
Example 15
Source File: OpenEgtaskFile.java    From BART with MIT License 4 votes vote down vote up
private NotifyDescriptor myNotify(String message)   {
    return new NotifyDescriptor(message, 
         "Wrog File", 
          NotifyDescriptor.DEFAULT_OPTION, 
          NotifyDescriptor.ERROR_MESSAGE, new Object[]{NotifyDescriptor.CLOSED_OPTION}, null);
}