use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class ServerJobManager method doJobAction.
/**
* Do job action: cancel, hold, unhold
*
* @param actionName
* @param actionId
*/
private void doJobAction(final String actionName, final String actionErrorName, final int actionId) {
final IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
new ConsoleJob(String.format(Messages.get().ServerJobManager_ActionJobName, actionName), this, Activator.PLUGIN_ID, JOB_FAMILY) {
@SuppressWarnings("rawtypes")
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
Iterator it = selection.iterator();
while (it.hasNext()) {
Object object = it.next();
if (object instanceof ServerJob) {
final ServerJob jobObject = (ServerJob) object;
switch(actionId) {
case CANCEL_JOB:
session.cancelServerJob(jobObject.getId());
break;
case HOLD_JOB:
session.holdServerJob(jobObject.getId());
break;
case UNHOLD_JOB:
session.unholdServerJob(jobObject.getId());
break;
default:
throw new NXCException(RCC.INTERNAL_ERROR);
}
} else {
throw new NXCException(RCC.INTERNAL_ERROR);
}
}
}
@Override
protected String getErrorMessage() {
return String.format(Messages.get().ServerJobManager_ActionJobError, actionErrorName);
}
@Override
protected void jobFinalize() {
refreshJobList(false);
}
}.start();
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class FindNodeByPrimaryHostname method run.
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
@Override
public void run(IAction action) {
final EnterPrimaryHostnameDlg dlg = new EnterPrimaryHostnameDlg(window.getShell());
if (dlg.open() != Window.OK)
return;
final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob("Searching for hostname" + dlg.getHostname() + "in the network", null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final List<AbstractNode> nodes = session.findNodesByHostname((int) dlg.getZoneId(), dlg.getHostname());
runInUIThread(new Runnable() {
@Override
public void run() {
if (nodes != null && !nodes.isEmpty()) {
StringBuilder sb = new StringBuilder();
sb.append("The following nodes matching the criteria have been found: ");
for (int i = 0; i < nodes.size(); i++) {
sb.append("\n" + nodes.get(i).getPrimaryName());
}
MessageDialogHelper.openInformation(shell, "Result", sb.toString());
} else
MessageDialogHelper.openInformation(shell, "Result", "No nodes found!");
}
});
}
@Override
protected String getErrorMessage() {
return "Search for hostname" + dlg.getHostname() + "failed.";
}
}.start();
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class CertificateView method deleteCertificate.
/**
* Delete selected certificate
*/
private void deleteCertificate() {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.isEmpty())
return;
if (!MessageDialogHelper.openConfirm(getSite().getShell(), Messages.get().CertificateView_Confirmation, Messages.get().CertificateView_AckDeleteCertif))
return;
final Object[] objects = selection.toArray();
new ConsoleJob(Messages.get().CertificateView_DeleteCertif, this, Activator.PLUGIN_ID, Activator.PLUGIN_ID) {
@Override
protected String getErrorMessage() {
return Messages.get().CertificateView_ErrorDeleteCert;
}
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
for (int i = 0; i < objects.length; i++) {
session.deleteCertificate(((AuthCertificate) objects[i]).getId());
}
}
}.start();
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class SystemRights method applyChanges.
/**
* Apply changes
*
* @param isApply true if update operation caused by "Apply" button
*/
protected void applyChanges(final boolean isApply) {
if (isApply)
setValid(false);
long systemRights = 0;
for (Entry<Long, Button> e : buttons.entrySet()) if (e.getValue().getSelection())
systemRights |= e.getKey();
object.setSystemRights(systemRights);
new ConsoleJob(Messages.get().SystemRights_JobTitle, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.modifyUserDBObject(object, AbstractUserObject.MODIFY_ACCESS_RIGHTS);
}
@Override
protected String getErrorMessage() {
return Messages.get().SystemRights_JobError;
}
@Override
protected void jobFinalize() {
if (isApply) {
runInUIThread(new Runnable() {
@Override
public void run() {
SystemRights.this.setValid(true);
}
});
}
}
}.start();
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class UserManagementView method detachLDAPUser.
/**
* Set user/group to non LDAP
*/
private void detachLDAPUser() {
final IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
new ConsoleJob(Messages.get().UserManagementView_DeleteJobName, this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
for (Object object : selection.toList()) {
((AbstractUserObject) object).setFlags(((AbstractUserObject) object).getFlags() & ~AbstractUserObject.LDAP_USER);
session.detachUserFromLdap(((AbstractUserObject) object));
}
}
@Override
protected String getErrorMessage() {
return Messages.get().UserManagementView_DetachError;
}
}.start();
changePassword();
}
Aggregations