1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-01 14:15:23 +02:00

Lambda conversions.

Change-Id: I500febcaad04a654ece7cc4cc6d918a7f3a9f05a
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
This commit is contained in:
Alexander Kurtakov 2018-12-21 21:08:16 +02:00
parent 861a8430ed
commit 041a7a6560
18 changed files with 257 additions and 419 deletions

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2014 QNX Software Systems and others. * Copyright (c) 2014, 2018 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -13,7 +13,6 @@ package org.eclipse.launchbar.core.internal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.LinkedList; import java.util.LinkedList;
@ -231,9 +230,19 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene
} }
// Sort things // Sort things
orderedDescriptorTypes = new ArrayList<>(descriptorTypes.values()); orderedDescriptorTypes = new ArrayList<>(descriptorTypes.values());
Collections.sort(orderedDescriptorTypes, new Comparator<LaunchDescriptorTypeInfo>() { Collections.sort(orderedDescriptorTypes, (o1, o2) -> {
@Override int p1 = o1.getPriority();
public int compare(LaunchDescriptorTypeInfo o1, LaunchDescriptorTypeInfo o2) { int p2 = o2.getPriority();
if (p1 < p2) {
return 1;
} else if (p1 > p2) {
return -1;
} else {
return 0;
}
});
for (List<LaunchConfigProviderInfo> providers : configProviders.values()) {
Collections.sort(providers, (o1, o2) -> {
int p1 = o1.getPriority(); int p1 = o1.getPriority();
int p2 = o2.getPriority(); int p2 = o2.getPriority();
if (p1 < p2) { if (p1 < p2) {
@ -243,22 +252,6 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene
} else { } else {
return 0; return 0;
} }
}
});
for (List<LaunchConfigProviderInfo> providers : configProviders.values()) {
Collections.sort(providers, new Comparator<LaunchConfigProviderInfo>() {
@Override
public int compare(LaunchConfigProviderInfo o1, LaunchConfigProviderInfo o2) {
int p1 = o1.getPriority();
int p2 = o2.getPriority();
if (p1 < p2) {
return 1;
} else if (p1 > p2) {
return -1;
} else {
return 0;
}
}
}); });
} }
// Now that all the types are loaded, the object providers which now // Now that all the types are loaded, the object providers which now

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2014, 2017 QNX Software Systems and others. * Copyright (c) 2014, 2018 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -18,7 +18,6 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeEvent; import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener; import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.IResourceDelta; import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.launchbar.core.ILaunchBarManager; import org.eclipse.launchbar.core.ILaunchBarManager;
@ -50,30 +49,27 @@ public class ProjectLaunchObjectProvider implements ILaunchObjectProvider, IReso
@Override @Override
public void resourceChanged(IResourceChangeEvent event) { public void resourceChanged(IResourceChangeEvent event) {
try { try {
event.getDelta().accept(new IResourceDeltaVisitor() { event.getDelta().accept(delta -> {
@Override IResource res = delta.getResource();
public boolean visit(IResourceDelta delta) throws CoreException { if (res instanceof IProject) {
IResource res = delta.getResource(); IProject project = (IProject) res;
if (res instanceof IProject) { int kind = delta.getKind();
IProject project = (IProject) res; if ((kind & IResourceDelta.ADDED) != 0) {
int kind = delta.getKind(); manager.launchObjectAdded(project);
if ((kind & IResourceDelta.ADDED) != 0) { } else if ((kind & IResourceDelta.REMOVED) != 0) {
manager.launchObjectAdded(project); manager.launchObjectRemoved(project);
} else if ((kind & IResourceDelta.REMOVED) != 0) { } else if ((kind & IResourceDelta.CHANGED) != 0) {
manager.launchObjectRemoved(project); int flags = delta.getFlags();
} else if ((kind & IResourceDelta.CHANGED) != 0) { // Right now, only care about nature changes
int flags = delta.getFlags(); if ((flags & IResourceDelta.DESCRIPTION) != 0) {
// Right now, only care about nature changes manager.launchObjectChanged(project);
if ((flags & IResourceDelta.DESCRIPTION) != 0) {
manager.launchObjectChanged(project);
}
} }
return false;
} else if (res instanceof IFile || res instanceof IFolder) {
return false;
} }
return true; return false;
} else if (res instanceof IFile || res instanceof IFolder) {
return false;
} }
return true;
}); });
} catch (CoreException e) { } catch (CoreException e) {
Activator.log(e.getStatus()); Activator.log(e.getStatus());

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2014 QNX Software Systems and others. * Copyright (c) 2014, 2018 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -14,8 +14,6 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseTrackAdapter; import org.eclipse.swt.events.MouseTrackAdapter;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Point;
@ -31,21 +29,18 @@ public class CButton extends Canvas {
public CButton(Composite parent, int style) { public CButton(Composite parent, int style) {
super(parent, style); super(parent, style);
addPaintListener(new PaintListener() { addPaintListener(e -> {
@Override if (inButton) {
public void paintControl(PaintEvent e) { if (hotImage != null) {
if (inButton) { e.gc.drawImage(hotImage, 0, 0);
if (hotImage != null) { } else if (coldImage != null) {
e.gc.drawImage(hotImage, 0, 0); e.gc.drawImage(coldImage, 0, 0);
} else if (coldImage != null) { }
e.gc.drawImage(coldImage, 0, 0); } else {
} if (coldImage != null) {
} else { e.gc.drawImage(coldImage, 0, 0);
if (coldImage != null) { } else if (hotImage != null) {
e.gc.drawImage(coldImage, 0, 0); e.gc.drawImage(hotImage, 0, 0);
} else if (hotImage != null) {
e.gc.drawImage(hotImage, 0, 0);
}
} }
} }
}); });

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2014 QNX Software Systems and others. * Copyright (c) 2014, 2018 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -19,18 +19,12 @@ import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.layout.GridLayoutFactory; import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener; import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Color;
@ -141,17 +135,14 @@ public abstract class CSelector extends Composite {
GridLayout mainButtonLayout = new GridLayout(); GridLayout mainButtonLayout = new GridLayout();
setLayout(mainButtonLayout); setLayout(mainButtonLayout);
addPaintListener(new PaintListener() { addPaintListener(e -> {
@Override GC gc = e.gc;
public void paintControl(PaintEvent e) { gc.setBackground(getBackground());
GC gc = e.gc; gc.setForeground(getOutlineColor());
gc.setBackground(getBackground()); Point size = getSize();
gc.setForeground(getOutlineColor()); final int arc = 3;
Point size = getSize(); gc.fillRoundRectangle(0, 0, size.x - 1, size.y - 1, arc, arc);
final int arc = 3; gc.drawRoundRectangle(0, 0, size.x - 1, size.y - 1, arc, arc);
gc.fillRoundRectangle(0, 0, size.x - 1, size.y - 1, arc, arc);
gc.drawRoundRectangle(0, 0, size.x - 1, size.y - 1, arc, arc);
}
}); });
addMouseListener(mouseListener); addMouseListener(mouseListener);
} }
@ -181,13 +172,10 @@ public abstract class CSelector extends Composite {
return Status.CANCEL_STATUS; return Status.CANCEL_STATUS;
if (isDisposed()) if (isDisposed())
return Status.CANCEL_STATUS; return Status.CANCEL_STATUS;
getDisplay().asyncExec(new Runnable() { getDisplay().asyncExec(() -> {
@Override if (monitor.isCanceled())
public void run() { return;
if (monitor.isCanceled()) setSelection(element);
return;
setSelection(element);
}
}); });
return Status.OK_STATUS; return Status.OK_STATUS;
} }
@ -245,21 +233,18 @@ public abstract class CSelector extends Composite {
arrow.setBackground(getBackground()); arrow.setBackground(getBackground());
arrow.setForeground(getForeground()); arrow.setForeground(getForeground());
arrowTransition = new Transition(arrow, arrowMax, 80); arrowTransition = new Transition(arrow, arrowMax, 80);
arrow.addPaintListener(new PaintListener() { arrow.addPaintListener(e -> {
@Override final int hPadding = 2;
public void paintControl(PaintEvent e) { GC gc = e.gc;
final int hPadding = 2; LineAttributes attributes = new LineAttributes(2);
GC gc = e.gc; attributes.cap = SWT.CAP_ROUND;
LineAttributes attributes = new LineAttributes(2); gc.setLineAttributes(attributes);
attributes.cap = SWT.CAP_ROUND; gc.setAlpha(mouseOver ? 255 : 100);
gc.setLineAttributes(attributes); Rectangle bounds = arrow.getBounds();
gc.setAlpha(mouseOver ? 255 : 100); int arrowWidth = bounds.width - hPadding * 2;
Rectangle bounds = arrow.getBounds(); int current = arrowTransition.getCurrent();
int arrowWidth = bounds.width - hPadding * 2; gc.drawPolyline(new int[] { hPadding, bounds.height / 2 - current, hPadding + (arrowWidth / 2),
int current = arrowTransition.getCurrent(); bounds.height / 2 + current, hPadding + arrowWidth, bounds.height / 2 - current });
gc.drawPolyline(new int[] { hPadding, bounds.height / 2 - current, hPadding + (arrowWidth / 2),
bounds.height / 2 + current, hPadding + arrowWidth, bounds.height / 2 - current });
}
}); });
arrow.addMouseListener(mouseListener); arrow.addMouseListener(mouseListener);
if (editable) { if (editable) {
@ -272,12 +257,9 @@ public abstract class CSelector extends Composite {
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
// Need to run this after the current event storm // Need to run this after the current event storm
// Or we get a disposed error. // Or we get a disposed error.
getDisplay().asyncExec(new Runnable() { getDisplay().asyncExec(() -> {
@Override if (CSelector.this.selection != null)
public void run() { handleEdit(selection);
if (CSelector.this.selection != null)
handleEdit(selection);
}
}); });
} }
}); });
@ -311,18 +293,15 @@ public abstract class CSelector extends Composite {
initializeListViewer(listViewer); initializeListViewer(listViewer);
listViewer.setFilterVisible(elements.length > 7); listViewer.setFilterVisible(elements.length > 7);
listViewer.setInput(input); listViewer.setInput(input);
listViewer.addSelectionChangedListener(new ISelectionChangedListener() { listViewer.addSelectionChangedListener(event -> {
@Override if (!listViewer.isFinalSelection())
public void selectionChanged(SelectionChangedEvent event) { return;
if (!listViewer.isFinalSelection()) StructuredSelection ss = (StructuredSelection) event.getSelection();
return; if (!ss.isEmpty()) {
StructuredSelection ss = (StructuredSelection) event.getSelection(); setSelection(ss.getFirstElement());
if (!ss.isEmpty()) { fireSelectionChanged();
setSelection(ss.getFirstElement());
fireSelectionChanged();
}
closePopup();
} }
closePopup();
}); });
if (hasActionArea()) if (hasActionArea())
createActionArea(popup); createActionArea(popup);
@ -335,14 +314,11 @@ public abstract class CSelector extends Composite {
getDisplay().addFilter(SWT.FocusIn, focusOutListener); getDisplay().addFilter(SWT.FocusIn, focusOutListener);
getDisplay().addFilter(SWT.FocusOut, focusOutListener); getDisplay().addFilter(SWT.FocusOut, focusOutListener);
getDisplay().addFilter(SWT.MouseUp, focusOutListener); getDisplay().addFilter(SWT.MouseUp, focusOutListener);
popup.addDisposeListener(new DisposeListener() { popup.addDisposeListener(e -> {
@Override getDisplay().removeFilter(SWT.FocusIn, focusOutListener);
public void widgetDisposed(DisposeEvent e) { getDisplay().removeFilter(SWT.FocusOut, focusOutListener);
getDisplay().removeFilter(SWT.FocusIn, focusOutListener); getDisplay().removeFilter(SWT.MouseUp, focusOutListener);
getDisplay().removeFilter(SWT.FocusOut, focusOutListener); saveShellSize();
getDisplay().removeFilter(SWT.MouseUp, focusOutListener);
saveShellSize();
}
}); });
} }
@ -384,16 +360,13 @@ public abstract class CSelector extends Composite {
} }
private void closePopup() { private void closePopup() {
getDisplay().asyncExec(new Runnable() { getDisplay().asyncExec(() -> {
@Override if (popup == null || popup.isDisposed()) {
public void run() { return;
if (popup == null || popup.isDisposed()) {
return;
}
arrowTransition.to(arrowMax);
popup.setVisible(false);
popup.dispose();
} }
arrowTransition.to(arrowMax);
popup.setVisible(false);
popup.dispose();
}); });
} }
@ -415,12 +388,7 @@ public abstract class CSelector extends Composite {
icon.setImage(image); icon.setImage(image);
if (disposeImage) { if (disposeImage) {
final Image disposableImage = image; final Image disposableImage = image;
icon.addDisposeListener(new DisposeListener() { icon.addDisposeListener(e -> disposableImage.dispose());
@Override
public void widgetDisposed(DisposeEvent e) {
disposableImage.dispose();
}
});
} }
return icon; return icon;
} }
@ -490,16 +458,13 @@ public abstract class CSelector extends Composite {
} }
public void refresh() { public void refresh() {
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { PlatformUI.getWorkbench().getDisplay().asyncExec(() -> {
@Override if (isDisposed())
public void run() { return;
if (isDisposed()) update(selection); // update current selection - name or icon
return; // may have changed
update(selection); // update current selection - name or icon if (popup != null && !popup.isDisposed()) {
// may have changed listViewer.refresh(true); // update all labels in the popup
if (popup != null && !popup.isDisposed()) {
listViewer.refresh(true); // update all labels in the popup
}
} }
}); });
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2014 QNX Software Systems and others. * Copyright (c) 2014, 2018 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -10,8 +10,6 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.launchbar.ui.controls.internal; package org.eclipse.launchbar.ui.controls.internal;
import java.util.Comparator;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
@ -120,12 +118,7 @@ public class ConfigSelector extends CSelector {
// no sorter for top, data is sorted by provider in historical order // no sorter for top, data is sorted by provider in historical order
setHistorySortComparator(null); setHistorySortComparator(null);
// alphabetic sorter // alphabetic sorter
setSorter(new Comparator<ILaunchDescriptor>() { setSorter((ILaunchDescriptor o1, ILaunchDescriptor o2) -> o1.getName().compareTo(o2.getName()));
@Override
public int compare(ILaunchDescriptor o1, ILaunchDescriptor o2) {
return o1.getName().compareTo(o2.getName());
}
});
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2014, 2015 QNX Software Systems and others. * Copyright (c) 2014, 2018 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -24,18 +24,12 @@ import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.accessibility.AccessibleAdapter; import org.eclipse.swt.accessibility.AccessibleAdapter;
import org.eclipse.swt.accessibility.AccessibleEvent; import org.eclipse.swt.accessibility.AccessibleEvent;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.FocusAdapter; import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent; import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.TraverseEvent;
import org.eclipse.swt.events.TraverseListener;
import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridLayout;
@ -145,12 +139,7 @@ public class FilterControl extends Composite {
public Control attachListViewer(LaunchBarListViewer listViewer) { public Control attachListViewer(LaunchBarListViewer listViewer) {
this.listViewer = listViewer; this.listViewer = listViewer;
// listViewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); // listViewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
listViewer.getControl().addDisposeListener(new DisposeListener() { listViewer.getControl().addDisposeListener(e -> refreshJob.cancel());
@Override
public void widgetDisposed(DisposeEvent e) {
refreshJob.cancel();
}
});
listViewer.addFilter(patternFilter); listViewer.addFilter(patternFilter);
return listViewer.getControl(); return listViewer.getControl();
} }
@ -272,28 +261,20 @@ public class FilterControl extends Composite {
} }
}); });
// enter key set focus to tree // enter key set focus to tree
filterText.addTraverseListener(new TraverseListener() { filterText.addTraverseListener(e -> {
@Override if (e.detail == SWT.TRAVERSE_RETURN) {
public void keyTraversed(TraverseEvent e) { e.doit = false;
if (e.detail == SWT.TRAVERSE_RETURN) { listViewer.setFocus();
e.doit = false; updateListSelection(true);
listViewer.setFocus(); } else if (e.detail == SWT.TRAVERSE_ARROW_NEXT) {
updateListSelection(true); listViewer.setFocus();
} else if (e.detail == SWT.TRAVERSE_ARROW_NEXT) { updateListSelection(false);
listViewer.setFocus(); } else if (e.detail == SWT.TRAVERSE_ESCAPE) {
updateListSelection(false); listViewer.setDefaultSelection(new StructuredSelection());
} else if (e.detail == SWT.TRAVERSE_ESCAPE) { e.doit = false;
listViewer.setDefaultSelection(new StructuredSelection());
e.doit = false;
}
}
});
filterText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
textChanged();
} }
}); });
filterText.addModifyListener(e -> textChanged());
// if we're using a field with built in cancel we need to listen for // if we're using a field with built in cancel we need to listen for
// default selection changes (which tell us the cancel button has been // default selection changes (which tell us the cancel button has been
// pressed) // pressed)
@ -438,13 +419,10 @@ public class FilterControl extends Composite {
setFilterText(initialText); setFilterText(initialText);
textChanged(); textChanged();
} else { } else {
getDisplay().asyncExec(new Runnable() { getDisplay().asyncExec(() -> {
@Override if (!filterText.isDisposed() && filterText.isFocusControl()) {
public void run() { setFilterText(initialText);
if (!filterText.isDisposed() && filterText.isFocusControl()) { textChanged();
setFilterText(initialText);
textChanged();
}
} }
}); });
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2014, 2015 QNX Software Systems and others. * Copyright (c) 2014, 2018 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -28,8 +28,6 @@ import org.eclipse.launchbar.core.ILaunchDescriptor;
import org.eclipse.launchbar.core.target.ILaunchTarget; import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.launchbar.ui.ILaunchBarUIConstants; import org.eclipse.launchbar.ui.ILaunchBarUIConstants;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridData;
@ -68,12 +66,7 @@ public class LaunchBarControl implements ILaunchBarListener {
layout.marginHeight = 2; layout.marginHeight = 2;
layout.marginWidth = 2; layout.marginWidth = 2;
container.setLayout(layout); container.setLayout(layout);
container.addDisposeListener(new DisposeListener() { container.addDisposeListener(e -> LaunchBarControl.this.dispose());
@Override
public void widgetDisposed(DisposeEvent e) {
LaunchBarControl.this.dispose();
}
});
ToolBar toolBar = new ToolBar(container, SWT.FLAT); ToolBar toolBar = new ToolBar(container, SWT.FLAT);
IPreferenceStore store = Activator.getDefault().getPreferenceStore(); IPreferenceStore store = Activator.getDefault().getPreferenceStore();
@ -171,12 +164,7 @@ public class LaunchBarControl implements ILaunchBarListener {
} }
}; };
}); });
button.addDisposeListener(new DisposeListener() { button.addDisposeListener(e -> image.dispose());
@Override
public void widgetDisposed(DisposeEvent e) {
image.dispose();
}
});
return button; return button;
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2014, 2014 QNX Software Systems and others. * Copyright (c) 2014, 2018 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -26,11 +26,7 @@ import org.eclipse.e4.ui.model.application.ui.menu.MMenuFactory;
import org.eclipse.e4.ui.model.application.ui.menu.MToolControl; import org.eclipse.e4.ui.model.application.ui.menu.MToolControl;
import org.eclipse.e4.ui.workbench.UIEvents; import org.eclipse.e4.ui.workbench.UIEvents;
import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.widgets.Widget; import org.eclipse.swt.widgets.Widget;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventHandler;
public class LaunchBarInjector { public class LaunchBarInjector {
@ -47,39 +43,33 @@ public class LaunchBarInjector {
injectIntoAll(enabled); injectIntoAll(enabled);
// Watch for new trimmed windows and inject there too. // Watch for new trimmed windows and inject there too.
eventBroker.subscribe(UIEvents.TrimmedWindow.TOPIC_TRIMBARS, new EventHandler() { eventBroker.subscribe(UIEvents.TrimmedWindow.TOPIC_TRIMBARS, event -> {
@Override if (!UIEvents.isADD(event))
public void handleEvent(Event event) { return;
if (!UIEvents.isADD(event)) Object newValue = event.getProperty(UIEvents.EventTags.NEW_VALUE);
return; if (newValue instanceof MTrimBar) {
Object newValue = event.getProperty(UIEvents.EventTags.NEW_VALUE); MTrimBar trimBar = (MTrimBar) newValue;
if (newValue instanceof MTrimBar) { if (trimBar.getSide() == SideValue.TOP) {
MTrimBar trimBar = (MTrimBar) newValue; IPreferenceStore store1 = Activator.getDefault().getPreferenceStore();
if (trimBar.getSide() == SideValue.TOP) { boolean enabled1 = store1.getBoolean(Activator.PREF_ENABLE_LAUNCHBAR);
IPreferenceStore store = Activator.getDefault().getPreferenceStore(); injectLaunchBar(trimBar, enabled1);
boolean enabled = store.getBoolean(Activator.PREF_ENABLE_LAUNCHBAR);
injectLaunchBar(trimBar, enabled);
}
} }
} }
}); });
// Watch for preference changes // Watch for preference changes
Activator.getDefault().getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener() { Activator.getDefault().getPreferenceStore().addPropertyChangeListener(event -> {
@Override if (event.getProperty().equals(Activator.PREF_ENABLE_LAUNCHBAR)) {
public void propertyChange(PropertyChangeEvent event) { boolean enabled1 = Boolean.parseBoolean(event.getNewValue().toString());
if (event.getProperty().equals(Activator.PREF_ENABLE_LAUNCHBAR)) { injectIntoAll(enabled1);
boolean enabled = Boolean.parseBoolean(event.getNewValue().toString()); }
injectIntoAll(enabled); if (event.getProperty().equals(Activator.PREF_ALWAYS_TARGETSELECTOR)
} || event.getProperty().equals(Activator.PREF_ENABLE_BUILDBUTTON)) {
if (event.getProperty().equals(Activator.PREF_ALWAYS_TARGETSELECTOR) IPreferenceStore store1 = Activator.getDefault().getPreferenceStore();
|| event.getProperty().equals(Activator.PREF_ENABLE_BUILDBUTTON)) { boolean enabled2 = store1.getBoolean(Activator.PREF_ENABLE_LAUNCHBAR);
IPreferenceStore store = Activator.getDefault().getPreferenceStore(); if (enabled2){
boolean enabled = store.getBoolean(Activator.PREF_ENABLE_LAUNCHBAR); injectIntoAll(false);
if (enabled){ injectIntoAll(true);
injectIntoAll(false);
injectIntoAll(true);
}
} }
} }
}); });

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2014 QNX Software Systems and others. * Copyright (c) 2014, 2018 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -28,8 +28,6 @@ import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.launchbar.core.ILaunchDescriptor; import org.eclipse.launchbar.core.ILaunchDescriptor;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite; import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseAdapter;
@ -39,7 +37,6 @@ import org.eclipse.swt.events.MouseTrackAdapter;
import org.eclipse.swt.events.MouseTrackListener; import org.eclipse.swt.events.MouseTrackListener;
import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.events.TraverseEvent;
import org.eclipse.swt.events.TraverseListener; import org.eclipse.swt.events.TraverseListener;
import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.GC;
@ -50,9 +47,7 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Sash; import org.eclipse.swt.widgets.Sash;
import org.eclipse.swt.widgets.Widget; import org.eclipse.swt.widgets.Widget;
@ -85,57 +80,54 @@ public class LaunchBarListViewer extends StructuredViewer {
} }
} }
private TraverseListener listItemTraverseListener = new TraverseListener() { private TraverseListener listItemTraverseListener = e -> {
@Override final ListItem currItem = selIndex >= 0 ? listItems[selIndex] : null;
public void keyTraversed(TraverseEvent e) { if (currItem == null && e.keyCode != SWT.ARROW_DOWN) {
final ListItem currItem = selIndex >= 0 ? listItems[selIndex] : null; return;
if (currItem == null && e.keyCode != SWT.ARROW_DOWN) { }
return; if (e.detail == SWT.TRAVERSE_ARROW_NEXT || e.detail == SWT.TRAVERSE_TAB_NEXT) {
} if (e.keyCode == SWT.ARROW_DOWN) {
if (e.detail == SWT.TRAVERSE_ARROW_NEXT || e.detail == SWT.TRAVERSE_TAB_NEXT) { int maxIdx = listItems.length - 1;
if (e.keyCode == SWT.ARROW_DOWN) { if (selIndex < maxIdx) {
int maxIdx = listItems.length - 1; // move to next item
if (selIndex < maxIdx) { listItems[selIndex + 1].setSelected(true);
// move to next item if (scrollBucket < maxScrollBucket) {
listItems[selIndex + 1].setSelected(true); scrollBucket++;
if (scrollBucket < maxScrollBucket) { } else {
scrollBucket++; // need to scroll the list up 1 item
} else { int sY1 = listScrolled.getOrigin().y;
// need to scroll the list up 1 item listScrolled.setOrigin(0, sY1 + itemH);
int sY = listScrolled.getOrigin().y;
listScrolled.setOrigin(0, sY + itemH);
}
} else if (selIndex == maxIdx && maxIdx > maxScrollBucket) {
// level the scroll for any offset at the bottom of the list
listScrolled.setOrigin(0, itemH * (maxIdx - maxScrollBucket + 1));
} }
} else if (selIndex == maxIdx && maxIdx > maxScrollBucket) {
// level the scroll for any offset at the bottom of the list
listScrolled.setOrigin(0, itemH * (maxIdx - maxScrollBucket + 1));
} }
} else if (e.detail == SWT.TRAVERSE_ARROW_PREVIOUS || e.detail == SWT.TRAVERSE_TAB_PREVIOUS) {
if (e.keyCode == SWT.ARROW_UP) {
if (selIndex > 0) {
// move to previous item
if (scrollBucket > 0) {
scrollBucket--;
} else {
// need to scroll the list down 1 item
int sY = listScrolled.getOrigin().y;
listScrolled.setOrigin(0, sY - itemH);
}
listItems[selIndex - 1].setSelected(true);
} else if (selIndex == 0) {
// level any offset @ beginning
listScrolled.setOrigin(0, 0);
}
} else if (currItem.editButton != null) {
// remove focus from edit button
currItem.editButton.setSelected(false);
currItem.editButton.redraw();
}
} else if (e.detail == SWT.TRAVERSE_RETURN) {
setDefaultSelection(new StructuredSelection(currItem.element));
} else if (e.detail == SWT.TRAVERSE_ESCAPE) {
setDefaultSelection(new StructuredSelection());
} }
} else if (e.detail == SWT.TRAVERSE_ARROW_PREVIOUS || e.detail == SWT.TRAVERSE_TAB_PREVIOUS) {
if (e.keyCode == SWT.ARROW_UP) {
if (selIndex > 0) {
// move to previous item
if (scrollBucket > 0) {
scrollBucket--;
} else {
// need to scroll the list down 1 item
int sY2 = listScrolled.getOrigin().y;
listScrolled.setOrigin(0, sY2 - itemH);
}
listItems[selIndex - 1].setSelected(true);
} else if (selIndex == 0) {
// level any offset @ beginning
listScrolled.setOrigin(0, 0);
}
} else if (currItem.editButton != null) {
// remove focus from edit button
currItem.editButton.setSelected(false);
currItem.editButton.redraw();
}
} else if (e.detail == SWT.TRAVERSE_RETURN) {
setDefaultSelection(new StructuredSelection(currItem.element));
} else if (e.detail == SWT.TRAVERSE_ESCAPE) {
setDefaultSelection(new StructuredSelection());
} }
}; };
@ -308,12 +300,7 @@ public class LaunchBarListViewer extends StructuredViewer {
icon.setImage(image); icon.setImage(image);
if (disposeImage) { if (disposeImage) {
final Image disposableImage = image; final Image disposableImage = image;
icon.addDisposeListener(new DisposeListener() { icon.addDisposeListener(e -> disposableImage.dispose());
@Override
public void widgetDisposed(DisposeEvent e) {
disposableImage.dispose();
}
});
} }
icon.setBackground(parent.getBackground()); icon.setBackground(parent.getBackground());
return icon; return icon;
@ -361,12 +348,7 @@ public class LaunchBarListViewer extends StructuredViewer {
sash.moveBelow(null); sash.moveBelow(null);
sash.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_LIST_SELECTION)); sash.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_LIST_SELECTION));
sash.addListener(SWT.Selection, new Listener() { sash.addListener(SWT.Selection, e -> separatorIndex = (e.y + itemH / 2) / itemH);
@Override
public void handleEvent(Event e) {
separatorIndex = (e.y + itemH / 2) / itemH;
}
});
sash.addMouseListener(new MouseListener() { sash.addMouseListener(new MouseListener() {
@Override @Override
public void mouseUp(MouseEvent e) { public void mouseUp(MouseEvent e) {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2014 QNX Software Systems and others. * Copyright (c) 2014, 2018 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -10,7 +10,6 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.launchbar.ui.controls.internal; package org.eclipse.launchbar.ui.controls.internal;
import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -107,32 +106,29 @@ public class ModeSelector extends CSelector {
return super.getText(element); return super.getText(element);
} }
}); });
setSorter(new Comparator<Object>() { setSorter((o1, o2) -> {
@Override if (o1 instanceof ILaunchMode && o2 instanceof ILaunchMode) {
public int compare(Object o1, Object o2) { String mode1 = ((ILaunchMode) o1).getIdentifier();
if (o1 instanceof ILaunchMode && o2 instanceof ILaunchMode) { String mode2 = ((ILaunchMode) o2).getIdentifier();
String mode1 = ((ILaunchMode) o1).getIdentifier(); // run comes first, then debug, then the rest
String mode2 = ((ILaunchMode) o2).getIdentifier(); if (mode1.equals("run")) { //$NON-NLS-1$
// run comes first, then debug, then the rest
if (mode1.equals("run")) { //$NON-NLS-1$
if (mode2.equals("run")) //$NON-NLS-1$
return 0;
else
return -1;
}
if (mode2.equals("run")) //$NON-NLS-1$ if (mode2.equals("run")) //$NON-NLS-1$
return 1; return 0;
if (mode1.equals("debug")) { //$NON-NLS-1$ else
if (mode2.equals("debug")) //$NON-NLS-1$ return -1;
return 0;
else
return -1;
}
if (mode2.equals("debug")) //$NON-NLS-1$
return 1;
} }
return 0; if (mode2.equals("run")) //$NON-NLS-1$
return 1;
if (mode1.equals("debug")) { //$NON-NLS-1$
if (mode2.equals("debug")) //$NON-NLS-1$
return 0;
else
return -1;
}
if (mode2.equals("debug")) //$NON-NLS-1$
return 1;
} }
return 0;
}); });
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2014 QNX Software Systems and others. * Copyright (c) 2014, 2018 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -10,8 +10,6 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.launchbar.ui.controls.internal; package org.eclipse.launchbar.ui.controls.internal;
import java.util.Comparator;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory; import org.eclipse.jface.layout.GridLayoutFactory;
@ -135,14 +133,11 @@ public class TargetSelector extends CSelector implements ILaunchTargetListener {
} }
}); });
setSorter(new Comparator<Object>() { setSorter((o1, o2) -> {
@Override // Sort by name
public int compare(Object o1, Object o2) { String s1 = String.valueOf(o1);
// Sort by name String s2 = String.valueOf(o2);
String s1 = String.valueOf(o1); return s1.compareTo(s2);
String s2 = String.valueOf(o2);
return s1.compareTo(s2);
}
}); });
} }

View file

@ -26,8 +26,6 @@ import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem; import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.events.FocusAdapter; import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent; import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridData;
@ -121,12 +119,7 @@ public class LaunchBarLaunchConfigDialog extends TitleAreaDialog implements ILau
nameText = new Text(nameComp, SWT.BORDER); nameText = new Text(nameComp, SWT.BORDER);
nameText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); nameText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
nameText.setText(workingCopy.getName()); nameText.setText(workingCopy.getName());
nameText.addModifyListener(new ModifyListener() { nameText.addModifyListener(e -> updateMessage());
@Override
public void modifyText(ModifyEvent e) {
updateMessage();
}
});
tabFolder = new CTabFolder(composite, SWT.BORDER); tabFolder = new CTabFolder(composite, SWT.BORDER);
tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2014 QNX Software Systems and others. * Copyright (c) 2014, 2018 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -191,23 +191,20 @@ public class BuildActiveCommandHandler extends AbstractHandler {
} }
protected void saveEditors(final Collection<IProject> projects) { protected void saveEditors(final Collection<IProject> projects) {
Display.getDefault().syncExec(new Runnable() { Display.getDefault().syncExec(() -> {
@Override IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
public void run() { for (IWorkbenchWindow window : windows) {
IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows(); IWorkbenchPage[] pages = window.getPages();
for (IWorkbenchWindow window : windows) { for (IWorkbenchPage page : pages) {
IWorkbenchPage[] pages = window.getPages(); if (projects.isEmpty()) {
for (IWorkbenchPage page : pages) { page.saveAllEditors(false);
if (projects.isEmpty()) { } else {
page.saveAllEditors(false); IEditorPart[] editors = page.getDirtyEditors();
} else { for (IEditorPart editor : editors) {
IEditorPart[] editors = page.getDirtyEditors(); IFile inputFile = ResourceUtil.getFile(editor.getEditorInput());
for (IEditorPart editor : editors) { if (inputFile != null) {
IFile inputFile = ResourceUtil.getFile(editor.getEditorInput()); if (projects.contains(inputFile.getProject())) {
if (inputFile != null) { page.saveEditor(editor, false);
if (projects.contains(inputFile.getProject())) {
page.saveEditor(editor, false);
}
} }
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2017 QNX Software Systems and others. * Copyright (c) 2017, 2018 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,7 +8,6 @@
package org.eclipse.launchbar.ui.internal.dialogs; package org.eclipse.launchbar.ui.internal.dialogs;
import java.util.Arrays; import java.util.Arrays;
import java.util.Comparator;
import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfigurationType; import org.eclipse.debug.core.ILaunchConfigurationType;
@ -151,15 +150,12 @@ public class NewLaunchConfigTypePage2 extends WizardPage {
editPage.setLaunchGroup(group); editPage.setLaunchGroup(group);
ILaunchConfigurationType[] types = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationTypes(); ILaunchConfigurationType[] types = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationTypes();
Arrays.sort(types, new Comparator<ILaunchConfigurationType>() { Arrays.sort(types, (type0, type1) -> {
@Override int comp = type0.getPluginIdentifier().compareTo(type1.getPluginIdentifier());
public int compare(ILaunchConfigurationType type0, ILaunchConfigurationType type1) { if (comp != 0) {
int comp = type0.getPluginIdentifier().compareTo(type1.getPluginIdentifier()); return comp;
if (comp != 0) { } else {
return comp; return type0.getName().compareTo(type1.getName());
} else {
return type0.getName().compareTo(type1.getName());
}
} }
}); });

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000, 2015 IBM Corporation and others. * Copyright (c) 2000, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -11,7 +11,6 @@
package org.eclipse.launchbar.ui.internal.target; package org.eclipse.launchbar.ui.internal.target;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator;
import java.util.List; import java.util.List;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
@ -68,13 +67,10 @@ class NewLaunchTargetWizardSelectionPage extends WizardPage {
} }
} }
elements.sort(new Comparator<IConfigurationElement>() { elements.sort((o1, o2) -> {
@Override String name1 = o1.getAttribute("name"); //$NON-NLS-1$
public int compare(IConfigurationElement o1, IConfigurationElement o2) { String name2 = o2.getAttribute("name"); //$NON-NLS-1$
String name1 = o1.getAttribute("name"); //$NON-NLS-1$ return name1.compareTo(name2);
String name2 = o2.getAttribute("name"); //$NON-NLS-1$
return name1.compareTo(name2);
}
}); });
for (IConfigurationElement element : elements) { for (IConfigurationElement element : elements) {

View file

@ -37,8 +37,6 @@ import org.eclipse.launchbar.core.ILaunchDescriptorType;
import org.eclipse.launchbar.core.target.ILaunchTarget; import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.launchbar.core.target.ILaunchTargetManager; import org.eclipse.launchbar.core.target.ILaunchTargetManager;
import org.junit.Test; import org.junit.Test;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
public class LaunchBarManagerTest { public class LaunchBarManagerTest {
@Test @Test
@ -172,12 +170,9 @@ public class LaunchBarManagerTest {
doReturn(launchConfig).when(configProvider).getLaunchConfiguration(eq(descriptor), any(ILaunchTarget.class)); doReturn(launchConfig).when(configProvider).getLaunchConfiguration(eq(descriptor), any(ILaunchTarget.class));
doReturn(launchConfigType).when(configProvider).getLaunchConfigurationType(any(ILaunchDescriptor.class), doReturn(launchConfigType).when(configProvider).getLaunchConfigurationType(any(ILaunchDescriptor.class),
any(ILaunchTarget.class)); any(ILaunchTarget.class));
doAnswer(new Answer<Boolean>() { doAnswer(invocation -> {
@Override ILaunchTarget target = (ILaunchTarget) invocation.getArguments()[1];
public Boolean answer(InvocationOnMock invocation) throws Throwable { return target.getTypeId().equals(ILaunchTargetManager.localLaunchTargetTypeId);
ILaunchTarget target = (ILaunchTarget) invocation.getArguments()[1];
return target.getTypeId().equals(ILaunchTargetManager.localLaunchTargetTypeId);
}
}).when(configProvider).supports(eq(descriptor), any(ILaunchTarget.class)); }).when(configProvider).supports(eq(descriptor), any(ILaunchTarget.class));
doReturn(elements.toArray(new IConfigurationElement[0])).when(extension).getConfigurationElements(); doReturn(elements.toArray(new IConfigurationElement[0])).when(extension).getConfigurationElements();

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2017 QNX Software Systems and others. * Copyright (c) 2017, 2018 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -44,12 +44,7 @@ public class SWTBotCSelector extends AbstractSWTBotControl<CSelector> {
@Override @Override
public SWTBotCSelector click() { public SWTBotCSelector click() {
Point size = syncExec(new Result<Point>() { Point size = syncExec((Result<Point>) () -> widget.getSize());
@Override
public Point run() {
return widget.getSize();
}
});
click(size.x / 2, size.y / 2); click(size.x / 2, size.y / 2);
return this; return this;
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2017 QNX Software Systems and others. * Copyright (c) 2017, 2018 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -38,12 +38,7 @@ public class SWTBotConfigSelector extends SWTBotCSelector {
@Override @Override
public ActionArea click() { public ActionArea click() {
Point size = syncExec(new Result<Point>() { Point size = syncExec((Result<Point>) () -> widget.getSize());
@Override
public Point run() {
return widget.getSize();
}
});
click(size.x / 2, size.y / 2); click(size.x / 2, size.y / 2);
return this; return this;
} }