1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 06:32:10 +02:00

Bug 306569: Dynamic content support for ICDebuggerPage

This commit is contained in:
Mikhail Khodjaiants 2010-04-06 00:49:45 +00:00
parent c13a2bfe52
commit 304f3b2500
3 changed files with 103 additions and 4 deletions

View file

@ -10,15 +10,24 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.debug.ui; package org.eclipse.cdt.debug.ui;
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
/** /**
* Common function for debugger pages. * Common function for debugger pages.
* @since 3.1 * @since 3.1
*/ */
abstract public class AbstractCDebuggerPage extends AbstractLaunchConfigurationTab implements ICDebuggerPage { abstract public class AbstractCDebuggerPage
extends AbstractLaunchConfigurationTab
implements ICDebuggerPage, ICDebuggerPageExtension {
private String fDebuggerID = null; private String fDebuggerID = null;
private ListenerList fContentListeners;
public AbstractCDebuggerPage() {
super();
fContentListeners = new ListenerList();
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.debug.ui.ICDebuggerPage#init(java.lang.String) * @see org.eclipse.cdt.debug.ui.ICDebuggerPage#init(java.lang.String)
@ -27,10 +36,43 @@ abstract public class AbstractCDebuggerPage extends AbstractLaunchConfigurationT
fDebuggerID = debuggerID; fDebuggerID = debuggerID;
} }
/* (non-Javadoc)
* @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#dispose()
*/
@Override
public void dispose() {
fContentListeners.clear();
super.dispose();
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.debug.ui.ICDebuggerPage#getDebuggerIdentifier() * @see org.eclipse.cdt.debug.ui.ICDebuggerPage#getDebuggerIdentifier()
*/ */
public String getDebuggerIdentifier() { public String getDebuggerIdentifier() {
return fDebuggerID; return fDebuggerID;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.ui.ICDebuggerPageExtension#addContentChangeListener(org.eclipse.cdt.debug.ui.ICDebuggerPageExtension.IContentChangeListener)
*/
public void addContentChangeListener( IContentChangeListener listener ) {
fContentListeners.add( listener );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.ui.ICDebuggerPageExtension#removeContentChangeListener(org.eclipse.cdt.debug.ui.ICDebuggerPageExtension.IContentChangeListener)
*/
public void removeContentChangeListener( IContentChangeListener listener ) {
fContentListeners.remove( listener );
}
/**
* Notifies the registered listeners that the page's content has changed.
*
* @since 7.0
*/
protected void contentChanged() {
for ( Object l : fContentListeners.getListeners() )
((IContentChangeListener)l).contentChanged();
}
} }

View file

@ -0,0 +1,41 @@
/*******************************************************************************
* Copyright (c) 2010 CodeSourcery 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:
* CodeSourcery - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.ui;
/**
* This interface extension allows the registration of content listeners.
* Page implementors can use it to notify parents of changes in
* the page content which will force the parent tab to recalculate its size.
*
* @since 7.0
*/
public interface ICDebuggerPageExtension extends ICDebuggerPage {
/**
* @since 7.0
*/
public interface IContentChangeListener {
void contentChanged();
}
/**
* Adds a listener to this page. This method has no effect
* if the same listener is already registered.
*/
void addContentChangeListener( IContentChangeListener listener );
/**
* Removes a listener from this list. Has no effect if
* the same listener was not already registered.
*/
void removeContentChangeListener( IContentChangeListener listener );
}

View file

@ -17,6 +17,8 @@ import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.debug.core.ICDebugConfiguration; import org.eclipse.cdt.debug.core.ICDebugConfiguration;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin; import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.cdt.debug.ui.ICDebuggerPage; import org.eclipse.cdt.debug.ui.ICDebuggerPage;
import org.eclipse.cdt.debug.ui.ICDebuggerPageExtension;
import org.eclipse.cdt.debug.ui.ICDebuggerPageExtension.IContentChangeListener;
import org.eclipse.cdt.launch.ui.CLaunchConfigurationTab; import org.eclipse.cdt.launch.ui.CLaunchConfigurationTab;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
@ -48,6 +50,16 @@ public abstract class AbstractCDebuggerTab extends CLaunchConfigurationTab {
private boolean fIsInitializing = false; private boolean fIsInitializing = false;
private boolean fPageUpdated; private boolean fPageUpdated;
private IContentChangeListener fContentListener = new IContentChangeListener() {
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.ui.ICDebuggerPageExtension.IContentChangeListener#contentChanged()
*/
public void contentChanged() {
contentsChanged();
}
};
protected void setDebugConfig(ICDebugConfiguration config) { protected void setDebugConfig(ICDebugConfiguration config) {
fCurrentDebugConfig = config; fCurrentDebugConfig = config;
} }
@ -61,7 +73,11 @@ public abstract class AbstractCDebuggerTab extends CLaunchConfigurationTab {
} }
protected void setDynamicTab(ICDebuggerPage tab) { protected void setDynamicTab(ICDebuggerPage tab) {
if ( fDynamicTab instanceof ICDebuggerPageExtension )
((ICDebuggerPageExtension)fDynamicTab).removeContentChangeListener( fContentListener );
fDynamicTab = tab; fDynamicTab = tab;
if ( fDynamicTab instanceof ICDebuggerPageExtension )
((ICDebuggerPageExtension)fDynamicTab).addContentChangeListener( fContentListener );
} }
protected Composite getDynamicTabHolder() { protected Composite getDynamicTabHolder() {