Search in sources :

Example 1 with EnterListDialog

use of org.pentaho.di.ui.core.dialog.EnterListDialog in project pentaho-kettle by pentaho.

the class Translator method selectLocales.

public void selectLocales() {
    String[] available = getAvailableLocale();
    EnterListDialog eld = new EnterListDialog(shell, SWT.NONE, available);
    String[] selection = eld.open();
    if (selection != null) {
        for (int i = 0; i < available.length; i++) {
            locales.put(available[i], Boolean.FALSE);
        }
        for (int i = 0; i < selection.length; i++) {
            locales.put(selection[i], Boolean.TRUE);
        }
    }
}
Also used : EnterListDialog(org.pentaho.di.ui.core.dialog.EnterListDialog)

Example 2 with EnterListDialog

use of org.pentaho.di.ui.core.dialog.EnterListDialog in project pentaho-kettle by pentaho.

the class ExcelInputDialog method getSheets.

/**
 * Get the names of the sheets from the Excel workbooks and let the user select some or all of them.
 */
public void getSheets() {
    List<String> sheetnames = new ArrayList<String>();
    ExcelInputMeta info = new ExcelInputMeta();
    getInfo(info);
    FileInputList fileList = info.getFileList(transMeta);
    for (FileObject fileObject : fileList.getFiles()) {
        try {
            KWorkbook workbook = WorkbookFactory.getWorkbook(info.getSpreadSheetType(), KettleVFS.getFilename(fileObject), info.getEncoding());
            int nrSheets = workbook.getNumberOfSheets();
            for (int j = 0; j < nrSheets; j++) {
                KSheet sheet = workbook.getSheet(j);
                String sheetname = sheet.getName();
                if (Const.indexOfString(sheetname, sheetnames) < 0) {
                    sheetnames.add(sheetname);
                }
            }
            workbook.close();
        } catch (Exception e) {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "System.Dialog.Error.Title"), BaseMessages.getString(PKG, "ExcelInputDialog.ErrorReadingFile.DialogMessage", KettleVFS.getFilename(fileObject)), e);
        }
    }
    // Put it in an array:
    String[] lst = sheetnames.toArray(new String[sheetnames.size()]);
    // Let the user select the sheet-names...
    EnterListDialog esd = new EnterListDialog(shell, SWT.NONE, lst);
    String[] selection = esd.open();
    if (selection != null) {
        for (int j = 0; j < selection.length; j++) {
            wSheetnameList.add(new String[] { selection[j], "" });
        }
        wSheetnameList.removeEmptyRows();
        wSheetnameList.setRowNums();
        wSheetnameList.optWidth(true);
        checkAlerts();
    }
}
Also used : KWorkbook(org.pentaho.di.core.spreadsheet.KWorkbook) ArrayList(java.util.ArrayList) KSheet(org.pentaho.di.core.spreadsheet.KSheet) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) EnterListDialog(org.pentaho.di.ui.core.dialog.EnterListDialog) KettleStepException(org.pentaho.di.core.exception.KettleStepException) KettlePluginException(org.pentaho.di.core.exception.KettlePluginException) ExcelInputMeta(org.pentaho.di.trans.steps.excelinput.ExcelInputMeta) FileObject(org.apache.commons.vfs2.FileObject) FileInputList(org.pentaho.di.core.fileinput.FileInputList)

Aggregations

EnterListDialog (org.pentaho.di.ui.core.dialog.EnterListDialog)2 ArrayList (java.util.ArrayList)1 FileObject (org.apache.commons.vfs2.FileObject)1 KettlePluginException (org.pentaho.di.core.exception.KettlePluginException)1 KettleStepException (org.pentaho.di.core.exception.KettleStepException)1 FileInputList (org.pentaho.di.core.fileinput.FileInputList)1 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)1 KSheet (org.pentaho.di.core.spreadsheet.KSheet)1 KWorkbook (org.pentaho.di.core.spreadsheet.KWorkbook)1 ExcelInputMeta (org.pentaho.di.trans.steps.excelinput.ExcelInputMeta)1 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)1