[HELP] Moving the AssetList Panel

Hello, so as the title, i wanted to move the AssetList into FileUploadWizard,
so i have created a function in FileUploadWizard and called the function at refreshAssetList, and everything is working, i can pass the treeItem from AssetList to FileUploadWizard, but the issue i am facing is that the dialog is not going to update the new added contents from the function

My Code :

AssetList.java :
private void refreshAssetList() {
final Images images = Ode.getImageBundle();
OdeLog.log("AssetList: refreshing for project " + projectId);
assetList.clear();

if (assetsFolder != null) {
  for (ProjectNode node : assetsFolder.getChildren()) {
    // Add the name to the tree. We need to enclose it in a span
    // because the CSS style for selection specifies a span.
    String nodeName = node.getName();
    if (nodeName.length() > 20)
      nodeName = nodeName.substring(0, 8) + "..." + nodeName.substring(nodeName.length() - 9,
          nodeName.length());
    String fileSuffix = node.getProjectId() + "/" + node.getFileId();
    String treeItemText = "<span style='cursor: pointer'>";
    if (StorageUtil.isImageFile(fileSuffix)) {
      treeItemText += new Image(images.mediaIconImg());
    } else if (StorageUtil.isAudioFile(fileSuffix )) {
      treeItemText += new Image(images.mediaIconAudio());
    } else if (StorageUtil.isVideoFile(fileSuffix )) {
      treeItemText += new Image(images.mediaIconVideo());
    }
    treeItemText += nodeName + "</span>";
    TreeItem treeItem = new TreeItem(new HTML(treeItemText));
    // keep a pointer from the tree item back to the actual node
    treeItem.setUserObject(node);
    assetList.addItem(treeItem);
   
   FileUploadWizard fileuploadwizards = new FileUploadWizard(assetsFolder);
   fileuploadwizards.refreshdAssetList(treeItem);

 OdeLog.log("Refresh Assets done");
  }
}

}

FileUploadWizard.java :

public FileUploadWizard(final FolderNode folderNode,
final FileUploadedCallback fileUploadedCallback) {
super(MESSAGES.fileUploadWizardCaption(), true, false);

// Initialize UI
final FileUpload upload = new FileUpload();
dassetList = new Tree();
dassetList.setWidth("100%");
dassetList.setVisible(true);
dassetList.setStyleName("ode-dialogAssetsList");
final HTML upText = new HTML("<div class='ode-fileuploadupper'><p class='ode-fileuploadtoptext'>Choose or Drag a File to Upload :</p></div>");

dassetList.setScrollOnSelectEnabled(false);
dassetList.sinkEvents(Event.ONMOUSEMOVE);
dassetList.addMouseMoveHandler(new MouseMoveHandler() {
  @Override
  public void onMouseMove(MouseMoveEvent event) {
    clientX = event.getClientX();
    clientY = event.getClientY();
  }
});
dassetList.addSelectionHandler(new SelectionHandler<TreeItem>() {
  @Override
  public void onSelection(SelectionEvent<TreeItem> event) {
    TreeItem selected = event.getSelectedItem();
    ProjectNode node = (ProjectNode) selected.getUserObject();
    // The actual menu is determined by what is registered for the filenode
    // type in CommandRegistry.java
    ProjectNodeContextMenu.show(node, selected.getWidget(), clientX, clientY);
  }});

upload.setName(ServerLayout.UPLOAD_FILE_FORM_ELEMENT);
upload.setStylePrimaryName("ode-assetUpload");
setStylePrimaryName("ode-DialogBox");
panel = new VerticalPanel();
panel.setVerticalAlignment(VerticalPanel.ALIGN_MIDDLE);

...................

panel.add(fileupImg);
panel.add(upText);
panel.add(upload);
panel.add(dassetList);
setPagePanelHeight(350);
setPixelSize(200,350);
addPage(panel);
........................

public void refreshdAssetList(TreeItem treeItem) {

OdeLog.log("updating Asset List");

    dassetList.clear();
    dassetList.addItem(treeItem);
    
    panel.add(dassetList);
    addPage(panel);
    //addPage(panel2);
    OdeLog.log("done");

}

As this two Log messages shows and i have tested and checked that the var TreeItem can be passed normally without any issue, so it is sure that the issue is that in FileUploadWizard it can not update the dialog in the function

2 Likes