Skip to content
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
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.e4.ui.workbench.addons.swt;singleton:=true
Bundle-Version: 1.5.800.qualifier
Bundle-Version: 1.5.900.qualifier
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,7 @@ private void subscribeVisibilityChanged(
if (parent.getRenderer() != null) {
Object myParent = ((AbstractPartRenderer) parent.getRenderer())
.getUIContainer(changedObj);
if (myParent instanceof Composite) {
Composite parentComp = (Composite) myParent;
if (myParent instanceof Composite parentComp) {
ctrl.setParent(parentComp);

Control prevControl = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

public class DetachedDropAgent extends DropAgent {
DnDManager manager;
private EModelService modelService;
private final EModelService modelService;
private Rectangle curRect;

public DetachedDropAgent(DnDManager manager) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ void subscribeTopicWidget(@UIEventTopic(UIEvents.UIElement.TOPIC_WIDGET) Event e
}

Object widget = event.getProperty(EventTags.NEW_VALUE);
if (widget instanceof Shell && !((Shell) widget).isDisposed()) {
Shell shell = (Shell) widget;
if (widget instanceof Shell shell && !shell.isDisposed()) {
DnDManager theManager = (DnDManager) shell.getData("DnDManager"); //$NON-NLS-1$
if (theManager == null) {
theManager = new DnDManager((MWindow) changedElement);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ private void setItemInfo() {
Control ctrl = (Control) curElement.getWidget();

// KLUDGE!! Should delegate to curElement's renderer
if (ctrl instanceof CTabFolder) {
CTabFolder ctf = (CTabFolder) ctrl;
if (ctrl instanceof CTabFolder ctf) {
Point localPos = display.map(null, ctf, cursorPos);
curItem = ctf.getItem(localPos);
if (curItem != null) {
Expand All @@ -137,8 +136,7 @@ private void setItemInfo() {
itemRect = display.map(ctf, ctf.getShell(), ((CTabItem) curItem).getBounds());
}
}
} else if (ctrl instanceof ToolBar) {
ToolBar tb = (ToolBar) ctrl;
} else if (ctrl instanceof ToolBar tb) {
Point localPos = display.map(null, tb, cursorPos);
ToolItem curItem = tb.getItem(localPos);
if (curItem != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ class DnDManager {
public static final int HOSTED = 1;
public static final int GHOSTED = 2;
public static final int SIMPLE = 3;
private int feedbackStyle = SIMPLE;
private int feedbackStyle;

Collection<DragAgent> dragAgents = new ArrayList<>();
Collection<DropAgent> dropAgents = new ArrayList<>();

DnDInfo info;
DragAgent dragAgent;

private MWindow dragWindow;
private final MWindow dragWindow;

private Shell dragHost;
private Control dragCtrl;
Expand All @@ -68,7 +68,7 @@ class DnDManager {
boolean dragging;

private Shell overlayFrame;
private List<Rectangle> frames = new ArrayList<>();
private final List<Rectangle> frames = new ArrayList<>();

DragDetectListener dragDetector = e -> {
if (dragging || e.widget.isDisposed()) {
Expand All @@ -93,8 +93,8 @@ public void addFrame(Rectangle newRect) {
updateOverlay();
}

private List<Image> images = new ArrayList<>();
private List<Rectangle> imageRects = new ArrayList<>();
private final List<Image> images = new ArrayList<>();
private final List<Rectangle> imageRects = new ArrayList<>();

protected boolean isModified;

Expand All @@ -105,6 +105,7 @@ public void addImage(Rectangle imageRect, Image image) {
}

public DnDManager(MWindow topLevelWindow) {
feedbackStyle = SIMPLE;
dragWindow = topLevelWindow;
info = new DnDInfo(topLevelWindow);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,11 @@ public void reactivatePart(MUIElement dragElement) {
MPart partToActivate = null;
if (dragElement instanceof MPart) {
partToActivate = (MPart) dragElement;
} else if (dragElement instanceof MPlaceholder) {
MPlaceholder ph = (MPlaceholder) dragElement;
} else if (dragElement instanceof MPlaceholder ph) {
if (ph.getRef() instanceof MPart) {
partToActivate = (MPart) ph.getRef();
}
} else if (dragElement instanceof MPartStack) {
MPartStack stack = (MPartStack) dragElement;
} else if (dragElement instanceof MPartStack stack) {
if (stack.getSelectedElement() instanceof MPart) {
partToActivate = (MPart) stack.getSelectedElement();
} else if (stack.getSelectedElement() instanceof MPlaceholder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ public MUIElement getElementToDrag(DnDInfo info) {
public void dragStart(DnDInfo info) {
super.dragStart(info);

if (dragElement instanceof MToolControl) {
MToolControl tc = (MToolControl) dragElement;
if (dragElement instanceof MToolControl tc) {
if (tc.getObject() instanceof TrimStack) {
TrimStack ts = (TrimStack) tc.getObject();
ts.showStack(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@ public PartDragAgent(DnDManager manager) {

@Override
public MUIElement getElementToDrag(DnDInfo info) {
if (!(info.curElement instanceof MPartStack)) {
if (!(info.curElement instanceof MPartStack stack)) {
return null;
}

MPartStack stack = (MPartStack) info.curElement;

// Drag a part that is in a stack
if (info.itemElement instanceof MStackElement) {
// Prevent dragging 'No Move' parts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,19 +308,17 @@ public boolean drop(MUIElement dragElement, DnDInfo info) {
}

// Adjust the relToElement based on the location of the dragElement
if (relToElement instanceof MArea) {
if (relToElement instanceof MArea area) {
// make it difficult to drag outside parts into the shared area
boolean fromSharedArea = dragElementLocation == EModelService.IN_SHARED_AREA;
// if from shared area and no modifier, is ok
// if not from shared area and modifier is on, then ok
boolean shouldBePlacedInSharedArea = fromSharedArea == !isModified();
if (shouldBePlacedInSharedArea) {
MArea area = (MArea) relToElement;
relToElement = area.getChildren().get(0);
}
} else if (relToElement instanceof MPerspective) {
} else if (relToElement instanceof MPerspective persp) {
if (dragElementLocation == EModelService.IN_ACTIVE_PERSPECTIVE) {
MPerspective persp = (MPerspective) relToElement;
relToElement = persp.getChildren().get(0);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ public class SplitFeedbackOverlay {

private Shell feedbackShell;
private int curSide = 0;
private float ratio;
private final float ratio;

private List<Rectangle> rects = new ArrayList<>();
private Rectangle outerRect;
private final List<Rectangle> rects = new ArrayList<>();
private final Rectangle outerRect;

Boolean isModified = null;
private IStylingEngine stylingEngine;
private final IStylingEngine stylingEngine;

public SplitFeedbackOverlay(Shell dragShell, Rectangle rect, int side, float pct,
boolean enclosed, boolean modified) {
Expand Down Expand Up @@ -119,9 +119,7 @@ private void defineRegion() {
// shadows will end up being drawn on top of the shadows for the parent
// shell rather than in the middle of the workbench window.
Composite parent = feedbackShell.getParent();
if (parent instanceof Shell) {
Shell parentShell = (Shell) parent;

if (parent instanceof Shell parentShell) {
Rectangle bounds = parentShell.getBounds();
rgn.add(bounds.width - 1, bounds.height - 1, 1, 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,10 @@ public boolean canDrop(MUIElement dragElement, DnDInfo info) {
}

// We have to be over a stack ourselves
if (!(info.curElement instanceof MPartStack)) {
if (!(info.curElement instanceof MPartStack stack)) {
return false;
}

MPartStack stack = (MPartStack) info.curElement;

if (stack.getTags().contains(IPresentationEngine.STANDALONE)) {
return false;
}
Expand Down Expand Up @@ -416,7 +414,7 @@ public boolean drop(MUIElement dragElement, DnDInfo info) {
if (dndManager.getFeedbackStyle() != DnDManager.HOSTED) {
int dropIndex = getDropIndex(info);
if (dropIndex != -1) {
MUIElement toActivate = dragElement instanceof MPartStack ? ((MPartStack) dragElement)
MUIElement toActivate = dragElement instanceof MPartStack m ? m
.getSelectedElement() : dragElement;
dock(dragElement, dropIndex);
reactivatePart(toActivate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public class MinMaxAddon {
@Inject
MApplication app;

private CTabFolder2Adapter CTFButtonListener = new CTabFolder2Adapter() {
private final CTabFolder2Adapter CTFButtonListener = new CTabFolder2Adapter() {
private MUIElement getElementToChange(CTabFolderEvent event) {
CTabFolder ctf = (CTabFolder) event.widget;
MUIElement element = (MUIElement) ctf.getData(AbstractPartRenderer.OWNING_ME);
Expand Down Expand Up @@ -136,7 +136,7 @@ public void restore(CTabFolderEvent event) {
}
};

private MouseListener CTFDblClickListener = new MouseAdapter() {
private final MouseListener CTFDblClickListener = new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
// HACK! If this is an empty stack treat it as though it was the editor area
Expand Down Expand Up @@ -238,8 +238,7 @@ private void subscribeTopicWidget(@UIEventTopic(UIEvents.UIElement.TOPIC_WIDGET)
}

MUIElement stateElement = changedElement;
if (changedElement instanceof MPartStack) {
MPartStack stack = (MPartStack) changedElement;
if (changedElement instanceof MPartStack stack) {
MArea area = MinMaxAddonUtil.getAreaFor(stack);
if (area != null && !(area.getWidget() instanceof CTabFolder)) {
stateElement = area.getCurSharedRef();
Expand Down Expand Up @@ -320,17 +319,15 @@ private void subscribeTopicSelectedElement(
}

final MUIElement changedElement = (MUIElement) event.getProperty(EventTags.ELEMENT);
if (!(changedElement instanceof MPerspectiveStack)) {
if (!(changedElement instanceof MPerspectiveStack ps)) {
return;
}

MPerspectiveStack ps = (MPerspectiveStack) changedElement;
MWindow window = modelService.getTopLevelWindowFor(ps);
Object widget = window.getWidget();
if (!(widget instanceof Shell)) {
if (!(widget instanceof final Shell winShell)) {
return;
}
final Shell winShell = (Shell) widget;
List<MToolControl> tcList = modelService.findElements(window, null, MToolControl.class);

final MPerspective curPersp = ps.getSelectedElement();
Expand Down Expand Up @@ -391,12 +388,10 @@ private void subscribeTopicTagsChanged(

Object changedObj = event.getProperty(EventTags.ELEMENT);

if (!(changedObj instanceof MUIElement)) {
if (!(changedObj instanceof final MUIElement changedElement)) {
return;
}

final MUIElement changedElement = (MUIElement) changedObj;

if (UIEvents.isADD(event)) {
if (UIEvents.contains(event, UIEvents.EventTags.NEW_VALUE, MINIMIZED)) {
minimize(changedElement);
Expand Down Expand Up @@ -432,12 +427,10 @@ private void subscribeTopicElementId(
Object changedObject = event.getProperty(EventTags.ELEMENT);

// Only care about MPerspective id changes
if (!(changedObject instanceof MPerspective)) {
if (!(changedObject instanceof MPerspective perspective)) {
return;
}

MPerspective perspective = (MPerspective) changedObject;

String newID = (String) event.getProperty(UIEvents.EventTags.NEW_VALUE);
String oldID = (String) event.getProperty(UIEvents.EventTags.OLD_VALUE);

Expand Down Expand Up @@ -622,8 +615,7 @@ private CTabFolder getCTFFor(MUIElement element) {
}
} else if (element.getWidget() instanceof CTabFolder) {
return (CTabFolder) element.getWidget();
} else if (element instanceof MPlaceholder) {
MPlaceholder ph = (MPlaceholder) element;
} else if (element instanceof MPlaceholder ph) {
if (ph.getRef() instanceof MArea) {
return getCTFFor(ph.getRef());
}
Expand All @@ -632,10 +624,9 @@ private CTabFolder getCTFFor(MUIElement element) {
}

boolean isEmptyPerspectiveStack(MUIElement element) {
if (!(element instanceof MPerspectiveStack)) {
if (!(element instanceof MPerspectiveStack ps)) {
return false;
}
MPerspectiveStack ps = (MPerspectiveStack) element;
return ps.getChildren().isEmpty();
}

Expand Down Expand Up @@ -989,11 +980,10 @@ private List<MUIElement> getElementsToRestore(MUIElement element) {

private void createTrim(MUIElement element) {
MWindow win = MinMaxAddonUtil.getWindowFor(element);
if (!(win instanceof MTrimmedWindow)) {
if (!(win instanceof MTrimmedWindow window)) {
return;
}

MTrimmedWindow window = (MTrimmedWindow) win;
Shell winShell = (Shell) window.getWidget();

// Is there already a TrimControl there ?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,9 @@ public static boolean isMinMaxChildrenAreaWithMultipleVisibleChildren(MUIElement
if (!element.getTags().contains(MIN_MAXIMIZEABLE_CHILDREN_AREA_TAG)) {
return false;
}
if (!(element instanceof MArea)) {
if (!(element instanceof MArea area)) {
return false;
}
MArea area = (MArea) element;
if (area.getChildren().isEmpty()) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
public class TrimPaneLayout extends Layout {
private static int BORDER_WIDTH = 4;
private static final Rectangle EMPTY_RECT = new Rectangle(0, 0, 0, 0);
private int fixedCorner;
private final int fixedCorner;

public Rectangle hSizingRect = EMPTY_RECT;
public Rectangle vSizingRect = EMPTY_RECT;
Expand All @@ -43,7 +43,7 @@ public class TrimPaneLayout extends Layout {

int trackState = SWT.NONE;
protected Point curPos;
private MToolControl toolControl;
private final MToolControl toolControl;

public TrimPaneLayout(MToolControl toolControl, int barSide) {
this.toolControl = toolControl;
Expand Down
Loading
Loading