Subversion Repositories eFlore/Archives.cel-v1

Rev

Rev 23 | Blame | Last modification | View Log | RSS feed

/*
 * Copyright 2006 Google Inc.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package org.tela_botanica.client;


import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;

/**
 * Composite permet de wrapper des Widget pour creer un nouveau Widget cf methode initWidget()
 */

public class ActionPanel extends Composite   {
        
  private Mediator mediator=null;
  private HTML exportButton=null;
  

  public ActionPanel(final Mediator med) {
         
   mediator=med;
   
   mediator.registerActionPanel(this);
   
        HorizontalPanel outer = new HorizontalPanel();
        HorizontalPanel buttons = new HorizontalPanel();
        buttons.setSpacing(3);

        
        // Transmission d'elements
        
        HTML transButton=new HTML("Transmettre Tela Botanica");
        transButton.setStyleName("html_button_long");
        transButton.addClickListener(
                new ClickListener() {
                        public void onClick(Widget sender) {
                                // TODO : une action dans le mediator
                                if (mediator.getConnected()) {
                                        mediator.getInventoryItemList().transmitElement();
                                }
                                else  {
                                        Window.alert("Identifiez-vous pour transmettre");
                                }
                        }
                }
        );              
        
        buttons.add(transButton);
        
        // Suppression d'elements
        
        HTML delButton=new HTML("Suppression");
        delButton.setStyleName("html_button");
        delButton.addClickListener(
                new ClickListener() {
                        public void onClick(Widget sender) {
                                // TODO : une action dans le mediator
                                mediator.getInventoryItemList().deleteElement();
                        }
                }
        );              
        
        buttons.add(delButton);

        // Export de la totalité 
        
        exportButton=new HTML("<a href=\""+mediator.getServiceBaseUrl()+"/InventoryExport/" 
        +  mediator.getUser() + 
        "\">"+"Export&nbsp;tableur</a>");
        buttons.add(exportButton);
        exportButton.setStyleName("html_button");


        // Selections de l'affichage
        
        HorizontalPanel selections = new HorizontalPanel();
        
        selections.setSpacing(3);
        

        selections.add(new HTML("S&eacute;lection : "));
        
        Label allLabel = new Label("Tous");
        Label separatorLabel = new Label(",");
        Label noneLabel = new Label("Aucun");
        
        allLabel.setStyleName("selection_label");
        noneLabel.setStyleName("selection_label");
        
        selections.add(allLabel);
        allLabel.addClickListener(
                        new ClickListener() {
                                public void onClick(Widget sender) {
                                        // TODO : une action dans le mediator
                                        mediator.getInventoryItemList().selectAll();
                                }
                        }
        );              
        
        selections.add(separatorLabel);
        
        selections.add(noneLabel);
        noneLabel.addClickListener(
                        new ClickListener() {
                                public void onClick(Widget sender) {
                                        // TODO : une action dans le mediator
                                        mediator.getInventoryItemList().deselectAll();
                                }
                        }
        );              
        

        outer.add(buttons);
        outer.add(selections);

        initWidget(outer);
        this.setStyleName("action-Panel");
   
    
  }


public HTML getExportButton() {
        return exportButton;
}
}