use of org.netxms.client.objects.AbstractNode in project netxms by netxms.
the class ObjectPolling method applyChanges.
/**
* Apply changes
*
* @param isApply true if update operation caused by "Apply" button
*/
protected boolean applyChanges(final boolean isApply) {
final NXCObjectModificationData md = new NXCObjectModificationData(object.getObjectId());
if (object.containPollerNode())
md.setPollerNode(pollerNode.getObjectId());
md.setObjectFlags(collectNodeFlags(), collectNodeFlagsMask());
if (object.containInterfaces())
md.setIfXTablePolicy(collectIfXTablePolicy());
if (object.containAgent())
md.setAgentCacheMode(collectAgentCacheMode());
if (object instanceof AbstractNode)
md.setRequiredPolls(pollCount.getSelection());
if (isApply)
setValid(false);
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().NodePolling_JobName, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.modifyObject(md);
}
@Override
protected String getErrorMessage() {
return Messages.get().NodePolling_JobError;
}
@Override
protected void jobFinalize() {
if (isApply) {
runInUIThread(new Runnable() {
@Override
public void run() {
ObjectPolling.this.setValid(true);
}
});
}
}
}.start();
return true;
}
use of org.netxms.client.objects.AbstractNode in project netxms by netxms.
the class ObjectPopupDialog method createDialogArea.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.PopupDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
Composite dialogArea = (Composite) super.createDialogArea(parent);
statusLabel = new CLabel(dialogArea, SWT.NONE);
statusLabel.setText(StatusDisplayInfo.getStatusText(object.getStatus()).toUpperCase());
statusLabel.setForeground(StatusDisplayInfo.getStatusColor(object.getStatus()));
statusLabel.setFont(boldFont);
StringBuilder sb = new StringBuilder();
if (object instanceof AbstractNode) {
appendText(sb, ((AbstractNode) object).getPrimaryIP().getHostAddress());
appendText(sb, ((AbstractNode) object).getPlatformName());
String sd = ((AbstractNode) object).getSystemDescription();
if (sd.length() > 127)
// $NON-NLS-1$
sd = sd.substring(0, 127) + "...";
appendText(sb, sd);
appendText(sb, ((AbstractNode) object).getSnmpSysName());
appendText(sb, ((AbstractNode) object).getSnmpSysContact());
}
if (sb.length() > 0) {
createSeparator(dialogArea);
if (sb.charAt(sb.length() - 1) == '\n')
sb.deleteCharAt(sb.length() - 1);
CLabel infoText = new CLabel(dialogArea, SWT.MULTI);
infoText.setText(sb.toString());
}
if (object instanceof DataCollectionTarget) {
List<DciValue> values = ((DataCollectionTarget) object).getTooltipDciData();
if (!values.isEmpty()) {
createSeparator(dialogArea);
Composite group = new Composite(dialogArea, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.numColumns = 2;
group.setLayout(layout);
StringBuilder leftColumn = new StringBuilder();
StringBuilder rightColumn = new StringBuilder();
for (DciValue v : values) {
if (leftColumn.length() > 0) {
leftColumn.append('\n');
rightColumn.append('\n');
}
leftColumn.append(v.getDescription());
rightColumn.append(v.getValue());
}
new CLabel(group, SWT.MULTI).setText(leftColumn.toString());
new CLabel(group, SWT.MULTI).setText(rightColumn.toString());
}
}
if (!object.getComments().isEmpty()) {
createSeparator(dialogArea);
new CLabel(dialogArea, SWT.MULTI).setText(object.getComments());
}
return dialogArea;
}
use of org.netxms.client.objects.AbstractNode in project netxms by netxms.
the class Commands method onObjectChange.
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.objectview.objecttabs.elements.OverviewPageElement#onObjectChange()
*/
@Override
protected void onObjectChange() {
commandBox.deleteAll(false);
if (getObject() instanceof AbstractNode) {
ObjectTool[] tools = ObjectToolsCache.getInstance().getTools();
for (final ObjectTool tool : tools) {
if (!tool.isVisibleInCommands() || !tool.isEnabled() || !tool.isApplicableForNode((AbstractNode) getObject()))
continue;
final Set<ObjectContext> nodes = new HashSet<ObjectContext>(1);
nodes.add(new ObjectContext((AbstractNode) getObject(), null));
if (!ObjectToolExecutor.isToolAllowed(tool, nodes))
continue;
final Action action = new Action(tool.getCommandDisplayName()) {
@Override
public void run() {
ObjectToolExecutor.execute(nodes, tool);
}
};
ImageDescriptor icon = ObjectToolsCache.getInstance().findIcon(tool.getId());
if (icon != null)
action.setImageDescriptor(icon);
commandBox.add(action, false);
}
} else if (getObject() instanceof Interface) {
commandBox.add(actionWakeup, false);
}
commandBox.rebuild();
}
use of org.netxms.client.objects.AbstractNode in project netxms by netxms.
the class ObjectStatusRadialWidget method paintControl.
/* (non-Javadoc)
* @see org.eclipse.swt.events.PaintListener#paintControl(org.eclipse.swt.events.PaintEvent)
*/
@Override
public void paintControl(PaintEvent e) {
GC gc = e.gc;
gc.setAdvanced(true);
if (!gc.getAdvanced()) {
gc.drawText("Advanced graphics not supported", 30, 30, true);
return;
}
objectMap.clear();
leafObjectCount = calculateMaxLVLAndObjCount(rootObject, 1);
leafObjectSize = 360 / (float) leafObjectCount;
Rectangle rect = getClientArea();
rect.width--;
rect.height--;
gc.setAntialias(SWT.ON);
gc.setTextAntialias(SWT.ON);
gc.setForeground(SharedColors.getColor(SharedColors.TEXT_NORMAL, getDisplay()));
gc.setLineWidth(1);
// calculate values
int rectSide = Math.min(rect.width, rect.height);
diameter = rectSide / (maxLvl + 1);
centerX = rect.x + (rectSide / 2);
centerY = rect.y + (rectSide / 2);
// draw objects
drawParts(gc, rootObject, 2, 0);
// draw general oval with
// draw white oval
gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_WHITE));
gc.setAlpha(255);
gc.fillOval(centerX - diameter / 2 - 3, centerY - diameter / 2 - 3, diameter + 6, diameter + 6);
gc.setBackground(StatusDisplayInfo.getStatusColor(rootObject.getStatus()));
gc.setAlpha(255);
gc.fillOval(centerX - diameter / 2, centerY - diameter / 2, diameter, diameter);
final String text = (rootObject instanceof AbstractNode) ? // $NON-NLS-1$
(rootObject.getObjectName() + "\n" + ((AbstractNode) rootObject).getPrimaryIP().getHostAddress()) : rootObject.getObjectName();
gc.setClipping(rect);
int h = gc.textExtent(text).y;
int l = gc.textExtent(text).x;
gc.setForeground(ColorConverter.selectTextColorByBackgroundColor(StatusDisplayInfo.getStatusColor(rootObject.getStatus()), cCache));
gc.drawText(text, rect.x + (rectSide / 2) - l / 2, rect.y + (rectSide / 2) - h / 2, SWT.DRAW_TRANSPARENT | SWT.DRAW_DELIMITER);
objectMap.add(new ObjectPosition(0, 360, 1, rootObject));
}
use of org.netxms.client.objects.AbstractNode in project netxms by netxms.
the class SoftwareInventory method refresh.
/**
* Refresh list
*/
public void refresh() {
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().SoftwareInventory_JobName, viewPart, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
AbstractObject object = session.findObjectById(rootObjectId);
if (object instanceof AbstractNode) {
final List<SoftwarePackage> packages = session.getNodeSoftwarePackages(rootObjectId);
runInUIThread(new Runnable() {
@Override
public void run() {
viewer.setInput(packages.toArray());
}
});
} else {
final List<SoftwareInventoryNode> nodes = new ArrayList<SoftwareInventoryNode>();
for (final AbstractObject o : object.getAllChilds(AbstractObject.OBJECT_NODE)) {
try {
List<SoftwarePackage> packages = session.getNodeSoftwarePackages(o.getObjectId());
nodes.add(new SoftwareInventoryNode((Node) o, packages));
} catch (NXCException e) {
if (e.getErrorCode() != RCC.NO_SOFTWARE_PACKAGE_DATA)
throw e;
}
}
runInUIThread(new Runnable() {
@Override
public void run() {
viewer.setInput(nodes);
}
});
}
}
@Override
protected String getErrorMessage() {
return Messages.get().SoftwareInventory_JobError;
}
}.start();
}
Aggregations