Search in sources :

Example 11 with UiNotifyConnector

use of com.intellij.util.ui.update.UiNotifyConnector in project intellij-community by JetBrains.

the class ActionToolbarImpl method updateWhenFirstShown.

private static void updateWhenFirstShown(JComponent targetComponent, final ToolbarReference ref) {
    Activatable activatable = new Activatable.Adapter() {

        public void showNotify() {
            ActionToolbarImpl toolbar = ref.get();
            if (toolbar != null) {
                toolbar.myUpdater.updateActions(false, false);
            }
        }
    };
    ref.myDisposable = new UiNotifyConnector(targetComponent, activatable) {

        @Override
        protected void showNotify() {
            super.showNotify();
            ref.disposeReference();
        }
    };
}
Also used : Activatable(com.intellij.util.ui.update.Activatable) ComponentAdapter(java.awt.event.ComponentAdapter) UiNotifyConnector(com.intellij.util.ui.update.UiNotifyConnector)

Example 12 with UiNotifyConnector

use of com.intellij.util.ui.update.UiNotifyConnector in project intellij-community by JetBrains.

the class SelectLocationStep method createComponent.

protected JComponent createComponent() {
    final JPanel panel = new MyPanel();
    final JPanel toolbarPanel = new JPanel(new GridBagLayout());
    final GridBagConstraints constraints = new GridBagConstraints();
    constraints.gridx = 0;
    constraints.gridy = 0;
    toolbarPanel.add(myFileSystemToolBar.getComponent(), constraints);
    constraints.gridx = 1;
    constraints.weightx = 1.0;
    constraints.anchor = GridBagConstraints.EAST;
    toolbarPanel.add(myTextFieldAction, constraints);
    myNorthPanel.add(toolbarPanel, BorderLayout.NORTH);
    panel.add(myNorthPanel, BorderLayout.NORTH);
    panel.add(ScrollPaneFactory.createScrollPane(myFileSystemTree.getTree()), BorderLayout.CENTER);
    JLabel dndLabel = new JLabel(FileChooserDialogImpl.DRAG_N_DROP_HINT, SwingConstants.CENTER);
    dndLabel.setFont(JBUI.Fonts.miniFont());
    dndLabel.setForeground(UIUtil.getLabelDisabledForeground());
    panel.add(dndLabel, BorderLayout.SOUTH);
    myUiUpdater = new MergingUpdateQueue("FileChooserUpdater", 200, false, panel);
    Disposer.register(myFileSystemTree, myUiUpdater);
    new UiNotifyConnector(panel, myUiUpdater);
    updateTextFieldShowing();
    return panel;
}
Also used : MergingUpdateQueue(com.intellij.util.ui.update.MergingUpdateQueue) UiNotifyConnector(com.intellij.util.ui.update.UiNotifyConnector)

Example 13 with UiNotifyConnector

use of com.intellij.util.ui.update.UiNotifyConnector 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

UiNotifyConnector (com.intellij.util.ui.update.UiNotifyConnector)13 Activatable (com.intellij.util.ui.update.Activatable)11 EditorFragmentComponent (com.intellij.codeInsight.hint.EditorFragmentComponent)3 Disposable (com.intellij.openapi.Disposable)3 JBLayeredPane (com.intellij.ui.components.JBLayeredPane)3 DropTarget (java.awt.dnd.DropTarget)3 DropTargetAdapter (java.awt.dnd.DropTargetAdapter)3 DropTargetDragEvent (java.awt.dnd.DropTargetDragEvent)3 DropTargetDropEvent (java.awt.dnd.DropTargetDropEvent)3 MergingUpdateQueue (com.intellij.util.ui.update.MergingUpdateQueue)2 UiActivity (com.intellij.ide.UiActivity)1 BaseProjectTreeBuilder (com.intellij.ide.projectView.BaseProjectTreeBuilder)1 PresentationData (com.intellij.ide.projectView.PresentationData)1 PsiDirectoryNode (com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode)1 PresentableNodeDescriptor (com.intellij.ide.util.treeView.PresentableNodeDescriptor)1 ApplicationActivationListener (com.intellij.openapi.application.ApplicationActivationListener)1 TextAttributesKey (com.intellij.openapi.editor.colors.TextAttributesKey)1 DocumentAdapter (com.intellij.openapi.editor.event.DocumentAdapter)1 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)1 IdeFrame (com.intellij.openapi.wm.IdeFrame)1