use of org.netxms.ui.eclipse.tools.IntermediateSelectionProvider 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.ui.eclipse.tools.IntermediateSelectionProvider 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;
}
});
}
use of org.netxms.ui.eclipse.tools.IntermediateSelectionProvider in project netxms by netxms.
the class DashboardDynamicView 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);
parentComposite = parent;
if (dashboard != null)
dbc = new DashboardControl(parent, SWT.NONE, dashboard, this, selectionProvider, false);
createActions();
contributeToActionBars();
selectionService = getSite().getWorkbenchWindow().getSelectionService();
selectionListener = new ISelectionListener() {
@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
if ((part instanceof DashboardNavigator) && (selection instanceof IStructuredSelection) && !selection.isEmpty()) {
Object object = ((IStructuredSelection) selection).getFirstElement();
if (object instanceof Dashboard) {
setObject((Dashboard) object);
}
}
}
};
selectionService.addSelectionListener(selectionListener);
}
Aggregations