crmConfigureCommitButton.setEnabled(false);
String command = "HostBrowser.getHostInfo";
if (!host.hasCorosyncInitScript()) {
command = "HostBrowser.getHostInfoHeartbeat";
}
host.execCommand(new ExecCommandConfig().commandString(command)
.execCallback(execCallback)
.silentCommand()
.silentOutput()
.sshCommandTimeout(Ssh.DEFAULT_COMMAND_TIMEOUT));
}
});
host.registerEnableOnConnect(hostInfoButton);
crmConfigureShowButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
registerComponentEditAccessMode(ta, new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL));
updateAdvancedPanels();
crmShowInProgress = true;
crmInfoShowing = false;
crmConfigureShowButton.setEnabled(false);
crmConfigureCommitButton.setEnabled(false);
host.execCommand(new ExecCommandConfig().commandString("HostBrowser.getCrmConfigureShow")
.execCallback(execCallback)
.sshCommandTimeout(Ssh.DEFAULT_COMMAND_TIMEOUT));
}
});
final CrmGraph crmg = getBrowser().getClusterBrowser().getCrmGraph();
final Document taDocument = ta.getDocument();
taDocument.addDocumentListener(new DocumentListener() {
private void update() {
if (!crmShowInProgress && !crmInfoShowing) {
crmConfigureCommitButton.setEnabled(true);
}
}
@Override
public void changedUpdate(final DocumentEvent e) {
update();
}
@Override
public void insertUpdate(final DocumentEvent e) {
update();
}
@Override
public void removeUpdate(final DocumentEvent e) {
update();
}
});
final ButtonCallback buttonCallback = new ButtonCallback() {
private volatile boolean mouseStillOver = false;
@Override
public boolean isEnabled() {
return !Tools.versionBeforePacemaker(host);
}
@Override
public void mouseOut(final ComponentWithTest component) {
if (!isEnabled()) {
return;
}
mouseStillOver = false;
crmg.stopTestAnimation((JComponent) component);
component.setToolTipText("");
}
@Override
public void mouseOver(final ComponentWithTest component) {
if (!isEnabled()) {
return;
}
mouseStillOver = true;
component.setToolTipText(ClusterBrowser.STARTING_PTEST_TOOLTIP);
component.setToolTipBackground(Tools.getDefaultColor("ClusterBrowser.Test.Tooltip.Background"));
Tools.sleep(250);
if (!mouseStillOver) {
return;
}
mouseStillOver = false;
final CountDownLatch startTestLatch = new CountDownLatch(1);
crmg.startTestAnimation((JComponent) component, startTestLatch);
final Host dcHost = getBrowser().getClusterBrowser().getDCHost();
getBrowser().getClusterBrowser().ptestLockAcquire();
try {
final ClusterStatus clStatus = getBrowser().getClusterBrowser().getClusterStatus();
clStatus.setPtestResult(null);
CRM.crmConfigureCommit(host, ta.getText(), Application.RunMode.TEST);
final PtestData ptestData = new PtestData(CRM.getPtest(dcHost));
component.setToolTipText(ptestData.getToolTip());
clStatus.setPtestResult(ptestData);
} finally {
getBrowser().getClusterBrowser().ptestLockRelease();
}
startTestLatch.countDown();
}
};
addMouseOverListener(crmConfigureCommitButton, buttonCallback);
crmConfigureCommitButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
crmConfigureCommitButton.setEnabled(false);
final Thread thread = new Thread(
new Runnable() {
@Override
public void run() {
getBrowser().getClusterBrowser().clStatusLock();
try {
CRM.crmConfigureCommit(host, ta.getText(), Application.RunMode.LIVE);
} finally {
getBrowser().getClusterBrowser().clStatusUnlock();
}
}
}
);
thread.start();
}
});
final JPanel mainPanel = new JPanel();
mainPanel.setBackground(HostBrowser.PANEL_BACKGROUND);
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.PAGE_AXIS));
final JPanel buttonPanel = new JPanel(new BorderLayout());
buttonPanel.setBackground(HostBrowser.BUTTON_PANEL_BACKGROUND);
buttonPanel.setMinimumSize(new Dimension(0, 50));
buttonPanel.setPreferredSize(new Dimension(0, 50));
buttonPanel.setMaximumSize(new Dimension(Short.MAX_VALUE, 50));
mainPanel.add(buttonPanel);
/* Actions */
buttonPanel.add(getActionsButton(), BorderLayout.LINE_END);
final JPanel p = new JPanel(new SpringLayout());
p.setBackground(HostBrowser.BUTTON_PANEL_BACKGROUND);
p.add(hostInfoButton);
p.add(crmConfigureShowButton);
p.add(crmConfigureCommitButton);
p.add(new JLabel(""));
SpringUtilities.makeCompactGrid(p, 1, 3, // rows, cols
1, 1, // initX, initY
1, 1); // xPad, yPad
mainPanel.setMinimumSize(new Dimension(application.getDefaultSize("HostBrowser.ResourceInfoArea.Width"),
application.getDefaultSize("HostBrowser.ResourceInfoArea.Height")));
mainPanel.setPreferredSize(new Dimension(application.getDefaultSize("HostBrowser.ResourceInfoArea.Width"),
application.getDefaultSize("HostBrowser.ResourceInfoArea.Height")));
buttonPanel.add(p);
mainPanel.add(new JLabel(Tools.getString("HostInfo.crmShellInfo")));
mainPanel.add(new JScrollPane(ta));
String command = "HostBrowser.getHostInfo";
if (!host.hasCorosyncInitScript()) {
command = "HostBrowser.getHostInfoHeartbeat";
}
host.execCommand(new ExecCommandConfig().commandString(command)
.execCallback(execCallback)
.silentCommand()
.silentOutput()
.sshCommandTimeout(Ssh.DEFAULT_COMMAND_TIMEOUT));
return mainPanel;