use of org.apache.hop.ui.core.dialog.SelectRowDialog in project hop by apache.
the class HopGuiFileDelegate method fileOpenRecent.
/**
* Show all the recent files in a new dialog...
*/
public void fileOpenRecent() {
// Get the recent files for the active perspective...
//
IHopPerspective perspective = hopGui.getActivePerspective();
try {
// Let's limit ourselves to 100 operations...
//
List<AuditEvent> events = AuditManager.findEvents(HopNamespace.getNamespace(), "file", "open", 100, true);
Set<String> filenames = new HashSet<>();
List<RowMetaAndData> rows = new ArrayList<>();
IRowMeta rowMeta = new RowMeta();
rowMeta.addValueMeta(new ValueMetaString("filename"));
rowMeta.addValueMeta(new ValueMetaString("operation"));
rowMeta.addValueMeta(new ValueMetaString("date"));
for (AuditEvent event : events) {
String filename = event.getName();
if (!filenames.contains(filename)) {
filenames.add(filename);
String operation = event.getOperation();
String dateString = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(event.getDate());
rows.add(new RowMetaAndData(rowMeta, new Object[] { filename, operation, dateString }));
}
}
SelectRowDialog rowDialog = new SelectRowDialog(hopGui.getShell(), hopGui.getVariables(), SWT.NONE, rows);
rowDialog.setTitle("Select the file to open");
RowMetaAndData row = rowDialog.open();
if (row != null) {
String filename = row.getString("filename", null);
hopGui.fileDelegate.fileOpen(filename);
}
} catch (Exception e) {
new ErrorDialog(hopGui.getShell(), "Error", "Error getting list of recently opened files", e);
}
}
use of org.apache.hop.ui.core.dialog.SelectRowDialog in project hop by apache.
the class TestingGuiPlugin method selectUnitTestFromAllTests.
/**
* List all unit tests which are defined And allow the user to select one
*/
public RowMetaAndData selectUnitTestFromAllTests() {
HopGui hopGui = HopGui.getInstance();
IHopMetadataProvider metadataProvider = hopGui.getMetadataProvider();
IRowMeta rowMeta = new RowMeta();
rowMeta.addValueMeta(new ValueMetaString("Unit test"));
rowMeta.addValueMeta(new ValueMetaString("Description"));
rowMeta.addValueMeta(new ValueMetaString("Filename"));
List<RowMetaAndData> rows = new ArrayList<>();
try {
IHopMetadataSerializer<PipelineUnitTest> testSerializer = metadataProvider.getSerializer(PipelineUnitTest.class);
List<String> testNames = testSerializer.listObjectNames();
for (String testName : testNames) {
PipelineUnitTest unitTest = testSerializer.load(testName);
Object[] row = RowDataUtil.allocateRowData(rowMeta.size());
row[0] = testName;
row[1] = unitTest.getDescription();
row[2] = unitTest.getPipelineFilename();
rows.add(new RowMetaAndData(rowMeta, row));
}
// Now show a selection dialog...
//
SelectRowDialog dialog = new SelectRowDialog(hopGui.getShell(), new Variables(), SWT.DIALOG_TRIM | SWT.MAX | SWT.RESIZE, rows);
RowMetaAndData selection = dialog.open();
if (selection != null) {
return selection;
}
return null;
} catch (Exception e) {
new ErrorDialog(hopGui.getShell(), BaseMessages.getString(PKG, "TestingGuiPlugin.SelectUnitTestFromAllTests.Error.Header"), BaseMessages.getString(PKG, "TestingGuiPlugin.SelectUnitTestFromAllTests.Error.Message"), e);
return null;
}
}
Aggregations