1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

Code cleanup

This commit is contained in:
Anton Leherbauer 2008-11-05 10:26:58 +00:00
parent 55a0d30355
commit 415ff10013
10 changed files with 27 additions and 574 deletions

View file

@ -27,9 +27,7 @@ import org.eclipse.jface.text.FindReplaceDocumentAdapter;
import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextOperationTarget; import org.eclipse.jface.text.ITextOperationTarget;
import org.eclipse.jface.text.ITextViewerExtension;
import org.eclipse.jface.text.rules.IWordDetector; import org.eclipse.jface.text.rules.IWordDetector;
import org.eclipse.jface.text.source.IOverviewRuler;
import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.IVerticalRuler; import org.eclipse.jface.text.source.IVerticalRuler;
import org.eclipse.jface.text.source.SourceViewerConfiguration; import org.eclipse.jface.text.source.SourceViewerConfiguration;
@ -68,32 +66,6 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe
*/ */
private ListenerList fReconcilingListeners= new ListenerList(ListenerList.IDENTITY); private ListenerList fReconcilingListeners= new ListenerList(ListenerList.IDENTITY);
/**
* Adapted source viewer for CEditor
*/
public class AdaptedSourceViewer extends ProjectionViewer implements ITextViewerExtension {
public AdaptedSourceViewer(Composite parent, IVerticalRuler ruler,
IOverviewRuler overviewRuler, boolean showsAnnotation, int styles) {
super(parent, ruler, overviewRuler, showsAnnotation, styles);
}
/* (non-Javadoc)
* @see org.eclipse.jface.text.source.ISourceViewer#setRangeIndication(int, int, boolean)
*/
public void setRangeIndication(int offset, int length, boolean moveCursor) {
// Fixin a bug in the ProjectViewer implemenation
// PR: https://bugs.eclipse.org/bugs/show_bug.cgi?id=72914
if (isProjectionMode()) {
super.setRangeIndication(offset, length, moveCursor);
} else {
super.setRangeIndication(offset, length, false);
}
}
}
MakefileSourceConfiguration getMakefileSourceConfiguration() { MakefileSourceConfiguration getMakefileSourceConfiguration() {
SourceViewerConfiguration configuration = getSourceViewerConfiguration(); SourceViewerConfiguration configuration = getSourceViewerConfiguration();
@ -169,7 +141,7 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe
} }
protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) { protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
ISourceViewer viewer = new AdaptedSourceViewer(parent, ruler, getOverviewRuler(), isOverviewRulerVisible(), styles); ISourceViewer viewer = new ProjectionViewer(parent, ruler, getOverviewRuler(), isOverviewRulerVisible(), styles);
// ensure decoration support has been created and configured. // ensure decoration support has been created and configured.
getSourceViewerDecorationSupport(viewer); getSourceViewerDecorationSupport(viewer);

View file

@ -8,7 +8,7 @@
* Contributors: * Contributors:
* IBM Rational Software - Initial API and implementation * IBM Rational Software - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.util; package org.eclipse.cdt.internal.corext.util;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;

View file

@ -1,468 +0,0 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Anton Leherbauer (Wind River Systems) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.dnd;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.BadPositionCategoryException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextOperationTarget;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.ITextViewerExtension5;
import org.eclipse.jface.text.Position;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.custom.StyledTextContent;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DropTargetAdapter;
import org.eclipse.swt.dnd.DropTargetEvent;
import org.eclipse.swt.dnd.FileTransfer;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.dnd.TransferData;
import org.eclipse.swt.graphics.Point;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.part.MarkerTransfer;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.ITextEditorDropTargetListener;
import org.eclipse.ui.texteditor.ITextEditorExtension;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.ui.CUIMessages;
import org.eclipse.cdt.internal.ui.util.EditorUtility;
import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
/**
* A drop adapter which supports dragging a non-workspace file from some
* external tool (e.g. explorer) into the editor area. The adaptor also supports
* text and marker transfer.
*
* @since 4.0
*/
public class TextEditorDropAdapter extends DropTargetAdapter implements
ITextEditorDropTargetListener {
/**
* Adapter factory for text editor drop target listeners. Can be registered
* to add text, file and marker drop support for all
* <code>ITextEditor</code>s.
*
* @see ITextEditorDropTargetListener
*/
public static class Factory implements IAdapterFactory {
private static final Class<?>[] CLASSES= { ITextEditorDropTargetListener.class };
/*
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object,
* java.lang.Class)
*/
@SuppressWarnings("unchecked")
public Object getAdapter(Object adaptableObject, Class adapterType) {
if (adaptableObject instanceof ITextEditor)
return TextEditorDropAdapter.create((ITextEditor) adaptableObject);
return null;
}
/*
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
*/
@SuppressWarnings("unchecked")
public Class[] getAdapterList() {
return CLASSES;
}
}
/** The text viewer target */
private ITextViewer fViewer;
/** The editor containing the viewer (can be null) */
private ITextEditor fEditor;
/** Cached selection of styled text widget upon dragEnter */
private Point fDropSelection;
/**
* Create an EditorDropAdapter for the given text viewer and (optional)
* editor.
*
* @param viewer
* the text viewer, may not be <code>null</code>
* @param editor
* the text editor, may be <code>null</code>
*/
public TextEditorDropAdapter(ITextViewer viewer, ITextEditor editor) {
super();
fViewer= viewer;
fEditor= editor;
}
/*
* @see org.eclipse.swt.dnd.DropTargetListener#drop(org.eclipse.swt.dnd.DropTargetEvent)
*/
@Override
public void drop(final DropTargetEvent event) {
try {
TransferData dataType= event.currentDataType;
if (isFileDataType(dataType)) {
// event.data is an array of strings which represent the
// absolute file pathes
assert event.data instanceof String[];
dropFiles((String[]) event.data);
} else if (isMarkerDataType(dataType)) {
assert event.data instanceof IMarker[];
dropMarkers((IMarker[]) event.data);
} else if (isTextDataType(dataType)) {
// event.data is a string
assert event.data instanceof String;
int offset= getOffsetAtLocation(event.x, event.y, true);
dropText((String) event.data, offset);
}
} catch (CoreException exc) {
ExceptionHandler.handle(exc,
CUIMessages.getString("TextEditorDropAdapter.error.title"), //$NON-NLS-1$
CUIMessages.getString("TextEditorDropAdapter.error.message")); //$NON-NLS-1$
}
}
/*
* @see org.eclipse.swt.dnd.DropTargetListener#dragEnter(org.eclipse.swt.dnd.DropTargetEvent)
*/
@Override
public void dragEnter(DropTargetEvent event) {
TransferData dataType= event.currentDataType;
if (isFileDataType(dataType)) {
// make sure the file is never moved; always do a copy
event.detail= DND.DROP_COPY;
event.feedback= DND.FEEDBACK_NONE;
} else if (isMarkerDataType(dataType)) {
event.detail= DND.DROP_COPY;
event.feedback= DND.FEEDBACK_NONE;
} else if (isTextDataType(dataType)) {
if (isDocumentEditable()) {
if (event.detail == DND.DROP_DEFAULT) {
event.detail= getAcceptableOperation(event.operations);
}
// workaround for
// Bug 162198: DnD removes selection and moves caret
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=162198
fDropSelection= fViewer.getTextWidget().getSelection();
} else {
event.detail= DND.DROP_NONE;
}
}
}
/*
* @see org.eclipse.swt.dnd.DropTargetListener#dragOver(org.eclipse.swt.dnd.DropTargetEvent)
*/
@Override
public void dragOver(DropTargetEvent event) {
TransferData dataType= event.currentDataType;
if (isFileDataType(dataType)) {
// make sure the file is never moved; always do a copy
event.detail= DND.DROP_COPY;
event.feedback= DND.FEEDBACK_NONE;
} else if (isMarkerDataType(dataType)) {
event.detail= DND.DROP_COPY;
event.feedback= DND.FEEDBACK_NONE;
} else if (isTextDataType(dataType)) {
if (isDocumentEditable()) {
if ((event.operations & event.detail) == 0) {
event.detail= getAcceptableOperation(event.operations);
}
int offset= getOffsetAtLocation(event.x, event.y, true);
if (offset < 0) {
event.detail= DND.DROP_NONE;
}
} else {
event.detail= DND.DROP_NONE;
}
event.feedback |= DND.FEEDBACK_SCROLL;
}
}
private static boolean isFileDataType(TransferData dataType) {
return FileTransfer.getInstance().isSupportedType(dataType);
}
private static boolean isTextDataType(TransferData dataType) {
return TextTransfer.getInstance().isSupportedType(dataType);
}
private static boolean isMarkerDataType(TransferData dataType) {
return MarkerTransfer.getInstance().isSupportedType(dataType);
}
/*
* @see org.eclipse.swt.dnd.DropTargetListener#dropAccept(org.eclipse.swt.dnd.DropTargetEvent)
*/
@Override
public void dropAccept(DropTargetEvent event) {
TransferData dataType= event.currentDataType;
if (isTextDataType(dataType)) {
// check if the offset is inside the drag source selection
IDocument doc= fViewer.getDocument();
if (doc.containsPositionCategory(TextViewerDragAdapter.DRAG_SELECTION_CATEGORY)) {
int widgetOffset= getOffsetAtLocation(event.x, event.y, true);
if (widgetOffset != -1) {
int documentOffset= getDocumentOffset(widgetOffset);
try {
Position[] dragSource= doc.getPositions(TextViewerDragAdapter.DRAG_SELECTION_CATEGORY);
if (dragSource.length == 0
|| event.detail == DND.DROP_MOVE
&& dragSource[0].includes(documentOffset)) {
// do not drop-move on the drag source
event.detail = DND.DROP_NONE;
}
} catch (BadPositionCategoryException e) {
event.detail= DND.DROP_NONE;
}
}
}
}
}
/*
* @see org.eclipse.swt.dnd.DropTargetListener#dragOperationChanged(org.eclipse.swt.dnd.DropTargetEvent)
*/
@Override
public void dragOperationChanged(DropTargetEvent event) {
TransferData dataType= event.currentDataType;
if (isFileDataType(dataType)) {
// make sure the file is never moved; always do a copy
event.detail= DND.DROP_COPY;
event.feedback= DND.FEEDBACK_NONE;
} else if (isMarkerDataType(dataType)) {
event.detail= DND.DROP_COPY;
event.feedback= DND.FEEDBACK_NONE;
} else if (isTextDataType(dataType)) {
if (isDocumentEditable()) {
if (event.detail == DND.DROP_DEFAULT) {
event.detail= getAcceptableOperation(event.operations);
}
} else {
event.detail= DND.DROP_NONE;
}
}
}
/**
* Get preferred operation out of allowed set.
*
* @param operations
* a bitset of allowed operations
* @return operation the preferred operation
*/
private int getAcceptableOperation(int operations) {
if ((operations & DND.DROP_MOVE) != 0 && isDocumentEditable()) {
return DND.DROP_MOVE;
}
if ((operations & DND.DROP_COPY) != 0) {
return DND.DROP_COPY;
}
return DND.DROP_NONE;
}
/*
* @see org.eclipse.swt.dnd.DropTargetListener#dragLeave(org.eclipse.swt.dnd.DropTargetEvent)
*/
@Override
public void dragLeave(DropTargetEvent event) {
fDropSelection= null;
}
/**
* Drop text data at offset.
*
* @param text
* @param offset
* @throws CoreException
*/
private void dropText(String text, int offset) throws CoreException {
IDocument d= fViewer.getDocument();
try {
int docOffset;
int docLength;
Point selection= fDropSelection;
if (selection != null && selection.x <= offset && offset < selection.y) {
// drop inside selection - replace selected text
docOffset= getDocumentOffset(selection.x);
docLength= getDocumentOffset(selection.y) - docOffset;
} else {
docOffset= getDocumentOffset(offset);
docLength= 0;
}
d.replace(docOffset, docLength, text);
fViewer.setSelectedRange(docOffset, text.length());
} catch (BadLocationException e) {
// should not happen
throw new CoreException(
new Status(IStatus.ERROR, CUIPlugin.getPluginId(), 0,
e.getLocalizedMessage(), e));
}
}
/**
* Drop (external) files.
*
* @param fileNames
*/
private void dropFiles(String[] fileNames) throws CoreException {
for (String fileName : fileNames) {
Path path= new Path(fileName);
java.io.File file= path.toFile();
if (!file.isFile()) {
throw new CoreException(new Status(IStatus.ERROR, CUIPlugin
.getPluginId(), 0, CUIMessages.getFormattedString(
"TextEditorDropAdapter.noFile", fileName), //$NON-NLS-1$
null));
}
if (file.canRead()) {
EditorUtility.openInEditor(path, null);
} else {
throw new CoreException(new Status(IStatus.ERROR, CUIPlugin
.getPluginId(), 0, CUIMessages.getFormattedString(
"TextEditorDropAdapter.unreadableFile", fileName), //$NON-NLS-1$
null));
}
}
}
/**
* Drop markers (open editor and navigate to marker).
*
* @param markers
* @throws PartInitException
*/
private void dropMarkers(IMarker[] markers) throws PartInitException {
for (IMarker marker : markers) {
IDE.openEditor(getPage(), marker);
}
}
private IWorkbenchPage getPage() {
if (fEditor != null) {
return ((IWorkbenchPart) fEditor).getSite().getPage();
}
return CUIPlugin.getActivePage();
}
/**
* Convert mouse screen coordinates to a <code>StyledText</code> offset.
*
* @param x
* screen X-coordinate
* @param y
* screen Y-coordinate
* @param absolute
* if <code>true</code>, coordinates are expected to be
* absolute screen coordinates
* @return text offset
*
* @see StyledText#getOffsetAtLocation()
*/
private int getOffsetAtLocation(int x, int y, boolean absolute) {
StyledText textWidget= fViewer.getTextWidget();
StyledTextContent content= textWidget.getContent();
Point location;
if (absolute) {
location= textWidget.toControl(x, y);
} else {
location= new Point(x, y);
}
int line= (textWidget.getTopPixel() + location.y)
/ textWidget.getLineHeight();
if (line >= content.getLineCount()) {
return content.getCharCount();
}
int lineOffset= content.getOffsetAtLine(line);
String lineText= content.getLine(line);
Point endOfLine= textWidget.getLocationAtOffset(lineOffset
+ lineText.length());
if (location.x >= endOfLine.x) {
return lineOffset + lineText.length();
}
try {
return textWidget.getOffsetAtLocation(location);
} catch (IllegalArgumentException iae) {
// we are expecting this
return -1;
}
}
/**
* Convert a widget offset to the corresponding document offset.
*
* @param widgetOffset
* @return document offset
*/
private int getDocumentOffset(int widgetOffset) {
if (fViewer instanceof ITextViewerExtension5) {
ITextViewerExtension5 extension= (ITextViewerExtension5) fViewer;
return extension.widgetOffset2ModelOffset(widgetOffset);
}
IRegion visible= fViewer.getVisibleRegion();
if (widgetOffset > visible.getLength()) {
return -1;
}
return widgetOffset + visible.getOffset();
}
/**
* @return true if the document may be changed by the drag.
*/
private boolean isDocumentEditable() {
if (fEditor instanceof ITextEditorExtension) {
return !((ITextEditorExtension) fEditor).isEditorInputReadOnly();
}
return fViewer.isEditable();
}
/*
* @see org.eclipse.ui.texteditor.ITextEditorDropTargetListener#getTransfers()
*/
public Transfer[] getTransfers() {
return new Transfer[] { TextTransfer.getInstance(),
FileTransfer.getInstance(), MarkerTransfer.getInstance() };
}
/**
* Factory method to create a drop target listener for the given text
* editor.
*
* @param textEditor
* @return a drop target listener or <code>null</code>
*/
protected static ITextEditorDropTargetListener create(ITextEditor textEditor) {
ITextViewer textViewer= (ITextViewer) textEditor
.getAdapter(ITextViewer.class);
if (textViewer == null) {
// this is a little trick to get the viewer from a text editor
ITextOperationTarget target= (ITextOperationTarget) textEditor
.getAdapter(ITextOperationTarget.class);
if (target instanceof ITextViewer) {
textViewer= (ITextViewer) target;
}
}
if (textViewer == null) {
return null;
}
return new TextEditorDropAdapter(textViewer, textEditor);
}
}

View file

@ -111,15 +111,10 @@ import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.custom.ST; import org.eclipse.swt.custom.ST;
import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.custom.VerifyKeyListener; import org.eclipse.swt.custom.VerifyKeyListener;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DragSource;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.events.VerifyEvent; import org.eclipse.swt.events.VerifyEvent;
import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IActionBars; import org.eclipse.ui.IActionBars;
@ -133,7 +128,6 @@ import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI; import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionContext; import org.eclipse.ui.actions.ActionContext;
import org.eclipse.ui.actions.ActionGroup; import org.eclipse.ui.actions.ActionGroup;
import org.eclipse.ui.dnd.IDragAndDropService;
import org.eclipse.ui.editors.text.EditorsUI; import org.eclipse.ui.editors.text.EditorsUI;
import org.eclipse.ui.editors.text.TextEditor; import org.eclipse.ui.editors.text.TextEditor;
import org.eclipse.ui.ide.IGotoMarker; import org.eclipse.ui.ide.IGotoMarker;
@ -151,7 +145,6 @@ import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.IEditorStatusLine; import org.eclipse.ui.texteditor.IEditorStatusLine;
import org.eclipse.ui.texteditor.ITextEditorActionConstants; import org.eclipse.ui.texteditor.ITextEditorActionConstants;
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds; import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
import org.eclipse.ui.texteditor.ITextEditorDropTargetListener;
import org.eclipse.ui.texteditor.IUpdate; import org.eclipse.ui.texteditor.IUpdate;
import org.eclipse.ui.texteditor.MarkerUtilities; import org.eclipse.ui.texteditor.MarkerUtilities;
import org.eclipse.ui.texteditor.SourceViewerDecorationSupport; import org.eclipse.ui.texteditor.SourceViewerDecorationSupport;
@ -200,8 +193,6 @@ import org.eclipse.cdt.internal.ui.actions.GoToNextPreviousMemberAction;
import org.eclipse.cdt.internal.ui.actions.GotoNextBookmarkAction; import org.eclipse.cdt.internal.ui.actions.GotoNextBookmarkAction;
import org.eclipse.cdt.internal.ui.actions.IndentAction; import org.eclipse.cdt.internal.ui.actions.IndentAction;
import org.eclipse.cdt.internal.ui.actions.RemoveBlockCommentAction; import org.eclipse.cdt.internal.ui.actions.RemoveBlockCommentAction;
import org.eclipse.cdt.internal.ui.dnd.TextEditorDropAdapter;
import org.eclipse.cdt.internal.ui.dnd.TextViewerDragAdapter;
import org.eclipse.cdt.internal.ui.search.OccurrencesFinder; import org.eclipse.cdt.internal.ui.search.OccurrencesFinder;
import org.eclipse.cdt.internal.ui.search.IOccurrencesFinder.OccurrenceLocation; import org.eclipse.cdt.internal.ui.search.IOccurrencesFinder.OccurrenceLocation;
import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup; import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup;
@ -1230,12 +1221,6 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
*/ */
private SemanticHighlightingManager fSemanticManager; private SemanticHighlightingManager fSemanticManager;
/**
* Custom text drag source listener overriding platform implementation.
* @since 4.0
*/
private TextViewerDragAdapter fTextViewerDragAdapter;
/** /**
* True if editor is opening a large file. * True if editor is opening a large file.
* @since 5.0 * @since 5.0
@ -2303,44 +2288,6 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
installOccurrencesFinder(false); installOccurrencesFinder(false);
} }
/*
* @see org.eclipse.ui.texteditor.AbstractTextEditor#installTextDragAndDrop(org.eclipse.jface.text.source.ISourceViewer)
*/
@Override
protected void installTextDragAndDrop(ISourceViewer viewer) {
if (fTextViewerDragAdapter != null) {
// already installed, enable it
fTextViewerDragAdapter.setEnabled(true);
return;
}
final IDragAndDropService dndService= (IDragAndDropService)getSite().getService(IDragAndDropService.class);
if (dndService == null || viewer == null) {
return;
}
Control control = viewer.getTextWidget();
int operations = DND.DROP_MOVE | DND.DROP_COPY;
DragSource dragSource = new DragSource(control, operations);
Transfer[] dragTypes = new Transfer[] { TextTransfer.getInstance() };
dragSource.setTransfer(dragTypes);
fTextViewerDragAdapter = new TextViewerDragAdapter(viewer, this);
dragSource.addDragListener(fTextViewerDragAdapter);
ITextEditorDropTargetListener dropTargetListener = new TextEditorDropAdapter(viewer, this);
dndService.addMergedDropTarget(control, operations, dropTargetListener.getTransfers(), dropTargetListener);
}
/*
* @see org.eclipse.ui.texteditor.AbstractTextEditor#uninstallTextDragAndDrop(org.eclipse.jface.text.source.ISourceViewer)
*/
@Override
protected void uninstallTextDragAndDrop(ISourceViewer viewer) {
if (fTextViewerDragAdapter != null) {
// uninstall not possible, disable instead
fTextViewerDragAdapter.setEnabled(false);
}
}
/* /*
* @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#getSourceViewerDecorationSupport(org.eclipse.jface.text.source.ISourceViewer) * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#getSourceViewerDecorationSupport(org.eclipse.jface.text.source.ISourceViewer)
*/ */

View file

@ -74,8 +74,6 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
shouldVisitDeclarators= true; shouldVisitDeclarators= true;
shouldVisitNamespaces= true; shouldVisitNamespaces= true;
} }
// tletodo
// private boolean shouldVisitCatchHandlers= true;
/** The semantic token */ /** The semantic token */
private SemanticToken fToken= new SemanticToken(); private SemanticToken fToken= new SemanticToken();

View file

@ -42,7 +42,6 @@ public class TogglePresentationAction extends TextEditorAction implements IPrope
public TogglePresentationAction() { public TogglePresentationAction() {
super(CEditorMessages.getResourceBundle(), "TogglePresentation.", null); //$NON-NLS-1$ super(CEditorMessages.getResourceBundle(), "TogglePresentation.", null); //$NON-NLS-1$
CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_MENU_SEGMENT_EDIT); CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_MENU_SEGMENT_EDIT);
setToolTipText(CEditorMessages.getString("TogglePresentation.tooltip")); //$NON-NLS-1$
setActionDefinitionId(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY); setActionDefinitionId(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY);
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.TOGGLE_PRESENTATION_ACTION); PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.TOGGLE_PRESENTATION_ACTION);
update(); update();

View file

@ -15,11 +15,11 @@ import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension; import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.InvalidRegistryObjectException;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
@ -59,7 +59,7 @@ public final class CompletionProposalCategory {
private int fSortOrder= 0x10000; private int fSortOrder= 0x10000;
private String fLastError= null; private String fLastError= null;
CompletionProposalCategory(IConfigurationElement element, CompletionProposalComputerRegistry registry) { CompletionProposalCategory(IConfigurationElement element, CompletionProposalComputerRegistry registry) throws CoreException {
fElement= element; fElement= element;
fRegistry= registry; fRegistry= registry;
IExtension parent= (IExtension) element.getParent(); IExtension parent= (IExtension) element.getParent();
@ -100,18 +100,19 @@ public final class CompletionProposalCategory {
} }
/** /**
* Checks an element that must be defined according to the extension * Checks that the given attribute value is not <code>null</code>.
* point schema. Throws an *
* <code>InvalidRegistryObjectException</code> if <code>obj</code> * @param value the element to be checked
* is <code>null</code>. * @param attribute the attribute
* @throws CoreException if <code>value</code> is <code>null</code>
*/ */
private void checkNotNull(Object obj, String attribute) throws InvalidRegistryObjectException { private void checkNotNull(Object obj, String attribute) throws CoreException {
if (obj == null) { if (obj == null) {
Object[] args= { getId(), fElement.getContributor().getName(), attribute }; Object[] args= { getId(), fElement.getContributor().getName(), attribute };
String message= Messages.format(ContentAssistMessages.CompletionProposalComputerDescriptor_illegal_attribute_message, args); String message= Messages.format(ContentAssistMessages.CompletionProposalComputerDescriptor_illegal_attribute_message, args);
IStatus status= new Status(IStatus.WARNING, CUIPlugin.getPluginId(), IStatus.OK, message, null); IStatus status= new Status(IStatus.WARNING, CUIPlugin.getPluginId(), IStatus.OK, message, null);
CUIPlugin.log(status); CUIPlugin.log(status);
throw new InvalidRegistryObjectException(); throw new CoreException(status);
} }
} }

View file

@ -126,8 +126,11 @@ final class CompletionProposalComputerDescriptor {
* *
* @param element the configuration element to read * @param element the configuration element to read
* @param registry the computer registry creating this descriptor * @param registry the computer registry creating this descriptor
* @param categories the categories
* @throws InvalidRegistryObjectException if this extension is no longer valid
* @throws CoreException if the configuration element is invalid
*/ */
CompletionProposalComputerDescriptor(IConfigurationElement element, CompletionProposalComputerRegistry registry, List<CompletionProposalCategory> categories) throws InvalidRegistryObjectException { CompletionProposalComputerDescriptor(IConfigurationElement element, CompletionProposalComputerRegistry registry, List<CompletionProposalCategory> categories) throws InvalidRegistryObjectException, CoreException {
Assert.isNotNull(registry); Assert.isNotNull(registry);
Assert.isNotNull(element); Assert.isNotNull(element);
@ -182,18 +185,19 @@ final class CompletionProposalComputerDescriptor {
} }
/** /**
* Checks an element that must be defined according to the extension * Checks that the given attribute value is not <code>null</code>.
* point schema. Throws an *
* <code>InvalidRegistryObjectException</code> if <code>obj</code> * @param value the element to be checked
* is <code>null</code>. * @param attribute the attribute
* @throws CoreException if <code>value</code> is <code>null</code>
*/ */
private void checkNotNull(Object obj, String attribute) throws InvalidRegistryObjectException { private void checkNotNull(Object obj, String attribute) throws CoreException {
if (obj == null) { if (obj == null) {
Object[] args= { getId(), fElement.getContributor().getName(), attribute }; Object[] args= { getId(), fElement.getContributor().getName(), attribute };
String message= Messages.format(ContentAssistMessages.CompletionProposalComputerDescriptor_illegal_attribute_message, args); String message= Messages.format(ContentAssistMessages.CompletionProposalComputerDescriptor_illegal_attribute_message, args);
IStatus status= new Status(IStatus.WARNING, CUIPlugin.getPluginId(), IStatus.OK, message, null); IStatus status= new Status(IStatus.WARNING, CUIPlugin.getPluginId(), IStatus.OK, message, null);
CUIPlugin.log(status); CUIPlugin.log(status);
throw new InvalidRegistryObjectException(); throw new CoreException(status);
} }
} }

View file

@ -23,11 +23,11 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IContributor; import org.eclipse.core.runtime.IContributor;
import org.eclipse.core.runtime.IExtensionRegistry; import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.InvalidRegistryObjectException;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogConstants;
@ -228,7 +228,7 @@ public final class CompletionProposalComputerRegistry {
} }
all.add(desc); all.add(desc);
} catch (InvalidRegistryObjectException x) { } catch (CoreException x) {
/* /*
* Element is not valid any longer as the contributing plug-in was unloaded or for * Element is not valid any longer as the contributing plug-in was unloaded or for
* some other reason. Do not include the extension in the list and inform the user * some other reason. Do not include the extension in the list and inform the user
@ -300,7 +300,7 @@ public final class CompletionProposalComputerRegistry {
category.setSortOrder(r); category.setSortOrder(r);
} }
} }
} catch (InvalidRegistryObjectException x) { } catch (CoreException x) {
/* /*
* Element is not valid any longer as the contributing plug-in was unloaded or for * Element is not valid any longer as the contributing plug-in was unloaded or for
* some other reason. Do not include the extension in the list and inform the user * some other reason. Do not include the extension in the list and inform the user

View file

@ -47,6 +47,7 @@ import org.eclipse.cdt.ui.refactoring.CTextFileChange;
import org.eclipse.cdt.internal.corext.codemanipulation.StubUtility; import org.eclipse.cdt.internal.corext.codemanipulation.StubUtility;
import org.eclipse.cdt.internal.corext.fix.LinkedProposalModel; import org.eclipse.cdt.internal.corext.fix.LinkedProposalModel;
import org.eclipse.cdt.internal.corext.fix.LinkedProposalPositionGroup; import org.eclipse.cdt.internal.corext.fix.LinkedProposalPositionGroup;
import org.eclipse.cdt.internal.corext.util.Resources;
import org.eclipse.cdt.internal.corext.util.Strings; import org.eclipse.cdt.internal.corext.util.Strings;
import org.eclipse.cdt.internal.ui.CUIStatus; import org.eclipse.cdt.internal.ui.CUIStatus;
@ -54,7 +55,6 @@ import org.eclipse.cdt.internal.ui.editor.CEditor;
import org.eclipse.cdt.internal.ui.text.correction.CorrectionMessages; import org.eclipse.cdt.internal.ui.text.correction.CorrectionMessages;
import org.eclipse.cdt.internal.ui.util.EditorUtility; import org.eclipse.cdt.internal.ui.util.EditorUtility;
import org.eclipse.cdt.internal.ui.util.ExceptionHandler; import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
import org.eclipse.cdt.internal.ui.util.Resources;
import org.eclipse.cdt.internal.ui.viewsupport.LinkedProposalModelPresenter; import org.eclipse.cdt.internal.ui.viewsupport.LinkedProposalModelPresenter;
/** /**