mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
[251452] - Added the default refresh handler implementation.
This commit is contained in:
parent
901476ba15
commit
d2b6ebba2f
3 changed files with 84 additions and 4 deletions
|
@ -0,0 +1,51 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2008 Wind River 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
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Wind River Systems - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel.actions;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
|
import org.eclipse.dd.dsf.ui.viewmodel.IVMAdapterExtension;
|
||||||
|
import org.eclipse.dd.dsf.ui.viewmodel.IVMProvider;
|
||||||
|
import org.eclipse.dd.dsf.ui.viewmodel.update.ICachingVMProvider;
|
||||||
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default implementation of the refresh all debug target which
|
||||||
|
* calls the active VM providers, to ask them to refresh.
|
||||||
|
*
|
||||||
|
* @since 1.1
|
||||||
|
*/
|
||||||
|
public class DefaultRefreshAllTarget implements IRefreshAllTarget {
|
||||||
|
|
||||||
|
public void refresh(ISelection debugContext) throws CoreException {
|
||||||
|
IVMAdapterExtension adapter = getActiveVMAdapter( debugContext );
|
||||||
|
|
||||||
|
if (adapter != null) {
|
||||||
|
for (IVMProvider provider : adapter.getActiveProviders()) {
|
||||||
|
if (provider instanceof ICachingVMProvider) {
|
||||||
|
((ICachingVMProvider)provider).refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IVMAdapterExtension getActiveVMAdapter(ISelection debugContext) {
|
||||||
|
|
||||||
|
if (debugContext instanceof IStructuredSelection) {
|
||||||
|
Object activeElement = ((IStructuredSelection)debugContext).getFirstElement();
|
||||||
|
if (activeElement instanceof IAdaptable) {
|
||||||
|
return (IVMAdapterExtension)((IAdaptable)activeElement).getAdapter(IVMAdapterExtension.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -42,7 +42,7 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate;
|
||||||
*/
|
*/
|
||||||
@ThreadSafe
|
@ThreadSafe
|
||||||
@SuppressWarnings("restriction")
|
@SuppressWarnings("restriction")
|
||||||
abstract public class AbstractVMAdapter implements IVMAdapter
|
abstract public class AbstractVMAdapter implements IVMAdapterExtension
|
||||||
{
|
{
|
||||||
|
|
||||||
private boolean fDisposed;
|
private boolean fDisposed;
|
||||||
|
@ -83,8 +83,10 @@ abstract public class AbstractVMAdapter implements IVMAdapter
|
||||||
*
|
*
|
||||||
* @since 1.1
|
* @since 1.1
|
||||||
*/
|
*/
|
||||||
protected Iterable<IVMProvider> getVMProviderIterable() {
|
public IVMProvider[] getActiveProviders() {
|
||||||
return fViewModelProviders.values();
|
synchronized(fViewModelProviders) {
|
||||||
|
return fViewModelProviders.values().toArray(new IVMProvider[fViewModelProviders.size()]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
|
@ -213,7 +215,7 @@ abstract public class AbstractVMAdapter implements IVMAdapter
|
||||||
|
|
||||||
aboutToHandleEvent(event);
|
aboutToHandleEvent(event);
|
||||||
|
|
||||||
for (IVMProvider vmProvider : getVMProviderIterable()) {
|
for (IVMProvider vmProvider : getActiveProviders()) {
|
||||||
if (vmProvider instanceof IVMEventListener) {
|
if (vmProvider instanceof IVMEventListener) {
|
||||||
eventListeners.add((IVMEventListener)vmProvider);
|
eventListeners.add((IVMEventListener)vmProvider);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2008 Wind River 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
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Wind River Systems - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.dd.dsf.ui.viewmodel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension to the IVMAdapter interface which allows access to the arra of active
|
||||||
|
* providers.
|
||||||
|
*
|
||||||
|
* @since 1.1
|
||||||
|
*/
|
||||||
|
public interface IVMAdapterExtension extends IVMAdapter {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the currently active VM providers in this adapter.
|
||||||
|
*
|
||||||
|
* @return array of VM providers
|
||||||
|
*/
|
||||||
|
public IVMProvider[] getActiveProviders();
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue