use of org.netxms.client.SessionNotification in project netxms by netxms.
the class DashboardNavigator method createPartControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
session = (NXCSession) ConsoleSharedData.getSession();
final Set<Integer> classFilter = new HashSet<Integer>(2);
classFilter.add(AbstractObject.OBJECT_DASHBOARDGROUP);
classFilter.add(AbstractObject.OBJECT_DASHBOARD);
objectTree = new ObjectTree(parent, SWT.NONE, ObjectTree.NONE, getRootObjects(classFilter), classFilter, false, true);
objectTree.enableFilter(false);
objectTree.getTreeViewer().expandToLevel(2);
createActions();
contributeToActionBars();
createPopupMenu();
getSite().setSelectionProvider(objectTree.getTreeViewer());
sessionListener = new SessionListener() {
@Override
public void notificationHandler(SessionNotification n) {
if ((n.getCode() == SessionNotification.OBJECT_CHANGED) && (n.getObject() instanceof DashboardRoot)) {
objectTree.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
refresh();
}
});
}
}
};
session.addListener(sessionListener);
}
use of org.netxms.client.SessionNotification in project netxms by netxms.
the class MappingTables method createPartControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
final int[] widths = { 80, 160, 80, 400 };
final String[] names = { Messages.get().MappingTables_ColID, Messages.get().MappingTables_ColName, Messages.get().MappingTables_ColFlags, Messages.get().MappingTables_ColDescription };
viewer = new SortableTableViewer(parent, names, widths, COLUMN_NAME, SWT.UP, SWT.FULL_SELECTION | SWT.MULTI);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new MappingTableListLabelProvider());
viewer.setComparator(new MappingTableListComparator());
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
editTable();
}
});
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
actionEditTable.setEnabled(selection.size() == 1);
actionDeleteTables.setEnabled(selection.size() > 0);
}
});
final IDialogSettings settings = Activator.getDefault().getDialogSettings();
// $NON-NLS-1$
WidgetHelper.restoreTableViewerSettings(viewer, settings, "MappingTablesList");
viewer.getTable().addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
// $NON-NLS-1$
WidgetHelper.saveTableViewerSettings(viewer, settings, "MappingTablesList");
}
});
createActions();
contributeToActionBars();
createPopupMenu();
session = ConsoleSharedData.getSession();
refresh(0);
final Display display = getSite().getShell().getDisplay();
listener = new SessionListener() {
@Override
public void notificationHandler(SessionNotification n) {
if (n.getCode() == SessionNotification.MAPPING_TABLE_UPDATED) {
final Integer id = (int) n.getSubCode();
display.asyncExec(new Runnable() {
@Override
public void run() {
refresh(id);
}
});
} else if (n.getCode() == SessionNotification.MAPPING_TABLE_DELETED) {
final Integer id = (int) n.getSubCode();
display.asyncExec(new Runnable() {
@Override
public void run() {
mappingTables.remove(id);
viewer.setInput(mappingTables.values().toArray());
}
});
}
}
};
session.addListener(listener);
}
use of org.netxms.client.SessionNotification in project netxms by netxms.
the class ServerJobManager method createPartControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
final String[] names = { Messages.get().ServerJobManager_ColStatus, Messages.get().ServerJobManager_ColInitiator, Messages.get().ServerJobManager_ColNode, Messages.get().ServerJobManager_ColDescription, Messages.get().ServerJobManager_ColProgress, Messages.get().ServerJobManager_ColMessage };
final int[] widths = { 80, 100, 150, 250, 100, 300 };
viewer = new SortableTableViewer(parent, names, widths, 0, SWT.DOWN, SortableTableViewer.DEFAULT_STYLE);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new ServerJobLabelProvider());
viewer.setComparator(new ServerJobComparator());
WidgetHelper.restoreTableViewerSettings(viewer, Activator.getDefault().getDialogSettings(), TABLE_CONFIG_PREFIX);
createActions();
contributeToActionBars();
createPopupMenu();
session = (NXCSession) ConsoleSharedData.getSession();
viewer.getTable().addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
WidgetHelper.saveTableViewerSettings(viewer, Activator.getDefault().getDialogSettings(), TABLE_CONFIG_PREFIX);
}
});
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
if (selection != null) {
actionCancelJob.setEnabled(selection.size() > 0);
actionHoldJob.setEnabled(selection.size() > 0);
actionUnholdJob.setEnabled(selection.size() > 0);
}
}
});
// Create listener for notifications received from server via client library
clientListener = new SessionListener() {
@Override
public void notificationHandler(SessionNotification n) {
if (n.getCode() != SessionNotification.JOB_CHANGE)
return;
refreshJobList(false);
}
};
session.addListener(clientListener);
refreshJobList(false);
}
use of org.netxms.client.SessionNotification in project netxms by netxms.
the class UserManagementView method createPartControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
session = ConsoleSharedData.getSession();
final String[] names = { Messages.get().UserManagementView_Name, Messages.get().UserManagementView_Type, Messages.get().UserManagementView_FullName, Messages.get().UserManagementView_Description, Messages.get().UserManagementView_Source, Messages.get().UserManagementView_Authentication, Messages.get().UserManagementView_GUID, "LDAP DN", "Last Login", "Created" };
final int[] widths = { 100, 80, 180, 250, 80, 170, 250, 400, 250, 250 };
viewer = new SortableTableViewer(parent, names, widths, 0, SWT.UP, SortableTableViewer.DEFAULT_STYLE);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new UserLabelProvider());
viewer.setComparator(new UserComparator());
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
if (selection != null) {
actionEditUser.setEnabled(selection.size() == 1);
actionChangePassword.setEnabled((selection.size() == 1) && (selection.getFirstElement() instanceof User));
actionDeleteUser.setEnabled(selection.size() > 0);
}
}
});
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
actionEditUser.run();
}
});
makeActions();
contributeToActionBars();
createPopupMenu();
// Listener for server's notifications
sessionListener = new SessionListener() {
@Override
public void notificationHandler(final SessionNotification n) {
if (n.getCode() == SessionNotification.USER_DB_CHANGED) {
viewer.getControl().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
viewer.setInput(session.getUserDatabaseObjects());
if (editNewUser && (n.getSubCode() == SessionNotification.USER_DB_OBJECT_CREATED)) {
editNewUser = false;
viewer.setSelection(new StructuredSelection(n.getObject()), true);
actionEditUser.run();
}
}
});
}
}
};
// Request server to lock user database, and on success refresh view
new ConsoleJob(Messages.get().UserManagementView_OpenJobName, this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.lockUserDatabase();
databaseLocked = true;
runInUIThread(new Runnable() {
@Override
public void run() {
viewer.setInput(session.getUserDatabaseObjects());
session.addListener(sessionListener);
}
});
}
@Override
protected void jobFailureHandler() {
runInUIThread(new Runnable() {
@Override
public void run() {
UserManagementView.this.getViewSite().getPage().hideView(UserManagementView.this);
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().UserManagementView_OpenJobError;
}
}.start();
}
use of org.netxms.client.SessionNotification in project netxms by netxms.
the class SummaryTablesCache method init.
/**
* Initialize object tools cache. Should be called when connection with
* the server already established.
*/
public static void init(NXCSession session) {
SummaryTablesCache.session = session;
reload();
session.addListener(new SessionListener() {
@Override
public void notificationHandler(SessionNotification n) {
switch(n.getCode()) {
case SessionNotification.DCI_SUMMARY_TABLE_UPDATED:
onTableChange((int) n.getSubCode());
break;
case SessionNotification.DCI_SUMMARY_TABLE_DELETED:
onTableDelete((int) n.getSubCode());
break;
}
}
});
}
Aggregations