use of org.netxms.client.objects.AbstractObject in project netxms by netxms.
the class TableColumns method queryColumns.
/**
* Query columns from agent
*/
private void queryColumns() {
if (!MessageDialogHelper.openQuestion(getShell(), "Warning", "Current column definition will be replaced by definition provided by agent. Continue?"))
return;
AbstractObject object = ConsoleSharedData.getSession().findObjectById(dci.getNodeId());
if ((editor.getSourceNode() == 0) && ((object instanceof Template) || (object instanceof Cluster))) {
ObjectSelectionDialog dlg = new ObjectSelectionDialog(getShell(), null, ObjectSelectionDialog.createNodeSelectionFilter(false));
if (dlg.open() != Window.OK)
return;
object = dlg.getSelectedObjects().get(0);
}
updateColumnsFromAgent(dci.getName(), true, object);
}
use of org.netxms.client.objects.AbstractObject 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.objects.AbstractObject in project netxms by netxms.
the class RuleEditor method createConditionControl.
/**
* Create condition summary control
*
* @param parent
* @param rule
* @return
*/
private Control createConditionControl(Composite parent, final EventProcessingPolicyRule rule) {
Composite clientArea = new Composite(parent, SWT.NONE);
clientArea.setBackground(SharedColors.getColor(SharedColors.RULE_EDITOR_BACKGROUND, getDisplay()));
GridLayout layout = new GridLayout();
layout.verticalSpacing = 0;
clientArea.setLayout(layout);
boolean needAnd = false;
if (((rule.getSources().size() > 0) && rule.isSourceInverted()) || ((rule.getSources().size() == 0) && (rule.getEvents().size() > 0) && rule.isEventsInverted()))
createLabel(clientArea, 0, true, Messages.get().RuleEditor_IF_NOT, null);
else
createLabel(clientArea, 0, true, Messages.get().RuleEditor_IF, null);
/* source */
if (rule.getSources().size() > 0) {
// $NON-NLS-1$
final MouseListener listener = createMouseListener("org.netxms.ui.eclipse.epp.propertypages.RuleSourceObjects#0");
addConditionGroupLabel(clientArea, Messages.get().RuleEditor_SourceIs, needAnd, rule.isSourceInverted(), listener);
for (Long id : rule.getSources()) {
CLabel clabel = createCLabel(clientArea, 2, false);
clabel.addMouseListener(listener);
AbstractObject object = session.findObjectById(id);
if (object != null) {
clabel.setText(object.getObjectName());
clabel.setImage(labelProvider.getImage(object));
} else {
// $NON-NLS-1$ //$NON-NLS-2$
clabel.setText("[" + id.toString() + "]");
clabel.setImage(SharedIcons.IMG_UNKNOWN_OBJECT);
}
}
needAnd = true;
}
/* events */
if (rule.getEvents().size() > 0) {
// $NON-NLS-1$
final MouseListener listener = createMouseListener("org.netxms.ui.eclipse.epp.propertypages.RuleEvents#10");
addConditionGroupLabel(clientArea, Messages.get().RuleEditor_EventIs, needAnd, rule.isEventsInverted(), listener);
List<EventObject> sortedEvents = new ArrayList<EventObject>(rule.getEvents().size());
for (Long code : rule.getEvents()) {
EventObject event = session.findEventObjectByCode(code);
if (event == null) {
event = new EventTemplate(code);
((EventTemplate) event).setSeverity(Severity.UNKNOWN);
// $NON-NLS-1$ //$NON-NLS-2$
event.setName("<" + code.toString() + ">");
}
sortedEvents.add(event);
}
Collections.sort(sortedEvents, new Comparator<EventObject>() {
@Override
public int compare(EventObject t1, EventObject t2) {
return t1.getName().compareToIgnoreCase(t2.getName());
}
});
for (EventObject e : sortedEvents) {
CLabel clabel = createCLabel(clientArea, 2, false);
clabel.addMouseListener(listener);
clabel.setText(e.getName());
if (e instanceof EventTemplate)
clabel.setImage(StatusDisplayInfo.getStatusImage(((EventTemplate) e).getSeverity()));
else
clabel.setImage(SharedIcons.IMG_CONTAINER);
}
needAnd = true;
}
/* severity */
if ((rule.getFlags() & EventProcessingPolicyRule.SEVERITY_ANY) != EventProcessingPolicyRule.SEVERITY_ANY) {
// $NON-NLS-1$
final MouseListener listener = createMouseListener("org.netxms.ui.eclipse.epp.propertypages.RuleSeverityFilter#20");
addConditionGroupLabel(clientArea, Messages.get().RuleEditor_SeverityIs, needAnd, false, listener);
if ((rule.getFlags() & EventProcessingPolicyRule.SEVERITY_NORMAL) != 0)
addSeverityLabel(clientArea, Severity.NORMAL, listener);
if ((rule.getFlags() & EventProcessingPolicyRule.SEVERITY_WARNING) != 0)
addSeverityLabel(clientArea, Severity.WARNING, listener);
if ((rule.getFlags() & EventProcessingPolicyRule.SEVERITY_MINOR) != 0)
addSeverityLabel(clientArea, Severity.MINOR, listener);
if ((rule.getFlags() & EventProcessingPolicyRule.SEVERITY_MAJOR) != 0)
addSeverityLabel(clientArea, Severity.MAJOR, listener);
if ((rule.getFlags() & EventProcessingPolicyRule.SEVERITY_CRITICAL) != 0)
addSeverityLabel(clientArea, Severity.CRITICAL, listener);
needAnd = true;
}
/* script */
if ((rule.getScript() != null) && !rule.getScript().isEmpty()) {
// $NON-NLS-1$
final MouseListener listener = createMouseListener("org.netxms.ui.eclipse.epp.propertypages.RuleFilterScript#30");
addConditionGroupLabel(clientArea, Messages.get().RuleEditor_ScriptIs, needAnd, false, listener);
ScriptEditor scriptEditor = new ScriptEditor(clientArea, SWT.BORDER, SWT.NONE);
GridData gd = new GridData();
gd.horizontalIndent = INDENT * 2;
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
scriptEditor.setLayoutData(gd);
scriptEditor.setText(rule.getScript());
scriptEditor.getTextWidget().setEditable(false);
scriptEditor.getTextWidget().addMouseListener(listener);
}
return clientArea;
}
use of org.netxms.client.objects.AbstractObject in project netxms by netxms.
the class ObjectGeoLocationViewer method mouseHover.
/* (non-Javadoc)
* @see org.eclipse.swt.events.MouseTrackListener#mouseHover(org.eclipse.swt.events.MouseEvent)
*/
@Override
public void mouseHover(MouseEvent e) {
if (// ignore hover if tooltip already open
objectTooltipRectangle == null) {
AbstractObject object = getObjectAtPoint(new Point(e.x, e.y));
if (object != currentObject) {
objectToolTipLocation = (object != null) ? new Point(e.x, e.y) : null;
setCurrentObject(object);
}
}
}
use of org.netxms.client.objects.AbstractObject in project netxms by netxms.
the class PackageManager method deployPackage.
/**
* Deploy package on managed nodes
*/
private void deployPackage() {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.size() != 1)
return;
final PackageInfo pkg = (PackageInfo) selection.getFirstElement();
ObjectSelectionDialog dlg = new ObjectSelectionDialog(getSite().getShell(), null, ObjectSelectionDialog.createNodeSelectionFilter(false));
dlg.enableMultiSelection(true);
if (dlg.open() != Window.OK)
return;
final Set<Long> objects = new HashSet<Long>();
for (AbstractObject o : dlg.getSelectedObjects()) {
objects.add(o.getObjectId());
}
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
ConsoleJob job = new ConsoleJob(Messages.get().PackageManager_DeployAgentPackage, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.deployPackage(pkg.getId(), objects.toArray(new Long[objects.size()]), new PackageDeploymentListener() {
private PackageDeploymentMonitor monitor = null;
@Override
public void statusUpdate(long nodeId, int status, String message) {
if (monitor != null)
monitor.viewStatusUpdate(nodeId, status, message);
}
@Override
public void deploymentStarted() {
final Object sync = new Object();
synchronized (sync) {
runInUIThread(new Runnable() {
@Override
public void run() {
try {
monitor = (PackageDeploymentMonitor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(PackageDeploymentMonitor.ID, toString(), IWorkbenchPage.VIEW_ACTIVATE);
monitor.setPackageId(pkg.getId());
} catch (PartInitException e) {
MessageDialogHelper.openError(getSite().getShell(), Messages.get().PackageManager_Error, Messages.get().PackageManager_ErrorOpenView + e.getLocalizedMessage());
}
synchronized (sync) {
sync.notify();
}
}
});
try {
sync.wait();
} catch (InterruptedException e) {
}
}
}
@Override
public void deploymentComplete() {
runInUIThread(new Runnable() {
@Override
public void run() {
MessageDialogHelper.openInformation(getSite().getShell(), Messages.get().PackageManager_Information, Messages.get().PackageManager_PkgDepCompleted);
}
});
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().PackageManager_DepStartError;
}
};
job.setUser(false);
job.start();
}
Aggregations