Search in sources :

Example 6 with ActionLink

use of com.intellij.ui.components.labels.ActionLink in project intellij-elixir by KronicDeth.

the class MixConfigurationForm method createUIComponents.

private void createUIComponents() {
    myLinkContainer = new JPanel(new BorderLayout());
    ActionLink link = new ActionLink("Download the latest Mix version", new AnAction() {

        @Override
        public void actionPerformed(AnActionEvent anActionEvent) {
            DownloadableFileService service = DownloadableFileService.getInstance();
            DownloadableFileDescription mix = service.createFileDescription("http://s3.hex.pm/builds/mix/mix", "mix");
            FileDownloader downloader = service.createDownloader(ContainerUtil.list(mix), "mix");
            List<Pair<VirtualFile, DownloadableFileDescription>> pairs = downloader.downloadWithProgress(null, getEventProject(anActionEvent), myLinkContainer);
            if (pairs != null) {
                for (Pair<VirtualFile, DownloadableFileDescription> pair : pairs) {
                    try {
                        String path = pair.first.getCanonicalPath();
                        if (path != null) {
                            FileUtilRt.setExecutableAttribute(path, true);
                            myMixPathSelector.setText(path);
                            validateMixPath();
                        }
                    } catch (Exception e) {
                    // Ignore
                    }
                }
            }
        }
    });
    myLinkContainer.add(link, BorderLayout.NORTH);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) AnAction(com.intellij.openapi.actionSystem.AnAction) ExecutionException(com.intellij.execution.ExecutionException) DownloadableFileDescription(com.intellij.util.download.DownloadableFileDescription) FileDownloader(com.intellij.util.download.FileDownloader) List(java.util.List) ActionLink(com.intellij.ui.components.labels.ActionLink) DownloadableFileService(com.intellij.util.download.DownloadableFileService) Pair(com.intellij.openapi.util.Pair)

Example 7 with ActionLink

use of com.intellij.ui.components.labels.ActionLink in project intellij-community by JetBrains.

the class VcsPushDialog method createForcePushInfoLabel.

@NotNull
private JComponent createForcePushInfoLabel() {
    JPanel text = new JPanel();
    text.setLayout(new BoxLayout(text, BoxLayout.X_AXIS));
    JLabel label = new JLabel("You can enable and configure Force Push in " + ShowSettingsUtil.getSettingsMenuName() + ".");
    label.setEnabled(false);
    label.setFont(JBUI.Fonts.smallFont());
    text.add(label);
    ActionLink here = new ActionLink("Configure", new AnAction() {

        @Override
        public void actionPerformed(AnActionEvent e) {
            Project project = myController.getProject();
            VcsPushDialog.this.doCancelAction(e.getInputEvent());
            ShowSettingsUtilImpl.showSettingsDialog(project, "vcs.Git", "force push");
        }
    });
    here.setFont(JBUI.Fonts.smallFont());
    text.add(here);
    return JBUI.Panels.simplePanel().addToRight(text).withBorder(JBUI.Borders.emptyBottom(4));
}
Also used : Project(com.intellij.openapi.project.Project) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) AnAction(com.intellij.openapi.actionSystem.AnAction) ActionLink(com.intellij.ui.components.labels.ActionLink) NotNull(org.jetbrains.annotations.NotNull)

Example 8 with ActionLink

use of com.intellij.ui.components.labels.ActionLink in project android by JetBrains.

the class ActionLinkFixture method findByActionId.

@NotNull
public static ActionLinkFixture findByActionId(@NotNull final String actionId, @NotNull final Robot robot, @NotNull final Container container) {
    final Ref<ActionLink> actionLinkRef = new Ref<>();
    Wait.seconds(1).expecting("ActionLink with ID '" + actionId + "' to be visible").until(() -> {
        Collection<ActionLink> found = robot.finder().findAll(container, new GenericTypeMatcher<ActionLink>(ActionLink.class) {

            @Override
            protected boolean isMatching(@NotNull ActionLink actionLink) {
                if (actionLink.isVisible()) {
                    AnAction action = actionLink.getAction();
                    String id = ActionManager.getInstance().getId(action);
                    return actionId.equals(id);
                }
                return false;
            }
        });
        if (found.size() == 1) {
            actionLinkRef.set(getFirstItem(found));
            return true;
        }
        return false;
    });
    ActionLink actionLink = actionLinkRef.get();
    if (actionLink == null) {
        throw new ComponentLookupException("Failed to find ActionLink with ID '" + actionId + "'");
    }
    return new ActionLinkFixture(robot, actionLink);
}
Also used : Ref(com.intellij.openapi.util.Ref) ComponentLookupException(org.fest.swing.exception.ComponentLookupException) AnAction(com.intellij.openapi.actionSystem.AnAction) ActionLink(com.intellij.ui.components.labels.ActionLink) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ActionLink (com.intellij.ui.components.labels.ActionLink)8 AnAction (com.intellij.openapi.actionSystem.AnAction)5 NotNull (org.jetbrains.annotations.NotNull)4 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)3 Ref (com.intellij.openapi.util.Ref)3 ComponentLookupException (org.fest.swing.exception.ComponentLookupException)3 Collection (java.util.Collection)2 GenericTypeMatcher (org.fest.swing.core.GenericTypeMatcher)2 Condition (org.fest.swing.timing.Condition)2 ExecutionException (com.intellij.execution.ExecutionException)1 Project (com.intellij.openapi.project.Project)1 Pair (com.intellij.openapi.util.Pair)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 DownloadableFileDescription (com.intellij.util.download.DownloadableFileDescription)1 DownloadableFileService (com.intellij.util.download.DownloadableFileService)1 FileDownloader (com.intellij.util.download.FileDownloader)1 List (java.util.List)1 EmptyBorder (javax.swing.border.EmptyBorder)1