Search in sources :

Example 1 with DashboardModifyListener

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

Aggregations

IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 SessionListener (org.netxms.client.SessionListener)1 SessionNotification (org.netxms.client.SessionNotification)1 DashboardControl (org.netxms.ui.eclipse.dashboard.widgets.DashboardControl)1 DashboardModifyListener (org.netxms.ui.eclipse.dashboard.widgets.internal.DashboardModifyListener)1 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)1 IntermediateSelectionProvider (org.netxms.ui.eclipse.tools.IntermediateSelectionProvider)1