Fixed # 18 - Fixed tree view and stream list after last tab is closed
This commit is contained in:
parent
429ea37080
commit
7e2869b7ee
|
@ -46,6 +46,7 @@ import org.eclipse.swt.dnd.DropTargetEvent;
|
|||
import org.eclipse.swt.dnd.Transfer;
|
||||
import org.eclipse.swt.events.ControlAdapter;
|
||||
import org.eclipse.swt.events.ControlEvent;
|
||||
import org.eclipse.swt.events.DisposeListener;
|
||||
import org.eclipse.swt.events.MouseAdapter;
|
||||
import org.eclipse.swt.events.MouseEvent;
|
||||
import org.eclipse.swt.events.MouseListener;
|
||||
|
@ -1249,4 +1250,9 @@ public class WaveformViewer implements IWaveformViewer {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// probably not the way it should be done
|
||||
public void addDisposeListener( DisposeListener listener ) {
|
||||
waveformCanvas.addDisposeListener(listener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import java.util.List;
|
|||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
||||
import org.eclipse.jface.viewers.ISelectionProvider;
|
||||
import org.eclipse.swt.events.DisposeListener;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
|
||||
|
@ -104,4 +105,6 @@ public interface IWaveformViewer extends PropertyChangeListener, ISelectionProvi
|
|||
public void setBaselineTime(Long scale);
|
||||
|
||||
public void scrollHorizontal(int percent);
|
||||
|
||||
public void addDisposeListener( DisposeListener listener );
|
||||
}
|
|
@ -49,6 +49,8 @@ import org.eclipse.swt.SWT;
|
|||
import org.eclipse.swt.custom.SashForm;
|
||||
import org.eclipse.swt.events.ControlAdapter;
|
||||
import org.eclipse.swt.events.ControlEvent;
|
||||
import org.eclipse.swt.events.DisposeEvent;
|
||||
import org.eclipse.swt.events.DisposeListener;
|
||||
import org.eclipse.swt.events.ModifyEvent;
|
||||
import org.eclipse.swt.events.ModifyListener;
|
||||
import org.eclipse.swt.events.PaintEvent;
|
||||
|
@ -344,6 +346,16 @@ public class DesignBrowser {
|
|||
thisSelectionCount=selection.toList().size();
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
/**
|
||||
* reset tree viewer and tableviewer after every closed tab
|
||||
*/
|
||||
protected void resetTreeViewer() {
|
||||
//reset tree- and tableviewer
|
||||
treeViewer.setInput(null);
|
||||
txTableViewer.setInput(null);
|
||||
txTableViewer.setSelection(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the status event.
|
||||
|
@ -354,21 +366,31 @@ public class DesignBrowser {
|
|||
@SuppressWarnings("unchecked")
|
||||
@Inject @Optional
|
||||
public void getActiveWaveformViewerEvent(@UIEventTopic(WaveformViewer.ACTIVE_WAVEFORMVIEW) WaveformViewer waveformViewerPart) {
|
||||
if(this.waveformViewerPart!=null)
|
||||
if(this.waveformViewerPart!=null) {
|
||||
this.waveformViewerPart.storeDesignBrowerState(new DBState());
|
||||
}
|
||||
if( this.waveformViewerPart == null || this.waveformViewerPart != waveformViewerPart ) {
|
||||
waveformViewerPart.addDisposeListener( new DisposeListener() {
|
||||
@Override
|
||||
public void widgetDisposed(DisposeEvent e) {
|
||||
// reset tree- and tableviewer
|
||||
resetTreeViewer();
|
||||
}
|
||||
} );
|
||||
}
|
||||
this.waveformViewerPart=waveformViewerPart;
|
||||
IWaveformDb database = waveformViewerPart.getDatabase();
|
||||
Object input = treeViewer.getInput();
|
||||
if(input!=null && input instanceof List<?>){
|
||||
IWaveformDb db = ((List<IWaveformDb>)input).get(0);
|
||||
if(db==database) return; // do nothing if old and new daabase is the same
|
||||
if(db==database) return; // do nothing if old and new database is the same
|
||||
((List<IWaveformDb>)input).get(0).removePropertyChangeListener(treeViewerPCL);
|
||||
}
|
||||
treeViewer.setInput(Arrays.asList(database.isLoaded()?new IWaveformDb[]{database}:new IWaveformDb[]{new LoadingWaveformDb()}));
|
||||
Object state=this.waveformViewerPart.retrieveDesignBrowerState();
|
||||
if(state!=null && state instanceof DBState)
|
||||
((DBState)state).apply();
|
||||
else
|
||||
else
|
||||
txTableViewer.setInput(null);
|
||||
// Set up the tree viewer
|
||||
database.addPropertyChangeListener(treeViewerPCL);
|
||||
|
|
|
@ -63,6 +63,8 @@ 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.events.DisposeEvent;
|
||||
import org.eclipse.swt.events.DisposeListener;
|
||||
import org.eclipse.swt.events.MouseEvent;
|
||||
import org.eclipse.swt.events.MouseTrackListener;
|
||||
import org.eclipse.swt.events.MouseWheelListener;
|
||||
|
@ -72,7 +74,7 @@ import org.eclipse.swt.widgets.Composite;
|
|||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
|
||||
import org.eclipse.swt.widgets.TypedListener;
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.ITxEvent;
|
||||
import com.minres.scviewer.database.ITxRelation;
|
||||
|
@ -101,7 +103,7 @@ import com.minres.scviewer.e4.application.preferences.PreferenceConstants;
|
|||
* The Class WaveformViewerPart.
|
||||
*/
|
||||
@SuppressWarnings("restriction")
|
||||
public class WaveformViewer implements IFileChangeListener, IPreferenceChangeListener {
|
||||
public class WaveformViewer implements IFileChangeListener, IPreferenceChangeListener, DisposeListener {
|
||||
|
||||
/** The Constant ACTIVE_WAVEFORMVIEW. */
|
||||
public static final String ACTIVE_WAVEFORMVIEW = "Active_Waveform_View"; //$NON-NLS-1$
|
||||
|
@ -149,6 +151,9 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
|||
/** The Constant WAVE_ACTION_ID. */
|
||||
public static final String WAVE_ACTION_ID = "com.minres.scviewer.ui.action.AddToWave"; //$NON-NLS-1$
|
||||
|
||||
/** The number of active DisposeListeners */
|
||||
private static int disposeListenerNumber = 0;
|
||||
|
||||
/** The factory. */
|
||||
WaveformViewerFactory factory = new WaveformViewerFactory();
|
||||
|
||||
|
@ -178,6 +183,8 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
|||
@Inject
|
||||
@Preference(nodePath = PreferenceConstants.PREFERENCES_SCOPE)
|
||||
IEclipsePreferences prefs;
|
||||
|
||||
@Inject @Optional DesignBrowser designBrowser;
|
||||
|
||||
/** The database. */
|
||||
private IWaveformDb database;
|
||||
|
@ -221,6 +228,8 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
|||
*/
|
||||
@PostConstruct
|
||||
public void createComposite(MPart part, Composite parent, IWaveformDbFactory dbFactory) {
|
||||
disposeListenerNumber += 1;
|
||||
|
||||
myPart = part;
|
||||
myParent = parent;
|
||||
database = dbFactory.getDatabase();
|
||||
|
@ -393,6 +402,8 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
|||
}
|
||||
});
|
||||
prefs.addPreferenceChangeListener(this);
|
||||
|
||||
waveformPane.addDisposeListener(this);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -1185,4 +1196,28 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
|||
waveformPane.update();
|
||||
}
|
||||
|
||||
/**
|
||||
* add dispose listener
|
||||
*
|
||||
* @param listener
|
||||
*/
|
||||
public void addDisposeListener (DisposeListener listener) {
|
||||
waveformPane.getControl().addDisposeListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* triggers included actions if widget is disposed
|
||||
*
|
||||
* @param e
|
||||
*/
|
||||
public void widgetDisposed(DisposeEvent e) {
|
||||
disposeListenerNumber -= 1;
|
||||
if( disposeListenerNumber == 0) { //if the last tab is closed, reset statusbar
|
||||
eventBroker.post(WaveStatusBarControl.ZOOM_LEVEL, null);
|
||||
eventBroker.post(WaveStatusBarControl.CURSOR_TIME, null);
|
||||
eventBroker.post(WaveStatusBarControl.MARKER_TIME, null);
|
||||
eventBroker.post(WaveStatusBarControl.MARKER_DIFF, null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue