use of org.netxms.client.NXCSession in project netxms by netxms.
the class OpenAgentConfig method run.
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
@Override
public void run(IAction action) {
IViewReference vr = window.getActivePage().findViewReference(AgentConfigEditorView.ID, Long.toString(nodeId));
if (vr != null) {
AgentConfigEditorView view = (AgentConfigEditorView) vr.getView(true);
if (view != null) {
window.getActivePage().activate(view);
}
} else {
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().OpenAgentConfig_GetConfig, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final String config = session.getAgentConfig(nodeId);
runInUIThread(new Runnable() {
@Override
public void run() {
try {
AgentConfigEditorView view = (AgentConfigEditorView) window.getActivePage().showView(AgentConfigEditorView.ID, Long.toString(nodeId), IWorkbenchPage.VIEW_ACTIVATE);
view.setConfig(config);
} catch (PartInitException e) {
MessageDialogHelper.openError(window.getShell(), Messages.get().OpenAgentConfig_Error, Messages.get().OpenAgentConfig_OpenErrorPrefix + e.getLocalizedMessage());
}
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().OpenAgentConfig_OpenError;
}
}.start();
}
}
use of org.netxms.client.NXCSession in project netxms by netxms.
the class AbstractHandler method login.
/**
* Login to NetXMS server
* @param login
* @param password
* @return SessionToken
*/
protected SessionToken login(String login, String password) throws Exception {
log.debug("Performing login to " + properties.getServerAddress() + ":" + properties.getServerPort());
session = new NXCSession(properties.getServerAddress(), properties.getServerPort());
session.connect();
session.login(login, (password == null) ? "" : password);
return SessionStore.getInstance(getServletContext()).registerSession(session);
}
use of org.netxms.client.NXCSession in project netxms by netxms.
the class ActionSelectionDialog method createDialogArea.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
final Composite dialogArea = (Composite) super.createDialogArea(parent);
GridLayout layout = new GridLayout();
layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
dialogArea.setLayout(layout);
viewer = new TableViewer(dialogArea, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new ActionSelectionDialogLabelProvider());
viewer.setComparator(new ViewerComparator() {
/* (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) {
return ((ServerAction) e1).getName().compareToIgnoreCase(((ServerAction) e2).getName());
}
});
final NXCSession session = ConsoleSharedData.getSession();
new ConsoleJob("Get server actions", null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final List<ServerAction> list = session.getActions();
runInUIThread(new Runnable() {
@Override
public void run() {
viewer.setInput(list.toArray());
}
});
}
@Override
protected String getErrorMessage() {
return "Cannot get server actions";
}
}.start();
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
gd.heightHint = 400;
viewer.getControl().setLayoutData(gd);
return dialogArea;
}
use of org.netxms.client.NXCSession in project netxms by netxms.
the class TunnelManager method refresh.
/**
* Refresh view
*/
private void refresh() {
final NXCSession session = ConsoleSharedData.getSession();
new ConsoleJob("Get list of active agent tunnels", this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final List<AgentTunnel> tunnels = session.getAgentTunnels();
runInUIThread(new Runnable() {
@Override
public void run() {
viewer.setInput(tunnels);
}
});
}
@Override
protected String getErrorMessage() {
return "Cannot get list of active agent tunnels";
}
}.start();
}
use of org.netxms.client.NXCSession 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;
}
Aggregations