Java Code Examples for org.openide.NotifyDescriptor#setOptionType()

The following examples show how to use org.openide.NotifyDescriptor#setOptionType() . 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: DeleteLocalAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
protected void performContextAction(final Node[] nodes) {
    NotifyDescriptor descriptor = new NotifyDescriptor.Confirmation(NbBundle.getMessage(DeleteLocalAction.class, "CTL_DeleteLocal_Prompt")); // NOI18N
    descriptor.setTitle(NbBundle.getMessage(DeleteLocalAction.class, "CTL_DeleteLocal_Title")); // NOI18N
    descriptor.setMessageType(JOptionPane.WARNING_MESSAGE);
    descriptor.setOptionType(NotifyDescriptor.YES_NO_OPTION);

    Object res = DialogDisplayer.getDefault().notify(descriptor);
    if (res != NotifyDescriptor.YES_OPTION) {
        return;
    }
    
    final Context ctx = getContext(nodes);
    ProgressSupport support = new ContextAction.ProgressSupport(this, nodes, ctx) {
        public void perform() {
            performDelete(ctx, this);
        }
    };
    support.start(createRequestProcessor(ctx));
}
 
Example 2
Source File: JavaActions.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Display an alert asking the user whether to really generate a target.
 * @param commandDisplayName the display name of the action to be bound
 * @param scriptPath the path that to the script that will be generated or written to
 * @return true if IDE should proceed
 */
private boolean alert(String commandDisplayName, String scriptPath) {
    String projectDisplayName = ProjectUtils.getInformation(project).getDisplayName();
    String title = NbBundle.getMessage(JavaActions.class, "TITLE_generate_target_dialog", commandDisplayName, projectDisplayName);
    String body = NbBundle.getMessage(JavaActions.class, "TEXT_generate_target_dialog", commandDisplayName, scriptPath);
    NotifyDescriptor d = new NotifyDescriptor.Message(body, NotifyDescriptor.QUESTION_MESSAGE);
    d.setTitle(title);
    d.setOptionType(NotifyDescriptor.OK_CANCEL_OPTION);
    JButton generate = new JButton(NbBundle.getMessage(JavaActions.class, "LBL_generate"));
    generate.setDefaultCapable(true);
    d.setOptions(new Object[] {generate, NotifyDescriptor.CANCEL_OPTION});
    return DialogDisplayer.getDefault().notify(d) == generate;
}
 
Example 3
Source File: SettingsTab.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent arg0) {
    SettingsTableModel model = getSettingsTableModel();
    int[] rowIndexes = table.getSelectedRows();
    for (int rowIndex : rowIndexes) {
        if (rowIndex != -1) {
            UpdateUnitProvider provider = model.getUpdateUnitProvider(rowIndex);
            if (provider != null) {//NOI18N
                String msg = NbBundle.getMessage(SettingsTab.class, "SettingsTab.bRemove.message",provider.getDisplayName());
                NotifyDescriptor nd = new NotifyDescriptor.Confirmation (msg);
                nd.setOptionType(NotifyDescriptor.YES_NO_OPTION);
                Object object = DialogDisplayer.getDefault ().notify (nd);
                if (NotifyDescriptor.YES_OPTION.equals (object)) {
                    model.remove(rowIndex);
                }
            }
        }
    }
    model.refreshModel();
    if (rowIndexes.length > 0) {
        if (model.getRowCount() > rowIndexes[0]) {
            table.getSelectionModel().setSelectionInterval(rowIndexes[0], rowIndexes[0]);
        } else {
            table.getSelectionModel().setSelectionInterval(0, 0);
        }
    }
}
 
Example 4
Source File: WebFreeFormActionProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Display an alert asking the user whether to really generate a target.
 * @param commandDisplayName the display name of the action to be bound
 * @param scriptPath the path that to the script that will be generated or written to
 * @return true if IDE should proceed
 */
private boolean alert(String commandDisplayName, String scriptPath) {
    String projectDisplayName = ProjectUtils.getInformation(project).getDisplayName();
    String title = NbBundle.getMessage(WebFreeFormActionProvider.class, "TITLE_generate_target_dialog", commandDisplayName, projectDisplayName);
    String body = NbBundle.getMessage(WebFreeFormActionProvider.class, "TEXT_generate_target_dialog", commandDisplayName, scriptPath);
    NotifyDescriptor d = new NotifyDescriptor.Message(body, NotifyDescriptor.QUESTION_MESSAGE);
    d.setTitle(title);
    d.setOptionType(NotifyDescriptor.OK_CANCEL_OPTION);
    JButton generate = new JButton(NbBundle.getMessage(WebFreeFormActionProvider.class, "LBL_generate"));
    generate.setDefaultCapable(true);
    d.setOptions(new Object[] {generate, NotifyDescriptor.CANCEL_OPTION});
    return DialogDisplayer.getDefault().notify(d) == generate;
}
 
Example 5
Source File: AppClientProjectProperties.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static boolean showModifiedMessage (String title) {
    String message = NbBundle.getMessage(AppClientProjectProperties.class,"TXT_Regenerate");
    JButton regenerateButton = new JButton (NbBundle.getMessage(AppClientProjectProperties.class,"CTL_RegenerateButton"));
    regenerateButton.setDefaultCapable(true);
    regenerateButton.getAccessibleContext().setAccessibleDescription (NbBundle.getMessage(AppClientProjectProperties.class,"AD_RegenerateButton"));
    NotifyDescriptor d = new NotifyDescriptor.Message (message, NotifyDescriptor.WARNING_MESSAGE);
    d.setTitle(title);
    d.setOptionType(NotifyDescriptor.OK_CANCEL_OPTION);
    d.setOptions(new Object[] {regenerateButton, NotifyDescriptor.CANCEL_OPTION});        
    return DialogDisplayer.getDefault().notify(d) == regenerateButton;
}
 
Example 6
Source File: BundleNodeCustomizer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void removeLocalesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeLocalesActionPerformed
    Object[] selectedValues = localesList.getSelectedValues();

    String basicName = propDataObject.getPrimaryFile().getName();
    basicName = Util.getBaseName(basicName);
    
    NotifyDescriptor descriptor = new NotifyDescriptor.Confirmation(NbBundle.getMessage(BundleNodeCustomizer.class, "CTL_Deletebundle_Prompt"));
    descriptor.setTitle(NbBundle.getMessage(BundleNodeCustomizer.class, "CTL_Deletebundle_Title"));
    descriptor.setMessageType(JOptionPane.WARNING_MESSAGE);
    descriptor.setOptionType(NotifyDescriptor.YES_NO_OPTION);

    Object res = DialogDisplayer.getDefault().notify(descriptor);
    if (res != NotifyDescriptor.YES_OPTION) {
        return;
    }

    for(int i=0; i<selectedValues.length; i++) {
        PropertiesFileEntry entry = propDataObject.getBundleStructure().getEntryByFileName(basicName + PropertiesDataLoader.PRB_SEPARATOR_CHAR + selectedValues[i].toString());
        try {
            entry.delete();
            if (!propDataObject.isValid()) {
                propDataObject = Util.findPrimaryDataObject(propDataObject);
                nameText.setText(propDataObject.getName());
            }
        } catch(IOException ioe) {
            org.openide.ErrorManager.getDefault().notify(org.openide.ErrorManager.INFORMATIONAL, ioe);
        }
    }
    
    localesList.setListData(retrieveLocales(propDataObject));
}
 
Example 7
Source File: CommitAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static boolean commitAfterMerge (boolean locallyModifiedExcluded, File repository) {
    // XXX consider usage of repository to determine if there are any non-included files which have to be committed, too
    // and thus removing the option HgModuleConfig.getDefault().getConfirmCommitAfterMerge()
    if (locallyModifiedExcluded || HgModuleConfig.getDefault().getConfirmCommitAfterMerge()) { // ask before commit?
        NotifyDescriptor descriptor = new NotifyDescriptor.Confirmation(NbBundle.getMessage(CommitAction.class, "MSG_COMMIT_AFTER_MERGE_QUERY")); // NOI18N
        descriptor.setTitle(NbBundle.getMessage(CommitAction.class, "MSG_COMMIT_AFTER_MERGE_TITLE")); // NOI18N
        descriptor.setMessageType(JOptionPane.WARNING_MESSAGE);
        descriptor.setOptionType(NotifyDescriptor.YES_NO_OPTION);

        Object res = DialogDisplayer.getDefault().notify(descriptor);
        return res == NotifyDescriptor.YES_OPTION;
    }
    return true;
}