use of org.pentaho.di.trans.step.jms.JmsConstants.PKG in project pentaho-kettle by pentaho.
the class JmsProducerDialog method open.
@Override
public String open() {
Shell parent = getParent();
Display display = parent.getDisplay();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.MIN | SWT.MAX | SWT.RESIZE);
props.setLook(shell);
setShellImage(shell, meta);
shell.setMinimumSize(SHELL_MIN_WIDTH, SHELL_MIN_HEIGHT);
changed = meta.hasChanged();
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = 15;
formLayout.marginHeight = 15;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "JmsProducerDialog.Shell.Title"));
Label wicon = new Label(shell, SWT.RIGHT);
wicon.setImage(getImage());
FormData fdlicon = new FormData();
fdlicon.top = new FormAttachment(0, 0);
fdlicon.right = new FormAttachment(100, 0);
wicon.setLayoutData(fdlicon);
props.setLook(wicon);
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "JmsProducerDialog.Stepname.Label"));
props.setLook(wlStepname);
fdlStepname = new FormData();
fdlStepname.left = new FormAttachment(0, 0);
fdlStepname.top = new FormAttachment(0, 0);
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.width = 250;
fdStepname.left = new FormAttachment(0, 0);
fdStepname.top = new FormAttachment(wlStepname, 5);
wStepname.setLayoutData(fdStepname);
Label spacer = new Label(shell, SWT.HORIZONTAL | SWT.SEPARATOR);
props.setLook(spacer);
FormData fdSpacer = new FormData();
fdSpacer.height = 2;
fdSpacer.left = new FormAttachment(0, 0);
fdSpacer.top = new FormAttachment(wStepname, 15);
fdSpacer.right = new FormAttachment(100, 0);
fdSpacer.width = 497;
spacer.setLayoutData(fdSpacer);
// Start of tabbed display
wTabFolder = new CTabFolder(shell, SWT.BORDER);
props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
wTabFolder.setSimple(false);
wTabFolder.setUnselectedCloseVisible(true);
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
FormData fdCancel = new FormData();
fdCancel.right = new FormAttachment(100, 0);
fdCancel.bottom = new FormAttachment(100, 0);
wCancel.setLayoutData(fdCancel);
wOK = new Button(shell, SWT.PUSH);
wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
FormData fdOk = new FormData();
fdOk.right = new FormAttachment(wCancel, -5);
fdOk.bottom = new FormAttachment(100, 0);
wOK.setLayoutData(fdOk);
Label hSpacer = new Label(shell, SWT.HORIZONTAL | SWT.SEPARATOR);
props.setLook(hSpacer);
FormData fdhSpacer = new FormData();
fdhSpacer.height = 2;
fdhSpacer.left = new FormAttachment(0, 0);
fdhSpacer.bottom = new FormAttachment(wCancel, -15);
fdhSpacer.right = new FormAttachment(100, 0);
hSpacer.setLayoutData(fdhSpacer);
FormData fdTabFolder = new FormData();
fdTabFolder.left = new FormAttachment(0, 0);
fdTabFolder.top = new FormAttachment(spacer, 15);
fdTabFolder.bottom = new FormAttachment(hSpacer, -15);
fdTabFolder.right = new FormAttachment(100, 0);
wTabFolder.setLayoutData(fdTabFolder);
// Setup Tab
wSetupTab = new CTabItem(wTabFolder, SWT.NONE);
wSetupTab.setText(BaseMessages.getString(PKG, "JmsProducerDialog.SetupTab"));
wSetupComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wSetupComp);
FormLayout setupLayout = new FormLayout();
setupLayout.marginHeight = 15;
setupLayout.marginWidth = 15;
wSetupComp.setLayout(setupLayout);
connectionForm = new ConnectionForm(wSetupComp, props, transMeta, lsMod, jmsDelegate);
Group group = connectionForm.layoutForm();
destinationForm = new DestinationForm(wSetupComp, group, props, transMeta, lsMod, jmsDelegate.destinationType, jmsDelegate.destinationName);
Composite destinationFormComposite = destinationForm.layoutForm();
Label lbMessageField = new Label(wSetupComp, SWT.LEFT);
props.setLook(lbMessageField);
lbMessageField.setText(getString(PKG, "JmsProducerDialog.MessageField"));
FormData fdMessage = new FormData();
fdMessage.left = new FormAttachment(0, 0);
fdMessage.top = new FormAttachment(destinationFormComposite, 15);
fdMessage.width = 250;
lbMessageField.setLayoutData(fdMessage);
wMessageField = new ComboVar(transMeta, wSetupComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wMessageField);
wMessageField.addModifyListener(lsMod);
FormData fdMessageField = new FormData();
fdMessageField.left = new FormAttachment(0, 0);
fdMessageField.top = new FormAttachment(lbMessageField, 5);
fdMessageField.width = 250;
wMessageField.setLayoutData(fdMessageField);
Listener lsMessageFocus = e -> {
String current = wMessageField.getText();
wMessageField.getCComboWidget().removeAll();
wMessageField.setText(current);
try {
RowMetaInterface rmi = transMeta.getPrevStepFields(meta.getParentStepMeta().getName());
List ls = rmi.getValueMetaList();
for (Object l : ls) {
ValueMetaBase vmb = (ValueMetaBase) l;
wMessageField.add(vmb.getName());
}
} catch (KettleStepException ex) {
// do nothing
}
};
wMessageField.getCComboWidget().addListener(SWT.FocusIn, lsMessageFocus);
FormData fdSetupComp = new FormData();
fdSetupComp.left = new FormAttachment(0, 0);
fdSetupComp.top = new FormAttachment(0, 0);
fdSetupComp.right = new FormAttachment(100, 0);
fdSetupComp.bottom = new FormAttachment(100, 0);
wSetupComp.setLayoutData(fdSetupComp);
wSetupComp.layout();
wSetupTab.setControl(wSetupComp);
wTabFolder.setSelection(0);
wOK.addListener(SWT.Selection, lsOK);
wCancel.addListener(SWT.Selection, lsCancel);
// get data for message field, other fields data is loaded by the forms
wMessageField.setText(nullToEmpty(meta.getFieldToSend()));
setSize();
meta.setChanged(changed);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
Aggregations