package com.cdsf.kettle.plugin.rabbitmq;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.events.*;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.*;
import org.pentaho.di.core.Const;
import org.pentaho.di.core.Props;
import org.pentaho.di.i18n.BaseMessages;
import org.pentaho.di.trans.TransMeta;
import org.pentaho.di.trans.step.BaseStepMeta;
import org.pentaho.di.trans.step.StepDialogInterface;
import org.pentaho.di.ui.core.widget.LabelComboVar;
import org.pentaho.di.ui.core.widget.LabelTextVar;
import org.pentaho.di.ui.trans.step.BaseStepDialog;
/**
* @author leidd Create on 2019/11/15 17:29
*/
public class RabbitMQConsumerDialog extends BaseStepDialog implements StepDialogInterface {
private static Class<?> PKG = RabbitMQConsumerMeta.class;
private RabbitMQConsumerMeta meta;
private ModifyListener lsMod;
private CTabFolder wTabFolder;
private Group wConnGroup;
private Group wDestGroup;
private Group wOutputGroup;
private LabelTextVar wHost;
private LabelTextVar wPort;
private LabelTextVar wVirtualHost;
private LabelTextVar wUsername;
private LabelTextVar wPassword;
private LabelTextVar wQueueName;
private LabelComboVar wMessageType;
private LabelTextVar wMessageField;
public RabbitMQConsumerDialog(Shell parent, Object in, TransMeta transMeta, String sname) {
super(parent, (BaseStepMeta) in, transMeta, sname);
meta = (RabbitMQConsumerMeta) in;
}
@Override
public String open() {
Shell parent = getParent();
Display display = parent.getDisplay();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
props.setLook(shell);
setShellImage(shell, meta);
lsMod = e -> meta.setChanged();
changed = meta.hasChanged();
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "RabbitMQConsumer.TypeLongDesc"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "System.Label.StepName"));
props.setLook(wlStepname);
fdlStepname = new FormData();
fdlStepname.left = new FormAttachment(0, 0);
fdlStepname.top = new FormAttachment(0, margin);
fdlStepname.right = new FormAttachment(middle, -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);
Composite wGeneralComp = new Composite(shell, SWT.NONE);
props.setLook(wGeneralComp);
FormLayout generalLayout = new FormLayout();
generalLayout.marginWidth = 3;
generalLayout.marginHeight = 3;
wGeneralComp.setLayout(generalLayout);
wTabFolder = new CTabFolder(shell, SWT.BORDER);
props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
addGeneralTab();
// ////////////
// BUTTONS //
// //////////
wOK = new Button(shell, SWT.PUSH);
wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
setButtonPositions(new Button[]{wOK, wCancel}, margin, null);
FormData fdTabFolder = new FormData();
fdTabFolder.left = new FormAttachment(0, 0);
fdTabFolder.top = new FormAttachment(wStepname, margin);
fdTabFolder.right = new FormAttachment(100, 0);
fdTabFolder.bottom = new FormAttachment(wOK, -margin);
wTabFolder.setLayoutData(fdTabFolder);
// //////////////////
// Std Listeners //
// ////////////////
addStandardListeners();
wTabFolder.setSelection(0);
// Set the shell size, based upon previous time...
setSize();
getData(meta);
meta.setChanged(changed);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
private void addGeneralTab() {
CTabItem wGeneralTab = new CTabItem(wTabFolder, SWT.NONE);
wGeneralTab.setText("General");
Composite wGeneralComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wGeneralComp);
FormLayout generalLayout = new FormLayout();
generalLayout.marginWidth = 3;
generalLayout.marginHeight = 3;
wGeneralComp.setLayout(generalLayout);
// Connection
fillConnectionGroup(wGeneralComp);
// Destination GROUP
fillDestinationGroup(wGeneralComp);
fillOutputGroup(wGeneralComp);
FormData fdGeneralComp = new FormData();
fdGeneralComp.left = new FormAttachment(0, 0);
fdGeneralComp.top = new FormAttachment(wStepname, Const.MARGIN);
fdGeneralComp.right = new FormAttachment(100, 0);
fdGeneralComp.bottom = new FormAttachment(100, 0);
wGeneralComp.setLayoutData(fdGeneralComp);
wGeneralComp.layout();
wGeneralTab.setControl(wGeneralComp);
}
private void fillConnectionGroup(Composite parentTab) {
wConnGroup = new Group(parentTab, SWT.SHADOW_NONE);
props.setLook(wConnGroup);
wConnGroup.setText(BaseMessages.getString(PKG, "RabbitMQConsumer.group.connection"));
FormLayout connGroupLayout = new FormLayout();
connGroupLayout.marginWidth = 10;
connGroupLayout.marginHeight = 10;
wConnGroup.setLayout(connGroupLayout);
// host
wHost = new LabelTextVar(transMeta, wConnGroup, BaseMessages.getString(PKG, "RabbitMQConsumer.host"), "host");
wHost.addModifyListener(lsMod);
// port
wPort = new LabelTextVar(transMeta, wConnGroup, BaseMessages.getString(PKG, "RabbitMQConsumer.port"), "port");
wPort.addModifyListener(lsMod);
// virtualHost
wVirtualHost = new LabelTextVar(transMeta, wConnGroup, BaseMessages.getString(PKG, "RabbitMQConsumer.virtualHost"), "virtualHost");
wVirtualHost.addModifyListener(lsMod);
// username
wUsername = new LabelTextVar(transMeta, wConnGroup, BaseMessages.getString(PKG, "RabbitMQConsumer.username"), "username");
wUsername.addModifyListener(lsMod);
// password
wPassword = new LabelTextVar(transMeta, wConnGroup, BaseMessages.getString(PKG, "RabbitMQConsumer.password"), "password", true);
wPassword.addModifyListener(lsMod);
// Test button
Button wTest = new Button(wConnGroup, SWT.PUSH);
wTest.setText(BaseMessages.getString(PKG, "RabbitMQConsumer.testConnect"));
wTest.setToolTipText(BaseMessages.getString(PKG, "RabbitMQConsumer.connectOk"));
wTest.addListener(SWT.Selection, arg0 -> testConnect());
Control[] Controls = new Control[]{wHost, wPort, wVirtualHost, wUsername, wPassword};
placeControls(wConnGroup, Controls);
BaseStepDialog.positionBottomButtons(wConnGroup, new Button[]{wTest}, Const.MARGIN, wPassword);
FormData fdGrou
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
kettle-rabbitmq.rar (8个子文件)
kettle-rabbitmq
pom.xml 2KB
src
main
resources
rabbitmq.png 1012B
com
cdsf
kettle
plugin
rabbitmq
messages
messages_en_US.properties 839B
messages_zh_CN.properties 1023B
java
com
cdsf
kettle
plugin
rabbitmq
RabbitMQConsumerData.java 582B
RabbitMQConsumer.java 4KB
RabbitMQConsumerMeta.java 8KB
RabbitMQConsumerDialog.java 15KB
共 8 条
- 1
资源评论
liaolimingyzy
- 粉丝: 2
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功