Search in sources :

Example 1 with IntermediateSelectionProvider

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);
}
Also used : IntermediateSelectionProvider(org.netxms.ui.eclipse.tools.IntermediateSelectionProvider) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) DashboardControl(org.netxms.ui.eclipse.dashboard.widgets.DashboardControl) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) DashboardModifyListener(org.netxms.ui.eclipse.dashboard.widgets.internal.DashboardModifyListener) SessionListener(org.netxms.client.SessionListener) SessionNotification(org.netxms.client.SessionNotification)

Example 2 with IntermediateSelectionProvider

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;
        }
    });
}
Also used : CLabel(org.eclipse.swt.custom.CLabel) IntermediateSelectionProvider(org.netxms.ui.eclipse.tools.IntermediateSelectionProvider) CTabFolder(org.eclipse.swt.custom.CTabFolder) NXCSession(org.netxms.client.NXCSession) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) CTabItem(org.eclipse.swt.custom.CTabItem) ISelectionListener(org.eclipse.ui.ISelectionListener) GridLayout(org.eclipse.swt.layout.GridLayout) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) AbstractObject(org.netxms.client.objects.AbstractObject) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ISelection(org.eclipse.jface.viewers.ISelection) AbstractObject(org.netxms.client.objects.AbstractObject) SessionListener(org.netxms.client.SessionListener) SessionNotification(org.netxms.client.SessionNotification) ObjectTab(org.netxms.ui.eclipse.objectview.objecttabs.ObjectTab) ISelectionListener(org.eclipse.ui.ISelectionListener) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 3 with IntermediateSelectionProvider

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);
}
Also used : IntermediateSelectionProvider(org.netxms.ui.eclipse.tools.IntermediateSelectionProvider) DashboardControl(org.netxms.ui.eclipse.dashboard.widgets.DashboardControl) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) ISelection(org.eclipse.jface.viewers.ISelection) Dashboard(org.netxms.client.objects.Dashboard) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ISelectionListener(org.eclipse.ui.ISelectionListener)

Aggregations

IntermediateSelectionProvider (org.netxms.ui.eclipse.tools.IntermediateSelectionProvider)3 ISelection (org.eclipse.jface.viewers.ISelection)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 ISelectionListener (org.eclipse.ui.ISelectionListener)2 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)2 SessionListener (org.netxms.client.SessionListener)2 SessionNotification (org.netxms.client.SessionNotification)2 DashboardControl (org.netxms.ui.eclipse.dashboard.widgets.DashboardControl)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 CLabel (org.eclipse.swt.custom.CLabel)1 CTabFolder (org.eclipse.swt.custom.CTabFolder)1 CTabItem (org.eclipse.swt.custom.CTabItem)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 SelectionListener (org.eclipse.swt.events.SelectionListener)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 NXCSession (org.netxms.client.NXCSession)1 AbstractObject (org.netxms.client.objects.AbstractObject)1 Dashboard (org.netxms.client.objects.Dashboard)1 DashboardModifyListener (org.netxms.ui.eclipse.dashboard.widgets.internal.DashboardModifyListener)1