Search in sources :

Example 1 with ICommandManager

use of org.eclipse.ui.commands.ICommandManager in project Pydev by fabioz.

the class PythonBreakpointPage method createConditionEditor.

/**
 * Creates the controls that allow the user to specify the breakpoint's
 * condition
 * @param parent the composite in which the condition editor should be created
 * @throws CoreException if an exception occurs accessing the breakpoint
 */
private void createConditionEditor(Composite parent) throws CoreException {
    PyBreakpoint breakpoint = getBreakpoint();
    String label = null;
    ICommandManager commandManager = PlatformUI.getWorkbench().getCommandSupport().getCommandManager();
    // $NON-NLS-1$
    ICommand command = commandManager.getCommand("org.eclipse.ui.edit.text.contentAssist.proposals");
    if (command != null) {
        List keyBindings = command.getKeySequenceBindings();
        if (keyBindings != null && keyBindings.size() > 0) {
            IKeySequenceBinding binding = (IKeySequenceBinding) keyBindings.get(0);
            // $NON-NLS-1$
            label = StringUtils.format("E&nable Condition %s", binding.getKeySequence().format());
        }
    }
    if (label == null) {
        // $NON-NLS-1$
        label = "E&nable Condition (code assist not available)";
    }
    Composite conditionComposite = new Group(parent, SWT.NONE);
    conditionComposite.setFont(parent.getFont());
    conditionComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    conditionComposite.setLayout(new GridLayout());
    fEnableConditionButton = createCheckButton(conditionComposite, label);
    fEnableConditionButton.setSelection(breakpoint.isConditionEnabled());
    fEnableConditionButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            setConditionEnabled(fEnableConditionButton.getSelection());
        }
    });
    fConditionEditor = new BreakpointConditionEditor(conditionComposite, this);
    // fSuspendWhenLabel= createLabel(conditionComposite, "Suspend when:");
    // fConditionIsTrue= createRadioButton(conditionComposite, "condition is \'tr&ue\'");
    // fConditionIsTrue= createLabel(conditionComposite, "condition is \'tr&ue\'");
    // fConditionHasChanged= createRadioButton(conditionComposite, "value of condition ch&anges");
    // if (breakpoint.isConditionSuspendOnTrue()) {
    // fConditionIsTrue.setSelection(true);
    // } else {
    // fConditionHasChanged.setSelection(true);
    // }
    setConditionEnabled(fEnableConditionButton.getSelection());
}
Also used : Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ICommandManager(org.eclipse.ui.commands.ICommandManager) GridLayout(org.eclipse.swt.layout.GridLayout) PyBreakpoint(org.python.pydev.debug.model.PyBreakpoint) ICommand(org.eclipse.ui.commands.ICommand) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ArrayList(java.util.ArrayList) List(java.util.List) IKeySequenceBinding(org.eclipse.ui.commands.IKeySequenceBinding)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)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 Group (org.eclipse.swt.widgets.Group)1 ICommand (org.eclipse.ui.commands.ICommand)1 ICommandManager (org.eclipse.ui.commands.ICommandManager)1 IKeySequenceBinding (org.eclipse.ui.commands.IKeySequenceBinding)1 PyBreakpoint (org.python.pydev.debug.model.PyBreakpoint)1