use of org.netxms.client.SessionListener in project netxms by netxms.
the class SummaryTableManager method createPartControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
// Create interface area
tableArea = new Composite(parent, SWT.BORDER);
FormLayout formLayout = new FormLayout();
tableArea.setLayout(formLayout);
// Create filter
filterText = new FilterText(tableArea, SWT.NONE);
filterText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
onFilterModify();
}
});
filterText.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
settings.put("SummaryTableManager.showFilter", initShowFilter);
}
});
final String[] names = { Messages.get().SummaryTableManager_ID, Messages.get().SummaryTableManager_MenuPath, Messages.get().SummaryTableManager_Title };
final int[] widths = { 90, 250, 200 };
viewer = new SortableTableViewer(tableArea, names, widths, COLUMN_MENU_PATH, SWT.UP, SortableTableViewer.DEFAULT_STYLE);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new SummaryTableLabelProvider());
viewer.setComparator(new SummaryTableComparator());
filter = new SummaryTableFilter();
viewer.addFilter(filter);
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
actionEdit.setEnabled(selection.size() == 1);
actionDelete.setEnabled(selection.size() > 0);
}
});
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
editSummaryTable();
}
});
// Setup layout
FormData fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(filterText);
fd.right = new FormAttachment(100, 0);
fd.bottom = new FormAttachment(100, 0);
viewer.getControl().setLayoutData(fd);
fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(0, 0);
fd.right = new FormAttachment(100, 0);
filterText.setLayoutData(fd);
createActions();
contributeToActionBars();
createPopupMenu();
filterText.setCloseAction(actionShowFilter);
enableFilter(initShowFilter);
refresh();
listener = new SessionListener() {
@Override
public void notificationHandler(SessionNotification n) {
if (n.getCode() == SessionNotification.DCI_SUMMARY_TABLE_DELETED) {
final int id = (int) n.getSubCode();
getSite().getShell().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
if (descriptors.remove(id) != null)
viewer.setInput(descriptors.values().toArray());
}
});
} else if (n.getCode() == SessionNotification.DCI_SUMMARY_TABLE_UPDATED) {
getSite().getShell().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
refresh();
}
});
}
}
};
session.addListener(listener);
activateContext();
}
use of org.netxms.client.SessionListener in project netxms by netxms.
the class InterfacesTab method createTabContent.
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.objectview.objecttabs.ObjectTab#createTabContent(org.eclipse.swt.widgets.Composite)
*/
@Override
protected void createTabContent(Composite parent) {
final IDialogSettings settings = Activator.getDefault().getDialogSettings();
// $NON-NLS-1$ //$NON-NLS-2$
showFilter = safeCast(settings.get("InterfacesTab.showFilter"), settings.getBoolean("InterfacesTab.showFilter"), showFilter);
// $NON-NLS-1$ //$NON-NLS-2$
hideSubInterfaces = safeCast(settings.get("InterfacesTab.hideSubInterfaces"), settings.getBoolean("InterfacesTab.hideSubInterfaces"), hideSubInterfaces);
// Create interface area
interfacesArea = new Composite(parent, SWT.BORDER);
FormLayout formLayout = new FormLayout();
interfacesArea.setLayout(formLayout);
// Create filter
filterText = new FilterText(interfacesArea, SWT.NONE);
filterText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
onFilterModify();
}
});
filterText.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
// $NON-NLS-1$
settings.put("InterfacesTab.showFilter", showFilter);
// $NON-NLS-1$
settings.put("InterfacesTab.hideSubInterfaces", hideSubInterfaces);
}
});
Action action = new Action() {
@Override
public void run() {
enableFilter(false);
ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
// $NON-NLS-1$
Command command = service.getCommand("org.netxms.ui.eclipse.objectview.commands.show_filter");
// $NON-NLS-1$
State state = command.getState("org.netxms.ui.eclipse.objectview.commands.show_filter.state");
state.setValue(false);
service.refreshElements(command.getId(), null);
}
};
setFilterCloseAction(action);
// Check/uncheck menu items
ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
// $NON-NLS-1$
Command command = service.getCommand("org.netxms.ui.eclipse.objectview.commands.show_filter");
// $NON-NLS-1$
State state = command.getState("org.netxms.ui.eclipse.objectview.commands.show_filter.state");
state.setValue(showFilter);
service.refreshElements(command.getId(), null);
// $NON-NLS-1$
command = service.getCommand("org.netxms.ui.eclipse.objectview.commands.hideSubInterfaces");
// $NON-NLS-1$
state = command.getState("org.netxms.ui.eclipse.objectview.commands.hideSubInterfaces.state");
state.setValue(hideSubInterfaces);
service.refreshElements(command.getId(), null);
// Setup layout
FormData fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(0, 0);
fd.right = new FormAttachment(100, 0);
filterText.setLayoutData(fd);
final String[] names = { Messages.get().InterfacesTab_ColId, Messages.get().InterfacesTab_ColName, Messages.get().InterfacesTab_Alias, Messages.get().InterfacesTab_ColIfType, Messages.get().InterfacesTab_ColIfIndex, Messages.get().InterfacesTab_ColSlot, Messages.get().InterfacesTab_ColPort, Messages.get().InterfacesTab_MTU, Messages.get().InterfacesTab_Speed, Messages.get().InterfacesTab_ColDescription, Messages.get().InterfacesTab_ColMacAddr, Messages.get().InterfacesTab_ColIpAddr, Messages.get().InterfacesTab_ColPeerNode, Messages.get().InterfacesTab_ColPeerMAC, Messages.get().InterfacesTab_ColPeerIP, Messages.get().InterfacesTab_PeerDiscoveryProtocol, Messages.get().InterfacesTab_ColAdminState, Messages.get().InterfacesTab_ColOperState, Messages.get().InterfacesTab_ColExpState, Messages.get().InterfacesTab_ColStatus, Messages.get().InterfacesTab_Col8021xPAE, Messages.get().InterfacesTab_Col8021xBackend };
final int[] widths = { 60, 150, 150, 150, 70, 70, 70, 70, 90, 150, 100, 90, 150, 100, 90, 80, 80, 80, 80, 80, 80, 80 };
viewer = new SortableTableViewer(interfacesArea, names, widths, COLUMN_NAME, SWT.UP, SWT.FULL_SELECTION | SWT.MULTI);
labelProvider = new InterfaceListLabelProvider();
viewer.setLabelProvider(labelProvider);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setComparator(new InterfaceListComparator());
viewer.getTable().setHeaderVisible(true);
viewer.getTable().setLinesVisible(true);
filter = new InterfacesTabFilter();
filter.setHideSubInterfaces(hideSubInterfaces);
viewer.addFilter(filter);
// $NON-NLS-1$
WidgetHelper.restoreTableViewerSettings(viewer, Activator.getDefault().getDialogSettings(), "InterfaceTable.V4");
viewer.getTable().addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
// $NON-NLS-1$
WidgetHelper.saveColumnSettings(viewer.getTable(), Activator.getDefault().getDialogSettings(), "InterfaceTable.V4");
}
});
// Setup layout
fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(filterText, 0, SWT.BOTTOM);
fd.bottom = new FormAttachment(100, 0);
fd.right = new FormAttachment(100, 0);
viewer.getControl().setLayoutData(fd);
createActions();
createPopupMenu();
// Set initial focus to filter input line
if (showFilter)
filterText.setFocus();
else
// Will hide filter area correctly
enableFilter(false);
sessionListener = new SessionListener() {
@Override
public void notificationHandler(SessionNotification n) {
if (n.getCode() == SessionNotification.OBJECT_CHANGED) {
AbstractObject object = (AbstractObject) n.getObject();
if ((object != null) && (object instanceof Interface) && (getObject() != null) && object.isDirectChildOf(getObject().getObjectId())) {
viewer.getControl().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
refresh();
}
});
}
}
}
};
ConsoleSharedData.getSession().addListener(sessionListener);
}
use of org.netxms.client.SessionListener in project netxms by netxms.
the class ScheduledTaskView 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 = { 50, 100, 200, 400, 150, 150, 100, 200, 250, 200 };
final String[] names = { "Id", "Schedule Type", "Object", "Parameters", "Execution time", "Last execution time", "Execution status", "Administrative status", "Owner", "Comments" };
viewer = new SortableTableViewer(parent, names, widths, SCHEDULE_ID, SWT.UP, SWT.FULL_SELECTION | SWT.MULTI);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new ScheduleTableEntryLabelProvider());
viewer.setComparator(new ScheduleTableEntryComparator());
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
actionEdit.run();
}
});
WidgetHelper.restoreTableViewerSettings(viewer, Activator.getDefault().getDialogSettings(), "ScheduledTasks");
viewer.getControl().addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
WidgetHelper.saveTableViewerSettings(viewer, Activator.getDefault().getDialogSettings(), "ScheduledTasks");
}
});
activateContext();
createActions();
contributeToActionBars();
createPopupMenu();
refresh();
final Display display = getSite().getShell().getDisplay();
listener = new SessionListener() {
@Override
public void notificationHandler(SessionNotification n) {
if (n.getCode() == SessionNotification.SCHEDULE_UPDATE) {
display.asyncExec(new Runnable() {
@Override
public void run() {
refresh();
}
});
}
}
};
session.addListener(listener);
}
Aggregations