Search in sources :

Example 1 with ConsoleJob

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();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ServerJob(org.netxms.client.server.ServerJob) Iterator(java.util.Iterator) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) NXCException(org.netxms.client.NXCException) NXCException(org.netxms.client.NXCException)

Example 2 with ConsoleJob

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();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) NXCSession(org.netxms.client.NXCSession) EnterPrimaryHostnameDlg(org.netxms.ui.eclipse.topology.dialogs.EnterPrimaryHostnameDlg) List(java.util.List) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Example 3 with ConsoleJob

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();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) AuthCertificate(org.netxms.client.users.AuthCertificate) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Example 4 with ConsoleJob

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();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Button(org.eclipse.swt.widgets.Button) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Example 5 with ConsoleJob

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();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) AbstractUserObject(org.netxms.client.users.AbstractUserObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Aggregations

ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)330 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)329 NXCSession (org.netxms.client.NXCSession)163 PartInitException (org.eclipse.ui.PartInitException)113 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)81 NXCObjectModificationData (org.netxms.client.NXCObjectModificationData)45 NXCException (org.netxms.client.NXCException)44 List (java.util.List)38 ArrayList (java.util.ArrayList)34 AbstractObject (org.netxms.client.objects.AbstractObject)33 NXCObjectCreationData (org.netxms.client.NXCObjectCreationData)28 IOException (java.io.IOException)27 CreateObjectDialog (org.netxms.ui.eclipse.objectbrowser.dialogs.CreateObjectDialog)16 ObjectSelectionDialog (org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog)13 File (java.io.File)12 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)10 Script (org.netxms.client.Script)10 Table (org.netxms.client.Table)10 CoreException (org.eclipse.core.runtime.CoreException)9 GridData (org.eclipse.swt.layout.GridData)9