Search in sources :

Example 16 with ComboVar

use of org.apache.hop.ui.core.widget.ComboVar in project hop by apache.

the class WebServiceEditor method createControl.

@Override
public void createControl(Composite parent) {
    PropsUi props = PropsUi.getInstance();
    int middle = props.getMiddlePct();
    int margin = props.getMargin();
    Label wIcon = new Label(parent, 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);
    // What's the name
    Label wlName = new Label(parent, SWT.RIGHT);
    props.setLook(wlName);
    wlName.setText(BaseMessages.getString(PKG, "WebServiceEditor.Name.Label"));
    FormData fdlName = new FormData();
    fdlName.top = new FormAttachment(wIcon, margin);
    fdlName.left = new FormAttachment(0, 0);
    fdlName.right = new FormAttachment(middle, 0);
    wlName.setLayoutData(fdlName);
    wName = new Text(parent, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wName);
    FormData fdName = new FormData();
    fdName.top = new FormAttachment(wlName, 0, SWT.CENTER);
    fdName.left = new FormAttachment(middle, margin);
    fdName.right = new FormAttachment(100, 0);
    wName.setLayoutData(fdName);
    Label spacer = new Label(parent, SWT.HORIZONTAL | SWT.SEPARATOR);
    FormData fdSpacer = new FormData();
    fdSpacer.left = new FormAttachment(0, 0);
    fdSpacer.top = new FormAttachment(wName, 15);
    fdSpacer.right = new FormAttachment(100, 0);
    spacer.setLayoutData(fdSpacer);
    Control lastControl = spacer;
    // Enabled?
    // 
    Label wlEnabled = new Label(parent, SWT.RIGHT);
    props.setLook(wlEnabled);
    wlEnabled.setText(BaseMessages.getString(PKG, "WebServiceEditor.Enabled.Label"));
    FormData fdlEnabled = new FormData();
    fdlEnabled.left = new FormAttachment(0, 0);
    fdlEnabled.right = new FormAttachment(middle, 0);
    fdlEnabled.top = new FormAttachment(lastControl, margin);
    wlEnabled.setLayoutData(fdlEnabled);
    wEnabled = new Button(parent, SWT.CHECK | SWT.LEFT);
    props.setLook(wEnabled);
    FormData fdEnabled = new FormData();
    fdEnabled.left = new FormAttachment(middle, margin);
    fdEnabled.right = new FormAttachment(100, 0);
    fdEnabled.top = new FormAttachment(wlEnabled, 0, SWT.CENTER);
    wEnabled.setLayoutData(fdEnabled);
    lastControl = wlEnabled;
    Label wlFilename = new Label(parent, SWT.RIGHT);
    props.setLook(wlFilename);
    wlFilename.setText(BaseMessages.getString(PKG, "WebServiceEditor.Filename.Label"));
    FormData fdlFilename = new FormData();
    fdlFilename.left = new FormAttachment(0, 0);
    fdlFilename.right = new FormAttachment(middle, 0);
    fdlFilename.top = new FormAttachment(lastControl, 2 * margin);
    wlFilename.setLayoutData(fdlFilename);
    Button wbbFilename = new Button(parent, SWT.PUSH);
    props.setLook(wbbFilename);
    wbbFilename.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
    FormData fdbbFilename = new FormData();
    fdbbFilename.right = new FormAttachment(100, 0);
    fdbbFilename.top = new FormAttachment(wlFilename, 0, SWT.CENTER);
    wbbFilename.setLayoutData(fdbbFilename);
    wbbFilename.addListener(SWT.Selection, e -> selectPipelineFilename(parent));
    Button wbnFilename = new Button(parent, SWT.PUSH);
    props.setLook(wbnFilename);
    wbnFilename.setText(BaseMessages.getString(PKG, "System.Button.New"));
    FormData fdbnFilename = new FormData();
    fdbnFilename.right = new FormAttachment(wbbFilename, -margin);
    fdbnFilename.top = new FormAttachment(wlFilename, 0, SWT.CENTER);
    wbnFilename.setLayoutData(fdbnFilename);
    wbnFilename.addListener(SWT.Selection, e -> createPipelineFile(parent));
    Button wboFilename = new Button(parent, SWT.PUSH);
    props.setLook(wboFilename);
    wboFilename.setText(BaseMessages.getString(PKG, "System.Button.Open"));
    FormData fdboFilename = new FormData();
    fdboFilename.right = new FormAttachment(wbnFilename, -margin);
    fdboFilename.top = new FormAttachment(wlFilename, 0, SWT.CENTER);
    wboFilename.setLayoutData(fdboFilename);
    wboFilename.addListener(SWT.Selection, e -> openPipelineFile(parent));
    wFilename = new TextVar(manager.getVariables(), parent, SWT.SINGLE | SWT.BORDER | SWT.LEFT);
    props.setLook(wFilename);
    FormData fdFilename = new FormData();
    fdFilename.left = new FormAttachment(middle, margin);
    fdFilename.right = new FormAttachment(wboFilename, -margin);
    fdFilename.top = new FormAttachment(wlFilename, 0, SWT.CENTER);
    wFilename.setLayoutData(fdFilename);
    lastControl = wlFilename;
    // Transform name
    // 
    Label wlTransform = new Label(parent, SWT.RIGHT);
    props.setLook(wlTransform);
    wlTransform.setText(BaseMessages.getString(PKG, "WebServiceEditor.Transform.Label"));
    FormData fdlTransform = new FormData();
    fdlTransform.left = new FormAttachment(0, 0);
    fdlTransform.right = new FormAttachment(middle, 0);
    fdlTransform.top = new FormAttachment(lastControl, 2 * margin);
    wlTransform.setLayoutData(fdlTransform);
    wTransform = new TextVar(manager.getVariables(), parent, SWT.SINGLE | SWT.BORDER | SWT.LEFT);
    props.setLook(wTransform);
    FormData fdTransform = new FormData();
    fdTransform.left = new FormAttachment(middle, margin);
    fdTransform.right = new FormAttachment(100, 0);
    fdTransform.top = new FormAttachment(wlTransform, 0, SWT.CENTER);
    wTransform.setLayoutData(fdTransform);
    lastControl = wlTransform;
    // Transform name
    // 
    Label wlField = new Label(parent, SWT.RIGHT);
    props.setLook(wlField);
    wlField.setText(BaseMessages.getString(PKG, "WebServiceEditor.Field.Label"));
    FormData fdlField = new FormData();
    fdlField.left = new FormAttachment(0, 0);
    fdlField.right = new FormAttachment(middle, 0);
    fdlField.top = new FormAttachment(lastControl, 2 * margin);
    wlField.setLayoutData(fdlField);
    wField = new TextVar(manager.getVariables(), parent, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wField);
    FormData fdField = new FormData();
    fdField.left = new FormAttachment(middle, margin);
    fdField.right = new FormAttachment(100, 0);
    fdField.top = new FormAttachment(wlField, 0, SWT.CENTER);
    wField.setLayoutData(fdField);
    lastControl = wlField;
    // Content type
    // 
    Label wlContentType = new Label(parent, SWT.RIGHT);
    props.setLook(wlContentType);
    wlContentType.setText(BaseMessages.getString(PKG, "WebServiceEditor.ContentType.Label"));
    FormData fdlContentType = new FormData();
    fdlContentType.left = new FormAttachment(0, 0);
    fdlContentType.right = new FormAttachment(middle, 0);
    fdlContentType.top = new FormAttachment(lastControl, 2 * margin);
    wlContentType.setLayoutData(fdlContentType);
    wContentType = new ComboVar(manager.getVariables(), parent, SWT.LEFT | SWT.BORDER);
    props.setLook(wContentType);
    FormData fdContentType = new FormData();
    fdContentType.left = new FormAttachment(middle, margin);
    fdContentType.right = new FormAttachment(100, 0);
    fdContentType.top = new FormAttachment(wlContentType, 0, SWT.CENTER);
    wContentType.setLayoutData(fdContentType);
    wContentType.add(ContentType.TEXT_PLAIN.getMimeType());
    wContentType.add(ContentType.APPLICATION_JSON.getMimeType());
    wContentType.add(ContentType.APPLICATION_XML.getMimeType());
    wContentType.add(ContentType.TEXT_HTML.getMimeType());
    lastControl = wlContentType;
    // List status?
    // 
    Label wlListStatus = new Label(parent, SWT.RIGHT);
    props.setLook(wlListStatus);
    wlListStatus.setText(BaseMessages.getString(PKG, "WebServiceEditor.ListStatus.Label"));
    FormData fdlListStatus = new FormData();
    fdlListStatus.left = new FormAttachment(0, 0);
    fdlListStatus.right = new FormAttachment(middle, 0);
    fdlListStatus.top = new FormAttachment(lastControl, margin);
    wlListStatus.setLayoutData(fdlListStatus);
    wListStatus = new Button(parent, SWT.CHECK | SWT.LEFT);
    props.setLook(wListStatus);
    FormData fdListStatus = new FormData();
    fdListStatus.left = new FormAttachment(middle, margin);
    fdListStatus.right = new FormAttachment(100, 0);
    fdListStatus.top = new FormAttachment(wlListStatus, 0, SWT.CENTER);
    wListStatus.setLayoutData(fdListStatus);
    setWidgetsContent();
    // Add listener to detect change after loading data
    Listener modifyListener = e -> setChanged();
    wName.addListener(SWT.Modify, modifyListener);
    wEnabled.addListener(SWT.Selection, modifyListener);
    wFilename.addListener(SWT.Modify, modifyListener);
    wTransform.addListener(SWT.Modify, modifyListener);
    wField.addListener(SWT.Modify, modifyListener);
    wContentType.addListener(SWT.Modify, modifyListener);
    wListStatus.addListener(SWT.Selection, modifyListener);
}
Also used : FormData(org.eclipse.swt.layout.FormData) StringUtils(org.apache.commons.lang.StringUtils) HopPipelineFileType(org.apache.hop.ui.hopgui.file.pipeline.HopPipelineFileType) IVariables(org.apache.hop.core.variables.IVariables) IHopMetadataProvider(org.apache.hop.metadata.api.IHopMetadataProvider) MetadataEditor(org.apache.hop.ui.core.metadata.MetadataEditor) HopGui(org.apache.hop.ui.hopgui.HopGui) NotePadMeta(org.apache.hop.core.NotePadMeta) PipelineMeta(org.apache.hop.pipeline.PipelineMeta) IRowMeta(org.apache.hop.core.row.IRowMeta) BaseMessages(org.apache.hop.i18n.BaseMessages) BaseDialog(org.apache.hop.ui.core.dialog.BaseDialog) FormData(org.eclipse.swt.layout.FormData) ContentType(org.apache.http.entity.ContentType) org.eclipse.swt.widgets(org.eclipse.swt.widgets) FormAttachment(org.eclipse.swt.layout.FormAttachment) EnterSelectionDialog(org.apache.hop.ui.core.dialog.EnterSelectionDialog) Const(org.apache.hop.core.Const) PropsUi(org.apache.hop.ui.core.PropsUi) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) HopDataOrchestrationPerspective(org.apache.hop.ui.hopgui.perspective.dataorch.HopDataOrchestrationPerspective) ComboVar(org.apache.hop.ui.core.widget.ComboVar) TextVar(org.apache.hop.ui.core.widget.TextVar) SWT(org.eclipse.swt.SWT) MetadataManager(org.apache.hop.ui.core.metadata.MetadataManager) WebService(org.apache.hop.www.service.WebService) ComboVar(org.apache.hop.ui.core.widget.ComboVar) FormAttachment(org.eclipse.swt.layout.FormAttachment) PropsUi(org.apache.hop.ui.core.PropsUi) TextVar(org.apache.hop.ui.core.widget.TextVar)

Example 17 with ComboVar

use of org.apache.hop.ui.core.widget.ComboVar in project hop by apache.

the class WorkflowRunConfigurationEditor method createControl.

@Override
public void createControl(Composite parent) {
    PropsUi props = PropsUi.getInstance();
    // Create a tabbed interface instead of the confusing left hand side options
    // This will make it more conforming the rest.
    // 
    int middle = props.getMiddlePct();
    int margin = props.getMargin();
    // The generic widgets: name, description and workflow engine type
    // 
    // What's the name
    // 
    Label wlName = new Label(parent, SWT.RIGHT);
    props.setLook(wlName);
    wlName.setText(BaseMessages.getString(PKG, "WorkflowRunConfigurationDialog.label.name"));
    FormData fdlName = new FormData();
    fdlName.top = new FormAttachment(0, margin * 2);
    // First one in the left top corner
    fdlName.left = new FormAttachment(0, 0);
    fdlName.right = new FormAttachment(middle, 0);
    wlName.setLayoutData(fdlName);
    wName = new Text(parent, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wName);
    FormData fdName = new FormData();
    fdName.top = new FormAttachment(wlName, 0, SWT.CENTER);
    // To the right of the label
    fdName.left = new FormAttachment(middle, margin);
    fdName.right = new FormAttachment(100, 0);
    wName.setLayoutData(fdName);
    Control lastControl = wName;
    Label wlDescription = new Label(parent, SWT.RIGHT);
    props.setLook(wlDescription);
    wlDescription.setText(BaseMessages.getString(PKG, "WorkflowRunConfigurationDialog.label.Description"));
    FormData fdlDescription = new FormData();
    fdlDescription.top = new FormAttachment(lastControl, margin * 2);
    // First one in the left top corner
    fdlDescription.left = new FormAttachment(0, 0);
    fdlDescription.right = new FormAttachment(middle, 0);
    wlDescription.setLayoutData(fdlDescription);
    wDescription = new Text(parent, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wDescription);
    FormData fdDescription = new FormData();
    fdDescription.top = new FormAttachment(wlDescription, 0, SWT.CENTER);
    // To the right of the label
    fdDescription.left = new FormAttachment(middle, margin);
    fdDescription.right = new FormAttachment(100, 0);
    wDescription.setLayoutData(fdDescription);
    lastControl = wDescription;
    // What's the type of engine?
    // 
    Label wlPluginType = new Label(parent, SWT.RIGHT);
    props.setLook(wlPluginType);
    wlPluginType.setText(BaseMessages.getString(PKG, "WorkflowRunConfigurationDialog.label.EngineType"));
    FormData fdlPluginType = new FormData();
    fdlPluginType.top = new FormAttachment(lastControl, margin * 2);
    // First one in the left top corner
    fdlPluginType.left = new FormAttachment(0, 0);
    fdlPluginType.right = new FormAttachment(middle, 0);
    wlPluginType.setLayoutData(fdlPluginType);
    wPluginType = new ComboVar(manager.getVariables(), parent, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wPluginType);
    wPluginType.setItems(getPluginTypes());
    FormData fdPluginType = new FormData();
    fdPluginType.top = new FormAttachment(wlPluginType, 0, SWT.CENTER);
    // To the right of the label
    fdPluginType.left = new FormAttachment(middle, margin);
    fdPluginType.right = new FormAttachment(100, 0);
    wPluginType.setLayoutData(fdPluginType);
    lastControl = wPluginType;
    // Add a composite area
    // 
    wPluginSpecificComp = new Composite(parent, SWT.BACKGROUND);
    props.setLook(wPluginSpecificComp);
    wPluginSpecificComp.setLayout(new FormLayout());
    FormData fdPluginSpecificComp = new FormData();
    fdPluginSpecificComp.left = new FormAttachment(0, 0);
    fdPluginSpecificComp.right = new FormAttachment(100, 0);
    fdPluginSpecificComp.top = new FormAttachment(lastControl, margin);
    fdPluginSpecificComp.bottom = new FormAttachment(100, 0);
    wPluginSpecificComp.setLayoutData(fdPluginSpecificComp);
    // Add the plugin specific widgets
    // 
    addGuiCompositeWidgets();
    setWidgetsContent();
    // Some widget set changed
    resetChanged();
    // Add listeners...
    // 
    wName.addListener(SWT.Modify, modifyListener);
    wDescription.addListener(SWT.Modify, modifyListener);
    wPluginType.addListener(SWT.Modify, modifyListener);
    wPluginType.addListener(SWT.Modify, e -> changeConnectionType());
}
Also used : FormData(org.eclipse.swt.layout.FormData) FormLayout(org.eclipse.swt.layout.FormLayout) ComboVar(org.apache.hop.ui.core.widget.ComboVar) FormAttachment(org.eclipse.swt.layout.FormAttachment) PropsUi(org.apache.hop.ui.core.PropsUi)

Example 18 with ComboVar

use of org.apache.hop.ui.core.widget.ComboVar in project hop by apache.

the class ProjectDialog method open.

public String open() {
    Shell parent = getParent();
    shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE);
    shell.setImage(GuiResource.getInstance().getImageHopUi());
    props.setLook(shell);
    int margin = Const.MARGIN + 2;
    int middle = Const.MIDDLE_PCT;
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;
    shell.setLayout(formLayout);
    shell.setText(BaseMessages.getString(PKG, "ProjectDialog.Shell.Name"));
    // Buttons go at the bottom of the dialog
    // 
    Button wOk = new Button(shell, SWT.PUSH);
    wOk.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    wOk.addListener(SWT.Selection, event -> ok());
    Button wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    wCancel.addListener(SWT.Selection, event -> cancel());
    BaseTransformDialog.positionBottomButtons(shell, new Button[] { wOk, wCancel }, margin * 3, null);
    Label wlName = new Label(shell, SWT.RIGHT);
    props.setLook(wlName);
    wlName.setText(BaseMessages.getString(PKG, "ProjectDialog.Label.ProjectName"));
    FormData fdlName = new FormData();
    fdlName.left = new FormAttachment(0, 0);
    fdlName.right = new FormAttachment(middle, 0);
    fdlName.top = new FormAttachment(0, margin);
    wlName.setLayoutData(fdlName);
    wName = new Text(shell, SWT.SINGLE | SWT.BORDER | SWT.LEFT);
    props.setLook(wName);
    FormData fdName = new FormData();
    fdName.left = new FormAttachment(middle, margin);
    fdName.right = new FormAttachment(100, 0);
    fdName.top = new FormAttachment(wlName, 0, SWT.CENTER);
    wName.setLayoutData(fdName);
    Control lastControl = wName;
    Label wlHome = new Label(shell, SWT.RIGHT);
    props.setLook(wlHome);
    wlHome.setText(BaseMessages.getString(PKG, "ProjectDialog.Label.HomeFolder"));
    FormData fdlHome = new FormData();
    fdlHome.left = new FormAttachment(0, 0);
    fdlHome.right = new FormAttachment(middle, 0);
    fdlHome.top = new FormAttachment(lastControl, margin);
    wlHome.setLayoutData(fdlHome);
    Button wbHome = new Button(shell, SWT.PUSH);
    props.setLook(wbHome);
    wbHome.setText(BaseMessages.getString(PKG, "ProjectDialog.Button.Browse"));
    FormData fdbHome = new FormData();
    fdbHome.right = new FormAttachment(100, 0);
    fdbHome.top = new FormAttachment(wlHome, 0, SWT.CENTER);
    wbHome.setLayoutData(fdbHome);
    wbHome.addListener(SWT.Selection, this::browseHomeFolder);
    wHome = new TextVar(variables, shell, SWT.SINGLE | SWT.BORDER | SWT.LEFT);
    props.setLook(wHome);
    FormData fdHome = new FormData();
    fdHome.left = new FormAttachment(middle, margin);
    fdHome.right = new FormAttachment(wbHome, -margin);
    fdHome.top = new FormAttachment(wlHome, 0, SWT.CENTER);
    wHome.setLayoutData(fdHome);
    lastControl = wHome;
    Label wlConfigFile = new Label(shell, SWT.RIGHT);
    props.setLook(wlConfigFile);
    wlConfigFile.setText(BaseMessages.getString(PKG, "ProjectDialog.Label.ConfigurationFile"));
    FormData fdlConfigFile = new FormData();
    fdlConfigFile.left = new FormAttachment(0, 0);
    fdlConfigFile.right = new FormAttachment(middle, 0);
    fdlConfigFile.top = new FormAttachment(lastControl, margin);
    wlConfigFile.setLayoutData(fdlConfigFile);
    Button wbConfigFile = new Button(shell, SWT.PUSH);
    props.setLook(wbConfigFile);
    wbConfigFile.setText(BaseMessages.getString(PKG, "ProjectDialog.Button.Browse"));
    FormData fdbConfigFile = new FormData();
    fdbConfigFile.right = new FormAttachment(100, 0);
    fdbConfigFile.top = new FormAttachment(wlConfigFile, 0, SWT.CENTER);
    wbConfigFile.setLayoutData(fdbConfigFile);
    wbConfigFile.addListener(SWT.Selection, this::browseConfigFolder);
    wConfigFile = new TextVar(variables, shell, SWT.SINGLE | SWT.BORDER | SWT.LEFT);
    props.setLook(wConfigFile);
    FormData fdConfigFile = new FormData();
    fdConfigFile.left = new FormAttachment(middle, margin);
    fdConfigFile.right = new FormAttachment(wbConfigFile, -margin);
    fdConfigFile.top = new FormAttachment(wlConfigFile, 0, SWT.CENTER);
    wConfigFile.setLayoutData(fdConfigFile);
    lastControl = wConfigFile;
    Label wlParentProject = new Label(shell, SWT.RIGHT);
    props.setLook(wlParentProject);
    wlParentProject.setText(BaseMessages.getString(PKG, "ProjectDialog.Label.ParentProject"));
    FormData fdlParentProject = new FormData();
    fdlParentProject.left = new FormAttachment(0, 0);
    fdlParentProject.right = new FormAttachment(middle, 0);
    fdlParentProject.top = new FormAttachment(lastControl, margin);
    wlParentProject.setLayoutData(fdlParentProject);
    wParentProject = new ComboVar(variables, shell, SWT.SINGLE | SWT.BORDER | SWT.LEFT);
    props.setLook(wParentProject);
    FormData fdParentProject = new FormData();
    fdParentProject.left = new FormAttachment(middle, margin);
    fdParentProject.right = new FormAttachment(100, 0);
    fdParentProject.top = new FormAttachment(wlParentProject, 0, SWT.CENTER);
    wParentProject.setLayoutData(fdParentProject);
    lastControl = wParentProject;
    Label wlDescription = new Label(shell, SWT.RIGHT);
    props.setLook(wlDescription);
    wlDescription.setText(BaseMessages.getString(PKG, "ProjectDialog.Label.Description"));
    FormData fdlDescription = new FormData();
    fdlDescription.left = new FormAttachment(0, 0);
    fdlDescription.right = new FormAttachment(middle, 0);
    fdlDescription.top = new FormAttachment(lastControl, margin);
    wlDescription.setLayoutData(fdlDescription);
    wDescription = new Text(shell, SWT.SINGLE | SWT.BORDER | SWT.LEFT);
    props.setLook(wDescription);
    FormData fdDescription = new FormData();
    fdDescription.left = new FormAttachment(middle, margin);
    fdDescription.right = new FormAttachment(100, 0);
    fdDescription.top = new FormAttachment(wlDescription, 0, SWT.CENTER);
    wDescription.setLayoutData(fdDescription);
    lastControl = wDescription;
    Label wlCompany = new Label(shell, SWT.RIGHT);
    props.setLook(wlCompany);
    wlCompany.setText(BaseMessages.getString(PKG, "ProjectDialog.Label.Company"));
    FormData fdlCompany = new FormData();
    fdlCompany.left = new FormAttachment(0, 0);
    fdlCompany.right = new FormAttachment(middle, 0);
    fdlCompany.top = new FormAttachment(lastControl, margin);
    wlCompany.setLayoutData(fdlCompany);
    wCompany = new Text(shell, SWT.SINGLE | SWT.BORDER | SWT.LEFT);
    props.setLook(wCompany);
    FormData fdCompany = new FormData();
    fdCompany.left = new FormAttachment(middle, margin);
    fdCompany.right = new FormAttachment(100, 0);
    fdCompany.top = new FormAttachment(wlCompany, 0, SWT.CENTER);
    wCompany.setLayoutData(fdCompany);
    lastControl = wCompany;
    Label wlDepartment = new Label(shell, SWT.RIGHT);
    props.setLook(wlDepartment);
    wlDepartment.setText(BaseMessages.getString(PKG, "ProjectDialog.Label.Department"));
    FormData fdlDepartment = new FormData();
    fdlDepartment.left = new FormAttachment(0, 0);
    fdlDepartment.right = new FormAttachment(middle, 0);
    fdlDepartment.top = new FormAttachment(lastControl, margin);
    wlDepartment.setLayoutData(fdlDepartment);
    wDepartment = new Text(shell, SWT.SINGLE | SWT.BORDER | SWT.LEFT);
    props.setLook(wDepartment);
    FormData fdDepartment = new FormData();
    fdDepartment.left = new FormAttachment(middle, margin);
    fdDepartment.right = new FormAttachment(100, 0);
    fdDepartment.top = new FormAttachment(wlDepartment, 0, SWT.CENTER);
    wDepartment.setLayoutData(fdDepartment);
    lastControl = wDepartment;
    Label wlMetadataBaseFolder = new Label(shell, SWT.RIGHT);
    props.setLook(wlMetadataBaseFolder);
    wlMetadataBaseFolder.setText(BaseMessages.getString(PKG, "ProjectDialog.Label.MetadataBaseFolder"));
    FormData fdlMetadataBaseFolder = new FormData();
    fdlMetadataBaseFolder.left = new FormAttachment(0, 0);
    fdlMetadataBaseFolder.right = new FormAttachment(middle, 0);
    fdlMetadataBaseFolder.top = new FormAttachment(lastControl, margin);
    wlMetadataBaseFolder.setLayoutData(fdlMetadataBaseFolder);
    wMetadataBaseFolder = new TextVar(variables, shell, SWT.SINGLE | SWT.BORDER | SWT.LEFT);
    props.setLook(wMetadataBaseFolder);
    FormData fdMetadataBaseFolder = new FormData();
    fdMetadataBaseFolder.left = new FormAttachment(middle, margin);
    fdMetadataBaseFolder.right = new FormAttachment(100, 0);
    fdMetadataBaseFolder.top = new FormAttachment(wlMetadataBaseFolder, 0, SWT.CENTER);
    wMetadataBaseFolder.setLayoutData(fdMetadataBaseFolder);
    wMetadataBaseFolder.addModifyListener(e -> updateIVariables());
    lastControl = wMetadataBaseFolder;
    Label wlUnitTestsBasePath = new Label(shell, SWT.RIGHT);
    props.setLook(wlUnitTestsBasePath);
    wlUnitTestsBasePath.setText(BaseMessages.getString(PKG, "ProjectDialog.Label.UnitTestBaseFolder"));
    FormData fdlUnitTestsBasePath = new FormData();
    fdlUnitTestsBasePath.left = new FormAttachment(0, 0);
    fdlUnitTestsBasePath.right = new FormAttachment(middle, 0);
    fdlUnitTestsBasePath.top = new FormAttachment(lastControl, margin);
    wlUnitTestsBasePath.setLayoutData(fdlUnitTestsBasePath);
    wUnitTestsBasePath = new TextVar(variables, shell, SWT.SINGLE | SWT.BORDER | SWT.LEFT);
    props.setLook(wUnitTestsBasePath);
    FormData fdUnitTestsBasePath = new FormData();
    fdUnitTestsBasePath.left = new FormAttachment(middle, margin);
    fdUnitTestsBasePath.right = new FormAttachment(100, 0);
    fdUnitTestsBasePath.top = new FormAttachment(wlUnitTestsBasePath, 0, SWT.CENTER);
    wUnitTestsBasePath.setLayoutData(fdUnitTestsBasePath);
    wUnitTestsBasePath.addModifyListener(e -> updateIVariables());
    lastControl = wUnitTestsBasePath;
    Label wlDataSetCsvFolder = new Label(shell, SWT.RIGHT);
    props.setLook(wlDataSetCsvFolder);
    wlDataSetCsvFolder.setText(BaseMessages.getString(PKG, "ProjectDialog.Label.DatasetCSVFolder"));
    FormData fdlDataSetCsvFolder = new FormData();
    fdlDataSetCsvFolder.left = new FormAttachment(0, 0);
    fdlDataSetCsvFolder.right = new FormAttachment(middle, 0);
    fdlDataSetCsvFolder.top = new FormAttachment(lastControl, margin);
    wlDataSetCsvFolder.setLayoutData(fdlDataSetCsvFolder);
    wDataSetCsvFolder = new TextVar(variables, shell, SWT.SINGLE | SWT.BORDER | SWT.LEFT);
    props.setLook(wDataSetCsvFolder);
    FormData fdDataSetCsvFolder = new FormData();
    fdDataSetCsvFolder.left = new FormAttachment(middle, margin);
    fdDataSetCsvFolder.right = new FormAttachment(100, 0);
    fdDataSetCsvFolder.top = new FormAttachment(wlDataSetCsvFolder, 0, SWT.CENTER);
    wDataSetCsvFolder.setLayoutData(fdDataSetCsvFolder);
    wDataSetCsvFolder.addModifyListener(e -> updateIVariables());
    lastControl = wDataSetCsvFolder;
    Label wlEnforceHomeExecution = new Label(shell, SWT.RIGHT);
    props.setLook(wlEnforceHomeExecution);
    wlEnforceHomeExecution.setText(BaseMessages.getString(PKG, "ProjectDialog.Label.EnforceExecutionInHome"));
    FormData fdlEnforceHomeExecution = new FormData();
    fdlEnforceHomeExecution.left = new FormAttachment(0, 0);
    fdlEnforceHomeExecution.right = new FormAttachment(middle, 0);
    fdlEnforceHomeExecution.top = new FormAttachment(lastControl, margin);
    wlEnforceHomeExecution.setLayoutData(fdlEnforceHomeExecution);
    wEnforceHomeExecution = new Button(shell, SWT.CHECK | SWT.LEFT);
    props.setLook(wEnforceHomeExecution);
    FormData fdEnforceHomeExecution = new FormData();
    fdEnforceHomeExecution.left = new FormAttachment(middle, margin);
    fdEnforceHomeExecution.right = new FormAttachment(100, 0);
    fdEnforceHomeExecution.top = new FormAttachment(wlEnforceHomeExecution, 0, SWT.CENTER);
    wEnforceHomeExecution.setLayoutData(fdEnforceHomeExecution);
    lastControl = wlEnforceHomeExecution;
    Label wlVariables = new Label(shell, SWT.LEFT);
    props.setLook(wlVariables);
    wlVariables.setText(BaseMessages.getString(PKG, "ProjectDialog.Group.Label.ProjectVariablesToSet"));
    FormData fdlVariables = new FormData();
    fdlVariables.left = new FormAttachment(0, 0);
    fdlVariables.right = new FormAttachment(100, 0);
    fdlVariables.top = new FormAttachment(lastControl, 2 * margin);
    wlVariables.setLayoutData(fdlVariables);
    ColumnInfo[] columnInfo = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "ProjectDialog.DetailTable.Label.VariableName"), ColumnInfo.COLUMN_TYPE_TEXT, false, false), new ColumnInfo(BaseMessages.getString(PKG, "ProjectDialog.DetailTable.Label.VariableValue"), ColumnInfo.COLUMN_TYPE_TEXT, false, false), new ColumnInfo(BaseMessages.getString(PKG, "ProjectDialog.DetailTable.Label.VariableDescription"), ColumnInfo.COLUMN_TYPE_TEXT, false, false) };
    columnInfo[0].setUsingVariables(true);
    columnInfo[1].setUsingVariables(true);
    wVariables = new TableView(new Variables(), shell, SWT.BORDER, columnInfo, project.getDescribedVariables().size(), null, props);
    props.setLook(wVariables);
    FormData fdVariables = new FormData();
    fdVariables.left = new FormAttachment(0, 0);
    fdVariables.right = new FormAttachment(100, 0);
    fdVariables.top = new FormAttachment(wlVariables, margin);
    fdVariables.bottom = new FormAttachment(wOk, -margin * 2);
    wVariables.setLayoutData(fdVariables);
    wVariables.addModifyListener(e -> needingProjectRefresh = true);
    // See if we need a project refresh/reload
    // 
    wParentProject.addModifyListener(e -> needingProjectRefresh = true);
    wHome.addModifyListener(e -> needingProjectRefresh = true);
    getData();
    BaseDialog.defaultShellHandling(shell, c -> ok(), c -> cancel());
    return returnValue;
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) ComboVar(org.apache.hop.ui.core.widget.ComboVar) ColumnInfo(org.apache.hop.ui.core.widget.ColumnInfo) TextVar(org.apache.hop.ui.core.widget.TextVar) IVariables(org.apache.hop.core.variables.IVariables) Variables(org.apache.hop.core.variables.Variables) FormAttachment(org.eclipse.swt.layout.FormAttachment) TableView(org.apache.hop.ui.core.widget.TableView)

Example 19 with ComboVar

use of org.apache.hop.ui.core.widget.ComboVar in project hop by apache.

the class FakeDialog method open.

@Override
public String open() {
    Shell parent = getParent();
    shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
    props.setLook(shell);
    setShellImage(shell, input);
    ModifyListener lsMod = e -> input.setChanged();
    changed = input.hasChanged();
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;
    shell.setLayout(formLayout);
    shell.setText(BaseMessages.getString(PKG, "FakeDialog.DialogTitle"));
    int middle = props.getMiddlePct();
    int margin = props.getMargin();
    // Filename line
    wlTransformName = new Label(shell, SWT.RIGHT);
    wlTransformName.setText(BaseMessages.getString(PKG, "System.Label.TransformName"));
    props.setLook(wlTransformName);
    fdlTransformName = new FormData();
    fdlTransformName.left = new FormAttachment(0, 0);
    fdlTransformName.right = new FormAttachment(middle, -margin);
    fdlTransformName.top = new FormAttachment(0, margin);
    wlTransformName.setLayoutData(fdlTransformName);
    wTransformName = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wTransformName.setText(transformName);
    props.setLook(wTransformName);
    wTransformName.addModifyListener(lsMod);
    fdTransformName = new FormData();
    fdTransformName.left = new FormAttachment(middle, 0);
    fdTransformName.top = new FormAttachment(0, margin);
    fdTransformName.right = new FormAttachment(100, 0);
    wTransformName.setLayoutData(fdTransformName);
    // Locale line
    Label wlLocale = new Label(shell, SWT.RIGHT);
    wlLocale.setText(BaseMessages.getString(PKG, "FakeDialog.Label.Locale"));
    props.setLook(wlLocale);
    FormData fdlLocale = new FormData();
    fdlLocale.left = new FormAttachment(0, 0);
    fdlLocale.right = new FormAttachment(middle, -margin);
    fdlLocale.top = new FormAttachment(wTransformName, margin);
    wlLocale.setLayoutData(fdlLocale);
    wLocale = new ComboVar(variables, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wLocale.setItems(FakeMeta.getFakerLocales());
    wLocale.setText(transformName);
    props.setLook(wLocale);
    wLocale.addModifyListener(lsMod);
    FormData fdLocale = new FormData();
    fdLocale.left = new FormAttachment(middle, 0);
    fdLocale.top = new FormAttachment(wlLocale, 0, SWT.CENTER);
    fdLocale.right = new FormAttachment(100, 0);
    wLocale.setLayoutData(fdLocale);
    wOk = new Button(shell, SWT.PUSH);
    wOk.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    wOk.addListener(SWT.Selection, e -> ok());
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    wCancel.addListener(SWT.Selection, e -> cancel());
    setButtonPositions(new Button[] { wOk, wCancel }, margin, null);
    ColumnInfo[] columns = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "FakeDialog.Name.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "FakeDialog.Type.Column"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[0]), new ColumnInfo(BaseMessages.getString(PKG, "FakeDialog.Topic.Column"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[0]) };
    columns[1].setComboValuesSelectionListener(this::getComboValues);
    columns[2].setComboValuesSelectionListener(this::getComboValues);
    wFields = new TableView(variables, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, columns, input.getFields().size(), lsMod, props);
    FormData fdFields = new FormData();
    fdFields.left = new FormAttachment(0, 0);
    fdFields.top = new FormAttachment(wLocale, 2 * margin);
    fdFields.right = new FormAttachment(100, 0);
    fdFields.bottom = new FormAttachment(wOk, -2 * margin);
    wFields.setLayoutData(fdFields);
    lsResize = event -> {
        Point size = shell.getSize();
        wFields.setSize(size.x - 10, size.y - 50);
        wFields.table.setSize(size.x - 10, size.y - 50);
        wFields.redraw();
    };
    shell.addListener(SWT.Resize, lsResize);
    getData();
    input.setChanged(changed);
    BaseDialog.defaultShellHandling(shell, c -> ok(), c -> cancel());
    return transformName;
}
Also used : Utils(org.apache.hop.core.util.Utils) ColumnInfo(org.apache.hop.ui.core.widget.ColumnInfo) BaseMessages(org.apache.hop.i18n.BaseMessages) TableView(org.apache.hop.ui.core.widget.TableView) FormLayout(org.eclipse.swt.layout.FormLayout) IVariables(org.apache.hop.core.variables.IVariables) BaseDialog(org.apache.hop.ui.core.dialog.BaseDialog) FormData(org.eclipse.swt.layout.FormData) org.eclipse.swt.widgets(org.eclipse.swt.widgets) BaseTransformMeta(org.apache.hop.pipeline.transform.BaseTransformMeta) FormAttachment(org.eclipse.swt.layout.FormAttachment) Const(org.apache.hop.core.Const) Point(org.eclipse.swt.graphics.Point) ITransformDialog(org.apache.hop.pipeline.transform.ITransformDialog) List(java.util.List) ComboVar(org.apache.hop.ui.core.widget.ComboVar) ModifyListener(org.eclipse.swt.events.ModifyListener) SWT(org.eclipse.swt.SWT) PipelineMeta(org.apache.hop.pipeline.PipelineMeta) Method(java.lang.reflect.Method) BaseTransformDialog(org.apache.hop.ui.pipeline.transform.BaseTransformDialog) FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) ComboVar(org.apache.hop.ui.core.widget.ComboVar) ModifyListener(org.eclipse.swt.events.ModifyListener) ColumnInfo(org.apache.hop.ui.core.widget.ColumnInfo) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) FormAttachment(org.eclipse.swt.layout.FormAttachment) TableView(org.apache.hop.ui.core.widget.TableView)

Example 20 with ComboVar

use of org.apache.hop.ui.core.widget.ComboVar in project hop by apache.

the class WidgetUtils method createFieldDropDown.

/**
 * creates a ComboVar populated with fields from the previous transform.
 *
 * @param parentComposite - the composite in which the widget will be placed
 * @param props - PropsUi props for L&F
 * @param transformMeta - transformMeta of the current transform
 * @param formData - FormData to use for placement
 */
public static ComboVar createFieldDropDown(Composite parentComposite, PropsUi props, IVariables variables, BaseTransformMeta transformMeta, FormData formData) {
    PipelineMeta pipelineMeta = transformMeta.getParentTransformMeta().getParentPipelineMeta();
    ComboVar fieldDropDownCombo = new ComboVar(variables, parentComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(fieldDropDownCombo);
    fieldDropDownCombo.addModifyListener(e -> transformMeta.setChanged());
    fieldDropDownCombo.setLayoutData(formData);
    Listener focusListener = e -> {
        String current = fieldDropDownCombo.getText();
        fieldDropDownCombo.getCComboWidget().removeAll();
        fieldDropDownCombo.setText(current);
        try {
            IRowMeta rmi = pipelineMeta.getPrevTransformFields(variables, transformMeta.getParentTransformMeta().getName());
            List ls = rmi.getValueMetaList();
            for (Object l : ls) {
                ValueMetaBase vmb = (ValueMetaBase) l;
                fieldDropDownCombo.add(vmb.getName());
            }
        } catch (HopTransformException ex) {
            // can be ignored, since previous transform may not be set yet.
            transformMeta.logDebug(ex.getMessage(), ex);
        }
    };
    fieldDropDownCombo.getCComboWidget().addListener(SWT.FocusIn, focusListener);
    return fieldDropDownCombo;
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) IRowMeta(org.apache.hop.core.row.IRowMeta) CTabFolder(org.eclipse.swt.custom.CTabFolder) FormLayout(org.eclipse.swt.layout.FormLayout) IVariables(org.apache.hop.core.variables.IVariables) FormData(org.eclipse.swt.layout.FormData) BaseTransformMeta(org.apache.hop.pipeline.transform.BaseTransformMeta) FormAttachment(org.eclipse.swt.layout.FormAttachment) HopTransformException(org.apache.hop.core.exception.HopTransformException) CTabItem(org.eclipse.swt.custom.CTabItem) List(java.util.List) ComboVar(org.apache.hop.ui.core.widget.ComboVar) Composite(org.eclipse.swt.widgets.Composite) Listener(org.eclipse.swt.widgets.Listener) SWT(org.eclipse.swt.SWT) ValueMetaBase(org.apache.hop.core.row.value.ValueMetaBase) PipelineMeta(org.apache.hop.pipeline.PipelineMeta) Control(org.eclipse.swt.widgets.Control) ComboVar(org.apache.hop.ui.core.widget.ComboVar) Listener(org.eclipse.swt.widgets.Listener) IRowMeta(org.apache.hop.core.row.IRowMeta) List(java.util.List) HopTransformException(org.apache.hop.core.exception.HopTransformException) PipelineMeta(org.apache.hop.pipeline.PipelineMeta) ValueMetaBase(org.apache.hop.core.row.value.ValueMetaBase)

Aggregations

ComboVar (org.apache.hop.ui.core.widget.ComboVar)35 FormAttachment (org.eclipse.swt.layout.FormAttachment)30 FormData (org.eclipse.swt.layout.FormData)30 FormLayout (org.eclipse.swt.layout.FormLayout)28 TextVar (org.apache.hop.ui.core.widget.TextVar)26 IVariables (org.apache.hop.core.variables.IVariables)22 SWT (org.eclipse.swt.SWT)21 Const (org.apache.hop.core.Const)20 BaseMessages (org.apache.hop.i18n.BaseMessages)20 org.eclipse.swt.widgets (org.eclipse.swt.widgets)19 BaseDialog (org.apache.hop.ui.core.dialog.BaseDialog)18 PipelineMeta (org.apache.hop.pipeline.PipelineMeta)17 BaseTransformDialog (org.apache.hop.ui.pipeline.transform.BaseTransformDialog)17 ColumnInfo (org.apache.hop.ui.core.widget.ColumnInfo)16 TableView (org.apache.hop.ui.core.widget.TableView)16 BaseTransformMeta (org.apache.hop.pipeline.transform.BaseTransformMeta)15 CTabItem (org.eclipse.swt.custom.CTabItem)15 HopException (org.apache.hop.core.exception.HopException)14 Utils (org.apache.hop.core.util.Utils)14 ITransformDialog (org.apache.hop.pipeline.transform.ITransformDialog)14