Search in sources :

Example 1 with HyperlinkEvent

use of javax.swing.event.HyperlinkEvent in project intellij-community by JetBrains.

the class DesignerEditorPanel method addErrorMessage.

protected void addErrorMessage(final FixableMessageInfo message, Icon icon) {
    if (message.myLinkText.length() > 0 || message.myAfterLinkText.length() > 0) {
        HyperlinkLabel warnLabel = new HyperlinkLabel();
        warnLabel.setOpaque(false);
        warnLabel.setHyperlinkText(message.myBeforeLinkText, message.myLinkText, message.myAfterLinkText);
        warnLabel.setIcon(icon);
        if (message.myQuickFix != null) {
            warnLabel.addHyperlinkListener(new HyperlinkListener() {

                public void hyperlinkUpdate(final HyperlinkEvent e) {
                    if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                        message.myQuickFix.run();
                    }
                }
            });
        }
        myErrorMessages.add(warnLabel);
    } else {
        JBLabel warnLabel = new JBLabel();
        warnLabel.setOpaque(false);
        warnLabel.setText("<html><body>" + message.myBeforeLinkText.replace("\n", "<br>") + "</body></html>");
        warnLabel.setIcon(icon);
        myErrorMessages.add(warnLabel);
    }
    if (message.myAdditionalFixes != null && message.myAdditionalFixes.size() > 0) {
        JPanel fixesPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0));
        fixesPanel.setBorder(IdeBorderFactory.createEmptyBorder(3, 0, 10, 0));
        fixesPanel.setOpaque(false);
        fixesPanel.add(Box.createHorizontalStrut(icon.getIconWidth()));
        for (Pair<String, Runnable> pair : message.myAdditionalFixes) {
            HyperlinkLabel fixLabel = new HyperlinkLabel();
            fixLabel.setOpaque(false);
            fixLabel.setHyperlinkText(pair.getFirst());
            final Runnable fix = pair.getSecond();
            fixLabel.addHyperlinkListener(new HyperlinkListener() {

                @Override
                public void hyperlinkUpdate(HyperlinkEvent e) {
                    if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                        fix.run();
                    }
                }
            });
            fixesPanel.add(fixLabel);
        }
        myErrorMessages.add(fixesPanel);
    }
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) VerticalFlowLayout(com.intellij.openapi.ui.VerticalFlowLayout) HyperlinkListener(javax.swing.event.HyperlinkListener) JBLabel(com.intellij.ui.components.JBLabel) ThrowableRunnable(com.intellij.util.ThrowableRunnable) HyperlinkLabel(com.intellij.ui.HyperlinkLabel)

Example 2 with HyperlinkEvent

use of javax.swing.event.HyperlinkEvent in project pcgen by PCGen.

the class Initiative method addTab.

/**
	 * <p>
	 * Adds a tab to the {@code tpaneInfo} member. All methods adding
	 * character tabs to {@code tpaneInfo} should call this method to do
	 * so, as it provides a standard setup for the text panes and installs
	 * hyperlink listeners.
	 * </p>
	 *
	 * @param cbt Combatant to add.
	 */
void addTab(final Combatant cbt) {
    javax.swing.JTextPane lp = new javax.swing.JTextPane();
    lp.setContentType("text/html");
    InfoCharacterDetails ic = new InfoCharacterDetails(cbt, lp);
    tpaneInfo.addTab(cbt.getName(), ic.getScrollPane());
    lp.setEditable(false);
    lp.addHyperlinkListener(new HyperlinkListener() {

        private final Combatant combatant = cbt;

        @Override
        public void hyperlinkUpdate(HyperlinkEvent e) {
            hyperLinkSelected(e, combatant);
        }
    });
}
Also used : InfoCharacterDetails(gmgen.plugin.InfoCharacterDetails) HyperlinkEvent(javax.swing.event.HyperlinkEvent) HyperlinkListener(javax.swing.event.HyperlinkListener) Combatant(gmgen.plugin.Combatant) PcgCombatant(gmgen.plugin.PcgCombatant) XMLCombatant(plugin.initiative.XMLCombatant)

Example 3 with HyperlinkEvent

use of javax.swing.event.HyperlinkEvent in project intellij-community by JetBrains.

the class SceneBuilderEditor method createErrorPage.

private void createErrorPage() {
    myErrorLabel.setOpaque(false);
    myErrorLabel.addHyperlinkListener(new HyperlinkListener() {

        @Override
        public void hyperlinkUpdate(HyperlinkEvent e) {
            updateState();
        }
    });
    myErrorStack = new JTextArea(50, 20);
    myErrorStack.setEditable(false);
    myErrorPanel.add(myErrorLabel, BorderLayout.NORTH);
    myErrorPanel.add(ScrollPaneFactory.createScrollPane(myErrorStack), BorderLayout.CENTER);
    myPanel.add(myErrorPanel);
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) HyperlinkListener(javax.swing.event.HyperlinkListener)

Example 4 with HyperlinkEvent

use of javax.swing.event.HyperlinkEvent in project intellij-community by JetBrains.

the class HgRemoteChangesetsCommand method executeCommandInCurrentThread.

@Override
protected HgCommandResult executeCommandInCurrentThread(VirtualFile repo, List<String> args) {
    String repositoryURL = getRepositoryUrl(repo);
    if (repositoryURL == null) {
        LOG.info("executeCommand no default path configured");
        return null;
    }
    HgRemoteCommandExecutor executor = new HgRemoteCommandExecutor(project, repositoryURL);
    HgCommandResult result = executor.executeInCurrentThread(repo, command, args);
    if (result == HgCommandResult.CANCELLED || HgErrorUtil.isAuthorizationError(result)) {
        final HgVcs vcs = HgVcs.getInstance(project);
        if (vcs == null) {
            return result;
        }
        new HgCommandResultNotifier(project).notifyError(result, "Checking for incoming/outgoing changes disabled", "Authentication is required to check incoming/outgoing changes in " + repositoryURL + "<br/>You may enable checking for changes <a href='#'>in the Settings</a>.", new NotificationListener() {

            @Override
            public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
                ShowSettingsUtil.getInstance().showSettingsDialog(project, vcs.getConfigurable().getDisplayName());
            }
        });
        final HgProjectSettings projectSettings = vcs.getProjectSettings();
        projectSettings.setCheckIncomingOutgoing(false);
        project.getMessageBus().syncPublisher(HgVcs.INCOMING_OUTGOING_CHECK_TOPIC).hide();
    }
    return result;
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) HgVcs(org.zmlx.hg4idea.HgVcs) HyperlinkEvent(javax.swing.event.HyperlinkEvent) HgProjectSettings(org.zmlx.hg4idea.HgProjectSettings) HgRemoteCommandExecutor(org.zmlx.hg4idea.execution.HgRemoteCommandExecutor) HgCommandResultNotifier(org.zmlx.hg4idea.action.HgCommandResultNotifier) Notification(com.intellij.notification.Notification) NotificationListener(com.intellij.notification.NotificationListener)

Example 5 with HyperlinkEvent

use of javax.swing.event.HyperlinkEvent in project intellij-community by JetBrains.

the class MavenServerManager method createRunProfileState.

private RunProfileState createRunProfileState() {
    return new CommandLineState(null) {

        private SimpleJavaParameters createJavaParameters() {
            final SimpleJavaParameters params = new SimpleJavaParameters();
            final Sdk jdk = getJdk();
            params.setJdk(jdk);
            params.setWorkingDirectory(PathManager.getBinPath());
            params.setMainClass(MAIN_CLASS);
            Map<String, String> defs = new THashMap<>();
            defs.putAll(MavenUtil.getPropertiesFromMavenOpts());
            // pass ssl-related options
            for (Map.Entry<Object, Object> each : System.getProperties().entrySet()) {
                Object key = each.getKey();
                Object value = each.getValue();
                if (key instanceof String && value instanceof String && ((String) key).startsWith("javax.net.ssl")) {
                    defs.put((String) key, (String) value);
                }
            }
            if (SystemInfo.isMac) {
                String arch = System.getProperty("sun.arch.data.model");
                if (arch != null) {
                    params.getVMParametersList().addParametersString("-d" + arch);
                }
            }
            defs.put("java.awt.headless", "true");
            for (Map.Entry<String, String> each : defs.entrySet()) {
                params.getVMParametersList().defineProperty(each.getKey(), each.getValue());
            }
            params.getVMParametersList().addProperty("idea.version=", MavenUtil.getIdeaVersionToPassToMavenProcess());
            boolean xmxSet = false;
            boolean forceMaven2 = false;
            if (myState.vmOptions != null) {
                ParametersList mavenOptsList = new ParametersList();
                mavenOptsList.addParametersString(myState.vmOptions);
                for (String param : mavenOptsList.getParameters()) {
                    if (param.startsWith("-Xmx")) {
                        xmxSet = true;
                    }
                    if (param.equals(FORCE_MAVEN2_OPTION)) {
                        forceMaven2 = true;
                    }
                    params.getVMParametersList().add(param);
                }
            }
            final File mavenHome;
            final String mavenVersion;
            final File currentMavenHomeFile = forceMaven2 ? BundledMavenPathHolder.myBundledMaven2Home : getCurrentMavenHomeFile();
            if (currentMavenHomeFile == null) {
                mavenHome = BundledMavenPathHolder.myBundledMaven3Home;
                mavenVersion = getMavenVersion(mavenHome);
                Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
                final Project project = openProjects.length == 1 ? openProjects[0] : null;
                if (project != null) {
                    new Notification(MavenUtil.MAVEN_NOTIFICATION_GROUP, "", RunnerBundle.message("external.maven.home.invalid.substitution.warning.with.fix", myState.mavenHome, mavenVersion), NotificationType.WARNING, new NotificationListener() {

                        @Override
                        public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
                            ShowSettingsUtil.getInstance().showSettingsDialog(project, MavenSettings.DISPLAY_NAME);
                        }
                    }).notify(null);
                } else {
                    new Notification(MavenUtil.MAVEN_NOTIFICATION_GROUP, "", RunnerBundle.message("external.maven.home.invalid.substitution.warning", myState.mavenHome, mavenVersion), NotificationType.WARNING).notify(null);
                }
            } else {
                mavenHome = currentMavenHomeFile;
                mavenVersion = getMavenVersion(mavenHome);
            }
            assert mavenVersion != null;
            params.getVMParametersList().addProperty(MavenServerEmbedder.MAVEN_EMBEDDER_VERSION, mavenVersion);
            String sdkConfigLocation = "Settings | Build, Execution, Deployment | Build Tools | Maven | Importing | JDK for Importer";
            verifyMavenSdkRequirements(jdk, mavenVersion, sdkConfigLocation);
            final List<String> classPath = new ArrayList<>();
            classPath.add(PathUtil.getJarPathForClass(org.apache.log4j.Logger.class));
            if (StringUtil.compareVersionNumbers(mavenVersion, "3.1") < 0) {
                classPath.add(PathUtil.getJarPathForClass(Logger.class));
                classPath.add(PathUtil.getJarPathForClass(Log4jLoggerFactory.class));
            }
            classPath.addAll(PathManager.getUtilClassPath());
            ContainerUtil.addIfNotNull(classPath, PathUtil.getJarPathForClass(Query.class));
            params.getClassPath().add(PathManager.getResourceRoot(getClass(), "/messages/CommonBundle.properties"));
            params.getClassPath().addAll(classPath);
            params.getClassPath().addAllFiles(collectClassPathAndLibsFolder(mavenVersion, mavenHome));
            String embedderXmx = System.getProperty("idea.maven.embedder.xmx");
            if (embedderXmx != null) {
                params.getVMParametersList().add("-Xmx" + embedderXmx);
            } else {
                if (!xmxSet) {
                    params.getVMParametersList().add("-Xmx768m");
                }
            }
            String mavenEmbedderDebugPort = System.getProperty("idea.maven.embedder.debug.port");
            if (mavenEmbedderDebugPort != null) {
                params.getVMParametersList().addParametersString("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=" + mavenEmbedderDebugPort);
            }
            String mavenEmbedderParameters = System.getProperty("idea.maven.embedder.parameters");
            if (mavenEmbedderParameters != null) {
                params.getProgramParametersList().addParametersString(mavenEmbedderParameters);
            }
            String mavenEmbedderCliOptions = System.getProperty(MavenServerEmbedder.MAVEN_EMBEDDER_CLI_ADDITIONAL_ARGS);
            if (mavenEmbedderCliOptions != null) {
                params.getVMParametersList().addProperty(MavenServerEmbedder.MAVEN_EMBEDDER_CLI_ADDITIONAL_ARGS, mavenEmbedderCliOptions);
            }
            return params;
        }

        @NotNull
        @Override
        public ExecutionResult execute(@NotNull Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
            ProcessHandler processHandler = startProcess();
            return new DefaultExecutionResult(processHandler);
        }

        @Override
        @NotNull
        protected OSProcessHandler startProcess() throws ExecutionException {
            SimpleJavaParameters params = createJavaParameters();
            GeneralCommandLine commandLine = params.toCommandLine();
            OSProcessHandler processHandler = new OSProcessHandler(commandLine);
            processHandler.setShouldDestroyProcessRecursively(false);
            return processHandler;
        }
    };
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) DefaultExecutionResult(com.intellij.execution.DefaultExecutionResult) Query(org.apache.lucene.search.Query) Logger(org.slf4j.Logger) NotNull(org.jetbrains.annotations.NotNull) Notification(com.intellij.notification.Notification) Executor(com.intellij.execution.Executor) THashMap(gnu.trove.THashMap) Log4jLoggerFactory(org.slf4j.impl.Log4jLoggerFactory) JavaSdk(com.intellij.openapi.projectRoots.JavaSdk) Sdk(com.intellij.openapi.projectRoots.Sdk) ProgramRunner(com.intellij.execution.runners.ProgramRunner) Project(com.intellij.openapi.project.Project) OSProcessHandler(com.intellij.execution.process.OSProcessHandler) OSProcessHandler(com.intellij.execution.process.OSProcessHandler) ProcessHandler(com.intellij.execution.process.ProcessHandler) UnicastRemoteObject(java.rmi.server.UnicastRemoteObject) THashMap(gnu.trove.THashMap) File(java.io.File) NotificationListener(com.intellij.notification.NotificationListener)

Aggregations

HyperlinkEvent (javax.swing.event.HyperlinkEvent)132 HyperlinkListener (javax.swing.event.HyperlinkListener)55 Notification (com.intellij.notification.Notification)41 NotificationListener (com.intellij.notification.NotificationListener)39 NotNull (org.jetbrains.annotations.NotNull)36 HyperlinkAdapter (com.intellij.ui.HyperlinkAdapter)20 Project (com.intellij.openapi.project.Project)15 URL (java.net.URL)15 File (java.io.File)14 VirtualFile (com.intellij.openapi.vfs.VirtualFile)13 HyperlinkLabel (com.intellij.ui.HyperlinkLabel)13 JEditorPane (javax.swing.JEditorPane)13 IOException (java.io.IOException)10 JPanel (javax.swing.JPanel)9 ActionEvent (java.awt.event.ActionEvent)8 JScrollPane (javax.swing.JScrollPane)8 JTextPane (javax.swing.JTextPane)8 URI (java.net.URI)7 HTMLDocument (javax.swing.text.html.HTMLDocument)7 Dimension (java.awt.Dimension)6