Skip to content

Commit

Permalink
Testing sidebar right-click menu NOT selecting the entry first
Browse files Browse the repository at this point in the history
  • Loading branch information
parg committed Dec 18, 2024
1 parent 194e3e1 commit 5b73835
Show file tree
Hide file tree
Showing 14 changed files with 140 additions and 69 deletions.
4 changes: 3 additions & 1 deletion core/src/com/biglybt/ui/mdi/MultipleDocumentInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,10 @@ public MdiEntry createEntryFromSkinRef(String parentEntryID, String id,
String configID, String title, ViewTitleInfo titleInfo, Object params,
boolean closeable, String preferedAfterID);

public MdiEntry getCurrentEntry();
public MdiEntry getSelectedEntry();

public MdiEntry getMenuEntry();

public MdiEntry getEntry(String id);

public MdiEntry getEntry(String id, Object datasource );
Expand Down
2 changes: 1 addition & 1 deletion uis/src/com/biglybt/ui/swt/TorrentUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -4800,7 +4800,7 @@ public static Map<String, Long> calculateToolbarStates(
if (!hasRealDM) {
MultipleDocumentInterfaceSWT mdi = UIFunctionsManagerSWT.getUIFunctionsSWT().getMDISWT();
if (mdi != null) {
MdiEntrySWT entry = mdi.getCurrentEntry();
MdiEntrySWT entry = mdi.getSelectedEntry();
if (entry != null) {
if (entry.getDataSource() instanceof DownloadManager) {
hasRealDM = true;
Expand Down
2 changes: 1 addition & 1 deletion uis/src/com/biglybt/ui/swt/devices/SBC_DevicesView.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public void coreRunning(Core core) {

MultipleDocumentInterfaceSWT mdi = UIFunctionsManagerSWT.getUIFunctionsSWT().getMDISWT();
if (mdi != null){
mdiEntry = mdi.getCurrentEntry();
mdiEntry = mdi.getSelectedEntry();
Object ds = mdiEntry.getDataSource();
if ( !( ds instanceof Device )){
return( null );
Expand Down
2 changes: 1 addition & 1 deletion uis/src/com/biglybt/ui/swt/extlistener/StimulusRPC.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public boolean receive(String name, Map values) {
if (tabID.length() > 0) {
// 3.2 TODO: Should we be checking for partial matches?
MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
MdiEntry entry = mdi.getCurrentEntry();
MdiEntry entry = mdi.getSelectedEntry();
if (entry != null) {
return entry.getViewID().equals(tabID);
}
Expand Down
8 changes: 4 additions & 4 deletions uis/src/com/biglybt/ui/swt/mainwindow/MenuFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ public static MenuItem addCloseTabMenuItem(Menu menu) {
public void handleEvent(Event event) {
MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
if (mdi != null) {
MdiEntry currentEntry = mdi.getCurrentEntry();
MdiEntry currentEntry = mdi.getMenuEntry();
if (currentEntry != null && currentEntry.isCloseable()) {
mdi.closeEntry(currentEntry,true);
}
Expand All @@ -515,7 +515,7 @@ public void handleEvent(Event event) {
public void menuShown(MenuEvent e) {
MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
if (mdi != null) {
MdiEntry currentEntry = mdi.getCurrentEntry();
MdiEntry currentEntry = mdi.getMenuEntry();
if (currentEntry != null && currentEntry.isCloseable()) {
menuItem.setEnabled(true);
return;
Expand All @@ -539,7 +539,7 @@ public static MenuItem addCloseCurrentViewMenuItem(Menu menu) {
public void handleEvent(Event e) {
MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
if (mdi != null) {
MdiEntry currentEntry = mdi.getCurrentEntry();
MdiEntry currentEntry = mdi.getMenuEntry();
if (currentEntry != null && currentEntry.isCloseable()) {
mdi.closeEntry(currentEntry,true);
}
Expand All @@ -554,7 +554,7 @@ public void handleEvent(Event event) {
if (!item.isDisposed() && !event.widget.isDisposed()) {
MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
if (mdi != null) {
MdiEntry currentEntry = mdi.getCurrentEntry();
MdiEntry currentEntry = mdi.getMenuEntry();
if (currentEntry != null && currentEntry.isCloseable()) {
item.setEnabled(true);
return;
Expand Down
13 changes: 9 additions & 4 deletions uis/src/com/biglybt/ui/swt/mdi/BaseMDI.java
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ protected BaseMdiEntry closeEntryByID(String id, boolean userInitiated) {
}

if (currentEntry == removedItem) {
setCurrentEntry(null);
setSelectedEntry(null);
}

removedItem.closeView( userInitiated );
Expand Down Expand Up @@ -294,15 +294,20 @@ public abstract MdiEntry createEntryFromSkinRef(String parentEntryID, String id,
boolean closeable, String preferedAfterID);

@Override
public MdiEntrySWT getCurrentEntry() {
public MdiEntrySWT getSelectedEntry() {
if (isDisposed()) {
return null;
}
return currentEntry;
}

@Override
public MdiEntrySWT getMenuEntry() {
return( getSelectedEntry());
}

protected void
setCurrentEntry(
setSelectedEntry(
MdiEntrySWT entry )
{
currentEntry = entry;
Expand Down Expand Up @@ -686,7 +691,7 @@ public Object skinObjectDestroyed(SWTSkinObject skinObject, Object params) {

@Override
public void updateUI() {
MdiEntry currentEntry = getCurrentEntry();
MdiEntry currentEntry = getSelectedEntry();
if (currentEntry != null) {
currentEntry.updateUI( false );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public MdiEntry createEntryFromEventListener(String parentEntryID,
MdiEntrySWT[] getEntries();

@Override
MdiEntrySWT getCurrentEntry();
MdiEntrySWT getSelectedEntry();

/**
* @param closeableConfigFile
Expand Down
24 changes: 12 additions & 12 deletions uis/src/com/biglybt/ui/swt/mdi/TabbedMDI.java
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ public void handleEvent(Event event) {
// ESC or CTRL+F4 closes current Tab
if (key == SWT.ESC
|| (event.keyCode == SWT.F4 && event.stateMask == SWT.CTRL)) {
closeEntry(getCurrentEntry(),true);
closeEntry(getSelectedEntry(),true);
event.doit = false;
} else if (event.keyCode == SWT.F6
|| (event.character == SWT.TAB && (event.stateMask & SWT.CTRL) != 0)) {
Expand All @@ -501,7 +501,7 @@ public void handleEvent(Event event) {
}
}else{
if (focus_control == tabFolder ){
TabbedEntry current = getCurrentEntry();
TabbedEntry current = getSelectedEntry();
if ( current != null ){
if ( current.processAccelerator( event.character, event.stateMask )){
event.doit = false;
Expand Down Expand Up @@ -1085,7 +1085,7 @@ public void showEntry(final MdiEntry _newEntry) {
select_history.removeFirst();
}

MdiEntry oldEntry = getCurrentEntry();
MdiEntry oldEntry = getSelectedEntry();
if (newEntry == oldEntry && oldEntry != null) {
((BaseMdiEntry) newEntry).show();
triggerSelectionListener(newEntry, newEntry);
Expand All @@ -1096,7 +1096,7 @@ public void showEntry(final MdiEntry _newEntry) {
oldEntry.hide();
}

setCurrentEntry((MdiEntrySWT)newEntry );
setSelectedEntry((MdiEntrySWT)newEntry );

if (newEntry instanceof BaseMdiEntry) {
((BaseMdiEntry) newEntry).show();
Expand Down Expand Up @@ -1318,7 +1318,7 @@ private void swt_setupNewEntry(TabbedEntry entry) {
@Override
public void widgetDisposed(DisposeEvent e) {
if (tabFolder.getItemCount() == 0) {
setCurrentEntry( null );
setSelectedEntry( null );
}
}
});
Expand All @@ -1330,7 +1330,7 @@ public void widgetDisposed(DisposeEvent e) {

@Override
public void runSupport() {
if (getCurrentEntry() != null || tabFolder.isDisposed()) {
if (getSelectedEntry() != null || tabFolder.isDisposed()) {
return;
}
CTabItem selection = tabFolder.getSelection();
Expand Down Expand Up @@ -1390,7 +1390,7 @@ protected TabbedEntry getEntryFromTabItem(CTabItem item) {
@Override
public String getUpdateUIName() {
String name = "MDI";
MdiEntry entry = getCurrentEntry();
MdiEntry entry = getSelectedEntry();
if (entry != null) {
name += "-" + entry.getViewID();
}
Expand Down Expand Up @@ -1817,14 +1817,14 @@ public String getMenuIdPrefix() {
}

@Override
protected void setCurrentEntry(MdiEntrySWT entry) {
super.setCurrentEntry(entry);
protected void setSelectedEntry(MdiEntrySWT entry) {
super.setSelectedEntry(entry);

Utils.execSWTThread(this::swt_refreshVitality);
}

protected void swt_refreshVitality() {
TabbedEntry currentEntry = getCurrentEntry();
TabbedEntry currentEntry = getSelectedEntry();
if (currentEntry == null) {
return;
}
Expand Down Expand Up @@ -1899,8 +1899,8 @@ public TabbedEntry getEntry(String id) {
}

@Override
public TabbedEntry getCurrentEntry() {
return (TabbedEntry) super.getCurrentEntry();
public TabbedEntry getSelectedEntry() {
return (TabbedEntry) super.getSelectedEntry();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ private BaseMdiEntry getActiveView() {
if (tabbedMDI == null || tabbedMDI.isDisposed()) {
return null;
}
return (BaseMdiEntry) tabbedMDI.getCurrentEntry();
return (BaseMdiEntry) tabbedMDI.getSelectedEntry();
}

public static class TorrentDetailMdiEntry
Expand Down
4 changes: 2 additions & 2 deletions uis/src/com/biglybt/ui/swt/views/skin/ToolBarView.java
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ public void _refreshCoreToolBarItems() {

if (mdi != null) {
UIToolBarItem[] allToolBarItems = tbm.getAllToolBarItems();
MdiEntrySWT entry = mdi.getCurrentEntry();
MdiEntrySWT entry = mdi.getSelectedEntry();
Map<String, Long> mapStates = new HashMap<>();
if (entry != null) {
UIToolBarEnablerBase[] enablers = entry.getToolbarEnablers();
Expand Down Expand Up @@ -1194,7 +1194,7 @@ private boolean triggerViewToolBar(ToolBarItem item, long activationType,
}
MultipleDocumentInterfaceSWT mdi = UIFunctionsManagerSWT.getUIFunctionsSWT().getMDISWT();
if (mdi != null) {
MdiEntrySWT entry = mdi.getCurrentEntry();
MdiEntrySWT entry = mdi.getSelectedEntry();
if ( entry != null ){
UIToolBarEnablerBase[] enablers = entry.getToolbarEnablers();
for (UIToolBarEnablerBase enabler : enablers) {
Expand Down
Loading

0 comments on commit 5b73835

Please sign in to comment.