Search in sources :

Example 96 with HyperlinkEvent

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

the class ArtifactEditorImpl method createMainComponent.

public JComponent createMainComponent() {
    mySourceItemsTree.initTree();
    myLayoutTreeComponent.initTree();
    DataManager.registerDataProvider(myMainPanel, new TypeSafeDataProviderAdapter(new MyDataProvider()));
    myErrorPanelPlace.add(myValidationManager.getMainErrorPanel(), BorderLayout.CENTER);
    final JBSplitter splitter = new OnePixelSplitter(false);
    final JPanel leftPanel = new JPanel(new BorderLayout());
    JPanel treePanel = myLayoutTreeComponent.getTreePanel();
    if (UIUtil.isUnderDarcula()) {
        treePanel.setBorder(new EmptyBorder(3, 0, 0, 0));
    } else {
        treePanel.setBorder(new LineBorder(UIUtil.getBorderColor()));
    }
    leftPanel.add(treePanel, BorderLayout.CENTER);
    if (UIUtil.isUnderDarcula()) {
        CompoundBorder border = new CompoundBorder(new CustomLineBorder(0, 0, 0, 1), BorderFactory.createEmptyBorder(0, 0, 0, 0));
        leftPanel.setBorder(border);
    } else {
        leftPanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 0));
    }
    splitter.setFirstComponent(leftPanel);
    final JPanel rightPanel = new JPanel(new BorderLayout());
    final JPanel rightTopPanel = new JPanel(new BorderLayout());
    final JPanel labelPanel = new JPanel();
    labelPanel.setLayout(new BoxLayout(labelPanel, BoxLayout.X_AXIS));
    labelPanel.add(new JLabel("Available Elements "));
    final HyperlinkLabel link = new HyperlinkLabel("");
    link.setIcon(AllIcons.General.Help_small);
    link.setUseIconAsLink(true);
    link.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        protected void hyperlinkActivated(HyperlinkEvent e) {
            final JLabel label = new JLabel(ProjectBundle.message("artifact.source.items.tree.tooltip"));
            label.setBorder(HintUtil.createHintBorder());
            label.setBackground(HintUtil.getInformationColor());
            label.setOpaque(true);
            HintManager.getInstance().showHint(label, RelativePoint.getSouthWestOf(link), HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE, -1);
        }
    });
    labelPanel.add(link);
    rightTopPanel.add(labelPanel, BorderLayout.CENTER);
    rightPanel.add(rightTopPanel, BorderLayout.NORTH);
    JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(mySourceItemsTree, true);
    JPanel scrollPaneWrap = new JPanel(new BorderLayout());
    scrollPaneWrap.add(scrollPane, BorderLayout.CENTER);
    if (UIUtil.isUnderDarcula()) {
        scrollPaneWrap.setBorder(new EmptyBorder(3, 0, 0, 0));
    } else {
        scrollPaneWrap.setBorder(new LineBorder(UIUtil.getBorderColor()));
    }
    rightPanel.add(scrollPaneWrap, BorderLayout.CENTER);
    if (UIUtil.isUnderDarcula()) {
        rightPanel.setBorder(new CompoundBorder(new CustomLineBorder(0, 1, 0, 0), BorderFactory.createEmptyBorder(0, 0, 0, 0)));
    } else {
        rightPanel.setBorder(BorderFactory.createEmptyBorder(3, 0, 3, 3));
    }
    splitter.setSecondComponent(rightPanel);
    splitter.getDivider().setBackground(UIUtil.getPanelBackground());
    treePanel.setBorder(JBUI.Borders.empty());
    rightPanel.setBorder(JBUI.Borders.empty());
    scrollPaneWrap.setBorder(JBUI.Borders.empty());
    leftPanel.setBorder(JBUI.Borders.empty());
    myShowContentCheckBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final ThreeStateCheckBox.State state = myShowContentCheckBox.getState();
            if (state == ThreeStateCheckBox.State.SELECTED) {
                mySubstitutionParameters.setSubstituteAll();
            } else if (state == ThreeStateCheckBox.State.NOT_SELECTED) {
                mySubstitutionParameters.setSubstituteNone();
            }
            myShowContentCheckBox.setThirdStateEnabled(false);
            myLayoutTreeComponent.rebuildTree();
            onShowContentSettingsChanged();
        }
    });
    ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, createToolbarActionGroup(), true);
    JComponent toolbarComponent = toolbar.getComponent();
    if (UIUtil.isUnderDarcula()) {
        toolbarComponent.setBorder(new CustomLineBorder(0, 0, 1, 0));
    }
    leftPanel.add(toolbarComponent, BorderLayout.NORTH);
    toolbar.updateActionsImmediately();
    rightTopPanel.setPreferredSize(new Dimension(-1, toolbarComponent.getPreferredSize().height));
    myTabbedPane = new TabbedPaneWrapper(this);
    myTabbedPane.addTab("Output Layout", splitter);
    myPropertiesEditors.addTabs(myTabbedPane);
    myEditorPanel.add(myTabbedPane.getComponent(), BorderLayout.CENTER);
    final LayoutTree tree = myLayoutTreeComponent.getLayoutTree();
    new ShowAddPackagingElementPopupAction(this).registerCustomShortcutSet(CommonShortcuts.getNew(), tree);
    PopupHandler.installPopupHandler(tree, createPopupActionGroup(), ActionPlaces.UNKNOWN, ActionManager.getInstance());
    ToolTipManager.sharedInstance().registerComponent(tree);
    rebuildTries();
    return getMainComponent();
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) ActionEvent(java.awt.event.ActionEvent) CustomLineBorder(com.intellij.ui.border.CustomLineBorder) LineBorder(javax.swing.border.LineBorder) CompoundBorder(javax.swing.border.CompoundBorder) EmptyBorder(javax.swing.border.EmptyBorder) TypeSafeDataProviderAdapter(com.intellij.ide.impl.TypeSafeDataProviderAdapter) CustomLineBorder(com.intellij.ui.border.CustomLineBorder) ActionListener(java.awt.event.ActionListener)

Example 97 with HyperlinkEvent

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

the class MavenExecuteGoalAction method actionPerformed.

@Override
public void actionPerformed(@NotNull final AnActionEvent e) {
    final Project project = e.getRequiredData(CommonDataKeys.PROJECT);
    ExecuteMavenGoalHistoryService historyService = ExecuteMavenGoalHistoryService.getInstance(project);
    MavenExecuteGoalDialog dialog = new MavenExecuteGoalDialog(project, historyService.getHistory());
    String lastWorkingDirectory = historyService.getWorkDirectory();
    if (lastWorkingDirectory.length() == 0) {
        lastWorkingDirectory = obtainAppropriateWorkingDirectory(project);
    }
    dialog.setWorkDirectory(lastWorkingDirectory);
    if (StringUtil.isEmptyOrSpaces(historyService.getCanceledCommand())) {
        if (historyService.getHistory().size() > 0) {
            dialog.setGoals(historyService.getHistory().get(0));
        }
    } else {
        dialog.setGoals(historyService.getCanceledCommand());
    }
    if (!dialog.showAndGet()) {
        historyService.setCanceledCommand(dialog.getGoals());
        return;
    }
    historyService.setCanceledCommand(null);
    String goals = dialog.getGoals();
    goals = goals.trim();
    if (goals.startsWith("mvn ")) {
        goals = goals.substring("mvn ".length()).trim();
    }
    String workDirectory = dialog.getWorkDirectory();
    historyService.addCommand(goals, workDirectory);
    MavenProjectsManager projectsManager = MavenProjectsManager.getInstance(project);
    File mavenHome = MavenUtil.resolveMavenHomeDirectory(projectsManager.getGeneralSettings().getMavenHome());
    if (mavenHome == null) {
        Notification notification = new Notification(MavenUtil.MAVEN_NOTIFICATION_GROUP, "Failed to execute goal", RunnerBundle.message("external.maven.home.no.default.with.fix"), NotificationType.ERROR, new NotificationListener.Adapter() {

            @Override
            protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) {
                ShowSettingsUtil.getInstance().showSettingsDialog(project, MavenSettings.DISPLAY_NAME);
            }
        });
        Notifications.Bus.notify(notification, project);
        return;
    }
    MavenRunnerParameters parameters = new MavenRunnerParameters(true, workDirectory, Arrays.asList(ParametersList.parse(goals)), Collections.<String>emptyList());
    MavenGeneralSettings generalSettings = new MavenGeneralSettings();
    generalSettings.setMavenHome(mavenHome.getPath());
    MavenRunnerSettings runnerSettings = MavenRunner.getInstance(project).getSettings().clone();
    runnerSettings.setMavenProperties(new LinkedHashMap<>());
    runnerSettings.setSkipTests(false);
    MavenRunConfigurationType.runConfiguration(project, parameters, generalSettings, runnerSettings, null);
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) MavenProjectsManager(org.jetbrains.idea.maven.project.MavenProjectsManager) Notification(com.intellij.notification.Notification) MavenProject(org.jetbrains.idea.maven.project.MavenProject) Project(com.intellij.openapi.project.Project) MavenGeneralSettings(org.jetbrains.idea.maven.project.MavenGeneralSettings) File(java.io.File) NotificationListener(com.intellij.notification.NotificationListener)

Example 98 with HyperlinkEvent

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

the class TaskManagerImpl method notifyAboutConnectionFailure.

private void notifyAboutConnectionFailure(final TaskRepository repository, String details) {
    Notifications.Bus.register(TASKS_NOTIFICATION_GROUP, NotificationDisplayType.BALLOON);
    String content = "<p><a href=\"\">Configure server...</a></p>";
    if (!StringUtil.isEmpty(details)) {
        content = "<p>" + details + "</p>" + content;
    }
    Notifications.Bus.notify(new Notification(TASKS_NOTIFICATION_GROUP, "Cannot connect to " + repository.getUrl(), content, NotificationType.WARNING, new NotificationListener() {

        public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
            TaskRepositoriesConfigurable configurable = new TaskRepositoriesConfigurable(myProject);
            ShowSettingsUtil.getInstance().editConfigurable(myProject, configurable);
            if (!ArrayUtil.contains(repository, getAllRepositories())) {
                notification.expire();
            }
        }
    }), myProject);
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) TaskRepositoriesConfigurable(com.intellij.tasks.config.TaskRepositoriesConfigurable) NotNull(org.jetbrains.annotations.NotNull)

Example 99 with HyperlinkEvent

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

the class StudyProjectComponent method projectOpened.

@Override
public void projectOpened() {
    Course course = StudyTaskManager.getInstance(myProject).getCourse();
    // Check if user has javafx lib in his JDK. Now bundled JDK doesn't have this lib inside.
    if (StudyUtils.hasJavaFx()) {
        Platform.setImplicitExit(false);
    }
    if (course != null && !course.isAdaptive() && !course.isUpToDate()) {
        final Notification notification = new Notification("Update.course", "Course Updates", "Course is ready to <a href=\"update\">update</a>", NotificationType.INFORMATION, new NotificationListener() {

            @Override
            public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
                FileEditorManagerEx.getInstanceEx(myProject).closeAllFiles();
                ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
                    ProgressManager.getInstance().getProgressIndicator().setIndeterminate(true);
                    return execCancelable(() -> {
                        updateCourse();
                        return true;
                    });
                }, "Updating Course", true, myProject);
                EduUtils.synchronize();
                course.setUpdated();
            }
        });
        notification.notify(myProject);
    }
    StudyUtils.registerStudyToolWindow(course, myProject);
    StartupManager.getInstance(myProject).runWhenProjectIsInitialized(() -> ApplicationManager.getApplication().invokeLater((DumbAwareRunnable) () -> ApplicationManager.getApplication().runWriteAction((DumbAwareRunnable) () -> {
        Course course1 = StudyTaskManager.getInstance(myProject).getCourse();
        if (course1 != null) {
            UISettings instance = UISettings.getInstance();
            instance.setHideToolStripes(false);
            instance.fireUISettingsChanged();
            registerShortcuts();
            EduUsagesCollector.projectTypeOpened(course1.isAdaptive() ? EduNames.ADAPTIVE : EduNames.STUDY);
        }
    })));
    myBusConnection = ApplicationManager.getApplication().getMessageBus().connect();
    myBusConnection.subscribe(EditorColorsManager.TOPIC, new EditorColorsListener() {

        @Override
        public void globalSchemeChange(EditorColorsScheme scheme) {
            final StudyToolWindow toolWindow = StudyUtils.getStudyToolWindow(myProject);
            if (toolWindow != null) {
                toolWindow.updateFonts(myProject);
            }
        }
    });
}
Also used : EditorColorsListener(com.intellij.openapi.editor.colors.EditorColorsListener) HyperlinkEvent(javax.swing.event.HyperlinkEvent) UISettings(com.intellij.ide.ui.UISettings) EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) StudyToolWindow(com.jetbrains.edu.learning.ui.StudyToolWindow) StudyProjectGenerator.flushCourse(com.jetbrains.edu.learning.courseGeneration.StudyProjectGenerator.flushCourse) Notification(com.intellij.notification.Notification) DumbAwareRunnable(com.intellij.openapi.project.DumbAwareRunnable) NotificationListener(com.intellij.notification.NotificationListener)

Example 100 with HyperlinkEvent

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

the class GitRebaseProcess method notifySuccess.

private void notifySuccess(@NotNull Map<GitRepository, GitSuccessfulRebase> successful, final MultiMap<GitRepository, GitRebaseUtils.CommitInfo> skippedCommits) {
    String rebasedBranch = getCommonCurrentBranchNameIfAllTheSame(myRebaseSpec.getAllRepositories());
    List<SuccessType> successTypes = map(successful.values(), GitSuccessfulRebase::getSuccessType);
    SuccessType commonType = getItemIfAllTheSame(successTypes, SuccessType.REBASED);
    GitRebaseParams params = myRebaseSpec.getParams();
    String baseBranch = params == null ? null : notNull(params.getNewBase(), params.getUpstream());
    if ("HEAD".equals(baseBranch)) {
        baseBranch = getItemIfAllTheSame(myRebaseSpec.getInitialBranchNames().values(), baseBranch);
    }
    String message = commonType.formatMessage(rebasedBranch, baseBranch, params != null && params.getBranch() != null);
    message += mentionSkippedCommits(skippedCommits);
    myNotifier.notifyMinorInfo("Rebase Successful", message, new NotificationListener.Adapter() {

        @Override
        protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) {
            handlePossibleCommitLinks(e.getDescription(), skippedCommits);
        }
    });
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) GitRebaseParams(git4idea.branch.GitRebaseParams) SuccessType(git4idea.rebase.GitSuccessfulRebase.SuccessType) Notification(com.intellij.notification.Notification) 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