minor - replace deprecated method usage
This commit is contained in:
parent
b03fc7bcd7
commit
86c0ebac2c
|
@ -38,7 +38,7 @@ import org.zkoss.zul.Messagebox;
|
||||||
public final class ConfirmPanel extends Hbox
|
public final class ConfirmPanel extends Hbox
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -6050634074454659578L;
|
private static final long serialVersionUID = -6050634074454659578L;
|
||||||
/** Action String OK. */
|
/** Action String OK. */
|
||||||
|
@ -70,17 +70,17 @@ public final class ConfirmPanel extends Hbox
|
||||||
public static final String A_PATTRIBUTE = "PAttribute";
|
public static final String A_PATTRIBUTE = "PAttribute";
|
||||||
/** Action String New. */
|
/** Action String New. */
|
||||||
public static final String A_NEW = "New";
|
public static final String A_NEW = "New";
|
||||||
|
|
||||||
private boolean m_withText = false;
|
private boolean m_withText = false;
|
||||||
|
|
||||||
private Map<String, Button> buttonMap = new HashMap<String, Button>();
|
private Map<String, Button> buttonMap = new HashMap<String, Button>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a button of the specified id
|
* Creates a button of the specified id
|
||||||
*
|
*
|
||||||
* @param id button id
|
* @param id button id
|
||||||
* @return button
|
* @return button
|
||||||
*
|
*
|
||||||
* <p>The string can be any of the following and the corresponding button will be created: </p>
|
* <p>The string can be any of the following and the corresponding button will be created: </p>
|
||||||
* <dl>
|
* <dl>
|
||||||
* <dt>Ok</dt> <dd>Ok button</dd>
|
* <dt>Ok</dt> <dd>Ok button</dd>
|
||||||
|
@ -96,7 +96,7 @@ public final class ConfirmPanel extends Hbox
|
||||||
* <dt>Zoom</dt> <dd>Zoom button</dd>
|
* <dt>Zoom</dt> <dd>Zoom button</dd>
|
||||||
* <dt>Help</dt> <dd>Help button</dd>
|
* <dt>Help</dt> <dd>Help button</dd>
|
||||||
* </dl>
|
* </dl>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public Button createButton(String name)
|
public Button createButton(String name)
|
||||||
{
|
{
|
||||||
|
@ -108,26 +108,26 @@ public final class ConfirmPanel extends Hbox
|
||||||
text = text.replaceAll("[&]", "");
|
text = text.replaceAll("[&]", "");
|
||||||
else
|
else
|
||||||
text = null;
|
text = null;
|
||||||
|
|
||||||
if (m_withText && text != null)
|
if (m_withText && text != null)
|
||||||
{
|
{
|
||||||
button.setSrc("images/"+name+"16.png");
|
button.setImage("images/"+name+"16.png");
|
||||||
button.setLabel(text);
|
button.setLabel(text);
|
||||||
LayoutUtils.addSclass("action-text-button", button);
|
LayoutUtils.addSclass("action-text-button", button);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
button.setSrc("images/"+name+"24.png");
|
button.setImage("images/"+name+"24.png");
|
||||||
if (text != null)
|
if (text != null)
|
||||||
button.setTooltiptext(text);
|
button.setTooltiptext(text);
|
||||||
LayoutUtils.addSclass("action-button", button);
|
LayoutUtils.addSclass("action-button", button);
|
||||||
}
|
}
|
||||||
|
|
||||||
buttonMap.put(name, button);
|
buttonMap.put(name, button);
|
||||||
|
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create confirm panel with multiple options
|
* create confirm panel with multiple options
|
||||||
* @param withCancelButton with cancel
|
* @param withCancelButton with cancel
|
||||||
|
@ -138,15 +138,15 @@ public final class ConfirmPanel extends Hbox
|
||||||
* @param withZoomButton with zoom
|
* @param withZoomButton with zoom
|
||||||
*/
|
*/
|
||||||
public ConfirmPanel(boolean withCancelButton,
|
public ConfirmPanel(boolean withCancelButton,
|
||||||
boolean withRefreshButton,
|
boolean withRefreshButton,
|
||||||
boolean withResetButton,
|
boolean withResetButton,
|
||||||
boolean withCustomizeButton,
|
boolean withCustomizeButton,
|
||||||
boolean withHistoryButton,
|
boolean withHistoryButton,
|
||||||
boolean withZoomButton)
|
boolean withZoomButton)
|
||||||
{
|
{
|
||||||
this(withCancelButton, withRefreshButton, withResetButton, withCustomizeButton, withHistoryButton, withZoomButton, false);
|
this(withCancelButton, withRefreshButton, withResetButton, withCustomizeButton, withHistoryButton, withZoomButton, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create confirm panel with multiple options
|
* create confirm panel with multiple options
|
||||||
* @param withCancelButton with cancel
|
* @param withCancelButton with cancel
|
||||||
|
@ -157,23 +157,23 @@ public final class ConfirmPanel extends Hbox
|
||||||
* @param withZoomButton with zoom
|
* @param withZoomButton with zoom
|
||||||
*/
|
*/
|
||||||
public ConfirmPanel(boolean withCancelButton,
|
public ConfirmPanel(boolean withCancelButton,
|
||||||
boolean withRefreshButton,
|
boolean withRefreshButton,
|
||||||
boolean withResetButton,
|
boolean withResetButton,
|
||||||
boolean withCustomizeButton,
|
boolean withCustomizeButton,
|
||||||
boolean withHistoryButton,
|
boolean withHistoryButton,
|
||||||
boolean withZoomButton,
|
boolean withZoomButton,
|
||||||
boolean withText)
|
boolean withText)
|
||||||
{
|
{
|
||||||
m_withText = withText;
|
m_withText = withText;
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
setVisible(A_CANCEL, withCancelButton);
|
setVisible(A_CANCEL, withCancelButton);
|
||||||
addComponentsRight(createButton(A_OK));
|
addComponentsRight(createButton(A_OK));
|
||||||
|
|
||||||
if (withCancelButton)
|
if (withCancelButton)
|
||||||
addComponentsRight(createButton(A_CANCEL));
|
addComponentsRight(createButton(A_CANCEL));
|
||||||
|
|
||||||
if (withRefreshButton)
|
if (withRefreshButton)
|
||||||
{
|
{
|
||||||
addComponentsLeft(createButton(A_REFRESH));
|
addComponentsLeft(createButton(A_REFRESH));
|
||||||
|
@ -193,9 +193,9 @@ public final class ConfirmPanel extends Hbox
|
||||||
if (withZoomButton)
|
if (withZoomButton)
|
||||||
{
|
{
|
||||||
addComponentsLeft(createButton(A_ZOOM));
|
addComponentsLeft(createButton(A_ZOOM));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create confirm panel with Ok button only
|
* Create confirm panel with Ok button only
|
||||||
*/
|
*/
|
||||||
|
@ -203,62 +203,62 @@ public final class ConfirmPanel extends Hbox
|
||||||
{
|
{
|
||||||
this(false,false,false,false,false,false);
|
this(false,false,false,false,false,false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create confirm panel with Ok and Cancel button
|
* Create confirm panel with Ok and Cancel button
|
||||||
* @param withCancel with cancel
|
* @param withCancel with cancel
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public ConfirmPanel(boolean withCancel)
|
public ConfirmPanel(boolean withCancel)
|
||||||
{
|
{
|
||||||
this(withCancel,false,false,false,false,false);
|
this(withCancel,false,false,false,false,false);
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
private Hbox hboxBtnLeft;
|
private Hbox hboxBtnLeft;
|
||||||
private Hbox hboxBtnRight;
|
private Hbox hboxBtnRight;
|
||||||
//
|
//
|
||||||
private Panel pnlBtnRight;
|
private Panel pnlBtnRight;
|
||||||
private Panel pnlBtnLeft;
|
private Panel pnlBtnLeft;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* initialise components
|
* initialise components
|
||||||
*/
|
*/
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
pnlBtnLeft = new Panel();
|
pnlBtnLeft = new Panel();
|
||||||
pnlBtnLeft.setAlign("left");
|
pnlBtnLeft.setAlign("left");
|
||||||
|
|
||||||
pnlBtnRight = new Panel();
|
pnlBtnRight = new Panel();
|
||||||
pnlBtnRight.setAlign("right");
|
pnlBtnRight.setAlign("right");
|
||||||
|
|
||||||
hboxBtnRight = new Hbox();
|
hboxBtnRight = new Hbox();
|
||||||
hboxBtnRight.appendChild(pnlBtnRight);
|
hboxBtnRight.appendChild(pnlBtnRight);
|
||||||
hboxBtnRight.setWidth("100%");
|
hboxBtnRight.setWidth("100%");
|
||||||
hboxBtnRight.setStyle("text-align:right");
|
hboxBtnRight.setStyle("text-align:right");
|
||||||
|
|
||||||
hboxBtnLeft = new Hbox();
|
hboxBtnLeft = new Hbox();
|
||||||
hboxBtnLeft.appendChild(pnlBtnLeft);
|
hboxBtnLeft.appendChild(pnlBtnLeft);
|
||||||
hboxBtnLeft.setWidth("100%");
|
hboxBtnLeft.setWidth("100%");
|
||||||
hboxBtnLeft.setStyle("text-align:left");
|
hboxBtnLeft.setStyle("text-align:left");
|
||||||
|
|
||||||
this.appendChild(hboxBtnLeft);
|
this.appendChild(hboxBtnLeft);
|
||||||
this.appendChild(hboxBtnRight);
|
this.appendChild(hboxBtnRight);
|
||||||
this.setWidth("100%");
|
this.setWidth("100%");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add button to the left side of the confirm panel
|
* add button to the left side of the confirm panel
|
||||||
* @param button button
|
* @param button button
|
||||||
*/
|
*/
|
||||||
public void addComponentsLeft(Button button)
|
public void addComponentsLeft(Button button)
|
||||||
{
|
{
|
||||||
if (!buttonMap.containsKey(button.getId()))
|
if (!buttonMap.containsKey(button.getId()))
|
||||||
buttonMap.put(button.getId(), button);
|
buttonMap.put(button.getId(), button);
|
||||||
pnlBtnLeft.appendChild(button);
|
pnlBtnLeft.appendChild(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add button to the right side of the confirm panel
|
* add button to the right side of the confirm panel
|
||||||
* @param button button
|
* @param button button
|
||||||
*/
|
*/
|
||||||
public void addComponentsRight(Button button)
|
public void addComponentsRight(Button button)
|
||||||
|
@ -266,8 +266,8 @@ public final class ConfirmPanel extends Hbox
|
||||||
if (!buttonMap.containsKey(button.getId()))
|
if (!buttonMap.containsKey(button.getId()))
|
||||||
buttonMap.put(button.getId(), button);
|
buttonMap.put(button.getId(), button);
|
||||||
pnlBtnRight.appendChild(button);
|
pnlBtnRight.appendChild(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return button of the specified id
|
* return button of the specified id
|
||||||
* @param id button id
|
* @param id button id
|
||||||
|
@ -292,7 +292,7 @@ public final class ConfirmPanel extends Hbox
|
||||||
{
|
{
|
||||||
return buttonMap.get(id);
|
return buttonMap.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sets the visibility of the specified button
|
* sets the visibility of the specified button
|
||||||
* @param btnName button name
|
* @param btnName button name
|
||||||
|
@ -365,7 +365,7 @@ public final class ConfirmPanel extends Hbox
|
||||||
* enable specific button
|
* enable specific button
|
||||||
* @param id button id
|
* @param id button id
|
||||||
* @param enabled enabled
|
* @param enabled enabled
|
||||||
*
|
*
|
||||||
* <p> The button id can be any of the following
|
* <p> The button id can be any of the following
|
||||||
* <dl>
|
* <dl>
|
||||||
* <dt>Ok</dt> <dd>Ok button</dd>
|
* <dt>Ok</dt> <dd>Ok button</dd>
|
||||||
|
@ -390,7 +390,7 @@ public final class ConfirmPanel extends Hbox
|
||||||
button.setEnabled(enabled);
|
button.setEnabled(enabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* enable all components
|
* enable all components
|
||||||
* @param enabled enabled
|
* @param enabled enabled
|
||||||
|
@ -401,7 +401,7 @@ public final class ConfirmPanel extends Hbox
|
||||||
List list2 = pnlBtnRight.getChildren();
|
List list2 = pnlBtnRight.getChildren();
|
||||||
Iterator iter1 = list1.iterator();
|
Iterator iter1 = list1.iterator();
|
||||||
Iterator iter2 = list2.iterator();
|
Iterator iter2 = list2.iterator();
|
||||||
|
|
||||||
while (iter1.hasNext())
|
while (iter1.hasNext())
|
||||||
{
|
{
|
||||||
Button button = (Button)iter1.next();
|
Button button = (Button)iter1.next();
|
||||||
|
@ -424,7 +424,7 @@ public final class ConfirmPanel extends Hbox
|
||||||
List list2 = pnlBtnRight.getChildren();
|
List list2 = pnlBtnRight.getChildren();
|
||||||
Iterator iter1 = list1.iterator();
|
Iterator iter1 = list1.iterator();
|
||||||
Iterator iter2 = list2.iterator();
|
Iterator iter2 = list2.iterator();
|
||||||
|
|
||||||
while (iter1.hasNext())
|
while (iter1.hasNext())
|
||||||
{
|
{
|
||||||
Button button = (Button)iter1.next();
|
Button button = (Button)iter1.next();
|
||||||
|
@ -460,5 +460,5 @@ public final class ConfirmPanel extends Hbox
|
||||||
public Button getOKButton() {
|
public Button getOKButton() {
|
||||||
return getButton(A_OK);
|
return getButton(A_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // ConfirmPanel
|
} // ConfirmPanel
|
||||||
|
|
Loading…
Reference in New Issue