Example #1
0
  /** get info of window export, index of active tab, list child tab */
  protected void initTabInfo() {
    IADTabbox adTab = panel.getADTab();
    int selected = adTab.getSelectedIndex();
    int tabLevel = panel.getActiveGridTab().getTabLevel();
    Set<String> tables = new HashSet<String>();
    childs = new ArrayList<GridTab>();
    List<GridTab> includedList = panel.getActiveGridTab().getIncludedTabs();
    for (GridTab included : includedList) {
      String tableName = included.getTableName();
      if (tables.contains(tableName)) continue;
      tables.add(tableName);
      childs.add(included);
    }
    for (int i = selected + 1; i < adTab.getTabCount(); i++) {
      IADTabpanel adTabPanel = adTab.getADTabpanel(i);
      if (adTabPanel.getGridTab().isSortTab()) continue;
      if (adTabPanel.getGridTab().getTabLevel() <= tabLevel) break;
      String tableName = adTabPanel.getGridTab().getTableName();
      if (tables.contains(tableName)) continue;
      tables.add(tableName);
      childs.add(adTabPanel.getGridTab());
    }

    indxDetailSelected = 0;
    if (adTab.getSelectedDetailADTabpanel() != null)
      indxDetailSelected = adTab.getSelectedDetailADTabpanel().getGridTab().getTabNo();
  }
Example #2
0
  private void exportFile() {
    try {
      boolean currentRowOnly = chkCurrentRow.isSelected();
      File file =
          File.createTempFile("Export", "." + cboType.getSelectedItem().getValue().toString());
      childs.clear();
      for (Checkbox chkSeletionTab : chkSelectionTabForExport) {
        if (chkSeletionTab.isChecked()) {
          childs.add((GridTab) chkSeletionTab.getAttribute("tabBinding"));
        }
      }

      exporter.export(panel.getActiveGridTab(), childs, currentRowOnly, file, indxDetailSelected);

      winExportFile.onClose();
      winExportFile = null;
      AMedia media = null;
      media =
          new AMedia(
              exporter.getSuggestedFileName(panel.getActiveGridTab()),
              null,
              exporter.getContentType(),
              file,
              true);
      Filedownload.save(media);
    } catch (Exception e) {
      throw new AdempiereException(e);
    } finally {
      if (winExportFile != null) winExportFile.onClose();
    }
  }
Example #3
0
 @Override
 public void onEvent(Event event) throws Exception {
   if (event.getTarget().getId().equals(ConfirmPanel.A_CANCEL)) winExportFile.onClose();
   else if (event.getTarget().getId().equals(ConfirmPanel.A_OK)) exportFile();
   else if (event.getName().equals(DialogEvents.ON_WINDOW_CLOSE)) {
     panel.hideBusyMask();
   } else if (event.getTarget().equals(cboType) && event.getName().equals(Events.ON_SELECT)) {
     displayExportTabSelection();
   } else if (event.getName().equals("onExporterException")) {
     FDialog.error(0, winExportFile, "FileInvalidExtension");
     winExportFile.onClose();
   }
 }
Example #4
0
  /** execute export action */
  public void export() {
    exporterMap = new HashMap<String, IGridTabExporter>();
    extensionMap = new HashMap<String, String>();
    List<IGridTabExporter> exporterList =
        EquinoxExtensionLocator.instance().list(IGridTabExporter.class).getExtensions();
    for (IGridTabExporter exporter : exporterList) {
      String extension = exporter.getFileExtension();
      if (!extensionMap.containsKey(extension)) {
        extensionMap.put(extension, exporter.getFileExtensionLabel());
        exporterMap.put(extension, exporter);
      }
    }

    if (winExportFile == null) {
      winExportFile = new Window();
      winExportFile.setTitle(
          Msg.getMsg(Env.getCtx(), "Export") + ": " + panel.getActiveGridTab().getName());
      winExportFile.setWidth("450px");
      winExportFile.setClosable(true);
      winExportFile.setBorder("normal");
      winExportFile.setStyle("position:absolute");
      winExportFile.setSclass("popup-dialog");
      winExportFile.setWidgetAttribute(AdempiereWebUI.WIDGET_INSTANCE_NAME, "exportAction");

      cboType.setMold("select");

      cboType.getItems().clear();
      for (Map.Entry<String, String> entry : extensionMap.entrySet()) {
        cboType.appendItem(entry.getKey() + " - " + entry.getValue(), entry.getKey());
      }

      cboType.setSelectedIndex(0);
      cboType.addActionListener(this);

      Vbox vb = new Vbox();
      vb.setWidth("100%");
      winExportFile.appendChild(vb);

      Vlayout vlayout = new Vlayout();
      vlayout.setSclass("dialog-content");
      vb.appendChild(vlayout);

      Grid grid = GridFactory.newGridLayout();
      vlayout.appendChild(grid);

      Columns columns = new Columns();
      Column column = new Column();
      column.setHflex("min");
      columns.appendChild(column);
      column = new Column();
      column.setHflex("1");
      columns.appendChild(column);
      grid.appendChild(columns);

      Rows rows = new Rows();
      grid.appendChild(rows);

      Row row = new Row();
      rows.appendChild(row);
      row.appendChild(new Label(Msg.getMsg(Env.getCtx(), "FilesOfType")));
      row.appendChild(cboType);
      cboType.setHflex("1");

      row = new Row();
      rows.appendChild(row);
      row.appendChild(new Space());
      chkCurrentRow.setLabel(Msg.getMsg(Env.getCtx(), "ExportCurrentRowOnly"));
      chkCurrentRow.setSelected(true);
      row.appendChild(chkCurrentRow);

      selectionTabRow = new Row();
      rows.appendChild(selectionTabRow);

      LayoutUtils.addSclass("dialog-footer", confirmPanel);
      vb.appendChild(confirmPanel);
      confirmPanel.addActionListener(this);
    }
    displayExportTabSelection();
    panel.getComponent().getParent().appendChild(winExportFile);
    panel.showBusyMask(winExportFile);
    LayoutUtils.openOverlappedWindow(panel.getComponent(), winExportFile, "middle_center");
    winExportFile.addEventListener(DialogEvents.ON_WINDOW_CLOSE, this);
    winExportFile.addEventListener("onExporterException", this);
  }