Java Code Examples for org.openide.NotifyDescriptor#OK_OPTION

The following examples show how to use org.openide.NotifyDescriptor#OK_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: RemoteUtils.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Display remote exception in a dialog window to inform user about error
 * on a remote server.
 * @param remoteException remote exception to be displayed
 */
@NbBundle.Messages({
    "LBL_RemoteError=Remote Error",
    "# {0} - reason of the failure",
    "MSG_RemoteErrorReason=\n\nReason: {0}"
})
public static void processRemoteException(RemoteException remoteException) {
    String title = Bundle.LBL_RemoteError();
    StringBuilder message = new StringBuilder(remoteException.getMessage());
    String remoteServerAnswer = remoteException.getRemoteServerAnswer();
    Throwable cause = remoteException.getCause();
    if (remoteServerAnswer != null && remoteServerAnswer.length() > 0) {
        message.append(Bundle.MSG_RemoteErrorReason(remoteServerAnswer));
    } else if (cause != null) {
        message.append(Bundle.MSG_RemoteErrorReason(cause.getMessage()));
    }
    NotifyDescriptor notifyDescriptor = new NotifyDescriptor(
            message.toString(),
            title,
            NotifyDescriptor.OK_CANCEL_OPTION,
            NotifyDescriptor.ERROR_MESSAGE,
            new Object[] {NotifyDescriptor.OK_OPTION},
            NotifyDescriptor.OK_OPTION);
    DialogDisplayer.getDefault().notifyLater(notifyDescriptor);
}
 
Example 2
Source File: OutputTab.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Invokes a file dialog and if a file is chosen, saves the output to that file.
 */
void saveAs() {
    OutWriter out = getOut();
    if (out == null) {
        return;
    }
    File f = showFileChooser(this);
    if (f != null) {
        try {
            synchronized (out) {
                out.getLines().saveAs(f.getPath());
            }
        } catch (IOException ioe) {
            NotifyDescriptor notifyDesc = new NotifyDescriptor(
                    NbBundle.getMessage(OutputTab.class, "MSG_SaveAsFailed", f.getPath()),
                    NbBundle.getMessage(OutputTab.class, "LBL_SaveAsFailedTitle"),
                    NotifyDescriptor.DEFAULT_OPTION,
                    NotifyDescriptor.ERROR_MESSAGE,
                    new Object[]{NotifyDescriptor.OK_OPTION},
                    NotifyDescriptor.OK_OPTION);

            DialogDisplayer.getDefault().notify(notifyDesc);
        }
    }
}
 
Example 3
Source File: FormattingCustomizerPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void globalButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_globalButtonActionPerformed

    NotifyDescriptor d = new NotifyDescriptor.Confirmation(
            NbBundle.getMessage(FormattingCustomizerPanel.class, "MSG_use_global_settings_confirmation"), //NOI18N
            NbBundle.getMessage(FormattingCustomizerPanel.class, "MSG_use_global_settings_confirmation_title"), //NOI18N
            NotifyDescriptor.OK_CANCEL_OPTION
    );

    if (DialogDisplayer.getDefault().notify(d) == NotifyDescriptor.OK_OPTION) {
        pf.getPreferences("").parent().put(USED_PROFILE, DEFAULT_PROFILE); //NOI18N
        loadButton.setEnabled(false);
        setEnabled(jScrollPane1, false);
    } else {
        projectButton.setSelected(true);
    }

}
 
Example 4
Source File: BreakpointsActionsProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static void setGroupName (Object[] nodes) {
    NotifyDescriptor.InputLine descriptor = new NotifyDescriptor.InputLine (
        NbBundle.getMessage
            (BreakpointsActionsProvider.class, "CTL_BreakpointAction_GroupDialog_NameLabel"),
        NbBundle.getMessage
            (BreakpointsActionsProvider.class, "CTL_BreakpointAction_GroupDialog_Title")
    );
    if (DialogDisplayer.getDefault ().notify (descriptor) == 
        NotifyDescriptor.OK_OPTION
    ) {
       int i, k = nodes.length;
        String newName = descriptor.getInputText ();
        for (i = 0; i < k; i++) {
            if (nodes [i] instanceof BreakpointGroup) {
                BreakpointGroup g = (BreakpointGroup) nodes[i];
                setGroupName(g, newName);
            } else if (nodes [i] instanceof Breakpoint) {
                ((Breakpoint) nodes [i]).setGroupName ( newName );
            }
        }
    }
}
 
Example 5
Source File: AddEntityDialog.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Opens dialog for adding entities.
 * @return fully qualified names of the selected entities' classes.
 */
public static List<String> open(EntityClassScope entityClassScope, Set<String> ignoreClassNames){
    AddEntityPanel panel = AddEntityPanel.create(entityClassScope, ignoreClassNames);
    
    final DialogDescriptor nd = new DialogDescriptor(
            panel,
            NbBundle.getMessage(AddEntityDialog.class, "LBL_AddEntity"),
            true,
            DialogDescriptor.OK_CANCEL_OPTION,
            DialogDescriptor.OK_OPTION,
            DialogDescriptor.DEFAULT_ALIGN,
            new HelpCtx(AddEntityPanel.class),
            null
            );
    
    Object button = DialogDisplayer.getDefault().notify(nd);
    if (button != NotifyDescriptor.OK_OPTION) {
        return Collections.emptyList();
    }
    
    return Collections.unmodifiableList(panel.getSelectedEntityClasses());
}
 
Example 6
Source File: EditPanelServer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
void showErrorDialog() {

	Object[] options = { NotifyDescriptor.OK_OPTION };
	
	NotifyDescriptor errorDialog = 
	    new NotifyDescriptor((Object)NbBundle.getBundle(EditPanelServer.class).getString("MON_Bad_server"),
				 NbBundle.getBundle(EditPanelServer.class).getString("MON_Invalid_input"),
				 NotifyDescriptor.DEFAULT_OPTION,
				 NotifyDescriptor.ERROR_MESSAGE, 
				 options,
				 NotifyDescriptor.OK_OPTION);

	DialogDisplayer.getDefault().notify(errorDialog);
    }
 
Example 7
Source File: InitAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void notifyImportImpossible(String msg) {
    NotifyDescriptor nd =
        new NotifyDescriptor(
            msg,
            NbBundle.getMessage(InitAction.class, "MSG_ImportNotAllowed"), // NOI18N
            NotifyDescriptor.DEFAULT_OPTION,
            NotifyDescriptor.WARNING_MESSAGE,
            new Object[] {NotifyDescriptor.OK_OPTION},
            NotifyDescriptor.OK_OPTION);
    DialogDisplayer.getDefault().notify(nd);
}
 
Example 8
Source File: AddQueryParameterDlg.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Creates new form AddQueryParameterDlg */
public AddQueryParameterDlg(boolean modal, String columnName) {

    initComponents();
    // try to make it so that the default information in the field is pre-selected so that the user
    // can simply type over it without having to select it.
    valueTxtField.setSelectionEnd(valueTxtField.getText().length());
    parmTxtField.setSelectionStart(0);
    parmTxtField.setSelectionEnd(parmTxtField.getText().length());

    ActionListener listener = new ActionListener () {

            public void actionPerformed (ActionEvent evt) {
                Object o = evt.getSource();
                if (o == NotifyDescriptor.CANCEL_OPTION) {
                    returnStatus = RET_CANCEL;
                } else if (o == NotifyDescriptor.OK_OPTION) {
                    // do something useful
                    returnStatus = RET_OK;
                } // else if HELP ...
            }
        };

    // Note - we may want to use the version that also has help (check with Jeff)
    DialogDescriptor dlg =
        new DialogDescriptor(this,
                NbBundle.getMessage(AddQueryParameterDlg.class,
                             "ADD_QUERY_CRITERIA_TITLE"),     // NOI18N
                             modal, listener);

    dlg.setHelpCtx (
        new HelpCtx( "projrave_ui_elements_dialogs_add_query_criteria" ) );        // NOI18N

    setColumnName(columnName);
    dialog = DialogDisplayer.getDefault().createDialog(dlg);
    dialog.setVisible(true);
}
 
Example 9
Source File: QueryController.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void onRemove() {
    NotifyDescriptor nd = new NotifyDescriptor.Confirmation(
        NbBundle.getMessage(QueryController.class, "MSG_RemoveQuery", new Object[] { query.getDisplayName() }), // NOI18N
        NbBundle.getMessage(QueryController.class, "CTL_RemoveQuery"),      // NOI18N
        NotifyDescriptor.OK_CANCEL_OPTION);

    if(DialogDisplayer.getDefault().notify(nd) == NotifyDescriptor.OK_OPTION) {
        Bugzilla.getInstance().getRequestProcessor().post(new Runnable() {
            @Override
            public void run() {
                remove();
            }
        });
    }
}
 
Example 10
Source File: FilterTopComponent.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void addFilterSetting() {
    NotifyDescriptor.InputLine l = new NotifyDescriptor.InputLine("Enter a name:", "Filter");
    if (DialogDisplayer.getDefault().notify(l) == NotifyDescriptor.OK_OPTION) {
        String name = l.getInputText();

        FilterSetting toRemove = null;
        for (FilterSetting s : filterSettings) {
            if (s.getName().equals(name)) {
                NotifyDescriptor.Confirmation conf = new NotifyDescriptor.Confirmation("Filter \"" + name + "\" already exists, to you want to overwrite?", "Filter");
                if (DialogDisplayer.getDefault().notify(conf) == NotifyDescriptor.YES_OPTION) {
                    toRemove = s;
                    break;
                } else {
                    return;
                }
            }
        }

        if (toRemove != null) {
            filterSettings.remove(toRemove);
        }
        FilterSetting setting = createFilterSetting(name);
        filterSettings.add(setting);

        // Sort alphabetically
        Collections.sort(filterSettings, new Comparator<FilterSetting>() {

            public int compare(FilterSetting o1, FilterSetting o2) {
                return o1.getName().compareTo(o2.getName());
            }
        });

        updateComboBox();
    }
}
 
Example 11
Source File: FilterTopComponent.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void addFilterSetting() {
    NotifyDescriptor.InputLine l = new NotifyDescriptor.InputLine("Name of the new profile:", "Filter Profile");
    if (DialogDisplayer.getDefault().notify(l) == NotifyDescriptor.OK_OPTION) {
        String name = l.getInputText();

        FilterSetting toRemove = null;
        for (FilterSetting s : filterSettings) {
            if (s.getName().equals(name)) {
                NotifyDescriptor.Confirmation conf = new NotifyDescriptor.Confirmation("Filter profile \"" + name + "\" already exists, do you want to replace it?", "Filter");
                if (DialogDisplayer.getDefault().notify(conf) == NotifyDescriptor.YES_OPTION) {
                    toRemove = s;
                    break;
                } else {
                    return;
                }
            }
        }

        if (toRemove != null) {
            filterSettings.remove(toRemove);
        }
        FilterSetting setting = createFilterSetting(name);
        filterSettings.add(setting);

        // Sort alphabetically
        Collections.sort(filterSettings, new Comparator<FilterSetting>() {

            @Override
            public int compare(FilterSetting o1, FilterSetting o2) {
                return o1.getName().compareTo(o2.getName());
            }
        });

        updateComboBox();
    }
}
 
Example 12
Source File: EditPanelCookies.java    From netbeans with Apache License 2.0 5 votes vote down vote up
void showErrorDialog() {

	Object[] options = { NotifyDescriptor.OK_OPTION };
	
	NotifyDescriptor errorDialog = 
	    new NotifyDescriptor((Object)NbBundle.getBundle(EditPanelCookies.class).getString("MON_Bad_cookie"),
				 NbBundle.getBundle(EditPanelCookies.class).getString("MON_Invalid_input"),
				 NotifyDescriptor.DEFAULT_OPTION,
				 NotifyDescriptor.ERROR_MESSAGE, 
				 options,
				 NotifyDescriptor.OK_OPTION);

	DialogDisplayer.getDefault().notify(errorDialog);
    }
 
Example 13
Source File: EditPanelQuery.java    From netbeans with Apache License 2.0 5 votes vote down vote up
void showErrorDialog() {

	Object[] options = { NotifyDescriptor.OK_OPTION };
	
	NotifyDescriptor errorDialog = 
	    new NotifyDescriptor((Object)NbBundle.getBundle(EditPanelQuery.class).getString("MON_Bad_param"),
				 NbBundle.getBundle(EditPanelQuery.class).getString("MON_Invalid_input"),
				 NotifyDescriptor.DEFAULT_OPTION,
				 NotifyDescriptor.ERROR_MESSAGE, 
				 options,
				 NotifyDescriptor.OK_OPTION);

	DialogDisplayer.getDefault().notify(errorDialog);
    }
 
Example 14
Source File: ProjectProblemsProviders.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
@NbBundle.Messages({
    "TITLE_UpgradeSourceLevel=Upgrade Source/Binary Format - \"{0}\" Project",
    "MSG_UpgradeSourceLevel=Upgrade the project source/binary format to the minimal supported one ({0})."
})
public Future<Result> resolve() {
    final Project project = FileOwnerQuery.getOwner(helper.getProjectDirectory());
    final Object option = DialogDisplayer.getDefault().notify(new NotifyDescriptor.Confirmation(
            MSG_UpgradeSourceLevel(minSourceVersion),
            TITLE_UpgradeSourceLevel(ProjectUtils.getInformation(project).getDisplayName()),
            NotifyDescriptor.OK_CANCEL_OPTION,
            NotifyDescriptor.QUESTION_MESSAGE));
    if (option == NotifyDescriptor.OK_OPTION) {
        return RP.submit(new Callable<ProjectProblemsProvider.Result>(){
            @Override
            @NonNull
            public Result call() throws Exception {
                return ProjectManager.mutex().writeAccess(new Mutex.Action<ProjectProblemsProvider.Result>() {
                    @Override
                    @NonNull
                    public ProjectProblemsProvider.Result run() {
                        try {
                            final EditableProperties ep = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
                            for (String prop : invalidVersionProps) {
                                ep.setProperty(prop, minSourceVersion.toString());
                            }
                            helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, ep);
                            ProjectManager.getDefault().saveProject(project);
                            return ProjectProblemsProvider.Result.create(ProjectProblemsProvider.Status.RESOLVED);
                        } catch (IOException ioe) {
                            return ProjectProblemsProvider.Result.create(ProjectProblemsProvider.Status.UNRESOLVED, ioe.getMessage());
                        }
                    }
                });
            }
        });
    } else {
        return new Done(ProjectProblemsProvider.Result.create(ProjectProblemsProvider.Status.UNRESOLVED));
    }
}
 
Example 15
Source File: Actions.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
    SortPanel panel = new SortPanel();
    NotifyDescriptor categoryNameDialog = new NotifyDescriptor(
            panel,
            NbBundle.getMessage(Actions.class, "MSG_SortDialog"),
            NotifyDescriptor.OK_CANCEL_OPTION,
            NotifyDescriptor.PLAIN_MESSAGE,
            null,
            NotifyDescriptor.OK_OPTION);
    if (DialogDisplayer.getDefault().notify(categoryNameDialog) == NotifyDescriptor.OK_OPTION) {
        panel.saveAttributes();
    }

}
 
Example 16
Source File: NbErrorManagerUserQuestionTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testUserQuestionExceptionDisplayedOK() 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.OK_OPTION;
    
    UQE ex = new UQE();
    Exceptions.printStackTrace(ex);
    
    waitEDT();

    assertNotNull("Dialog created", MockDD.lastDescriptor);
    assertEquals("Message is localized text", "Reboot?", MockDD.lastDescriptor.getMessage());
    assertTrue("The message has been confirmed", ex.confirm);
}
 
Example 17
Source File: CommandUtils.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** Return <code>true</code> if user wants to restart the current debug session. */
public static boolean warnNoMoreDebugSession() {
    String message = NbBundle.getMessage(CommandUtils.class, "MSG_NoMoreDebugSession");
    NotifyDescriptor descriptor = new NotifyDescriptor.Confirmation(message, NotifyDescriptor.OK_CANCEL_OPTION);
    return DialogDisplayer.getDefault().notify(descriptor) == NotifyDescriptor.OK_OPTION;
}
 
Example 18
Source File: ProjectRejectedTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public Object notify(NotifyDescriptor descriptor) {
    cnt++;
    return NotifyDescriptor.OK_OPTION;
}
 
Example 19
Source File: ProjectOpenTriggersAddOnsTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public Object notify(NotifyDescriptor descriptor) {
    cnt++;
    return NotifyDescriptor.OK_OPTION;
}
 
Example 20
Source File: SelectAppServerPanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public static boolean showServerSelectionDialog(Project project, J2eeModuleProvider provider, RunConfig config) {
    if (ExecutionChecker.DEV_NULL.equals(provider.getServerInstanceID())) {
        SelectAppServerPanel panel = new SelectAppServerPanel(isGoalOverridden(config), project);
        DialogDescriptor dd = new DialogDescriptor(panel, NbBundle.getMessage(SelectAppServerPanel.class, "TIT_Select"));
        panel.setNLS(dd.createNotificationLineSupport());
        Object obj = DialogDisplayer.getDefault().notify(dd);
        if (obj == NotifyDescriptor.OK_OPTION) {
            String instanceId = panel.getSelectedServerInstance();
            String serverId = panel.getSelectedServerType();
            if (!ExecutionChecker.DEV_NULL.equals(instanceId)) {
                boolean permanent = panel.isPermanent();
                boolean doNotRemember = panel.isDoNotRemember();

                // The server should be used only for this deployment
                if (doNotRemember) {
                    OneTimeDeployment oneTimeDeployment = project.getLookup().lookup(OneTimeDeployment.class);
                    if (oneTimeDeployment != null) {
                        oneTimeDeployment.setServerInstanceId(instanceId);
                    }

                    MavenProjectSupport.changeServer(project, true);
                } else if (permanent) {
                    persistServer(project, instanceId, serverId, panel.getChosenProject());
                } else {
                    SessionContent sc = project.getLookup().lookup(SessionContent.class);
                    if (sc != null) {
                        sc.setServerInstanceId(instanceId);
                    }

                    // We want to initiate context path to default value if there isn't related deployment descriptor yet
                    MavenProjectSupport.changeServer(project, true);
                }

                LoggingUtils.logUsage(ExecutionChecker.class, "USG_PROJECT_CONFIG_MAVEN_SERVER", new Object[] { MavenProjectSupport.obtainServerName(project) }, "maven"); //NOI18N

                return true;
            } else {
                //ignored used now..
                if (panel.isIgnored() && config != null) {
                    removeNetbeansDeployFromActionMappings(project, config.getActionName());
                    return true;
                }
            }
        }
        StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(SelectAppServerPanel.class, "ERR_Action_without_deployment_server"));
        return false;
    }
    return true;
}