use obsolete TW title property as Stripe button text

This commit is contained in:
Gregory.Shrago
2014-03-24 23:30:20 +04:00
parent 9c56b6279c
commit 654463b436
7 changed files with 46 additions and 121 deletions
@@ -568,7 +568,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
if (toolWindow != null) {
myContentManager = toolWindow.getContentManager();
if (!ApplicationManager.getApplication().isUnitTestMode()) {
toolWindow.setContentUiType(ToolWindowContentUiType.getInstance("combo"), null);
toolWindow.setContentUiType(ToolWindowContentUiType.COMBO, null);
((ToolWindowEx)toolWindow).setAdditionalGearActions(myActionGroup);
toolWindow.getComponent().putClientProperty(ToolWindowContentUi.HIDE_ID_LABEL, "true");
}
@@ -37,11 +37,20 @@ public class ToolWindowContentUiType {
public static ToolWindowContentUiType getInstance(String name) {
if (TABBED.getName().equals(name)) {
return TABBED;
} else if (COMBO.getName().equals(name)) {
}
else if (COMBO.getName().equals(name)) {
return COMBO;
} else {
}
else {
LOG.debug("Unknown content type=" + name);
return TABBED;
}
}
@Override
public String toString() {
return "ToolWindowContentUiType{" +
"myName='" + myName + '\'' +
'}';
}
}
@@ -29,12 +29,12 @@ import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.wm.*;
import com.intellij.openapi.wm.ex.ToolWindowEx;
import com.intellij.ui.Gray;
import com.intellij.ui.JBColor;
import com.intellij.ui.UIBundle;
import com.intellij.ui.components.panels.NonOpaquePanel;
import com.intellij.ui.content.Content;
import com.intellij.util.EventDispatcher;
import com.intellij.util.Producer;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NonNls;
@@ -44,11 +44,8 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import javax.swing.event.EventListenerList;
import java.awt.*;
import java.awt.event.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Map;
/**
@@ -63,7 +60,7 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
private WindowInfoImpl myInfo;
private final ToolWindowImpl myToolWindow;
private final MyDivider myDivider;
private final EventListenerList myListenerList;
private final EventDispatcher<InternalDecoratorListener> myDispatcher = EventDispatcher.create(InternalDecoratorListener.class);
/*
* Actions
*/
@@ -77,7 +74,6 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
/**
* Catches all event from tool window and modifies decorator's appearance.
*/
private final ToolWindowHandler myToolWindowHandler;
private final MyKeymapManagerListener myWeakKeymapManagerListener;
@NonNls private static final String HIDE_ACTIVE_WINDOW_ACTION_ID = "HideActiveWindow";
@NonNls public static final String TOGGLE_PINNED_MODE_ACTION_ID = "TogglePinnedMode";
@@ -101,8 +97,6 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
myToggleAutoHideModeAction = new TogglePinnedModeAction();
myToggleContentUiTypeAction = new ToggleContentUiTypeAction();
myListenerList = new EventListenerList();
myHeader = new ToolWindowHeader(toolWindow, info, new Producer<ActionGroup>() {
@Override
public ActionGroup produce() {
@@ -137,9 +131,6 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
init();
myToolWindowHandler = new ToolWindowHandler();
myToolWindow.addPropertyChangeListener(myToolWindowHandler);
apply(info);
}
@@ -187,8 +178,6 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
validate();
repaint();
//
updateTitle();
// Push "apply" request forward
@@ -210,17 +199,16 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
}
}
final void addInternalDecoratorListener(final InternalDecoratorListener l) {
myListenerList.add(InternalDecoratorListener.class, l);
final void addInternalDecoratorListener(InternalDecoratorListener l) {
myDispatcher.addListener(l);
}
final void removeInternalDecoratorListener(final InternalDecoratorListener l) {
myListenerList.remove(InternalDecoratorListener.class, l);
final void removeInternalDecoratorListener(InternalDecoratorListener l) {
myDispatcher.removeListener(l);
}
final void dispose() {
removeAll();
myToolWindow.removePropertyChangeListener(myToolWindowHandler);
KeymapManagerEx.getInstanceEx().removeWeakListener(myWeakKeymapManagerListener);
Disposer.dispose(myHeader);
@@ -228,76 +216,49 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
myProject = null;
}
private void fireAnchorChanged(final ToolWindowAnchor anchor) {
final InternalDecoratorListener[] listeners = myListenerList.getListeners(InternalDecoratorListener.class);
for (InternalDecoratorListener listener : listeners) {
listener.anchorChanged(this, anchor);
}
private void fireAnchorChanged(ToolWindowAnchor anchor) {
myDispatcher.getMulticaster().anchorChanged(this, anchor);
}
private void fireAutoHideChanged(final boolean autoHide) {
final InternalDecoratorListener[] listeners = myListenerList.getListeners(InternalDecoratorListener.class);
for (InternalDecoratorListener listener : listeners) {
listener.autoHideChanged(this, autoHide);
}
private void fireAutoHideChanged(boolean autoHide) {
myDispatcher.getMulticaster().autoHideChanged(this, autoHide);
}
/**
* Fires event that "hide" button has been pressed.
*/
final void fireHidden() {
final InternalDecoratorListener[] listeners = myListenerList.getListeners(InternalDecoratorListener.class);
for (InternalDecoratorListener listener : listeners) {
listener.hidden(this);
}
myDispatcher.getMulticaster().hidden(this);
}
/**
* Fires event that "hide" button has been pressed.
*/
final void fireHiddenSide() {
final InternalDecoratorListener[] listeners = myListenerList.getListeners(InternalDecoratorListener.class);
for (InternalDecoratorListener listener : listeners) {
listener.hiddenSide(this);
}
myDispatcher.getMulticaster().hiddenSide(this);
}
/**
* Fires event that user performed click into the title bar area.
*/
final void fireActivated() {
final InternalDecoratorListener[] listeners = myListenerList.getListeners(InternalDecoratorListener.class);
for (InternalDecoratorListener listener : listeners) {
listener.activated(this);
}
myDispatcher.getMulticaster().activated(this);
}
private void fireTypeChanged(final ToolWindowType type) {
final InternalDecoratorListener[] listeners = myListenerList.getListeners(InternalDecoratorListener.class);
for (InternalDecoratorListener listener : listeners) {
listener.typeChanged(this, type);
}
private void fireTypeChanged(ToolWindowType type) {
myDispatcher.getMulticaster().typeChanged(this, type);
}
final void fireResized() {
final InternalDecoratorListener[] listeners = myListenerList.getListeners(InternalDecoratorListener.class);
for (InternalDecoratorListener listener : listeners) {
listener.resized(this);
}
myDispatcher.getMulticaster().resized(this);
}
private void fireSideStatusChanged(boolean isSide) {
final InternalDecoratorListener[] listeners = myListenerList.getListeners(InternalDecoratorListener.class);
for (InternalDecoratorListener listener : listeners) {
listener.sideStatusChanged(this, isSide);
}
myDispatcher.getMulticaster().sideStatusChanged(this, isSide);
}
private void fireContentUiTypeChanges(ToolWindowContentUiType type) {
final InternalDecoratorListener[] listeners = myListenerList.getListeners(InternalDecoratorListener.class);
for (InternalDecoratorListener listener : listeners) {
listener.contentUiTypeChanges(this, type);
}
myDispatcher.getMulticaster().contentUiTypeChanges(this, type);
}
private void init() {
@@ -515,30 +476,6 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
}
}
// TODO: to b removed
private void updateTitle() {
final StringBuffer fullTitle = new StringBuffer();
// Due to JDK's bug #4234645 we cannot support custom decoration on Linux platform.
// The prblem is that Window.setLocation() doesn't work properly wjen the dialod is displayable.
// Therefore we use native WM decoration. When the dialog has native decoration we show window ID
// in the dialog's title and window title at the custom title panel. If the custom decoration
// is used we show composite string at the custom title panel.
// TODO[vova] investigate the problem under Mac OSX.
if (SystemInfo.isWindows || !myInfo.isFloating()) {
fullTitle.append(myInfo.getId());
final String title = myToolWindow.getTitle();
if (title != null && title.length() > 0) {
fullTitle.append(" - ").append(title);
}
}
else { // Unixes ans MacOSX go here when tool window is in floating mode
final String title = myToolWindow.getTitle();
if (title != null && title.length() > 0) {
fullTitle.append(title);
}
}
}
private final class ChangeAnchorAction extends AnAction implements DumbAware {
private final ToolWindowAnchor myAnchor;
@@ -816,22 +753,6 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
}
}
/**
* Synchronizes decorator with IdeToolWindow changes.
*/
private final class ToolWindowHandler implements PropertyChangeListener {
@Override
public final void propertyChange(final PropertyChangeEvent e) {
final String name = e.getPropertyName();
if (ToolWindowEx.PROP_TITLE.equals(name)) {
updateTitle();
if (myHeader != null) {
myHeader.repaint();
}
}
}
}
@Override
public void putInfo(@NotNull Map<String, String> info) {
info.put("toolWindowTitle", myToolWindow.getTitle());
@@ -323,7 +323,7 @@ public final class StripeButton extends AnchoredButton implements ActionListener
* and short cut registered in the key map.
*/
void updateText() {
final String toolWindowId = getWindowInfo().getId();
String toolWindowId = myDecorator.getToolWindow().getTitle();
String text = toolWindowId;
if (UISettings.getInstance().SHOW_TOOL_WINDOW_NUMBERS) {
final int mnemonic = ActivateToolWindowAction.getMnemonicForToolWindow(toolWindowId);
@@ -36,6 +36,7 @@ import com.intellij.ui.content.Content;
import com.intellij.ui.content.ContentFactory;
import com.intellij.ui.content.ContentManager;
import com.intellij.ui.content.impl.ContentImpl;
import com.intellij.util.ObjectUtils;
import com.intellij.util.ui.update.Activatable;
import com.intellij.util.ui.update.UiNotifyConnector;
import org.jetbrains.annotations.NotNull;
@@ -59,7 +60,8 @@ public final class ToolWindowImpl implements ToolWindowEx {
private final JComponent myComponent;
private boolean myAvailable;
private final ContentManager myContentManager;
private Icon myIcon = null;
private Icon myIcon;
private String myTitle;
private static final Content EMPTY_CONTENT = new ContentImpl(new JLabel(), "", false);
private final ToolWindowContentUi myContentUI;
@@ -342,7 +344,7 @@ public final class ToolWindowImpl implements ToolWindowEx {
public final String getTitle() {
ApplicationManager.getApplication().assertIsDispatchThread();
return getSelectedContent().getDisplayName();
return ObjectUtils.notNull(myTitle, myId);
}
public final void setIcon(final Icon icon) {
@@ -356,10 +358,10 @@ public final class ToolWindowImpl implements ToolWindowEx {
myChangeSupport.firePropertyChange(PROP_ICON, oldIcon, icon);
}
public final void setTitle(final String title) {
public final void setTitle(String title) {
ApplicationManager.getApplication().assertIsDispatchThread();
final String oldTitle = getTitle();
getSelectedContent().setDisplayName(title);
myTitle = title;
myChangeSupport.firePropertyChange(PROP_TITLE, oldTitle, title);
}
@@ -57,6 +57,7 @@ import com.intellij.ui.switcher.QuickAccessSettings;
import com.intellij.ui.switcher.SwitchManager;
import com.intellij.util.Alarm;
import com.intellij.util.ArrayUtil;
import com.intellij.util.EventDispatcher;
import com.intellij.util.IJSwingUtilities;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.HashMap;
@@ -69,7 +70,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.event.EventListenerList;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import java.awt.*;
@@ -89,7 +89,7 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
private final Project myProject;
private final WindowManagerEx myWindowManager;
private final EventListenerList myListenerList;
private final EventDispatcher<ToolWindowManagerListener> myDispatcher = EventDispatcher.create(ToolWindowManagerListener.class);
private final DesktopLayout myLayout;
private final Map<String, InternalDecorator> myId2InternalDecorator;
private final Map<String, FloatingDecorator> myId2FloatingDecorator;
@@ -163,7 +163,6 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
myWindowManager = windowManagerEx;
myFileEditorManager = fem;
myLafManager = lafManager;
myListenerList = new EventListenerList();
if (!project.isDefault()) {
actionManager.addAnActionListener(new AnActionListener() {
@@ -570,13 +569,13 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
}
@Override
public void addToolWindowManagerListener(@NotNull final ToolWindowManagerListener l) {
myListenerList.add(ToolWindowManagerListener.class, l);
public void addToolWindowManagerListener(@NotNull ToolWindowManagerListener l) {
myDispatcher.addListener(l);
}
@Override
public void removeToolWindowManagerListener(@NotNull final ToolWindowManagerListener l) {
myListenerList.remove(ToolWindowManagerListener.class, l);
public void removeToolWindowManagerListener(@NotNull ToolWindowManagerListener l) {
myDispatcher.addListener(l);
}
/**
@@ -1662,17 +1661,11 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
}
private void fireToolWindowRegistered(final String id) {
final ToolWindowManagerListener[] listeners = myListenerList.getListeners(ToolWindowManagerListener.class);
for (ToolWindowManagerListener listener : listeners) {
listener.toolWindowRegistered(id);
}
myDispatcher.getMulticaster().toolWindowRegistered(id);
}
private void fireStateChanged() {
final ToolWindowManagerListener[] listeners = myListenerList.getListeners(ToolWindowManagerListener.class);
for (ToolWindowManagerListener listener : listeners) {
listener.stateChanged();
}
myDispatcher.getMulticaster().stateChanged();
}
boolean isToolWindowActive(final String id) {
@@ -71,7 +71,7 @@ abstract class ContentLayout {
public abstract boolean shouldDrawDecorations();
protected void updateIdLabel(BaseLabel label) {
label.setText(myUi.myWindow.getId() + (shouldDrawDecorations() ? ":" : ""));
label.setText(myUi.myWindow.getTitle() + (shouldDrawDecorations() ? ":" : ""));
label.setBorder(new EmptyBorder(0, 2, 0, 8));
if (myUi.myManager.getContentCount() == 1) {