Search in sources :

Example 11 with HyperlinkLabel

use of com.intellij.ui.HyperlinkLabel in project android by JetBrains.

the class NlPropertiesPanel method createViewAllPropertiesLinkPanel.

@NotNull
private JComponent createViewAllPropertiesLinkPanel(boolean viewAllProperties) {
    HyperlinkLabel textLink = new HyperlinkLabel();
    textLink.setHyperlinkText(viewAllProperties ? ViewAllPropertiesAction.VIEW_ALL_PROPERTIES : ViewAllPropertiesAction.VIEW_FEWER_PROPERTIES);
    textLink.addHyperlinkListener(event -> setAllPropertiesPanelVisible(event, viewAllProperties));
    HyperlinkLabel iconLink = new HyperlinkLabel();
    iconLink.setIcon(AndroidIcons.NeleIcons.ToggleProperties);
    iconLink.setFocusable(false);
    iconLink.setUseIconAsLink(true);
    iconLink.addHyperlinkListener(event -> setAllPropertiesPanelVisible(event, viewAllProperties));
    JPanel linkPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    linkPanel.setOpaque(false);
    linkPanel.add(textLink);
    linkPanel.add(iconLink);
    return linkPanel;
}
Also used : HyperlinkLabel(com.intellij.ui.HyperlinkLabel) NotNull(org.jetbrains.annotations.NotNull)

Example 12 with HyperlinkLabel

use of com.intellij.ui.HyperlinkLabel in project android by JetBrains.

the class ConnectionDetailsView method update.

/**
   * Updates the view to show given data. If given {@code httpData} is not null, show the details and set the view to be visible;
   * otherwise, clears the view and set view to be invisible.
   */
public void update(@Nullable HttpData httpData) {
    setBackground(JBColor.background());
    myEditorPanel.removeAll();
    myFieldsPanel.removeAll();
    myCallstackView.setText("");
    if (httpData != null) {
        VirtualFile payloadVirtualFile = httpData.getResponsePayloadFile() != null ? LocalFileSystem.getInstance().findFileByIoFile(httpData.getResponsePayloadFile()) : null;
        if (payloadVirtualFile != null) {
            // TODO: Find proper project to refactor this.
            Project project = ProjectManager.getInstance().getDefaultProject();
            // TODO: Investigate when the editor provider is null.
            FileEditorProvider[] editorProviders = FileEditorProviderManager.getInstance().getProviders(project, payloadVirtualFile);
            FileEditor editor = editorProviders.length > 0 ? editorProviders[0].createEditor(project, payloadVirtualFile) : null;
            if (editor != null) {
                myEditorPanel.add(editor.getComponent(), BorderLayout.CENTER);
            }
        }
        int row = 0;
        myFieldsPanel.add(new NoWrapBoldLabel("Request"), new TabularLayout.Constraint(row, 0));
        myFieldsPanel.add(new JLabel(HttpData.getUrlName(httpData.getUrl())), new TabularLayout.Constraint(row, 2));
        String contentType = httpData.getResponseField(HttpData.FIELD_CONTENT_TYPE);
        if (contentType != null) {
            row++;
            myFieldsPanel.add(new NoWrapBoldLabel("Content type"), new TabularLayout.Constraint(row, 0));
            // Content type looks like "type/subtype;" or "type/subtype; parameters".
            // Always convert to "type"
            contentType = contentType.split(";")[0];
            myFieldsPanel.add(new JLabel(contentType), new TabularLayout.Constraint(row, 2));
        }
        HyperlinkLabel urlLabel = new HyperlinkLabel(httpData.getUrl());
        urlLabel.setHyperlinkTarget(httpData.getUrl());
        row++;
        myFieldsPanel.add(new NoWrapBoldLabel("URL"), new TabularLayout.Constraint(row, 0));
        myFieldsPanel.add(urlLabel, new TabularLayout.Constraint(row, 2));
        String contentLength = httpData.getResponseField(HttpData.FIELD_CONTENT_LENGTH);
        if (contentLength != null) {
            contentLength = contentLength.split(";")[0];
            row++;
            myFieldsPanel.add(new NoWrapBoldLabel("Content length"), new TabularLayout.Constraint(row, 0));
            myFieldsPanel.add(new JLabel(contentLength), new TabularLayout.Constraint(row, 2));
        }
        // TODO: We are showing the callstack but we can't currently click on any of the links to
        // navigate to the code.
        myCallstackView.setText(httpData.getTrace());
        repaint();
    }
    setVisible(httpData != null);
    revalidate();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) FileEditor(com.intellij.openapi.fileEditor.FileEditor) FileEditorProvider(com.intellij.openapi.fileEditor.FileEditorProvider) TabularLayout(com.android.tools.adtui.TabularLayout) HyperlinkLabel(com.intellij.ui.HyperlinkLabel)

Example 13 with HyperlinkLabel

use of com.intellij.ui.HyperlinkLabel 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 14 with HyperlinkLabel

use of com.intellij.ui.HyperlinkLabel in project scss-lint-plugin by idok.

the class ScssLintInspection method createOptionsPanel.

public JComponent createOptionsPanel() {
    JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    HyperlinkLabel settingsLink = createHyperLink();
    panel.setBorder(IdeBorderFactory.createTitledBorder(getDisplayName() + " options"));
    panel.add(settingsLink);
    return panel;
}
Also used : HyperlinkLabel(com.intellij.ui.HyperlinkLabel)

Example 15 with HyperlinkLabel

use of com.intellij.ui.HyperlinkLabel in project intellij-community by JetBrains.

the class IntentionDescriptionPanel method setupPoweredByPanel.

private void setupPoweredByPanel(final IntentionActionMetaData actionMetaData) {
    PluginId pluginId = actionMetaData == null ? null : actionMetaData.getPluginId();
    JComponent owner;
    if (pluginId == null) {
        @NonNls String label = XmlStringUtil.wrapInHtml("<b>" + ApplicationNamesInfo.getInstance().getFullProductName() + "</b>");
        owner = new JLabel(label);
    } else {
        final IdeaPluginDescriptor pluginDescriptor = PluginManager.getPlugin(pluginId);
        HyperlinkLabel label = new HyperlinkLabel(CodeInsightBundle.message("powered.by.plugin", pluginDescriptor.getName()));
        label.addHyperlinkListener(new HyperlinkListener() {

            @Override
            public void hyperlinkUpdate(HyperlinkEvent e) {
                final ShowSettingsUtil util = ShowSettingsUtil.getInstance();
                final PluginManagerConfigurable pluginConfigurable = new PluginManagerConfigurable(PluginManagerUISettings.getInstance());
                final Project project = ProjectManager.getInstance().getDefaultProject();
                util.editConfigurable(project, pluginConfigurable, () -> pluginConfigurable.select(pluginDescriptor));
            }
        });
        owner = label;
    }
    //myPoweredByContainer.setVisible(true);
    myPoweredByPanel.removeAll();
    myPoweredByPanel.add(owner, BorderLayout.CENTER);
}
Also used : NonNls(org.jetbrains.annotations.NonNls) HyperlinkEvent(javax.swing.event.HyperlinkEvent) ShowSettingsUtil(com.intellij.openapi.options.ShowSettingsUtil) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) PluginId(com.intellij.openapi.extensions.PluginId) PluginManagerConfigurable(com.intellij.ide.plugins.PluginManagerConfigurable) Project(com.intellij.openapi.project.Project) HyperlinkListener(javax.swing.event.HyperlinkListener) HyperlinkLabel(com.intellij.ui.HyperlinkLabel)

Aggregations

HyperlinkLabel (com.intellij.ui.HyperlinkLabel)25 HyperlinkEvent (javax.swing.event.HyperlinkEvent)9 NotNull (org.jetbrains.annotations.NotNull)7 HyperlinkAdapter (com.intellij.ui.HyperlinkAdapter)5 HyperlinkListener (javax.swing.event.HyperlinkListener)4 Project (com.intellij.openapi.project.Project)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 DataContext (com.intellij.openapi.actionSystem.DataContext)2 FileChooser.chooseFile (com.intellij.openapi.fileChooser.FileChooser.chooseFile)2 VfsUtil.findFileByIoFile (com.intellij.openapi.vfs.VfsUtil.findFileByIoFile)2 VfsUtilCore.virtualToIoFile (com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)2 File (java.io.File)2 IOException (java.io.IOException)2 ScreenOrientation (com.android.resources.ScreenOrientation)1 SystemImage (com.android.sdklib.repository.targets.SystemImage)1 LabelWithEditLink (com.android.tools.adtui.LabelWithEditLink)1 TabularLayout (com.android.tools.adtui.TabularLayout)1 ModelWizardDialog (com.android.tools.idea.wizard.model.ModelWizardDialog)1 Function (com.google.common.base.Function)1 ImmutableList (com.google.common.collect.ImmutableList)1