Java Code Examples for org.openide.NotifyDescriptor#NO_OPTION

The following examples show how to use org.openide.NotifyDescriptor#NO_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: CloneableEditorUserQuestionAsync2Test.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testExceptionThrownWhenDocumentIsBeingReadNo () throws Exception {
    MyEx my = new MyEx();

    toThrow = my;

    DD.options = null;
    DD.toReturn = NotifyDescriptor.NO_OPTION;
    
    support.open ();
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            JEditorPane[] panes = support.getOpenedPanes();
            assertNull(panes);
        }
    });
}
 
Example 2
Source File: DefaultDataObjectHasOpenTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
protected void tearDown() throws Exception {
    waitForAWT();
    DD.disableTest = true;

    super.tearDown();
    if (obj != null) {
        CloseCookie cc;
        cc = obj.getCookie(CloseCookie.class);
        if (cc != null) {
            DD.toReturn = NotifyDescriptor.NO_OPTION;
            cc.close();
        }
    }

    waitForAWT();
}
 
Example 3
Source File: XMLDataObjectMimeTypeTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
protected void tearDown() throws Exception {
    waitForAWT();
    DD.disableTest = true;

    super.tearDown();
    if (obj != null) {
        CloseCookie cc;
        cc = obj.getCookie(CloseCookie.class);
        if (cc != null) {
            DD.toReturn = NotifyDescriptor.NO_OPTION;
            cc.close();
        }
    }
    Repository.getDefault().removeFileSystem(lfs);

    waitForAWT();
}
 
Example 4
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 5
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 6
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 7
Source File: ProfilerDialogsProviderImpl.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Boolean displayConfirmationDNSA(String message, String caption, String dnsaMessage, boolean cancellable, String key, boolean dnsaDefault) {
    ProfilerDialogs.DNSAConfirmation dnsa = new ProfilerDialogs.DNSAConfirmation(
            key, message, cancellable ? NotifyDescriptor.YES_NO_CANCEL_OPTION : NotifyDescriptor.YES_NO_OPTION);
    if (caption != null) dnsa.setTitle(caption);
    if (dnsaMessage != null) dnsa.setDNSAMessage(dnsaMessage);
    dnsa.setDNSADefault(dnsaDefault);
    Object ret = ProfilerDialogs.notify(dnsa);
    if (ret == NotifyDescriptor.YES_OPTION) return Boolean.TRUE;
    if (ret == NotifyDescriptor.NO_OPTION) return Boolean.FALSE;
    return null;
}
 
Example 8
Source File: UpgradeAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private boolean confirm (String title, String message) {
    NotifyHtmlPanel p = new NotifyHtmlPanel();
    p.setText(message);
    NotifyDescriptor descriptor = new NotifyDescriptor(
            p, 
            title,
            NotifyDescriptor.OK_CANCEL_OPTION,
            NotifyDescriptor.QUESTION_MESSAGE,
            new Object [] { NotifyDescriptor.YES_OPTION, NotifyDescriptor.NO_OPTION },
            NotifyDescriptor.YES_OPTION);
    return NotifyDescriptor.YES_OPTION == DialogDisplayer.getDefault().notify(descriptor);
}
 
Example 9
Source File: SftpClient.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public boolean promptYesNo(String message) {
    NotifyDescriptor descriptor = new NotifyDescriptor(
            message,
            NbBundle.getMessage(SftpClient.class, "LBL_Warning"),
            NotifyDescriptor.YES_NO_OPTION,
            NotifyDescriptor.WARNING_MESSAGE,
            new Object[] {NotifyDescriptor.YES_OPTION, NotifyDescriptor.NO_OPTION},
            NotifyDescriptor.YES_OPTION);
    return DialogDisplayer.getDefault().notify(descriptor) == NotifyDescriptor.YES_OPTION;
}
 
Example 10
Source File: ExternalBindingTablePanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void actionPerformed(ActionEvent e) {
    //Display information about wsdlLocation
    NotifyDescriptor.Confirmation notifyDesc =
            new NotifyDescriptor.Confirmation(NbBundle.getMessage
            (ExternalBindingTablePanel.class, "MSG_EXTERNAL_BINDING", getRelativePathToWsdl()),
            NotifyDescriptor.YES_NO_OPTION);
    DialogDisplayer.getDefault().notify(notifyDesc);
    if(notifyDesc.getValue() == NotifyDescriptor.NO_OPTION) return;
    
    JFileChooser chooser = new JFileChooser(previousDirectory);
    chooser.setMultiSelectionEnabled(false);
    chooser.setAcceptAllFileFilterUsed(false);
    chooser.addChoosableFileFilter(XML_FILE_FILTER);
    chooser.setFileFilter(XML_FILE_FILTER);
    
    if(chooser.showOpenDialog(ExternalBindingTablePanel.this) == JFileChooser.APPROVE_OPTION) {
        File bindingFile = chooser.getSelectedFile();
        if(bindingFile.exists()){
            FileObject bindingFO = FileUtil.toFileObject(bindingFile);
            String bindingName = bindingFO.getName();
            bindingName = FileUtil.findFreeFileName(getBindingsFolder(node), bindingName, bindingFO.getExt());
            bindingName = bindingFO.getExt().equals("") ? bindingName : bindingName + "." + bindingFO.getExt();
            addedBindings.put(bindingName, bindingFO);
            ExternalBindingTablePanel.this.model.addRow(bindingName);
            previousDirectory = bindingFile.getPath();
        }
    }
}
 
Example 11
Source File: ExcitationEditorJFrame.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
private void jLoadMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jLoadMenuItemActionPerformed
// TODO add your handling code here:
        //Browse for existing xml file
        if (dPanel.getControlSet()!=null){
            Object answer = DialogDisplayer.getDefault().notify(
                    new NotifyDescriptor.Confirmation("Loading a new file will erase the current content of the excitation editor. Do you want to proceed?",NotifyDescriptor.YES_NO_OPTION));
            if (answer==NotifyDescriptor.NO_OPTION) return;
            dPanel.clear();
        }
         String fileName = FileUtils.getInstance().browseForFilename(".xml", "Controls XML file", this);
         if(fileName!=null) {
         OpenSimObject objGeneric = OpenSimObject.makeObjectFromFile(fileName);
         if (objGeneric==null || !objGeneric.getConcreteClassName().equalsIgnoreCase("ControlSet")){
            DialogDisplayer.getDefault().notify(
               new NotifyDescriptor.Message("Could not construct excitations from the specified file.")); 
            return;
         }
         ControlSet obj = new ControlSet(fileName);
         if (obj != null){
             dPanel.populate(obj, true);
             setTitle("Excitation Editor: Editing file "+new File(fileName).getName());
          } else {
            DialogDisplayer.getDefault().notify(
               new NotifyDescriptor.Message("Could not construct excitations from the specified file."));
         }
      }
   
    }
 
Example 12
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 13
Source File: ProfilerDialogsProviderImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Boolean displayConfirmationDNSA(String message, String caption, String dnsaMessage, boolean cancellable, String key, boolean dnsaDefault) {
    ProfilerDialogs.DNSAConfirmation dnsa = new ProfilerDialogs.DNSAConfirmation(
            key, message, cancellable ? NotifyDescriptor.YES_NO_CANCEL_OPTION : NotifyDescriptor.YES_NO_OPTION);
    if (caption != null) dnsa.setTitle(caption);
    if (dnsaMessage != null) dnsa.setDNSAMessage(dnsaMessage);
    dnsa.setDNSADefault(dnsaDefault);
    Object ret = ProfilerDialogs.notify(dnsa);
    if (ret == NotifyDescriptor.YES_OPTION) return Boolean.TRUE;
    if (ret == NotifyDescriptor.NO_OPTION) return Boolean.FALSE;
    return null;
}
 
Example 14
Source File: ProfilerDialogsProviderImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Boolean displayConfirmation(String message, String caption, boolean cancellable) {
    NotifyDescriptor nd = new NotifyDescriptor.Confirmation(message,
            cancellable ? NotifyDescriptor.YES_NO_CANCEL_OPTION : NotifyDescriptor.YES_NO_OPTION);
    if (caption != null) nd.setTitle(caption);
    Object ret = DialogDisplayer.getDefault().notify(nd);
    if (ret == NotifyDescriptor.YES_OPTION) return Boolean.TRUE;
    if (ret == NotifyDescriptor.NO_OPTION) return Boolean.FALSE;
    return null;
}
 
Example 15
Source File: IKToolModel.java    From opensim-gui with Apache License 2.0 4 votes vote down vote up
public void finished() {
    progressHandle.finish();
    SimulationDB.getInstance().fireToolFinish();
    if (!cleanup) {
        setExecuting(false);
        return;
    }
    // Clean up motion displayer (this is necessary!)
    animationCallback.cleanupMotionDisplayer();

    getOriginalModel().removeAnalysis(animationCallback, false);
    getOriginalModel().removeAnalysis(interruptingCallback, false);
    interruptingCallback = null;

    if (result) {
        resetModified();
    }

    boolean addMotion = true;
    if (!result) {
        boolean havePartialResult = false;//OpenSim23 ikTool.getOutputStorage()!=null && ikTool.getOutputStorage().getSize()>0;
        if (havePartialResult && promptToKeepPartialResult) {
            Object answer = DialogDisplayer.getDefault().notify(new NotifyDescriptor.Confirmation("Inverse kinematics did not complete.  Keep partial result?", NotifyDescriptor.YES_NO_OPTION));
            if (answer == NotifyDescriptor.NO_OPTION) {
                addMotion = false;
            }
        } else {
            addMotion = false;
        }
    }
    // We don't create full state to avoid polluting results
    // This will be done internally in MotionDisplayer
    Storage ikmotion = new Storage(animationCallback.getStorage()); // Java-side copy
    ikmotion.setName("IKResults");
    updateMotion(ikmotion);

    setExecuting(false);

    //modelCopy = null;
    worker = null;
}
 
Example 16
Source File: HttpServerSettings.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** Requests access for address addr. If necessary asks the user. Returns true it the access
* has been granted. */  
boolean allowAccess(InetAddress addr, String requestPath) {
    if (accessAllowedNow(addr, requestPath))
        return true;

    Thread askThread = null;
    synchronized (whoAsking) {
        // one more test in the synchronized block
        if (accessAllowedNow(addr, requestPath))
            return true;

        askThread = (Thread)whoAsking.get(addr);
        if (askThread == null) {
            askThread = Thread.currentThread();
            whoAsking.put(addr, askThread);
        }
    }

    // now ask the user
    synchronized (HttpServerSettings.class) {
        if (askThread != Thread.currentThread()) {
            return accessAllowedNow(addr, requestPath);
        }

        try {
            if (!isShowGrantAccessDialog ())
                return false;
            
            String msg = NbBundle.getMessage (HttpServerSettings.class, "MSG_AddAddress", addr.getHostAddress ());
            
            final GrantAccessPanel panel = new GrantAccessPanel (msg);
            DialogDescriptor descriptor = new DialogDescriptor (
                panel,
                NbBundle.getMessage (HttpServerSettings.class, "CTL_GrantAccessTitle"),
                true,
                NotifyDescriptor.YES_NO_OPTION,
                NotifyDescriptor.NO_OPTION,
                null
            );
            descriptor.setMessageType (NotifyDescriptor.QUESTION_MESSAGE);
            // descriptor.setOptionsAlign (DialogDescriptor.BOTTOM_ALIGN);
            final Dialog d  = DialogDisplayer.getDefault ().createDialog (descriptor);
            d.setSize (580, 180);
            d.setVisible(true);

            setShowGrantAccessDialog (panel.getShowDialog ());
            if (NotifyDescriptor.YES_OPTION.equals(descriptor.getValue ())) {
                appendAddressToGranted(addr.getHostAddress());
                return true;
            }
            else
                return false;
        }
        finally {
            whoAsking.remove(addr);
        }
    } // end synchronized
}
 
Example 17
Source File: DataViewActionHandler.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private static Object showYesAllDialog(Object msg, String title) {
    NotifyDescriptor nd = new NotifyDescriptor(msg, title, NotifyDescriptor.YES_NO_OPTION, NotifyDescriptor.QUESTION_MESSAGE, null, NotifyDescriptor.NO_OPTION);
    DialogDisplayer.getDefault().notify(nd);
    return nd.getValue();
}
 
Example 18
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 19
Source File: CloneableEditorUserQuestionTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void doExceptionThrownWhenDocumentIsBeingRead () throws Exception {
    class MyEx extends UserQuestionException {
        private int confirmed;
        
        public @Override String getLocalizedMessage() {
            return "locmsg";
        }
        
        public @Override String getMessage() {
            return "msg";
        }
        
        public void confirmed () {
            confirmed++;
            toThrow = null;
        }
    }
    
    MyEx my = new MyEx ();
    toThrow = my;

    DD.toReturn = NotifyDescriptor.NO_OPTION;
    support.open ();
    
    if (!SwingUtilities.isEventDispatchThread ()) {
        javax.swing.SwingUtilities.invokeAndWait (new Runnable () { public void run () {} });
    }
    
    assertNotNull ("Some otions", DD.options);
    assertEquals ("Two options", 2, DD.options.length);
    assertEquals ("Yes", NotifyDescriptor.YES_OPTION, DD.options[0]);
    assertEquals ("No", NotifyDescriptor.NO_OPTION, DD.options[1]);
    assertEquals ("confirmed not called", 0, my.confirmed);
    
    assertNull ("Still no document", support.getDocument ());
    
    DD.options = null;
    DD.toReturn = NotifyDescriptor.YES_OPTION;
    support.open ();

    if (!SwingUtilities.isEventDispatchThread ()) {
        javax.swing.SwingUtilities.invokeAndWait (new Runnable () { public void run () {} });
    }
    
    assertEquals ("confirmed called", 1, my.confirmed);
    assertNotNull ("Some otions", DD.options);
    assertEquals ("Two options", 2, DD.options.length);
    assertEquals ("Yes", NotifyDescriptor.YES_OPTION, DD.options[0]);
    assertEquals ("No", NotifyDescriptor.NO_OPTION, DD.options[1]);
    DD.options = null;
    
    assertNotNull ("Document opened", support.getDocument ());
    
}
 
Example 20
Source File: CloneableEditorUserQuestionAsyncTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void doExceptionThrownWhenDocumentIsBeingRead1Start (MyEx my) throws Exception {
    toThrow = my;

    DD.toReturn = NotifyDescriptor.NO_OPTION;
    support.open();
}