Here are some examples that show how to customize mydoggy. Remember to obtain an instance of ResourceManager you can use the following:
MyDoggyToolWindowManager toolWindowManager = new MyDoggyToolWindowManager(...); ResourceManager resourceManager = toolWindowManager.getResourceManager();
Look at this page to understand at what i'm referring when i write TitleBar, ToolWindowTab, etc..
You can use the following code to set a property value:
resourceManager.putProperty("drag.icon.transparency.enabled", "false");
Here is a list of supported properties.
| Name | Type | Description |
| drag.icon.transparency.enabled | boolean | Used to enable or disable the transparency of the drag icon. |
| drag.icon.useDefault | boolean | Used to enable or disable the use of a simple icon instead of a more complex one during the a drag phase. |
| ContentManagerUI.ContentManagerUiListener.import | boolean | Used to enable or disable the import of all listeners from an unmounting ContentManageUI to the new mmounted ContentManagerUI. |
| drag.toolwindow.asTab | boolean | Used to enable or disable dragging of toolwindows as tabs. |
|
You can use the following code:
import org.noos.xing.mydoggy.plaf.ui.MyDoggyKeySpace;
....
resourceManager.putColor(MyDoggyKeySpace.TWTB_BACKGROUND_ACTIVE_START, Color.BLUE);
resourceManager.putColor(MyDoggyKeySpace.TWTB_BACKGROUND_ACTIVE_END, Color.GREEN);
resourceManager.putColor(MyDoggyKeySpace.TWTB_BACKGROUND_INACTIVE_START, Color.BLACK);
resourceManager.putColor(MyDoggyKeySpace.TWTB_BACKGROUND_INACTIVE_END, Color.GREEN.darker());
|
|
You can use the following code:
import org.noos.xing.mydoggy.plaf.ui.MyDoggyKeySpace;
....
resourceManager.putColor(MyDoggyKeySpace.TWTB_TAB_FOREGROUND_SELECTED, Color.GREEN);
resourceManager.putColor(MyDoggyKeySpace.TWTB_TAB_FOREGROUND_UNSELECTED, Color.DARK_GRAY);
|
|
You can use the following code:
import org.noos.xing.mydoggy.plaf.ui.MyDoggyKeySpace;
....
resourceManager.putColor(MyDoggyKeySpace.RAB_BACKGROUND_ACTIVE_START, Color.RED);
resourceManager.putColor(MyDoggyKeySpace.RAB_BACKGROUND_ACTIVE_END, Color.ORANGE);
|
|
You can use the following code:
import org.noos.xing.mydoggy.plaf.ui.MyDoggyKeySpace;
....
resourceManager.putColor(MyDoggyKeySpace.RAB_FOREGROUND, Color.BLUE);
|
resourceManager.putIcon(MyDoggyKeySpace.DOCKED, new Icon(...));
Here are some examples that show how to customize in a more deep way mydoggy. To obtain an instance of MyDoggyResourceManager you can use the following:
MyDoggyToolWindowManager toolWindowManager = new MyDoggyToolWindowManager(...); MyDoggyResourceManager myDoggyResourceManager = (MyDoggyResourceManager) toolWindowManager.getResourceManager();
|
As you can see, now the gradient direction has changed and instead of an arc there is a arrow. You can use the following code:
import org.noos.xing.mydoggy.plaf.ui.MyDoggyKeySpace;
import org.noos.xing.mydoggy.plaf.ui.look.ToolWindowTitleBarUI;
import org.noos.xing.mydoggy.plaf.ui.ToolWindowDescriptor;
import org.noos.xing.mydoggy.plaf.ui.ToolWindowContainer;
import org.noos.xing.mydoggy.plaf.ui.util.GraphicsUtil;
import org.noos.common.context.Context;
import org.noos.common.object.ObjectCreator;
...
myDoggyResourceManager.putComponentUICreator(MyDoggyKeySpace.TOOL_WINDOW_TITLE_BAR_UI,
new ObjectCreator<ComponentUI>() {
public ComponentUI create(Context context) {
return new ToolWindowTitleBarUI(context.get(ToolWindowDescriptor.class) ,
context.get(ToolWindowContainer.class)) {
protected void updateToolWindowTitleBar(Graphics g, JComponent c, Color backgroundStart, Color backgroundEnd, Color idBackgroundColor, Color idColor) {
Rectangle r = c.getBounds();
r.x = r.y = 0;
GraphicsUtil.fillRect(g, r,
backgroundStart, backgroundEnd,
null,
GraphicsUtil.LEFT_TO_RIGHT_GRADIENT);
if (descriptor.getDockedTypeDescriptor().isIdVisibleOnTitleBar() ||
toolWindow.getType() == ToolWindowType.FLOATING ||
toolWindow.getType() == ToolWindowType.FLOATING_FREE ||
toolWindow.getType() == ToolWindowType.FLOATING_LIVE) {
String id = resourceManager.getUserString(descriptor.getToolWindow().getId());
r.width = g.getFontMetrics().stringWidth(id) + 8;
int halfHeigh = (r.height / 2);
GraphicsUtil.fillRect(g, r,
Color.WHITE,
idBackgroundColor,
new Polygon(new int[]{r.x, r.x + r.width - halfHeigh, r.x + r.width - halfHeigh, r.x},
new int[]{r.y, r.y, r.y + r.height, r.y + r.height},
4),
GraphicsUtil.LEFT_TO_RIGHT_GRADIENT);
Polygon polygon = new Polygon();
polygon.addPoint(r.x + r.width - halfHeigh, r.y);
polygon.addPoint(r.x + r.width - halfHeigh + 8, r.y + (r.height / 2));
polygon.addPoint(r.x + r.width - halfHeigh, r.y + r.height);
GraphicsUtil.fillRect(g, r,
Color.WHITE,
idBackgroundColor,
polygon,
GraphicsUtil.LEFT_TO_RIGHT_GRADIENT);
g.setColor(idColor);
g.drawString(id, r.x + 2, r.y + g.getFontMetrics().getAscent());
}
}
};
}
}); |
|
As use can see, now we have two buttons. One is the hide buttone, the other is a special button, if the user clicks on it then a popup menu is showed with all available actions. You can use the following code:
import org.noos.xing.mydoggy.plaf.ui.TitleBarButtons;
import org.noos.xing.mydoggy.plaf.ui.ToolWindowDescriptor;
import org.noos.xing.mydoggy.plaf.ui.ToolWindowContainer;
import org.noos.xing.mydoggy.plaf.ui.util.GraphicsUtil;
import org.noos.common.context.Context;
import org.noos.common.object.ObjectCreator;
import org.noos.xing.mydoggy.plaf.ui.cmp.MenuTitleBarButtons;
...
myDoggyResourceManager.putInstanceCreator(TitleBarButtons.class,
new ObjectCreator() {
public Object create(Context context) {
return new MenuTitleBarButtons(
context.get(ToolWindowDescriptor.class),
context.get(ToolWindowContainer.class)
);
}
}); |