Search in sources :

Example 36 with ConsoleJob

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

the class SummaryTableGeneral method applyChanges.

/**
 * Apply changes
 *
 * @param isApply true if update operation caused by "Apply" button
 */
protected void applyChanges(final boolean isApply) {
    if (isApply)
        setValid(false);
    table.setMenuPath(menuPath.getText());
    table.setTitle(title.getText());
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(Messages.get().SummaryTableGeneral_JobName, null, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            synchronized (table) {
                int id = session.modifyDciSummaryTable(table);
                table.setId(id);
            }
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().SummaryTableGeneral_JobError;
        }

        /* (non-Javadoc)
			 * @see org.netxms.ui.eclipse.jobs.ConsoleJob#jobFinalize()
			 */
        @Override
        protected void jobFinalize() {
            if (isApply) {
                runInUIThread(new Runnable() {

                    @Override
                    public void run() {
                        SummaryTableGeneral.this.setValid(true);
                    }
                });
            }
        }
    }.start();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) NXCSession(org.netxms.client.NXCSession) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Example 37 with ConsoleJob

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

the class DataCollectionEditor method copyItems.

/**
 * Copy items to another node
 */
private void copyItems(final boolean doMove) {
    final ObjectSelectionDialog dlg = new ObjectSelectionDialog(getSite().getShell(), null, ObjectSelectionDialog.createNodeAndTemplateSelectionFilter(true));
    if (dlg.open() != Window.OK)
        return;
    IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
    Iterator<?> it = selection.iterator();
    final long[] dciList = new long[selection.size()];
    for (int i = 0; (i < dciList.length) && it.hasNext(); i++) dciList[i] = ((DataCollectionObject) it.next()).getId();
    new ConsoleJob(Messages.get().DataCollectionEditor_CopyJob_Title + object.getObjectName(), this, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            for (AbstractObject o : dlg.getSelectedObjects(AbstractNode.class)) dciConfig.copyObjects(o.getObjectId(), dciList);
            for (AbstractObject o : dlg.getSelectedObjects(Template.class)) dciConfig.copyObjects(o.getObjectId(), dciList);
            for (AbstractObject o : dlg.getSelectedObjects(Cluster.class)) dciConfig.copyObjects(o.getObjectId(), dciList);
            for (AbstractObject o : dlg.getSelectedObjects(MobileDevice.class)) dciConfig.copyObjects(o.getObjectId(), dciList);
            for (AbstractObject o : dlg.getSelectedObjects(Sensor.class)) dciConfig.copyObjects(o.getObjectId(), dciList);
            if (doMove) {
                for (long id : dciList) dciConfig.deleteObject(id);
                runInUIThread(new Runnable() {

                    @Override
                    public void run() {
                        viewer.setInput(dciConfig.getItems());
                    }
                });
            }
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().DataCollectionEditor_CopyJob_Error + object.getObjectName();
        }
    }.start();
}
Also used : AbstractNode(org.netxms.client.objects.AbstractNode) DataCollectionObject(org.netxms.client.datacollection.DataCollectionObject) Cluster(org.netxms.client.objects.Cluster) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) PartInitException(org.eclipse.ui.PartInitException) NXCException(org.netxms.client.NXCException) Template(org.netxms.client.objects.Template) ObjectSelectionDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) MobileDevice(org.netxms.client.objects.MobileDevice) AbstractObject(org.netxms.client.objects.AbstractObject) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) Sensor(org.netxms.client.objects.Sensor)

Example 38 with ConsoleJob

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

the class DataCollectionEditor method deleteItems.

/**
 * Delete currently selected DCIs
 */
private void deleteItems() {
    final IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
    if (selection.size() <= 0)
        return;
    if (!MessageDialogHelper.openConfirm(getSite().getShell(), Messages.get().DataCollectionEditor_DeleteConfirmTitle, Messages.get().DataCollectionEditor_DeleteConfirmText))
        return;
    new ConsoleJob(Messages.get().DataCollectionEditor_DeleteJob_Title + object.getObjectName(), this, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            for (Object dci : selection.toList()) {
                dciConfig.deleteObject(((DataCollectionObject) dci).getId());
            }
            runInUIThread(new Runnable() {

                @Override
                public void run() {
                    viewer.setInput(dciConfig.getItems());
                }
            });
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().DataCollectionEditor_DeleteJob_Error + object.getObjectName();
        }
    }.start();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) DataCollectionObject(org.netxms.client.datacollection.DataCollectionObject) AbstractObject(org.netxms.client.objects.AbstractObject) DataCollectionObject(org.netxms.client.datacollection.DataCollectionObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) PartInitException(org.eclipse.ui.PartInitException) NXCException(org.netxms.client.NXCException)

Example 39 with ConsoleJob

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

the class DataCollectionEditor method setItemStatus.

/**
 * Change status for selected items
 *
 * @param newStatus New status
 */
private void setItemStatus(final int newStatus) {
    final IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
    if (selection.size() <= 0)
        return;
    new ConsoleJob(Messages.get().DataCollectionEditor_ChStatusJob_Title + object.getObjectName(), this, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            final long[] itemList = new long[selection.size()];
            int pos = 0;
            for (Object dci : selection.toList()) {
                itemList[pos++] = ((DataCollectionObject) dci).getId();
            }
            dciConfig.setObjectStatus(itemList, newStatus);
            runInUIThread(new Runnable() {

                @Override
                public void run() {
                    for (Object dci : selection.toList()) {
                        ((DataCollectionObject) dci).setStatus(newStatus);
                        viewer.update(dci, null);
                        new DataCollectionObjectEditor((DataCollectionObject) dci).modify();
                    }
                }
            });
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().DataCollectionEditor_ChStatusJob_Error + object.getObjectName();
        }
    }.start();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) DataCollectionObject(org.netxms.client.datacollection.DataCollectionObject) DataCollectionObjectEditor(org.netxms.ui.eclipse.datacollection.api.DataCollectionObjectEditor) AbstractObject(org.netxms.client.objects.AbstractObject) DataCollectionObject(org.netxms.client.datacollection.DataCollectionObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) PartInitException(org.eclipse.ui.PartInitException) NXCException(org.netxms.client.NXCException)

Example 40 with ConsoleJob

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

the class PackageManager method createPartControl.

/* (non-Javadoc)
	 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
	 */
@Override
public void createPartControl(Composite parent) {
    final String[] names = { Messages.get().PackageManager_ColumnID, Messages.get().PackageManager_ColumnName, Messages.get().PackageManager_ColumnVersion, Messages.get().PackageManager_ColumnPlatform, Messages.get().PackageManager_ColumnFile, Messages.get().PackageManager_ColumnDescription };
    final int[] widths = { 70, 120, 90, 120, 150, 400 };
    viewer = new SortableTableViewer(parent, names, widths, COLUMN_ID, SWT.UP, SWT.FULL_SELECTION | SWT.MULTI);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new PackageLabelProvider());
    viewer.setComparator(new PackageComparator());
    createActions();
    contributeToActionBars();
    createPopupMenu();
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
            actionDeploy.setEnabled(selection.size() == 1);
            actionRemove.setEnabled(selection.size() > 0);
        }
    });
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(Messages.get().PackageManager_OpenDatabase, this, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            try {
                session.lockPackageDatabase();
            } catch (NXCException e) {
                // New versions may not require package DB lock
                if (e.getErrorCode() != RCC.NOT_IMPLEMENTED)
                    throw e;
            }
            runInUIThread(new Runnable() {

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

        @Override
        protected String getErrorMessage() {
            return Messages.get().PackageManager_OpenError;
        }
    }.start();
}
Also used : NXCSession(org.netxms.client.NXCSession) PackageComparator(org.netxms.ui.eclipse.agentmanager.views.helpers.PackageComparator) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) PackageLabelProvider(org.netxms.ui.eclipse.agentmanager.views.helpers.PackageLabelProvider) PartInitException(org.eclipse.ui.PartInitException) IOException(java.io.IOException) NXCException(org.netxms.client.NXCException) NXCException(org.netxms.client.NXCException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) 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