mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-30 21:55:31 +02:00
Lambda conversions.
Change-Id: I500febcaad04a654ece7cc4cc6d918a7f3a9f05a Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
This commit is contained in:
parent
861a8430ed
commit
041a7a6560
18 changed files with 257 additions and 419 deletions
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* 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.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
|
@ -231,9 +230,19 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene
|
|||
}
|
||||
// Sort things
|
||||
orderedDescriptorTypes = new ArrayList<>(descriptorTypes.values());
|
||||
Collections.sort(orderedDescriptorTypes, new Comparator<LaunchDescriptorTypeInfo>() {
|
||||
@Override
|
||||
public int compare(LaunchDescriptorTypeInfo o1, LaunchDescriptorTypeInfo o2) {
|
||||
Collections.sort(orderedDescriptorTypes, (o1, o2) -> {
|
||||
int p1 = o1.getPriority();
|
||||
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 p2 = o2.getPriority();
|
||||
if (p1 < p2) {
|
||||
|
@ -243,22 +252,6 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene
|
|||
} else {
|
||||
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
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* 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.IResourceChangeListener;
|
||||
import org.eclipse.core.resources.IResourceDelta;
|
||||
import org.eclipse.core.resources.IResourceDeltaVisitor;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.launchbar.core.ILaunchBarManager;
|
||||
|
@ -50,30 +49,27 @@ public class ProjectLaunchObjectProvider implements ILaunchObjectProvider, IReso
|
|||
@Override
|
||||
public void resourceChanged(IResourceChangeEvent event) {
|
||||
try {
|
||||
event.getDelta().accept(new IResourceDeltaVisitor() {
|
||||
@Override
|
||||
public boolean visit(IResourceDelta delta) throws CoreException {
|
||||
IResource res = delta.getResource();
|
||||
if (res instanceof IProject) {
|
||||
IProject project = (IProject) res;
|
||||
int kind = delta.getKind();
|
||||
if ((kind & IResourceDelta.ADDED) != 0) {
|
||||
manager.launchObjectAdded(project);
|
||||
} else if ((kind & IResourceDelta.REMOVED) != 0) {
|
||||
manager.launchObjectRemoved(project);
|
||||
} else if ((kind & IResourceDelta.CHANGED) != 0) {
|
||||
int flags = delta.getFlags();
|
||||
// Right now, only care about nature changes
|
||||
if ((flags & IResourceDelta.DESCRIPTION) != 0) {
|
||||
manager.launchObjectChanged(project);
|
||||
}
|
||||
event.getDelta().accept(delta -> {
|
||||
IResource res = delta.getResource();
|
||||
if (res instanceof IProject) {
|
||||
IProject project = (IProject) res;
|
||||
int kind = delta.getKind();
|
||||
if ((kind & IResourceDelta.ADDED) != 0) {
|
||||
manager.launchObjectAdded(project);
|
||||
} else if ((kind & IResourceDelta.REMOVED) != 0) {
|
||||
manager.launchObjectRemoved(project);
|
||||
} else if ((kind & IResourceDelta.CHANGED) != 0) {
|
||||
int flags = delta.getFlags();
|
||||
// Right now, only care about nature changes
|
||||
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) {
|
||||
Activator.log(e.getStatus());
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* 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.MouseEvent;
|
||||
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.graphics.Image;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
|
@ -31,21 +29,18 @@ public class CButton extends Canvas {
|
|||
|
||||
public CButton(Composite parent, int style) {
|
||||
super(parent, style);
|
||||
addPaintListener(new PaintListener() {
|
||||
@Override
|
||||
public void paintControl(PaintEvent e) {
|
||||
if (inButton) {
|
||||
if (hotImage != null) {
|
||||
e.gc.drawImage(hotImage, 0, 0);
|
||||
} else if (coldImage != null) {
|
||||
e.gc.drawImage(coldImage, 0, 0);
|
||||
}
|
||||
} else {
|
||||
if (coldImage != null) {
|
||||
e.gc.drawImage(coldImage, 0, 0);
|
||||
} else if (hotImage != null) {
|
||||
e.gc.drawImage(hotImage, 0, 0);
|
||||
}
|
||||
addPaintListener(e -> {
|
||||
if (inButton) {
|
||||
if (hotImage != null) {
|
||||
e.gc.drawImage(hotImage, 0, 0);
|
||||
} else if (coldImage != null) {
|
||||
e.gc.drawImage(coldImage, 0, 0);
|
||||
}
|
||||
} else {
|
||||
if (coldImage != null) {
|
||||
e.gc.drawImage(coldImage, 0, 0);
|
||||
} else if (hotImage != null) {
|
||||
e.gc.drawImage(hotImage, 0, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* 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.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.viewers.ILabelProvider;
|
||||
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
||||
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
||||
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
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.MouseEvent;
|
||||
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.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
|
@ -141,17 +135,14 @@ public abstract class CSelector extends Composite {
|
|||
|
||||
GridLayout mainButtonLayout = new GridLayout();
|
||||
setLayout(mainButtonLayout);
|
||||
addPaintListener(new PaintListener() {
|
||||
@Override
|
||||
public void paintControl(PaintEvent e) {
|
||||
GC gc = e.gc;
|
||||
gc.setBackground(getBackground());
|
||||
gc.setForeground(getOutlineColor());
|
||||
Point size = getSize();
|
||||
final int arc = 3;
|
||||
gc.fillRoundRectangle(0, 0, size.x - 1, size.y - 1, arc, arc);
|
||||
gc.drawRoundRectangle(0, 0, size.x - 1, size.y - 1, arc, arc);
|
||||
}
|
||||
addPaintListener(e -> {
|
||||
GC gc = e.gc;
|
||||
gc.setBackground(getBackground());
|
||||
gc.setForeground(getOutlineColor());
|
||||
Point size = getSize();
|
||||
final int arc = 3;
|
||||
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);
|
||||
}
|
||||
|
@ -181,13 +172,10 @@ public abstract class CSelector extends Composite {
|
|||
return Status.CANCEL_STATUS;
|
||||
if (isDisposed())
|
||||
return Status.CANCEL_STATUS;
|
||||
getDisplay().asyncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (monitor.isCanceled())
|
||||
return;
|
||||
setSelection(element);
|
||||
}
|
||||
getDisplay().asyncExec(() -> {
|
||||
if (monitor.isCanceled())
|
||||
return;
|
||||
setSelection(element);
|
||||
});
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
|
@ -245,21 +233,18 @@ public abstract class CSelector extends Composite {
|
|||
arrow.setBackground(getBackground());
|
||||
arrow.setForeground(getForeground());
|
||||
arrowTransition = new Transition(arrow, arrowMax, 80);
|
||||
arrow.addPaintListener(new PaintListener() {
|
||||
@Override
|
||||
public void paintControl(PaintEvent e) {
|
||||
final int hPadding = 2;
|
||||
GC gc = e.gc;
|
||||
LineAttributes attributes = new LineAttributes(2);
|
||||
attributes.cap = SWT.CAP_ROUND;
|
||||
gc.setLineAttributes(attributes);
|
||||
gc.setAlpha(mouseOver ? 255 : 100);
|
||||
Rectangle bounds = arrow.getBounds();
|
||||
int arrowWidth = bounds.width - hPadding * 2;
|
||||
int current = arrowTransition.getCurrent();
|
||||
gc.drawPolyline(new int[] { hPadding, bounds.height / 2 - current, hPadding + (arrowWidth / 2),
|
||||
bounds.height / 2 + current, hPadding + arrowWidth, bounds.height / 2 - current });
|
||||
}
|
||||
arrow.addPaintListener(e -> {
|
||||
final int hPadding = 2;
|
||||
GC gc = e.gc;
|
||||
LineAttributes attributes = new LineAttributes(2);
|
||||
attributes.cap = SWT.CAP_ROUND;
|
||||
gc.setLineAttributes(attributes);
|
||||
gc.setAlpha(mouseOver ? 255 : 100);
|
||||
Rectangle bounds = arrow.getBounds();
|
||||
int arrowWidth = bounds.width - hPadding * 2;
|
||||
int current = arrowTransition.getCurrent();
|
||||
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);
|
||||
if (editable) {
|
||||
|
@ -272,12 +257,9 @@ public abstract class CSelector extends Composite {
|
|||
public void widgetSelected(SelectionEvent e) {
|
||||
// Need to run this after the current event storm
|
||||
// Or we get a disposed error.
|
||||
getDisplay().asyncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (CSelector.this.selection != null)
|
||||
handleEdit(selection);
|
||||
}
|
||||
getDisplay().asyncExec(() -> {
|
||||
if (CSelector.this.selection != null)
|
||||
handleEdit(selection);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -311,18 +293,15 @@ public abstract class CSelector extends Composite {
|
|||
initializeListViewer(listViewer);
|
||||
listViewer.setFilterVisible(elements.length > 7);
|
||||
listViewer.setInput(input);
|
||||
listViewer.addSelectionChangedListener(new ISelectionChangedListener() {
|
||||
@Override
|
||||
public void selectionChanged(SelectionChangedEvent event) {
|
||||
if (!listViewer.isFinalSelection())
|
||||
return;
|
||||
StructuredSelection ss = (StructuredSelection) event.getSelection();
|
||||
if (!ss.isEmpty()) {
|
||||
setSelection(ss.getFirstElement());
|
||||
fireSelectionChanged();
|
||||
}
|
||||
closePopup();
|
||||
listViewer.addSelectionChangedListener(event -> {
|
||||
if (!listViewer.isFinalSelection())
|
||||
return;
|
||||
StructuredSelection ss = (StructuredSelection) event.getSelection();
|
||||
if (!ss.isEmpty()) {
|
||||
setSelection(ss.getFirstElement());
|
||||
fireSelectionChanged();
|
||||
}
|
||||
closePopup();
|
||||
});
|
||||
if (hasActionArea())
|
||||
createActionArea(popup);
|
||||
|
@ -335,14 +314,11 @@ public abstract class CSelector extends Composite {
|
|||
getDisplay().addFilter(SWT.FocusIn, focusOutListener);
|
||||
getDisplay().addFilter(SWT.FocusOut, focusOutListener);
|
||||
getDisplay().addFilter(SWT.MouseUp, focusOutListener);
|
||||
popup.addDisposeListener(new DisposeListener() {
|
||||
@Override
|
||||
public void widgetDisposed(DisposeEvent e) {
|
||||
getDisplay().removeFilter(SWT.FocusIn, focusOutListener);
|
||||
getDisplay().removeFilter(SWT.FocusOut, focusOutListener);
|
||||
getDisplay().removeFilter(SWT.MouseUp, focusOutListener);
|
||||
saveShellSize();
|
||||
}
|
||||
popup.addDisposeListener(e -> {
|
||||
getDisplay().removeFilter(SWT.FocusIn, focusOutListener);
|
||||
getDisplay().removeFilter(SWT.FocusOut, focusOutListener);
|
||||
getDisplay().removeFilter(SWT.MouseUp, focusOutListener);
|
||||
saveShellSize();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -384,16 +360,13 @@ public abstract class CSelector extends Composite {
|
|||
}
|
||||
|
||||
private void closePopup() {
|
||||
getDisplay().asyncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (popup == null || popup.isDisposed()) {
|
||||
return;
|
||||
}
|
||||
arrowTransition.to(arrowMax);
|
||||
popup.setVisible(false);
|
||||
popup.dispose();
|
||||
getDisplay().asyncExec(() -> {
|
||||
if (popup == null || popup.isDisposed()) {
|
||||
return;
|
||||
}
|
||||
arrowTransition.to(arrowMax);
|
||||
popup.setVisible(false);
|
||||
popup.dispose();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -415,12 +388,7 @@ public abstract class CSelector extends Composite {
|
|||
icon.setImage(image);
|
||||
if (disposeImage) {
|
||||
final Image disposableImage = image;
|
||||
icon.addDisposeListener(new DisposeListener() {
|
||||
@Override
|
||||
public void widgetDisposed(DisposeEvent e) {
|
||||
disposableImage.dispose();
|
||||
}
|
||||
});
|
||||
icon.addDisposeListener(e -> disposableImage.dispose());
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
|
@ -490,16 +458,13 @@ public abstract class CSelector extends Composite {
|
|||
}
|
||||
|
||||
public void refresh() {
|
||||
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (isDisposed())
|
||||
return;
|
||||
update(selection); // update current selection - name or icon
|
||||
// may have changed
|
||||
if (popup != null && !popup.isDisposed()) {
|
||||
listViewer.refresh(true); // update all labels in the popup
|
||||
}
|
||||
PlatformUI.getWorkbench().getDisplay().asyncExec(() -> {
|
||||
if (isDisposed())
|
||||
return;
|
||||
update(selection); // update current selection - name or icon
|
||||
// may have changed
|
||||
if (popup != null && !popup.isDisposed()) {
|
||||
listViewer.refresh(true); // update all labels in the popup
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -10,8 +10,6 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.launchbar.ui.controls.internal;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
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
|
||||
setHistorySortComparator(null);
|
||||
// alphabetic sorter
|
||||
setSorter(new Comparator<ILaunchDescriptor>() {
|
||||
@Override
|
||||
public int compare(ILaunchDescriptor o1, ILaunchDescriptor o2) {
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
}
|
||||
});
|
||||
setSorter((ILaunchDescriptor o1, ILaunchDescriptor o2) -> o1.getName().compareTo(o2.getName()));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* 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.accessibility.AccessibleAdapter;
|
||||
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.FocusEvent;
|
||||
import org.eclipse.swt.events.ModifyEvent;
|
||||
import org.eclipse.swt.events.ModifyListener;
|
||||
import org.eclipse.swt.events.MouseAdapter;
|
||||
import org.eclipse.swt.events.MouseEvent;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
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.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
|
@ -145,12 +139,7 @@ public class FilterControl extends Composite {
|
|||
public Control attachListViewer(LaunchBarListViewer listViewer) {
|
||||
this.listViewer = listViewer;
|
||||
// listViewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
|
||||
listViewer.getControl().addDisposeListener(new DisposeListener() {
|
||||
@Override
|
||||
public void widgetDisposed(DisposeEvent e) {
|
||||
refreshJob.cancel();
|
||||
}
|
||||
});
|
||||
listViewer.getControl().addDisposeListener(e -> refreshJob.cancel());
|
||||
listViewer.addFilter(patternFilter);
|
||||
return listViewer.getControl();
|
||||
}
|
||||
|
@ -272,28 +261,20 @@ public class FilterControl extends Composite {
|
|||
}
|
||||
});
|
||||
// enter key set focus to tree
|
||||
filterText.addTraverseListener(new TraverseListener() {
|
||||
@Override
|
||||
public void keyTraversed(TraverseEvent e) {
|
||||
if (e.detail == SWT.TRAVERSE_RETURN) {
|
||||
e.doit = false;
|
||||
listViewer.setFocus();
|
||||
updateListSelection(true);
|
||||
} else if (e.detail == SWT.TRAVERSE_ARROW_NEXT) {
|
||||
listViewer.setFocus();
|
||||
updateListSelection(false);
|
||||
} else if (e.detail == SWT.TRAVERSE_ESCAPE) {
|
||||
listViewer.setDefaultSelection(new StructuredSelection());
|
||||
e.doit = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
filterText.addModifyListener(new ModifyListener() {
|
||||
@Override
|
||||
public void modifyText(ModifyEvent e) {
|
||||
textChanged();
|
||||
filterText.addTraverseListener(e -> {
|
||||
if (e.detail == SWT.TRAVERSE_RETURN) {
|
||||
e.doit = false;
|
||||
listViewer.setFocus();
|
||||
updateListSelection(true);
|
||||
} else if (e.detail == SWT.TRAVERSE_ARROW_NEXT) {
|
||||
listViewer.setFocus();
|
||||
updateListSelection(false);
|
||||
} else if (e.detail == SWT.TRAVERSE_ESCAPE) {
|
||||
listViewer.setDefaultSelection(new StructuredSelection());
|
||||
e.doit = false;
|
||||
}
|
||||
});
|
||||
filterText.addModifyListener(e -> textChanged());
|
||||
// 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
|
||||
// pressed)
|
||||
|
@ -438,13 +419,10 @@ public class FilterControl extends Composite {
|
|||
setFilterText(initialText);
|
||||
textChanged();
|
||||
} else {
|
||||
getDisplay().asyncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!filterText.isDisposed() && filterText.isFocusControl()) {
|
||||
setFilterText(initialText);
|
||||
textChanged();
|
||||
}
|
||||
getDisplay().asyncExec(() -> {
|
||||
if (!filterText.isDisposed() && filterText.isFocusControl()) {
|
||||
setFilterText(initialText);
|
||||
textChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* 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.ui.ILaunchBarUIConstants;
|
||||
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.graphics.Image;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
|
@ -68,12 +66,7 @@ public class LaunchBarControl implements ILaunchBarListener {
|
|||
layout.marginHeight = 2;
|
||||
layout.marginWidth = 2;
|
||||
container.setLayout(layout);
|
||||
container.addDisposeListener(new DisposeListener() {
|
||||
@Override
|
||||
public void widgetDisposed(DisposeEvent e) {
|
||||
LaunchBarControl.this.dispose();
|
||||
}
|
||||
});
|
||||
container.addDisposeListener(e -> LaunchBarControl.this.dispose());
|
||||
|
||||
ToolBar toolBar = new ToolBar(container, SWT.FLAT);
|
||||
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
|
||||
|
@ -171,12 +164,7 @@ public class LaunchBarControl implements ILaunchBarListener {
|
|||
}
|
||||
};
|
||||
});
|
||||
button.addDisposeListener(new DisposeListener() {
|
||||
@Override
|
||||
public void widgetDisposed(DisposeEvent e) {
|
||||
image.dispose();
|
||||
}
|
||||
});
|
||||
button.addDisposeListener(e -> image.dispose());
|
||||
return button;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* 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.workbench.UIEvents;
|
||||
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.osgi.service.event.Event;
|
||||
import org.osgi.service.event.EventHandler;
|
||||
|
||||
public class LaunchBarInjector {
|
||||
|
||||
|
@ -47,39 +43,33 @@ public class LaunchBarInjector {
|
|||
injectIntoAll(enabled);
|
||||
|
||||
// Watch for new trimmed windows and inject there too.
|
||||
eventBroker.subscribe(UIEvents.TrimmedWindow.TOPIC_TRIMBARS, new EventHandler() {
|
||||
@Override
|
||||
public void handleEvent(Event event) {
|
||||
if (!UIEvents.isADD(event))
|
||||
return;
|
||||
Object newValue = event.getProperty(UIEvents.EventTags.NEW_VALUE);
|
||||
if (newValue instanceof MTrimBar) {
|
||||
MTrimBar trimBar = (MTrimBar) newValue;
|
||||
if (trimBar.getSide() == SideValue.TOP) {
|
||||
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
|
||||
boolean enabled = store.getBoolean(Activator.PREF_ENABLE_LAUNCHBAR);
|
||||
injectLaunchBar(trimBar, enabled);
|
||||
}
|
||||
eventBroker.subscribe(UIEvents.TrimmedWindow.TOPIC_TRIMBARS, event -> {
|
||||
if (!UIEvents.isADD(event))
|
||||
return;
|
||||
Object newValue = event.getProperty(UIEvents.EventTags.NEW_VALUE);
|
||||
if (newValue instanceof MTrimBar) {
|
||||
MTrimBar trimBar = (MTrimBar) newValue;
|
||||
if (trimBar.getSide() == SideValue.TOP) {
|
||||
IPreferenceStore store1 = Activator.getDefault().getPreferenceStore();
|
||||
boolean enabled1 = store1.getBoolean(Activator.PREF_ENABLE_LAUNCHBAR);
|
||||
injectLaunchBar(trimBar, enabled1);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Watch for preference changes
|
||||
Activator.getDefault().getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener() {
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent event) {
|
||||
if (event.getProperty().equals(Activator.PREF_ENABLE_LAUNCHBAR)) {
|
||||
boolean enabled = Boolean.parseBoolean(event.getNewValue().toString());
|
||||
injectIntoAll(enabled);
|
||||
}
|
||||
if (event.getProperty().equals(Activator.PREF_ALWAYS_TARGETSELECTOR)
|
||||
|| event.getProperty().equals(Activator.PREF_ENABLE_BUILDBUTTON)) {
|
||||
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
|
||||
boolean enabled = store.getBoolean(Activator.PREF_ENABLE_LAUNCHBAR);
|
||||
if (enabled){
|
||||
injectIntoAll(false);
|
||||
injectIntoAll(true);
|
||||
}
|
||||
Activator.getDefault().getPreferenceStore().addPropertyChangeListener(event -> {
|
||||
if (event.getProperty().equals(Activator.PREF_ENABLE_LAUNCHBAR)) {
|
||||
boolean enabled1 = Boolean.parseBoolean(event.getNewValue().toString());
|
||||
injectIntoAll(enabled1);
|
||||
}
|
||||
if (event.getProperty().equals(Activator.PREF_ALWAYS_TARGETSELECTOR)
|
||||
|| event.getProperty().equals(Activator.PREF_ENABLE_BUILDBUTTON)) {
|
||||
IPreferenceStore store1 = Activator.getDefault().getPreferenceStore();
|
||||
boolean enabled2 = store1.getBoolean(Activator.PREF_ENABLE_LAUNCHBAR);
|
||||
if (enabled2){
|
||||
injectIntoAll(false);
|
||||
injectIntoAll(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* 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.swt.SWT;
|
||||
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.KeyListener;
|
||||
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.PaintEvent;
|
||||
import org.eclipse.swt.events.PaintListener;
|
||||
import org.eclipse.swt.events.TraverseEvent;
|
||||
import org.eclipse.swt.events.TraverseListener;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
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.Control;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.Sash;
|
||||
import org.eclipse.swt.widgets.Widget;
|
||||
|
||||
|
@ -85,57 +80,54 @@ public class LaunchBarListViewer extends StructuredViewer {
|
|||
}
|
||||
}
|
||||
|
||||
private TraverseListener listItemTraverseListener = new TraverseListener() {
|
||||
@Override
|
||||
public void keyTraversed(TraverseEvent e) {
|
||||
final ListItem currItem = selIndex >= 0 ? listItems[selIndex] : null;
|
||||
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) {
|
||||
int maxIdx = listItems.length - 1;
|
||||
if (selIndex < maxIdx) {
|
||||
// move to next item
|
||||
listItems[selIndex + 1].setSelected(true);
|
||||
if (scrollBucket < maxScrollBucket) {
|
||||
scrollBucket++;
|
||||
} else {
|
||||
// need to scroll the list up 1 item
|
||||
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));
|
||||
private TraverseListener listItemTraverseListener = e -> {
|
||||
final ListItem currItem = selIndex >= 0 ? listItems[selIndex] : null;
|
||||
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) {
|
||||
int maxIdx = listItems.length - 1;
|
||||
if (selIndex < maxIdx) {
|
||||
// move to next item
|
||||
listItems[selIndex + 1].setSelected(true);
|
||||
if (scrollBucket < maxScrollBucket) {
|
||||
scrollBucket++;
|
||||
} else {
|
||||
// need to scroll the list up 1 item
|
||||
int sY1 = listScrolled.getOrigin().y;
|
||||
listScrolled.setOrigin(0, sY1 + 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 (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);
|
||||
if (disposeImage) {
|
||||
final Image disposableImage = image;
|
||||
icon.addDisposeListener(new DisposeListener() {
|
||||
@Override
|
||||
public void widgetDisposed(DisposeEvent e) {
|
||||
disposableImage.dispose();
|
||||
}
|
||||
});
|
||||
icon.addDisposeListener(e -> disposableImage.dispose());
|
||||
}
|
||||
icon.setBackground(parent.getBackground());
|
||||
return icon;
|
||||
|
@ -361,12 +348,7 @@ public class LaunchBarListViewer extends StructuredViewer {
|
|||
sash.moveBelow(null);
|
||||
|
||||
sash.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_LIST_SELECTION));
|
||||
sash.addListener(SWT.Selection, new Listener() {
|
||||
@Override
|
||||
public void handleEvent(Event e) {
|
||||
separatorIndex = (e.y + itemH / 2) / itemH;
|
||||
}
|
||||
});
|
||||
sash.addListener(SWT.Selection, e -> separatorIndex = (e.y + itemH / 2) / itemH);
|
||||
sash.addMouseListener(new MouseListener() {
|
||||
@Override
|
||||
public void mouseUp(MouseEvent e) {
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -10,7 +10,6 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.launchbar.ui.controls.internal;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -107,32 +106,29 @@ public class ModeSelector extends CSelector {
|
|||
return super.getText(element);
|
||||
}
|
||||
});
|
||||
setSorter(new Comparator<Object>() {
|
||||
@Override
|
||||
public int compare(Object o1, Object o2) {
|
||||
if (o1 instanceof ILaunchMode && o2 instanceof ILaunchMode) {
|
||||
String mode1 = ((ILaunchMode) o1).getIdentifier();
|
||||
String mode2 = ((ILaunchMode) o2).getIdentifier();
|
||||
// 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;
|
||||
}
|
||||
setSorter((o1, o2) -> {
|
||||
if (o1 instanceof ILaunchMode && o2 instanceof ILaunchMode) {
|
||||
String mode1 = ((ILaunchMode) o1).getIdentifier();
|
||||
String mode2 = ((ILaunchMode) o2).getIdentifier();
|
||||
// run comes first, then debug, then the rest
|
||||
if (mode1.equals("run")) { //$NON-NLS-1$
|
||||
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;
|
||||
else
|
||||
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;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -10,8 +10,6 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.launchbar.ui.controls.internal;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.jface.layout.GridDataFactory;
|
||||
import org.eclipse.jface.layout.GridLayoutFactory;
|
||||
|
@ -135,14 +133,11 @@ public class TargetSelector extends CSelector implements ILaunchTargetListener {
|
|||
}
|
||||
});
|
||||
|
||||
setSorter(new Comparator<Object>() {
|
||||
@Override
|
||||
public int compare(Object o1, Object o2) {
|
||||
// Sort by name
|
||||
String s1 = String.valueOf(o1);
|
||||
String s2 = String.valueOf(o2);
|
||||
return s1.compareTo(s2);
|
||||
}
|
||||
setSorter((o1, o2) -> {
|
||||
// Sort by name
|
||||
String s1 = String.valueOf(o1);
|
||||
String s2 = String.valueOf(o2);
|
||||
return s1.compareTo(s2);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -26,8 +26,6 @@ import org.eclipse.swt.custom.CTabFolder;
|
|||
import org.eclipse.swt.custom.CTabItem;
|
||||
import org.eclipse.swt.events.FocusAdapter;
|
||||
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.SelectionEvent;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
|
@ -121,12 +119,7 @@ public class LaunchBarLaunchConfigDialog extends TitleAreaDialog implements ILau
|
|||
nameText = new Text(nameComp, SWT.BORDER);
|
||||
nameText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
||||
nameText.setText(workingCopy.getName());
|
||||
nameText.addModifyListener(new ModifyListener() {
|
||||
@Override
|
||||
public void modifyText(ModifyEvent e) {
|
||||
updateMessage();
|
||||
}
|
||||
});
|
||||
nameText.addModifyListener(e -> updateMessage());
|
||||
|
||||
tabFolder = new CTabFolder(composite, SWT.BORDER);
|
||||
tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -191,23 +191,20 @@ public class BuildActiveCommandHandler extends AbstractHandler {
|
|||
}
|
||||
|
||||
protected void saveEditors(final Collection<IProject> projects) {
|
||||
Display.getDefault().syncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
|
||||
for (IWorkbenchWindow window : windows) {
|
||||
IWorkbenchPage[] pages = window.getPages();
|
||||
for (IWorkbenchPage page : pages) {
|
||||
if (projects.isEmpty()) {
|
||||
page.saveAllEditors(false);
|
||||
} else {
|
||||
IEditorPart[] editors = page.getDirtyEditors();
|
||||
for (IEditorPart editor : editors) {
|
||||
IFile inputFile = ResourceUtil.getFile(editor.getEditorInput());
|
||||
if (inputFile != null) {
|
||||
if (projects.contains(inputFile.getProject())) {
|
||||
page.saveEditor(editor, false);
|
||||
}
|
||||
Display.getDefault().syncExec(() -> {
|
||||
IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
|
||||
for (IWorkbenchWindow window : windows) {
|
||||
IWorkbenchPage[] pages = window.getPages();
|
||||
for (IWorkbenchPage page : pages) {
|
||||
if (projects.isEmpty()) {
|
||||
page.saveAllEditors(false);
|
||||
} else {
|
||||
IEditorPart[] editors = page.getDirtyEditors();
|
||||
for (IEditorPart editor : editors) {
|
||||
IFile inputFile = ResourceUtil.getFile(editor.getEditorInput());
|
||||
if (inputFile != null) {
|
||||
if (projects.contains(inputFile.getProject())) {
|
||||
page.saveEditor(editor, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -8,7 +8,6 @@
|
|||
package org.eclipse.launchbar.ui.internal.dialogs;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.eclipse.debug.core.DebugPlugin;
|
||||
import org.eclipse.debug.core.ILaunchConfigurationType;
|
||||
|
@ -151,15 +150,12 @@ public class NewLaunchConfigTypePage2 extends WizardPage {
|
|||
editPage.setLaunchGroup(group);
|
||||
|
||||
ILaunchConfigurationType[] types = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationTypes();
|
||||
Arrays.sort(types, new Comparator<ILaunchConfigurationType>() {
|
||||
@Override
|
||||
public int compare(ILaunchConfigurationType type0, ILaunchConfigurationType type1) {
|
||||
int comp = type0.getPluginIdentifier().compareTo(type1.getPluginIdentifier());
|
||||
if (comp != 0) {
|
||||
return comp;
|
||||
} else {
|
||||
return type0.getName().compareTo(type1.getName());
|
||||
}
|
||||
Arrays.sort(types, (type0, type1) -> {
|
||||
int comp = type0.getPluginIdentifier().compareTo(type1.getPluginIdentifier());
|
||||
if (comp != 0) {
|
||||
return comp;
|
||||
} else {
|
||||
return type0.getName().compareTo(type1.getName());
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -11,7 +11,6 @@
|
|||
package org.eclipse.launchbar.ui.internal.target;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -68,13 +67,10 @@ class NewLaunchTargetWizardSelectionPage extends WizardPage {
|
|||
}
|
||||
}
|
||||
|
||||
elements.sort(new Comparator<IConfigurationElement>() {
|
||||
@Override
|
||||
public int compare(IConfigurationElement o1, IConfigurationElement o2) {
|
||||
String name1 = o1.getAttribute("name"); //$NON-NLS-1$
|
||||
String name2 = o2.getAttribute("name"); //$NON-NLS-1$
|
||||
return name1.compareTo(name2);
|
||||
}
|
||||
elements.sort((o1, o2) -> {
|
||||
String name1 = o1.getAttribute("name"); //$NON-NLS-1$
|
||||
String name2 = o2.getAttribute("name"); //$NON-NLS-1$
|
||||
return name1.compareTo(name2);
|
||||
});
|
||||
|
||||
for (IConfigurationElement element : elements) {
|
||||
|
|
|
@ -37,8 +37,6 @@ import org.eclipse.launchbar.core.ILaunchDescriptorType;
|
|||
import org.eclipse.launchbar.core.target.ILaunchTarget;
|
||||
import org.eclipse.launchbar.core.target.ILaunchTargetManager;
|
||||
import org.junit.Test;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
public class LaunchBarManagerTest {
|
||||
@Test
|
||||
|
@ -172,12 +170,9 @@ public class LaunchBarManagerTest {
|
|||
doReturn(launchConfig).when(configProvider).getLaunchConfiguration(eq(descriptor), any(ILaunchTarget.class));
|
||||
doReturn(launchConfigType).when(configProvider).getLaunchConfigurationType(any(ILaunchDescriptor.class),
|
||||
any(ILaunchTarget.class));
|
||||
doAnswer(new Answer<Boolean>() {
|
||||
@Override
|
||||
public Boolean answer(InvocationOnMock invocation) throws Throwable {
|
||||
ILaunchTarget target = (ILaunchTarget) invocation.getArguments()[1];
|
||||
return target.getTypeId().equals(ILaunchTargetManager.localLaunchTargetTypeId);
|
||||
}
|
||||
doAnswer(invocation -> {
|
||||
ILaunchTarget target = (ILaunchTarget) invocation.getArguments()[1];
|
||||
return target.getTypeId().equals(ILaunchTargetManager.localLaunchTargetTypeId);
|
||||
}).when(configProvider).supports(eq(descriptor), any(ILaunchTarget.class));
|
||||
|
||||
doReturn(elements.toArray(new IConfigurationElement[0])).when(extension).getConfigurationElements();
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -44,12 +44,7 @@ public class SWTBotCSelector extends AbstractSWTBotControl<CSelector> {
|
|||
|
||||
@Override
|
||||
public SWTBotCSelector click() {
|
||||
Point size = syncExec(new Result<Point>() {
|
||||
@Override
|
||||
public Point run() {
|
||||
return widget.getSize();
|
||||
}
|
||||
});
|
||||
Point size = syncExec((Result<Point>) () -> widget.getSize());
|
||||
click(size.x / 2, size.y / 2);
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -38,12 +38,7 @@ public class SWTBotConfigSelector extends SWTBotCSelector {
|
|||
|
||||
@Override
|
||||
public ActionArea click() {
|
||||
Point size = syncExec(new Result<Point>() {
|
||||
@Override
|
||||
public Point run() {
|
||||
return widget.getSize();
|
||||
}
|
||||
});
|
||||
Point size = syncExec((Result<Point>) () -> widget.getSize());
|
||||
click(size.x / 2, size.y / 2);
|
||||
return this;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue