From 0525d8d456f51531127c79300967ff19d91ea674 Mon Sep 17 00:00:00 2001 From: TuxPaper <725353+TuxPaper@users.noreply.github.com> Date: Mon, 9 Oct 2023 12:33:22 -0700 Subject: [PATCH] Fix missing menu item on right click of tab that has yet to be visible --- .../ui/swt/views/DownloadActivityView.java | 52 +++++++++++++------ 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/uis/src/com/biglybt/ui/swt/views/DownloadActivityView.java b/uis/src/com/biglybt/ui/swt/views/DownloadActivityView.java index b2445dc4514..65f918ff2bf 100644 --- a/uis/src/com/biglybt/ui/swt/views/DownloadActivityView.java +++ b/uis/src/com/biglybt/ui/swt/views/DownloadActivityView.java @@ -40,7 +40,9 @@ import com.biglybt.core.util.average.AverageFactory; import com.biglybt.core.util.average.MovingImmediateAverage; import com.biglybt.ui.common.ToolBarItem; +import com.biglybt.ui.common.viewtitleinfo.ViewTitleInfo2; import com.biglybt.ui.mdi.MdiEntry; +import com.biglybt.ui.mdi.MultipleDocumentInterface; import com.biglybt.ui.selectedcontent.SelectedContent; import com.biglybt.ui.selectedcontent.SelectedContentManager; import com.biglybt.ui.swt.Messages; @@ -65,7 +67,8 @@ */ public class DownloadActivityView - implements UISWTViewCoreEventListener, UIPluginViewToolBarListener, MdiSWTMenuHackListener, ParameterListener + implements UISWTViewCoreEventListener, UIPluginViewToolBarListener, + MdiSWTMenuHackListener, ParameterListener, ViewTitleInfo2 { public static final String MSGID_PREFIX = "DownloadActivityView"; @@ -103,6 +106,11 @@ return( MessageText.getString(MSGID_PREFIX + ".title.full" )); } + @Override + public Object getTitleInfoProperty(int propertyID) { + return null; + } + public void initialize( Composite parent ) @@ -741,22 +749,30 @@ private void create() { - swtView.setTitle(getFullTitle()); - - swtView.setToolBarListener(this); - COConfigurationManager.addParameterListener( "DownloadActivity.show.eta", this ); show_time = COConfigurationManager.getBooleanParameter( "DownloadActivity.show.eta" ); - + } + + private void setSwtView(UISWTView swtView) { + if (this.swtView == swtView) { + return; + } + this.swtView = swtView; + + swtView.setTitle(getFullTitle()); + + swtView.setToolBarListener(this); + if (swtView instanceof TabbedEntry) { - + TabbedEntry tabView = (TabbedEntry)swtView; - + tabView.addListener( this ); - + legend_at_bottom = tabView.getMDI().getAllowSubViews(); } + } private void @@ -779,13 +795,6 @@ eta = null; } - - if ( swtView instanceof TabbedEntry ){ - - TabbedEntry tabView = (TabbedEntry)swtView; - - tabView.removeListener( this ); - } } @Override @@ -795,7 +804,8 @@ { switch( event.getType()){ case UISWTViewEvent.TYPE_CREATE:{ - swtView = event.getView(); + + setSwtView(event.getView()); create(); @@ -880,6 +890,14 @@ return( true ); } + @Override + public void titleInfoLinked(MultipleDocumentInterface mdi, + MdiEntry mdiEntry) { + if (mdiEntry instanceof UISWTView) { + setSwtView((UISWTView) mdiEntry); + } + } + /* (non-Javadoc) * @see com.biglybt.pif.ui.toolbar.UIToolBarActivationListener#toolBarItemActivated(ToolBarItem, long, java.lang.Object) */