use of org.netxms.client.datacollection.DataCollectionObject in project netxms by netxms.
the class DataCollectionEditor method editSelectedObject.
/**
* Edit selected object
*/
private void editSelectedObject() {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.size() != 1)
return;
DataCollectionObject dco = (DataCollectionObject) selection.getFirstElement();
DialogData data = null;
if (!hideModificationWarnings && dco.getTemplateId() != 0) {
String message = DataCollectionObjectEditor.createModificationWarningMessage(dco);
if (message != null) {
data = MessageDialogHelper.openWarningWithCheckbox(getSite().getShell(), "Warning", "Don't show this message again", message);
hideModificationWarnings = data.getSaveSelection();
}
}
if ((data == null) || data.isOkPressed()) {
// $NON-NLS-1$
ExtendedPropertyDialog dlg = ExtendedPropertyDialog.createDialogOn(getSite().getShell(), null, dco, "");
dlg.createAllPages();
int result = dlg.open();
if (((DataCollectionObject) selection.getFirstElement()).isNewItem() && result != SWT.OK) {
viewer.remove(selection.getFirstElement());
}
}
}
use of org.netxms.client.datacollection.DataCollectionObject in project netxms by netxms.
the class DciComparator method compare.
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
int result;
DataCollectionObject dci1 = (DataCollectionObject) e1;
DataCollectionObject dci2 = (DataCollectionObject) e2;
// $NON-NLS-1$
int column = (Integer) ((SortableTableViewer) viewer).getTable().getSortColumn().getData("ID");
switch(column) {
case DataCollectionEditor.COLUMN_ID:
result = (int) (dci1.getId() - dci2.getId());
break;
case DataCollectionEditor.COLUMN_DESCRIPTION:
result = dci1.getDescription().compareToIgnoreCase(dci2.getDescription());
break;
case DataCollectionEditor.COLUMN_PARAMETER:
result = dci1.getName().compareToIgnoreCase(dci2.getName());
break;
case DataCollectionEditor.COLUMN_INTERVAL:
result = (int) (dci1.getComparablePollingInterval() - dci2.getComparablePollingInterval());
break;
case DataCollectionEditor.COLUMN_RETENTION:
result = (int) (dci1.getComparableRetentionTime() - dci2.getComparableRetentionTime());
break;
case DataCollectionEditor.COLUMN_ORIGIN:
case DataCollectionEditor.COLUMN_DATATYPE:
case DataCollectionEditor.COLUMN_STATUS:
case DataCollectionEditor.COLUMN_TEMPLATE:
final String text1 = labelProvider.getColumnText(e1, column);
final String text2 = labelProvider.getColumnText(e2, column);
if (text1 != null && text2 != null) {
result = text1.compareToIgnoreCase(text2);
} else {
if (text1 == null) {
if (text2 == null) {
result = 0;
} else {
result = -1;
}
} else {
result = 1;
}
}
break;
default:
result = 0;
break;
}
return (((SortableTableViewer) viewer).getTable().getSortDirection() == SWT.UP) ? result : -result;
}
use of org.netxms.client.datacollection.DataCollectionObject in project netxms by netxms.
the class StartDataRecalculation 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 ForceDciPoll 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 createPartControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
content = new Composite(parent, SWT.NONE);
content.setLayout(new FormLayout());
// Create filter area
filterText = new FilterText(content, SWT.NONE);
filterText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
onFilterModify();
}
});
final String[] names = { Messages.get().DataCollectionEditor_ColID, Messages.get().DataCollectionEditor_ColOrigin, Messages.get().DataCollectionEditor_ColDescription, Messages.get().DataCollectionEditor_ColParameter, Messages.get().DataCollectionEditor_ColDataType, Messages.get().DataCollectionEditor_ColPollingInterval, Messages.get().DataCollectionEditor_ColRetentionTime, Messages.get().DataCollectionEditor_ColStatus, Messages.get().DataCollectionEditor_ColThresholds, Messages.get().DataCollectionEditor_ColTemplate };
final int[] widths = { 60, 100, 250, 200, 90, 90, 90, 100, 200, 150 };
viewer = new SortableTableViewer(content, names, widths, 0, SWT.UP, SortableTableViewer.DEFAULT_STYLE);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new DciLabelProvider());
viewer.setComparator(new DciComparator((DciLabelProvider) viewer.getLabelProvider()));
filter = new DciFilter();
viewer.addFilter(filter);
// $NON-NLS-1$
WidgetHelper.restoreTableViewerSettings(viewer, settings, "DataCollectionEditor");
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
if (selection != null) {
actionEdit.setEnabled(selection.size() == 1);
actionDelete.setEnabled(selection.size() > 0);
actionCopy.setEnabled(selection.size() > 0);
actionMove.setEnabled(selection.size() > 0);
actionConvert.setEnabled(selection.size() > 0);
actionDuplicate.setEnabled(selection.size() > 0);
Iterator<?> it = selection.iterator();
boolean canActivate = false;
boolean canDisable = false;
while (it.hasNext() && (!canActivate || !canDisable)) {
DataCollectionObject dci = (DataCollectionObject) it.next();
if (dci.getStatus() != DataCollectionObject.ACTIVE)
canActivate = true;
if (dci.getStatus() != DataCollectionObject.DISABLED)
canDisable = true;
}
actionActivate.setEnabled(canActivate);
actionDisable.setEnabled(canDisable);
}
}
});
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
actionEdit.run();
}
});
viewer.getTable().addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
// $NON-NLS-1$
WidgetHelper.saveTableViewerSettings(viewer, settings, "DataCollectionEditor");
settings.put("DataCollectionEditor.hideModificationWarnings", hideModificationWarnings);
}
});
// Setup layout
FormData fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(filterText);
fd.right = new FormAttachment(100, 0);
fd.bottom = new FormAttachment(100, 0);
viewer.getTable().setLayoutData(fd);
fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(0, 0);
fd.right = new FormAttachment(100, 0);
filterText.setLayoutData(fd);
createActions();
contributeToActionBars();
createPopupMenu();
filterText.setCloseAction(new Action() {
@Override
public void run() {
enableFilter(false);
actionShowFilter.setChecked(false);
}
});
// Request server to open data collection configuration
new ConsoleJob(Messages.get().DataCollectionEditor_OpenJob_Title + object.getObjectName(), this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
dciConfig = session.openDataCollectionConfiguration(object.getObjectId());
dciConfig.setUserData(viewer);
runInUIThread(new Runnable() {
@Override
public void run() {
viewer.setInput(dciConfig.getItems());
}
});
}
@Override
protected void jobFailureHandler() {
runInUIThread(new Runnable() {
@Override
public void run() {
DataCollectionEditor.this.getViewSite().getPage().hideView(DataCollectionEditor.this);
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().DataCollectionEditor_OpenJob_Error + object.getObjectName();
}
}.start();
// Set initial focus to filter input line
if (actionShowFilter.isChecked())
filterText.setFocus();
else
// Will hide filter area correctly
enableFilter(false);
hideModificationWarnings = getBooleanFromSettings("DataCollectionEditor.hideModificationWarnings", false);
activateContext();
}
Aggregations