Search in sources :

Example 1 with IMyViewPart

use of cl.utfsm.acs.acg.gui.IMyViewPart in project ACS by ACS-Community.

the class LoadFromCDBActionDelegate method run.

@Override
public void run(IAction action) {
    if (_window == null)
        return;
    boolean confirmLoad;
    confirmLoad = MessageDialog.openQuestion(_window.getShell(), "Load from CDB", "Load contents from the CDB?");
    if (!confirmLoad)
        return;
    final Display display = _window.getShell().getDisplay();
    new Thread(new Runnable() {

        public void run() {
            display.syncExec(new Runnable() {

                public void run() {
                    // Disable all views
                    IViewReference[] views = _window.getActivePage().getViewReferences();
                    for (int i = 0; i < views.length; i++) {
                        if (views[i].getView(false) instanceof IMyViewPart)
                            ((IMyViewPart) views[i].getView(false)).setEnabled(false);
                    }
                }
            });
            // Reload information from the CDB
            AlarmSystemManager.getInstance().loadFromCDB();
            display.asyncExec(new Runnable() {

                public void run() {
                    // Enable all views, and reload their contents
                    IViewReference[] views = _window.getActivePage().getViewReferences();
                    for (int i = 0; i < views.length; i++) {
                        if (views[i].getView(false) instanceof IMyViewPart) {
                            IMyViewPart view = ((IMyViewPart) views[i].getView(false));
                            view.setEnabled(true);
                            view.refreshContents();
                        }
                    }
                }
            });
        }
    }).start();
}
Also used : IMyViewPart(cl.utfsm.acs.acg.gui.IMyViewPart) Display(org.eclipse.swt.widgets.Display)

Example 2 with IMyViewPart

use of cl.utfsm.acs.acg.gui.IMyViewPart in project ACS by ACS-Community.

the class SaveToCDBActionDelegate method run.

@Override
public void run(IAction action) {
    if (_window == null)
        return;
    boolean confirmSave;
    confirmSave = MessageDialog.openQuestion(_window.getShell(), "Save to CDB", "Save the new contents to the CDB?");
    if (!confirmSave)
        return;
    final Display display = _window.getShell().getDisplay();
    new Thread(new Runnable() {

        public void run() {
            display.syncExec(new Runnable() {

                public void run() {
                    // Disable all views
                    IViewReference[] views = _window.getActivePage().getViewReferences();
                    for (int i = 0; i < views.length; i++) {
                        if (views[i].getView(false) instanceof IMyViewPart)
                            ((IMyViewPart) views[i].getView(false)).setEnabled(false);
                    }
                }
            });
            // Save and reload information from the CDB
            AlarmSystemManager.getInstance().saveToCDB();
            display.asyncExec(new Runnable() {

                public void run() {
                    // Enable all views, and reload their contents
                    IViewReference[] views = _window.getActivePage().getViewReferences();
                    for (int i = 0; i < views.length; i++) {
                        if (views[i].getView(false) instanceof IMyViewPart) {
                            IMyViewPart view = ((IMyViewPart) views[i].getView(false));
                            view.setEnabled(true);
                            view.refreshContents();
                        }
                    }
                }
            });
        }
    }).start();
}
Also used : IMyViewPart(cl.utfsm.acs.acg.gui.IMyViewPart) Display(org.eclipse.swt.widgets.Display)

Aggregations

IMyViewPart (cl.utfsm.acs.acg.gui.IMyViewPart)2 Display (org.eclipse.swt.widgets.Display)2