Skip to content

Commit 62b383c

Browse files
committed
AbstractEditor supports now IViewParts too
Also NP annotated related code Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
1 parent d3437ba commit 62b383c

File tree

5 files changed

+143
-98
lines changed

5 files changed

+143
-98
lines changed

AnyEditTools/src/de/loskutov/anyedit/actions/ToggleWhitespace.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ private static void addAnnotations(final AbstractEditor aEditor,
171171

172172
@Override
173173
public IStatus run(IProgressMonitor monitor) {
174-
if(aEditor.isDisposed() || aEditor.getEditorPart() == null){
174+
if(aEditor.isDisposed() || aEditor.getPart() == null){
175175
return Status.CANCEL_STATUS;
176176
}
177177

AnyEditTools/src/de/loskutov/anyedit/actions/compare/CompareWithAction.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import org.eclipse.jface.action.IAction;
1818
import org.eclipse.jface.viewers.ISelection;
1919
import org.eclipse.jface.viewers.IStructuredSelection;
20-
import org.eclipse.ui.IEditorPart;
2120
import org.eclipse.ui.IObjectActionDelegate;
2221
import org.eclipse.ui.IWorkbenchPart;
2322
import org.eclipse.ui.handlers.HandlerUtil;
@@ -65,12 +64,7 @@ public String getId() {
6564

6665
@Override
6766
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
68-
if (targetPart instanceof IEditorPart) {
69-
editor = new AbstractEditor((IEditorPart) targetPart);
70-
} else {
71-
editor = new AbstractEditor(null);
72-
}
73-
67+
editor = new AbstractEditor(targetPart);
7468
}
7569

7670
@Override

AnyEditTools/src/de/loskutov/anyedit/actions/compare/CompareWithEditorAction.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
import org.eclipse.swt.SWT;
3131
import org.eclipse.swt.graphics.Image;
3232
import org.eclipse.swt.widgets.Shell;
33-
import org.eclipse.ui.IEditorPart;
3433
import org.eclipse.ui.IEditorReference;
34+
import org.eclipse.ui.IWorkbenchPart;
3535
import org.eclipse.ui.dialogs.ListDialog;
3636
import org.eclipse.ui.progress.UIJob;
3737

@@ -196,7 +196,7 @@ public EditorsContentProvider(AbstractEditor myEditor, ContentWrapper selectedCo
196196
}
197197

198198
// if we are called from navigator (not from editor menu)
199-
if(myEditor == null || myEditor.getEditorPart() == null){
199+
if(myEditor == null || myEditor.getPart() == null){
200200
// if navigator context menu has no valid selection
201201
if(selectedContent == null) {
202202
continue;
@@ -216,7 +216,7 @@ public EditorsContentProvider(AbstractEditor myEditor, ContentWrapper selectedCo
216216

217217
// here we was called from the editor menu
218218
AbstractEditor abstractEditor = new AbstractEditor(reference.getEditor(initEditor));
219-
if (abstractEditor.getEditorPart() == null || sameEditor(abstractEditor)) {
219+
if (abstractEditor.getPart() == null || sameEditor(abstractEditor)) {
220220
continue;
221221
}
222222
refs.add(editorReferences[i]);
@@ -263,7 +263,7 @@ private boolean similarEditor(IEditorReference reference) {
263263
if(myEditor == null) {
264264
return false;
265265
}
266-
IEditorPart part = myEditor.getEditorPart();
266+
IWorkbenchPart part = myEditor.getPart();
267267
if(part == null) {
268268
return false;
269269
}

AnyEditTools/src/de/loskutov/anyedit/compare/TextStreamContent.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ private TextStreamContent(ContentWrapper content, AbstractEditor editor, String
8686
this.selectedText = selectedText;
8787
this.position = position;
8888
this.partListener = new PartListener2Impl();
89-
if(this.editor.getEditorPart() != null) {
89+
if(this.editor.getPart() != null) {
9090
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().addPartListener(
9191
partListener);
9292
IDocument document = this.editor.getDocument();
@@ -370,7 +370,7 @@ private final class PartListener2Impl implements IPartListener2 {
370370

371371
@Override
372372
public void partClosed(IWorkbenchPartReference partRef) {
373-
if (editor.getEditorPart() == partRef.getPart(false)) {
373+
if (editor.getPart() == partRef.getPart(false)) {
374374

375375
positionUpdater = null;
376376
dispose();

0 commit comments

Comments
 (0)