Search in sources :

Example 11 with NXCSession

use of org.netxms.client.NXCSession in project netxms by netxms.

the class IdMatchingDialog method updateDciMapping.

/**
 * Update mapping for all DCIs of given node after node mapping change
 *
 * @param objData
 */
private void updateDciMapping(final ObjectIdMatchingData objData) {
    if (objData.dcis.size() == 0)
        return;
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(Messages.get().IdMatchingDialog_JobTitle, null, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            final DciValue[] dciValues = session.getLastValues(objData.dstId);
            runInUIThread(new Runnable() {

                @Override
                public void run() {
                    for (DciIdMatchingData d : objData.dcis) {
                        d.dstNodeId = objData.dstId;
                        d.dstDciId = 0;
                        d.dstName = null;
                        for (DciValue v : dciValues) {
                            if (v.getDescription().equalsIgnoreCase(d.srcName)) {
                                d.dstDciId = v.getId();
                                d.dstName = v.getDescription();
                                break;
                            }
                        }
                    }
                    viewer.refresh(true);
                }
            });
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().IdMatchingDialog_JobErrorText;
        }
    }.start();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) NXCSession(org.netxms.client.NXCSession) DciValue(org.netxms.client.datacollection.DciValue) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) DciIdMatchingData(org.netxms.ui.eclipse.dashboard.dialogs.helpers.DciIdMatchingData)

Example 12 with NXCSession

use of org.netxms.client.NXCSession in project netxms by netxms.

the class RegionalSettingsPrefPage method updateShortTimeExample.

/**
 * Update formatting example
 */
private void updateShortTimeExample(Control updatedControl) {
    DateFormat df;
    switch(format) {
        case RegionalSettings.DATETIME_FORMAT_SERVER:
            NXCSession session = (NXCSession) ConsoleSharedData.getSession();
            df = new SimpleDateFormat(session.getShortTimeFormat());
            break;
        case RegionalSettings.DATETIME_FORMAT_CUSTOM:
            try {
                df = new SimpleDateFormat(shortTimeFormatString.getText());
            } catch (IllegalArgumentException e) {
                setErrorMessage(e.getLocalizedMessage());
                if (updatedControl != null)
                    updatedControl.setBackground(SharedColors.getColor(SharedColors.ERROR_BACKGROUND, getShell().getDisplay()));
                return;
            }
            break;
        default:
            df = DateFormat.getTimeInstance(DateFormat.SHORT);
            break;
    }
    shortTimeExample.setText(df.format(new Date(System.currentTimeMillis())));
    setErrorMessage(null);
    shortTimeFormatString.getTextControl().setBackground(null);
}
Also used : NXCSession(org.netxms.client.NXCSession) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 13 with NXCSession

use of org.netxms.client.NXCSession in project netxms by netxms.

the class RegionalSettingsPrefPage method updateExample.

/**
 * Update formatting example
 */
private void updateExample(Control updatedControl) {
    DateFormat df;
    switch(format) {
        case RegionalSettings.DATETIME_FORMAT_SERVER:
            NXCSession session = ConsoleSharedData.getSession();
            // $NON-NLS-1$
            df = new SimpleDateFormat(session.getDateFormat() + " " + session.getTimeFormat());
            break;
        case RegionalSettings.DATETIME_FORMAT_CUSTOM:
            try {
                // $NON-NLS-1$
                df = new SimpleDateFormat(dateFormatString.getText() + " " + timeFormatString.getText());
            } catch (IllegalArgumentException e) {
                setErrorMessage(e.getLocalizedMessage());
                if (updatedControl != null)
                    updatedControl.setBackground(SharedColors.getColor(SharedColors.ERROR_BACKGROUND, getShell().getDisplay()));
                return;
            }
            break;
        default:
            df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM);
            break;
    }
    dateTimeExample.setText(df.format(new Date(System.currentTimeMillis())));
    setErrorMessage(null);
    dateFormatString.getTextControl().setBackground(null);
    timeFormatString.getTextControl().setBackground(null);
}
Also used : NXCSession(org.netxms.client.NXCSession) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 14 with NXCSession

use of org.netxms.client.NXCSession in project netxms by netxms.

the class CreateDashboard method run.

/* (non-Javadoc)
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
	 */
@Override
public void run(IAction action) {
    final CreateObjectDialog dlg = new CreateObjectDialog(window.getShell(), Messages.get().CreateDashboard_Dashboard);
    if (dlg.open() != Window.OK)
        return;
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(Messages.get().CreateDashboard_JobTitle, part, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            NXCObjectCreationData cd = new NXCObjectCreationData(AbstractObject.OBJECT_DASHBOARD, dlg.getObjectName(), parentId);
            session.createObject(cd);
        }

        @Override
        protected String getErrorMessage() {
            return String.format(Messages.get().CreateDashboard_Error, dlg.getObjectName());
        }
    }.start();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CreateObjectDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.CreateObjectDialog) NXCSession(org.netxms.client.NXCSession) NXCObjectCreationData(org.netxms.client.NXCObjectCreationData) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Example 15 with NXCSession

use of org.netxms.client.NXCSession in project netxms by netxms.

the class ObjectAlarmBrowser method createPartControl.

/* (non-Javadoc)
	 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
	 */
@Override
public void createPartControl(Composite parent) {
    parent.setLayout(new FillLayout());
    content = new CompositeWithMessageBar(parent, SWT.NONE);
    // $NON-NLS-1$
    alarmView = new AlarmList(this, content.getContent(), SWT.NONE, "ObjectAlarmBrowser", null);
    alarmView.setRootObjects(objects);
    if (objects.size() == 1) {
        NXCSession session = (NXCSession) ConsoleSharedData.getSession();
        setPartName(String.format(Messages.get().ObjectAlarmBrowser_Title, session.getObjectName(objects.get(0))));
    // content.hideMessage();
    } else {
        setPartName(Messages.get().ObjectAlarmBrowser_TitleMultipleObjects);
        showObjectList();
    }
    createActions();
    contributeToActionBars();
    getSite().setSelectionProvider(alarmView.getSelectionProvider());
}
Also used : NXCSession(org.netxms.client.NXCSession) AlarmList(org.netxms.ui.eclipse.alarmviewer.widgets.AlarmList) CompositeWithMessageBar(org.netxms.ui.eclipse.widgets.CompositeWithMessageBar) FillLayout(org.eclipse.swt.layout.FillLayout)

Aggregations

NXCSession (org.netxms.client.NXCSession)248 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)167 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)163 AbstractObject (org.netxms.client.objects.AbstractObject)54 NXCObjectModificationData (org.netxms.client.NXCObjectModificationData)45 PartInitException (org.eclipse.ui.PartInitException)31 NXCObjectCreationData (org.netxms.client.NXCObjectCreationData)28 List (java.util.List)26 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)22 NXCException (org.netxms.client.NXCException)22 ArrayList (java.util.ArrayList)19 GridData (org.eclipse.swt.layout.GridData)18 GridLayout (org.eclipse.swt.layout.GridLayout)17 Composite (org.eclipse.swt.widgets.Composite)17 CreateObjectDialog (org.netxms.ui.eclipse.objectbrowser.dialogs.CreateObjectDialog)15 AbstractNode (org.netxms.client.objects.AbstractNode)14 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)13 IOException (java.io.IOException)11 ObjectSelectionDialog (org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog)11 SelectionEvent (org.eclipse.swt.events.SelectionEvent)10