use of org.netxms.client.datacollection.DataCollectionObject in project netxms by netxms.
the class DataCollectionObjectPropertyTester method test.
/* (non-Javadoc)
* @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
*/
@Override
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
if (!(receiver instanceof DataCollectionObject))
return false;
if (// $NON-NLS-1$
property.equals("isClusterObject")) {
NXCSession session = (NXCSession) ConsoleSharedData.getSession();
AbstractObject owner = session.findObjectById(((DataCollectionObject) receiver).getNodeId());
if (owner instanceof Cluster)
return true;
if (owner instanceof AbstractNode) {
for (AbstractObject o : owner.getParentsAsArray()) {
if (o instanceof Cluster)
return true;
}
}
return false;
}
if (// $NON-NLS-1$
property.equals("isTemplateObject")) {
NXCSession session = (NXCSession) ConsoleSharedData.getSession();
AbstractObject owner = session.findObjectById(((DataCollectionObject) receiver).getNodeId());
return (owner instanceof Template);
}
return false;
}
use of org.netxms.client.datacollection.DataCollectionObject in project netxms by netxms.
the class ClearCollectedData method selectionChanged.
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
*/
@Override
public void selectionChanged(IAction action, ISelection selection) {
Set<DCI> dciList = null;
if (selection instanceof IStructuredSelection) {
dciList = new HashSet<DCI>();
for (Object o : ((IStructuredSelection) selection).toList()) {
if (o instanceof DciValue) {
dciList.add(new DCI(((DciValue) o).getNodeId(), ((DciValue) o).getId()));
} else if (o instanceof DataCollectionObject) {
dciList.add(new DCI(((DataCollectionObject) o).getNodeId(), ((DataCollectionObject) o).getId()));
} else {
dciList = null;
break;
}
}
}
objects = dciList;
action.setEnabled((objects != null) && (objects.size() > 0));
}
use of org.netxms.client.datacollection.DataCollectionObject 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();
}
use of org.netxms.client.datacollection.DataCollectionObject 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();
}
use of org.netxms.client.datacollection.DataCollectionObject 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();
}
Aggregations