Author: jerome
Date: 2008-08-23 09:44:41 +0200 (Sat, 23 Aug 2008)
New Revision: 1573

Added:
   
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/Renderer/LabelsListRenderer.java
Modified:
   
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/CcInterface.java
Log:
* Removed dialog box dropping a gadget/attitune.
* Some improvements
* Added a JList Renderer to create dynamics playlists (in the future).

Modified: 
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/CcInterface.java
===================================================================
--- 
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/CcInterface.java
     2008-08-22 15:56:16 UTC (rev 1572)
+++ 
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/CcInterface.java
     2008-08-23 07:44:41 UTC (rev 1573)
@@ -75,6 +75,8 @@
 import javax.swing.SwingUtilities;
 import javax.swing.UIManager;
 import javax.swing.border.BevelBorder;
+import javax.swing.event.ListDataEvent;
+import javax.swing.event.ListDataListener;
 import javax.swing.event.PopupMenuEvent;
 import javax.swing.event.PopupMenuListener;
 import javax.swing.plaf.InsetsUIResource;
@@ -96,6 +98,7 @@
 import com.tuxdroid.cc.Object.PseudoFileBrowser.FileBrowser;
 import com.tuxdroid.cc.Object.WebBrowser.webBrowser;
 import com.tuxdroid.cc.Renderer.ColorCellRenderer;
+import com.tuxdroid.cc.Renderer.LabelsListRenderer;
 import com.tuxdroid.cc.Utils.AttituneAlertPanel;
 import com.tuxdroid.cc.Utils.CCRemoteActions;
 import com.tuxdroid.cc.Utils.GadgetAlertPanel;
@@ -172,7 +175,8 @@
        protected static final int ALERT_ACTION = 0;
        protected static final int ADD_REMOTE_ACTION = 1;
        protected String IP = "127.0.0.1";
-       public int leftSize;
+       public int leftSize;
+       int playlistDragToIndex = -1;
        
        /** CcInterface specifics variables **/
        public byte view = CcInterface.VIEW_LIST;
@@ -1464,12 +1468,12 @@
        public void showGadgetLatestProperties(){
                if(view == CcInterface.VIEW_LIST){
                        if(file_browser.getListViewSelectedIndex() != -1){ 
-                               maskAllTabs();
+                               this.maskAllTabs();
                                if(this.savedProperties.containsKey("gadget")){
                                        JPanel[] panels = (JPanel[]) 
this.savedProperties.get("gadget");
                                        
this.jTabbedPane.add(language.getPanelSummary(), panels[0]);
                                        
this.jTabbedPane.add(language.getPanelHelp(), panels[1]);
-                               }
+                               }else this.maskGadgetsTabs();
                        } else this.maskGadgetsTabs();
                }
                else if(view == CcInterface.VIEW_THUMBNAIL){
@@ -1479,7 +1483,7 @@
                                        JPanel[] panels = (JPanel[]) 
this.savedProperties.get("gadget-thumbnail");
                                        
this.jTabbedPane.add(language.getPanelSummary(), panels[0]);
                                        
this.jTabbedPane.add(language.getPanelHelp(), panels[1]);
-                               }
+                               }else this.maskGadgetsTabs();
                        }else this.maskGadgetsTabs();
                }
        }
@@ -1489,7 +1493,7 @@
         * @param index let choose between gadgets or attitunes components.
         */
        private void showFileBrowser(int index){
-               this.jTabbedPane.setVisible(true); //FIXME 
+               this.jTabbedPane.setVisible(true);
                this.getTrash().setVisible(true);
                this.getLeftPanel().setSize(this.getLeftPanel().getWidth(),
                                this.leftSize);
@@ -1640,7 +1644,7 @@
        
        
        protected void showPlaylist(int index){
-               this.jTabbedPane.setVisible(true); //FIXME 
+               this.jTabbedPane.setVisible(true);
                this.getTrash().setVisible(true);
                this.getLeftPanel().setSize(this.getLeftPanel().getWidth(),
                                this.leftSize);
@@ -1652,7 +1656,7 @@
                this.scroll_fileBrowser_thumbnailAttitunes.setVisible(false);
                this.scroll_fileBrowser_thumbnailGadgets.setVisible(false);
                this.jListLibrary.clearSelection();
-               //TODO 
+               
                if(index == 1){
                        remotePlaylist.setVisible(true);
                        alertPlaylist.setVisible(false);
@@ -1706,8 +1710,8 @@
         */
        private JList getJListPlaylists() {
                if (jListPlaylists == null) {
-                       String[] listeItems = { "      
"+language.getPlaylistsOptNotification(),
-                                                                       "      
"+language.getPlaylistsOptRemote(),
+                       String[] listeItems = {"      
"+language.getPlaylistsOptNotification(),
+                                                                  "      
"+language.getPlaylistsOptRemote(),
                                                                  };
                        jListPlaylists = new JList(listeItems);
                        jListPlaylists.setFont(new Font("Verdana", Font.PLAIN, 
11));
@@ -1725,7 +1729,9 @@
                                catch(Exception exc){}
                        
dropTargPlaylist.setDefaultActions(DnDConstants.ACTION_COPY);
                    dropTargPlaylist.setComponent(jListPlaylists);
-                   dropTargPlaylist.setFlavorMap(null);
+                   dropTargPlaylist.setFlavorMap(null);
+                   jListPlaylists.setCellRenderer(new LabelsListRenderer());
+
                }
                return jListPlaylists;
        }
@@ -2016,7 +2022,7 @@
                                        
getClass().getResource("images/buttons/play.png")));
                        //file_browser.stopPlaying();
                        this.playButton.doClick();
-               }//FIXME 
+               }
                else 
if(arg0.getPropertyName().equalsIgnoreCase("Attitune-Selection-Changed")){
                        TuxDegradeePanelWithInset panel = 
(TuxDegradeePanelWithInset)arg0.getNewValue();
                        this.maskAllTabs();
@@ -2733,14 +2739,10 @@
        
        
        public void addToPlaylist(DropTargetDropEvent arg0){
-               Object[] options = new Object[]{"Create Alert", "Add to remote 
list"};
-               String message = language.getChooseActionCaption();
-               Object result = JOptionPane.showInputDialog(jContentPane, 
message, message,
-                               JOptionPane.QUESTION_MESSAGE, null, options, 
options[0]);
-               
-               //Create action with an attitune.
+               //Create action with an attitune.
+               System.out.println(this.playlistDragToIndex);
                if(this.type == CcInterface.TYPE_ATTITUNES){  
-                       if(result == options[0]){
+                       if(this.playlistDragToIndex == 0){
                                Object[] datas = 
file_browser.getDatasAsRemoteStruct(TYPE_ATTITUNES, this.view);
                                datas = rename(datas, 
alertPlaylist.datasToDisplay);
                                settings.addToAlertList(datas, null);
@@ -2748,7 +2750,7 @@
                                this.showPlaylist(0);
                        }
                        
-                       else if(result == options[1]){
+                       else if(this.playlistDragToIndex == 1){
                                Object[] datas = 
file_browser.getDatasAsRemoteStruct(TYPE_ATTITUNES, this.view);
                                datas = rename(datas, 
remotePlaylist.datasToDisplay);
                                settings.addToRemoteList(datas);
@@ -2760,7 +2762,7 @@
                
                //Create action with a gadget.
                else if(this.type == CcInterface.TYPE_GADGETS){
-                       if(result == options[0]){
+                       if(this.playlistDragToIndex == 0){
                                Object[] datas = 
file_browser.getDatasAsRemoteStruct(TYPE_GADGETS, this.view);
                                datas = rename(datas, 
alertPlaylist.datasToDisplay);
                                settings.addToAlertList(datas, null);
@@ -2768,7 +2770,7 @@
                                this.showPlaylist(0);
                        }
                        
-                       else if(result == options[1]){
+                       else if(this.playlistDragToIndex == 1){
                                Object[] datas = 
file_browser.getDatasAsRemoteStruct(TYPE_GADGETS, this.view);
                                datas = rename(datas, 
remotePlaylist.datasToDisplay);
                                settings.addToRemoteList(datas);
@@ -2784,7 +2786,8 @@
        
        public void drop(DropTargetDropEvent arg0) {
                //Drop to playlists.
-               if(arg0.getSource().equals(this.dropTargPlaylist)){
+               if(arg0.getSource().equals(this.dropTargPlaylist)){
+               playlistDragToIndex = 
jListPlaylists.locationToIndex(arg0.getLocation());
                        this.addToPlaylist(arg0);
                }
                //Drop to library.

Added: 
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/Renderer/LabelsListRenderer.java
===================================================================
--- 
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/Renderer/LabelsListRenderer.java
                             (rev 0)
+++ 
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/Renderer/LabelsListRenderer.java
     2008-08-23 07:44:41 UTC (rev 1573)
@@ -0,0 +1,58 @@
+/* This file is part of "TuxDroid Control Center".
+ *    Copyright 2008, kysoh
+ *    Author : Conan Jerome
+ *    eMail  : [EMAIL PROTECTED]
+ *    Site   : http://www.kysoh.com/
+ *
+ * "TuxDroid Control Center" is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * "TuxDroid Control Center" is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with "TuxDroid Control Center"; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package com.tuxdroid.cc.Renderer;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Font;
+
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.JLabel;
+import javax.swing.JList;
+
+public class LabelsListRenderer extends DefaultListCellRenderer{
+       private static final long serialVersionUID = 1L;
+       
+       JLabel label;
+       
+       public Component getListCellRendererComponent(JList list, Object value, 
int index,                                                 
+                                                                               
boolean isSelected, boolean cellHasFocus)    
+       {   
+               label = new JLabel();
+               label.setOpaque(true);
+               String val = 
((JLabel)super.getListCellRendererComponent(list,value,index,isSelected,cellHasFocus)).getText();
        
+        label.setText(val);
+        label.setFont(new Font("Verdana", Font.PLAIN, 11));
+        label.setForeground(Color.white);
+        
+        if(isSelected){
+               label.setBackground(new Color(224, 224, 224));
+               label.setForeground(Color.black);
+        }
+        else{
+               label.setBackground(new Color(143, 143, 143));
+        }
+               
+               return label;
+       }
+}


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to