|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent javax.swing.JPanel com.jidesoft.dashboard.GadgetPalette
public class GadgetPalette
The palette contains the gadget so that user can drag and drop the gadget to dashboard.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JPanel |
---|
JPanel.AccessibleJPanel |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
protected ButtonGroup |
_buttonGroup
|
protected Container |
_gadgetList
|
protected JComponent |
_status
|
static String |
CONTEXT_BUTTON_ADD
CONTEXT_BUTTON_ADD, CONTEXT_BUTTON_DONE, CONTEXT_BUTTON_DESCRIPTION are the name of the components in the GadgetPalette description panel. |
static String |
CONTEXT_BUTTON_DESCRIPTION
|
static String |
CONTEXT_BUTTON_DONE
|
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
GadgetPalette(GadgetManager manager,
GadgetPaletteInstaller installer)
|
Method Summary | |
---|---|
protected AbstractButton |
createButton(Gadget gadget)
|
protected JComponent |
createDescriptionLabel()
|
protected JPanel |
createDescriptionPanel(Component statusComponent)
Creates the panel for the status label and two more buttons. |
protected Container |
createGadgetButtonContainer()
Creates the container for the gadget buttons. |
protected AbstractButton |
createScrollButton(int type)
Creates the scroll button for the SimpleScrollPane used by GadgetPalete when there aren't enough space to show all gadgets on the palette. |
protected void |
customizeButton(AbstractButton button)
|
void |
eventHappened(GadgetEvent e)
Invoked when a Gadget event happened |
GadgetManager |
getGadgetManager()
|
GadgetPaletteInstaller |
getInstaller()
|
protected String |
getResourceString(String key)
Gets the localized string from resource bundle. |
protected void |
paintBackground(Graphics g)
Paints the background of GadgetPalette. |
protected void |
paintComponent(Graphics g)
|
void |
propertyChange(PropertyChangeEvent evt)
|
protected void |
recreateGadgetButtons()
Recreates the gadget buttons and add them to the containers for the gadget buttons. |
void |
setButtonLayout(LayoutManager layout)
Set the layout manager for the container contains gadget buttons. |
protected void |
uncustomizeButton(AbstractButton button)
|
protected void |
updateOpaque()
Update opaque property to false for every child components in GadgetPalette. |
void |
updateUI()
|
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String CONTEXT_BUTTON_ADD
public static final String CONTEXT_BUTTON_DONE
public static final String CONTEXT_BUTTON_DESCRIPTION
protected ButtonGroup _buttonGroup
protected JComponent _status
protected Container _gadgetList
Constructor Detail |
---|
public GadgetPalette(GadgetManager manager, GadgetPaletteInstaller installer)
Method Detail |
---|
protected void updateOpaque()
protected JComponent createDescriptionLabel()
protected Container createGadgetButtonContainer()
recreateGadgetButtons()
method, we will create gadget buttons and add it to the ScrollableButtonPanel. To make it easy for people to
override, the default code is inlcuded below. The _gadgetList is a field of ScrollableButtonPanel.
_gadgetList = new JPanel(new GridLayout(1, 0, 4, 4));
JPanel panel = JideSwingUtilities.createCenterPanel(_gadgetList);
panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
SimpleScrollPane scrollPane = new SimpleScrollPane(_gadgetList) {
protected AbstractButton createScrollButton(int type) {
AbstractButton button = GadgetPalette.this.createScrollButton(type);
if (button != null) {
return button;
}
else {
return super.createScrollButton(type);
}
}
};
scrollPane.setRepeatDelay(100);
scrollPane.setBorder(BorderFactory.createEmptyBorder());
return scrollPane;
public void setButtonLayout(LayoutManager layout)
layout
- the layout managerprotected void recreateGadgetButtons()
To make it easy for people to override, the default code is inlcuded
below. The _gadgetList is a field of ScrollableButtonPanel.
Component[] components = _gadgetList.getComponents();
for (Component component : components) {
if (component instanceof AbstractButton) {
uncustomizeButton(((AbstractButton) component));
_buttonGroup.remove(((AbstractButton) component));
}
}
_gadgetList.removeAll();
String[] elements = _manager.getGadgets();
for (String key : elements) {
Gadget element = _manager.getGadget(key);
AbstractButton button = createButton(element);
customizeButton(button);
_gadgetList.addButton(button);
_buttonGroup.add(button);
}
revalidate();
repaint();
protected JPanel createDescriptionPanel(Component statusComponent)
statusComponent
- the status component.
protected AbstractButton createScrollButton(int type)
type
- left or right. It could be SwingConstants.WEST or SwingConstants.EAST.
public void updateUI()
updateUI
in class JPanel
protected void paintComponent(Graphics g)
paintComponent
in class JComponent
protected void paintBackground(Graphics g)
g
- the Graphics instancepublic GadgetManager getGadgetManager()
public GadgetPaletteInstaller getInstaller()
protected AbstractButton createButton(Gadget gadget)
protected void customizeButton(AbstractButton button)
protected void uncustomizeButton(AbstractButton button)
protected String getResourceString(String key)
key
- the resource key.
public void eventHappened(GadgetEvent e)
GadgetListener
Gadget
event happened
eventHappened
in interface GadgetListener
e
- GadgetEventpublic void propertyChange(PropertyChangeEvent evt)
propertyChange
in interface PropertyChangeListener
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |