use of com.intellij.util.ui.update.Activatable in project intellij-community by JetBrains.
the class DockablePopupManager method createToolWindow.
public void createToolWindow(final PsiElement element, PsiElement originalElement) {
assert myToolWindow == null;
final T component = createComponent();
final ToolWindowManagerEx toolWindowManagerEx = ToolWindowManagerEx.getInstanceEx(myProject);
final ToolWindow toolWindow = toolWindowManagerEx.getToolWindow(getToolwindowId());
myToolWindow = toolWindow == null ? toolWindowManagerEx.registerToolWindow(getToolwindowId(), true, ToolWindowAnchor.RIGHT, myProject) : toolWindow;
myToolWindow.setIcon(AllIcons.Toolwindows.Documentation);
myToolWindow.setAvailable(true, null);
myToolWindow.setToHideOnEmptyContent(false);
setToolwindowDefaultState();
((ToolWindowEx) myToolWindow).setTitleActions(createRestorePopupAction());
final ContentManager contentManager = myToolWindow.getContentManager();
final ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
final Content content = contentFactory.createContent(component, getTitle(element), false);
contentManager.addContent(content);
contentManager.addContentManagerListener(new ContentManagerAdapter() {
@Override
public void contentRemoved(ContentManagerEvent event) {
restorePopupBehavior();
}
});
new UiNotifyConnector(component, new Activatable() {
@Override
public void showNotify() {
restartAutoUpdate(myAutoUpdateDocumentation);
}
@Override
public void hideNotify() {
restartAutoUpdate(false);
}
});
myToolWindow.show(null);
PropertiesComponent.getInstance().setValue(getShowInToolWindowProperty(), Boolean.TRUE.toString());
restartAutoUpdate(PropertiesComponent.getInstance().getBoolean(getAutoUpdateEnabledProperty(), true));
doUpdateComponent(element, originalElement, component);
}
use of com.intellij.util.ui.update.Activatable in project intellij-community by JetBrains.
the class AbstractProjectViewPSIPane method createComponent.
@Override
public JComponent createComponent() {
if (myComponent != null)
return myComponent;
DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(null);
DefaultTreeModel treeModel = new DefaultTreeModel(rootNode);
myTree = createTree(treeModel);
enableDnD();
myComponent = ScrollPaneFactory.createScrollPane(myTree);
if (Registry.is("error.stripe.enabled")) {
ErrorStripePainter painter = new ErrorStripePainter(true);
Disposer.register(this, new TreeUpdater<ErrorStripePainter>(painter, myComponent, myTree) {
@Override
protected void update(ErrorStripePainter painter, int index, Object object) {
if (object instanceof DefaultMutableTreeNode) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) object;
object = node.getUserObject();
}
if (object instanceof PsiDirectoryNode && !myTree.isCollapsed(index)) {
object = null;
}
super.update(painter, index, object);
}
@Override
protected ErrorStripe getErrorStripe(Object object) {
if (object instanceof PresentableNodeDescriptor) {
PresentableNodeDescriptor node = (PresentableNodeDescriptor) object;
PresentationData presentation = node.getPresentation();
TextAttributesKey key = presentation.getTextAttributesKey();
if (key != null) {
TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(key);
if (attributes != null && EffectType.WAVE_UNDERSCORE == attributes.getEffectType()) {
return ErrorStripe.create(attributes.getEffectColor(), 1);
}
}
}
return null;
}
});
}
myTreeStructure = createStructure();
BaseProjectTreeBuilder treeBuilder = createBuilder(treeModel);
installComparator(treeBuilder);
setTreeBuilder(treeBuilder);
initTree();
Disposer.register(getTreeBuilder(), new UiNotifyConnector(myTree, new Activatable() {
private boolean showing;
@Override
public void showNotify() {
if (!showing) {
showing = true;
restoreExpandedPaths();
}
}
@Override
public void hideNotify() {
if (showing) {
showing = false;
saveExpandedPaths();
}
}
}));
return myComponent;
}
use of com.intellij.util.ui.update.Activatable in project intellij-community by JetBrains.
the class MouseDragHelper method start.
public void start() {
if (myGlassPane != null)
return;
new UiNotifyConnector(myDragComponent, new Activatable() {
@Override
public void showNotify() {
attach();
}
@Override
public void hideNotify() {
detach(true);
}
});
Disposer.register(myParentDisposable, new Disposable() {
@Override
public void dispose() {
stop();
}
});
}
use of com.intellij.util.ui.update.Activatable 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();
}
};
}
Aggregations