Search in sources :

Example 11 with LinkLabel

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

the class PushLog method createStrategyPanel.

private JComponent createStrategyPanel() {
    final JPanel labelPanel = new JPanel(new BorderLayout());
    labelPanel.setBackground(myTree.getBackground());
    final LinkLabel<String> linkLabel = new LinkLabel<>("Edit all targets", null);
    linkLabel.setBorder(new EmptyBorder(2, 2, 2, 2));
    linkLabel.setListener(new LinkListener<String>() {

        @Override
        public void linkSelected(LinkLabel aSource, String aLinkData) {
            if (linkLabel.isEnabled()) {
                startSyncEditing();
            }
        }
    }, null);
    myTree.addPropertyChangeListener(PushLogTreeUtil.EDIT_MODE_PROP, new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            Boolean editMode = (Boolean) evt.getNewValue();
            linkLabel.setEnabled(!editMode);
            linkLabel.setPaintUnderline(!editMode);
            linkLabel.repaint();
        }
    });
    labelPanel.add(linkLabel, BorderLayout.EAST);
    return labelPanel;
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) LinkLabel(com.intellij.ui.components.labels.LinkLabel) EmptyBorder(javax.swing.border.EmptyBorder)

Example 12 with LinkLabel

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

the class Banner method updateAction.

void updateAction(Action action) {
    final LinkLabel label = myActions.get(action);
    label.setVisible(action.isEnabled());
    label.setText((String) action.getValue(Action.NAME));
    label.setToolTipText((String) action.getValue(Action.SHORT_DESCRIPTION));
}
Also used : LinkLabel(com.intellij.ui.components.labels.LinkLabel)

Example 13 with LinkLabel

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

the class TodoCheckinHandler method getBeforeCheckinConfigurationPanel.

@Override
public RefreshableOnComponent getBeforeCheckinConfigurationPanel() {
    JCheckBox checkBox = new JCheckBox(VcsBundle.message("before.checkin.new.todo.check", ""));
    return new RefreshableOnComponent() {

        @Override
        public JComponent getComponent() {
            JPanel panel = new JPanel(new BorderLayout(4, 0));
            panel.add(checkBox, BorderLayout.WEST);
            setFilterText(myConfiguration.myTodoPanelSettings.todoFilterName);
            if (myConfiguration.myTodoPanelSettings.todoFilterName != null) {
                myTodoFilter = TodoConfiguration.getInstance().getTodoFilter(myConfiguration.myTodoPanelSettings.todoFilterName);
            }
            Consumer<TodoFilter> consumer = todoFilter -> {
                myTodoFilter = todoFilter;
                String name = todoFilter == null ? null : todoFilter.getName();
                myConfiguration.myTodoPanelSettings.todoFilterName = name;
                setFilterText(name);
            };
            LinkLabel linkLabel = new LinkLabel("Configure", null);
            linkLabel.setListener(new LinkListener() {

                @Override
                public void linkSelected(LinkLabel aSource, Object aLinkData) {
                    DefaultActionGroup group = SetTodoFilterAction.createPopupActionGroup(myProject, myConfiguration.myTodoPanelSettings, consumer);
                    ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu(ActionPlaces.TODO_VIEW_TOOLBAR, group);
                    popupMenu.getComponent().show(linkLabel, 0, linkLabel.getHeight());
                }
            }, null);
            panel.add(linkLabel, BorderLayout.CENTER);
            CheckinHandlerUtil.disableWhenDumb(myProject, checkBox, "TODO check is impossible until indices are up-to-date");
            return panel;
        }

        private void setFilterText(String filterName) {
            if (filterName == null) {
                checkBox.setText(VcsBundle.message("before.checkin.new.todo.check", IdeBundle.message("action.todo.show.all")));
            } else {
                checkBox.setText(VcsBundle.message("before.checkin.new.todo.check", "Filter: " + filterName));
            }
        }

        @Override
        public void refresh() {
        }

        @Override
        public void saveState() {
            myConfiguration.CHECK_NEW_TODO = checkBox.isSelected();
        }

        @Override
        public void restoreState() {
            checkBox.setSelected(myConfiguration.CHECK_NEW_TODO);
        }
    };
}
Also used : ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager) DateFormatUtil(com.intellij.util.text.DateFormatUtil) LinkListener(com.intellij.ui.components.labels.LinkListener) Change(com.intellij.openapi.vcs.changes.Change) UIUtil.getWarningIcon(com.intellij.util.ui.UIUtil.getWarningIcon) ModalityState(com.intellij.openapi.application.ModalityState) PairConsumer(com.intellij.util.PairConsumer) com.intellij.ide.todo(com.intellij.ide.todo) ActionManager(com.intellij.openapi.actionSystem.ActionManager) VcsConfiguration(com.intellij.openapi.vcs.VcsConfiguration) Task(com.intellij.openapi.progress.Task) ActionPopupMenu(com.intellij.openapi.actionSystem.ActionPopupMenu) ApplicationNamesInfo(com.intellij.openapi.application.ApplicationNamesInfo) Project(com.intellij.openapi.project.Project) LinkLabel(com.intellij.ui.components.labels.LinkLabel) Messages(com.intellij.openapi.ui.Messages) CommitExecutor(com.intellij.openapi.vcs.changes.CommitExecutor) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) ProgressManager(com.intellij.openapi.progress.ProgressManager) DumbService(com.intellij.openapi.project.DumbService) CheckinProjectPanel(com.intellij.openapi.vcs.CheckinProjectPanel) ToolWindow(com.intellij.openapi.wm.ToolWindow) StringUtil(com.intellij.openapi.util.text.StringUtil) Collection(java.util.Collection) Content(com.intellij.ui.content.Content) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) RefreshableOnComponent(com.intellij.openapi.vcs.ui.RefreshableOnComponent) VcsBundle(com.intellij.openapi.vcs.VcsBundle) java.awt(java.awt) IdeBundle(com.intellij.ide.IdeBundle) Nullable(org.jetbrains.annotations.Nullable) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) ServiceManager(com.intellij.openapi.components.ServiceManager) ActionPlaces(com.intellij.openapi.actionSystem.ActionPlaces) ApplicationManager(com.intellij.openapi.application.ApplicationManager) ContentManager(com.intellij.ui.content.ContentManager) NotNull(org.jetbrains.annotations.NotNull) Ref(com.intellij.openapi.util.Ref) Consumer(com.intellij.util.Consumer) javax.swing(javax.swing) CommonBundle.getCancelButtonText(com.intellij.CommonBundle.getCancelButtonText) LinkListener(com.intellij.ui.components.labels.LinkListener) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) LinkLabel(com.intellij.ui.components.labels.LinkLabel) ActionPopupMenu(com.intellij.openapi.actionSystem.ActionPopupMenu) RefreshableOnComponent(com.intellij.openapi.vcs.ui.RefreshableOnComponent)

Example 14 with LinkLabel

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

the class FileChooserDialogImpl method createCenterPanel.

protected JComponent createCenterPanel() {
    JPanel panel = new MyPanel();
    myUiUpdater = new MergingUpdateQueue("FileChooserUpdater", 200, false, panel);
    Disposer.register(myDisposable, myUiUpdater);
    new UiNotifyConnector(panel, myUiUpdater);
    panel.setBorder(JBUI.Borders.empty());
    createTree();
    final DefaultActionGroup group = createActionGroup();
    ActionToolbar toolBar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true);
    toolBar.setTargetComponent(panel);
    final JPanel toolbarPanel = new JPanel(new BorderLayout());
    toolbarPanel.add(toolBar.getComponent(), BorderLayout.CENTER);
    myTextFieldAction = new TextFieldAction() {

        public void linkSelected(final LinkLabel aSource, final Object aLinkData) {
            toggleShowTextField();
        }
    };
    toolbarPanel.add(myTextFieldAction, BorderLayout.EAST);
    JPanel extraToolbarPanel = createExtraToolbarPanel();
    if (extraToolbarPanel != null) {
        toolbarPanel.add(extraToolbarPanel, BorderLayout.SOUTH);
    }
    myPathTextFieldWrapper = new JPanel(new BorderLayout());
    myPathTextFieldWrapper.setBorder(JBUI.Borders.emptyBottom(2));
    myPathTextField = new FileTextFieldImpl.Vfs(FileChooserFactoryImpl.getMacroMap(), getDisposable(), new LocalFsFinder.FileChooserFilter(myChooserDescriptor, myFileSystemTree)) {

        protected void onTextChanged(final String newValue) {
            myUiUpdater.cancelAllUpdates();
            updateTreeFromPath(newValue);
        }
    };
    Disposer.register(myDisposable, myPathTextField);
    myPathTextFieldWrapper.add(myPathTextField.getField(), BorderLayout.CENTER);
    if (getRecentFiles().length > 0) {
        myPathTextFieldWrapper.add(createHistoryButton(), BorderLayout.EAST);
    }
    myNorthPanel = new JPanel(new BorderLayout());
    myNorthPanel.add(toolbarPanel, BorderLayout.NORTH);
    updateTextFieldShowing();
    panel.add(myNorthPanel, BorderLayout.NORTH);
    registerMouseListener(group);
    JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myFileSystemTree.getTree());
    //scrollPane.setBorder(BorderFactory.createLineBorder(new Color(148, 154, 156)));
    panel.add(scrollPane, BorderLayout.CENTER);
    panel.setPreferredSize(JBUI.size(400));
    JLabel dndLabel = new JLabel(DRAG_N_DROP_HINT, SwingConstants.CENTER);
    dndLabel.setFont(JBUI.Fonts.miniFont());
    dndLabel.setForeground(UIUtil.getLabelDisabledForeground());
    panel.add(dndLabel, BorderLayout.SOUTH);
    ApplicationManager.getApplication().getMessageBus().connect(getDisposable()).subscribe(ApplicationActivationListener.TOPIC, new ApplicationActivationListener.Adapter() {

        @Override
        public void applicationActivated(IdeFrame ideFrame) {
            ((SaveAndSyncHandlerImpl) SaveAndSyncHandler.getInstance()).maybeRefresh(ModalityState.current());
        }
    });
    return panel;
}
Also used : MergingUpdateQueue(com.intellij.util.ui.update.MergingUpdateQueue) UiNotifyConnector(com.intellij.util.ui.update.UiNotifyConnector) IdeFrame(com.intellij.openapi.wm.IdeFrame) LinkLabel(com.intellij.ui.components.labels.LinkLabel) ApplicationActivationListener(com.intellij.openapi.application.ApplicationActivationListener)

Aggregations

LinkLabel (com.intellij.ui.components.labels.LinkLabel)14 LinkListener (com.intellij.ui.components.labels.LinkListener)6 EmptyBorder (javax.swing.border.EmptyBorder)4 NonOpaquePanel (com.intellij.ui.components.panels.NonOpaquePanel)3 NotNull (org.jetbrains.annotations.NotNull)2 CommonBundle.getCancelButtonText (com.intellij.CommonBundle.getCancelButtonText)1 IdeBundle (com.intellij.ide.IdeBundle)1 IdeaPluginDescriptor (com.intellij.ide.plugins.IdeaPluginDescriptor)1 com.intellij.ide.todo (com.intellij.ide.todo)1 ActionManager (com.intellij.openapi.actionSystem.ActionManager)1 ActionPlaces (com.intellij.openapi.actionSystem.ActionPlaces)1 ActionPopupMenu (com.intellij.openapi.actionSystem.ActionPopupMenu)1 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)1 ApplicationActivationListener (com.intellij.openapi.application.ApplicationActivationListener)1 ApplicationManager (com.intellij.openapi.application.ApplicationManager)1 ApplicationNamesInfo (com.intellij.openapi.application.ApplicationNamesInfo)1 ModalityState (com.intellij.openapi.application.ModalityState)1 ServiceManager (com.intellij.openapi.components.ServiceManager)1 DocumentAdapter (com.intellij.openapi.editor.event.DocumentAdapter)1 DocumentEvent (com.intellij.openapi.editor.event.DocumentEvent)1