Example usage for org.springframework.ide.eclipse.boot.dash.views BootDashActions BootDashActions

List of usage examples for org.springframework.ide.eclipse.boot.dash.views BootDashActions BootDashActions

Introduction

In this page you can find the example usage for org.springframework.ide.eclipse.boot.dash.views BootDashActions BootDashActions.

Prototype

public BootDashActions(BootDashViewModel model, MultiSelection<BootDashElement> selection,
            LiveExpression<BootDashModel> section, UserInteractions ui) 

Source Link

Usage

From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java

@Before
public void setup() throws Exception {
    StsTestUtil.deleteAllProjects();/*from w  w w.j  a  va 2s .c  o m*/
    this.context = new TestBootDashModelContext(ResourcesPlugin.getWorkspace(),
            DebugPlugin.getDefault().getLaunchManager());
    this.clientFactory = new MockCloudFoundryClientFactory();
    this.harness = CloudFoundryTestHarness.create(context, clientFactory);
    this.projects = new BootProjectTestHarness(context.getWorkspace());
    this.ui = mock(UserInteractions.class);
    this.actions = new BootDashActions(harness.model, harness.selection.forReading(), harness.sectionSelection,
            ui);
}

From source file:org.springframework.ide.eclipse.boot.dash.views.sections.BootDashUnifiedTreeSection.java

@Override
public void createContents(Composite page) {
    tv = new CustomTreeViewer(page, SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI);
    tv.setExpandPreCheckFilters(true);//from   w ww .  j a va  2 s .  c  o  m
    tv.setContentProvider(new BootDashTreeContentProvider());
    tv.setSorter(new BootModelViewerSorter(this.model));
    tv.setInput(model);
    tv.getTree().setLinesVisible(false);

    stylers = new Stylers(tv.getTree().getFont());
    tv.setLabelProvider(new BootDashTreeLabelProvider(stylers, tv));

    ColumnViewerToolTipSupport.enableFor(tv);

    GridDataFactory.fillDefaults().grab(true, true).applyTo(tv.getTree());

    new HiddenElementsLabel(page, tv.hiddenElementCount);

    tv.getControl().addControlListener(new ControlListener() {
        public void controlResized(ControlEvent e) {
            ReflowUtil.reflow(owner, tv.getControl());
        }

        public void controlMoved(ControlEvent e) {
        }
    });

    actions = new BootDashActions(model, getSelection(), getSectionSelection(), ui);
    hookContextMenu();

    // Careful, either selection or tableviewer might be created first.
    // in either case we must make sure the listener is added when *both*
    // have been created.
    if (selection != null) {
        addViewerSelectionListener();
    }

    tv.addDoubleClickListener(new IDoubleClickListener() {
        public void doubleClick(DoubleClickEvent event) {
            if (selection != null) {
                BootDashElement selected = selection.getSingle();
                if (selected != null) {
                    String url = selected.getUrl();
                    if (url != null) {
                        UiUtil.openUrl(url);
                    }
                } else if (sectionSelection.getValue() != null) {
                    IAction openCloudAdminConsoleAction = actions.getOpenCloudAdminConsoleAction();
                    if (openCloudAdminConsoleAction != null) {
                        openCloudAdminConsoleAction.run();
                    }
                }
            }
        }
    });

    model.getRunTargets().addListener(RUN_TARGET_LISTENER);
    model.getSectionModels().addListener(ELEMENTS_SET_LISTENER_ADAPTER);

    model.addElementStateListener(ELEMENT_STATE_LISTENER);

    if (searchFilterModel != null) {
        searchFilterModel.addListener(FILTER_LISTENER);
        tv.addFilter(new ViewerFilter() {
            @Override
            public boolean select(Viewer viewer, Object parentElement, Object element) {
                if (searchFilterModel.getValue() != null && element instanceof BootDashElement) {
                    return searchFilterModel.getValue().accept((BootDashElement) element);
                }
                return true;
            }
        });
    }

    tv.getTree().addDisposeListener(new DisposeListener() {
        @Override
        public void widgetDisposed(DisposeEvent e) {
            model.removeElementStateListener(ELEMENT_STATE_LISTENER);
            model.getRunTargets().removeListener(RUN_TARGET_LISTENER);
            model.getSectionModels().removeListener(ELEMENTS_SET_LISTENER_ADAPTER);
            for (BootDashModel m : model.getSectionModels().getValue()) {
                m.removeModelStateListener(MODEL_STATE_LISTENER);
            }

            if (searchFilterModel != null) {
                searchFilterModel.removeListener(FILTER_LISTENER);
            }

            if (actions != null) {
                actions.dispose();
                actions = null;
            }
            if (stylers != null) {
                stylers.dispose();
                stylers = null;
            }
        }
    });

    addDragSupport(tv);
    addDropSupport(tv);
}