Skip to content

Commit bce87b7

Browse files
committed
Don't use unconditional pattern in instanceof for non-null checks
- Can't do something like this in Java 17: if(object.toString() instanceof String s) - This is allowed in Java 21 - In Eclipse 4.35+ these give an "Expression type cannot be a subtype of the Pattern type" compile error. Was OK in earlier versions of Eclipse. - See eclipse-jdt/eclipse.jdt.core#3478
1 parent cf01327 commit bce87b7

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

com.archimatetool.editor/src/com/archimatetool/editor/diagram/actions/TextAlignmentAction.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import org.eclipse.ui.actions.RetargetAction;
1818

1919
import com.archimatetool.editor.diagram.commands.TextAlignmentCommand;
20-
import com.archimatetool.editor.ui.factory.IObjectUIProvider;
20+
import com.archimatetool.editor.ui.factory.IGraphicalObjectUIProvider;
2121
import com.archimatetool.editor.ui.factory.ObjectUIFactory;
2222
import com.archimatetool.model.IArchimatePackage;
2323
import com.archimatetool.model.ILockable;
@@ -117,7 +117,7 @@ private List<ITextAlignment> getValidSelectedObjects() {
117117
for(Object object : getSelectedObjects()) {
118118
if(object instanceof EditPart editPart && editPart.getModel() instanceof ITextAlignment textAlignmentObject
119119
&& !(textAlignmentObject instanceof ILockable lockable && lockable.isLocked())
120-
&& ObjectUIFactory.INSTANCE.getProvider(textAlignmentObject) instanceof IObjectUIProvider provider
120+
&& ObjectUIFactory.INSTANCE.getProvider(textAlignmentObject) instanceof IGraphicalObjectUIProvider provider
121121
&& provider.shouldExposeFeature(IArchimatePackage.Literals.TEXT_ALIGNMENT__TEXT_ALIGNMENT.getName())) {
122122
list.add(textAlignmentObject);
123123
}

com.archimatetool.editor/src/com/archimatetool/editor/diagram/actions/TextPositionAction.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import org.eclipse.ui.actions.RetargetAction;
1818

1919
import com.archimatetool.editor.diagram.commands.TextPositionCommand;
20-
import com.archimatetool.editor.ui.factory.IObjectUIProvider;
20+
import com.archimatetool.editor.ui.factory.IGraphicalObjectUIProvider;
2121
import com.archimatetool.editor.ui.factory.ObjectUIFactory;
2222
import com.archimatetool.model.IArchimatePackage;
2323
import com.archimatetool.model.ILockable;
@@ -117,7 +117,7 @@ private List<ITextPosition> getValidSelectedObjects() {
117117
for(Object object : getSelectedObjects()) {
118118
if(object instanceof EditPart editPart && editPart.getModel() instanceof ITextPosition textPositionObject
119119
&& !(textPositionObject instanceof ILockable lockable && lockable.isLocked())
120-
&& ObjectUIFactory.INSTANCE.getProvider(textPositionObject) instanceof IObjectUIProvider provider
120+
&& ObjectUIFactory.INSTANCE.getProvider(textPositionObject) instanceof IGraphicalObjectUIProvider provider
121121
&& provider.shouldExposeFeature(IArchimatePackage.Literals.TEXT_POSITION__TEXT_POSITION.getName())) {
122122
list.add(textPositionObject);
123123
}

com.archimatetool.editor/src/com/archimatetool/editor/views/tree/TreeSelectionSynchroniser.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,14 @@ private boolean doSync() {
124124
}
125125

126126
/**
127-
* Update with the last known selection
127+
* Update with the last known selections
128128
*/
129129
private void updateSelection() {
130130
// In this case we have created a new TreeViewer and synchroniser, so create a new selection event
131131
if(lastSelectionEvent == null) {
132132
IEditorPart activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
133-
if(activeEditor instanceof IDiagramModelEditor editor && editor.getGraphicalViewer() instanceof GraphicalViewer viewer) { // check this is not a zombie editor part
134-
selectionChanged(new SelectionChangedEvent(viewer, viewer.getSelection()));
133+
if(activeEditor instanceof IDiagramModelEditor editor && editor.getGraphicalViewer() != null) { // check this is not a zombie editor part
134+
selectionChanged(new SelectionChangedEvent(editor.getGraphicalViewer(), editor.getGraphicalViewer().getSelection()));
135135
}
136136
}
137137
else {

0 commit comments

Comments
 (0)