use of org.netxms.client.SessionListener in project netxms by netxms.
the class DashboardView method createPartControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
selectionProvider = new IntermediateSelectionProvider();
getSite().setSelectionProvider(selectionProvider);
ConsoleJob job = new ConsoleJob(Messages.get().DashboardView_GetEffectiveRights, this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
readOnly = ((dashboard.getEffectiveRights() & UserAccessRights.OBJECT_ACCESS_MODIFY) == 0);
}
@Override
protected String getErrorMessage() {
return Messages.get().DashboardView_GetEffectiveRightsError;
}
};
job.start();
// FIXME: rewrite waiting
try {
job.join();
} catch (InterruptedException e) {
}
parentComposite = parent;
dbc = new DashboardControl(parent, SWT.NONE, dashboard, this, selectionProvider, false);
if (!readOnly) {
dbcModifyListener = new DashboardModifyListener() {
@Override
public void save() {
actionSave.setEnabled(false);
firePropertyChange(PROP_DIRTY);
}
@Override
public void modify() {
actionSave.setEnabled(true);
firePropertyChange(PROP_DIRTY);
}
};
dbc.setModifyListener(dbcModifyListener);
}
activateContext();
createActions();
contributeToActionBars();
clientListener = new SessionListener() {
@Override
public void notificationHandler(SessionNotification n) {
if (n.getCode() == SessionNotification.OBJECT_CHANGED && dashboard.getObjectId() == n.getSubCode()) {
parentComposite.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
rebuildDashboard(true);
}
});
}
}
};
session.addListener(clientListener);
}
use of org.netxms.client.SessionListener in project netxms by netxms.
the class AbstractNetworkMapView method createPartControl.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.part.ViewPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public final void createPartControl(Composite parent) {
FillLayout layout = new FillLayout();
parent.setLayout(layout);
viewer = new ExtendedGraphViewer(parent, SWT.NONE);
viewer.setContentProvider(new MapContentProvider(viewer));
labelProvider = new MapLabelProvider(viewer);
viewer.setLabelProvider(labelProvider);
viewer.setBackgroundColor(parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB());
IDialogSettings settings = Activator.getDefault().getDialogSettings();
try {
// $NON-NLS-1$
alwaysFitLayout = settings.getBoolean(viewId + ".alwaysFitLayout");
} catch (Exception e) {
}
// Zoom level restore and save
try {
// $NON-NLS-1$
viewer.zoomTo(settings.getDouble(viewId + ".zoom"));
} catch (NumberFormatException e) {
}
viewer.getGraphControl().addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
IDialogSettings settings = Activator.getDefault().getDialogSettings();
// $NON-NLS-1$
settings.put(viewId + ".zoom", viewer.getZoom());
}
});
getSite().setSelectionProvider(this);
ISelectionChangedListener listener = new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent e) {
if (bendpointEditor != null) {
bendpointEditor.stop();
bendpointEditor = null;
}
currentSelection = transformSelection(e.getSelection());
if (currentSelection.size() == 1) {
int selectionType = analyzeSelection(currentSelection);
if (selectionType == SELECTION_OBJECTS) {
AbstractObject object = (AbstractObject) currentSelection.getFirstElement();
actionOpenDrillDownObject.setEnabled(object.getDrillDownObjectId() != 0);
} else {
actionOpenDrillDownObject.setEnabled(false);
if (selectionType == SELECTION_LINKS) {
NetworkMapLink link = (NetworkMapLink) currentSelection.getFirstElement();
actionLockLink.setChecked(link.isLocked());
if (!link.isLocked() && link.getRouting() == NetworkMapLink.ROUTING_BENDPOINTS) {
bendpointEditor = new BendpointEditor(link, (GraphConnection) viewer.getGraphControl().getSelection().get(0), viewer);
}
}
}
} else {
actionOpenDrillDownObject.setEnabled(false);
}
if (selectionListeners.isEmpty())
return;
SelectionChangedEvent event = new SelectionChangedEvent(AbstractNetworkMapView.this, currentSelection);
for (ISelectionChangedListener l : selectionListeners) {
l.selectionChanged(event);
}
}
};
viewer.addPostSelectionChangedListener(listener);
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
int selectionType = analyzeSelection(currentSelection);
if (selectionType == SELECTION_EMPTY)
return;
if (selectionType == SELECTION_OBJECTS) {
AbstractObject object = (AbstractObject) currentSelection.getFirstElement();
if (object instanceof Rack) {
openRackView(Long.toString(object.getObjectId()));
return;
}
for (DoubleClickHandlerData h : doubleClickHandlers) {
if ((h.enabledFor == null) || (h.enabledFor.isInstance(object))) {
if (h.handler.onDoubleClick(object)) {
return;
}
}
}
} else if (((NetworkMapLink) currentSelection.getFirstElement()).isLocked() && selectionType == SELECTION_LINKS) {
openLinkDci();
}
// Default behavior
actionOpenDrillDownObject.run();
}
});
sessionListener = new SessionListener() {
@Override
public void notificationHandler(final SessionNotification n) {
if (n.getCode() == SessionNotification.OBJECT_CHANGED) {
viewer.getControl().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
onObjectChange((AbstractObject) n.getObject());
}
});
}
}
};
session.addListener(sessionListener);
createActions();
contributeToActionBars();
createPopupMenu();
if (automaticLayoutEnabled) {
setLayoutAlgorithm(layoutAlgorithm, true);
} else {
viewer.setLayoutAlgorithm(new ManualLayout());
}
activateContext();
registerDoubleClickHandlers();
setupMapControl();
refreshMap();
}
use of org.netxms.client.SessionListener in project netxms by netxms.
the class ReportNavigator 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();
reportTree = new TreeViewer(parent, SWT.NONE);
reportTree.setContentProvider(new ReportTreeContentProvider());
reportTree.setLabelProvider(new ReportTreeLabelProvider());
// reportTree.setInput(session);
createActions();
contributeToActionBars();
createPopupMenu();
getSite().setSelectionProvider(reportTree);
sessionListener = new SessionListener() {
@Override
public void notificationHandler(SessionNotification n) {
if ((n.getCode() == SessionNotification.OBJECT_CHANGED) && (n.getObject() instanceof DashboardRoot)) {
reportTree.getTree().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
refresh();
}
});
}
}
};
session.addListener(sessionListener);
refresh();
}
use of org.netxms.client.SessionListener in project netxms by netxms.
the class ServiceAvailability method createPartControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
final Composite clientArea = new Composite(parent, SWT.NONE);
colors = new ColorCache(clientArea);
GridLayout layout = new GridLayout();
layout.numColumns = 4;
clientArea.setLayout(layout);
dayChart = createChart(clientArea, Messages.get().ServiceAvailability_Today);
weekChart = createChart(clientArea, Messages.get().ServiceAvailability_ThisWeek);
monthChart = createChart(clientArea, Messages.get().ServiceAvailability_ThisMonth);
Canvas legend = new Canvas(clientArea, SWT.NONE);
legend.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
paintLegend(e.gc);
}
});
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
legend.setLayoutData(gd);
listener = new SessionListener() {
@Override
public void notificationHandler(final SessionNotification n) {
if (!clientArea.isDisposed() && (n.getCode() == SessionNotification.OBJECT_CHANGED) && (n.getSubCode() == object.getObjectId())) {
clientArea.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
object = (ServiceContainer) n.getObject();
refresh();
}
});
}
}
};
ConsoleSharedData.getSession().addListener(listener);
}
use of org.netxms.client.SessionListener in project netxms by netxms.
the class TabbedObjectView method createPartControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.verticalSpacing = 0;
parent.setLayout(layout);
headerFont = FontTools.createFont(HEADER_FONTS, +3, SWT.BOLD);
header = new CLabel(parent, SWT.BORDER);
header.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
header.setFont(headerFont);
header.setBackground(SharedColors.getColor(SharedColors.OBJECT_TAB_HEADER_BACKGROUND, parent.getDisplay()));
header.setForeground(SharedColors.getColor(SharedColors.OBJECT_TAB_HEADER, parent.getDisplay()));
tabFolder = new CTabFolder(parent, SWT.TOP | SWT.FLAT | SWT.MULTI);
tabFolder.setUnselectedImageVisible(true);
tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
tabFolder.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
onTabSelectionChange((e.item != null) ? (ObjectTab) ((CTabItem) e.item).getData() : null);
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
tabs = new ArrayList<ObjectTab>();
addTabs();
selectionListener = new ISelectionListener() {
@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
if (// $NON-NLS-1$
(part.getSite().getId().equals("org.netxms.ui.eclipse.view.navigation.objectbrowser")) && (selection instanceof IStructuredSelection)) {
if (selection.isEmpty()) {
setObject(null);
} else {
Object object = ((IStructuredSelection) selection).getFirstElement();
if (object instanceof AbstractObject) {
setObject((AbstractObject) object);
}
}
}
}
};
selectionService.addPostSelectionListener(selectionListener);
createActions();
contributeToActionBars();
selectionProvider = new IntermediateSelectionProvider();
getSite().setSelectionProvider(selectionProvider);
final NXCSession session = ConsoleSharedData.getSession();
sessionListener = new SessionListener() {
@Override
public void notificationHandler(SessionNotification n) {
if ((n.getCode() == SessionNotification.OBJECT_CHANGED) && (objectId == n.getSubCode())) {
final AbstractObject object = (AbstractObject) n.getObject();
getSite().getShell().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
onObjectUpdate(object);
}
});
}
}
};
session.addListener(sessionListener);
CommandBridge.getInstance().registerCommand("TabbedObjectView/selectTab", new // $NON-NLS-1$
Command() {
@Override
public Object execute(String name, Object arg) {
if (arg instanceof String)
selectTab((String) arg);
return null;
}
});
CommandBridge.getInstance().registerCommand("TabbedObjectView/changeObject", new // $NON-NLS-1$
Command() {
@Override
public Object execute(String name, Object arg) {
if (arg instanceof Long)
setObject(session.findObjectById((Long) arg));
return null;
}
});
}
Aggregations