Search in sources :

Example 46 with HyperlinkEvent

use of javax.swing.event.HyperlinkEvent in project processdash by dtuma.

the class AutoUpdateManager method displayUpdateMessage.

/** Display a message box, telling the user that various packages are
     *  now available for download.
     */
protected void displayUpdateMessage(Component parent, int numUpdatesFound) {
    HashSet urlsSeen = new HashSet();
    DashPackage pkg;
    StringBuffer html = new StringBuffer();
    html.append("<html><head><style>" + "UL { margin-top: 0pt; margin-bottom: 0pt }" + "</style></head><body>");
    for (int i = 0; i < packages.size(); i++) {
        pkg = (DashPackage) packages.get(i);
        if (!pkg.updateAvailable)
            continue;
        String userURL = pkg.userURL;
        if (userURL == null || urlsSeen.contains(userURL))
            continue;
        urlsSeen.add(userURL);
        ArrayList updates = new ArrayList();
        updates.add(pkg.name);
        for (int j = i + 1; j < packages.size(); j++) {
            pkg = (DashPackage) packages.get(j);
            if (pkg.updateAvailable && userURL.equals(pkg.userURL))
                updates.add(pkg.name);
        }
        Collections.sort(updates, String.CASE_INSENSITIVE_ORDER);
        html.append("<p>");
        String hyperlink = "<a href=\"" + userURL + "\">" + HTMLUtils.escapeEntities(userURL) + "</a>";
        html.append(resources.format("Updates_Available_Message_FMT", hyperlink, new Integer(updates.size())));
        html.append("<ul>");
        Iterator u = updates.iterator();
        while (u.hasNext()) {
            String updateName = Translator.translate((String) u.next());
            html.append("<li>").append(HTMLUtils.escapeEntities(updateName));
        }
        html.append("</ul>");
    }
    JEditorPane message = new JEditorPane();
    message.setContentType("text/html");
    message.setEditable(false);
    message.setBackground(null);
    message.setText(html.toString());
    message.addHyperlinkListener(new HyperlinkListener() {

        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
                Browser.launch(e.getURL().toString());
        }
    });
    JCheckBox disable = new JCheckBox(resources.getString("Do_Not_Check_Label"));
    Object[] messageDisplay = new Object[2];
    messageDisplay[0] = message;
    messageDisplay[1] = disable;
    String[] updateOptions = { resources.getString("Remind_Label"), resources.getString("Close_Label") };
    int choice = JOptionPane.showOptionDialog(parent, messageDisplay, resources.getString("Updates_Available_Title"), JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, updateOptions, updateOptions[0]);
    if (choice == 0)
        InternalSettings.set(AUTO_UPDATE_SETTING + REMIND, "true");
    if (disable.isSelected())
        InternalSettings.set(AUTO_UPDATE_SETTING + DISABLED, "true");
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) ArrayList(java.util.ArrayList) JCheckBox(javax.swing.JCheckBox) HyperlinkListener(javax.swing.event.HyperlinkListener) Iterator(java.util.Iterator) JEditorPane(javax.swing.JEditorPane) HashSet(java.util.HashSet)

Example 47 with HyperlinkEvent

use of javax.swing.event.HyperlinkEvent in project buck by facebook.

the class BuckPluginNotifications method notifyActionToolbar.

public static void notifyActionToolbar(final Project project) {
    if (!PropertiesComponent.getInstance().isValueSet(GROUP_DISPLAY_ID)) {
        Notifications.Bus.notify(new Notification(GROUP_DISPLAY_ID, "Buck Plugin", "<html><a href=''>Enable</a> the toolbar to easily access the buck plugin actions." + "<br>You can enable/disable it at any time by pressing on View > Toolbar " + "in the menu.</html>", NotificationType.INFORMATION, new NotificationListener() {

            @Override
            public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent hyperlinkEvent) {
                BuckToolWindowFactory.showMainToolbar(project);
            }
        }), project);
        PropertiesComponent.getInstance().setValue(GROUP_DISPLAY_ID, "true");
    }
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) NotNull(org.jetbrains.annotations.NotNull) Notification(com.intellij.notification.Notification) NotificationListener(com.intellij.notification.NotificationListener)

Example 48 with HyperlinkEvent

use of javax.swing.event.HyperlinkEvent in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoModuleLibrariesInitializer method showVendoringNotification.

private void showVendoringNotification() {
    if (!myModuleInitialized || myModule.isDisposed()) {
        return;
    }
    Project project = myModule.getProject();
    String version = GoSdkService.getInstance(project).getSdkVersion(myModule);
    if (!GoVendoringUtil.supportsVendoring(version) || GoVendoringUtil.supportsVendoringByDefault(version)) {
        return;
    }
    if (GoModuleSettings.getInstance(myModule).getVendoringEnabled() != ThreeState.UNSURE) {
        return;
    }
    PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(project);
    boolean shownAlready;
    //noinspection SynchronizationOnLocalVariableOrMethodParameter
    synchronized (propertiesComponent) {
        shownAlready = propertiesComponent.getBoolean(GO_VENDORING_NOTIFICATION_HAD_BEEN_SHOWN, false);
        if (!shownAlready) {
            propertiesComponent.setValue(GO_VENDORING_NOTIFICATION_HAD_BEEN_SHOWN, String.valueOf(true));
        }
    }
    if (!shownAlready) {
        NotificationListener.Adapter notificationListener = new NotificationListener.Adapter() {

            @Override
            protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
                if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED && "configure".equals(event.getDescription())) {
                    GoModuleSettings.showModulesConfigurable(project);
                }
            }
        };
        Notification notification = GoConstants.GO_NOTIFICATION_GROUP.createNotification("Vendoring usage is detected", "<p><strong>vendor</strong> directory usually means that project uses Go Vendor Experiment.</p>\n" + "<p>Selected Go SDK version support vendoring but it's disabled by default.</p>\n" + "<p>You may want to explicitly enabled Go Vendor Experiment in the <a href='configure'>project settings</a>.</p>", NotificationType.INFORMATION, notificationListener);
        Notifications.Bus.notify(notification, project);
    }
}
Also used : Project(com.intellij.openapi.project.Project) HyperlinkEvent(javax.swing.event.HyperlinkEvent) PropertiesComponent(com.intellij.ide.util.PropertiesComponent) NotNull(org.jetbrains.annotations.NotNull) Notification(com.intellij.notification.Notification) NotificationListener(com.intellij.notification.NotificationListener)

Example 49 with HyperlinkEvent

use of javax.swing.event.HyperlinkEvent in project scss-lint-plugin by idok.

the class ScssLintInspection method createHyperLink.

@NotNull
private HyperlinkLabel createHyperLink() {
    //        List path = ContainerUtil.newArrayList(JSBundle.message("settings.javascript.root.configurable.name"), JSBundle.message("settings.javascript.linters.configurable.name"), getDisplayName());
    List<String> path = ContainerUtil.newArrayList(ScssLintBundle.message("scss.inspections.group.name"), ScssLintBundle.message("scss.inspection.group.name"), getDisplayName());
    String title = Joiner.on(" / ").join(path);
    final HyperlinkLabel settingsLink = new HyperlinkLabel(title);
    settingsLink.addHyperlinkListener(new HyperlinkAdapter() {

        public void hyperlinkActivated(HyperlinkEvent e) {
            DataContext dataContext = DataManager.getInstance().getDataContext(settingsLink);
            Project project = CommonDataKeys.PROJECT.getData(dataContext);
            if (project != null) {
                showSettings(project);
            //                } else {
            //                    new ScssLintSettingsPage(null).showSettings();
            }
        //                Settings settings = (Settings) Settings.KEY.getData(dataContext);
        //                if (settings == null) {
        //                    configurable.showEditDialog();
        //                } else {
        //                    settings.select(settings.find(getId()));
        //                }
        //
        //                OptionsEditor optionsEditor = OptionsEditor.KEY.getData(dataContext);
        //                if (optionsEditor == null) {
        //                    Project project = CommonDataKeys.PROJECT.getData(dataContext);
        //                    if (project != null) {
        //                        showSettings(project);
        //                    }
        //                    return;
        //                }
        //                Configurable configurable = optionsEditor.findConfigurableById(ScssLintInspection.this.getId());
        //                if (configurable != null) {
        //                    optionsEditor.clearSearchAndSelect(configurable);
        //                }
        //
        //
        //
        //                Project project = CommonDataKeys.PROJECT.getData(dataContext);
        //                if(project == null) {
        //                    LOG.warn("No project found in data context");
        //                } else {
        //                    JSLinterConfigurable configurable = JSLinterInspection.this.getExternalAnnotatorForBatchInspection().createSettingsConfigurable(project);
        //                    Settings settings = (Settings)Settings.KEY.getData(dataContext);
        //                    if(settings == null) {
        //                        configurable.showEditDialog();
        //                    } else {
        //                        settings.select(settings.find(configurable.getId()));
        //                    }
        //                }
        }
    });
    return settingsLink;
}
Also used : Project(com.intellij.openapi.project.Project) DataContext(com.intellij.openapi.actionSystem.DataContext) HyperlinkEvent(javax.swing.event.HyperlinkEvent) HyperlinkLabel(com.intellij.ui.HyperlinkLabel) HyperlinkAdapter(com.intellij.ui.HyperlinkAdapter) NotNull(org.jetbrains.annotations.NotNull)

Example 50 with HyperlinkEvent

use of javax.swing.event.HyperlinkEvent in project libgdx by libgdx.

the class GdxSetupUI method generate.

void generate() {
    final String name = ui.form.nameText.getText().trim();
    if (name.length() == 0) {
        JOptionPane.showMessageDialog(this, "Please enter a project name.");
        return;
    }
    final String pack = ui.form.packageText.getText().trim();
    if (pack.length() == 0) {
        JOptionPane.showMessageDialog(this, "Please enter a package name.");
        return;
    }
    Pattern pattern = Pattern.compile("[a-z][a-z0-9_]*(\\.[a-z0-9_]+)+[0-9a-z_]");
    Matcher matcher = pattern.matcher(pack);
    boolean matches = matcher.matches();
    if (!matches) {
        JOptionPane.showMessageDialog(this, "Invalid package name");
        return;
    }
    final String clazz = ui.form.gameClassText.getText().trim();
    if (clazz.length() == 0) {
        JOptionPane.showMessageDialog(this, "Please enter a game class name.");
        return;
    }
    final String destination = ui.form.destinationText.getText().trim();
    if (destination.length() == 0) {
        JOptionPane.showMessageDialog(this, "Please enter a destination directory.");
        return;
    }
    final String sdkLocation = ui.form.sdkLocationText.getText().trim();
    if (sdkLocation.length() == 0 && modules.contains(ProjectType.ANDROID)) {
        JOptionPane.showMessageDialog(this, "Please enter your Android SDK's path");
        return;
    }
    if (!GdxSetup.isSdkLocationValid(sdkLocation) && modules.contains(ProjectType.ANDROID)) {
        JOptionPane.showMessageDialog(this, "Your Android SDK path doesn't contain an SDK! Please install the Android SDK, including all platforms and build tools!");
        return;
    }
    if (modules.contains(ProjectType.ANDROID)) {
        if (!GdxSetup.isSdkUpToDate(sdkLocation)) {
            File sdkLocationFile = new File(sdkLocation);
            try {
                //give them a poke in the right direction
                if (System.getProperty("os.name").contains("Windows")) {
                    String replaced = sdkLocation.replace("\\", "\\\\");
                    Runtime.getRuntime().exec("\"" + replaced + "\\SDK Manager.exe\"");
                } else {
                    File sdkManager = new File(sdkLocation, "tools/android");
                    Runtime.getRuntime().exec(new String[] { sdkManager.getAbsolutePath(), "sdk" });
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            return;
        }
    }
    if (!GdxSetup.isEmptyDirectory(destination)) {
        int value = JOptionPane.showConfirmDialog(this, "The destination is not empty, do you want to overwrite?", "Warning!", JOptionPane.YES_NO_OPTION);
        if (value != 0) {
            return;
        }
    }
    List<String> incompatList = builder.buildProject(modules, dependencies);
    if (incompatList.size() == 0) {
        try {
            builder.build();
        } catch (IOException e) {
            e.printStackTrace();
        }
    } else {
        JPanel panel = new JPanel();
        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
        for (String subIncompat : incompatList) {
            JLabel label = new JLabel(subIncompat);
            label.setAlignmentX(Component.CENTER_ALIGNMENT);
            panel.add(label);
        }
        JLabel infoLabel = new JLabel("<html><br><br>The project can be generated, but you wont be able to use these extensions in the respective sub modules<br>Please see the link to learn about extensions</html>");
        infoLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
        panel.add(infoLabel);
        JEditorPane pane = new JEditorPane("text/html", "<a href=\"https://github.com/libgdx/libgdx/wiki/Dependency-management-with-Gradle\">Dependency Management</a>");
        pane.addHyperlinkListener(new HyperlinkListener() {

            @Override
            public void hyperlinkUpdate(HyperlinkEvent e) {
                if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED))
                    try {
                        Desktop.getDesktop().browse(new URI(e.getURL().toString()));
                    } catch (IOException e1) {
                        e1.printStackTrace();
                    } catch (URISyntaxException e1) {
                        e1.printStackTrace();
                    }
            }
        });
        pane.setEditable(false);
        pane.setOpaque(false);
        pane.setAlignmentX(Component.CENTER_ALIGNMENT);
        panel.add(pane);
        Object[] options = { "Yes, build it!", "No, I'll change my extensions" };
        int value = JOptionPane.showOptionDialog(null, panel, "Extension Incompatibilities", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, null);
        if (value != 0) {
            return;
        } else {
            try {
                builder.build();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    ui.generateButton.setEnabled(false);
    new Thread() {

        public void run() {
            log("Generating app in " + destination);
            new GdxSetup().build(builder, destination, name, pack, clazz, sdkLocation, new CharCallback() {

                @Override
                public void character(char c) {
                    log(c);
                }
            }, ui.settings.getGradleArgs());
            log("Done!");
            if (ui.settings.getGradleArgs().contains("eclipse") || ui.settings.getGradleArgs().contains("idea")) {
                log("To import in Eclipse: File -> Import -> General -> Existing Projects into Workspace");
                log("To import to Intellij IDEA: File -> Open -> YourProject.ipr");
            } else {
                log("To import in Eclipse: File -> Import -> Gradle -> Gradle Project");
                log("To import to Intellij IDEA: File -> Open -> build.gradle");
                log("To import to NetBeans: File -> Open Project...");
            }
            SwingUtilities.invokeLater(new Runnable() {

                @Override
                public void run() {
                    ui.generateButton.setEnabled(true);
                }
            });
        }
    }.start();
}
Also used : Pattern(java.util.regex.Pattern) JPanel(javax.swing.JPanel) HyperlinkEvent(javax.swing.event.HyperlinkEvent) Matcher(java.util.regex.Matcher) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) Point(java.awt.Point) CharCallback(com.badlogic.gdx.setup.Executor.CharCallback) HyperlinkListener(javax.swing.event.HyperlinkListener) JEditorPane(javax.swing.JEditorPane) File(java.io.File)

Aggregations

HyperlinkEvent (javax.swing.event.HyperlinkEvent)90 NotNull (org.jetbrains.annotations.NotNull)36 Notification (com.intellij.notification.Notification)33 NotificationListener (com.intellij.notification.NotificationListener)31 HyperlinkListener (javax.swing.event.HyperlinkListener)30 Project (com.intellij.openapi.project.Project)14 HyperlinkAdapter (com.intellij.ui.HyperlinkAdapter)14 File (java.io.File)14 VirtualFile (com.intellij.openapi.vfs.VirtualFile)11 HyperlinkLabel (com.intellij.ui.HyperlinkLabel)9 IOException (java.io.IOException)7 URL (java.net.URL)5 AnAction (com.intellij.openapi.actionSystem.AnAction)4 DataContext (com.intellij.openapi.actionSystem.DataContext)4 IdeFrame (com.intellij.openapi.wm.IdeFrame)3 MultiMap (com.intellij.util.containers.MultiMap)3 NonNls (org.jetbrains.annotations.NonNls)3 Nullable (org.jetbrains.annotations.Nullable)3 UISettings (com.intellij.ide.ui.UISettings)2 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)2