mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 09:16:02 +02:00
Fixed up startup, selection handling, and preferences in LaunchBar.
This commit is contained in:
parent
fcd66c7d04
commit
49b65cb5b2
8 changed files with 138 additions and 142 deletions
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.launchbar.core;
|
|||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.ILaunchMode;
|
||||
|
||||
public interface ILaunchBarManager extends IAdaptable {
|
||||
|
@ -25,6 +26,8 @@ public interface ILaunchBarManager extends IAdaptable {
|
|||
void addLaunchConfigurationDescriptor(ILaunchConfigurationDescriptor configDesc) throws CoreException;
|
||||
|
||||
void removeLaunchConfigurationDescriptor(ILaunchConfigurationDescriptor configDesc);
|
||||
|
||||
ILaunchConfigurationDescriptor getLaunchConfigurationDescriptor(ILaunchConfiguration configuration);
|
||||
|
||||
ILaunchMode[] getLaunchModes() throws CoreException;
|
||||
|
||||
|
|
|
@ -12,10 +12,8 @@ package org.eclipse.cdt.launchbar.core.internal;
|
|||
|
||||
import org.eclipse.cdt.launchbar.core.ILaunchBarManager;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.osgi.framework.BundleActivator;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
@ -39,18 +37,12 @@ public class Activator implements BundleActivator {
|
|||
@Override
|
||||
public synchronized ILaunchBarManager getService(Bundle bundle, ServiceRegistration<ILaunchBarManager> registration) {
|
||||
if (launchBarManager == null) {
|
||||
launchBarManager = new LaunchBarManager();
|
||||
new Job("Init LaunchBar Manager") {
|
||||
@Override
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
try {
|
||||
launchBarManager.init();
|
||||
return Status.OK_STATUS;
|
||||
} catch (CoreException e) {
|
||||
return e.getStatus();
|
||||
}
|
||||
}
|
||||
}.schedule();;
|
||||
try {
|
||||
launchBarManager = new LaunchBarManager();
|
||||
} catch (CoreException e) {
|
||||
// TODO log
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return launchBarManager;
|
||||
}
|
||||
|
|
|
@ -35,6 +35,8 @@ import org.eclipse.debug.core.ILaunchConfigurationListener;
|
|||
import org.eclipse.debug.core.ILaunchConfigurationType;
|
||||
import org.eclipse.debug.core.ILaunchManager;
|
||||
import org.eclipse.debug.core.ILaunchMode;
|
||||
import org.osgi.service.prefs.BackingStoreException;
|
||||
import org.osgi.service.prefs.Preferences;
|
||||
|
||||
public class LaunchBarManager extends PlatformObject implements ILaunchBarManager, ILaunchConfigurationListener {
|
||||
|
||||
|
@ -71,7 +73,7 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
|
||||
}
|
||||
|
||||
void init() throws CoreException {
|
||||
public LaunchBarManager() throws CoreException {
|
||||
IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(
|
||||
Activator.PLUGIN_ID,
|
||||
"launchConfigProvider");
|
||||
|
@ -107,7 +109,11 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
|
||||
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
|
||||
for (ILaunchConfiguration configuration : launchManager.getLaunchConfigurations()) {
|
||||
launchConfigurationAdded(configuration);
|
||||
ILaunchConfigurationDescriptor configDesc = new DefaultLaunchConfigurationDescriptor(configuration);
|
||||
for (ProviderExtensionDescriptor provider : providers) {
|
||||
configDesc = provider.getProvider().filterDescriptor(configDesc);
|
||||
}
|
||||
configDescs.put(configDesc.getName(), configDesc);
|
||||
}
|
||||
|
||||
for (ProviderExtensionDescriptor providerDesc : providers) {
|
||||
|
@ -152,7 +158,9 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
|
||||
@Override
|
||||
public void launchConfigurationRemoved(ILaunchConfiguration configuration) {
|
||||
// TODO Auto-generated method stub
|
||||
ILaunchConfigurationDescriptor configDesc = getLaunchConfigurationDescriptor(configuration);
|
||||
if (configDesc != null)
|
||||
removeLaunchConfigurationDescriptor(configDesc);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -172,12 +180,48 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
return activeConfigDesc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILaunchConfigurationDescriptor getLaunchConfigurationDescriptor(ILaunchConfiguration configuration) {
|
||||
// Check by name
|
||||
ILaunchConfigurationDescriptor configDesc = configDescs.get(configuration.getName());
|
||||
if (configDesc.matches(configuration))
|
||||
return configDesc;
|
||||
|
||||
// Nope, try all descs
|
||||
for (ILaunchConfigurationDescriptor cd : configDescs.values()) {
|
||||
if (cd.matches(configuration))
|
||||
return cd;
|
||||
}
|
||||
|
||||
// nothing, weird
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActiveLaunchConfigurationDescriptor(ILaunchConfigurationDescriptor configDesc) throws CoreException {
|
||||
if (activeConfigDesc == configDesc)
|
||||
return;
|
||||
activeConfigDesc = configDesc;
|
||||
|
||||
IEclipsePreferences store = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
|
||||
if (activeConfigDesc != null) {
|
||||
store.put(PREF_ACTIVE_CONFIG_DESC, activeConfigDesc.getName());
|
||||
} else {
|
||||
store.remove(PREF_ACTIVE_CONFIG_DESC);
|
||||
}
|
||||
try {
|
||||
store.flush();
|
||||
} catch (BackingStoreException e) {
|
||||
// TODO log
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (activeConfigDesc == null) {
|
||||
setActiveLaunchMode(null);
|
||||
setActiveLaunchTarget(null);
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the launch modes
|
||||
List<ILaunchMode> mymodes = new ArrayList<>();
|
||||
ILaunchConfigurationType type = activeConfigDesc.getLaunchConfigurationType();
|
||||
|
@ -198,8 +242,7 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
}
|
||||
|
||||
// Set active mode
|
||||
IEclipsePreferences store = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
|
||||
String activeModeName = store.get(PREF_ACTIVE_LAUNCH_MODE, null);
|
||||
String activeModeName = store.node(activeConfigDesc.getName()).get(PREF_ACTIVE_LAUNCH_MODE, null);
|
||||
boolean foundMode = false;
|
||||
if (activeModeName != null) {
|
||||
for (ILaunchMode mode : launchModes) {
|
||||
|
@ -234,10 +277,21 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
}
|
||||
|
||||
@Override
|
||||
public void removeLaunchConfigurationDescriptor(
|
||||
ILaunchConfigurationDescriptor configDesc) {
|
||||
// TODO Auto-generated method stub
|
||||
public void removeLaunchConfigurationDescriptor(ILaunchConfigurationDescriptor configDesc) {
|
||||
configDescs.remove(configDesc.getName());
|
||||
|
||||
// Fix up the active config if this one was it
|
||||
if (activeConfigDesc.equals(configDesc)) {
|
||||
try {
|
||||
if (configDescs.isEmpty())
|
||||
setActiveLaunchConfigurationDescriptor(null);
|
||||
else
|
||||
setActiveLaunchConfigurationDescriptor(configDescs.values().iterator().next());
|
||||
} catch (CoreException e) {
|
||||
// TODO log
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -262,6 +316,20 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
if (activeLaunchMode == mode)
|
||||
return;
|
||||
activeLaunchMode = mode;
|
||||
|
||||
Preferences store = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID).node(activeConfigDesc.getName());
|
||||
if (mode != null) {
|
||||
store.put(PREF_ACTIVE_LAUNCH_MODE, mode.getIdentifier());
|
||||
} else {
|
||||
store.remove(PREF_ACTIVE_LAUNCH_MODE);
|
||||
}
|
||||
try {
|
||||
store.flush();
|
||||
} catch (BackingStoreException e) {
|
||||
// TODO log
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
for (Listener listener : listeners)
|
||||
listener.activeLaunchModeChanged();
|
||||
}
|
||||
|
|
|
@ -12,19 +12,11 @@ package org.eclipse.cdt.launchbar.ui.internal.controls;
|
|||
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.launchbar.ui.IHoverProvider;
|
||||
import org.eclipse.cdt.launchbar.ui.internal.Activator;
|
||||
import org.eclipse.jface.viewers.ILabelProvider;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
||||
import org.eclipse.jface.viewers.ISelectionProvider;
|
||||
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.custom.ScrolledComposite;
|
||||
import org.eclipse.swt.events.DisposeEvent;
|
||||
|
@ -55,7 +47,7 @@ import org.eclipse.swt.widgets.Label;
|
|||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
public class CSelector extends Composite implements ISelectionProvider {
|
||||
public abstract class CSelector extends Composite {
|
||||
|
||||
private IStructuredContentProvider contentProvider;
|
||||
private ILabelProvider labelProvider;
|
||||
|
@ -71,8 +63,7 @@ public class CSelector extends Composite implements ISelectionProvider {
|
|||
private static final int arrowMax = 2;
|
||||
private Transition arrowTransition;
|
||||
|
||||
private IStructuredSelection selection;
|
||||
private List<ISelectionChangedListener> selectionChangedListeners = new LinkedList<>();
|
||||
private Object selection;
|
||||
|
||||
protected final Color backgroundColor;
|
||||
protected final Color outlineColor;
|
||||
|
@ -118,7 +109,7 @@ public class CSelector extends Composite implements ISelectionProvider {
|
|||
if (hoverProvider != null && (popup == null || popup.isDisposed())) {
|
||||
final Object eventSource = e.getSource();
|
||||
if ((eventSource == currentLabel || eventSource == buttonComposite || eventSource == currentIcon)) {
|
||||
if (hoverProvider.displayHover(CSelector.this.selection.getFirstElement())) {
|
||||
if (hoverProvider.displayHover(selection)) {
|
||||
buttonComposite.setToolTipText("");
|
||||
if (currentLabel != null) {
|
||||
currentLabel.setToolTipText("");
|
||||
|
@ -222,27 +213,8 @@ public class CSelector extends Composite implements ISelectionProvider {
|
|||
popup.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSelectionChangedListener(ISelectionChangedListener listener) {
|
||||
selectionChangedListeners.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeSelectionChangedListener(
|
||||
ISelectionChangedListener listener) {
|
||||
selectionChangedListeners.remove(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelection(ISelection selection) {
|
||||
if (!(selection instanceof IStructuredSelection))
|
||||
return;
|
||||
IStructuredSelection newSelection = (IStructuredSelection) selection;
|
||||
if (this.selection != null && newSelection.getFirstElement() == this.selection.getFirstElement())
|
||||
// Already selected
|
||||
return;
|
||||
|
||||
this.selection = newSelection;
|
||||
public void setSelection(Object element) {
|
||||
this.selection = element;
|
||||
|
||||
if (buttonComposite != null)
|
||||
buttonComposite.dispose();
|
||||
|
@ -251,8 +223,6 @@ public class CSelector extends Composite implements ISelectionProvider {
|
|||
|
||||
boolean editable = false;
|
||||
int columns = 2;
|
||||
Object element = null;
|
||||
element = this.selection.getFirstElement();
|
||||
|
||||
Image image = labelProvider.getImage(element);
|
||||
if (image != null)
|
||||
|
@ -342,7 +312,7 @@ public class CSelector extends Composite implements ISelectionProvider {
|
|||
@Override
|
||||
public void run() {
|
||||
if (CSelector.this.selection != null)
|
||||
handleEdit(CSelector.this.selection.getFirstElement());
|
||||
handleEdit(selection);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -350,18 +320,11 @@ public class CSelector extends Composite implements ISelectionProvider {
|
|||
}
|
||||
|
||||
layout();
|
||||
fireSelectionChanged();
|
||||
}
|
||||
|
||||
private void fireSelectionChanged() {
|
||||
SelectionChangedEvent event = new SelectionChangedEvent(this, selection);
|
||||
for (ISelectionChangedListener listener : selectionChangedListeners) {
|
||||
listener.selectionChanged(event);
|
||||
}
|
||||
}
|
||||
protected abstract void fireSelectionChanged();
|
||||
|
||||
@Override
|
||||
public IStructuredSelection getSelection() {
|
||||
public Object getSelection() {
|
||||
return selection;
|
||||
}
|
||||
|
||||
|
@ -453,7 +416,7 @@ public class CSelector extends Composite implements ISelectionProvider {
|
|||
selIndex = -1;
|
||||
scrollBucket = 0;
|
||||
if (hoverProvider != null) {
|
||||
hoverProvider.dismissHover(selection != null ? selection.getFirstElement() : null, true);
|
||||
hoverProvider.dismissHover(selection != null ? selection : null, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -539,7 +502,8 @@ public class CSelector extends Composite implements ISelectionProvider {
|
|||
} else {
|
||||
// list item was pressed
|
||||
popup.dispose();
|
||||
setSelection(new StructuredSelection(currItem.element));
|
||||
setSelection(currItem.element);
|
||||
fireSelectionChanged();
|
||||
}
|
||||
} else if (e.detail == SWT.TRAVERSE_ESCAPE) {
|
||||
popup.dispose();
|
||||
|
@ -594,7 +558,8 @@ public class CSelector extends Composite implements ISelectionProvider {
|
|||
@Override
|
||||
public void mouseUp(MouseEvent e) {
|
||||
popup.dispose();
|
||||
setSelection(new StructuredSelection(element));
|
||||
setSelection(element);
|
||||
fireSelectionChanged();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -811,7 +776,7 @@ public class CSelector extends Composite implements ISelectionProvider {
|
|||
}
|
||||
|
||||
public void update(Object element) {
|
||||
if (selection.getFirstElement() == element) {
|
||||
if (selection == element) {
|
||||
if (currentIcon != null && !currentIcon.isDisposed()) {
|
||||
currentIcon.setImage(labelProvider.getImage(element));
|
||||
}
|
||||
|
|
|
@ -33,12 +33,8 @@ import org.eclipse.debug.ui.DebugUITools;
|
|||
import org.eclipse.debug.ui.ILaunchGroup;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.jface.viewers.ILabelProvider;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
||||
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
||||
import org.eclipse.jface.viewers.LabelProvider;
|
||||
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
import org.eclipse.jface.window.Window;
|
||||
import org.eclipse.jface.wizard.WizardDialog;
|
||||
|
@ -65,8 +61,6 @@ public class ConfigSelector extends CSelector {
|
|||
|
||||
private LaunchBarUIManager uiManager;
|
||||
|
||||
private static final ISelection nullSelection = new StructuredSelection("No Launch Configurations");
|
||||
|
||||
public ConfigSelector(Composite parent, int style) {
|
||||
super(parent, style);
|
||||
|
||||
|
@ -153,23 +147,21 @@ public class ConfigSelector extends CSelector {
|
|||
return text1.compareTo(text2);
|
||||
}
|
||||
});
|
||||
|
||||
addSelectionChangedListener(new ISelectionChangedListener() {
|
||||
@Override
|
||||
public void selectionChanged(SelectionChangedEvent event) {
|
||||
Object selected = getSelection().getFirstElement();
|
||||
if (selected instanceof ILaunchConfigurationDescriptor) {
|
||||
ILaunchConfigurationDescriptor configDesc = (ILaunchConfigurationDescriptor) selected;
|
||||
try {
|
||||
getManager().setActiveLaunchConfigurationDescriptor(configDesc);
|
||||
} catch (CoreException e) {
|
||||
Activator.log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fireSelectionChanged() {
|
||||
Object selected = getSelection();
|
||||
if (selected instanceof ILaunchConfigurationDescriptor) {
|
||||
ILaunchConfigurationDescriptor configDesc = (ILaunchConfigurationDescriptor) selected;
|
||||
try {
|
||||
getManager().setActiveLaunchConfigurationDescriptor(configDesc);
|
||||
} catch (CoreException e) {
|
||||
Activator.log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditable(Object element) {
|
||||
return element instanceof ILaunchConfigurationDescriptor;
|
||||
|
@ -283,12 +275,4 @@ public class ConfigSelector extends CSelector {
|
|||
uiManager = (LaunchBarUIManager) ((ILaunchBarManager) input).getAdapter(LaunchBarUIManager.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelection(ISelection selection) {
|
||||
if (selection == null)
|
||||
super.setSelection(nullSelection);
|
||||
else
|
||||
super.setSelection(selection);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import org.eclipse.cdt.launchbar.core.ILaunchTarget;
|
|||
import org.eclipse.cdt.launchbar.ui.internal.Activator;
|
||||
import org.eclipse.cdt.launchbar.ui.internal.Messages;
|
||||
import org.eclipse.debug.core.ILaunchMode;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.DisposeEvent;
|
||||
import org.eclipse.swt.events.DisposeListener;
|
||||
|
@ -80,13 +79,13 @@ public class LaunchBarControl implements ILaunchBarManager.Listener {
|
|||
targetSelector.setInput(manager);
|
||||
|
||||
ILaunchConfigurationDescriptor configDesc = manager.getActiveLaunchConfigurationDescriptor();
|
||||
configSelector.setSelection(configDesc == null ? null : new StructuredSelection(configDesc));
|
||||
configSelector.setSelection(configDesc == null ? null : configDesc);
|
||||
|
||||
ILaunchMode mode = manager.getActiveLaunchMode();
|
||||
modeSelector.setSelection(mode == null ? null : new StructuredSelection(mode));
|
||||
modeSelector.setSelection(mode == null ? null : mode);
|
||||
|
||||
ILaunchTarget target = manager.getActiveLaunchTarget();
|
||||
targetSelector.setSelection(target == null ? null : new StructuredSelection(target));
|
||||
targetSelector.setSelection(target == null ? null : target);
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
|
@ -117,7 +116,7 @@ public class LaunchBarControl implements ILaunchBarManager.Listener {
|
|||
@Override
|
||||
public void run() {
|
||||
if (!configSelector.isDisposed())
|
||||
configSelector.setSelection(configDesc == null ? null : new StructuredSelection(configDesc));
|
||||
configSelector.setSelection(configDesc == null ? null : configDesc);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -131,7 +130,7 @@ public class LaunchBarControl implements ILaunchBarManager.Listener {
|
|||
@Override
|
||||
public void run() {
|
||||
if (!modeSelector.isDisposed())
|
||||
modeSelector.setSelection(mode == null ? null : new StructuredSelection(mode));
|
||||
modeSelector.setSelection(mode == null ? null : mode);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -145,7 +144,7 @@ public class LaunchBarControl implements ILaunchBarManager.Listener {
|
|||
@Override
|
||||
public void run() {
|
||||
if (!targetSelector.isDisposed())
|
||||
targetSelector.setSelection(target == null ? null : new StructuredSelection(target));
|
||||
targetSelector.setSelection(target == null ? null : target);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -22,12 +22,8 @@ import org.eclipse.debug.core.ILaunchMode;
|
|||
import org.eclipse.debug.internal.ui.DebugUIPlugin;
|
||||
import org.eclipse.debug.ui.ILaunchGroup;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
||||
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
||||
import org.eclipse.jface.viewers.LabelProvider;
|
||||
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
|
@ -36,11 +32,11 @@ import org.eclipse.swt.widgets.Composite;
|
|||
@SuppressWarnings("restriction")
|
||||
public class ModeSelector extends CSelector {
|
||||
|
||||
private static final ISelection nullSelection = new StructuredSelection("---");
|
||||
|
||||
public ModeSelector(Composite parent, int style) {
|
||||
super(parent, style);
|
||||
|
||||
setToolTipText("Launch configuration");
|
||||
|
||||
setContentProvider(new IStructuredContentProvider() {
|
||||
@Override
|
||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||
|
@ -137,21 +133,17 @@ public class ModeSelector extends CSelector {
|
|||
return 0;
|
||||
}
|
||||
});
|
||||
|
||||
setToolTipText("Launch configuration");
|
||||
addSelectionChangedListener(new ISelectionChangedListener() {
|
||||
@Override
|
||||
public void selectionChanged(SelectionChangedEvent event) {
|
||||
Object selected = getSelection().getFirstElement();
|
||||
if (selected instanceof ILaunchMode) {
|
||||
ILaunchMode mode = (ILaunchMode) selected;
|
||||
getManager().setActiveLaunchMode(mode);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fireSelectionChanged() {
|
||||
Object selected = getSelection();
|
||||
if (selected instanceof ILaunchMode) {
|
||||
ILaunchMode mode = (ILaunchMode) selected;
|
||||
getManager().setActiveLaunchMode(mode);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point computeSize(int wHint, int hHint, boolean changed) {
|
||||
return super.computeSize(150, hHint, changed);
|
||||
|
@ -161,12 +153,4 @@ public class ModeSelector extends CSelector {
|
|||
return (ILaunchBarManager) getInput();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelection(ISelection selection) {
|
||||
if (selection == null)
|
||||
super.setSelection(nullSelection);
|
||||
else
|
||||
super.setSelection(selection);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -209,6 +209,15 @@ public class TargetSelector extends CSelector {
|
|||
createLabel.addMouseTrackListener(mouseTrackListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fireSelectionChanged() {
|
||||
Object selection = getSelection();
|
||||
if (selection instanceof ILaunchTarget) {
|
||||
ILaunchTarget target = (ILaunchTarget) selection;
|
||||
uiManager.getManager().setActiveLaunchTarget(target);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point computeSize(int wHint, int hHint, boolean changed) {
|
||||
return super.computeSize(200, hHint, changed);
|
||||
|
@ -218,12 +227,4 @@ public class TargetSelector extends CSelector {
|
|||
return (ILaunchBarManager) getInput();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelection(ISelection selection) {
|
||||
if (selection == null)
|
||||
super.setSelection(nullSelection);
|
||||
else
|
||||
super.setSelection(selection);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue