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);
}
}
}
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();
}
}
Aggregations