}
});
items.add(addGroupMenuItem);
/* add service */
final MyMenu addServiceMenuItem = menuFactory.createMenu(
Tools.getString("ClusterBrowser.Hb.AddService"),
new AccessMode(AccessMode.OP, AccessMode.NORMAL),
new AccessMode(AccessMode.OP, AccessMode.NORMAL))
.enablePredicate(new EnablePredicate() {
@Override
public String check() {
if (servicesInfo.getBrowser().getCrmXml() == null) {
return ClusterBrowser.UNKNOWN_CLUSTER_STATUS_STRING;
}
if (servicesInfo.getBrowser().crmStatusFailed()) {
return ClusterBrowser.UNKNOWN_CLUSTER_STATUS_STRING;
}
return null;
}
});
addServiceMenuItem.onUpdate(new Runnable() {
@Override
public void run() {
application.isSwingThread();
addServiceMenuItem.removeAll();
final Point2D pos = addServiceMenuItem.getPos();
final CrmXml crmXML = servicesInfo.getBrowser().getCrmXml();
if (crmXML == null) {
return;
}
final ResourceAgent fsService = crmXML.getResourceAgent(
"Filesystem",
ResourceAgent.HEARTBEAT_PROVIDER,
ResourceAgent.OCF_CLASS_NAME);
if (crmXML.isLinbitDrbdResourceAgentPresent()) { /* just skip it, if it is not */
final MyMenuItem ldMenuItem = menuFactory.createMenuItem(
Tools.getString("ClusterBrowser.linbitDrbdMenuName"),
null,
null,
new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
new AccessMode(AccessMode.OP, AccessMode.NORMAL))
.addAction(new MenuAction() {
@Override
public void run(final String text) {
servicesInfo.hidePopup();
if (!servicesInfo.getBrowser().linbitDrbdConfirmDialog()) {
return;
}
final FilesystemRaInfo fsi = (FilesystemRaInfo) servicesInfo.addServicePanel(
fsService,
addServiceMenuItem.getPos(),
true,
null,
null,
runMode);
fsi.setDrbddiskIsPreferred(false);
servicesInfo.getBrowser().getCrmGraph().repaint();
}
});
if (servicesInfo.getBrowser().atLeastOneDrbddiskConfigured()
|| !crmXML.isLinbitDrbdResourceAgentPresent()) {
ldMenuItem.setEnabled(false);
}
ldMenuItem.setPos(pos);
addServiceMenuItem.add(ldMenuItem);
}
final ResourceAgent ipService = crmXML.getResourceAgent(
"IPaddr2",
ResourceAgent.HEARTBEAT_PROVIDER,
ResourceAgent.OCF_CLASS_NAME);
if (ipService != null) { /* just skip it, if it is not*/
final MyMenuItem ipMenuItem =
menuFactory.createMenuItem(ipService.getPullDownMenuName(),
null,
null,
new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
new AccessMode(AccessMode.OP, AccessMode.NORMAL))
.addAction(new MenuAction() {
@Override
public void run(final String text) {
servicesInfo.hidePopup();
servicesInfo.addServicePanel(ipService,
addServiceMenuItem.getPos(),
true,
null,
null,
runMode);
servicesInfo.getBrowser().getCrmGraph().repaint();
}
});
ipMenuItem.setPos(pos);
addServiceMenuItem.add(ipMenuItem);
}
if (crmXML.isDrbddiskResourceAgentPresent()
&& (servicesInfo.getBrowser().isDrbddiskRAPreferred()
|| servicesInfo.getBrowser().atLeastOneDrbddiskConfigured()
|| !crmXML.isLinbitDrbdResourceAgentPresent())) {
final MyMenuItem ddMenuItem = menuFactory.createMenuItem(
Tools.getString("ClusterBrowser.DrbddiskMenuName"),
null,
null,
new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
new AccessMode(AccessMode.OP, AccessMode.NORMAL))
.addAction(new MenuAction() {
@Override
public void run(final String text) {
servicesInfo.hidePopup();
final FilesystemRaInfo fsi = (FilesystemRaInfo) servicesInfo.addServicePanel(
fsService,
addServiceMenuItem.getPos(),
true,
null,
null,
runMode);
fsi.setDrbddiskIsPreferred(true);
servicesInfo.getBrowser().getCrmGraph().repaint();
}
});
if (servicesInfo.getBrowser().isOneLinbitDrbdRaConfigured()
|| !crmXML.isDrbddiskResourceAgentPresent()) {
ddMenuItem.setEnabled(false);
}
ddMenuItem.setPos(pos);
addServiceMenuItem.add(ddMenuItem);
}
final Collection<JDialog> popups = new ArrayList<JDialog>();
for (final String cl : ClusterBrowser.CRM_CLASSES) {
final List<ResourceAgent> services = servicesInfo.getAddServiceList(cl);
if (services.isEmpty()) {
/* no services, don't show */
continue;
}
AccessMode.Mode mode = AccessMode.NORMAL;
if (ResourceAgent.UPSTART_CLASS_NAME.equals(cl) || ResourceAgent.SYSTEMD_CLASS_NAME.equals(cl)) {
mode = AccessMode.ADVANCED;
}
if (ResourceAgent.LSB_CLASS_NAME.equals(cl)
&& !servicesInfo.getAddServiceList(ResourceAgent.SERVICE_CLASS_NAME).isEmpty()) {
mode = AccessMode.ADVANCED;
}
final MyMenu classItem =
menuFactory.createMenu(ClusterBrowser.getClassMenuName(cl),
new AccessMode(AccessMode.ADMIN, mode),
new AccessMode(AccessMode.OP, mode));
final MyListModel<MyMenuItem> dlm = new MyListModel<MyMenuItem>();
for (final ResourceAgent ra : services) {
final MyMenuItem mmi = menuFactory.createMenuItem(
ra.getPullDownMenuName(),
null,
null,
new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
new AccessMode(AccessMode.OP, AccessMode.NORMAL))
.addAction(new MenuAction() {
@Override
public void run(final String text) {
servicesInfo.hidePopup();
application.invokeLater(new Runnable() {
@Override
public void run() {
for (final JDialog otherP : popups) {
otherP.dispose();
}
}
});
if (ra.isLinbitDrbd() && !servicesInfo.getBrowser().linbitDrbdConfirmDialog()) {
return;
} else if (ra.isHbDrbd() && !servicesInfo.getBrowser().hbDrbdConfirmDialog()) {
return;
}
servicesInfo.addServicePanel(ra,
addServiceMenuItem.getPos(),
true,
null,
null,
runMode);
servicesInfo.getBrowser().getCrmGraph().repaint();
}
});
mmi.setPos(pos);
dlm.addElement(mmi);
}
final boolean ret = guiData.getScrollingMenu(
ClusterBrowser.getClassMenuName(cl),
null, /* options */
classItem,
dlm,
new MyList<MyMenuItem>(dlm, addServiceMenuItem.getBackground()),
servicesInfo,
popups,
null);
if (!ret) {
classItem.setEnabled(false);
}
addServiceMenuItem.add(classItem);
}
addServiceMenuItem.updateMenuComponents();
addServiceMenuItem.processAccessMode();