/** Copy information from the meta-data input to the dialog fields. */ public void getData() { wStepname.selectAll(); wFieldname.setText(Const.NVL(mappingMeta.getFieldName(), "")); wExecuteForEachRow.setSelection(mappingMeta.getExecuteForEachRow()); // Add the parameters tab addParametersTab(mappingParameters); wTabFolder.setSelection(0); // Now add the input stream tabs: where is our data coming from? for (int i = 0; i < inputMappings.size(); i++) { addInputMappingDefinitionTab(inputMappings.get(i), i); } // Now add the output stream tabs: where is our data going to? for (int i = 0; i < outputMappings.size(); i++) { addOutputMappingDefinitionTab(outputMappings.get(i), i); } }
public MappingFiledRunnerDialog(Shell parent, Object in, TransMeta tr, String sname) { super(parent, (BaseStepMeta) in, tr, sname); mappingMeta = (MappingFiledRunnerMeta) in; transModified = false; // Make a copy for our own purposes... // This allows us to change everything directly in the classes with // listeners. // Later we need to copy it to the input class on ok() // mappingParameters = (MappingParameters) mappingMeta.getMappingParameters().clone(); inputMappings = new ArrayList<MappingIODefinition>(); outputMappings = new ArrayList<MappingIODefinition>(); for (int i = 0; i < mappingMeta.getInputMappings().size(); i++) inputMappings.add((MappingIODefinition) mappingMeta.getInputMappings().get(i).clone()); for (int i = 0; i < mappingMeta.getOutputMappings().size(); i++) outputMappings.add((MappingIODefinition) mappingMeta.getOutputMappings().get(i).clone()); changeList = new ArrayList<ApplyChanges>(); }
private void ok() { if (Const.isEmpty(wStepname.getText())) return; stepname = wStepname.getText(); // return value mappingMeta.setFieldName(wFieldname.getText()); mappingMeta.setExecuteEachRow(wExecuteForEachRow.getSelection()); // Load the information on the tabs, optionally do some // verifications... // collectInformation(); mappingMeta.setMappingParameters(mappingParameters); mappingMeta.setInputMappings(inputMappings); mappingMeta.setOutputMappings(outputMappings); mappingMeta.setChanged(true); dispose(); }
public String open() { Shell parent = getParent(); Display display = parent.getDisplay(); shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MIN | SWT.MAX); props.setLook(shell); setShellImage(shell, mappingMeta); lsMod = new ModifyListener() { public void modifyText(ModifyEvent e) { mappingMeta.setChanged(); } }; changed = mappingMeta.hasChanged(); FormLayout formLayout = new FormLayout(); formLayout.marginWidth = Const.FORM_MARGIN; formLayout.marginHeight = Const.FORM_MARGIN; shell.setLayout(formLayout); shell.setText(Messages.getString("MappingFieldRunnerDialog.Shell.Title")); // $NON-NLS-1$ middle = props.getMiddlePct(); margin = Const.MARGIN; // Stepname line wlStepname = new Label(shell, SWT.RIGHT); wlStepname.setText( Messages.getString("MappingFieldRunnerDialog.Stepname.Label")); // $NON-NLS-1$ props.setLook(wlStepname); fdlStepname = new FormData(); fdlStepname.left = new FormAttachment(0, 0); fdlStepname.right = new FormAttachment(middle, -margin); fdlStepname.top = new FormAttachment(0, margin); wlStepname.setLayoutData(fdlStepname); wStepname = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER); wStepname.setText(stepname); props.setLook(wStepname); wStepname.addModifyListener(lsMod); fdStepname = new FormData(); fdStepname.left = new FormAttachment(middle, 0); fdStepname.top = new FormAttachment(0, margin); fdStepname.right = new FormAttachment(100, 0); wStepname.setLayoutData(fdStepname); // Show a group with 2 main options: a transformation in the repository // or on file // // ////////////////////////////////////////////////// // The key creation box // ////////////////////////////////////////////////// // gTransGroup = new Group(shell, SWT.SHADOW_ETCHED_IN); gTransGroup.setText( Messages.getString("MappingFieldRunnerDialog.TransGroup.Label")); // $NON-NLS-1$; gTransGroup.setBackground(shell.getBackground()); // the default looks // ugly FormLayout transGroupLayout = new FormLayout(); transGroupLayout.marginLeft = margin * 2; transGroupLayout.marginTop = margin * 2; transGroupLayout.marginRight = margin * 2; transGroupLayout.marginBottom = margin * 2; gTransGroup.setLayout(transGroupLayout); wFieldname = new ComboVar(transMeta, gTransGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER); props.setLook(wFieldname); wFieldname.addModifyListener(lsMod); FormData fdFilename = new FormData(); fdFilename.left = new FormAttachment(0, 25); fdFilename.right = new FormAttachment(100, -margin); fdFilename.top = new FormAttachment(0, 0); wFieldname.setLayoutData(fdFilename); wExecuteForEachRow = new Button(gTransGroup, SWT.CHECK); FormData fdExecuteForEachRow = new FormData(); fdExecuteForEachRow.left = new FormAttachment(0, 25); fdExecuteForEachRow.top = new FormAttachment(wFieldname, margin); wExecuteForEachRow.setLayoutData(fdExecuteForEachRow); wlExecuteForEachRow = new Label(gTransGroup, SWT.NONE); wlExecuteForEachRow.setText( Messages.getString("MappingFieldRunnerDialog.ForEachRow.Label")); // $NON-NLS-1$ FormData fdlExecuteForEachRow = new FormData(); fdlExecuteForEachRow.left = new FormAttachment(wExecuteForEachRow, margin); fdlExecuteForEachRow.top = new FormAttachment(wFieldname, margin); wlExecuteForEachRow.setLayoutData(fdlExecuteForEachRow); FormData fdTransGroup = new FormData(); fdTransGroup.left = new FormAttachment(0, 0); fdTransGroup.top = new FormAttachment(wStepname, 2 * margin); fdTransGroup.right = new FormAttachment(100, 0); // fdTransGroup.bottom = new FormAttachment(wStepname, 350); gTransGroup.setLayoutData(fdTransGroup); // // Add a tab folder for the parameters and various input and output // streams // wTabFolder = new CTabFolder(shell, SWT.BORDER); props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB); wTabFolder.setSimple(false); wTabFolder.setUnselectedCloseVisible(true); FormData fdTabFolder = new FormData(); fdTabFolder.left = new FormAttachment(0, 0); fdTabFolder.right = new FormAttachment(100, 0); fdTabFolder.top = new FormAttachment(gTransGroup, margin * 2); fdTabFolder.bottom = new FormAttachment(100, -75); wTabFolder.setLayoutData(fdTabFolder); // Now add buttons that will allow us to add or remove input or output // tabs... wAddInput = new Button(shell, SWT.PUSH); props.setLook(wAddInput); wAddInput.setText(Messages.getString("MappingFieldRunnerDialog.button.AddInput")); wAddInput.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { // Simply add a new MappingIODefinition object to the // inputMappings MappingIODefinition definition = new MappingIODefinition(); inputMappings.add(definition); int index = inputMappings.size() - 1; addInputMappingDefinitionTab(definition, index); } }); wAddOutput = new Button(shell, SWT.PUSH); props.setLook(wAddOutput); wAddOutput.setText(Messages.getString("MappingFieldRunnerDialog.button.AddOutput")); wAddOutput.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { // Simply add a new MappingIODefinition object to the // inputMappings MappingIODefinition definition = new MappingIODefinition(); outputMappings.add(definition); int index = outputMappings.size() - 1; addOutputMappingDefinitionTab(definition, index); } }); setButtonPositions(new Button[] {wAddInput, wAddOutput}, margin, wTabFolder); // Some buttons wOK = new Button(shell, SWT.PUSH); wOK.setText(Messages.getString("System.Button.OK")); // $NON-NLS-1$ wCancel = new Button(shell, SWT.PUSH); wCancel.setText(Messages.getString("System.Button.Cancel")); // $NON-NLS-1$ setButtonPositions(new Button[] {wOK, wCancel}, margin, null); // Add listeners lsCancel = new Listener() { public void handleEvent(Event e) { cancel(); } }; lsOK = new Listener() { public void handleEvent(Event e) { ok(); } }; wCancel.addListener(SWT.Selection, lsCancel); wOK.addListener(SWT.Selection, lsOK); lsDef = new SelectionAdapter() { public void widgetDefaultSelected(SelectionEvent e) { ok(); } }; wStepname.addSelectionListener(lsDef); wFieldname.addSelectionListener(lsDef); wExecuteForEachRow.addSelectionListener(lsDef); // Detect X or ALT-F4 or something that kills this window... shell.addShellListener( new ShellAdapter() { public void shellClosed(ShellEvent e) { cancel(); } }); // Set the shell size, based upon previous time... setSize(); getData(); getFields(); mappingMeta.setChanged(changed); wTabFolder.setSelection(0); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } return stepname; }
private void cancel() { stepname = null; mappingMeta.setChanged(changed); dispose(); }