Search in sources :

Example 1 with DashboardControl

use of org.netxms.ui.eclipse.dashboard.widgets.DashboardControl in project netxms by netxms.

the class DashboardDynamicView method setObject.

/**
 * @param object
 */
private void setObject(Dashboard object) {
    if (dbc != null)
        dbc.dispose();
    dashboard = object;
    dbc = new DashboardControl(parentComposite, SWT.NONE, dashboard, this, selectionProvider, false);
    parentComposite.layout();
    setPartName(Messages.get().DashboardDynamicView_PartNamePrefix + dashboard.getObjectName());
}
Also used : DashboardControl(org.netxms.ui.eclipse.dashboard.widgets.DashboardControl)

Example 2 with DashboardControl

use of org.netxms.ui.eclipse.dashboard.widgets.DashboardControl 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 3 with DashboardControl

use of org.netxms.ui.eclipse.dashboard.widgets.DashboardControl in project netxms by netxms.

the class DashboardPage method createContent.

/* (non-Javadoc)
    * @see org.netxms.webui.mobile.pages.AbstractPage#createContent(org.eclipse.swt.widgets.Composite)
    */
@Override
protected Composite createContent(Composite parent) {
    NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    Dashboard dashboard = (Dashboard) session.findObjectById(objectId, Dashboard.class);
    if (dashboard != null) {
        DashboardControl dbc = new DashboardControl(parent, SWT.NONE, dashboard, null, false);
        setTitle(dashboard.getObjectName());
        return dbc;
    } else {
        setTitle("[" + objectId + "]");
        return new Composite(parent, SWT.NONE);
    }
}
Also used : NXCSession(org.netxms.client.NXCSession) Composite(org.eclipse.swt.widgets.Composite) DashboardControl(org.netxms.ui.eclipse.dashboard.widgets.DashboardControl) Dashboard(org.netxms.client.objects.Dashboard)

Example 4 with DashboardControl

use of org.netxms.ui.eclipse.dashboard.widgets.DashboardControl 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)

Example 5 with DashboardControl

use of org.netxms.ui.eclipse.dashboard.widgets.DashboardControl in project netxms by netxms.

the class DashboardDynamicView method rebuildDashboard.

/**
 * Rebuild current dashboard
 */
private void rebuildDashboard() {
    if (dashboard == null)
        return;
    if (dbc != null)
        dbc.dispose();
    dashboard = (Dashboard) ((NXCSession) ConsoleSharedData.getSession()).findObjectById(dashboard.getObjectId(), Dashboard.class);
    if (dashboard != null) {
        dbc = new DashboardControl(parentComposite, SWT.NONE, dashboard, this, selectionProvider, false);
        parentComposite.layout();
        setPartName(Messages.get().DashboardDynamicView_PartNamePrefix + dashboard.getObjectName());
    } else {
        dbc = null;
    }
}
Also used : NXCSession(org.netxms.client.NXCSession) DashboardControl(org.netxms.ui.eclipse.dashboard.widgets.DashboardControl)

Aggregations

DashboardControl (org.netxms.ui.eclipse.dashboard.widgets.DashboardControl)6 NXCSession (org.netxms.client.NXCSession)3 Dashboard (org.netxms.client.objects.Dashboard)2 IntermediateSelectionProvider (org.netxms.ui.eclipse.tools.IntermediateSelectionProvider)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 ISelection (org.eclipse.jface.viewers.ISelection)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 Composite (org.eclipse.swt.widgets.Composite)1 ISelectionListener (org.eclipse.ui.ISelectionListener)1 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)1 SessionListener (org.netxms.client.SessionListener)1 SessionNotification (org.netxms.client.SessionNotification)1 DashboardModifyListener (org.netxms.ui.eclipse.dashboard.widgets.internal.DashboardModifyListener)1 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)1