Java Code Examples for org.openide.NotifyDescriptor#CANCEL_OPTION

The following examples show how to use org.openide.NotifyDescriptor#CANCEL_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: EditPanelCookies.java    From netbeans with Apache License 2.0 6 votes vote down vote up
void showConfirmDialog(String msg) {

	Object[] options = { NotifyDescriptor.OK_OPTION, 
			   NotifyDescriptor.CANCEL_OPTION 
	};
	
	NotifyDescriptor confirmDialog = 
	    new NotifyDescriptor((Object)msg, 
				 NbBundle.getBundle(EditPanelCookies.class).getString("MON_Confirmation_Required"),
				 NotifyDescriptor.OK_CANCEL_OPTION,
				 NotifyDescriptor.QUESTION_MESSAGE, 
				 options,
				 NotifyDescriptor.CANCEL_OPTION);

	DialogDisplayer.getDefault().notify(confirmDialog);
	if(confirmDialog.getValue().equals(NotifyDescriptor.OK_OPTION)) 
	    setCookies = true;
	else 
	    setCookies = false;
    }
 
Example 2
Source File: EditPanelQuery.java    From netbeans with Apache License 2.0 6 votes vote down vote up
void showConfirmDialog(String msg) {

	Object[] options = { NotifyDescriptor.OK_OPTION, 
			   NotifyDescriptor.CANCEL_OPTION 
	};
	
	NotifyDescriptor confirmDialog = 
	    new NotifyDescriptor((Object)msg, 
				 NbBundle.getBundle(EditPanelQuery.class).getString("MON_Confirmation_Required"),
				 NotifyDescriptor.OK_CANCEL_OPTION,
				 NotifyDescriptor.QUESTION_MESSAGE, 
				 options,
				 NotifyDescriptor.CANCEL_OPTION);

	DialogDisplayer.getDefault().notify(confirmDialog);
	if(confirmDialog.getValue().equals(NotifyDescriptor.OK_OPTION)) 
	    setParams = true;
	else 
	    setParams = false;
    }
 
Example 3
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 4
Source File: FetchAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@NbBundle.Messages({
    "LBL_FetchAction.appliedPatches.title=Mercurial Patches applied",
    "MSG_FetchAction.appliedPatches.text=You have applied patches from the active Mercurial queue.\n\n"
        + "Do you want to pop them first before the operation\nstarts and apply them right after it finishes?"
})
static QPatch selectPatch (File root) throws HgException {
    QPatch[] patches = HgCommand.qListSeries(root);
    QPatch topPatch = null;
    for (QPatch patch : patches) {
        if (patch.isApplied()) {
            topPatch = patch;
        }
    }
    if (topPatch != null) {
        Object conf = DialogDisplayer.getDefault().notify(new NotifyDescriptor.Confirmation(
                Bundle.MSG_FetchAction_appliedPatches_text(), 
                Bundle.LBL_FetchAction_appliedPatches_title(),
                NotifyDescriptor.YES_NO_CANCEL_OPTION, NotifyDescriptor.WARNING_MESSAGE));
        if (conf == NotifyDescriptor.CANCEL_OPTION) {
            throw new HgException.HgCommandCanceledException("Canceled"); //NOI18N
        } else if (conf == NotifyDescriptor.NO_OPTION) {
            topPatch = null;
        }
    }
    return topPatch;
}
 
Example 5
Source File: DialogDisplayer128399Test.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testDefaultOptionWithStandardCancel () {
    JButton testButton = new JButton ("for-test-only");
    DialogDescriptor dd = new DialogDescriptor (
            "Hello", // innerPane
            "title", // title
            false, // isModal
            new Object[] { NotifyDescriptor.OK_OPTION, NotifyDescriptor.CANCEL_OPTION }, // options
            NotifyDescriptor.CANCEL_OPTION, // initialValue
            DialogDescriptor.DEFAULT_ALIGN, // optionsAlign
            HelpCtx.DEFAULT_HELP, // help
            null); // action listener
    dd.setAdditionalOptions (new JButton[] {testButton});
    Dialog dlg = DialogDisplayer.getDefault ().createDialog (dd);
    //dlg.setVisible (true);
    assertEquals ("CANCEL_OPTION is the default value.", NotifyDescriptor.CANCEL_OPTION, dd.getDefaultValue ());
    assertEquals ("CANCEL_OPTION is the default button on dialog",
            NbBundle.getBundle (NbPresenter.class).getString ("CANCEL_OPTION_CAPTION"),
            testButton.getRootPane ().getDefaultButton ().getText ());
    //dlg.dispose ();
}
 
Example 6
Source File: TemplateSelector.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static byte[] getFileContentsAsByteArray (File file) throws IOException {
    long length = file.length();
    if(length > 1024 * 10) {
        NotifyDescriptor nd =
            new NotifyDescriptor(
                NbBundle.getMessage(TemplateSelector.class, "MSG_FileTooBig"),
                NbBundle.getMessage(TemplateSelector.class, "LBL_FileTooBig"),    // NOI18N
                NotifyDescriptor.DEFAULT_OPTION,
                NotifyDescriptor.WARNING_MESSAGE,
                new Object[] {NotifyDescriptor.OK_OPTION, NotifyDescriptor.CANCEL_OPTION},
                NotifyDescriptor.OK_OPTION);
        if(DialogDisplayer.getDefault().notify(nd) != NotifyDescriptor.OK_OPTION) {
            return null;
        }
    }

    return FileUtils.getFileContentsAsByteArray(file);
}
 
Example 7
Source File: ServerInstance.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Start the admin server in the profile mode. Show UI feedback. 
 *
 * @throws ServerException if the server cannot be started.
 */
public void startProfile(boolean forceRestart, ProgressUI ui) 
throws ServerException {
    // check whether another server not already running in profile mode
    // and ask whether it is ok to stop it
    ServerInstance tmpProfiledServerInstance = profiledServerInstance.get();
    if (tmpProfiledServerInstance != null && tmpProfiledServerInstance != this) {
        String msg = NbBundle.getMessage(
                                ServerInstance.class,
                                "MSG_AnotherServerProfiling",
                                tmpProfiledServerInstance.getDisplayName());
        NotifyDescriptor nd = new NotifyDescriptor.Confirmation(msg, NotifyDescriptor.OK_CANCEL_OPTION);
        if (DialogDisplayer.getDefault().notify(nd) == NotifyDescriptor.CANCEL_OPTION) {
            // start in profile mode has been cancelled
            String err = NbBundle.getMessage(ServerInstance.class, "MSG_ProfilingCancelled", getDisplayName());
            throw new ServerException(err);
        }
    }
    try {
        setServerState(STATE_WAITING);
        // target == null - admin server
        _startProfile(null, forceRestart, ui);
    } finally {
        refresh();
    }
}
 
Example 8
Source File: AfterRestartExceptions.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@NbBundle.Messages({ "TTL_AfterRestartReport=Unexpected Exception on Last Run",
                     "MSG_AfterRestartReportQuestion=There was an error during the last run of NetBeans IDE.\nCan you please report the problem?",
                     "BTN_ReviewAndReport=&Review and Report Problem" })
@Override
public void run() {
    
    final Set<LogRecord> records = afterRestartRecords;
    
    String msg = Bundle.MSG_AfterRestartReportQuestion();
    String title = Bundle.TTL_AfterRestartReport();
    int optionType = NotifyDescriptor.QUESTION_MESSAGE;
    JButton reportOption = new JButton();
    Mnemonics.setLocalizedText(reportOption, Bundle.BTN_ReviewAndReport());
    NotifyDescriptor confMessage = new NotifyDescriptor(msg, title, optionType,
                                                        NotifyDescriptor.QUESTION_MESSAGE,
                                                        new Object[] { reportOption, NotifyDescriptor.CANCEL_OPTION },
                                                        reportOption);
    Object ret = DialogDisplayer.getDefault().notify(confMessage);
    if (ret == reportOption) {
        Installer.RP.post(new Runnable() {
            @Override
            public void run() {
                Installer.displaySummary("ERROR_URL", true, false, true,
                                         Installer.DataType.DATA_UIGESTURE,
                                         new ArrayList<>(records), null, true);
                Installer.setSelectedExcParams(null);
                afterRestartRecords = null;
            }
        });
    }
    
}
 
Example 9
Source File: EditClusterPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Displays Add Cluster dialog and lets user select path to external cluster.
 *
 * @param prj Project into which the path will be stored. Returned path is relative to the project dir if possible.
 * @return Info for newly added cluster or null if user cancelled the dialog.
 */
static ClusterInfo showAddDialog(Project prj) {
    EditClusterPanel panel = new EditClusterPanel();
    panel.prjDir = FileUtil.toFile(prj.getProjectDirectory());
    panel.prj = prj;
    SourceRootsSupport srs = new SourceRootsSupport(new URL[0], null);
    panel.sourcesPanel.setSourceRootsProvider(srs);
    JavadocRootsSupport jrs = new JavadocRootsSupport(new URL[0], null);
    panel.javadocPanel.setJavadocRootsProvider(jrs);
    DialogDescriptor descriptor = new DialogDescriptor(
            panel,
            NbBundle.getMessage(EditClusterPanel.class, "CTL_AddCluster_Title"), // NOI18N
            true,
            new Object[] { panel.okButton, NotifyDescriptor.CANCEL_OPTION },
            panel.okButton,
            DialogDescriptor.DEFAULT_ALIGN,
            new HelpCtx("org.netbeans.modules.apisupport.project.ui.customizer.EditClusterPanel"),
            null);
    descriptor.setClosingOptions(null);
    Dialog dlg = DialogDisplayer.getDefault().createDialog(descriptor);
    panel.updateDialog();
    dlg.setVisible(true);
    ClusterInfo retVal = null;
    if (descriptor.getValue() == panel.okButton) {
        retVal = ClusterInfo.createExternal(panel.getAbsoluteClusterPath(),
                srs.getSourceRoots(), jrs.getJavadocRoots(), true);

    }
    dlg.dispose();
    return retVal;
}
 
Example 10
Source File: EditPreferencesAction.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
public void performAction() {
   EditPreferencesJPanel prefsPanel;
   Object [] options =  {  NotifyDescriptor.OK_OPTION,
                             NotifyDescriptor.CANCEL_OPTION,
                             helpBtn};
   try {
      prefsPanel = new EditPreferencesJPanel();
      //DialogDescriptor prefsDialog = new DialogDescriptor(prefsPanel, "Preferences");
      DialogDescriptor prefsDialog = new DialogDescriptor(prefsPanel,
                                         "Preferences",
                                         true,
                                         options,
                                         NotifyDescriptor.OK_OPTION,
                                         DialogDescriptor.DEFAULT_ALIGN,
                                         null,
                                         new ActionListener() {

                                             @Override
                                             public void actionPerformed(ActionEvent ae) {
                                                 if(ae.getSource().equals(helpBtn)) {
                                                     BrowserLauncher.openURL("https://simtk-confluence.stanford.edu/display/OpenSim40/User+Preferences");
                                                 }
                                             }
                                         });
      setEnabled(false);
      DialogDisplayer.getDefault().createDialog(prefsDialog).setVisible(true);
      setEnabled(true);

     //when JDialog is closed, do something
     Object userInput = prefsDialog.getValue();
     if (userInput == NotifyDescriptor.OK_OPTION)
         prefsPanel.apply();
     return;
   } catch (BackingStoreException ex) {
      ex.printStackTrace();
   }
}
 
Example 11
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 12
Source File: DataEditorSupportMoveTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public Object notify(NotifyDescriptor descriptor) {
    called = new Exception("Notify called");
    return NotifyDescriptor.CANCEL_OPTION;
}
 
Example 13
Source File: TemplateWizardTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public Object notify(NotifyDescriptor descriptor) {
    return NotifyDescriptor.CANCEL_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: ExitDialog.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Opens the ExitDialog.
 */
private static boolean innerShowDialog() {
    Collection<? extends Savable> set = Savable.REGISTRY.lookupAll(Savable.class);
    if (!set.isEmpty()) {

        // XXX(-ttran) caching this dialog is fatal.  If the user
        // cancels the Exit action, modifies some more files and tries to
        // Exit again the list of modified DataObject's is not updated,
        // changes made by the user after the first aborted Exit will be
        // lost.
        exitDialog = null;
        
        if (exitDialog == null) {
            ResourceBundle bundle = NbBundle.getBundle(ExitDialog.class);
            JButton buttonSave = new JButton();
            buttonSave.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_Save"));
            JButton buttonSaveAll = new JButton();
            buttonSaveAll.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_SaveAll"));
            JButton buttonDiscardAll = new JButton();
            buttonDiscardAll.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_DiscardAll"));

            // special handling to handle a button title with mnemonic 
            // and to allow enable/disable control of the option
            Mnemonics.setLocalizedText(buttonSave, bundle.getString("CTL_Save"));
            Mnemonics.setLocalizedText(buttonSaveAll, bundle.getString("CTL_SaveAll"));
            Mnemonics.setLocalizedText(buttonDiscardAll, bundle.getString("CTL_DiscardAll"));

            exitOptions = new Object[] {
                              buttonSave,
                              buttonSaveAll,
                              buttonDiscardAll,
                          };
            ExitDialog exitComponent = new ExitDialog ();
            DialogDescriptor exitDlgDescriptor = new DialogDescriptor (
                                                     exitComponent,                                                   // inside component
                                                     bundle.getString("CTL_ExitTitle"), // title
                                                     true,                                                            // modal
                                                     exitOptions,                                                     // options
                                                     NotifyDescriptor.CANCEL_OPTION,                                  // initial value
                                                     DialogDescriptor.RIGHT_ALIGN,                                    // option align
                                                     null,                                                            // HelpCtx
                                                     exitComponent                                                    // Action Listener
                                                 );
            exitDlgDescriptor.setHelpCtx( new HelpCtx( "help_on_exit_dialog" ) ); //NOI18N
            exitDlgDescriptor.setAdditionalOptions (new Object[] {NotifyDescriptor.CANCEL_OPTION});
            exitDialog = org.openide.DialogDisplayer.getDefault ().createDialog (exitDlgDescriptor);
        }

        result = false;
        exitDialog.setVisible(true); // Show the modal Save dialog
        return result;

    }
    else
        return true;
}
 
Example 16
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);
}
 
Example 17
Source File: ExitDialog.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** Opens the ExitDialog for activated nodes or for
   * whole repository.
   */
  private static boolean innerShowDialog (Set<DataObject> openedFiles) {
      if (!openedFiles.isEmpty()) {
          if (SAVE_ALL_UNCONDITIONALLY) {
              //this section should be invoked only by tests!
for (DataObject d: openedFiles) {
                  doSave(d);
              }
              
              return true;
          }

          // XXX(-ttran) caching this dialog is fatal.  If the user
          // cancels the Exit action, modifies some more files and tries to
          // Exit again the list of modified DataObject's is not updated,
          // changes made by the user after the first aborted Exit will be
          // lost.
          exitDialog = null;
          
          if (exitDialog == null) {
              ResourceBundle bundle = NbBundle.getBundle(ExitDialog.class);
              JButton buttonSave = new JButton();
              buttonSave.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_Save"));
              JButton buttonSaveAll = new JButton();
              buttonSaveAll.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_SaveAll"));
              JButton buttonDiscardAll = new JButton();
              buttonDiscardAll.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_DiscardAll"));
              
              Mnemonics.setLocalizedText(buttonSave, bundle.getString("CTL_Save"));
              Mnemonics.setLocalizedText(buttonSaveAll, bundle.getString ("CTL_SaveAll"));
              Mnemonics.setLocalizedText(buttonDiscardAll, bundle.getString ("CTL_DiscardAll"));
              
              exitOptions = new Object[] {
                                buttonSave,
                                buttonSaveAll,
                                buttonDiscardAll,
                            };
              ExitDialog exitComponent = null;
              exitComponent = new ExitDialog (openedFiles);
              DialogDescriptor exitDlgDescriptor = new DialogDescriptor (
                                                       exitComponent,                                                   // inside component
                                                       bundle.getString("CTL_ExitTitle"), // title
                                                       true,                                                            // modal
                                                       exitOptions,                                                     // options
                                                       NotifyDescriptor.CANCEL_OPTION,                                  // initial value
                                                       DialogDescriptor.RIGHT_ALIGN,                                    // option align
                                                       null,                                                            // no help
                                                       exitComponent                                                    // Action Listener
                                                   );
              exitDlgDescriptor.setAdditionalOptions (new Object[] {NotifyDescriptor.CANCEL_OPTION});
              exitDialog = DialogDisplayer.getDefault ().createDialog (exitDlgDescriptor);
          }

          result = false;
          exitDialog.setVisible (true); // Show the modal Save dialog
          return result;

      }
      else
          return true;
  }
 
Example 18
Source File: FormEditorSupport.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Reports errors occurred during loading or saving the form.
 */
private void reportErrors() {
    if (!formEditor.isFormLoaded()) {
        formEditor.reportLoadingErrors(null); // fatal error, no options
    } else {
        // The form was loaded with some non-fatal errors - some data
        // was not loaded - show a warning about possible data loss.
        // The dialog is shown later to let the designer opening complete.
        JButton viewButton = new JButton();
        Mnemonics.setLocalizedText(viewButton, FormUtils.getBundleString("CTL_ViewOnly")); // NOI18N
        JButton editButton = new JButton();
        Mnemonics.setLocalizedText(editButton, FormUtils.getBundleString("CTL_AllowEditing")); // NOI18N
        final Object[] options = new Object[] { viewButton, editButton,
                                                NotifyDescriptor.CANCEL_OPTION };
        final DialogDescriptor dd = formEditor.reportLoadingErrors(options);
        if (dd != null) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                @Override
                public void run() {
                    if (formEditor != null && !formEditor.isFormLoaded()) {
                        return; // quite unlikely, but the form could be closed meanwhile (#164444)
                    }
                    Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
                    // hack: adjust focus so it is not on the Show Exceptions button
                    if (dialog instanceof JDialog) {
                        ((JDialog)dialog).getContentPane().requestFocus();
                    }
                    dialog.setVisible(true);
                    dialog.dispose();

                    Object ret = dd.getValue();
                    if (ret == options[0]) { // View Only
                        formEditor.setFormReadOnly();
                        updateMVTCDisplayName();
                    } else if (ret == options[1]) { // Allow Editing
                        formEditor.destroyInvalidComponents();
                    } else { // close form, switch to source editor
                        closeFormEditor();
                    }
                }
            });
        }
    }
}
 
Example 19
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 20
Source File: AddTableDlg.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** Creates new form AddTableDlg */

    public AddTableDlg(String[] tableList,
                       boolean modal)
    {
        _tableList = tableList;
        initComponents();

        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;
                    }
                }
            };

        MouseListener mouseListener = new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 2) {
                    returnStatus = RET_OK;
                    dialog.setVisible(false);
                }
            }
        };
        _tableJList.addMouseListener(mouseListener);


        DialogDescriptor dlg =
            new DialogDescriptor(this,
                                 NbBundle.getMessage(AddTableDlg.class, "Add_Table_Title"),     // NOI18N
                                 modal,
                                 listener);
        dlg.setHelpCtx (
            new HelpCtx( "projrave_ui_elements_editors_about_query_editor" ) );        // NOI18N

        dialog = DialogDisplayer.getDefault().createDialog(dlg);
        dialog.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(AddTableDlg.class, "TABLE_LIST_a11yDescription"));
        dialog.setVisible(true);
    }