I fail to change the text and tooltip of action like maximize and minimize
so i set it up in my own minimize/maximum etc… (as you do for the CMinimizeAction but i change the setText and setToolTip parameters)
but now i got a problem about that, here some source code to understand what happens :
import java.awt.BorderLayout;
import java.awt.Color;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import bibliothek.gui.Dockable;
import bibliothek.gui.dock.FlapDockStation;
import bibliothek.gui.dock.action.DefaultActionOffer;
import bibliothek.gui.dock.action.DockAction;
import bibliothek.gui.dock.action.DockActionSource;
import bibliothek.gui.dock.action.FilteredDockActionSource;
import bibliothek.gui.dock.common.CControl;
import bibliothek.gui.dock.common.CLocation;
import bibliothek.gui.dock.common.ColorMap;
import bibliothek.gui.dock.common.DefaultSingleCDockable;
import bibliothek.gui.dock.common.SingleCDockable;
import bibliothek.gui.dock.common.intern.CDockable;
import bibliothek.gui.dock.common.intern.DefaultCDockable;
import bibliothek.gui.dock.common.intern.action.CExtendedModeAction;
import bibliothek.gui.dock.common.mode.CLocationModeManager;
import bibliothek.gui.dock.common.mode.ExtendedMode;
import bibliothek.gui.dock.common.theme.ThemeMap;
import bibliothek.gui.dock.station.flap.ButtonPane;
import bibliothek.gui.dock.station.flap.DefaultFlapWindowFactory;
import bibliothek.gui.dock.station.flap.FlapDockHoldToggle;
import bibliothek.gui.dock.station.flap.FlapWindow;
public class LostButton extends JFrame
{
private SingleCDockable dock1;
private SingleCDockable dock2;
public static void main(String[] args)
{
new LostButton();
}
public LostButton()
{
super();
this.enableInputMethods(true);
ColorMap cm;
CControl control = new CControl(this);
control.getController().addActionOffer(new HoldToggleFilter());
control.putProperty(FlapDockStation.WINDOW_FACTORY,
new DefaultFlapWindowFactory()
{
@Override
public FlapWindow create(FlapDockStation station,
ButtonPane buttonPane)
{
return null;
}
});
ThemeMap theme = control.getThemes();
theme.select(ThemeMap.KEY_BUBBLE_THEME);
this.setLayout(new BorderLayout());
this.add(control.getContentArea());
dock1 = create(new JPanel(), "Dock 1", Color.white);
cm = dock1.getColors();
cm.setColor(ColorMap.COLOR_KEY_TITLE_FOREGROUND, Color.white);
cm.setColor(ColorMap.COLOR_KEY_TITLE_BACKGROUND, Color.black);
dock2 = create(new JPanel(), "Dock 2", Color.white);
cm = dock2.getColors();
cm.setColor(ColorMap.COLOR_KEY_TITLE_FOREGROUND, Color.white);
cm.setColor(ColorMap.COLOR_KEY_TITLE_BACKGROUND, Color.black);
MinimizeSouthAction minimize = new MinimizeSouthAction(control);
MaximizeAction maximize = new MaximizeAction(control);
NormalizeAction normalize = new NormalizeAction(control);
((DefaultSingleCDockable) dock1).putAction(
CDockable.ACTION_KEY_MINIMIZE, minimize);
((DefaultSingleCDockable) dock1).putAction(
CDockable.ACTION_KEY_NORMALIZE, normalize);
((DefaultSingleCDockable) dock2).putAction(
CDockable.ACTION_KEY_MAXIMIZE, maximize);
((DefaultSingleCDockable) dock2).putAction(
CDockable.ACTION_KEY_NORMALIZE, normalize);
control.addDockable(dock1);
control.addDockable(dock2);
dock1.setVisible(true);
dock2.setVisible(true);
removeDockAction(dock1, true, false, false, true, true, false);
removeDockAction(dock2, true, false, true, false, true, false);
this.setResizable(true);
this.setSize(500, 500);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setVisible(true);
}
public static SingleCDockable create(JComponent panel, String title,
Color color)
{
JComponent background = panel;
background.setOpaque(true);
background.setBackground(color);
return new DefaultSingleCDockable(title, title, background);
}
private void removeDockAction(SingleCDockable dock, boolean resizable,
boolean externalizable, boolean maximalizable, boolean minimizable,
boolean showTitle, boolean stackable)
{
DefaultCDockable dockParam = ((DefaultCDockable) dock);
dockParam.setResizeLocked(resizable);
dockParam.setResizeLockedHorizontally(resizable);
dockParam.setResizeLockedVertically(resizable);
dockParam.setExternalizable(externalizable);
dockParam.setMaximizable(maximalizable);
dockParam.setMinimizable(minimizable);
dockParam.setMinimizedHold(false);
dockParam.setTitleShown(showTitle);
dockParam.setStackable(stackable);
}
private static class HoldToggleFilter extends DefaultActionOffer
{
@Override
public DockActionSource getSource(Dockable dockable,
DockActionSource source, DockActionSource[] guards,
DockActionSource parent, DockActionSource[] parents)
{
DockActionSource result = super.getSource(dockable, source, guards,
parent, parents);
return new HoldToggleFilterActionSource(result);
}
}
/**
* Ce filtre est appliqué par {@link HoldToggleFilter} et ne montre pas
* l'action qui est fourni par {@link FlapDockStation}.
*/
private static class HoldToggleFilterActionSource extends
FilteredDockActionSource
{
public HoldToggleFilterActionSource(DockActionSource source)
{
super(source);
}
@Override
protected boolean include(DockAction action)
{
return !(action instanceof FlapDockHoldToggle);
}
}
public class MaximizeAction extends CExtendedModeAction
{
public MaximizeAction(CControl control)
{
super(control, ExtendedMode.MAXIMIZED,
CLocationModeManager.ICON_MANAGER_KEY_MAXIMIZE, "", "",
CControl.KEY_GOTO_MAXIMIZED);
setText("Maximize text in my language");
setTooltip("Maximize tooltip in my language");
}
}
public class MinimizeSouthAction extends CExtendedModeAction
{
public MinimizeSouthAction(CControl control)
{
super(control, ExtendedMode.MINIMIZED,
CLocationModeManager.ICON_MANAGER_KEY_MINIMIZE, "", "",
CControl.KEY_GOTO_MINIMIZED);
setText("Minimize text in my language");
setTooltip("Minimize tooltip in my language");
}
@Override
public void action(CDockable dockable)
{
dockable.setLocation(CLocation.base().minimalSouth());
}
}
public class NormalizeAction extends CExtendedModeAction
{
public NormalizeAction(CControl control)
{
super(control, ExtendedMode.NORMALIZED,
CLocationModeManager.ICON_MANAGER_KEY_NORMALIZE,
"normalize", "", CControl.KEY_GOTO_NORMALIZED);
setText("Normalize text in my language");
setTooltip("Normalize tooltip in my language");
}
}
}
dock1 is only minimizable.
dock2 is only maximizable.
i use my own minimize/maximize/normalize actions.
dock2 works fine on maximization and back to normal, no problem with my overriden actions.
dock1 works fine to minimize but when minimized the normalize button isnt paint (i can still right clic and do the action).
this behaviour is weird for me cause the default normalize action works fine but cant change the text/tooltip and when i use exactly the same code but change 2 strings, it failed :s