Search in sources :

Example 6 with HyperlinkEvent

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

the class CopiesPanel method updateList.

private void updateList(@NotNull final List<WCInfo> infoList, @NotNull final List<WorkingCopyFormat> supportedFormats) {
    myPanel.removeAll();
    final Insets nullIndent = new Insets(1, 3, 1, 0);
    final GridBagConstraints gb = new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(2, 2, 0, 0), 0, 0);
    gb.insets.left = 4;
    myPanel.add(myRefreshLabel, gb);
    gb.insets.left = 1;
    final LocalFileSystem lfs = LocalFileSystem.getInstance();
    final Insets topIndent = new Insets(10, 3, 0, 0);
    for (final WCInfo wcInfo : infoList) {
        final Collection<WorkingCopyFormat> upgradeFormats = getUpgradeFormats(wcInfo, supportedFormats);
        final VirtualFile vf = lfs.refreshAndFindFileByIoFile(new File(wcInfo.getPath()));
        final VirtualFile root = (vf == null) ? wcInfo.getVcsRoot() : vf;
        final JEditorPane editorPane = new JEditorPane(UIUtil.HTML_MIME, "");
        editorPane.setEditable(false);
        editorPane.setFocusable(true);
        editorPane.setBackground(UIUtil.getPanelBackground());
        editorPane.setOpaque(false);
        editorPane.addHyperlinkListener(new HyperlinkListener() {

            @Override
            public void hyperlinkUpdate(HyperlinkEvent e) {
                if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                    if (CONFIGURE_BRANCHES.equals(e.getDescription())) {
                        if (!checkRoot(root, wcInfo.getPath(), " invoke Configure Branches"))
                            return;
                        BranchConfigurationDialog.configureBranches(myProject, root);
                    } else if (FIX_DEPTH.equals(e.getDescription())) {
                        final int result = Messages.showOkCancelDialog(myVcs.getProject(), "You are going to checkout into '" + wcInfo.getPath() + "' with 'infinity' depth.\n" + "This will update your working copy to HEAD revision as well.", "Set Working Copy Infinity Depth", Messages.getWarningIcon());
                        if (result == Messages.OK) {
                            // update of view will be triggered by roots changed event
                            SvnCheckoutProvider.checkout(myVcs.getProject(), new File(wcInfo.getPath()), wcInfo.getRootUrl(), SVNRevision.HEAD, Depth.INFINITY, false, null, wcInfo.getFormat());
                        }
                    } else if (CHANGE_FORMAT.equals(e.getDescription())) {
                        changeFormat(wcInfo, upgradeFormats);
                    } else if (MERGE_FROM.equals(e.getDescription())) {
                        if (!checkRoot(root, wcInfo.getPath(), " invoke Merge From"))
                            return;
                        mergeFrom(wcInfo, root, editorPane);
                    } else if (CLEANUP.equals(e.getDescription())) {
                        if (!checkRoot(root, wcInfo.getPath(), " invoke Cleanup"))
                            return;
                        new CleanupWorker(myVcs, singletonList(root)).execute();
                    }
                }
            }

            private boolean checkRoot(VirtualFile root, final String path, final String actionName) {
                if (root == null) {
                    Messages.showWarningDialog(myProject, "Invalid working copy root: " + path, "Can not " + actionName);
                    return false;
                }
                return true;
            }
        });
        editorPane.setBorder(null);
        editorPane.setText(formatWc(wcInfo, upgradeFormats));
        final JPanel copyPanel = new JPanel(new GridBagLayout());
        final GridBagConstraints gb1 = new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, nullIndent, 0, 0);
        gb1.insets.top = 1;
        gb1.gridwidth = 3;
        gb.insets = topIndent;
        gb.fill = GridBagConstraints.HORIZONTAL;
        ++gb.gridy;
        final JPanel contForCopy = new JPanel(new BorderLayout());
        contForCopy.add(copyPanel, BorderLayout.WEST);
        myPanel.add(contForCopy, gb);
        copyPanel.add(editorPane, gb1);
        gb1.insets = nullIndent;
    }
    myPanel.revalidate();
    myPanel.repaint();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) HyperlinkEvent(javax.swing.event.HyperlinkEvent) HyperlinkListener(javax.swing.event.HyperlinkListener) LocalFileSystem(com.intellij.openapi.vfs.LocalFileSystem) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) CleanupWorker(org.jetbrains.idea.svn.actions.CleanupWorker)

Example 7 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 8 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)

Example 9 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 10 with HyperlinkEvent

use of javax.swing.event.HyperlinkEvent in project ideavim by JetBrains.

the class VimPlugin method updateState.

private void updateState() {
    if (isEnabled() && !ApplicationManager.getApplication().isUnitTestMode()) {
        if (SystemInfo.isMac) {
            final MacKeyRepeat keyRepeat = MacKeyRepeat.getInstance();
            final Boolean enabled = keyRepeat.isEnabled();
            final Boolean isKeyRepeat = editor.isKeyRepeat();
            if ((enabled == null || !enabled) && (isKeyRepeat == null || isKeyRepeat)) {
                if (Messages.showYesNoDialog("Do you want to enable repeating keys in Mac OS X on press and hold?\n\n" + "(You can do it manually by running 'defaults write -g " + "ApplePressAndHoldEnabled 0' in the console).", IDEAVIM_NOTIFICATION_TITLE, Messages.getQuestionIcon()) == Messages.YES) {
                    editor.setKeyRepeat(true);
                    keyRepeat.setEnabled(true);
                } else {
                    editor.setKeyRepeat(false);
                }
            }
        }
        if (previousStateVersion > 0 && previousStateVersion < 3) {
            final KeymapManagerEx manager = KeymapManagerEx.getInstanceEx();
            Keymap keymap = null;
            if (previousKeyMap != null) {
                keymap = manager.getKeymap(previousKeyMap);
            }
            if (keymap == null) {
                keymap = manager.getKeymap(DefaultKeymap.getInstance().getDefaultKeymapName());
            }
            assert keymap != null : "Default keymap not found";
            new Notification(VimPlugin.IDEAVIM_STICKY_NOTIFICATION_ID, VimPlugin.IDEAVIM_NOTIFICATION_TITLE, String.format("IdeaVim plugin doesn't use the special \"Vim\" keymap any longer. " + "Switching to \"%s\" keymap.<br/><br/>" + "Now it is possible to set up:<br/>" + "<ul>" + "<li>Vim keys in your ~/.ideavimrc file using key mapping commands</li>" + "<li>IDE action shortcuts in \"File | Settings | Keymap\"</li>" + "<li>Vim or IDE handlers for conflicting shortcuts in <a href='#settings'>Vim Emulation</a> settings</li>" + "</ul>", keymap.getPresentableName()), NotificationType.INFORMATION, new NotificationListener.Adapter() {

                @Override
                protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) {
                    ShowSettingsUtil.getInstance().editConfigurable((Project) null, new VimEmulationConfigurable());
                }
            }).notify(null);
            manager.setActiveKeymap(keymap);
        }
        if (previousStateVersion > 0 && previousStateVersion < 4) {
            new Notification(VimPlugin.IDEAVIM_STICKY_NOTIFICATION_ID, VimPlugin.IDEAVIM_NOTIFICATION_TITLE, "The ~/.vimrc file is no longer read by default, use ~/.ideavimrc instead. You can read it from your " + "~/.ideavimrc using this command:<br/><br/>" + "<code>source ~/.vimrc</code>", NotificationType.INFORMATION).notify(null);
        }
    }
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) MacKeyRepeat(com.maddyhome.idea.vim.helper.MacKeyRepeat) KeymapManagerEx(com.intellij.openapi.keymap.ex.KeymapManagerEx) EditorFactoryAdapter(com.intellij.openapi.editor.event.EditorFactoryAdapter) ProjectManagerAdapter(com.intellij.openapi.project.ProjectManagerAdapter) VimEmulationConfigurable(com.maddyhome.idea.vim.ui.VimEmulationConfigurable) NotNull(org.jetbrains.annotations.NotNull) Keymap(com.intellij.openapi.keymap.Keymap) DefaultKeymap(com.intellij.openapi.keymap.impl.DefaultKeymap)

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