Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove left-overs of code completion in breakpoint properties #369

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
*/
package org.python.pydev.debug.ui.propertypages;

import java.util.Map;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.debug.core.DebugException;
import org.eclipse.jface.resource.JFaceResources;
Expand All @@ -18,21 +16,11 @@
import org.eclipse.jface.text.IDocumentPartitioner;
import org.eclipse.jface.text.IUndoManager;
import org.eclipse.jface.text.TextViewerUndoManager;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.AbstractHandler;
import org.eclipse.ui.commands.ExecutionException;
import org.eclipse.ui.commands.HandlerSubmission;
import org.eclipse.ui.commands.IHandler;
import org.eclipse.ui.commands.IWorkbenchCommandSupport;
import org.eclipse.ui.commands.Priority;
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
import org.python.pydev.core.IPythonPartitions;
import org.python.pydev.core.partition.PyPartitionScanner;
import org.python.pydev.core.partition.PyPartitioner;
Expand All @@ -47,7 +35,6 @@ public class BreakpointConditionEditor {
private String fOldValue;
private String fErrorMessage;

private HandlerSubmission submission;
private IDocumentListener fDocumentListener;

private PythonBreakpointPage fPage;
Expand Down Expand Up @@ -77,12 +64,6 @@ public BreakpointConditionEditor(Composite parent, PythonBreakpointPage page) {
IDocumentPartitioner partitioner = new PyPartitioner(new PyPartitionScanner(), IPythonPartitions.types);
document.setDocumentPartitioner(partitioner);
partitioner.connect(document);
/*
fViewer.configure(new DisplayViewerConfiguration() {
public IContentAssistProcessor getContentAssistantProcessor() {
return getCompletionProcessor();
}
});*/
fViewer.setEditable(true);
fViewer.setDocument(document);
final IUndoManager undoManager = new TextViewerUndoManager(100);
Expand All @@ -108,47 +89,12 @@ public void documentChanged(DocumentEvent event) {
};
fViewer.getDocument().addDocumentListener(fDocumentListener);

// we can only do code assist if there is an associated type
/*
try {
//getCompletionProcessor().setType(type);
String source= null;
ICompilationUnit compilationUnit= type.getCompilationUnit();
if (compilationUnit != null) {
source= compilationUnit.getSource();
} else {
IClassFile classFile= type.getClassFile();
if (classFile != null) {
source= classFile.getSource();
}
}
int lineNumber= fBreakpoint.getMarker().getAttribute(IMarker.LINE_NUMBER, -1);
int position= -1;
if (source != null && lineNumber != -1) {
try {
position= new Document(source).getLineOffset(lineNumber - 1);
} catch (BadLocationException e) {
}
}
//getCompletionProcessor().setPosition(position);
} catch (CoreException e) {
}*/

gd = (GridData) fViewer.getControl().getLayoutData();
gd.heightHint = fPage.convertHeightInCharsToPixels(10);
gd.widthHint = fPage.convertWidthInCharsToPixels(40);
document.set(condition);
valueChanged();

IHandler handler = new AbstractHandler() {
@Override
public Object execute(Map parameter) throws ExecutionException {
fViewer.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
return null;
}
};
submission = new HandlerSubmission(null, parent.getShell(), null,
ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS, handler, Priority.MEDIUM);
}

/**
Expand Down Expand Up @@ -178,18 +124,6 @@ protected void refreshValidState() {
}
}

/**
* Return the completion processor associated with this viewer.
* @return BreakPointConditionCompletionProcessor
*/
/*
protected BreakpointConditionCompletionProcessor getCompletionProcessor() {
if (fCompletionProcessor == null) {
fCompletionProcessor= new BreakpointConditionCompletionProcessor(null);
}
return fCompletionProcessor;
}*/

/**
* @see org.eclipse.jface.preference.FieldEditor#setEnabled(boolean, org.eclipse.swt.widgets.Composite)
*/
Expand All @@ -199,16 +133,9 @@ public void setEnabled(boolean enabled) {
if (enabled) {
fViewer.updateViewerColors();
fViewer.getTextWidget().setFocus();

IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchCommandSupport commandSupport = workbench.getCommandSupport();
commandSupport.addHandlerSubmission(submission);
} else {
Color color = fViewer.getControl().getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
fViewer.getTextWidget().setBackground(color);
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchCommandSupport commandSupport = workbench.getCommandSupport();
commandSupport.removeHandlerSubmission(submission);
}
valueChanged();
}
Expand All @@ -223,11 +150,6 @@ protected void valueChanged() {
}

public void dispose() {
if (fViewer.isEditable()) {
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchCommandSupport commandSupport = workbench.getCommandSupport();
commandSupport.removeHandlerSubmission(submission);
}
fViewer.getDocument().removeDocumentListener(fDocumentListener);
fViewer.dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommand;
import org.eclipse.ui.commands.ICommandManager;
import org.eclipse.ui.commands.IKeySequenceBinding;
import org.eclipse.ui.dialogs.PropertyPage;
import org.eclipse.ui.model.IWorkbenchAdapter;
import org.python.pydev.debug.core.PydevDebugPlugin;
Expand Down Expand Up @@ -350,20 +346,7 @@ private void storeEnabled(PyBreakpoint breakpoint) throws CoreException {
private void createConditionEditor(Composite parent) throws CoreException {
PyBreakpoint breakpoint = getBreakpoint();

String label = null;
ICommandManager commandManager = PlatformUI.getWorkbench().getCommandSupport().getCommandManager();
ICommand command = commandManager.getCommand("org.eclipse.ui.edit.text.contentAssist.proposals"); //$NON-NLS-1$
if (command != null) {
List keyBindings = command.getKeySequenceBindings();
if (keyBindings != null && keyBindings.size() > 0) {
IKeySequenceBinding binding = (IKeySequenceBinding) keyBindings.get(0);
label = StringUtils.format("E&nable Condition %s", binding.getKeySequence().format()); //$NON-NLS-1$
}
}

if (label == null) {
label = "E&nable Condition (code assist not available)"; //$NON-NLS-1$
}
String 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));
Expand Down
Loading