From: <pga...@vu...> - 2017-01-10 21:59:42
|
Revision: 43973 Author: pgardner Date: 2017-01-10 21:59:20 +0000 (Tue, 10 Jan 2017) Log Message: ----------- reworked top bar a bit; added options to select which views are available Modified Paths: -------------- client/trunk/azureus2/src/org/gudy/azureus2/internat/MessagesBundle.properties client/trunk/azureus3/src/com/aelitis/azureus/activities/VuzeActivitiesManager.java client/trunk/azureus3/src/com/aelitis/azureus/ui/swt/views/TopBarView.java client/trunk/azureus3/src/com/aelitis/azureus/ui/swt/views/ViewQuickNotifications.java Modified: client/trunk/azureus2/src/org/gudy/azureus2/internat/MessagesBundle.properties =================================================================== --- client/trunk/azureus2/src/org/gudy/azureus2/internat/MessagesBundle.properties 2017-01-10 17:15:41 UTC (rev 43972) +++ client/trunk/azureus2/src/org/gudy/azureus2/internat/MessagesBundle.properties 2017-01-10 21:59:20 UTC (rev 43973) @@ -1895,7 +1895,7 @@ ConfigView.section.file.resume.recheck.all=On crash-restart check entire file for completed pieces (Otherwise only pieces active at last save are checked) ConfigureWizard.language.choose=Choose a language from the list below: popup.closing.in=Auto-closing window in %1 seconds -popup.more.waiting=%1 more message(s).. +popup.more.waiting=%1 more message(s)... # > 2402 Modified: client/trunk/azureus3/src/com/aelitis/azureus/activities/VuzeActivitiesManager.java =================================================================== --- client/trunk/azureus3/src/com/aelitis/azureus/activities/VuzeActivitiesManager.java 2017-01-10 17:15:41 UTC (rev 43972) +++ client/trunk/azureus3/src/com/aelitis/azureus/activities/VuzeActivitiesManager.java 2017-01-10 21:59:20 UTC (rev 43973) @@ -589,16 +589,20 @@ return allEntries.getList(); } - public static VuzeActivitiesEntry + public static Object[] getMostRecentUnseen() { VuzeActivitiesEntry newest = null; long newest_time = 0; + int num_unseen = 0; + for ( VuzeActivitiesEntry entry: allEntries ){ if ( !entry.getViewed()){ + num_unseen++; + long t = entry.getTimestamp(); if ( t > newest_time ){ @@ -609,7 +613,7 @@ } } - return( newest ); + return( new Object[]{ newest, num_unseen }); } public static int getNumEntries() { Modified: client/trunk/azureus3/src/com/aelitis/azureus/ui/swt/views/TopBarView.java =================================================================== --- client/trunk/azureus3/src/com/aelitis/azureus/ui/swt/views/TopBarView.java 2017-01-10 17:15:41 UTC (rev 43972) +++ client/trunk/azureus3/src/com/aelitis/azureus/ui/swt/views/TopBarView.java 2017-01-10 21:59:20 UTC (rev 43973) @@ -47,7 +47,6 @@ import com.aelitis.azureus.ui.skin.SkinConstants; import com.aelitis.azureus.ui.swt.UIFunctionsManagerSWT; import com.aelitis.azureus.ui.swt.skin.*; -import com.aelitis.azureus.ui.swt.skin.SWTSkinButtonUtility.ButtonListenerAdapter; import com.aelitis.azureus.ui.swt.views.skin.SkinView; /** @@ -58,6 +57,8 @@ public class TopBarView extends SkinView { + private static final Object view_name_key = new Object(); + private List<UISWTViewCore> topbarViews = new ArrayList<UISWTViewCore>(); private UISWTViewCore activeTopBar; @@ -182,6 +183,7 @@ } }); + /* SWTSkinObject soPrev = skin.getSkinObject("topbar-plugin-prev"); if (soPrev != null) { SWTSkinButtonUtility btnPrev = new SWTSkinButtonUtility(soPrev); @@ -255,7 +257,8 @@ } }); } - + */ + SWTSkinObject soList = skin.getSkinObject("topbar-plugin-list"); if (soList != null) { final Composite cList = (Composite) soList.getControl(); @@ -265,10 +268,19 @@ listPlugins.setForeground(cList.getForeground()); listPlugins.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { - int i = listPlugins.getSelectionIndex(); - if (i >= 0 && i < topbarViews.size()) { - activateTopBar((UISWTViewCore) topbarViews.get(i)); - COConfigurationManager.setParameter("topbar.viewindex", i); + String[] selection = listPlugins.getSelection(); + + if ( selection.length > 0 ){ + + String name = selection[0]; + + for ( UISWTViewCore view: topbarViews ){ + + if ( getViewName(view).equals( name )){ + + activateTopBar( view ); + } + } } } @@ -275,6 +287,67 @@ public void widgetDefaultSelected(SelectionEvent e) { } }); + + final Menu menu = new Menu( listPlugins ); + + listPlugins.setMenu( menu ); + + menu.addMenuListener( + new MenuListener() { + + @Override + public void menuShown(MenuEvent e) { + for ( MenuItem mi: menu.getItems()){ + mi.dispose(); + } + + for ( final UISWTViewCore view: topbarViews ){ + + final String id = view.getViewID(); + + final String name = getViewName( view ); + + final MenuItem mi = new MenuItem( menu, SWT.CHECK ); + + mi.setText( name ); + + boolean enabled = isEnabled( view ); + + mi.setSelection( enabled ); + + mi.addSelectionListener( + new SelectionAdapter() { + @Override + public void + widgetSelected( + SelectionEvent e ) + { + boolean sel = mi.getSelection(); + + COConfigurationManager.setParameter( "topbar.view." + id + ".enabled", sel ); + + view.getComposite().setVisible( sel ); + + if ( sel ){ + + listPlugins.add( name ); + + }else{ + + listPlugins.remove( name ); + } + + Utils.relayout( cPluginArea ); + } + }); + + } + } + + @Override + public void menuHidden(MenuEvent e) { + } + }); } skinObject = skin.getSkinObject(SkinConstants.VIEWID_PLUGINBAR); @@ -338,10 +411,6 @@ }); } - int toActiveView = COConfigurationManager.getIntParameter( - "topbar.viewindex", 0); - int viewIndex = toActiveView; - UISWTInstanceImpl uiSWTinstance = (UISWTInstanceImpl) UIFunctionsManagerSWT.getUIFunctionsSWT().getUISWTInstance(); if (uiSWTinstance != null && !registeredCoreSubViews ) { @@ -361,68 +430,188 @@ } if ( uiSWTinstance != null ){ + UISWTViewEventListenerHolder[] pluginViews = uiSWTinstance.getViewListeners(UISWTInstance.VIEW_TOPBAR); + for (UISWTViewEventListenerHolder l : pluginViews) { - if (l != null) { - try { + + if ( l != null ){ + + try{ UISWTViewImpl view = new UISWTViewImpl(l.getViewID(), UISWTInstance.VIEW_TOPBAR, false); + view.setEventListener(l, true); + addTopBarView(view, cPluginArea); - if (toActiveView-- == 0) { - activateTopBar(view); - if (listPlugins != null) { - listPlugins.setSelection(viewIndex); - } - } - } catch (Exception e) { - e.printStackTrace(); - // skip, plugin probably specifically asked to not be added + + }catch ( Throwable e ){ + + Debug.out( e ); } } } } - if (toActiveView >= 0 && topbarViews.size() > 0) { - activeTopBar = topbarViews.get(0); - activeTopBar.getComposite().setVisible(true); + String active_view_id = COConfigurationManager.getStringParameter( "topbar.active.view.id", "" ); + + boolean activated = false; + UISWTViewCore first_enabled = null; + + for ( UISWTViewCore view: topbarViews ){ + + if ( isEnabled( view )){ + + if ( first_enabled == null ){ + + first_enabled = view; + } + + if ( active_view_id.equals( view.getViewID())){ + + activateTopBar( view ); + + activated = true; + + break; + } + } } + if ( !activated && first_enabled != null ){ + + activateTopBar( first_enabled ); + + activated = true; + } + + if ( !activated && topbarViews.size() > 0 ){ + + UISWTViewCore view = topbarViews.get( 0 ); + + setEnabled( view, true ); + + activateTopBar( view ); + } + if ( skinObject != null ){ skinObject.getControl().getParent().layout(true); } - } catch (Exception e) { - Debug.out(e); + }catch( Throwable e ){ + + Debug.out( e ); } } - /** - * @param view - * - * @since 3.0.1.1 - */ - protected void activateTopBar(UISWTViewCore view) { - if (activeTopBar != null) { + private boolean + isEnabled( + UISWTViewCore view ) + { + return( COConfigurationManager.getBooleanParameter( "topbar.view." + view.getViewID() + ".enabled", true )); + } + + private boolean + setEnabled( + UISWTViewCore view, + boolean enabled ) + { + return( COConfigurationManager.setParameter( "topbar.view." + view.getViewID() + ".enabled", enabled )); + } + + private String + getViewName( + UISWTViewCore view ) + { + // no locale switching support, la de da + + String s = (String)view.getUserData( view_name_key ); + + if ( s != null ){ + + return( s ); + } + + s = view.getFullTitle(); + + if ( MessageText.keyExists(s)){ + + s = MessageText.getString(s); + } + + view.setUserData( view_name_key, s ); + + return( s ); + } + + protected void + activateTopBar( + UISWTViewCore view ) + { + + if ( !isEnabled( view )){ + + Debug.out( "Attempt to activate disabled view" ); + + return; + } + + if ( view == activeTopBar ){ + + return; + } + + if ( activeTopBar != null ){ + Composite c = activeTopBar.getComposite(); - while (c.getParent() != cPluginArea) { + + while (c.getParent() != cPluginArea ){ + c = c.getParent(); } + c.setVisible(false); } + activeTopBar = view; + + COConfigurationManager.setParameter( "topbar.active.view.id", view.getViewID()); + + if ( listPlugins != null ){ + + String name = getViewName( view ); + + int index = listPlugins.indexOf( name ); + + if ( index == -1 ){ + + listPlugins.add( name ); + + index = listPlugins.indexOf( name ); + } + + listPlugins.setSelection( new String[0]); // hide selection state as distracting + + } + Composite c = activeTopBar.getComposite(); - while (c.getParent() != cPluginArea) { + + while (c.getParent() != cPluginArea ){ + c = c.getParent(); } + c.setVisible(true); + /* SWTSkinObject soTitle = skin.getSkinObject("topbar-plugin-title"); - //System.out.println("Hello" + soTitle); + if (soTitle != null) { + soTitle.getControl().redraw(); } + */ - Utils.relayout(c); + Utils.relayout(cPluginArea); activeTopBar.triggerEvent( UISWTViewEvent.TYPE_FOCUSGAINED, null ); } @@ -459,12 +648,13 @@ } topbarViews.add(view); - if (listPlugins != null) { - String s = view.getFullTitle(); - if (MessageText.keyExists(s)) { - s = MessageText.getString(s); + + if ( listPlugins != null ){ + + if ( isEnabled( view )){ + + listPlugins.add( getViewName( view )); } - listPlugins.add(s); } } Modified: client/trunk/azureus3/src/com/aelitis/azureus/ui/swt/views/ViewQuickNotifications.java =================================================================== --- client/trunk/azureus3/src/com/aelitis/azureus/ui/swt/views/ViewQuickNotifications.java 2017-01-10 17:15:41 UTC (rev 43972) +++ client/trunk/azureus3/src/com/aelitis/azureus/ui/swt/views/ViewQuickNotifications.java 2017-01-10 21:59:20 UTC (rev 43973) @@ -17,8 +17,6 @@ package com.aelitis.azureus.ui.swt.views; -import java.net.InetAddress; - import org.eclipse.swt.SWT; import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseEvent; @@ -36,8 +34,6 @@ import com.aelitis.azureus.activities.VuzeActivitiesEntry; import com.aelitis.azureus.activities.VuzeActivitiesManager; -import com.aelitis.azureus.core.networkmanager.admin.NetworkAdmin; -import com.aelitis.azureus.core.speedmanager.SpeedManager; import com.aelitis.azureus.ui.UIFunctions; import com.aelitis.azureus.ui.UIFunctionsManager; import com.aelitis.azureus.ui.mdi.MultipleDocumentInterface; @@ -51,6 +47,7 @@ private Composite composite; private Label notification_icon; private BufferedLabel notification_text; + private BufferedLabel more_text; public ViewQuickNotifications() @@ -71,6 +68,7 @@ Utils.setLayoutData(composite, gridData); GridLayout layout = new GridLayout(2, false); + layout.marginLeft = layout.marginRight = layout.marginTop = layout.marginBottom = 0; composite.setLayout(layout); @@ -100,9 +98,20 @@ } } }; + + // text + more_text = new BufferedLabel(composite,SWT.NONE); + gridData = new GridData(GridData.FILL_HORIZONTAL); + gridData.horizontalSpan = 2; + Utils.setLayoutData(more_text, gridData); + + + composite.addMouseListener( listener ); + notification_icon.addMouseListener( listener ); notification_text.addMouseListener( listener ); + more_text.addMouseListener( listener ); } private void @@ -125,8 +134,10 @@ private void refresh() { - VuzeActivitiesEntry entry = VuzeActivitiesManager.getMostRecentUnseen(); + Object[] temp = VuzeActivitiesManager.getMostRecentUnseen(); + VuzeActivitiesEntry entry = (VuzeActivitiesEntry)temp[0]; + if ( entry == null ){ notification_icon.setImage( null ); @@ -133,6 +144,8 @@ notification_text.setText( "" ); + more_text.setText( "" ); + }else{ notification_text.setText( entry.getText()); @@ -157,6 +170,20 @@ notification_icon.setImage( null ); } + + int num = (Integer)temp[1]; + + if ( num <= 1 ){ + + more_text.setText( "" ); + + }else{ + + more_text.setText( + MessageText.getString( + "popup.more.waiting", + new String[]{ String.valueOf( num-1 )} )); + } } } |