[cc-commits] [CC SVN] r14601 - in ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice: . program ui/flickr
webmaster at creativecommons.org
webmaster at creativecommons.org
Sat Jul 24 12:47:13 EDT 2010
Author: akila87
Date: 2010-07-24 16:47:13 +0000 (Sat, 24 Jul 2010)
New Revision: 14601
Added:
ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/FlickrDialog.java
ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/FlickrImageButtonListener.java
ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/FlickrSearchClickListener.java
Removed:
ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/ImageButtonListener.java
ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/PictureFlickrDialog.java
ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/SavedSearchThread.java
ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/SearchClickListener.java
Modified:
ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/CcOOoAddin.java
ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/program/FlickrConnection.java
ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/SearchThread.java
ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/SizesMenuListener.java
Log:
*Wrap up Flickr
Modified: ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/CcOOoAddin.java
===================================================================
--- ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/CcOOoAddin.java 2010-07-24 15:53:51 UTC (rev 14600)
+++ ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/CcOOoAddin.java 2010-07-24 16:47:13 UTC (rev 14601)
@@ -62,7 +62,7 @@
import org.creativecommons.openoffice.program.Impress;
import org.creativecommons.openoffice.program.Writer;
import org.creativecommons.openoffice.ui.license.ChooserDialog;
-import org.creativecommons.openoffice.ui.flickr.PictureFlickrDialog;
+import org.creativecommons.openoffice.ui.flickr.FlickrDialog;
import org.creativecommons.openoffice.ui.openclipart.OpenClipArtDialog;
import org.creativecommons.openoffice.ui.picasa.PicasaDialog;
import org.creativecommons.openoffice.ui.wikimedia.WikimediaDialog;
@@ -96,7 +96,7 @@
private XComponent xCurrentComponent = null;
protected XMultiComponentFactory xMultiComponentFactory = null;
protected XMultiComponentFactory mxRemoteServiceManager = null;
- private PictureFlickrDialog pictureFlickrDialog = null;
+ private FlickrDialog pictureFlickrDialog = null;
private OpenClipArtDialog openClipArtDialog = null;
private WikimediaDialog wikimediaDialog=null;
private PicasaDialog picasaDialog=null;
@@ -338,7 +338,7 @@
this.updateCurrentComponent();
if (pictureFlickrDialog == null) {
- pictureFlickrDialog = new PictureFlickrDialog(this, this.m_xContext);
+ pictureFlickrDialog = new FlickrDialog(this, this.m_xContext);
pictureFlickrDialog.setLoadable(true);
pictureFlickrDialog.showDialog(false);
} else {
Modified: ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/program/FlickrConnection.java
===================================================================
--- ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/program/FlickrConnection.java 2010-07-24 15:53:51 UTC (rev 14600)
+++ ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/program/FlickrConnection.java 2010-07-24 16:47:13 UTC (rev 14601)
@@ -19,7 +19,7 @@
import com.aetrion.flickr.people.PeopleInterface;
import java.io.IOException;
import java.util.Date;
-import org.creativecommons.openoffice.ui.flickr.PictureFlickrDialog;
+import org.creativecommons.openoffice.ui.flickr.FlickrDialog;
import org.xml.sax.SAXException;
/**
@@ -53,8 +53,8 @@
PhotosInterface pInterf = flickr.getPhotosInterface();
PhotoList list = null;
try {
- list = pInterf.search(currentSearch, PictureFlickrDialog.SHOWRESULTSPERROW
- * PictureFlickrDialog.SHOWRESULTSPERCOLUMN, currentPage);
+ list = pInterf.search(currentSearch, FlickrDialog.SHOWRESULTSPERROW
+ * FlickrDialog.SHOWRESULTSPERCOLUMN, currentPage);
} catch (com.aetrion.flickr.FlickrException ex) {
ex.printStackTrace();
} catch (java.io.IOException ex) {
Copied: ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/FlickrDialog.java (from rev 14578, ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/PictureFlickrDialog.java)
===================================================================
--- ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/FlickrDialog.java (rev 0)
+++ ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/FlickrDialog.java 2010-07-24 16:47:13 UTC (rev 14601)
@@ -0,0 +1,566 @@
+/*
+ * ChooserDialog.java
+ *
+ * Copyright 2007, Creative Commons
+ * licensed under the GNU LGPL License; see licenses/LICENSE for details
+ *
+ */
+package org.creativecommons.openoffice.ui.flickr;
+
+import com.aetrion.flickr.photos.licenses.License;
+import java.net.URL;
+import com.sun.star.awt.XCheckBox;
+import com.sun.star.awt.SystemPointer;
+import java.awt.Rectangle;
+import com.sun.star.awt.XButton;
+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.XPopupMenu;
+import com.sun.star.awt.XToolkit;
+import com.sun.star.awt.XWindow;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.beans.XMultiPropertySet;
+import com.sun.star.container.XNameContainer;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import java.util.ArrayList;
+import java.util.Collection;
+import com.sun.star.graphic.XGraphic;
+import org.creativecommons.openoffice.*;
+import org.creativecommons.openoffice.program.Image;
+import com.sun.star.awt.XWindowPeer;
+import java.util.Date;
+import org.creativecommons.openoffice.program.FlickrConnection;
+import org.creativecommons.openoffice.ui.InsertImageDialog;
+import org.creativecommons.openoffice.ui.SavedSearchThread;
+
+/**
+ *
+ * @author Husleag Mihai
+ */
+public class FlickrDialog extends InsertImageDialog{
+
+
+ private short savedCommercialStatus;
+ private short savedUpdateStatus;
+ private short savedShareAlikeStatus;
+ public static final String CHK_COMMERCIALNAME = "chkCommercial";
+ public static final String CHK_COMMERCIALLABEL = "Search for works I can use for commercial purposes";
+ public static final String CHK_UPDATENAME = "chkUpdate";
+ public static final String CHK_UPDATELABEL = "Search for works I can modify, adapt, or build upon";
+ public static final String CHK_SHAREALKENAME = "chkShareAlike";
+ public static final String CHK_SHAREALKELABEL = "Include content which requires me to Share-Alike";
+
+
+ /**
+ * Creates a new instance of ChooserDialog
+ */
+ public FlickrDialog(CcOOoAddin addin, XComponentContext m_xContext) {
+ super(addin, m_xContext, 45, 63, 347);
+ searchClickListener = new FlickrSearchClickListener(this, addin);
+ }
+
+ /**
+ * Method for creating a dialog at runtime
+ *
+ */
+ public void showDialog(boolean defaultSearch) throws com.sun.star.uno.Exception {
+
+ try {
+ long time = new Date().getTime();
+ // get the service manager from the component context
+ this.xMultiComponentFactory = this.m_xContext.getServiceManager();
+
+ // create the dialog model and set the properties
+ Object dlgLicenseSelector = xMultiComponentFactory.createInstanceWithContext(
+ "com.sun.star.awt.UnoControlDialogModel", m_xContext);
+ XMultiServiceFactory msfLicenseSelector = (XMultiServiceFactory)
+ UnoRuntime.queryInterface(XMultiServiceFactory.class, dlgLicenseSelector);
+
+ XPropertySet xPSetDialog = createAWTControl(dlgLicenseSelector, "dlgMainForm",
+ "", new Rectangle(DIALOGX, DIALOGY, DIALOGWIDTH, DIALOGHEIHT));//360
+ xPSetDialog.setPropertyValue("Title", new String("Insert Picture From Flickr"));
+ xPSetDialog.setPropertyValue("Step", (short) 1);
+
+ // get the name container for the dialog for inserting other elements
+ this.xNameCont = (XNameContainer) UnoRuntime.queryInterface(
+ XNameContainer.class, dlgLicenseSelector);
+
+ // get the service manager from the dialog model
+ this.xMultiServiceFactory = (XMultiServiceFactory) UnoRuntime.queryInterface(
+ XMultiServiceFactory.class, dlgLicenseSelector);
+
+ Object lblTags = msfLicenseSelector.createInstance(
+ "com.sun.star.awt.UnoControlFixedTextModel");
+ createAWTControl(lblTags, LBL_TAGS, "Tags", new Rectangle(10, 10, 50, 12));
+
+ Object txtTags = msfLicenseSelector.createInstance(
+ "com.sun.star.awt.UnoControlEditModel");
+ createAWTControl(txtTags, TXT_TAGS, "", new Rectangle(30, 10, 150, 12));
+
+ Object chkCommercial = msfLicenseSelector.createInstance(
+ "com.sun.star.awt.UnoControlCheckBoxModel");
+ XPropertySet xpsCHKProperties = createAWTControl(chkCommercial, CHK_COMMERCIALNAME, CHK_COMMERCIALLABEL,
+ new Rectangle(10, 27, 150, 12));
+
+ xpsCHKProperties.setPropertyValue("TriState", Boolean.FALSE);
+ xpsCHKProperties.setPropertyValue("State", new Short((short) 1));
+
+ Object chkUpdate = msfLicenseSelector.createInstance(
+ "com.sun.star.awt.UnoControlCheckBoxModel");
+ xpsCHKProperties = createAWTControl(chkUpdate, CHK_UPDATENAME, CHK_UPDATELABEL,
+ new Rectangle(10, 39, 150, 12));
+ xpsCHKProperties.setPropertyValue("TriState", Boolean.FALSE);
+ xpsCHKProperties.setPropertyValue("State", new Short((short) 1));
+
+ Object chkShareAlike = msfLicenseSelector.createInstance(
+ "com.sun.star.awt.UnoControlCheckBoxModel");
+ xpsCHKProperties = createAWTControl(chkShareAlike, CHK_SHAREALKENAME, CHK_SHAREALKELABEL,
+ new Rectangle(10, 51, 150, 12)); //(50, 66, 150, 12));
+ xpsCHKProperties.setPropertyValue("TriState", Boolean.FALSE);
+ xpsCHKProperties.setPropertyValue("State", new Short((short) 0));
+
+ Object searchButton = msfLicenseSelector.createInstance(
+ "com.sun.star.awt.UnoControlButtonModel");
+ XPropertySet xPSetFinishButton = createAWTControl(searchButton, BTN_SEARCH,
+ searchButtonLabel,new Rectangle(190, 10, 40, 15)); //(140, 85, 40, 15));
+ xPSetFinishButton.setPropertyValue("DefaultButton", new Boolean("true"));
+
+ // create the dialog control and set the model
+ Object dialog = xMultiComponentFactory.createInstanceWithContext(
+ "com.sun.star.awt.UnoControlDialog", m_xContext); //esse
+ xControl = (XControl) UnoRuntime.queryInterface(XControl.class, dialog);
+ XControlModel xControlModel = (XControlModel) UnoRuntime.queryInterface(
+ XControlModel.class, dlgLicenseSelector);
+ xControl.setModel(xControlModel);
+
+ xControlCont = (XControlContainer) UnoRuntime.queryInterface(
+ XControlContainer.class, dialog);
+
+ Object objSearchButton = xControlCont.getControl(BTN_SEARCH);
+ XButton xFinishButton = (XButton) UnoRuntime.queryInterface(XButton.class, objSearchButton);
+ xFinishButton.addActionListener(new FlickrSearchClickListener(this, this.addin));
+ xFinishButton.setActionCommand(BTN_SEARCH);
+
+
+ //this.flickrLicenses = FlickrConnection.instance.getLicenses(); //this method takes about 2-3 seconds
+ setLicenses(); //adding licenses locally
+
+ Object oGBResults = msfLicenseSelector.createInstance("com.sun.star.awt.UnoControlGroupBoxModel");
+ createAWTControl(oGBResults, GB_RESULTS, "Results", new Rectangle(
+ 10, locationMagesy, 220, 280));//315
+
+ Object oPBar = msfLicenseSelector.createInstance(
+ "com.sun.star.awt.UnoControlProgressBarModel");
+ XMultiPropertySet xPBModelMPSet = (XMultiPropertySet)
+ UnoRuntime.queryInterface(XMultiPropertySet.class, oPBar);
+ // 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(DIALOGHEIHT-8)/*418*/, new Integer(220)});
+
+ // The controlmodel is not really available until inserted to the Dialog container
+ getNameContainer().insertByName(PB_NAME, oPBar);
+ XPropertySet xPBModelPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oPBar);
+
+ xPBModelPSet.setPropertyValue("ProgressValueMin", new Integer(0));
+ xPBModelPSet.setPropertyValue("ProgressValueMax", new Integer(100));
+
+ // create a peer
+ Object toolkit = xMultiComponentFactory.createInstanceWithContext("com.sun.star.awt.Toolkit", m_xContext);
+ XToolkit xToolkit = (XToolkit) UnoRuntime.queryInterface(XToolkit.class, toolkit);
+ XWindow xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, xControl);
+ xWindow.setVisible(false);
+ xControl.createPeer(xToolkit, null);
+ xWindowPeer = xControl.getPeer();
+ System.out.println("Flicker Dialog Showing All " + (new Date().getTime() - time));
+ if (defaultSearch) {
+ SavedSearchThread thread = new SavedSearchThread(this);
+ thread.start();
+ }
+
+ // execute the dialog
+ this.xDialog = (XDialog) UnoRuntime.queryInterface(XDialog.class, dialog);
+ this.xDialog.execute();
+
+ // dispose the dialog
+ XComponent xComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, dialog);
+ xComponent.dispose();
+
+
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ protected void createImageControl(Image img, Rectangle rect, String pos) {
+
+ if (!isLoadable) {
+
+ return;
+ }
+ createImageLoad(rect, pos, "file://" + this.getClass().
+ getProtectionDomain().getCodeSource().
+ getLocation().getPath().
+ replaceFirst("ccooo.jar", "images/loadingFlickr.png"));
+
+ try {
+ String userName = "";
+ if (img != null) {
+ if (img.getUserName().equalsIgnoreCase("")) {
+ /**********************/
+ img.setUserName(FlickrConnection.instance.getUserName(img.getUserID())); //bottleneck2
+ /************************/
+ }
+
+ userName = "From " + img.getUserName();
+ }
+
+ XGraphic xGraphic = null;
+ if (img != null) {
+
+ if (img.getGraphic() != null) {
+ xGraphic = img.getGraphic();
+ } else {
+ xGraphic = getGraphic(img.getImgURL());
+
+ img.setGraphic(xGraphic);
+ }
+ }
+
+ Object oICModel = null;
+ if (getNameContainer().hasByName("ImageControl" + pos)) {
+ XControl xImageControl = xControlCont.getControl("ImageControl" + pos);
+ if (xImageControl != null) {
+ xImageControl.dispose();
+ }
+ getNameContainer().removeByName("ImageControl" + pos);
+ }
+
+ oICModel = xMultiServiceFactory.createInstance(
+ "com.sun.star.awt.UnoControlImageControlModel");
+ XPropertySet xpsImageControl = (XPropertySet)
+ UnoRuntime.queryInterface(XPropertySet.class, oICModel);
+
+ xpsImageControl.setPropertyValue("Border", (short) 0);
+ xpsImageControl.setPropertyValue("Height", new Integer(rect.height));
+ xpsImageControl.setPropertyValue("Name", "ImageControl" + pos);
+ xpsImageControl.setPropertyValue("PositionX", new Integer(rect.x));
+ xpsImageControl.setPropertyValue("PositionY", new Integer(rect.y));
+ xpsImageControl.setPropertyValue("Width", new Integer(rect.width));
+
+ String title = "";
+ if (img != null) {
+ title = img.getTitle();
+ } else {
+ title = "";
+ }
+
+ xpsImageControl.setPropertyValue("HelpText", title);
+
+ getNameContainer().insertByName("ImageControl" + pos, oICModel);
+
+ XControl xImageControl = xControlCont.getControl("ImageControl" + pos);
+ XWindow xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, xImageControl);
+ if (xWindow != null) {
+ xWindow.addMouseListener(new FlickrImageButtonListener(this, this.addin, img));
+ }
+
+ xpsImageControl.setPropertyValue("Graphic", xGraphic);
+
+ Object lblUser = null;
+ if (getNameContainer().hasByName("ImageLabelUser" + pos)) {
+ lblUser = getNameContainer().getByName("ImageLabelUser" + pos);
+ } else {
+ lblUser = xMultiServiceFactory.createInstance(
+ "com.sun.star.awt.UnoControlFixedHyperlinkModel");
+ }
+
+ XPropertySet xpsProperties = createAWTControl(lblUser,
+ "ImageLabelUser" + pos, userName,
+ new Rectangle(rect.x, rect.y + rect.height + 3, positionWidthHeight, 15)); //50
+ if (img != null) {
+ xpsProperties.setPropertyValue("URL", img.getProfile());
+ } else {
+ xpsProperties.setPropertyValue("URL", "");
+ }
+ xpsProperties.setPropertyValue("Label", userName);
+
+
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+
+ }
+
+ public XPopupMenu executePopupMenu(Image img, Integer positionX, Integer positionY,
+ XWindowPeer xImagePeer) {
+
+ this.selectedImage = img;
+ Collection sizes = FlickrConnection.instance.getPhotoSizes(img.getPhotoID());
+ img.setSelectedImageSizes(sizes);
+
+ XPopupMenu xPopupMenu = null;
+ try {
+ // create a popup menu
+ Object oPopupMenu = xMultiComponentFactory.createInstanceWithContext(
+ "com.sun.star.awt.PopupMenu", m_xContext);
+ xPopupMenu = (XPopupMenu) UnoRuntime.queryInterface(XPopupMenu.class, oPopupMenu);
+
+ for (Object p : sizes.toArray()) {
+ com.aetrion.flickr.photos.Size currentSize = ((com.aetrion.flickr.photos.Size) p);
+ xPopupMenu.insertItem((short) currentSize.getLabel(),
+ FlickrConnection.instance.getStringSize(currentSize.getLabel()),
+ (short) 0, (short) currentSize.getLabel());
+ }
+
+ com.sun.star.awt.Rectangle rect = new com.sun.star.awt.Rectangle();//100, 100, 260, 440);
+ rect.Height = positionWidthHeight;
+ rect.Width = positionWidthHeight + 50;
+ rect.X = positionX;
+ rect.Y = positionY - positionWidthHeight;
+
+ xPopupMenu.addMenuListener(new SizesMenuListener(this, addin));
+ xPopupMenu.execute(xImagePeer, rect, com.sun.star.awt.PopupMenuDirection.EXECUTE_DEFAULT);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return xPopupMenu;
+ }
+
+ @SuppressWarnings("unchecked")
+ private void setLicenses(){
+ flickrLicenses=new ArrayList<License>();
+ License license=new License();
+ license.setId("4");
+ license.setName("Attribution License");
+ license.setUrl("http://creativecommons.org/licenses/by/2.0/");
+ flickrLicenses.add(license);
+
+ license=new License();
+ license.setId("6");
+ license.setName("Attribution-NoDerivs License");
+ license.setUrl("http://creativecommons.org/licenses/by-nd/2.0/");
+ flickrLicenses.add(license);
+
+ license=new License();
+ license.setId("3");
+ license.setName("Attribution-NonCommercial-NoDerivs License");
+ license.setUrl("http://creativecommons.org/licenses/by-nc-nd/2.0/");
+ flickrLicenses.add(license);
+
+ license=new License();
+ license.setId("2");
+ license.setName("Attribution-NonCommercial License");
+ license.setUrl("http://creativecommons.org/licenses/by-nc/2.0/");
+ flickrLicenses.add(license);
+
+ license=new License();
+ license.setId("1");
+ license.setName("Attribution-NonCommercial-ShareAlike License");
+ license.setUrl("http://creativecommons.org/licenses/by-nc-sa/2.0/");
+ flickrLicenses.add(license);
+
+ license=new License();
+ license.setId("5");
+ license.setName("Attribution-ShareAlike License");
+ license.setUrl("http://creativecommons.org/licenses/by-sa/2.0/");
+ flickrLicenses.add(license);
+
+ license=new License();
+ license.setId("7");
+ license.setName("No known copyright restrictions");
+ license.setUrl("http://flickr.com/commons/usage/");
+ flickrLicenses.add(license);
+ }
+
+ public String getLicenseURL(String licenseID) {
+
+ for (Object p : this.flickrLicenses.toArray()) {
+ com.aetrion.flickr.photos.licenses.License currentLicense = (
+ (com.aetrion.flickr.photos.licenses.License) p);
+ if ((currentLicense != null)
+ && (currentLicense.getId().equalsIgnoreCase(licenseID))) {
+ return currentLicense.getUrl();
+ }
+ }
+ return "";
+ }
+
+ public String getLicenseNumber(String licenseURL) {
+
+ String licenseNumber = "";
+ if (!licenseURL.equalsIgnoreCase("")) {
+
+ if (licenseURL.endsWith("/")) {
+ licenseURL = licenseURL.substring(0, licenseURL.length() - 1);
+ }
+ licenseNumber = licenseURL.substring(licenseURL.lastIndexOf("/") + 1);
+ }
+
+ return licenseNumber;
+ }
+
+ public String getLicenseCode(String licenseURL) {
+
+ String licenseNumber = "";
+ if (!licenseURL.equalsIgnoreCase("")) {
+ try {
+ URL licenseUrl = new URL(licenseURL);
+ String[] pieces = licenseUrl.getPath().split("/");
+ if (pieces.length > 2) {
+ return pieces[2];
+ }
+
+ } catch (java.net.MalformedURLException ex) {
+ ex.printStackTrace();
+ }
+ return null;
+ }
+
+ return licenseNumber;
+ }
+
+ public String getLicense() {
+
+ boolean commercial = getCheckBoxStatus(CHK_COMMERCIALNAME);
+ boolean update = getCheckBoxStatus(CHK_UPDATENAME);
+ boolean shareAlike = getCheckBoxStatus(CHK_SHAREALKENAME);
+
+ if (commercial && update && shareAlike) {
+ return "4,5";
+ } else if (commercial && update) {
+ return "4";
+ } else if (update && shareAlike) {
+ return "1,2,4,5";
+ } else if (commercial) {
+ return "4,5,6";
+ } else if (update) {
+ return "2,4";
+ }
+
+ //default atribution license
+ return "4";
+ }
+
+ public boolean getCheckBoxStatus(String ctrlName) {
+
+ Object oLicense = xControlCont.getControl(ctrlName);
+ XCheckBox checkBox = (XCheckBox) UnoRuntime.queryInterface(XCheckBox.class, oLicense);
+
+ Object value = checkBox.getState();
+ if (value != null) {
+
+ short chkStatus = new Short(value.toString());
+ if (chkStatus == 1) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean IsInputValid() {
+
+ if (this.GetTags().length == 0) {
+ return false;
+ }
+
+ boolean commercial = getCheckBoxStatus(CHK_COMMERCIALNAME);
+ boolean update = getCheckBoxStatus(CHK_UPDATENAME);
+ boolean shareAlike = getCheckBoxStatus(CHK_SHAREALKENAME);
+
+ if (!commercial && !update && !shareAlike) {
+ return false;
+ }
+
+ if (commercial && !update && shareAlike) {
+ return false;
+ }
+
+ if (!commercial && !update && shareAlike) {
+ return false;
+ }
+
+ return true;
+ }
+
+ public void saveSearch() {
+
+ try {
+
+ Object oTags = xControlCont.getControl(TXT_TAGS);
+ XControl txtTags = (XControl) UnoRuntime.queryInterface(XControl.class, oTags);
+ XControlModel xControlModel = txtTags.getModel();
+ XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class, xControlModel);
+ String selTags = (String) xPSet.getPropertyValue("Text");
+ this.savedTags = selTags.trim();
+
+ if (getCheckBoxStatus(CHK_COMMERCIALNAME)) {
+ savedCommercialStatus = 1;
+ } else {
+ savedCommercialStatus = 0;
+ }
+
+ if (getCheckBoxStatus(CHK_UPDATENAME)) {
+ savedUpdateStatus = 1;
+ } else {
+ savedUpdateStatus = 0;
+ }
+
+ if (getCheckBoxStatus(CHK_SHAREALKENAME)) {
+ savedShareAlikeStatus = 1;
+ } else {
+ savedShareAlikeStatus = 0;
+ }
+
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ public void startSavedSearch() {
+
+ setMousePointer(SystemPointer.WAIT);
+ enableControl(FlickrDialog.BTN_SEARCH, false);
+ enableControl(FlickrDialog.BTN_NEXT, false);
+ currentPositionInList = 0;
+
+ try {
+ Object oTags = xControlCont.getControl(TXT_TAGS);
+ XControl txtTags = (XControl) UnoRuntime.queryInterface(XControl.class, oTags);
+ XControlModel xControlModel = txtTags.getModel();
+ XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class, xControlModel);
+ xPSet.setPropertyValue("Text", this.savedTags);
+
+ Object oLicense = xControlCont.getControl(CHK_COMMERCIALNAME);
+ XCheckBox checkBox = (XCheckBox) UnoRuntime.queryInterface(
+ XCheckBox.class, oLicense);
+ checkBox.setState(savedCommercialStatus);
+
+ oLicense = xControlCont.getControl(CHK_UPDATENAME);
+ checkBox = (XCheckBox) UnoRuntime.queryInterface(XCheckBox.class, oLicense);
+ checkBox.setState(savedUpdateStatus);
+
+ oLicense = xControlCont.getControl(CHK_SHAREALKENAME);
+ checkBox = (XCheckBox) UnoRuntime.queryInterface(XCheckBox.class, oLicense);
+ checkBox.setState(savedShareAlikeStatus);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+
+ showResults(currentList, 0);
+ setProgressValue(100);
+ enableControl(FlickrDialog.BTN_SEARCH, true);
+ // enableControl(FlickrDialog.BTN_NEXT, true);
+ setMousePointer(SystemPointer.ARROW);
+ }
+
+} // FlickrDialog
\ No newline at end of file
Copied: ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/FlickrImageButtonListener.java (from rev 14578, ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/ImageButtonListener.java)
===================================================================
--- ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/FlickrImageButtonListener.java (rev 0)
+++ ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/FlickrImageButtonListener.java 2010-07-24 16:47:13 UTC (rev 14601)
@@ -0,0 +1,60 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.creativecommons.openoffice.ui.flickr;
+
+import java.util.Collection;
+import com.sun.star.awt.MouseEvent;
+import com.sun.star.awt.XControl;
+import com.sun.star.awt.XControlModel;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.uno.UnoRuntime;
+import org.creativecommons.openoffice.CcOOoAddin;
+import org.creativecommons.openoffice.program.Image;
+import org.creativecommons.openoffice.program.FlickrConnection;
+import com.sun.star.awt.MouseButton;
+import org.creativecommons.openoffice.ui.ImageButtonListener;
+
+/**
+ *
+ * @author Husleag Mihai
+ */
+public class FlickrImageButtonListener extends ImageButtonListener {
+
+ public FlickrImageButtonListener(FlickrDialog flickrDialog, CcOOoAddin addin, Image img) {
+
+ super(flickrDialog, addin, img);
+ }
+
+ @Override
+ protected void mousePressedRun(MouseEvent _mouseEvent) {
+ //we have to add also the position of the image control within the main dialog
+ XControl xControl = (XControl) UnoRuntime.queryInterface(XControl.class, _mouseEvent.Source);
+ XControlModel xControlModel = xControl.getModel();
+ XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class, xControlModel);
+
+ if (_mouseEvent.Buttons == MouseButton.RIGHT) {
+
+ // XWindowPeer xImagePeer = (XWindowPeer) UnoRuntime.queryInterface(XControl.class, xControl);
+ imageDialog.executePopupMenu(this.currentImage, _mouseEvent.X,
+ _mouseEvent.Y, xControl.getPeer());
+ } else if (_mouseEvent.Buttons == MouseButton.LEFT && _mouseEvent.ClickCount == 2) {
+ imageDialog.close();
+ imageDialog.setSelectedImage(currentImage);
+ Collection sizes = FlickrConnection.instance.getPhotoSizes(currentImage.getPhotoID());
+ currentImage.setSelectedImageSizes(sizes);
+ imageDialog.getSelectedImage().RefreshSelectedSizeImageData(
+ (short) com.aetrion.flickr.photos.Size.MEDIUM);
+ com.aetrion.flickr.photos.Photo ph =
+ FlickrConnection.instance.getPhotoInfo(currentImage.getPhotoID(),
+ currentImage.getSecret());
+ currentImage.setLicenseID(ph.getLicense());
+ currentImage.setLicenseURL(((FlickrDialog) imageDialog).getLicenseURL(ph.getLicense()));
+ currentImage.setLicenseNumber(((FlickrDialog) imageDialog).getLicenseNumber(currentImage.getLicenseURL()));
+ currentImage.setLicenseCode(((FlickrDialog) imageDialog).getLicenseCode(currentImage.getLicenseURL()));
+ addin.getProgramWrapper().insertPicture(imageDialog.getSelectedImage());
+ }
+ }
+}
Copied: ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/FlickrSearchClickListener.java (from rev 14578, ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/SearchClickListener.java)
===================================================================
--- ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/FlickrSearchClickListener.java (rev 0)
+++ ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/FlickrSearchClickListener.java 2010-07-24 16:47:13 UTC (rev 14601)
@@ -0,0 +1,41 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.creativecommons.openoffice.ui.flickr;
+
+import com.sun.star.awt.ActionEvent;
+import com.sun.star.awt.XActionListener;
+import com.sun.star.lang.EventObject;
+import org.creativecommons.openoffice.CcOOoAddin;
+import org.creativecommons.openoffice.program.FlickrConnection;
+import org.creativecommons.openoffice.ui.SearchClickListener;
+
+/**
+ *
+ * @author Husleag Mihai
+ */
+public class FlickrSearchClickListener extends SearchClickListener{
+
+ public FlickrSearchClickListener(FlickrDialog flickrDialog, CcOOoAddin addin){
+
+ super( flickrDialog,addin);
+ }
+
+ public void actionPerformed(ActionEvent a) {
+
+ if (!imageDialog.IsInputValid()) {
+
+ return;
+ }
+
+ SearchThread th = new SearchThread((FlickrDialog) imageDialog,a.ActionCommand);
+ th.start();
+
+ } // actionPerformed
+
+ public void disposing(EventObject e) {
+ }
+
+}
Deleted: ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/ImageButtonListener.java
===================================================================
--- ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/ImageButtonListener.java 2010-07-24 15:53:51 UTC (rev 14600)
+++ ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/ImageButtonListener.java 2010-07-24 16:47:13 UTC (rev 14601)
@@ -1,92 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package org.creativecommons.openoffice.ui.flickr;
-
-import java.util.Collection;
-import com.sun.star.awt.MouseEvent;
-import com.sun.star.awt.FocusEvent;
-import com.sun.star.awt.ActionEvent;
-import com.sun.star.awt.XControl;
-import com.sun.star.awt.XControlModel;
-import com.sun.star.beans.XPropertySet;
-import com.sun.star.lang.EventObject;
-import com.sun.star.uno.UnoRuntime;
-import org.creativecommons.openoffice.CcOOoAddin;
-import org.creativecommons.openoffice.program.Image;
-import org.creativecommons.openoffice.program.FlickrConnection;
-import com.sun.star.awt.XMouseListener;
-import com.sun.star.awt.MouseButton;
-import com.sun.star.awt.XWindowPeer;
-
-/**
- *
- * @author Husleag Mihai
- */
-public class ImageButtonListener implements XMouseListener {
-
- private PictureFlickrDialog flickrDialog;
- private CcOOoAddin addin;
- private Image currentImage;
-
- public ImageButtonListener(PictureFlickrDialog flickrDialog, CcOOoAddin addin, Image img) {
-
- this.flickrDialog = flickrDialog;
- this.addin = addin;
- this.currentImage = img;
- }
-
- public void focusGained(FocusEvent focusEvent) {
- }
-
- public void mouseReleased(MouseEvent mouseEvent) {
- }
-
- public void mousePressed(MouseEvent _mouseEvent) {
-
- if ((_mouseEvent.Buttons == MouseButton.RIGHT && !_mouseEvent.PopupTrigger)
- || (_mouseEvent.Buttons == MouseButton.LEFT && !_mouseEvent.PopupTrigger)) {
-
- //we have to add also the position of the image control within the main dialog
- XControl xControl = (XControl) UnoRuntime.queryInterface(XControl.class, _mouseEvent.Source);
- XControlModel xControlModel = xControl.getModel();
- XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(
- XPropertySet.class, xControlModel);
-
- if (_mouseEvent.Buttons == MouseButton.RIGHT) {
-
- // XWindowPeer xImagePeer = (XWindowPeer) UnoRuntime.queryInterface(XControl.class, xControl);
- flickrDialog.executePopupMenu(this.currentImage, _mouseEvent.X,
- _mouseEvent.Y, xControl.getPeer());
- } else if (_mouseEvent.Buttons == MouseButton.LEFT && _mouseEvent.ClickCount == 2) {
- flickrDialog.close();
- flickrDialog.setSelectedImage(currentImage);
- Collection sizes = FlickrConnection.instance.getPhotoSizes(currentImage.getPhotoID());
- currentImage.setSelectedImageSizes(sizes);
- flickrDialog.getSelectedImage().RefreshSelectedSizeImageData(
- (short) com.aetrion.flickr.photos.Size.MEDIUM);
- com.aetrion.flickr.photos.Photo ph =
- FlickrConnection.instance.getPhotoInfo(currentImage.getPhotoID(),
- currentImage.getSecret());
- currentImage.setLicenseID(ph.getLicense());
- currentImage.setLicenseURL(flickrDialog.getLicenseURL(ph.getLicense()));
- currentImage.setLicenseNumber(flickrDialog.getLicenseNumber(currentImage.getLicenseURL()));
- currentImage.setLicenseCode(flickrDialog.getLicenseCode(currentImage.getLicenseURL()));
- addin.getProgramWrapper().insertPicture(flickrDialog.getSelectedImage());
- }
- }
- }
-
- public void mouseExited(MouseEvent mouseEvent) {
- }
-
- public void mouseEntered(MouseEvent _mouseEvent) {
- }
-
- public void actionPerformed(ActionEvent a) {
- }
-
- public void disposing(EventObject e) {
- }
-}
Deleted: ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/PictureFlickrDialog.java
===================================================================
--- ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/PictureFlickrDialog.java 2010-07-24 15:53:51 UTC (rev 14600)
+++ ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/PictureFlickrDialog.java 2010-07-24 16:47:13 UTC (rev 14601)
@@ -1,931 +0,0 @@
-/*
- * ChooserDialog.java
- *
- * Copyright 2007, Creative Commons
- * licensed under the GNU LGPL License; see licenses/LICENSE for details
- *
- */
-package org.creativecommons.openoffice.ui.flickr;
-
-import com.aetrion.flickr.photos.licenses.License;
-import java.net.URL;
-import com.sun.star.awt.XCheckBox;
-import com.sun.star.awt.SystemPointer;
-import java.awt.Rectangle;
-import com.sun.star.awt.XButton;
-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.XPopupMenu;
-import com.sun.star.awt.XToolkit;
-import com.sun.star.awt.XWindow;
-import com.sun.star.beans.XPropertySet;
-import com.sun.star.beans.XMultiPropertySet;
-import com.sun.star.container.XNameContainer;
-import com.sun.star.lang.XComponent;
-import com.sun.star.lang.XMultiComponentFactory;
-import com.sun.star.lang.XMultiServiceFactory;
-import com.sun.star.uno.UnoRuntime;
-import com.sun.star.uno.XComponentContext;
-import java.util.ArrayList;
-import java.util.Collection;
-import com.sun.star.graphic.XGraphic;
-import org.creativecommons.openoffice.*;
-import org.creativecommons.openoffice.program.Image;
-import com.sun.star.awt.XWindowPeer;
-import com.sun.star.graphic.XGraphicProvider;
-import com.sun.star.beans.PropertyValue;
-import java.util.Date;
-import org.creativecommons.openoffice.program.FlickrConnection;
-
-/**
- *
- * @author Husleag Mihai
- */
-public class PictureFlickrDialog {
-
- private XMultiServiceFactory xMultiServiceFactory = null;
- protected XComponentContext m_xContext = null;
- protected XMultiComponentFactory xMultiComponentFactory = null;
- private XNameContainer xNameCont = null;
- private XControlContainer xControlCont = null;
- private XDialog xDialog = null;
- private XControl xControl;
- private XWindowPeer xWindowPeer;
- private CcOOoAddin addin = null;
- private int currentPositionInList = 0;
- public ArrayList<Image> currentList = null;
- private Image selectedImage = null;
- private Collection flickrLicenses = null;
- private String savedTags;
- private short savedCommercialStatus;
- private short savedUpdateStatus;
- private short savedShareAlikeStatus;
- private int currentPage = 0;
- private boolean isLoadable = false;
- private Image loadingImage = null;
- public static final String LBL_TAGS = "lblTags";
- public static final String TXT_TAGS = "txtTags";
- public static final String CHK_COMMERCIALNAME = "chkCommercial";
- public static final String CHK_COMMERCIALLABEL = "Search for works I can use for commercial purposes";
- public static final String CHK_UPDATENAME = "chkUpdate";
- public static final String CHK_UPDATELABEL = "Search for works I can modify, adapt, or build upon";
- public static final String CHK_SHAREALKENAME = "chkShareAlike";
- public static final String CHK_SHAREALKELABEL = "Include content which requires me to Share-Alike";
- //public static final String LBL_LICENSE = "lblLicense";
- //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";
- public static final String BTN_NEXT = "btnNext";
- public static final String BTN_NEXTLABEL = "Next";
- public static final String BTN_PREVIOUS = "btnPrevious";
- public static final String BTN_PREVIOUSLABEL = "Previous";
- public static final String PB_NAME = "progressBar";
- public static final int SHOWRESULTSPERROW = 4;
- public static final int SHOWRESULTSPERCOLUMN = 4;
- public static final int POSITIONWIDTHHEIGHT = 45;//50
- public static final int LOCATIONIMAGESY = 80;//100
-
- /**
- * Creates a new instance of ChooserDialog
- */
- public PictureFlickrDialog(CcOOoAddin addin, XComponentContext m_xContext) {
- this.addin = addin;
- this.m_xContext = m_xContext;
- this.loadingImage = new Image("Loading...", null, null, null, null, null,
- null, null, null, null);
- }
-
- /**
- * Method for creating a dialog at runtime
- *
- */
- public void showDialog(boolean defaultSearch) throws com.sun.star.uno.Exception {
-
- try {
- long time = new Date().getTime();
- // get the service manager from the component context
- this.xMultiComponentFactory = this.m_xContext.getServiceManager();
-
- // create the dialog model and set the properties
- Object dlgLicenseSelector = xMultiComponentFactory.createInstanceWithContext(
- "com.sun.star.awt.UnoControlDialogModel", m_xContext);
- XMultiServiceFactory msfLicenseSelector = (XMultiServiceFactory)
- UnoRuntime.queryInterface(XMultiServiceFactory.class, dlgLicenseSelector);
-
- XPropertySet xPSetDialog = createAWTControl(dlgLicenseSelector, "dlgMainForm",
- "", new Rectangle(100, 100, 240, 400));//360
- xPSetDialog.setPropertyValue("Title", new String("Insert Picture From Flickr"));
- xPSetDialog.setPropertyValue("Step", (short) 1);
-
- // get the name container for the dialog for inserting other elements
- this.xNameCont = (XNameContainer) UnoRuntime.queryInterface(
- XNameContainer.class, dlgLicenseSelector);
-
- // get the service manager from the dialog model
- this.xMultiServiceFactory = (XMultiServiceFactory) UnoRuntime.queryInterface(
- XMultiServiceFactory.class, dlgLicenseSelector);
-
- Object lblTags = msfLicenseSelector.createInstance(
- "com.sun.star.awt.UnoControlFixedTextModel");
- createAWTControl(lblTags, LBL_TAGS, "Tags", new Rectangle(10, 10, 50, 12));
-
- Object txtTags = msfLicenseSelector.createInstance(
- "com.sun.star.awt.UnoControlEditModel");
- createAWTControl(txtTags, TXT_TAGS, "", new Rectangle(30, 10, 150, 12));
-
- Object chkCommercial = msfLicenseSelector.createInstance(
- "com.sun.star.awt.UnoControlCheckBoxModel");
- XPropertySet xpsCHKProperties = createAWTControl(chkCommercial, CHK_COMMERCIALNAME, CHK_COMMERCIALLABEL,
- new Rectangle(10, 32, 150, 12));
-
- xpsCHKProperties.setPropertyValue("TriState", Boolean.FALSE);
- xpsCHKProperties.setPropertyValue("State", new Short((short) 1));
-
- Object chkUpdate = msfLicenseSelector.createInstance(
- "com.sun.star.awt.UnoControlCheckBoxModel");
- xpsCHKProperties = createAWTControl(chkUpdate, CHK_UPDATENAME, CHK_UPDATELABEL,
- new Rectangle(10, 49, 150, 12));
- xpsCHKProperties.setPropertyValue("TriState", Boolean.FALSE);
- xpsCHKProperties.setPropertyValue("State", new Short((short) 1));
-
- Object chkShareAlike = msfLicenseSelector.createInstance(
- "com.sun.star.awt.UnoControlCheckBoxModel");
- xpsCHKProperties = createAWTControl(chkShareAlike, CHK_SHAREALKENAME, CHK_SHAREALKELABEL,
- new Rectangle(10, 66, 150, 12)); //(50, 66, 150, 12));
- xpsCHKProperties.setPropertyValue("TriState", Boolean.FALSE);
- xpsCHKProperties.setPropertyValue("State", new Short((short) 0));
-
- Object searchButton = msfLicenseSelector.createInstance(
- "com.sun.star.awt.UnoControlButtonModel");
- XPropertySet xPSetFinishButton = createAWTControl(searchButton, BTN_SEARCH,
- searchButtonLabel,new Rectangle(170, 45, 40, 15)); //(140, 85, 40, 15));
- xPSetFinishButton.setPropertyValue("DefaultButton", new Boolean("true"));
-
- // create the dialog control and set the model
- Object dialog = xMultiComponentFactory.createInstanceWithContext(
- "com.sun.star.awt.UnoControlDialog", m_xContext); //esse
- xControl = (XControl) UnoRuntime.queryInterface(XControl.class, dialog);
- XControlModel xControlModel = (XControlModel) UnoRuntime.queryInterface(
- XControlModel.class, dlgLicenseSelector);
- xControl.setModel(xControlModel);
-
- xControlCont = (XControlContainer) UnoRuntime.queryInterface(
- XControlContainer.class, dialog);
-
- Object objSearchButton = xControlCont.getControl(BTN_SEARCH);
- XButton xFinishButton = (XButton) UnoRuntime.queryInterface(XButton.class, objSearchButton);
- xFinishButton.addActionListener(new SearchClickListener(this, this.addin));
- xFinishButton.setActionCommand(BTN_SEARCH);
-
-
- //this.flickrLicenses = FlickrConnection.instance.getLicenses(); //this method takes about 2-3 seconds
- setLicenses(); //adding licenses locally
-
- Object oGBResults = msfLicenseSelector.createInstance("com.sun.star.awt.UnoControlGroupBoxModel");
- createAWTControl(oGBResults, GB_RESULTS, "Results", new Rectangle(
- 10, LOCATIONIMAGESY, 220, 280));//315
-
- Object oPBar = msfLicenseSelector.createInstance(
- "com.sun.star.awt.UnoControlProgressBarModel");
- XMultiPropertySet xPBModelMPSet = (XMultiPropertySet)
- UnoRuntime.queryInterface(XMultiPropertySet.class, oPBar);
- // 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(390)/*418*/, new Integer(220)});
-
- // The controlmodel is not really available until inserted to the Dialog container
- getNameContainer().insertByName(PB_NAME, oPBar);
- XPropertySet xPBModelPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oPBar);
-
- xPBModelPSet.setPropertyValue("ProgressValueMin", new Integer(0));
- xPBModelPSet.setPropertyValue("ProgressValueMax", new Integer(100));
-
- // create a peer
- Object toolkit = xMultiComponentFactory.createInstanceWithContext("com.sun.star.awt.Toolkit", m_xContext);
- XToolkit xToolkit = (XToolkit) UnoRuntime.queryInterface(XToolkit.class, toolkit);
- XWindow xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, xControl);
- xWindow.setVisible(false);
- xControl.createPeer(xToolkit, null);
- xWindowPeer = xControl.getPeer();
- System.out.println("Flicker Dialog Showing All " + (new Date().getTime() - time));
- if (defaultSearch) {
- SavedSearchThread thread = new SavedSearchThread(this);
- thread.start();
- }
-
- // execute the dialog
- this.xDialog = (XDialog) UnoRuntime.queryInterface(XDialog.class, dialog);
- this.xDialog.execute();
-
- // dispose the dialog
- XComponent xComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, dialog);
- xComponent.dispose();
-
-
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
-
- private XPropertySet createAWTControl(Object objControl, String ctrlName,
- String ctrlCaption, Rectangle posSize) throws Exception {
-
- XPropertySet xpsProperties = (XPropertySet) UnoRuntime.queryInterface(
- XPropertySet.class, objControl);
-
- xpsProperties.setPropertyValue("PositionX", new Integer(posSize.x));
- xpsProperties.setPropertyValue("PositionY", new Integer(posSize.y));
- xpsProperties.setPropertyValue("Width", new Integer(posSize.width));
- xpsProperties.setPropertyValue("Height", new Integer(posSize.height));
- xpsProperties.setPropertyValue("Name", ctrlName);
- if (ctrlCaption != "") {
- xpsProperties.setPropertyValue("Label", ctrlCaption);
- }
-
- if ((getNameContainer() != null) && (!getNameContainer().hasByName(ctrlName))) {
- getNameContainer().insertByName(ctrlName, objControl);
- }
-
- return xpsProperties;
- }
-
- public String[] GetTags() {
- Object oTags = xControlCont.getControl(TXT_TAGS);
- XControl txtTags = (XControl) UnoRuntime.queryInterface(XControl.class, oTags);
- XControlModel xControlModel = txtTags.getModel();
- XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xControlModel);
-
- try {
-
- String selTags = (String) xPSet.getPropertyValue("Text");
- if (selTags.trim().equalsIgnoreCase("")) {
- return new String[0];
- }
-
- return selTags.split(" ");
-
- } catch (Exception ex) {
- ex.printStackTrace();
- }
-
- return new String[0];
- }
-
- public void showResults(ArrayList<Image> imgList, int progressValue) {
-
- this.currentList = imgList;
- this.currentPositionInList = 0;
- showNextPage(progressValue);
- }
-
- private void showNextPage(int progressValue) {
- if (currentList == null) {
- return;
- }
-
- enableControl(BTN_PREVIOUS, false);
-
- double rateProgress = (double) (95 - progressValue) / currentList.size();
- double currentProgress = progressValue;
- int currentY = LOCATIONIMAGESY - POSITIONWIDTHHEIGHT - 5;
- int currentX = 15 - POSITIONWIDTHHEIGHT - 10;
-
- for (int i = 0; i < SHOWRESULTSPERROW; i++) {
-
- currentY += POSITIONWIDTHHEIGHT + 20;
- currentX = 15 - POSITIONWIDTHHEIGHT - 10;
-
- for (int j = 0; j < SHOWRESULTSPERCOLUMN; j++) {
-
- currentX += POSITIONWIDTHHEIGHT + 10;
-
- if (currentList.size() > currentPositionInList) {
- createImageControl(currentList.get(currentPositionInList),
- new Rectangle(currentX,currentY, POSITIONWIDTHHEIGHT, POSITIONWIDTHHEIGHT),
- String.valueOf(currentPositionInList));
- } else {
- createImageControl(null, new Rectangle(currentX, currentY, POSITIONWIDTHHEIGHT,
- POSITIONWIDTHHEIGHT), String.valueOf(currentPositionInList));
- }
-
- currentPositionInList++;
- currentProgress += rateProgress;
- this.setProgressValue((int) currentProgress);
- }
- }
-
- try {
- Object button = null;
- boolean isNewCreated = false;
- if (getNameContainer().hasByName(BTN_NEXT)) {
- button = getNameContainer().getByName(BTN_NEXT);
- } else {
- button = xMultiServiceFactory.createInstance(
- "com.sun.star.awt.UnoControlButtonModel");
- isNewCreated = true;
- }
-
- createAWTControl(button, BTN_NEXT, BTN_NEXTLABEL, new Rectangle(150, 370, 40, 15));//395
-
- if (isNewCreated) {
- XButton xNextButton = (XButton) UnoRuntime.queryInterface(XButton.class,
- xControlCont.getControl(BTN_NEXT));
- if (xNextButton != null) {
- xNextButton.addActionListener(new SearchClickListener(this, this.addin));
- xNextButton.setActionCommand(BTN_NEXT);
- }
- }
-
- isNewCreated = false;
- if (getNameContainer().hasByName(BTN_PREVIOUS)) {
- button = getNameContainer().getByName(BTN_PREVIOUS);
- } else {
- button = xMultiServiceFactory.createInstance(
- "com.sun.star.awt.UnoControlButtonModel");
- isNewCreated = true;
- }
-
- createAWTControl(button, BTN_PREVIOUS, BTN_PREVIOUSLABEL, new Rectangle(50, 370, 40, 15)); //395
-
- if (isNewCreated) {
- XButton xPrevButton = (XButton) UnoRuntime.queryInterface(XButton.class,
- xControlCont.getControl(BTN_PREVIOUS));
- if (xPrevButton != null) {
- xPrevButton.addActionListener(new SearchClickListener(this, this.addin));
- xPrevButton.setActionCommand(BTN_PREVIOUS);
- }
- }
-
- if (currentPage <= 1) {
- enableControl(BTN_PREVIOUS, false);
- } else {
- enableControl(BTN_PREVIOUS, true);
- }
-
- if (currentList.size() < SHOWRESULTSPERROW * SHOWRESULTSPERCOLUMN) {
- enableControl(BTN_NEXT, false);
- } else {
- enableControl(BTN_NEXT, true);
- }
-
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
-
- private void createImageControl(Image img, Rectangle rect, String pos) {
-
- if (!isLoadable) {
-
- return;
- }
- createImageLoad(rect,pos);
-
- try {
- String userName = "";
- if (img != null) {
- if (img.getUserName().equalsIgnoreCase("")) {
- /**********************/
- img.setUserName(FlickrConnection.instance.getUserName(img.getUserID())); //bottleneck2
- /************************/
- }
-
- userName = "From " + img.getUserName();
- }
-
- XGraphic xGraphic = null;
- if (img != null) {
-
- if (img.getGraphic() != null) {
- xGraphic = img.getGraphic();
- } else {
- xGraphic = getGraphic(img.getImgURL());
-
- img.setGraphic(xGraphic);
- }
- }
-
- Object oICModel = null;
- if (getNameContainer().hasByName("ImageControl" + pos)) {
- XControl xImageControl = xControlCont.getControl("ImageControl" + pos);
- if (xImageControl != null) {
- xImageControl.dispose();
- }
- getNameContainer().removeByName("ImageControl" + pos);
- }
-
- oICModel = xMultiServiceFactory.createInstance(
- "com.sun.star.awt.UnoControlImageControlModel");
- XPropertySet xpsImageControl = (XPropertySet)
- UnoRuntime.queryInterface(XPropertySet.class, oICModel);
-
- xpsImageControl.setPropertyValue("Border", (short) 0);
- xpsImageControl.setPropertyValue("Height", new Integer(rect.height));
- xpsImageControl.setPropertyValue("Name", "ImageControl" + pos);
- xpsImageControl.setPropertyValue("PositionX", new Integer(rect.x));
- xpsImageControl.setPropertyValue("PositionY", new Integer(rect.y));
- xpsImageControl.setPropertyValue("Width", new Integer(rect.width));
-
- String title = "";
- if (img != null) {
- title = img.getTitle();
- } else {
- title = "";
- }
-
- xpsImageControl.setPropertyValue("HelpText", title);
-
- getNameContainer().insertByName("ImageControl" + pos, oICModel);
-
- XControl xImageControl = xControlCont.getControl("ImageControl" + pos);
- XWindow xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, xImageControl);
- if (xWindow != null) {
- xWindow.addMouseListener(new ImageButtonListener(this, this.addin, img));
- }
-
- xpsImageControl.setPropertyValue("Graphic", xGraphic);
-
- Object lblUser = null;
- if (getNameContainer().hasByName("ImageLabelUser" + pos)) {
- lblUser = getNameContainer().getByName("ImageLabelUser" + pos);
- } else {
- lblUser = xMultiServiceFactory.createInstance(
- "com.sun.star.awt.UnoControlFixedHyperlinkModel");
- }
-
- XPropertySet xpsProperties = createAWTControl(lblUser,
- "ImageLabelUser" + pos, userName,
- new Rectangle(rect.x, rect.y + rect.height + 3, POSITIONWIDTHHEIGHT, 15)); //50
- if (img != null) {
- xpsProperties.setPropertyValue("URL", img.getProfile());
- } else {
- xpsProperties.setPropertyValue("URL", "");
- }
- xpsProperties.setPropertyValue("Label", userName);
-
-
- } catch (Exception ex) {
- ex.printStackTrace();
- }
-
- }
-
- private void createImageLoad(Rectangle rect, String pos) {
-
- if (!isLoadable) {
-
- return;
- }
-
- try {
- Object oICModel = null;
- if (getNameContainer().hasByName("ImageControl" + pos)) {
- XControl xImageControl = xControlCont.getControl("ImageControl" + pos);
- if (xImageControl != null) {
- xImageControl.dispose();
- }
- getNameContainer().removeByName("ImageControl" + pos);
- }
-
- oICModel = xMultiServiceFactory.createInstance(
- "com.sun.star.awt.UnoControlImageControlModel");
-
- XGraphic xGraphic = null;
-
- if (loadingImage.getGraphic() != null) {
- xGraphic = loadingImage.getGraphic();
- } else {
- xGraphic = getGraphic("file://"+this.getClass().
- getProtectionDomain().getCodeSource().
- getLocation().getPath().
- replaceFirst("ccooo.jar", "images/loadingFlickr.png"));
- loadingImage.setGraphic(xGraphic);
- }
-
- XPropertySet xpsImageControl = (XPropertySet)
- UnoRuntime.queryInterface(XPropertySet.class, oICModel);
-
- xpsImageControl.setPropertyValue("Border", (short) 0);
- xpsImageControl.setPropertyValue("Height", new Integer(rect.height));
- xpsImageControl.setPropertyValue("Name", "ImageControl" + pos);
- xpsImageControl.setPropertyValue("PositionX", new Integer(rect.x));
- xpsImageControl.setPropertyValue("PositionY", new Integer(rect.y));
- xpsImageControl.setPropertyValue("Width", new Integer(rect.width));
-
- String title = "Loading...";
-
- xpsImageControl.setPropertyValue("HelpText", title);
-
- getNameContainer().insertByName("ImageControl" + pos, oICModel);
-
- xpsImageControl.setPropertyValue("Graphic", xGraphic);
-
- Object lblUser = null;
- if (getNameContainer().hasByName("ImageLabelUser" + pos)) {
- lblUser = getNameContainer().getByName("ImageLabelUser" + pos);
- } else {
- lblUser = xMultiServiceFactory.createInstance(
- "com.sun.star.awt.UnoControlFixedHyperlinkModel");
- }
-
- String userName = "";
-
- XPropertySet xpsProperties = createAWTControl(lblUser, "ImageLabelUser" + pos, userName,
- new Rectangle(rect.x, rect.y + rect.height + 3, POSITIONWIDTHHEIGHT, 15)); //50
- xpsProperties.setPropertyValue("Label", userName);
-
- } catch (Exception ex) {
- ex.printStackTrace();
- }
-
- }
-
- public void enableControl(String controlName, boolean enable) {
- try {
- if (getNameContainer().hasByName(controlName)) {
- Object oControl = getNameContainer().getByName(controlName);
- XPropertySet xModelPSet = (XPropertySet)
- UnoRuntime.queryInterface(XPropertySet.class, oControl);
-
- xModelPSet.setPropertyValue("Enabled", enable);
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
-
- public void setProgressValue(int step) {
-
- if (!getNameContainer().hasByName(PB_NAME)) {
-
- return;
- }
-
- try {
- Object oPBar = getNameContainer().getByName(PB_NAME);
- XPropertySet xPBModelPSet = (XPropertySet)
- UnoRuntime.queryInterface(XPropertySet.class, oPBar);
-
- xPBModelPSet.setPropertyValue("ProgressValue", new Integer(step));
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
-
- public XPopupMenu executePopupMenu(Image img, Integer positionX, Integer positionY,
- XWindowPeer xImagePeer) {
-
- this.selectedImage = img;
- Collection sizes = FlickrConnection.instance.getPhotoSizes(img.getPhotoID());
- img.setSelectedImageSizes(sizes);
-
- XPopupMenu xPopupMenu = null;
- try {
- // create a popup menu
- Object oPopupMenu = xMultiComponentFactory.createInstanceWithContext(
- "com.sun.star.awt.PopupMenu", m_xContext);
- xPopupMenu = (XPopupMenu) UnoRuntime.queryInterface(XPopupMenu.class, oPopupMenu);
-
- for (Object p : sizes.toArray()) {
- com.aetrion.flickr.photos.Size currentSize = ((com.aetrion.flickr.photos.Size) p);
- xPopupMenu.insertItem((short) currentSize.getLabel(),
- FlickrConnection.instance.getStringSize(currentSize.getLabel()),
- (short) 0, (short) currentSize.getLabel());
- }
-
- com.sun.star.awt.Rectangle rect = new com.sun.star.awt.Rectangle();//100, 100, 260, 440);
- rect.Height = POSITIONWIDTHHEIGHT;
- rect.Width = POSITIONWIDTHHEIGHT + 50;
- rect.X = positionX;
- rect.Y = positionY - POSITIONWIDTHHEIGHT;
-
- xPopupMenu.addMenuListener(new SizesMenuListener(this, addin));
- xPopupMenu.execute(xImagePeer, rect, com.sun.star.awt.PopupMenuDirection.EXECUTE_DEFAULT);
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- return xPopupMenu;
- }
-
- // creates a UNO graphic object that can be used to be assigned
- // to the property "Graphic" of a controlmodel
- public XGraphic getGraphic(String _sImageUrl) {
-
- XGraphic xGraphic = null;
- try {
-
- // create a GraphicProvider at the global service manager...
- Object oGraphicProvider = xMultiComponentFactory.createInstanceWithContext(
- "com.sun.star.graphic.GraphicProvider", m_xContext);
- XGraphicProvider xGraphicProvider = (XGraphicProvider)
- UnoRuntime.queryInterface(XGraphicProvider.class, oGraphicProvider);
- // create the graphic object
- PropertyValue[] aPropertyValues = new PropertyValue[1];
- PropertyValue aPropertyValue = new PropertyValue();
- aPropertyValue.Name = "URL";
- aPropertyValue.Value = _sImageUrl;
- aPropertyValues[0] = aPropertyValue;
- /**********************************************/
- long time = new Date().getTime();
- xGraphic = xGraphicProvider.queryGraphic(aPropertyValues); /////////// bottleneck 2
- System.out.println("Flicker adding thumbnails to dialog " + (new Date().getTime() - time) + _sImageUrl);
- /**********************************************/
- return xGraphic;
- } catch (com.sun.star.uno.Exception ex) {
- throw new java.lang.RuntimeException("cannot happen...");
- }
- }
- @SuppressWarnings("unchecked")
- private void setLicenses(){
- flickrLicenses=new ArrayList<License>();
- License license=new License();
- license.setId("4");
- license.setName("Attribution License");
- license.setUrl("http://creativecommons.org/licenses/by/2.0/");
- flickrLicenses.add(license);
-
- license=new License();
- license.setId("6");
- license.setName("Attribution-NoDerivs License");
- license.setUrl("http://creativecommons.org/licenses/by-nd/2.0/");
- flickrLicenses.add(license);
-
- license=new License();
- license.setId("3");
- license.setName("Attribution-NonCommercial-NoDerivs License");
- license.setUrl("http://creativecommons.org/licenses/by-nc-nd/2.0/");
- flickrLicenses.add(license);
-
- license=new License();
- license.setId("2");
- license.setName("Attribution-NonCommercial License");
- license.setUrl("http://creativecommons.org/licenses/by-nc/2.0/");
- flickrLicenses.add(license);
-
- license=new License();
- license.setId("1");
- license.setName("Attribution-NonCommercial-ShareAlike License");
- license.setUrl("http://creativecommons.org/licenses/by-nc-sa/2.0/");
- flickrLicenses.add(license);
-
- license=new License();
- license.setId("5");
- license.setName("Attribution-ShareAlike License");
- license.setUrl("http://creativecommons.org/licenses/by-sa/2.0/");
- flickrLicenses.add(license);
-
- license=new License();
- license.setId("7");
- license.setName("No known copyright restrictions");
- license.setUrl("http://flickr.com/commons/usage/");
- flickrLicenses.add(license);
- }
-
- public String getLicenseURL(String licenseID) {
-
- for (Object p : this.flickrLicenses.toArray()) {
- com.aetrion.flickr.photos.licenses.License currentLicense = (
- (com.aetrion.flickr.photos.licenses.License) p);
- if ((currentLicense != null)
- && (currentLicense.getId().equalsIgnoreCase(licenseID))) {
- return currentLicense.getUrl();
- }
- }
- return "";
- }
-
- public String getLicenseNumber(String licenseURL) {
-
- String licenseNumber = "";
- if (!licenseURL.equalsIgnoreCase("")) {
-
- if (licenseURL.endsWith("/")) {
- licenseURL = licenseURL.substring(0, licenseURL.length() - 1);
- }
- licenseNumber = licenseURL.substring(licenseURL.lastIndexOf("/") + 1);
- }
-
- return licenseNumber;
- }
-
- public String getLicenseCode(String licenseURL) {
-
- String licenseNumber = "";
- if (!licenseURL.equalsIgnoreCase("")) {
- try {
- URL licenseUrl = new URL(licenseURL);
- String[] pieces = licenseUrl.getPath().split("/");
- if (pieces.length > 2) {
- return pieces[2];
- }
-
- } catch (java.net.MalformedURLException ex) {
- ex.printStackTrace();
- }
- return null;
- }
-
- return licenseNumber;
- }
-
- /**
- * Canges the mouse pointer.
- *
- * @param xContext
- * @param xWindowPeer
- * @param nSystemPointer
- */
- public void setMousePointer(int nSystemPointer) {
- if (xWindowPeer == null) {
- return;
- }
-
- try {
- Object oPointer = xMultiComponentFactory.createInstanceWithContext(
- "com.sun.star.awt.Pointer", m_xContext);
- if (oPointer != null) {
- XPointer xPointer = (XPointer) UnoRuntime.queryInterface(
- XPointer.class, oPointer);
- xPointer.setType(new Integer(nSystemPointer));
- xWindowPeer.setPointer(xPointer);
- }
- } catch (java.lang.Exception ex) {
- ex.printStackTrace();
- }
- }
-
-
- public String getLicense() {
-
- boolean commercial = getCheckBoxStatus(CHK_COMMERCIALNAME);
- boolean update = getCheckBoxStatus(CHK_UPDATENAME);
- boolean shareAlike = getCheckBoxStatus(CHK_SHAREALKENAME);
-
- if (commercial && update && shareAlike) {
- return "4,5";
- } else if (commercial && update) {
- return "4";
- } else if (update && shareAlike) {
- return "1,2,4,5";
- } else if (commercial) {
- return "4,5,6";
- } else if (update) {
- return "2,4";
- }
-
- //default atribution license
- return "4";
- }
-
- public boolean getCheckBoxStatus(String ctrlName) {
-
- Object oLicense = xControlCont.getControl(ctrlName);
- XCheckBox checkBox = (XCheckBox) UnoRuntime.queryInterface(XCheckBox.class, oLicense);
-
- Object value = checkBox.getState();
- if (value != null) {
-
- short chkStatus = new Short(value.toString());
- if (chkStatus == 1) {
- return true;
- }
- }
- return false;
- }
-
- public XNameContainer getNameContainer() {
- return xNameCont;
- }
-
- public Image getSelectedImage() {
- return selectedImage;
- }
-
- public void setSelectedImage(Image selImage) {
-
- this.selectedImage = selImage;
- }
-
- public int getCurrentPage() {
- return currentPage;
- }
-
- public void setCurrentPage(int _currentPage) {
- this.currentPage = _currentPage;
- }
-
- public void close() {
- this.xDialog.endExecute();
- }
-
- public boolean IsInputValid() {
-
- if (this.GetTags().length == 0) {
- return false;
- }
-
- boolean commercial = getCheckBoxStatus(CHK_COMMERCIALNAME);
- boolean update = getCheckBoxStatus(CHK_UPDATENAME);
- boolean shareAlike = getCheckBoxStatus(CHK_SHAREALKENAME);
-
- if (!commercial && !update && !shareAlike) {
- return false;
- }
-
- if (commercial && !update && shareAlike) {
- return false;
- }
-
- if (!commercial && !update && shareAlike) {
- return false;
- }
-
- return true;
- }
-
- public void saveSearch() {
-
- try {
-
- Object oTags = xControlCont.getControl(TXT_TAGS);
- XControl txtTags = (XControl) UnoRuntime.queryInterface(XControl.class, oTags);
- XControlModel xControlModel = txtTags.getModel();
- XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(
- XPropertySet.class, xControlModel);
- String selTags = (String) xPSet.getPropertyValue("Text");
- this.savedTags = selTags.trim();
-
- if (getCheckBoxStatus(CHK_COMMERCIALNAME)) {
- savedCommercialStatus = 1;
- } else {
- savedCommercialStatus = 0;
- }
-
- if (getCheckBoxStatus(CHK_UPDATENAME)) {
- savedUpdateStatus = 1;
- } else {
- savedUpdateStatus = 0;
- }
-
- if (getCheckBoxStatus(CHK_SHAREALKENAME)) {
- savedShareAlikeStatus = 1;
- } else {
- savedShareAlikeStatus = 0;
- }
-
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
-
- public void startSavedSearch() {
-
- setMousePointer(SystemPointer.WAIT);
- enableControl(PictureFlickrDialog.BTN_SEARCH, false);
- enableControl(PictureFlickrDialog.BTN_NEXT, false);
- currentPositionInList = 0;
-
- try {
- Object oTags = xControlCont.getControl(TXT_TAGS);
- XControl txtTags = (XControl) UnoRuntime.queryInterface(XControl.class, oTags);
- XControlModel xControlModel = txtTags.getModel();
- XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(
- XPropertySet.class, xControlModel);
- xPSet.setPropertyValue("Text", this.savedTags);
-
- Object oLicense = xControlCont.getControl(CHK_COMMERCIALNAME);
- XCheckBox checkBox = (XCheckBox) UnoRuntime.queryInterface(
- XCheckBox.class, oLicense);
- checkBox.setState(savedCommercialStatus);
-
- oLicense = xControlCont.getControl(CHK_UPDATENAME);
- checkBox = (XCheckBox) UnoRuntime.queryInterface(XCheckBox.class, oLicense);
- checkBox.setState(savedUpdateStatus);
-
- oLicense = xControlCont.getControl(CHK_SHAREALKENAME);
- checkBox = (XCheckBox) UnoRuntime.queryInterface(XCheckBox.class, oLicense);
- checkBox.setState(savedShareAlikeStatus);
- } catch (Exception ex) {
- ex.printStackTrace();
- }
-
- showResults(currentList, 0);
- setProgressValue(100);
- enableControl(PictureFlickrDialog.BTN_SEARCH, true);
- // enableControl(PictureFlickrDialog.BTN_NEXT, true);
- setMousePointer(SystemPointer.ARROW);
- }
-
- public void setLoadable(boolean val) {
-
- this.isLoadable = val;
- }
-} // PictureFlickrDialog
-
Deleted: ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/SavedSearchThread.java
===================================================================
--- ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/SavedSearchThread.java 2010-07-24 15:53:51 UTC (rev 14600)
+++ ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/SavedSearchThread.java 2010-07-24 16:47:13 UTC (rev 14601)
@@ -1,27 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
-package org.creativecommons.openoffice.ui.flickr;
-
-/**
- *
- * @author Husleag Mihai
- */
-public class SavedSearchThread extends Thread {
-
- private PictureFlickrDialog flickrDialog;
-
- public SavedSearchThread(PictureFlickrDialog flickrDialog) {
-
- this.flickrDialog = flickrDialog;
- }
-
- @Override
- public void run() {
-
- flickrDialog.startSavedSearch();
- }
-
-}
Deleted: ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/SearchClickListener.java
===================================================================
--- ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/SearchClickListener.java 2010-07-24 15:53:51 UTC (rev 14600)
+++ ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/SearchClickListener.java 2010-07-24 16:47:13 UTC (rev 14601)
@@ -1,44 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
-package org.creativecommons.openoffice.ui.flickr;
-
-import com.sun.star.awt.ActionEvent;
-import com.sun.star.awt.XActionListener;
-import com.sun.star.lang.EventObject;
-import org.creativecommons.openoffice.CcOOoAddin;
-import org.creativecommons.openoffice.program.FlickrConnection;
-
-/**
- *
- * @author Husleag Mihai
- */
-public class SearchClickListener implements XActionListener{
-
- private PictureFlickrDialog flickrDialog;
- private CcOOoAddin addin;
- private FlickrConnection flickrConn;
- public SearchClickListener(PictureFlickrDialog flickrDialog, CcOOoAddin addin){
-
- this.flickrDialog = flickrDialog;
- this.addin = addin;
- }
-
- public void actionPerformed(ActionEvent a) {
-
- if (!flickrDialog.IsInputValid()) {
-
- return;
- }
-
- SearchThread th = new SearchThread(flickrDialog,a.ActionCommand);
- th.start();
-
- } // actionPerformed
-
- public void disposing(EventObject e) {
- }
-
-}
Modified: ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/SearchThread.java
===================================================================
--- ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/SearchThread.java 2010-07-24 15:53:51 UTC (rev 14600)
+++ ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/SearchThread.java 2010-07-24 16:47:13 UTC (rev 14601)
@@ -16,10 +16,10 @@
*/
public class SearchThread extends Thread {
- private PictureFlickrDialog flickrDialog;
+ private FlickrDialog flickrDialog;
private String buttonName;
- public SearchThread(PictureFlickrDialog flickrDialog, String btnName) {
+ public SearchThread(FlickrDialog flickrDialog, String btnName) {
this.flickrDialog = flickrDialog;
this.buttonName = btnName;
@@ -29,19 +29,19 @@
public void run() {
flickrDialog.setMousePointer(SystemPointer.WAIT);
- flickrDialog.enableControl(PictureFlickrDialog.BTN_NEXT, false);
- flickrDialog.enableControl(PictureFlickrDialog.BTN_PREVIOUS, false);
- flickrDialog.enableControl(PictureFlickrDialog.BTN_SEARCH, false);
+ flickrDialog.enableControl(FlickrDialog.BTN_NEXT, false);
+ flickrDialog.enableControl(FlickrDialog.BTN_PREVIOUS, false);
+ flickrDialog.enableControl(FlickrDialog.BTN_SEARCH, false);
flickrDialog.saveSearch();
flickrDialog.setProgressValue(0);
String licenseID = flickrDialog.getLicense();
- if (buttonName.equalsIgnoreCase(PictureFlickrDialog.BTN_SEARCH)) {
+ if (buttonName.equalsIgnoreCase(FlickrDialog.BTN_SEARCH)) {
flickrDialog.setCurrentPage(1);
}
else
- if (buttonName.equalsIgnoreCase(PictureFlickrDialog.BTN_PREVIOUS)) {
+ if (buttonName.equalsIgnoreCase(FlickrDialog.BTN_PREVIOUS)) {
flickrDialog.setCurrentPage(flickrDialog.getCurrentPage() - 1);
}
@@ -55,7 +55,7 @@
flickrDialog.setProgressValue(15);
flickrDialog.showResults(imgList, 15);
flickrDialog.setProgressValue(100);
- flickrDialog.enableControl(PictureFlickrDialog.BTN_SEARCH, true);
+ flickrDialog.enableControl(FlickrDialog.BTN_SEARCH, true);
flickrDialog.setMousePointer(SystemPointer.ARROW);
}
Modified: ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/SizesMenuListener.java
===================================================================
--- ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/SizesMenuListener.java 2010-07-24 15:53:51 UTC (rev 14600)
+++ ccooo/branches/akila-gsoc-2010/src/org/creativecommons/openoffice/ui/flickr/SizesMenuListener.java 2010-07-24 16:47:13 UTC (rev 14601)
@@ -18,10 +18,10 @@
*/
public class SizesMenuListener implements XMenuListener {
- private PictureFlickrDialog flickrDialog;
+ private FlickrDialog flickrDialog;
private CcOOoAddin addin;
- public SizesMenuListener(PictureFlickrDialog _flickrDialog, CcOOoAddin _addin) {
+ public SizesMenuListener(FlickrDialog _flickrDialog, CcOOoAddin _addin) {
this.flickrDialog = _flickrDialog;
this.addin = _addin;
More information about the cc-commits
mailing list