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();
}
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);
}
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);
}
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();
}
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());
}
Aggregations