org.openide.NotifyDescriptor.Message Java Examples

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: SceneApplication.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void handleError(String msg, Throwable t) {
    progressHandle.finish();
    if (msg == null) {
        return;
    }
    if (!started) {
        SceneViewerTopComponent.showOpenGLError(msg);
        Exceptions.printStackTrace(t);
    } else {
        if (lastError != null && !lastError.equals(msg)) {
            Message mesg = new NotifyDescriptor.Message(
                    "Error in scene!\n"
                    + "(" + t + ")",
                    NotifyDescriptor.WARNING_MESSAGE);
            DialogDisplayer.getDefault().notifyLater(mesg);
            Exceptions.printStackTrace(t);
            lastError = msg;
        }
    }
}
 
Example #2
Source File: MobilePanel.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    FileChooserBuilder builder = new FileChooserBuilder(AndroidSdkTool.class);
    builder.setTitle("Please select Android SDK Folder");
    builder.setDirectoriesOnly(true);
    File file = builder.showOpenDialog();
    if (file != null) {
        FileObject folder = FileUtil.toFileObject(file);
        if (folder.getFileObject("tools") == null) {
            Message msg = new NotifyDescriptor.Message(
                    "Not a valid SDK folder!",
                    NotifyDescriptor.ERROR_MESSAGE);
            DialogDisplayer.getDefault().notifyLater(msg);

        } else {
            String name = file.getPath();
            jTextField1.setText(name);
        }
    }
}
 
Example #3
Source File: NodeQuickSearch.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private List<InputNode> findMatches(String name, String value, InputGraph inputGraph, SearchResponse response) {
    try {
        RegexpPropertyMatcher matcher = new RegexpPropertyMatcher(name, value, Pattern.CASE_INSENSITIVE);
        Properties.PropertySelector<InputNode> selector = new Properties.PropertySelector<>(inputGraph.getNodes());
        List<InputNode> matches = selector.selectMultiple(matcher);
        return matches.size() == 0 ? null : matches;
    } catch (Exception e) {
        final String msg = e.getMessage();
        response.addResult(new Runnable() {
            @Override
            public void run() {
                Message desc = new NotifyDescriptor.Message("An exception occurred during the search, "
                        + "perhaps due to a malformed query string:\n" + msg,
                        NotifyDescriptor.WARNING_MESSAGE);
                DialogDisplayer.getDefault().notify(desc);
            }
        },
                "(Error during search)"
        );
    }
    return null;
}
 
Example #4
Source File: DragDropUtilities.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Notifies user that the drop was not succesfull. */
static void dropNotSuccesfull() {
    DialogDisplayer.getDefault().notify(
        new Message(
            NbBundle.getMessage(TreeViewDropSupport.class, "MSG_NoPasteTypes"),
            NotifyDescriptor.WARNING_MESSAGE
        )
    );
}
 
Example #5
Source File: SceneViewerTopComponent.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static void showOpenGLError(String e) {
    Message msg = new NotifyDescriptor.Message(
            "Error opening OpenGL window!\n"
            + "Error: " + e,
            NotifyDescriptor.ERROR_MESSAGE);
    DialogDisplayer.getDefault().notifyLater(msg);
}
 
Example #6
Source File: AndroidSdkTool.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Returns a String with the path to the SDK or null if none is specified.
 * @return 
 */
public static String getSdkPath() {
    String path = NbPreferences.forModule(AndroidSdkTool.class).get("sdk_path", null);
    if (path == null) {
        FileChooserBuilder builder = new FileChooserBuilder(AndroidSdkTool.class);
        builder.setTitle("Please select Android SDK Folder");
        builder.setDirectoriesOnly(true);
        File file = builder.showOpenDialog();
        if (file != null) {
            FileObject folder = FileUtil.toFileObject(file);
            if (folder.getFileObject("tools") == null) {
                Message msg = new NotifyDescriptor.Message(
                        "Not a valid SDK folder!",
                        NotifyDescriptor.ERROR_MESSAGE);
                DialogDisplayer.getDefault().notifyLater(msg);

            } else {
                String name = file.getPath();
                NbPreferences.forModule(AndroidSdkTool.class).put("sdk_path", name);
                return name;
            }
        }
    } else {
        return path;
    }
    return null;
}
 
Example #7
Source File: FontAndColorsPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void actionPerformed (ActionEvent e) {
    if (!listen) return;
    if (e.getSource () == bDuplicate) {
        InputLine il = new InputLine (
            loc ("CTL_Create_New_Profile_Message"),                // NOI18N
            loc ("CTL_Create_New_Profile_Title")                   // NOI18N
        );
        il.setInputText (currentProfile);
        DialogDisplayer.getDefault ().notify (il);
        if (il.getValue () == NotifyDescriptor.OK_OPTION) {
            String newScheme = il.getInputText ();                
            for (int i = 0; i < cbProfile.getItemCount(); i++)                 
                if (newScheme.equals (cbProfile.getItemAt(i))) {
                    Message md = new Message (
                        loc ("CTL_Duplicate_Profile_Name"),        // NOI18N
                        Message.ERROR_MESSAGE
                    );
                    DialogDisplayer.getDefault ().notify (md);
                    return;
                }
            setCurrentProfile (newScheme);
            listen = false;
            cbProfile.addItem (il.getInputText ());
            cbProfile.setSelectedItem (il.getInputText ());
            listen = true;
        }
        return;
    }
    if (e.getSource () == bDelete) {
        deleteCurrentProfile ();
    }
}
 
Example #8
Source File: ActionsImplementationFactory.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static void notifyOutOfContext(String refactoringNameKey, Lookup context) {
    for (Node node : context.lookupAll(Node.class)) {
        for (FileObject file : node.getLookup().lookupAll(FileObject.class)) {
            if (!isFileInOpenProject(file)) {
                DialogDisplayer.getDefault().notify(new Message(
                        NbBundle.getMessage(CopyAction.class, "ERR_ProjectNotOpened", file.getNameExt())));
                return;
            }
        }
    }
    String refactoringName = NbBundle.getMessage(CopyAction.class, refactoringNameKey);
    DialogDisplayer.getDefault().notify(new Message(
            NbBundle.getMessage(CopyAction.class, "MSG_CantApplyRefactoring", refactoringName)));
}
 
Example #9
Source File: SymfonyScript.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Get the project specific, <b>valid only</b> Symfony script. If not found, the {@link #getDefault() default} Symfony script is returned.
 * @param phpModule PHP module for which Symfony script is taken
 * @param warn <code>true</code> if user is warned when the {@link #getDefault() default} Symfony script is returned.
 * @return the project specific, <b>valid only</b> Symfony script.
 * @throws InvalidPhpExecutableException if Symfony script is not valid. If not found, the {@link #getDefault() default} Symfony script is returned.
 * @see #getDefault()
 */
public static SymfonyScript forPhpModule(PhpModule phpModule, boolean warn) throws InvalidPhpExecutableException {
    String symfony = new File(FileUtil.toFile(phpModule.getSourceDirectory()), SCRIPT_NAME).getAbsolutePath();
    String error = validate(symfony);
    if (error != null) {
        if (warn) {
            Message message = new NotifyDescriptor.Message(
                    NbBundle.getMessage(SymfonyScript.class, "MSG_InvalidProjectSymfonyScript", error),
                    NotifyDescriptor.WARNING_MESSAGE);
            DialogDisplayer.getDefault().notify(message);
        }
        return getDefault();
    }
    return new SymfonyScript(symfony);
}
 
Example #10
Source File: ActionRegistrationHinter.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Messages("ActionRegistrationHinter.missing_org.openide.awt=You must add a dependency on org.openide.awt (7.27+) before using this fix.")
private boolean annotationsAvailable(Context ctx) {
    if (ctx.canAccess("org.openide.awt.ActionReferences")) {
        return true;
    } else {
        DialogDisplayer.getDefault().notify(new Message(ActionRegistrationHinter_missing_org_openide_awt(), NotifyDescriptor.WARNING_MESSAGE));
        return false;
    }
}
 
Example #11
Source File: ProfilesPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private String duplicateProfile() {
    String newName = null;
    InputLine il = new InputLine(
            KeymapPanel.loc("CTL_Create_New_Profile_Message"), // NOI18N
            KeymapPanel.loc("CTL_Create_New_Profile_Title") // NOI18N
            );
    String profileToDuplicate =(String) profilesList.getSelectedValue();
    il.setInputText(profileToDuplicate);
    DialogDisplayer.getDefault().notify(il);
    if (il.getValue() == NotifyDescriptor.OK_OPTION) {
        newName = il.getInputText();
        for (String s : getKeymapPanel().getMutableModel().getProfiles()) {
            if (newName.equals(s)) {
                Message md = new Message(
                        KeymapPanel.loc("CTL_Duplicate_Profile_Name"), // NOI18N
                        Message.ERROR_MESSAGE);
                DialogDisplayer.getDefault().notify(md);
                return null;
            }
        }
        MutableShortcutsModel currentModel = getKeymapPanel().getMutableModel();
        String currrentProfile = currentModel.getCurrentProfile();
        getKeymapPanel().getMutableModel().setCurrentProfile(profileToDuplicate);
        getKeymapPanel().getMutableModel().cloneProfile(newName);
        currentModel.setCurrentProfile(currrentProfile);
        model.addItem(newName);
        profilesList.setSelectedValue(il.getInputText(), true);
    }
    return newName;
}
 
Example #12
Source File: PlatformShellAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@NbBundle.Messages({
    "# {0} - error message",
    "ERR_RunPlatformShell=Error starting Java Shell: {0}"
})
@Override
public void actionPerformed(ActionEvent e) {
    JavaPlatform platform = options.getSelectedPlatform();
    if (platform == null) {
        NotifyDescriptor.Confirmation conf = new NotifyDescriptor.Confirmation(
                Bundle.ERR_NoShellPlatform(), NotifyDescriptor.Confirmation.OK_CANCEL_OPTION
        );
        Object result = DialogDisplayer.getDefault().notify(conf);
        if (result == NotifyDescriptor.Confirmation.OK_OPTION) {
            OptionsDisplayer.getDefault().open("Java/JShell", true);
        }
        platform = options.getSelectedPlatform();
        if (platform == null) {
            return;
        }
    }
    try {
        JShellEnvironment env = ShellRegistry.get().openDefaultSession(platform);
        env.open();
    } catch (IOException ex) {
        Message msg = new Message(Bundle.ERR_RunPlatformShell(ex.getLocalizedMessage()), Message.ERROR_MESSAGE);
        DialogDisplayer.getDefault().notifyLater(msg);
    }
}
 
Example #13
Source File: CustomZoomAction.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** Actually performs action. */
public void performAction () {
    final Dialog[] dialogs = new Dialog[1];
    final CustomZoomPanel zoomPanel = new CustomZoomPanel();

    zoomPanel.setEnlargeFactor(1);
    zoomPanel.setDecreaseFactor(1);
    
    DialogDescriptor dd = new DialogDescriptor(
        zoomPanel,
        NbBundle.getBundle(CustomZoomAction.class).getString("LBL_CustomZoomAction"),
        true,
        DialogDescriptor.OK_CANCEL_OPTION,
        DialogDescriptor.OK_OPTION,
        new ActionListener() {
            public void actionPerformed(ActionEvent ev) {
                if (ev.getSource() == DialogDescriptor.OK_OPTION) {
                    int enlargeFactor = 1, decreaseFactor = 1;
                    
                    try {
                        enlargeFactor = zoomPanel.getEnlargeFactor();
                        decreaseFactor = zoomPanel.getDecreaseFactor();
                    } catch (NumberFormatException nfe) {
                        notifyInvalidInput();
                        return;
                    }
                    
                    // Invalid values.
                    if(enlargeFactor == 0 || decreaseFactor == 0) {
                        notifyInvalidInput();
                        return;
                    }
                    
                    performZoom(enlargeFactor, decreaseFactor);
                    
                    dialogs[0].setVisible(false);
                    dialogs[0].dispose();
                } else {
                    dialogs[0].setVisible(false);
                    dialogs[0].dispose();
                }
            }        
            
            private void notifyInvalidInput() {
                DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(
                    NbBundle.getBundle(CustomZoomAction.class).getString("MSG_InvalidValues"),
                    NotifyDescriptor.ERROR_MESSAGE
                ));
            }
            
        } // End of annonymnous ActionListener.
    );
    dialogs[0] = DialogDisplayer.getDefault().createDialog(dd);
    dialogs[0].setVisible(true);
    
}
 
Example #14
Source File: Hinter.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Tries to find the Java declaration of an instance attribute, and if successful, runs a task to modify it.
 * @param instanceAttribute the result of {@link FileObject#getAttribute} on a {@code literal:*} key (or {@link #instanceAttribute})
 * @param task a task to run (may modify Java sources and layer objects; all will be saved for you)
 * @throws IOException in case of problem (will instead show a message and return early if the type could not be found)
 */
@Messages({
    "# {0} - layer attribute", "Hinter.missing_instance_class=Could not find Java source corresponding to {0}.",
    "Hinter.do_not_edit_layer=Do not edit layer.xml until the hint has had a chance to run."
})
public void findAndModifyDeclaration(@NullAllowed final Object instanceAttribute, final ModifyDeclarationTask task) throws IOException {
    FileObject java = findDeclaringSource(instanceAttribute);
    if (java == null) {
        DialogDisplayer.getDefault().notify(new Message(Hinter_missing_instance_class(instanceAttribute), NotifyDescriptor.WARNING_MESSAGE));
        return;
    }
    JavaSource js = JavaSource.forFileObject(java);
    if (js == null) {
        throw new IOException("No source info for " + java);
    }
    js.runModificationTask(new Task<WorkingCopy>() {
        public @Override void run(WorkingCopy wc) throws Exception {
            wc.toPhase(JavaSource.Phase.RESOLVED);
            if (DataObject.find(layer.getLayerFile()).isModified()) { // #207077
                DialogDisplayer.getDefault().notify(new Message(Hinter_do_not_edit_layer(), NotifyDescriptor.WARNING_MESSAGE));
                return;
            }
            Element decl = findDeclaration(wc, instanceAttribute);
            if (decl == null) {
                DialogDisplayer.getDefault().notify(new Message(Hinter_missing_instance_class(instanceAttribute), NotifyDescriptor.WARNING_MESSAGE));
                return;
            }
            ModifiersTree mods;
            if (decl.getKind() == ElementKind.CLASS) {
                mods = wc.getTrees().getTree((TypeElement) decl).getModifiers();
            } else {
                mods = wc.getTrees().getTree((ExecutableElement) decl).getModifiers();
            }
            task.run(wc, decl, mods);
            saveLayer();
        }
    }).commit();
    SaveCookie sc = DataObject.find(java).getLookup().lookup(SaveCookie.class);
    if (sc != null) {
        sc.save();
    }
}
 
Example #15
Source File: ImportWorldForgeAction.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private void showError(String e) {
    Message msg = new NotifyDescriptor.Message(
            e,
            NotifyDescriptor.ERROR_MESSAGE);
    DialogDisplayer.getDefault().notifyLater(msg);
}
 
Example #16
Source File: SceneEditorController.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void displayInfo(String info) {
    Message msg = new NotifyDescriptor.Message(info);
    DialogDisplayer.getDefault().notifyLater(msg);
}
 
Example #17
Source File: SceneComposerTopComponent.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void displayInfo(String info) {
    Message msg = new NotifyDescriptor.Message(info);
    DialogDisplayer.getDefault().notifyLater(msg);
}
 
Example #18
Source File: GrailsPlatform.java    From netbeans with Apache License 2.0 3 votes vote down vote up
/**
 * Creates the callable spawning the command (process) described
 * by the command descriptor. Usually you don't need to use this method
 * directly as most of use cases can be solved with {@link ExecutionSupport}.
 *
 * @param descriptor descriptor of the command and its environment
 * @return the callable spawning the command (process)
 * @throws IllegalStateException if the runtime is not configured
 *
 * @see #isConfigured()
 * @see ExecutionSupport
 */
public Callable<Process> createCommand(CommandDescriptor descriptor) {
    Parameters.notNull("descriptor", descriptor);

    if (!isConfigured()) {
        Message dialogMessage = new NotifyDescriptor.Message(NbBundle.getMessage(GrailsPlatform.class, "MSG_GrailsNotConfigured"));
        if (DialogDisplayer.getDefault().notify(dialogMessage) == NotifyDescriptor.OK_OPTION) {
            return new GrailsCallable(descriptor);
        }
    }
    return new GrailsCallable(descriptor);
}