Example #1
0
 public Album(G3Viewer a_Container) {
   m_UploadControl = a_Container.getUploadControl();
   m_ID = 1;
   m_Title = "Root";
   m_Container = a_Container;
   m_View = a_Container.getView();
   m_Sort = "Unknown";
   m_DropController = new AlbumTreeDropController(this);
   m_Label = initComponents();
   refresh();
 }
Example #2
0
  public Album(JSONObject jsonObject, G3Viewer a_Container) {
    m_UploadControl = a_Container.getUploadControl();
    m_ID = Utils.extractId(jsonObject.get("id"));
    m_Title = ((JSONString) jsonObject.get("title")).stringValue();
    m_Sort = ((JSONString) jsonObject.get("sort")).stringValue();

    m_Container = a_Container;
    m_View = a_Container.getView();
    m_DropController = new AlbumTreeDropController(this);
    m_Label = initComponents();
  }
Example #3
0
 private void addDropZone(Album a_Parent, Item a_CompareTo, boolean a_Before) {
   HTML drop = new HTML();
   drop.addStyleName("DropZone");
   DropZoneController dzp = new DropZoneController(a_Parent, drop, a_CompareTo, a_Before);
   m_Container.getDragController().registerDropController(dzp);
   m_DropZones.add(dzp);
   addToView(drop);
 }
Example #4
0
  private Label initComponents() {
    Label toReturn = new Label(m_Title);
    toReturn.addStyleName("Tree-Album");
    setWidget(toReturn);
    m_Container.getDragController().registerDropController(m_DropController);
    expand();

    return toReturn;
  }
Example #5
0
 /** returns the album with the given id */
 public void selectSubAlbum(int a_Id) {
   for (int i = 0; i < getChildCount(); i++) {
     Album ab = ((Album) getChild(i));
     if (ab.m_ID == a_Id) {
       ab.select();
       m_Container.getTree().ensureSelected(ab);
     }
   }
 }
Example #6
0
  public void refresh() {
    m_Container.doJSONRequest(
        G3Viewer.VIEW_ITEM_URL + getId(),
        new HttpSuccessHandler() {

          @Override
          public void success(JSONValue aValue) {
            updateValues(aValue);
          }
        },
        false,
        true);
  }
Example #7
0
  public void select() {
    Loading.getInstance().loading("Loading Contents..");
    m_Container.doJSONRequest(
        G3Viewer.VIEW_CHILDREN_URL + getId(),
        new HttpSuccessHandler() {

          @Override
          public void success(JSONValue aValue) {
            viewAlbum(aValue);
          }
        },
        false,
        true);
  }
Example #8
0
  /*
   * Fetch the requested URL.
   */
  public void expand() {

    m_Container.doJSONRequest(
        G3Viewer.VIEW_ALBUM_URL + getId(),
        new HttpSuccessHandler() {

          @Override
          public void success(JSONValue aValue) {
            addAlbums(aValue);
          }
        },
        false,
        true);
  }
Example #9
0
  private void clearView() {
    PickupDragController pdc = m_Container.getDragController();
    if (m_DropZones.size() > 0) {
      for (DropZoneController dropController : m_DropZones) {
        pdc.unregisterDropController(dropController);
      }
      m_DropZones.clear();
    }

    for (Widget widget : getChildren()) {
      if (widget instanceof Item) {
        ((Item) widget).hidding();
      }
    }
    pdc.clearSelection();
    clear();
  }
Example #10
0
  /** moves the given array of ids to this album */
  public void moveTo(JSONArray a_Ids) {
    Loading.getInstance().loading("Moving Items..");

    m_Container.doJSONRequest(
        G3Viewer.MOVE_TO_ALBUM_URL + getId() + "?sourceids=" + a_Ids.toString(),
        new HttpSuccessHandler() {

          @Override
          public void success(JSONValue aValue) {
            expand();
            m_View.getCurrentAlbum().expand();
            m_View.getCurrentAlbum().select();
          }
        },
        true,
        true);
  }
Example #11
0
  /** rearranges the albums */
  public void rearrangeTo(JSONArray a_Ids, Item m_CompareTo, boolean m_Before) {
    Loading.getInstance().loading("Re-arranging..");
    String bora = m_Before ? "before" : "after";

    m_Container.doJSONRequest(
        G3Viewer.REARRANGE_URL
            + m_CompareTo.getID()
            + "/"
            + bora
            + "?sourceids="
            + a_Ids.toString(),
        new HttpSuccessHandler() {

          @Override
          public void success(JSONValue aValue) {
            m_View.getCurrentAlbum().select();
          }
        },
        true,
        true);
  }
Example #12
0
  public void uploadFiles(final File[] files) {

    m_Container.doJSONRequest(
        G3Viewer.RESIZE_DETAILS_URL,
        new HttpSuccessHandler() {

          public void success(JSONValue a_Value) {
            JSONObject jso = a_Value.isObject();
            if (jso != null) {

              ResizeOptions ro = new ResizeOptions(jso);
              UploadFile uf;
              for (File file : files) {
                uf = m_UploadControl.createUploadFile(Album.this, file, ro);
                m_AllUploads.add(uf);
                m_View.addToView(uf);
              }
              m_Container.updateInformation();
            }
          }
        },
        false,
        true);
  }
Example #13
0
 public View(G3Viewer a_Container) {
   m_Container = a_Container;
   if (m_Container.isUploadEnabled()) {
     ((DndDesktopFactory) GWT.create(DndDesktopFactory.class)).getInstance(this);
   }
 }
Example #14
0
 public void cleanup() {
   m_Container.getDragController().unregisterDropController(m_DropController);
   for (int i = 0; i < getChildCount(); i++) {
     ((Album) getChild(i)).cleanup();
   }
 }
Example #15
0
  public void showPopupMenu(Event event) {
    m_Label.addStyleName("popped");
    final PopupPanel popupPanel = new PopupPanel(true);
    popupPanel.setAnimationEnabled(true);
    MenuBar popupMenuBar = new MenuBar(true);

    MenuItem editItem =
        new MenuItem(
            "Edit Album",
            true,
            new Command() {

              @Override
              public void execute() {
                m_Container.doDialog(
                    "index.php/form/edit/albums/" + m_ID,
                    new HttpDialogHandler() {
                      @Override
                      public void success(String aResult) {
                        refresh();
                      }
                    });
                popupPanel.hide();
              }
            });

    MenuItem addAlbum =
        new MenuItem(
            "Add Album",
            true,
            new Command() {

              @Override
              public void execute() {
                m_Container.doDialog(
                    "index.php/form/add/albums/" + m_ID + "?type=album",
                    new HttpDialogHandler() {
                      @Override
                      public void success(String aResult) {
                        expand();
                        m_View.getCurrentAlbum().select();
                      }
                    });

                popupPanel.hide();
              }
            });

    MenuItem userPermissions =
        new MenuItem(
            "User Permissions",
            true,
            new Command() {
              @Override
              public void execute() {
                m_Container.doDialog(
                    "index.php/permissions/browse/" + m_ID,
                    new HttpDialogHandler() {
                      @Override
                      public void success(String aResult) {}
                    });

                popupPanel.hide();
              }
            });

    popupPanel.setStyleName("popup");
    editItem.addStyleName("popup-item");
    addAlbum.addStyleName("popup-item");
    userPermissions.addStyleName("popup-item");

    if (m_Container.isUploadEnabled()) {
      MenuItem uploadPhotos =
          new MenuItem(
              "Upload Photos",
              true,
              new Command() {

                @Override
                public void execute() {
                  uploadFiles();
                  popupPanel.hide();
                }
              });
      uploadPhotos.addStyleName("popup-item");
      popupMenuBar.addItem(uploadPhotos);
    }

    popupMenuBar.addItem(editItem);
    popupMenuBar.addItem(addAlbum);
    popupMenuBar.addItem(userPermissions);

    popupMenuBar.setVisible(true);
    popupPanel.add(popupMenuBar);

    int x = DOM.eventGetClientX(event);
    int y = DOM.eventGetClientY(event);
    popupPanel.setPopupPosition(x, y);
    popupPanel.addCloseHandler(
        new CloseHandler<PopupPanel>() {

          @Override
          public void onClose(CloseEvent<PopupPanel> event) {

            m_Label.removeStyleName("popped");
          }
        });

    popupPanel.show();
  }