org.openide.awt.NotificationDisplayer Java Examples

The following examples show how to use org.openide.awt.NotificationDisplayer. 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: Installer.java    From editorconfig-netbeans with MIT License 6 votes vote down vote up
/**
 * Displays a notification in the default notification UI containing
 * information on the plugin's incompatibility with the current IDE's version
 * of the JVM
 */
private static void registerIncompatabilityNotification() {

  //These are the title, message and icon displayed in the notification area and within popup if user interacts with notification
  final String incompatTitle = NbBundle.getMessage(Installer.class, "wlc-nbeditorconfig-version-error-title");
  final String incompatMessage = NbBundle.getMessage(Installer.class, "wlc-nbeditorconfig-version-error-message");
  final Icon incompatIcon = new MetalIconFactory.FileIcon16();
  
  INSTALLER_LOGGER.log(Level.SEVERE, incompatMessage);

  final ActionListener notificationInteractionListener = new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      NotifyDescriptor.Message pluginIncompatiableMessage = new NotifyDescriptor.Message(incompatMessage, NotifyDescriptor.ERROR_MESSAGE);
      DialogDisplayer.getDefault().notify(pluginIncompatiableMessage);
    }
  };

  NotificationDisplayer.getDefault().notify(incompatTitle, incompatIcon, incompatMessage, notificationInteractionListener);

}
 
Example #2
Source File: InstallStep.java    From netbeans with Apache License 2.0 6 votes vote down vote up
static void notifyRestartNeeded (final Runnable onMouseClick, final String tooltip) {
    //final NotifyDescriptor nd = new NotifyDescriptor.Confirmation (
    //                                    getBundle ("RestartConfirmation_Message"),
    //                                    getBundle ("RestartConfirmation_Title"),
    //                                    NotifyDescriptor.YES_NO_OPTION);
    ActionListener onClickAction = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //DialogDisplayer.getDefault ().notify (nd);
            //if (NotifyDescriptor.OK_OPTION.equals (nd.getValue ())) {
                onMouseClick.run ();
            //}
        }
    };
    synchronized (InstallStep.class) {
        if (restartNotification != null) {
            restartNotification.clear();
            restartNotification = null;
        }

        restartNotification = NotificationDisplayer.getDefault().notify(tooltip,
                ImageUtilities.loadImageIcon("org/netbeans/modules/autoupdate/ui/resources/restart.png", false),
                getBundle("RestartNeeded_Details"), onClickAction, NotificationDisplayer.Priority.HIGH, NotificationDisplayer.Category.WARNING);
    }
}
 
Example #3
Source File: AutoupdateCheckScheduler.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static void signOn () {
    // temprorary to investigate #203326
    NotificationDisplayer.getDefault();
    // end of investigation #203326
    
    AutoupdateSettings.generateIdentity ();
    
    if (timeToCheck ()) {
        // schedule refresh providers
        // install update checker when UI is ready (main window shown)
        WindowManager.getDefault().invokeWhenUIReady(new Runnable () {
            @Override
            public void run () {
                Installer.RP.post (doCheck, 5000);
            }
        });
    } else {
        // install update checker when UI is ready (main window shown)
        WindowManager.getDefault().invokeWhenUIReady(new Runnable () {
            @Override
            public void run () {
                Installer.RP.post (doCheckLazyUpdates, 11000);
            }
        });
    }
}
 
Example #4
Source File: InstallStep.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Messages({
    "# {0} - plugin_name",
    "inBackground_WritePermission=You don''t have permission to install plugin {0} into the installation directory.",
    "inBackground_WritePermission_Details=details", "cancel=Cancel", "install=Install anyway"})
private void notifyWritePermissionProblem(final OperationException ex, final UpdateElement culprit) {
    // lack of privileges for writing
    ActionListener onMouseClickAction = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            ProblemPanel problem = new ProblemPanel(ex, culprit, false);
            problem.showWriteProblemDialog();
        }
    };
    String title = inBackground_WritePermission(culprit.getDisplayName());
    String description = inBackground_WritePermission_Details();
    NotificationDisplayer.getDefault().notify(title,
            ImageUtilities.loadImageIcon("org/netbeans/modules/autoupdate/ui/resources/error.png", false), // NOI18N
            description, onMouseClickAction, NotificationDisplayer.Priority.HIGH, NotificationDisplayer.Category.ERROR);
}
 
Example #5
Source File: SlownessReporter.java    From netbeans with Apache License 2.0 6 votes vote down vote up
NotifySnapshot(SlownessData data) {
    this.data = data;
    NotificationDisplayer.Priority priority = data.getTime() > PRIORITY ?
        Priority.LOW : Priority.SILENT;
    String message = NbBundle.getMessage(NotifySnapshot.class, data.getSlownessType());
    note = NotificationDisplayer.getDefault().notify(
            message,
            ImageUtilities.loadImageIcon("org/netbeans/modules/uihandler/vilik.png", true),
            createPanel(), createPanel(),
            priority,
            NotificationDisplayer.Category.WARNING);
    if (CLEAR > 0) {
        Installer.RP.post(new Runnable() {

            @Override
            public void run() {
                clear();
            }
        }, CLEAR, Thread.MIN_PRIORITY);
    }
}
 
Example #6
Source File: NotifyExcPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static synchronized ExceptionFlasher notify(String summary, ImageIcon icon) {
    if (flash == null) {
        flash = new ExceptionFlasher();
    } else {
        flash.timer.restart();
        if (flash.note != null) {
            flash.note.clear();
        }
    }
    JComponent detailsPanel = getDetailsPanel(summary);
    JComponent bubblePanel = getDetailsPanel(summary);

    flash.note = NotificationDisplayer.getDefault().notify(
            NbBundle.getMessage(NotifyExcPanel.class, "NTF_ExceptionalExceptionTitle"),
            icon, bubblePanel, detailsPanel,
            NotificationDisplayer.Priority.SILENT, NotificationDisplayer.Category.ERROR);
    return flash;
}
 
Example #7
Source File: CosChecker.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Messages({
    "CosChecker.no_test_cos.title=Not using Compile on Save",
    "CosChecker.no_test_cos.details=Compile on Save mode can speed up single test execution for many projects."
})
static void warnNoTestCoS(RunConfig config) {
    if (warnedNoCoS) {
        return;
    }
    final Project project = config.getProject();
    if (project == null) {
        return;
    }
    final Notification n = NotificationDisplayer.getDefault().notify(CosChecker_no_test_cos_title(), ImageUtilities.loadImageIcon(SUGGESTION, true), CosChecker_no_test_cos_details(), new ActionListener() {
        @Override public void actionPerformed(ActionEvent e) {
            showCompilePanel(project);
        }
    }, NotificationDisplayer.Priority.LOW);
    RequestProcessor.getDefault().post(new Runnable() {
        @Override public void run() {
            n.clear();
        }
    }, 15 * 1000);
    warnedNoCoS = true;
}
 
Example #8
Source File: WebServer.java    From constellation with Apache License 2.0 6 votes vote down vote up
/**
 * Check that a request contains the correct secret.
 * <p>
 * If the request does not contain the correct secret, send an
 * SC_AUTHORIZED error to the client; the caller is expected to honor
 * the return value and return immediately without doing any work if the
 * return value is false.
 *
 * @param request The client request.
 * @param response The response.
 *
 * @return True if the correct secret was found, false otherwise.
 *
 * @throws javax.servlet.ServletException
 * @throws java.io.IOException
 */
public static boolean checkSecret(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException {
    final String header = request.getHeader(SECRET_HEADER);
    final boolean ok = header != null && SECRET.equals(header);
    if (!ok) {
        final String msg = String.format("REST API secret %s not provided.", SECRET_HEADER);
        response.sendError(HttpServletResponse.SC_UNAUTHORIZED, msg);

        final String msg2 = String.format("<html>REST API secret %s not provided.<br>Please download the external scripting Python client again.</html>",
                SECRET_HEADER);
        NotificationDisplayer.getDefault().notify("REST API server",
                UserInterfaceIconProvider.WARNING.buildIcon(16, ConstellationColor.DARK_ORANGE.getJavaColor()),
                msg2,
                null
        );
    }

    return ok;
}
 
Example #9
Source File: DataAccessSearchProvider.java    From constellation with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
    final String message;
    final DataAccessPane dapane = DataAccessUtilities.getDataAccessPane();
    if (dapane != null) {
        final Tab tab = dapane.getCurrentTab();
        if (tab != null) {
            final QueryPhasePane queryPhasePane = DataAccessPane.getQueryPhasePane(tab);
            Platform.runLater(() -> {
                queryPhasePane.expandPlugin(pluginName);
            });

            return;
        } else {
            message = "Please create a step in the Data Access view.";
        }
    } else {
        message = "Please open the Data Access view and create a step.";
    }

    NotificationDisplayer.getDefault().notify("Data Access view",
            UserInterfaceIconProvider.WARNING.buildIcon(16, ConstellationColor.DARK_ORANGE.getJavaColor()),
            message,
            null
    );
}
 
Example #10
Source File: UIProviderImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void notifyLowMemory(String rootName) {
    if (PRIORITY != null) {
        NotificationDisplayer.getDefault().notify(
                NbBundle.getMessage(UIProviderImpl.class, "TITLE_LowMemory"),
                ImageUtilities.loadImageIcon(WARNING_ICON, false),
                NbBundle.getMessage(UIProviderImpl.class, "MSG_LowMemory", rootName),
                new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        try {
                            final URL url = new URL(NbBundle.getMessage(UIProviderImpl.class, "URL_LowMemory"));
                            HtmlBrowser.URLDisplayer.getDefault().showURLExternal(url);
                        } catch (MalformedURLException ex) {
                            Exceptions.printStackTrace(ex);
                        }
                    }
                },
                PRIORITY, NotificationDisplayer.Category.ERROR);
    }

}
 
Example #11
Source File: TypeScriptLSP.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
@Messages({"WARN_NoNode=node.js not found, TypeScript support disabled.",
           "DESC_NoNode=Please specify node.js location in the Tools/Options, and restart the IDE."
})
public LanguageServerDescription startServer(Lookup lookup) {
    String node = NodeJsSupport.getInstance().getNode(null);
    if (node == null || node.isEmpty()) {
        NotificationDisplayer.getDefault().notify(Bundle.WARN_NoNode(), ImageUtilities.loadImageIcon("org/netbeans/modules/typescript/editor/icon.png", true), Bundle.DESC_NoNode(), evt -> {
            OptionsDisplayer.getDefault().open("Html5/NodeJs");
        });
        return null;
    }
    File server = InstalledFileLocator.getDefault().locate("typescript-lsp/node_modules/typescript-language-server/lib/cli.js", null, false);
    try {
        Process p = new ProcessBuilder(new String[] {node, server.getAbsolutePath(), "--stdio"}).directory(server.getParentFile().getParentFile()).redirectError(ProcessBuilder.Redirect.INHERIT).start();
        return LanguageServerDescription.create(p.getInputStream(), p.getOutputStream(), p);
    } catch (IOException ex) {
        LOG.log(Level.FINE, null, ex);
        return null;
    }
}
 
Example #12
Source File: ClientSideProject.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@NbBundle.Messages({
    "# {0} - project name",
    "OpenHookImpl.notification.autoconfigured.title=Project {0} automatically configured",
    "OpenHookImpl.notification.autoconfigured.details=Review and correct important project settings detected by the IDE.",
})
private void checkAutoconfigured() {
    ClientSideProjectProperties projectProperties = new ClientSideProjectProperties(project);
    if (projectProperties.isAutoconfigured()) {
        NotificationDisplayer.getDefault().notify(
                Bundle.OpenHookImpl_notification_autoconfigured_title(ProjectUtils.getInformation(project).getDisplayName()),
                NotificationDisplayer.Priority.LOW.getIcon(),
                Bundle.OpenHookImpl_notification_autoconfigured_details(),
                new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        project.getLookup().lookup(CustomizerProviderImpl.class)
                                .showCustomizer(CompositePanelProviderImpl.SOURCES);
                    }
                },
                NotificationDisplayer.Priority.LOW);
        projectProperties.setAutoconfigured(false);
        projectProperties.save();
    }
}
 
Example #13
Source File: ClientSideProject.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@NbBundle.Messages({
    "# {0} - provider name",
    "# {1} - project name",
    "PlatformProvidersListenerImpl.sync.title={0} ({1})",
    "# {0} - project name",
    "PlatformProvidersListenerImpl.sync.name=Project name synced to {0}.",
})
private void projectNameChanged(PlatformProvider platformProvider, String newName) {
    if (StringUtilities.hasText(newName)
            && !getName().equals(newName)) {
        setName(newName);
        NotificationDisplayer.getDefault().notify(
                Bundle.PlatformProvidersListenerImpl_sync_title(platformProvider.getDisplayName(), newName),
                NotificationDisplayer.Priority.LOW.getIcon(),
                Bundle.PlatformProvidersListenerImpl_sync_name(newName),
                null,
                NotificationDisplayer.Priority.LOW);
    }
}
 
Example #14
Source File: ImportManager.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void notifyAvailable () {
    remindLater ();
    String msg = NbBundle.getMessage (ImportManager.class,
            "ImportNotifier_PluginAvailableForImport", // NOI18N
            toImport.size () + toInstall.size ());
    String details = NbBundle.getMessage (ImportManager.class,
            "ImportNotifier_PluginAvailableForImport_Details", // NOI18N
            srcCluster);
    MyAction a = new MyAction();
    synchronized( this ) {
        if( null != currentNotification ) {
            currentNotification.clear();
        }
        Notification notification = NotificationDisplayer.getDefault().notify(msg,
                ImageUtilities.loadImageIcon("org/netbeans/modules/autoupdate/pluginimporter/resources/import.png", false), //NOI18N
                details,
                a);
        a.notification = notification;
        currentNotification = notification;
    }
}
 
Example #15
Source File: JUnitLibraryInstaller.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Messages({"writePermission=You don't have permission to install JUnit Library into the installation directory which is recommended.",
    "showDetails=Show details"})
private static void notifyWarning(final OperationContainer<InstallSupport> oc, final UpdateElement jUnitElement, final UpdateUnit jUnitLib) {
    // lack of privileges for writing
    ActionListener onMouseClickAction = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Runnable r = new Runnable() {
                @Override
                public void run() {
                    try {
                        install(oc, jUnitElement, jUnitLib, true);
                    } catch (OperationException ex) {
                        LOG.log(Level.INFO, "While installing " + jUnitLib + " thrown " + ex, ex);
                    }
                }
            };
            showWritePermissionDialog(r);
        }
    };
    String title = writePermission();
    String description = showDetails();
    NotificationDisplayer.getDefault().notify(title,
            ImageUtilities.loadImageIcon("org/netbeans/modules/autoupdate/pluginimporter/resources/warning.gif", false), // NOI18N
            description, onMouseClickAction, NotificationDisplayer.Priority.HIGH, NotificationDisplayer.Category.WARNING);
}
 
Example #16
Source File: GradleDistributionManager.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Messages({
    "# {0} - The downloading GradleVersion ",
    "TIT_Download_Gradle=Downloading {0}",
    "# {0} - The downloading GradleVersion ",
    "MSG_Download_Gradle={0} is being downloaded and installed."
})
public DownloadTask(NbGradleVersion version) {
    this.version = version;
    handle = ProgressHandleFactory.createSystemHandle(Bundle.TIT_Download_Gradle(version.getVersion()));
    notification = NotificationDisplayer.getDefault().notify(
            Bundle.TIT_Download_Gradle(version.getVersion()),
            NbGradleProject.getIcon(),
            Bundle.MSG_Download_Gradle(version.getVersion()),
            null,
            NotificationDisplayer.Priority.NORMAL,
            NotificationDisplayer.Category.INFO);
}
 
Example #17
Source File: GradleProjectCache.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static void openNotification(File projectDir, String title, String problem, String details) {
    StringBuilder sb = new StringBuilder(details.length());
    sb.append("<html>");
    String[] lines = details.split("\n");
    for (String line : lines) {
        sb.append(line).append("<br/>");
    }
    Notification notify = NotificationDisplayer.getDefault().notify(title,
            NbGradleProject.getWarningIcon(),
            new JLabel(problem),
            new JLabel(sb.toString()),
            Priority.LOW, Category.WARNING);
    List<Notification> nlist = NOTIFICATIONS.get(projectDir);
    if (nlist == null) {
        nlist = new LinkedList<>();
        NOTIFICATIONS.put(projectDir, nlist);
    }
    nlist.add(notify);
}
 
Example #18
Source File: GradleCoverageProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Messages({
        "STATUS_INCOMPATIBLE=Old JaCoCo execution data format.",
        "# {0} - Actual JaCoCo version",
        "GRADLE_HINT=<html>Use at least the version <b>0.7.5</b> of JaCoCo in your"
                + " build to get code coverage metrics recognized.<br/><br/>"
                + "Add the following line to your build script:<br/>"
                + "jacoco.toolVersion = ''{0}''<br/><br/>"
                + "then run a Clean and Test build to update the statistics.",
})
private void updateVersionNotification(boolean hasVersionProblem) {
    if (!hasVersionProblem && (versionNotification != null)) {
        //Clear notification if the problem has been resolved
        versionNotification.clear();
        versionNotification = null;
    }

    if (hasVersionProblem && (versionNotification == null)) {
        versionNotification = NotificationDisplayer.getDefault().notify(
                STATUS_INCOMPATIBLE(),
                NbGradleProject.getWarningIcon(),
                new JLabel(STATUS_INCOMPATIBLE()),
                new JLabel(GRADLE_HINT(JACOCO_VERSION)),
                NotificationDisplayer.Priority.NORMAL,
                NotificationDisplayer.Category.WARNING);
    }
}
 
Example #19
Source File: ChangelogWildflyPlugin.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static void showChangelog() {
    try {
        Preferences prefs = NbPreferences.forModule(ChangelogWildflyPlugin.class);
        int version = Integer.parseInt(NbBundle.getMessage(ChangelogWildflyPlugin.class, VERSION_PREF));
        if (prefs.getInt(VERSION_PREF, 5) < version) {
            NotificationDisplayer.getDefault().notify(NbBundle.getMessage(ChangelogWildflyPlugin.class, "MSG_CHANGES_TITLE"),
                    new ImageIcon(ImageUtilities.loadImage("org/netbeans/modules/javaee/wildfly/resources/wildfly.png")),
                    new JLabel(NbBundle.getMessage(ChangelogWildflyPlugin.class, "MSG_CHANGES_SUMMARY")),
                    new JLabel(NbBundle.getMessage(ChangelogWildflyPlugin.class, "MSG_CHANGES_DESC")),
                    NotificationDisplayer.Priority.NORMAL, Category.INFO);
            prefs.putInt(VERSION_PREF, version);
        }
    } catch (MissingResourceException ex) {
        LOGGER.log(Level.WARNING, null, ex);
    }
}
 
Example #20
Source File: PhpProject.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@NbBundle.Messages({
    "# {0} - project name",
    "PhpOpenedHook.notification.autoconfigured.title=Project {0} automatically configured",
    "PhpOpenedHook.notification.autoconfigured.details=Review and correct important project settings detected by the IDE.",
})
private void checkAutoconfigured() {
    PhpProjectProperties projectProperties = new PhpProjectProperties(PhpProject.this);
    if (projectProperties.isAutoconfigured()) {
        NotificationDisplayer.getDefault().notify(
                Bundle.PhpOpenedHook_notification_autoconfigured_title(ProjectUtils.getInformation(PhpProject.this).getDisplayName()),
                NotificationDisplayer.Priority.LOW.getIcon(),
                Bundle.PhpOpenedHook_notification_autoconfigured_details(),
                new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        PhpProjectUtils.openCustomizer(PhpProject.this, CompositePanelProviderImpl.SOURCES);
                    }
                },
                NotificationDisplayer.Priority.LOW);
        projectProperties.setAutoconfigured(false);
        projectProperties.save();
    }
}
 
Example #21
Source File: InstallationManager.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@NbBundle.Messages({
    "NotifyMultipleInstallations.title=Multiple MySQL installations found",
    "NotifyMultipleInstallations.text=Select the installation to use"
})
private static void notifyAboutMultipleInstallations() {
    NotificationDisplayer.getDefault().notify(
            Bundle.NotifyMultipleInstallations_title(),
            ImageUtilities.loadImageIcon(ICON_BASE, false),
            Bundle.NotifyMultipleInstallations_text(),
            new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            SelectInstallationPanel.showSelectInstallationDialog();
        }
    }, NotificationDisplayer.Priority.HIGH, NotificationDisplayer.Category.WARNING);
}
 
Example #22
Source File: ClipboardHistory.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void clipboardChanged(ClipboardEvent ev) {
    ExClipboard clipboard = ev.getClipboard();

    Transferable transferable = null;
    String clipboardContent = null;
    try {
        transferable = clipboard.getContents(null);
        if (transferable != null && transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) {
            clipboardContent = (String) transferable.getTransferData(DataFlavor.stringFlavor);
        }
    } catch (OutOfMemoryError oom) {            
        NotificationDisplayer.getDefault().notify( NbBundle.getBundle(ClipboardHistory.class).getString("clipboard-history-oom"),NotificationDisplayer.Priority.NORMAL.getIcon(), NbBundle.getBundle(ClipboardHistory.class).getString("clipboard-history-oom-details"), null);
        return;
    } catch (IOException ioe) {
        //ignored for bug #218255
    } catch (UnsupportedFlavorException ufe) {
    }

    if (clipboardContent != null) {
        addHistory(transferable, clipboardContent);
    }
}
 
Example #23
Source File: Minify.java    From minifierbeans with Apache License 2.0 6 votes vote down vote up
private void showNotification(MinifyResult minifyResult, String jsEval, String cssEval, String htmlEval, String xmlEval, String jsonEval, long totalTime) throws HeadlessException {
    final String message = "%s Directories Found \n"
            + "%s JS Files Minified \n"
            + "%s CSS Files Minified \n"
            + "%s HTML Files Minified \n"
            + "%s XML Files Minified \n"
            + "%s JSON Files Minified \n\n"
            + "%s%s%s%s%s \n\n"
            + "Total Time - %d ms";

    NotificationDisplayer.getDefault().notify("Successful JS & CSS minification",
            NotificationDisplayer.Priority.NORMAL.getIcon(),
            String.format(message,
                    minifyResult.getDirectories(),
                    minifyResult.getJsFiles(),
                    minifyResult.getCssFiles(),
                    minifyResult.getHtmlFiles(),
                    minifyResult.getXmlFiles(),
                    minifyResult.getJsonFiles(),
                    jsEval,
                    cssEval,
                    htmlEval,
                    xmlEval,
                    jsonEval,
                    totalTime), null);
}
 
Example #24
Source File: Base64Encode.java    From minifierbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(ActionEvent ev) {
    Runnable runnable = new Runnable() {
        @Override
        public void run() {
            encode();
        }
    };
    final RequestProcessor.Task theTask = RP.create(runnable);
    final ProgressHandle ph = ProgressHandleFactory.createHandle("Base64 Encoding Image " + context.getPrimaryFile().getName(), theTask);
    theTask.addTaskListener(new TaskListener() {
        @Override
        public void taskFinished(org.openide.util.Task task) {
            NotificationDisplayer.getDefault().notify("Image encoded successfully", NotificationDisplayer.Priority.NORMAL.getIcon(), "The encoding of the image was successful.", null);
            
            ph.finish();
        }
    });

    ph.start();
    theTask.schedule(0);
}
 
Example #25
Source File: Base64Decode.java    From minifierbeans with Apache License 2.0 6 votes vote down vote up
void decode() {
    InputOutput io = IOProvider.getDefault().getIO(Bundle.CTL_Base64Encode(), false);
    ImageUtil imageUtil = new ImageUtil();

    try {
        FileObject file = context.getPrimaryFile();

        if (file.getExt().equalsIgnoreCase("ENCODE")) {
            File newFile = new File(file.getPath());
            String fileType = file.getName().substring(file.getName().lastIndexOf('.') + 1);

            imageUtil.decodeToImage(FileUtils.readFileToString(newFile), file.getParent().getPath() + File.separator + file.getName(), fileType);

            NotificationDisplayer.getDefault().notify("Image decoded successfully", NotificationDisplayer.Priority.NORMAL.getIcon(), "The decoding of the image was successful.", null);
        } else {
            NotificationDisplayer.getDefault().notify("Invalid file to decode", NotificationDisplayer.Priority.HIGH.getIcon(), String.format("The file '%s' is invalid. File must have an '.encode' extension.", file.getParent().getPath() + File.separator + file.getNameExt()), null);
        }
    } catch (IOException ex) {
        io.getOut().println("Exception: " + ex.toString());
    }
}
 
Example #26
Source File: ImageCompress.java    From minifierbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(ActionEvent ev) {
    Runnable runnable = new Runnable() {
        @Override
        public void run() {
            compress();
        }
    };
    
    final RequestProcessor.Task theTask = RP.create(runnable);
    final ProgressHandle ph = ProgressHandleFactory.createHandle("Compressing Image " + context.getPrimaryFile().getName(), theTask);
    
    theTask.addTaskListener(new TaskListener() {
        @Override
        public void taskFinished(org.openide.util.Task task) {
            NotificationDisplayer.getDefault().notify("Image compressed successfully", NotificationDisplayer.Priority.NORMAL.getIcon(), "The compression of the image was successful.", null);
            
            ph.finish();
        }
    });
    
    ph.start();
    theTask.schedule(0);

}
 
Example #27
Source File: ClassWizardDescriptor.java    From jeddict with Apache License 2.0 6 votes vote down vote up
public static void notifyBackupCreation(ModelerFile file, FileObject backupFile) {
    if (backupFile == null) {
        return;
    }
    NotificationDisplayer.getDefault().notify("Backup created",
            ImageUtilities.image2Icon(file.getIcon()),
            "Previous state of file has been saved to " + backupFile.getName() + ". Click here to delete it", (ActionEvent e) -> {
        try {
            if (backupFile.isValid()) {
                backupFile.delete();
            }
        } catch (IOException ex) {
            file.handleException(ex);
        }
    }, NotificationDisplayer.Priority.NORMAL, NotificationDisplayer.Category.INFO);
}
 
Example #28
Source File: SnapApp.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Handles an error.
 *
 * @param message An error message.
 * @param t       An exception or {@code null}.
 */
public void handleError(String message, Throwable t) {
    if (t != null) {
        t.printStackTrace();
    }
    Dialogs.showError("Error", message);
    getLogger().log(Level.SEVERE, message, t);

    ImageIcon icon = TangoIcons.status_dialog_error(TangoIcons.Res.R16);
    JLabel balloonDetails = new JLabel(message);
    JButton popupDetails = new JButton("Report");
    popupDetails.addActionListener(e -> {
        try {
            Desktop.getDesktop().browse(new URI("http://forum.step.esa.int/"));
        } catch (URISyntaxException | IOException e1) {
            getLogger().log(Level.SEVERE, message, e1);
        }
    });
    NotificationDisplayer.getDefault().notify("Error",
                                              icon,
                                              balloonDetails,
                                              popupDetails,
                                              NotificationDisplayer.Priority.HIGH,
                                              NotificationDisplayer.Category.ERROR);
}
 
Example #29
Source File: SmartyPhpFrameworkProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
    long startTime = System.currentTimeMillis();
    LOGGER.log(Level.FINEST, "Smarty templates autodetection started.");
    FileObject sourceDirectory = phpModule.getSourceDirectory();
    PhpVisibilityQuery visibilityQuery = Queries.getVisibilityQuery(phpModule);
    if (sourceDirectory != null && detectSmartyTemplate(sourceDirectory, visibilityQuery)) {
        NotificationDisplayer.getDefault().notify(
                Bundle.SmartyPhpFrameworkProvider_tit_smarty_template_autodetection(),
                NotificationDisplayer.Priority.LOW.getIcon(),
                new AutodetectionPanel(phpModule),
                new AutodetectionPanel(phpModule),
                NotificationDisplayer.Priority.LOW);
    }
    if (LOGGER.isLoggable(Level.FINEST)) {
        LOGGER.log(Level.FINEST, "Smarty templates autodetection took {0}ms.", System.currentTimeMillis() - startTime);
    }
}
 
Example #30
Source File: NativeExecutionUserNotificationImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void showErrorNotification(String title, String shortText, String longText) {
    ImageIcon icon = ImageUtilities.loadImageIcon("org/netbeans/modules/nativeexecution/impl/error.png", false); //NOI18N
    longText = "<html>" + longText + "</html>"; // NOI18N
    NotificationDisplayer.getDefault().notify(title, icon, new JLabel(shortText), new JLabel(longText),
            NotificationDisplayer.Priority.HIGH, NotificationDisplayer.Category.ERROR);
}