[cc-commits] [CC SVN] r14585 - in ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice: program ui/picasa

webmaster at creativecommons.org webmaster at creativecommons.org
Mon Jul 19 07:06:05 EDT 2010


Author: akila87
Date: 2010-07-19 11:06:05 +0000 (Mon, 19 Jul 2010)
New Revision: 14585

Modified:
   ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/program/PicasaConnection.java
   ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/picasa/PicasaDialog.java
   ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/picasa/SearchClickListener.java
   ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/picasa/SearchThread.java
Log:
*Search picasa images by license.

Modified: ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/program/PicasaConnection.java
===================================================================
--- ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/program/PicasaConnection.java	2010-07-18 16:38:41 UTC (rev 14584)
+++ ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/program/PicasaConnection.java	2010-07-19 11:06:05 UTC (rev 14585)
@@ -7,7 +7,7 @@
  * TODO:
  * Support for selecting images based on license
  * Get different sizes of images
- * 
+ *
  */
 package org.creativecommons.openoffice.program;
 
@@ -37,7 +37,7 @@
     protected PicasaConnection() {
     }
 
-    public ArrayList<Image> searchPhotos(String[] tags, int currentPage) {
+    public ArrayList<Image> searchPhotos(String[] tags, int currentPage, String licenseID) {
 
         imgList.removeAll(imgList);
         String tagLine = "";
@@ -52,7 +52,7 @@
             DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
             Document doc = docBuilder.parse("http://picasaweb.google.com/data/feed/base/"
                     + "all?alt=rss&kind=photo&access=public&filter=1&q="
-                    + tagLine + "&imglic=creative_commons&thumbsize=144");//CC-BY
+                    + tagLine + "&imglic="+licenseID+"&thumbsize=144");//CC-BY
             //&imgmax=94, 110, 128, 200, 220, 288, 320, 400, 512, 576, 640, 720, 800, 912, 1024, 1152, 1280, 1440, 1600
 
             //normalize text representation

Modified: ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/picasa/PicasaDialog.java
===================================================================
--- ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/picasa/PicasaDialog.java	2010-07-18 16:38:41 UTC (rev 14584)
+++ ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/picasa/PicasaDialog.java	2010-07-19 11:06:05 UTC (rev 14585)
@@ -10,11 +10,13 @@
 import com.sun.star.awt.SystemPointer;
 import java.awt.Rectangle;
 import com.sun.star.awt.XButton;
+import com.sun.star.awt.XCheckBox;
 import com.sun.star.awt.XPointer;
 import com.sun.star.awt.XControl;
 import com.sun.star.awt.XControlContainer;
 import com.sun.star.awt.XControlModel;
 import com.sun.star.awt.XDialog;
+import com.sun.star.awt.XRadioButton;
 import com.sun.star.awt.XToolkit;
 import com.sun.star.awt.XWindow;
 import com.sun.star.beans.XPropertySet;
@@ -59,7 +61,7 @@
     public static final String LBL_TAGS = "lblTags";
     public static final String TXT_TAGS = "txtTags";
     //public static final String LBL_LICENSE = "lblLicense";
-    //public static final String LISTBOX_LICENSE = "cmbLicense";    
+    //public static final String LISTBOX_LICENSE = "cmbLicense";
     public static final String BTN_SEARCH = "btnSearch";
     public static final String searchButtonLabel = "Search";
     public static final String GB_RESULTS = "gbResults";
@@ -68,11 +70,22 @@
     public static final String BTN_PREVIOUS = "btnPrevious";
     public static final String BTN_PREVIOUSLABEL = "Previous";
     public static final String PB_NAME = "progressBar";
+    public static final String RDO_COMMERCIALNAME = "rdoCommercial";
+    public static final String RDO_COMMERCIALLABEL = "Search for works I can use for commercial purposes";
+    public static final String RDO_UPDATENAME = "chkUpdate";
+    public static final String RDO_UPDATELABEL = "Search for works I can modify, adapt, or build upon";
+    public static final String RDO_CCNAME = "rdoCC";
+    public static final String RDO_CCLABEL = "Images with Creative Commons Licenses (Including above two)";
+
     public static final int SHOWRESULTSPERROW = 4;
     public static final int SHOWRESULTSPERCOLUMN = 4;
     public static final int POSITIONWIDTHHEIGHT = 45;//50
-    public static final int LOCATIONIMAGESY = 40;//100
+    public static final int LOCATIONIMAGESY = 80;//100
 
+    private short savedCommercialStatus;
+    private short savedUpdateStatus;
+    private short savedCCStatus;
+
     /**
      * Creates a new instance of ChooserDialog
      */
@@ -101,7 +114,7 @@
                     UnoRuntime.queryInterface(XMultiServiceFactory.class, dlgLicenseSelector);
 
             XPropertySet xPSetDialog = createAWTControl(dlgLicenseSelector, "dlgMainForm",
-                    "", new Rectangle(100, 100, 240, 360));//360
+                    "", new Rectangle(100, 100, 240, 400));//360
             xPSetDialog.setPropertyValue("Title", new String("Insert Picture from Picasa"));
             xPSetDialog.setPropertyValue("Step", (short) 1);
 
@@ -121,6 +134,24 @@
                     "com.sun.star.awt.UnoControlEditModel");
             createAWTControl(txtTags, TXT_TAGS, "", new Rectangle(30, 10, 150, 12));
 
+            Object rdoCommercial = msfLicenseSelector.createInstance(
+                    "com.sun.star.awt.UnoControlRadioButtonModel");
+            XPropertySet xpsRDOProperties = createAWTControl(rdoCommercial, RDO_COMMERCIALNAME, RDO_COMMERCIALLABEL,
+                    new Rectangle(10, 32, 150, 12));
+            xpsRDOProperties.setPropertyValue("State", new Short((short) 1));
+
+            Object rdoUpdate = msfLicenseSelector.createInstance(
+                    "com.sun.star.awt.UnoControlRadioButtonModel");
+            xpsRDOProperties = createAWTControl(rdoUpdate, RDO_UPDATENAME, RDO_UPDATELABEL,
+                    new Rectangle(10, 49, 150, 12));
+            xpsRDOProperties.setPropertyValue("State", new Short((short) 0));
+
+            Object chkCC = msfLicenseSelector.createInstance(
+                    "com.sun.star.awt.UnoControlRadioButtonModel");
+            xpsRDOProperties = createAWTControl(chkCC, RDO_CCNAME, RDO_CCLABEL,
+                    new Rectangle(10, 66, 150, 12)); //(50, 66, 150, 12));
+            xpsRDOProperties.setPropertyValue("State", new Short((short) 0));
+
             Object searchButton = msfLicenseSelector.createInstance(
                     "com.sun.star.awt.UnoControlButtonModel");
             XPropertySet xPSetFinishButton = createAWTControl(searchButton,
@@ -156,7 +187,7 @@
             // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
             xPBModelMPSet.setPropertyValues(
                     new String[]{"Height", "Name", "PositionX", "PositionY", "Width"},
-                    new Object[]{new Integer(8), PB_NAME, new Integer(10), new Integer(350)/*418*/, new Integer(220)});
+                    new Object[]{new Integer(8), PB_NAME, new Integer(10), new Integer(390)/*418*/, new Integer(220)});
 
             // The controlmodel is not really available until inserted to the Dialog container
             getNameContainer().insertByName(PB_NAME, oPBar);
@@ -268,11 +299,11 @@
                 currentX += POSITIONWIDTHHEIGHT + 10;
 
                 if (currentList.size() > currentPositionInList) {
-                    createImageControl(currentList.get(currentPositionInList), 
+                    createImageControl(currentList.get(currentPositionInList),
                             new Rectangle(currentX,currentY, POSITIONWIDTHHEIGHT,
                             POSITIONWIDTHHEIGHT), String.valueOf(currentPositionInList));
                 } else {
-                    createImageControl(null, new Rectangle(currentX, currentY, 
+                    createImageControl(null, new Rectangle(currentX, currentY,
                             POSITIONWIDTHHEIGHT, POSITIONWIDTHHEIGHT),
                             String.valueOf(currentPositionInList));
                 }
@@ -294,7 +325,7 @@
                 isNewCreated = true;
             }
 
-            createAWTControl(button, BTN_NEXT, BTN_NEXTLABEL, new Rectangle(150, 330, 40, 15));//395
+            createAWTControl(button, BTN_NEXT, BTN_NEXTLABEL, new Rectangle(150, 370, 40, 15));//395
 
             if (isNewCreated) {
                 XButton xNextButton = (XButton) UnoRuntime.queryInterface(XButton.class,
@@ -314,7 +345,7 @@
                 isNewCreated = true;
             }
 
-            createAWTControl(button, BTN_PREVIOUS, BTN_PREVIOUSLABEL, new Rectangle(50, 330, 40, 15)); //395
+            createAWTControl(button, BTN_PREVIOUS, BTN_PREVIOUSLABEL, new Rectangle(50, 370, 40, 15)); //395
 
             if (isNewCreated) {
                 XButton xPrevButton = (XButton) UnoRuntime.queryInterface(XButton.class,
@@ -586,6 +617,36 @@
         }
     }
 
+        public String getLicense() {
+
+        boolean commercial = getRadioButtonStatus(RDO_COMMERCIALNAME);
+        boolean update = getRadioButtonStatus(RDO_UPDATENAME);
+        boolean cc = getRadioButtonStatus(RDO_CCNAME);
+
+        if (commercial) {
+            return "commercial";
+        } else if (update) {
+            return "remix";
+        } else if (cc) {
+            return "creative_commons";
+        }
+
+        //default atribution license
+        return "4";
+    }
+
+    public boolean getRadioButtonStatus(String ctrlName) {
+
+        Object oLicense = xControlCont.getControl(ctrlName);
+        XRadioButton radioButton = (XRadioButton) UnoRuntime.queryInterface(XRadioButton.class, oLicense);
+
+        Object value = radioButton.getState();
+        if (value != null) {
+                return (Boolean)value;
+        }
+        return false;
+    }
+
     public XNameContainer getNameContainer() {
         return xNameCont;
     }
@@ -611,6 +672,15 @@
         this.xDialog.endExecute();
     }
 
+    public boolean IsInputValid() {
+
+        if (this.GetTags().length == 0) {
+            return false;
+        }
+
+        return true;
+    }
+
     public void saveSearch() {
 
         try {
@@ -623,6 +693,24 @@
             String selTags = (String) xPSet.getPropertyValue("Text");
             this.savedTags = selTags.trim();
 
+            if (getRadioButtonStatus(RDO_COMMERCIALNAME)) {
+                savedCommercialStatus = 1;
+            } else {
+                savedCommercialStatus = 0;
+            }
+
+            if (getRadioButtonStatus(RDO_UPDATENAME)) {
+                savedUpdateStatus = 1;
+            } else {
+                savedUpdateStatus = 0;
+            }
+
+            if (getRadioButtonStatus(RDO_CCNAME)) {
+                savedCCStatus = 1;
+            } else {
+                savedCCStatus = 0;
+            }
+
         } catch (Exception ex) {
             ex.printStackTrace();
         }
@@ -643,7 +731,19 @@
                     XPropertySet.class, xControlModel);
             xPSet.setPropertyValue("Text", this.savedTags);
 
+            Object oLicense = xControlCont.getControl(RDO_COMMERCIALNAME);
+            XCheckBox checkBox = (XCheckBox) UnoRuntime.queryInterface(
+                    XCheckBox.class, oLicense);
+            checkBox.setState(savedCommercialStatus);
 
+            oLicense = xControlCont.getControl(RDO_UPDATENAME);
+            checkBox = (XCheckBox) UnoRuntime.queryInterface(XCheckBox.class, oLicense);
+            checkBox.setState(savedUpdateStatus);
+
+            oLicense = xControlCont.getControl(RDO_CCNAME);
+            checkBox = (XCheckBox) UnoRuntime.queryInterface(XCheckBox.class, oLicense);
+            checkBox.setState(savedCCStatus);
+
         } catch (Exception ex) {
             ex.printStackTrace();
         }

Modified: ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/picasa/SearchClickListener.java
===================================================================
--- ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/picasa/SearchClickListener.java	2010-07-18 16:38:41 UTC (rev 14584)
+++ ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/picasa/SearchClickListener.java	2010-07-19 11:06:05 UTC (rev 14585)
@@ -23,14 +23,18 @@
         this.picasaDialog = picasaDialog;
         this.addin = addin;
     }
-    
+
     public void actionPerformed(ActionEvent a) {
+
+        if (!picasaDialog.IsInputValid()) {
+            return;
+        }
         SearchThread th = new SearchThread(picasaDialog,a.ActionCommand);
         th.start();
-        
+
     } // actionPerformed
-    
+
     public void disposing(EventObject e) {
     }
-    
+
 }

Modified: ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/picasa/SearchThread.java
===================================================================
--- ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/picasa/SearchThread.java	2010-07-18 16:38:41 UTC (rev 14584)
+++ ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/picasa/SearchThread.java	2010-07-19 11:06:05 UTC (rev 14585)
@@ -33,11 +33,12 @@
         picasaDialog.enableControl(PicasaDialog.BTN_SEARCH, false);
         picasaDialog.saveSearch();
         picasaDialog.setProgressValue(0);
+        String licenseID = picasaDialog.getLicense();
         ArrayList<Image> imgList = null;
         if (buttonName.equalsIgnoreCase(PicasaDialog.BTN_SEARCH)) {
             //PicasaConnection p=PicasaConnection.instance;
             PicasaConnection.instance.searchPhotos(
-                    picasaDialog.GetTags(), picasaDialog.getCurrentPage());
+                    picasaDialog.GetTags(), picasaDialog.getCurrentPage(),licenseID);
             picasaDialog.setCurrentPage(1);
             imgList = new ArrayList<Image>();
             int currentPage = picasaDialog.getCurrentPage();




More information about the cc-commits mailing list