use of org.netxms.client.AgentTunnel in project netxms by netxms.
the class TunnelManager method fillContextMenu.
/**
* Fill context menu
* @param manager Menu manager
*/
protected void fillContextMenu(IMenuManager manager) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if ((selection.size() == 1) && !((AgentTunnel) selection.getFirstElement()).isBound()) {
manager.add(actionBind);
manager.add(actionCreateNode);
} else {
for (Object o : selection.toList()) {
if (((AgentTunnel) o).isBound()) {
manager.add(actionUnbind);
break;
}
}
}
manager.add(actionShowFilter);
}
use of org.netxms.client.AgentTunnel in project netxms by netxms.
the class TunnelListComparator 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) {
AgentTunnel t1 = (AgentTunnel) e1;
AgentTunnel t2 = (AgentTunnel) e2;
int result;
switch(// $NON-NLS-1$
(Integer) ((SortableTableViewer) viewer).getTable().getSortColumn().getData("ID")) {
case TunnelManager.COL_AGENT_VERSION:
result = t1.getAgentVersion().compareToIgnoreCase(t2.getAgentVersion());
break;
case TunnelManager.COL_CHANNELS:
result = t1.getActiveChannelCount() - t2.getActiveChannelCount();
break;
case TunnelManager.COL_ID:
result = t1.getId() - t2.getId();
break;
case TunnelManager.COL_IP_ADDRESS:
result = ComparatorHelper.compareInetAddresses(t1.getAddress(), t2.getAddress());
break;
case TunnelManager.COL_NODE:
NXCSession session = ConsoleSharedData.getSession();
result = session.getObjectName(t1.getNodeId()).compareToIgnoreCase(session.getObjectName(t2.getNodeId()));
break;
case TunnelManager.COL_PLATFORM:
result = t1.getPlatformName().compareToIgnoreCase(t2.getPlatformName());
break;
case TunnelManager.COL_STATE:
result = (t1.isBound() ? 1 : 0) - (t2.isBound() ? 1 : 0);
break;
case TunnelManager.COL_SYSINFO:
result = t1.getSystemInformation().compareToIgnoreCase(t2.getSystemInformation());
break;
case TunnelManager.COL_SYSNAME:
result = t1.getSystemName().compareToIgnoreCase(t2.getSystemName());
break;
default:
result = 0;
}
return (((SortableTableViewer) viewer).getTable().getSortDirection() == SWT.UP) ? result : -result;
}
use of org.netxms.client.AgentTunnel in project netxms by netxms.
the class TunnelManager method bindTunnel.
/**
* Bind tunnel to node
*/
private void bindTunnel() {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.size() != 1)
return;
final AgentTunnel tunnel = (AgentTunnel) selection.getFirstElement();
if (tunnel.isBound())
return;
ObjectSelectionDialog dlg = new ObjectSelectionDialog(getSite().getShell(), null, ObjectSelectionDialog.createNodeSelectionFilter(false));
if (dlg.open() != Window.OK)
return;
final long nodeId = dlg.getSelectedObjects().get(0).getObjectId();
final NXCSession session = ConsoleSharedData.getSession();
new ConsoleJob("Bind tunnels", this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
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 bind tunnel";
}
}.start();
}
use of org.netxms.client.AgentTunnel 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.AgentTunnel in project netxms by netxms.
the class TunnelManager method unbindTunnel.
/**
* Unbind tunnel
*/
private void unbindTunnel() {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.isEmpty())
return;
if (!MessageDialogHelper.openQuestion(getSite().getShell(), "Unbind Tunnel", "Selected tunnels will be unbound. Are you sure?"))
return;
final Object[] tunnels = selection.toArray();
final NXCSession session = ConsoleSharedData.getSession();
new ConsoleJob("Unbind tunnels", this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
for (Object o : tunnels) {
AgentTunnel t = (AgentTunnel) o;
if (!t.isBound())
continue;
session.unbindAgentTunnel(t.getNodeId());
}
final List<AgentTunnel> tunnels = session.getAgentTunnels();
runInUIThread(new Runnable() {
@Override
public void run() {
viewer.setInput(tunnels);
}
});
}
@Override
protected String getErrorMessage() {
return "Cannot unbind tunnel";
}
}.start();
}
Aggregations