use of org.netxms.client.NXCObjectCreationData 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.NXCObjectCreationData in project netxms by netxms.
the class CreateNetworkMap method run.
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
@Override
public void run(IAction action) {
final CreateNetworkMapDialog dlg = new CreateNetworkMapDialog(window.getShell());
if (dlg.open() != Window.OK)
return;
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().CreateNetworkMap_JobName, part, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
NXCObjectCreationData cd = new NXCObjectCreationData(AbstractObject.OBJECT_NETWORKMAP, dlg.getName(), parentId);
cd.setMapType(dlg.getType());
cd.setSeedObjectId(dlg.getSeedObject());
session.createObject(cd);
}
@Override
protected String getErrorMessage() {
return String.format(Messages.get().CreateNetworkMap_JobError, dlg.getName());
}
}.start();
}
use of org.netxms.client.NXCObjectCreationData in project netxms by netxms.
the class TunnelManager method createNode.
/**
* Create new node and bind tunnel
*/
private void createNode() {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.size() != 1)
return;
final AgentTunnel tunnel = (AgentTunnel) selection.getFirstElement();
if (tunnel.isBound())
return;
CreateNodeDialog dlg = new CreateNodeDialog(getSite().getShell(), null);
dlg.setEnableShowAgainFlag(false);
dlg.setObjectName(tunnel.getSystemName());
dlg.setZoneUIN(tunnel.getZoneUIN());
if (dlg.open() != Window.OK)
return;
final NXCObjectCreationData cd = new NXCObjectCreationData(AbstractObject.OBJECT_NODE, dlg.getObjectName(), 2);
cd.setCreationFlags(dlg.getCreationFlags());
cd.setPrimaryName(dlg.getHostName());
cd.setAgentPort(dlg.getAgentPort());
cd.setSnmpPort(dlg.getSnmpPort());
cd.setAgentProxyId(dlg.getAgentProxy());
cd.setSnmpProxyId(dlg.getSnmpProxy());
cd.setIcmpProxyId(dlg.getIcmpProxy());
cd.setSshProxyId(dlg.getSshProxy());
cd.setZoneUIN(dlg.getZoneUIN());
cd.setSshLogin(dlg.getSshLogin());
cd.setSshPassword(dlg.getSshPassword());
final NXCSession session = ConsoleSharedData.getSession();
new ConsoleJob("Create new node and bind tunnel", this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
long nodeId = session.createObject(cd);
session.bindAgentTunnel(tunnel.getId(), nodeId);
final List<AgentTunnel> tunnels = session.getAgentTunnels();
runInUIThread(new Runnable() {
@Override
public void run() {
viewer.setInput(tunnels);
}
});
}
@Override
protected String getErrorMessage() {
return "Cannot create node and bind tunnel";
}
}.start();
}
use of org.netxms.client.NXCObjectCreationData in project netxms by netxms.
the class CreateContainer method run.
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
@Override
public void run(IAction action) {
final CreateObjectDialog dlg = new CreateObjectDialog(window.getShell(), Messages.get().CreateContainer_Container);
if (dlg.open() != Window.OK)
return;
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().CreateContainer_JobTitle, part, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
NXCObjectCreationData cd = new NXCObjectCreationData(AbstractObject.OBJECT_CONTAINER, dlg.getObjectName(), parentId);
session.createObject(cd);
}
@Override
protected String getErrorMessage() {
return String.format(Messages.get().CreateContainer_JobError, dlg.getObjectName());
}
}.start();
}
use of org.netxms.client.NXCObjectCreationData in project netxms by netxms.
the class CreateMobileDevice method run.
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
@Override
public void run(IAction action) {
final CreateMobileDeviceDialog dlg = new CreateMobileDeviceDialog(window.getShell());
if (dlg.open() != Window.OK)
return;
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().CreateMobileDevice_JobTitle, part, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
NXCObjectCreationData cd = new NXCObjectCreationData(AbstractObject.OBJECT_MOBILEDEVICE, dlg.getName(), parentId);
cd.setDeviceId(dlg.getDeviceId());
session.createObject(cd);
}
@Override
protected String getErrorMessage() {
return String.format(Messages.get().CreateMobileDevice_JobError, dlg.getName());
}
}.start();
}
Aggregations