use of org.netxms.client.NXCObjectModificationData in project netxms by netxms.
the class ImportDashboard method run.
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
@Override
public void run(IAction action) {
final ImportDashboardDialog dlg = new ImportDashboardDialog(window.getShell());
if (dlg.open() != Window.OK)
return;
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
final Display display = Display.getCurrent();
new ConsoleJob(Messages.get().ImportDashboard_JobTitle, part, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document dom = db.parse(dlg.getImportFile());
Element root = dom.getDocumentElement();
if (// $NON-NLS-1$
!root.getNodeName().equals("dashboard"))
throw new Exception(Messages.get().ImportDashboard_InvalidFile);
root.normalize();
List<DashboardElement> dashboardElements = new ArrayList<DashboardElement>();
// $NON-NLS-1$
NodeList elementsRoot = root.getElementsByTagName("elements");
for (int i = 0; i < elementsRoot.getLength(); i++) {
if (elementsRoot.item(i).getNodeType() != Node.ELEMENT_NODE)
continue;
// $NON-NLS-1$
NodeList elements = ((Element) elementsRoot.item(i)).getElementsByTagName("dashboardElement");
for (int j = 0; j < elements.getLength(); j++) {
Element e = (Element) elements.item(j);
// $NON-NLS-1$ //$NON-NLS-2$
DashboardElement de = new DashboardElement(getNodeValueAsInt(e, "type", 0), getNodeValueAsXml(e, "element"));
// $NON-NLS-1$
de.setLayout(getNodeValueAsXml(e, "layout"));
dashboardElements.add(de);
}
}
root.normalize();
objectName = dlg.getObjectName();
if (doIdMapping(display, session, dashboardElements, root)) {
NXCObjectCreationData cd = new NXCObjectCreationData(AbstractObject.OBJECT_DASHBOARD, objectName, parentId);
final long objectId = session.createObject(cd);
NXCObjectModificationData md = new NXCObjectModificationData(objectId);
// $NON-NLS-1$
md.setColumnCount(getNodeValueAsInt(root, "columns", 1));
// $NON-NLS-1$
md.setObjectFlags(getNodeValueAsInt(root, "options", 0));
md.setDashboardElements(dashboardElements);
session.modifyObject(md);
}
}
@Override
protected String getErrorMessage() {
return String.format(Messages.get().ImportDashboard_Error, dlg.getObjectName());
}
}.start();
}
use of org.netxms.client.NXCObjectModificationData in project netxms by netxms.
the class ConditionScript method applyChanges.
/**
* Apply changes
*
* @param isApply true if update operation caused by "Apply" button
*/
protected void applyChanges(final boolean isApply) {
if (initialScript.equals(filterSource.getText()))
// Nothing to apply
return;
if (isApply)
setValid(false);
final String newScript = filterSource.getText();
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
final NXCObjectModificationData md = new NXCObjectModificationData(object.getObjectId());
md.setScript(newScript);
new ConsoleJob(Messages.get().ConditionScript_JobName, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.modifyObject(md);
initialScript = newScript;
}
@Override
protected String getErrorMessage() {
return Messages.get().ConditionScript_JobError;
}
@Override
protected void jobFinalize() {
if (isApply) {
runInUIThread(new Runnable() {
@Override
public void run() {
ConditionScript.this.setValid(true);
}
});
}
}
}.start();
}
use of org.netxms.client.NXCObjectModificationData in project netxms by netxms.
the class General method applyChanges.
/**
* Apply changes
*
* @param isApply true if update operation caused by "Apply" button
*/
protected void applyChanges(final boolean isApply) {
if (isApply)
setValid(false);
final String newName = textName.getText();
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
final NXCObjectModificationData data = new NXCObjectModificationData(object.getObjectId());
data.setName(newName);
new ConsoleJob(Messages.get().General_JobName, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.modifyObject(data);
}
@Override
protected String getErrorMessage() {
return Messages.get().General_JobError;
}
@Override
protected void jobFinalize() {
if (isApply) {
runInUIThread(new Runnable() {
@Override
public void run() {
initialName = newName;
General.this.setValid(true);
}
});
}
}
}.start();
}
use of org.netxms.client.NXCObjectModificationData in project netxms by netxms.
the class InterfacePolling method applyChanges.
/**
* Apply changes
*
* @param isApply true if update operation caused by "Apply" button
*/
protected void applyChanges(final boolean isApply) {
if ((expectedState.getSelectionIndex() == currentExpectedState) && (pollCount.getSelection() == currentPollCount) && (checkExcludeFromTopology.getSelection() == currentExcludeFlag))
// nothing to change
return;
if (isApply)
setValid(false);
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
final NXCObjectModificationData data = new NXCObjectModificationData(object.getObjectId());
data.setExpectedState(expectedState.getSelectionIndex());
data.setRequiredPolls(pollCount.getSelection());
data.setObjectFlags(checkExcludeFromTopology.getSelection() ? Interface.IF_EXCLUDE_FROM_TOPOLOGY : 0, Interface.IF_EXCLUDE_FROM_TOPOLOGY);
new ConsoleJob(Messages.get().InterfacePolling_JobName, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.modifyObject(data);
}
@Override
protected String getErrorMessage() {
return String.format(Messages.get().InterfacePolling_JobError, object.getObjectName());
}
@Override
protected void jobFinalize() {
if (isApply) {
runInUIThread(new Runnable() {
@Override
public void run() {
currentExpectedState = data.getExpectedState();
currentPollCount = data.getRequiredPolls();
currentExcludeFlag = ((data.getObjectFlags() & Interface.IF_EXCLUDE_FROM_TOPOLOGY) != 0);
InterfacePolling.this.setValid(true);
}
});
}
}
}.start();
}
use of org.netxms.client.NXCObjectModificationData in project netxms by netxms.
the class AutoApply method applyChanges.
/**
* Apply changes
*
* @param isApply true if update operation caused by "Apply" button
*/
protected void applyChanges(final boolean isApply) {
int flags = object.getFlags();
if (checkboxEnableApply.getSelection())
flags |= Template.TF_AUTO_APPLY;
else
flags &= ~Template.TF_AUTO_APPLY;
if (checkboxEnableRemove.getSelection())
flags |= Template.TF_AUTO_REMOVE;
else
flags &= ~Template.TF_AUTO_REMOVE;
if ((flags == initialFlags) && initialApplyFilter.equals(filterSource.getText()))
// Nothing to apply
return;
if (isApply)
setValid(false);
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
final NXCObjectModificationData md = new NXCObjectModificationData(object.getObjectId());
md.setAutoBindFilter(filterSource.getText());
md.setObjectFlags(flags);
new ConsoleJob(Messages.get().AutoApply_JobName, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.modifyObject(md);
initialFlags = md.getObjectFlags();
initialApplyFilter = md.getAutoBindFilter();
}
@Override
protected void jobFinalize() {
if (isApply) {
runInUIThread(new Runnable() {
@Override
public void run() {
AutoApply.this.setValid(true);
}
});
}
}
@Override
protected String getErrorMessage() {
return Messages.get().AutoApply_JobError;
}
}.start();
}
Aggregations