allow a button to be marked as 'download', which causes it to be hidden when patch is available

This commit is contained in:
Dmitry Jemerov
2012-02-09 16:28:09 +01:00
parent 75a73d76da
commit df47c5d2b8
2 changed files with 15 additions and 1 deletions
@@ -23,10 +23,12 @@ import org.jdom.Element;
public class ButtonInfo {
private final String myName;
private final String myUrl;
private final boolean myDownload;
public ButtonInfo(Element element) {
myName = element.getAttributeValue("name");
myUrl = element.getAttributeValue("url");
myDownload = element.getAttributeValue("download") != null;
}
public String getName() {
@@ -36,4 +38,13 @@ public class ButtonInfo {
public String getUrl() {
return myUrl;
}
/**
* The button marked with 'download=true' attribute is hidden if patch is available.
*
* @return true if the button should be hidden when the patch is available.
*/
public boolean isDownload() {
return myDownload;
}
}
@@ -66,11 +66,14 @@ class UpdateInfoDialog extends AbstractUpdateDialog {
}
else {
for (ButtonInfo info : buttons) {
actions.add(new ButtonAction(info));
if (!info.isDownload()) {
actions.add(new ButtonAction(info));
}
}
}
}
else {
// the first button replaces the OK action
for (int i = 1; i < buttons.size(); i++) {
actions.add(new ButtonAction(buttons.get(i)));
}