Java Code Examples for org.openide.NotifyDescriptor#Message

The following examples show how to use org.openide.NotifyDescriptor#Message . 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: BaseJspEditorSupport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Test if the loaded encoding is supported and warn the user if not.
 */
private void verifyEncoding() {
    String encoding = getJspDataObject().getFileEncoding();
    if (!isSupportedEncoding(encoding)) {

        NotifyDescriptor nd = new NotifyDescriptor.Message(
                NbBundle.getMessage(BaseJspEditorSupport.class, "MSG_BadEncodingDuringLoad", //NOI18N
                new Object[]{getDataObject().getPrimaryFile().getNameExt(),
                    encoding,
                    defaulEncoding}),
                NotifyDescriptor.WARNING_MESSAGE);
        
        DialogDisplayer.getDefault().notifyLater(nd);
    }


}
 
Example 2
Source File: MakeDefaultCatalogAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * If DDL exception was caused by a closed connection, log info and display
 * a simple error dialog. Otherwise let users report the exception.
 */
private void handleDLLException(DatabaseConnection dbConn,
        DDLException e) throws SQLException, MissingResourceException {
    Connection conn = dbConn == null ? null : dbConn.getJDBCConnection();
    if (conn != null && !conn.isValid(1000)) {
        LOGGER.log(Level.INFO, e.getMessage(), e);
        NotifyDescriptor nd = new NotifyDescriptor.Message(
                NbBundle.getMessage(
                MakeDefaultCatalogAction.class,
                "ERR_ConnectionToServerClosed"), //NOI18N
                NotifyDescriptor.ERROR_MESSAGE);
        DialogDisplayer.getDefault().notifyLater(nd);
    } else {
        Exceptions.printStackTrace(e);
    }
}
 
Example 3
Source File: AnalyzeAndForwardToolPanel.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
public void update(Observable observable, Object obj) {
     if (observable instanceof OpenSimDB){
        if (obj instanceof ModelEvent) {
             if (OpenSimDB.getInstance().hasModel(toolModel.getOriginalModel()))
                 return;
             else {
                 toolModel.deleteObserver(this);
                 OpenSimDB.getInstance().deleteObserver(this);
                 NotifyDescriptor.Message dlg =
                       new NotifyDescriptor.Message("Model used by the tool is being closed. Closing tool.");
                 DialogDisplayer.getDefault().notify(dlg);
                 this.close();
                 return;
             }        
        }
        return;
    }
   if(observable == toolModel && obj == AbstractToolModel.Operation.ExecutionStateChanged)

   //if(observable == toolModel && (obj == AbstractToolModel.Operation.ExecutionStateChanged ||
   //        obj == AbstractToolModel.Operation.InputDataChanged))
      updateDialogButtons();
   else
      updateFromModel(); 
}
 
Example 4
Source File: JsonIO.java    From constellation with Apache License 2.0 6 votes vote down vote up
/**
 * Deletes the selected JSON file from disk, and hence from the selection
 * dialog
 *
 * @param filenameToDelete name of file to delete
 */
public static void deleteJsonPreference(final String filenameToDelete) {
    final Preferences prefs = NbPreferences.forModule(ApplicationPreferenceKeys.class);
    final String userDir = ApplicationPreferenceKeys.getUserDir(prefs);
    final File prefDir = new File(userDir, currentDir);

    if (filenameToDelete != null) {
        final String encodedFilename = FilenameEncoder.encode(currentPrefix.concat(filenameToDelete)) + FILE_EXT;

        // Loop through files in preference directory looking for one matching selected item
        // delete it when found
        if (prefDir.isDirectory()) {
            for (File file : prefDir.listFiles()) {
                if (file.getName().equals(encodedFilename)) {
                    boolean result = file.delete();
                    if (!result) {
                        final String msg = String.format("Failed to delete file %s from disk", file.getName());
                        final NotifyDescriptor nd = new NotifyDescriptor.Message(msg, NotifyDescriptor.ERROR_MESSAGE);
                        DialogDisplayer.getDefault().notify(nd);
                    }
                    break;
                }
            }
        }
    }
}
 
Example 5
Source File: IncomingCallAction.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
@Override
protected void performAction(Node[] activatedNodes) {
    EmulatorControlSupport emulatorControl = activatedNodes[0].getLookup().lookup(EmulatorControlSupport.class);
    if (emulatorControl != null) {
        NotifyDescriptor.InputLine inputLine = new NotifyDescriptor.InputLine("Phone number:", "Incoming call", NotifyDescriptor.OK_CANCEL_OPTION, NotifyDescriptor.QUESTION_MESSAGE);
        Object notify = DialogDisplayer.getDefault().notify(inputLine);
        if (NotifyDescriptor.OK_OPTION.equals(notify)) {
            String phoneNo = inputLine.getInputText();
            String ok = emulatorControl.getConsole().call(phoneNo);
            if (ok == null) {
                CancelIncomingCallAction.addCalledNumber(emulatorControl.getDevice().getSerialNumber(), phoneNo);
            } else {
                NotifyDescriptor nd = new NotifyDescriptor.Message(ok, NotifyDescriptor.ERROR_MESSAGE);
                DialogDisplayer.getDefault().notifyLater(nd);
            }
        }
    }
}
 
Example 6
Source File: EditWSAttributesCookieImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void openEditor() {
    try {
        doOpenEditor();
    }
    catch( InvalidDataException ex ){
        NotifyDescriptor descriptor = new NotifyDescriptor.Message(
                ex.getLocalizedMessage(), 
                NotifyDescriptor.ERROR_MESSAGE);
        DialogDisplayer.getDefault().notify( descriptor );
    }
}
 
Example 7
Source File: ActionMessageCallbackUIImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void messageCallback(Object action, String message) {
    if (action == ActionsManager.ACTION_FIX) {
        // Special handling of messages coming from apply code changes - print into debug output.
        consoleIO.println(message, null, false);
    } else {
        NotifyDescriptor.Message descriptor = new NotifyDescriptor.Message(message);
        DialogDisplayer.getDefault().notify(descriptor);
    }
}
 
Example 8
Source File: JavaPlatformSelector.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
private static void notifyWrongBinary(String javaName, String archName) {
    String msg = archName != null ? NbBundle.getMessage(JavaPlatformSelector.class,
                                    "MSG_Incorrect_java_binary_arch", javaName, archName) : // NOI18N
                                    NbBundle.getMessage(JavaPlatformSelector.class,
                                    "MSG_Incorrect_java_binary_noarch", javaName); // NOI18N
    NotifyDescriptor nd = new NotifyDescriptor.Message(msg, NotifyDescriptor.WARNING_MESSAGE);
    DialogDisplayer.getDefault().notify(nd);
}
 
Example 9
Source File: EditWSAttributesCookieImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void openEditor() {
    try {
        doOpenEditor();
    }
    catch( InvalidDataException ex ){
        NotifyDescriptor descriptor = new NotifyDescriptor.Message(
                ex.getLocalizedMessage(), 
                NotifyDescriptor.ERROR_MESSAGE);
        DialogDisplayer.getDefault().notify( descriptor );
    }
}
 
Example 10
Source File: ProjectCustomizerProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
@NbBundle.Messages("MSG_CustomizerForbidden=The customizer is disabled, using it would revert manual changes done to the nbproject/project.xml file.")
public void showCustomizer() {
    AuxiliaryProperties props = project.getLookup().lookup(AuxiliaryProperties.class);
    String show = props.get("show.customizer", true);
    if (show != null && "false".equals(show)) {
        String message = props.get("show.customizer.message", true);
        if (message == null) {
            message = MSG_CustomizerForbidden();
        }
        NotifyDescriptor nd = new NotifyDescriptor.Message(message, NotifyDescriptor.WARNING_MESSAGE);
        DialogDisplayer.getDefault().notify(nd);
        return;
    }
    Dialog dialog = project2Dialog.get (project);
    if ( dialog != null ) {            
        dialog.setVisible(true);
    }
    else {
        InstanceContent ic = new InstanceContent();
        Lookup context = new AbstractLookup(ic);
        ic.add(project);
        ic.add(project.getLookup().lookup(ProjectAccessor.class));
        ic.add(project.getLookup().lookup(AuxiliaryConfiguration.class));
        //TODO replace with generic apis..
        ic.add(ic);
        
        OptionListener listener = new OptionListener();
        dialog = ProjectCustomizer.createCustomizerDialog(CUSTOMIZER_FOLDER_PATH, context, null, listener, null );
        dialog.addWindowListener( listener );
        dialog.setTitle( MessageFormat.format(                 
                NbBundle.getMessage( ProjectCustomizerProvider.class, "LBL_Customizer_Title" ), // NOI18N 
                new Object[] { ProjectUtils.getInformation(project).getDisplayName() } ) );

        project2Dialog.put(project, dialog);
        dialog.setVisible(true);
    }
}
 
Example 11
Source File: DataAccessPane.java    From constellation with Apache License 2.0 5 votes vote down vote up
/**
 * Add and remove plugins from the favourites section
 */
private void manageFavourites() {
    final List<String> selectedPlugins = new ArrayList<>();

    // get a list of the selected plugins
    final QueryPhasePane queryPhasePane = getQueryPhasePane(getCurrentTab());
    queryPhasePane.getDataAccessPanes().stream().forEach(tp -> {
        if (tp.isQueryEnabled()) {
            selectedPlugins.add(tp.getPlugin().getName());
        }
    });

    if (selectedPlugins.isEmpty()) {
        final NotifyDescriptor nd = new NotifyDescriptor.Message("No plugins selected.", NotifyDescriptor.WARNING_MESSAGE);
        DialogDisplayer.getDefault().notify(nd);
    } else {
        final StringBuilder message = new StringBuilder(300);
        message.append("Add or remove plugins from your favourites category.\n\n");
        message.append("The following plugins were selected:\n");
        selectedPlugins.stream().forEach(plugin -> {
            message.append(plugin).append("\n");
        });
        message.append("\nNote that you need to restart before changes take effect.");

        final NotifyDescriptor nde = new NotifyDescriptor(message.toString(), "Manage Favourites", NotifyDescriptor.DEFAULT_OPTION, NotifyDescriptor.QUESTION_MESSAGE,
                new Object[]{ADD_FAVOURITE, REMOVE_FAVOURITE, NotifyDescriptor.CANCEL_OPTION}, NotifyDescriptor.OK_OPTION);
        final Object option = DialogDisplayer.getDefault().notify(nde);

        if (option != NotifyDescriptor.CANCEL_OPTION) {
            selectedPlugins.stream().forEach(name -> {
                DataAccessPreferences.setFavourite(name, option == ADD_FAVOURITE);
            });
        }
    }
}
 
Example 12
Source File: SelfSamplerAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Invoked when an action occurs.
 */
@Override
public void actionPerformed(final ActionEvent e) {
    Sampler c = Sampler.createManualSampler("Self Sampler");  // NOI18N
    if (c != null) {
        if (RUNNING.compareAndSet(null, c)) {
            putValue(Action.NAME, ACTION_NAME_STOP);
            putValue(Action.SHORT_DESCRIPTION, ACTION_NAME_STOP);
            putValue ("iconBase", "org/netbeans/core/ui/sampler/selfSamplerRunning.png"); // NOI18N
            c.start();
        } else if ((c = RUNNING.getAndSet(null)) != null) {
            final Sampler controller = c;

            setEnabled(false);
            SwingWorker worker = new SwingWorker() {

                @Override
                protected Object doInBackground() throws Exception {
                    controller.stop();
                    return null;
                }

                @Override
                protected void done() {
                    putValue(Action.NAME, ACTION_NAME_START);
                    putValue(Action.SHORT_DESCRIPTION, ACTION_NAME_START);
                    putValue ("iconBase", "org/netbeans/core/ui/sampler/selfSampler.png"); // NOI18N
                    SelfSamplerAction.this.setEnabled(true);
                }
            };
            worker.execute();
        }
    } else {
        NotifyDescriptor d = new NotifyDescriptor.Message(NOT_SUPPORTED, NotifyDescriptor.INFORMATION_MESSAGE);
        DialogDisplayer.getDefault().notify(d);
    }
}
 
Example 13
Source File: DatabaseTablesPanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private static void notify(String message) {
    NotifyDescriptor nd = new NotifyDescriptor.Message(message, NotifyDescriptor.ERROR_MESSAGE);
    DialogDisplayer.getDefault().notify(nd);
}
 
Example 14
Source File: TomcatWebModuleChildrenFactory.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 * <p>
 * Asks the tomcat manager for modules available on the target. Manager
 * and target are fetched from lookup passed in constructor.
 */
@Override
protected boolean createKeys(List<TomcatWebModule> toPopulate) {
    DeploymentManager manager = lookup.lookup(DeploymentManager.class);
    Target target = lookup.lookup(Target.class);

    TreeSet<TomcatWebModule> list = new TreeSet<TomcatWebModule>(
            TomcatWebModule.TOMCAT_WEB_MODULE_COMPARATOR);

    if (manager instanceof TomcatManager && target != null) {
        TomcatManager tm = (TomcatManager) manager;

        if (tm.isSuspended() || !tm.isRunning(true)) {
            return true;
        }
        try {
            TargetModuleID[] modules = manager.getRunningModules(ModuleType.WAR, new Target[] {target});
            for (int i = 0; i < modules.length; i++) {
                list.add(new TomcatWebModule(manager, (TomcatModule) modules[i], true));
            }

            modules = manager.getNonRunningModules(ModuleType.WAR, new Target[] {target});
            for (int i = 0; i < modules.length; i++) {
                list.add(new TomcatWebModule(manager, (TomcatModule) modules[i], false));
            }

        } catch (Exception e) {
            if (e.getCause() instanceof AuthorizationException) {
                // connection to tomcat manager has not been allowed
                String errMsg = NbBundle.getMessage(TomcatWebModuleChildrenFactory.class,
                        "MSG_AuthorizationFailed", tm.isAboveTomcat70() ? "manager-script" : "manager");
                NotifyDescriptor notDesc = new NotifyDescriptor.Message(
                        errMsg, NotifyDescriptor.ERROR_MESSAGE);
                DialogDisplayer.getDefault().notify(notDesc);
            } else {
                LOGGER.log(Level.INFO, null, e);
            }
        }
    }
    toPopulate.addAll(list);
    return true;
}
 
Example 15
Source File: XMLJ2eeUtils.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private static void showDialog(String elementName, String attrName, String attrValue){
 String mes = NbBundle.getMessage(XMLJ2eeUtils.class, "TXT_elementExists",
    new Object [] { elementName, attrName, attrValue});
 NotifyDescriptor.Message message = new NotifyDescriptor.Message(mes);
 DialogDisplayer.getDefault().notify(message);
}
 
Example 16
Source File: CustomizerSupport.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void addPathElement () {
    JFileChooser chooser = new JFileChooser();
    FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
    chooser.setMultiSelectionEnabled (true);
    String title = null;
    String message = null;
    String approveButtonName = null;
    String approveButtonNameMne = null;
    if (SOURCES.equals(this.type)) {
        title = NbBundle.getMessage (CustomizerSupport.class,"TXT_OpenSources");
        message = NbBundle.getMessage (CustomizerSupport.class,"TXT_FilterSources");
        approveButtonName = NbBundle.getMessage (CustomizerSupport.class,"TXT_OpenSources");
        approveButtonNameMne = NbBundle.getMessage (CustomizerSupport.class,"MNE_OpenSources");
    } else if (JAVADOC.equals(this.type)) {
        title = NbBundle.getMessage (CustomizerSupport.class,"TXT_OpenJavadoc");
        message = NbBundle.getMessage (CustomizerSupport.class,"TXT_FilterJavadoc");
        approveButtonName = NbBundle.getMessage (CustomizerSupport.class,"TXT_OpenJavadoc");
        approveButtonNameMne = NbBundle.getMessage (CustomizerSupport.class,"MNE_OpenJavadoc");
    } else {
        throw new IllegalStateException("Can't add element for classpath"); // NOI18N
    }
    chooser.setDialogTitle(title);
    chooser.setApproveButtonText(approveButtonName);
    chooser.setApproveButtonMnemonic (approveButtonNameMne.charAt(0));
    chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    //#61789 on old macosx (jdk 1.4.1) these two method need to be called in this order.
    chooser.setAcceptAllFileFilterUsed( false );
    chooser.setFileFilter (new SimpleFileFilter(message,new String[] {"ZIP","JAR"}));   //NOI18N
    if (this.currentDir != null && currentDir.exists()) {
        chooser.setCurrentDirectory(this.currentDir);
    }
    if (chooser.showOpenDialog(this)==JFileChooser.APPROVE_OPTION) {
        File[] fs = chooser.getSelectedFiles();
        PathModel model = (PathModel) this.resources.getModel();
        boolean addingFailed = false;
        int firstIndex = this.resources.getModel().getSize();
        for (int i = 0; i < fs.length; i++) {
            File f = fs[i];
            //XXX: JFileChooser workaround (JDK bug #5075580), double click on folder returns wrong file
            // E.g. for /foo/src it returns /foo/src/src
            // Try to convert it back by removing last invalid name component
            if (!f.exists()) {
                File parent = f.getParentFile();
                if (parent != null && f.getName().equals(parent.getName()) && parent.exists()) {
                    f = parent;
                }
            }
            addingFailed|=!model.addPath (f);
        }
        if (addingFailed) {
            new NotifyDescriptor.Message (NbBundle.getMessage(CustomizerSupport.class,"TXT_CanNotAddResolve"),
                    NotifyDescriptor.ERROR_MESSAGE);
        }
        int lastIndex = this.resources.getModel().getSize()-1;
        if (firstIndex<=lastIndex) {
            int[] toSelect = new int[lastIndex-firstIndex+1];
            for (int i = 0; i < toSelect.length; i++) {
                toSelect[i] = firstIndex+i;
            }
            this.resources.setSelectedIndices(toSelect);
        }
        this.currentDir = FileUtil.normalizeFile(chooser.getCurrentDirectory());
    }
}
 
Example 17
Source File: Utils.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public static void notifyError(Exception ex) {
    NotifyDescriptor ndd = new NotifyDescriptor.Message(ex.getMessage(), NotifyDescriptor.ERROR_MESSAGE);
    DialogDisplayer.getDefault().notify(ndd);
}
 
Example 18
Source File: ProxyListener.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
void showStackMemoryPanel(Object thread) {
    NotifyDescriptor nd = new NotifyDescriptor.Message("Not yet implemented", NotifyDescriptor.INFORMATION_MESSAGE) ;
    DialogDisplayer.getDefault().notify(nd);
}
 
Example 19
Source File: DialogDisplayerImplTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@RandomlyFails
public void testLeafNotify() throws Exception {
    boolean leaf = true;
    DialogDescriptor ownerDD = new DialogDescriptor (pane, "Owner", true, new Object[] {closeOwner}, null, 0, null, null, leaf);
    final Dialog owner = DialogDisplayer.getDefault ().createDialog (ownerDD);
    
    // make leaf visible
    postInAwtAndWaitOutsideAwt (new Runnable () {
        @Override
        public void run () {
            owner.setVisible (true);
        }
    });
    assertShowing("Owner should be visible", true, owner);
    
    child = new JButton();
    final NotifyDescriptor nd = new NotifyDescriptor.Message(child);

    // make the child visible
    RequestProcessor.getDefault().post(new Runnable () {
        @Override
        public void run () {
            DialogDisplayer.getDefault().notify(nd);
        }
    });
    assertShowing("Child will be visible", true, child);
    
    Window w = SwingUtilities.windowForComponent(child);
    assertFalse ("No dialog is owned by leaf dialog.", owner.equals (w.getOwner ()));
    assertEquals ("The leaf dialog has no child.", 0, owner.getOwnedWindows ().length);
    
    assertTrue ("Leaf is visible", owner.isVisible ());
    assertTrue ("Child is visible", child.isVisible ());
    
    // close the leaf window
    postInAwtAndWaitOutsideAwt (new Runnable () {
        @Override
        public void run () {
            owner.setVisible (false);
        }
    });
    assertShowing("Disappear", false, owner);
    
    assertFalse ("Leaf is dead", owner.isVisible ());
    assertTrue ("Child is visible still", child.isVisible ());

    w.setVisible(false);
    assertShowing("Child is invisible", false, child);
    
    assertFalse ("Child is dead too", child.isShowing());
}
 
Example 20
Source File: ParamEditor.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
    * Handle user input...
    */

   public void evaluateInput() {

if (editDialog.getValue().equals(NotifyDescriptor.CANCEL_OPTION)) { 
    dialog.dispose();
    dialogOK = false; 
    return; 
}

if(editable == Editable.NEITHER) {
    dialog.dispose();
    dialogOK = false; 
    return;
}

errorMessage = null; 

if(name.equals("")) 
    errorMessage = NbBundle.getMessage(ParamEditor.class, 
				       "MSG_no_name"); 
else if(condition == Condition.COOKIE && name.equalsIgnoreCase("jsessionid"))
    errorMessage = NbBundle.getMessage(ParamEditor.class, 
				       "MSG_no_jsession"); 
else if(condition == Condition.VALUE && value.equals("")) 
    errorMessage = NbBundle.getMessage(ParamEditor.class, 
				       "MSG_no_value"); 
else if(condition == Condition.HEADER && 
	name.equalsIgnoreCase("cookie") &&
	(value.indexOf("jsessionid") > -1 ||
	 value.indexOf("JSESSIONID") > -1))
    errorMessage = NbBundle.getMessage(ParamEditor.class, 
				       "MSG_no_jsession"); 

if(errorMessage == null) { 
    dialog.dispose();
    dialogOK = true; 
} 
else {
   editDialog.setValue(NotifyDescriptor.CLOSED_OPTION);
   NotifyDescriptor nd = new NotifyDescriptor.Message
       (errorMessage, NotifyDescriptor.ERROR_MESSAGE); 
    DialogDisplayer.getDefault().notify(nd);
}
   }