Search in sources :

Example 1 with InterpretedModuleListContentProvider

use of org.erlide.debug.ui.views.InterpretedModuleListContentProvider in project erlide_eclipse by erlang.

the class DebugTab method createControl.

/**
 * @wbp.parser.entryPoint
 */
@Override
public void createControl(final Composite parent) {
    final Composite comp = new Composite(parent, SWT.NONE);
    setControl(comp);
    final GridLayout topLayout = new GridLayout();
    comp.setLayout(topLayout);
    distributedDebugCheck = createCheckButton(comp, "Debug all connected nodes");
    final Group attachGroup = SWTUtil.createGroup(comp, "Auto Attach", 1, GridData.FILL_BOTH);
    attachGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
    attachOnFirstCallCheck = createCheckButton(attachGroup, "First &call");
    attachOnBreakpointCheck = createCheckButton(attachGroup, "&Breakpoint");
    attachOnExitCheck = createCheckButton(attachGroup, "E&xit");
    distributedDebugCheck.addSelectionListener(fBasicSelectionListener);
    attachOnFirstCallCheck.addSelectionListener(fBasicSelectionListener);
    attachOnBreakpointCheck.addSelectionListener(fBasicSelectionListener);
    attachOnExitCheck.addSelectionListener(fBasicSelectionListener);
    final Group interpretedModulesGroup = new Group(comp, SWT.NONE);
    final GridData gd_interpretedModulesGroup = new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1);
    gd_interpretedModulesGroup.widthHint = 387;
    interpretedModulesGroup.setLayoutData(gd_interpretedModulesGroup);
    interpretedModulesGroup.setText("Interpreted modules");
    interpretedModulesGroup.setLayout(new GridLayout(2, false));
    // final Label anyModuleHavingLabel = new Label(interpretedModulesGroup,
    // SWT.WRAP);
    // anyModuleHavingLabel.setLayoutData(new GridData(279, SWT.DEFAULT));
    // anyModuleHavingLabel
    // .setText("Any module having breakpoints enabled will be dynamically added to
    // the list.\n\nThis widget is disabled for now, it takes 100%CPU for large
    // projects. If you need to use \"attach on first call\" or \"attach on exit\",
    // please mark the modules by setting a dummy breakpoint in them. Sorry for the
    // inconvenience!");
    listViewer = new ListViewer(interpretedModulesGroup, SWT.BORDER | SWT.MULTI);
    listViewer.addSelectionChangedListener(event -> {
        final ISelection selection = event.getSelection();
        removeButton.setEnabled(!selection.isEmpty());
    });
    // checkboxTreeViewer.addCheckStateListener(new ICheckStateListener() {
    // @Override
    // @SuppressWarnings("synthetic-access")
    // public void checkStateChanged(final CheckStateChangedEvent event) {
    // final DebugTreeItem dti = (DebugTreeItem) event.getElement();
    // checkboxTreeViewer.setGrayed(dti, false);
    // final boolean checked = event.getChecked();
    // setSubtreeChecked(dti, checked);
    // // checkUpwards(checkboxTreeViewer, dti, checked, false);
    // updateLaunchConfigurationDialog();
    // }
    // 
    // });
    listViewer.setLabelProvider(new ModuleItemLabelProvider());
    contentProvider = new InterpretedModuleListContentProvider();
    listViewer.setContentProvider(contentProvider);
    final Control control = listViewer.getControl();
    final GridData gd_list = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 3);
    gd_list.minimumWidth = 250;
    gd_list.minimumHeight = 120;
    gd_list.widthHint = 256;
    gd_list.heightHint = 220;
    control.setLayoutData(gd_list);
    addButton = createPushButton(interpretedModulesGroup, "Add...", null);
    addButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            final List<IErlModule> result = DebugTab.getModulesFromAddModulesDialog(getShell());
            contentProvider.addModules(result);
            listViewer.refresh();
            updateLaunchConfigurationDialog();
        }
    });
    removeButton = createPushButton(interpretedModulesGroup, "Remove", null);
    removeButton.setEnabled(false);
    removeButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            final IStructuredSelection selection = (IStructuredSelection) listViewer.getSelection();
            for (final Object o : selection.toArray()) {
                contentProvider.removeModule((IErlModule) o);
            }
            listViewer.refresh();
            updateLaunchConfigurationDialog();
        }
    });
}
Also used : Group(org.eclipse.swt.widgets.Group) ListViewer(org.eclipse.jface.viewers.ListViewer) Composite(org.eclipse.swt.widgets.Composite) InterpretedModuleListContentProvider(org.erlide.debug.ui.views.InterpretedModuleListContentProvider) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ModuleItemLabelProvider(org.erlide.debug.ui.utils.ModuleItemLabelProvider) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) GridData(org.eclipse.swt.layout.GridData) ISelection(org.eclipse.jface.viewers.ISelection) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IErlModule(org.erlide.engine.model.root.IErlModule) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 ISelection (org.eclipse.jface.viewers.ISelection)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 ListViewer (org.eclipse.jface.viewers.ListViewer)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 Control (org.eclipse.swt.widgets.Control)1 Group (org.eclipse.swt.widgets.Group)1 ModuleItemLabelProvider (org.erlide.debug.ui.utils.ModuleItemLabelProvider)1 InterpretedModuleListContentProvider (org.erlide.debug.ui.views.InterpretedModuleListContentProvider)1 IErlModule (org.erlide.engine.model.root.IErlModule)1