public void valueChanged(final ListSelectionEvent e) { final Object value = queryNameList.getSelectedValue(); if (value == null) { nameTextField.setEnabled(false); fileTextField.setEnabled(false); stepsList.setEnabled(false); editParameterAction.setEnabled(false); return; } inUpdateFromList = true; nameTextField.setEnabled(true); fileTextField.setEnabled(true); final AbstractReportDefinition report = designTimeContext.getReport(); final MasterReport masterReport = DesignTimeUtil.getMasterReport(report); final ResourceKey contentBase; if (masterReport == null) { contentBase = null; } else { contentBase = masterReport.getContentBase(); } try { final KettleQueryEntry selectedQuery = (KettleQueryEntry) value; fileTextField.setText(selectedQuery.getFile()); nameTextField.setText(selectedQuery.getName()); final StepMeta[] data = selectedQuery.getSteps(report.getResourceManager(), contentBase); stepsList.setListData(data); final String selectedStepName = selectedQuery.getSelectedStep(); if (selectedStepName != null) { for (int i = 0; i < data.length; i++) { final StepMeta stepMeta = data[i]; if (selectedStepName.equals(stepMeta.getName())) { stepsList.setSelectedValue(stepMeta, true); break; } } } stepsList.setEnabled(true); editParameterAction.setEnabled(true); } catch (ReportDataFactoryException rdfe) { logger.warn("Non-critical failure while executing the query", rdfe); stepsList.setEnabled(false); editParameterAction.setEnabled(false); } catch (Exception e1) { designTimeContext.error(e1); stepsList.setEnabled(false); editParameterAction.setEnabled(false); } catch (Throwable t1) { designTimeContext.error(new StackableRuntimeException("Fatal error", t1)); stepsList.setEnabled(false); editParameterAction.setEnabled(false); } finally { inUpdateFromList = false; } }
public void actionPerformed(final ActionEvent e) { final FileFilter[] fileFilters = new FileFilter[] { new FilesystemFilter( new String[] {".ktr"}, Messages.getString("KettleDataSourceDialog.KtrFileDescription") + " (*.ktr)", true) }; final File reportContextFile = DesignTimeUtil.getContextAsFile(designTimeContext.getReport()); final CommonFileChooser fileChooser = FileChooserService.getInstance().getFileChooser("kettle"); final String fileText = fileTextField.getText(); if (StringUtils.isEmpty(fileText) == false) { if (reportContextFile != null) { fileChooser.setSelectedFile( new File(reportContextFile.getParentFile(), fileTextField.getText())); } else { fileChooser.setSelectedFile(new File(fileTextField.getText())); } } fileChooser.setFilters(fileFilters); if (fileChooser.showDialog(KettleDataSourceDialog.this, JFileChooser.OPEN_DIALOG) == false) { return; } final File file = fileChooser.getSelectedFile(); if (file == null) { return; } final String path; if (reportContextFile != null) { path = IOUtils.getInstance() .createRelativePath(file.getPath(), reportContextFile.getAbsolutePath()); } else { path = file.getPath(); } final KettleQueryEntry queryEntry = (KettleQueryEntry) queryNameList.getSelectedValue(); queryEntry.setFile(path); fileTextField.setText(path); }
private IMetadataDomainRepository buildDomainRepository() { try { final AbstractReportDefinition report = context.getReport(); final MasterReport masterReport = DesignTimeUtil.getMasterReport(report); final ResourceKey contentBase; if (masterReport == null) { contentBase = null; } else { contentBase = masterReport.getContentBase(); } final ResourceManager resourceManager = context.getReport().getResourceManager(); return new PmdConnectionProvider() .getMetadataDomainRepository(domainId, resourceManager, contentBase, fileName); } catch (Exception e) { context.error(e); } return new InMemoryMetadataDomainRepository(); }
/** Invoked when an action occurs. */ public void actionPerformed(final ActionEvent e) { final KettleQueryEntry queryEntry = (KettleQueryEntry) queryNameList.getSelectedValue(); if (queryEntry == null) { return; } final AbstractReportDefinition report = designTimeContext.getReport(); final MasterReport masterReport = DesignTimeUtil.getMasterReport(report); final ResourceKey contentBase; if (masterReport == null) { contentBase = null; } else { contentBase = masterReport.getContentBase(); } try { final ParameterEditorDialog dialog = new ParameterEditorDialog(KettleDataSourceDialog.this); final String[] reportFields = designTimeContext.getDataSchemaModel().getColumnNames(); final ParameterEditorDialog.EditResult editResult = dialog.performEdit( queryEntry.getArguments(), queryEntry.getParameters(), reportFields, queryEntry.getDeclaredParameters(report.getResourceManager(), contentBase)); if (editResult == null) { return; } queryEntry.setArguments(editResult.getArgumentNames()); queryEntry.setParameters(editResult.getParameterMappings()); } catch (Exception e1) { designTimeContext.error(e1); } catch (Throwable t1) { designTimeContext.error(new StackableRuntimeException("Fatal error", t1)); } }