Search in sources :

Example 6 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 7 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)

Example 8 with ConsoleJob

use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.

the class Authentication method applyChanges.

/**
 * Apply changes
 *
 * @param isApply true if update operation caused by "Apply" button
 */
protected void applyChanges(final boolean isApply) {
    // Account flags
    int flags = 0;
    if (checkDisabled.getSelection())
        flags |= AbstractUserObject.DISABLED;
    if (checkChangePassword.getSelection())
        flags |= AbstractUserObject.CHANGE_PASSWORD;
    if (checkFixedPassword.getSelection())
        flags |= AbstractUserObject.CANNOT_CHANGE_PASSWORD;
    if (checkCloseSessions.getSelection())
        flags |= AbstractUserObject.CLOSE_OTHER_SESSIONS;
    flags |= object.getFlags() & AbstractUserObject.LDAP_USER;
    object.setFlags(flags);
    // Authentication
    object.setAuthMethod(comboAuthMethod.getSelectionIndex());
    object.setCertMappingMethod(comboMappingMethod.getSelectionIndex());
    object.setCertMappingData(textMappingData.getText());
    if (isApply)
        setValid(false);
    new ConsoleJob(Messages.get().Authentication_JobTitle, null, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            session.modifyUserDBObject(object, AbstractUserObject.MODIFY_FLAGS | AbstractUserObject.MODIFY_AUTH_METHOD | AbstractUserObject.MODIFY_CERT_MAPPING);
        }

        @Override
        protected void jobFinalize() {
            if (isApply) {
                runInUIThread(new Runnable() {

                    @Override
                    public void run() {
                        Authentication.this.setValid(true);
                    }
                });
            }
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().Authentication_JobError;
        }
    }.start();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Example 9 with ConsoleJob

use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.

the class ExportDashboard method run.

/* (non-Javadoc)
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
	 */
@Override
public void run(IAction action) {
    if (dashboard == null)
        return;
    final Set<Long> objects = new HashSet<Long>();
    final Map<Long, Long> items = new HashMap<Long, Long>();
    // $NON-NLS-1$
    final StringBuilder xml = new StringBuilder("<dashboard>\n\t<name>");
    xml.append(dashboard.getObjectName());
    // $NON-NLS-1$
    xml.append("</name>\n\t<columns>");
    xml.append(dashboard.getNumColumns());
    // $NON-NLS-1$
    xml.append("</columns>\n\t<options>");
    xml.append(dashboard.getOptions());
    // $NON-NLS-1$
    xml.append("</options>\n\t<elements>\n");
    for (DashboardElement e : dashboard.getElements()) {
        // $NON-NLS-1$
        xml.append("\t\t<dashboardElement>\n\t\t\t<type>");
        xml.append(e.getType());
        // $NON-NLS-1$
        xml.append("</type>\n");
        xml.append(e.getLayout());
        xml.append('\n');
        xml.append(e.getData());
        // $NON-NLS-1$
        xml.append("\n\t\t</dashboardElement>\n");
        DashboardElementConfig config = (DashboardElementConfig) Platform.getAdapterManager().getAdapter(e, DashboardElementConfig.class);
        if (config != null) {
            objects.addAll(config.getObjects());
            items.putAll(config.getDataCollectionItems());
        }
    }
    // $NON-NLS-1$
    xml.append("\t</elements>\n");
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(Messages.get().ExportDashboard_JobTitle, wbPart, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            // Add object ID mapping
            // $NON-NLS-1$
            xml.append("\t<objectMap>\n");
            for (Long id : objects) {
                AbstractObject o = session.findObjectById(id);
                if (o != null) {
                    // $NON-NLS-1$
                    xml.append("\t\t<object id=\"");
                    xml.append(id);
                    // $NON-NLS-1$
                    xml.append("\" class=\"");
                    xml.append(o.getObjectClass());
                    // $NON-NLS-1$
                    xml.append("\">");
                    xml.append(o.getObjectName());
                    // $NON-NLS-1$
                    xml.append("</object>\n");
                }
            }
            // $NON-NLS-1$
            xml.append("\t</objectMap>\n\t<dciMap>\n");
            // Add DCI ID mapping
            long[] nodeList = new long[items.size()];
            long[] dciList = new long[items.size()];
            int pos = 0;
            for (Entry<Long, Long> dci : items.entrySet()) {
                dciList[pos] = dci.getKey();
                nodeList[pos] = dci.getValue();
                pos++;
            }
            String[] names = session.dciIdsToNames(nodeList, dciList);
            for (int i = 0; i < names.length; i++) {
                // $NON-NLS-1$
                xml.append("\t\t<dci id=\"");
                xml.append(dciList[i]);
                // $NON-NLS-1$
                xml.append("\" node=\"");
                xml.append(nodeList[i]);
                // $NON-NLS-1$
                xml.append("\">");
                xml.append(names[i]);
                // $NON-NLS-1$
                xml.append("</dci>\n");
            }
            // $NON-NLS-1$
            xml.append("\t</dciMap>\n</dashboard>\n");
            // $NON-NLS-1$
            OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(dashboard.getObjectName() + ".xml"), "UTF-8");
            try {
                out.write(xml.toString());
            } finally {
                out.close();
                final File dashboardFile = new File(dashboard.getObjectName() + ".xml");
                if (dashboardFile.length() > 0) {
                    DownloadServiceHandler.addDownload(dashboardFile.getName(), dashboardFile.getName(), dashboardFile, "application/octet-stream");
                    runInUIThread(new Runnable() {

                        @Override
                        public void run() {
                            DownloadServiceHandler.startDownload(dashboardFile.getName());
                        }
                    });
                }
            }
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().ExportDashboard_ErrorText;
        }
    }.start();
}
Also used : NXCSession(org.netxms.client.NXCSession) HashMap(java.util.HashMap) DashboardElement(org.netxms.client.dashboards.DashboardElement) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Entry(java.util.Map.Entry) DashboardElementConfig(org.netxms.ui.eclipse.dashboard.widgets.internal.DashboardElementConfig) AbstractObject(org.netxms.client.objects.AbstractObject) FileOutputStream(java.io.FileOutputStream) OutputStreamWriter(java.io.OutputStreamWriter) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) File(java.io.File) HashSet(java.util.HashSet)

Example 10 with ConsoleJob

use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.

the class DCISummaryTableSortColumnSelectionDialog method createDialogArea.

/* (non-Javadoc)
    * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
    */
@Override
protected Control createDialogArea(Composite parent) {
    Composite dialogArea = (Composite) super.createDialogArea(parent);
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob("Get summary table configuration by id", null, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            sourceSummaryTable = session.getDciSummaryTable(summaryTableId);
            runInUIThread(new Runnable() {

                @Override
                public void run() {
                    refresh();
                }
            });
        }

        @Override
        protected String getErrorMessage() {
            return "Unable to get summary table configuration";
        }
    }.start();
    GridLayout layout = new GridLayout();
    dialogArea.setLayout(layout);
    selector = new DCISummaryTableColumnSelector(dialogArea, SWT.NONE, AbstractSelector.SHOW_CLEAR_BUTTON, sortingColumn, null, sourceSummaryTable);
    selector.setLabel("Filter column name");
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalSpan = 520;
    selector.setLayoutData(gd);
    descSorting = new Button(dialogArea, SWT.CHECK);
    gd = new GridData();
    // gd.horizontalAlignment = SWT.FILL;
    // gd.grabExcessHorizontalSpace = true;
    descSorting.setText("Use descending sorting");
    descSorting.setLayoutData(gd);
    descSorting.setSelection(isDescSorting);
    return dialogArea;
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) GridLayout(org.eclipse.swt.layout.GridLayout) NXCSession(org.netxms.client.NXCSession) DCISummaryTableColumnSelector(org.netxms.ui.eclipse.dashboard.widgets.DCISummaryTableColumnSelector) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) 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