Search in sources :

Example 1 with TableView

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

the class DataSetEditor method createControl.

@Override
public void createControl(Composite parent) {
    PropsUi props = PropsUi.getInstance();
    int margin = Const.MARGIN;
    // The name of the group...
    // 
    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, "DataSetDialog.Name.Label"));
    FormData fdlName = new FormData();
    fdlName.top = new FormAttachment(0, 0);
    fdlName.left = new FormAttachment(0, 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, 5);
    fdName.left = new FormAttachment(0, 0);
    fdName.right = new FormAttachment(wIcon, -5);
    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);
    // The description of the group...
    // 
    Label wlDescription = new Label(parent, SWT.LEFT);
    props.setLook(wlDescription);
    wlDescription.setText(BaseMessages.getString(PKG, "DataSetDialog.Description.Label"));
    FormData fdlDescription = new FormData();
    fdlDescription.top = new FormAttachment(spacer, margin);
    fdlDescription.left = new FormAttachment(0, 0);
    fdlDescription.right = new FormAttachment(100, 0);
    wlDescription.setLayoutData(fdlDescription);
    wDescription = new Text(parent, SWT.MULTI | SWT.LEFT | SWT.V_SCROLL | SWT.BORDER);
    props.setLook(wDescription);
    FormData fdDescription = new FormData();
    fdDescription.height = 50;
    fdDescription.top = new FormAttachment(wlDescription, margin);
    fdDescription.left = new FormAttachment(0, 0);
    fdDescription.right = new FormAttachment(100, 0);
    wDescription.setLayoutData(fdDescription);
    // The folder containing the set...
    // 
    Label wlFolderName = new Label(parent, SWT.LEFT);
    props.setLook(wlFolderName);
    wlFolderName.setText(BaseMessages.getString(PKG, "DataSetDialog.FolderName.Label"));
    FormData fdlFolderName = new FormData();
    fdlFolderName.top = new FormAttachment(wDescription, margin);
    fdlFolderName.left = new FormAttachment(0, 0);
    fdlFolderName.right = new FormAttachment(100, 0);
    wlFolderName.setLayoutData(fdlFolderName);
    wFolderName = new TextVar(manager.getVariables(), parent, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wFolderName);
    FormData fdFolderName = new FormData();
    fdFolderName.top = new FormAttachment(wlFolderName, margin);
    fdFolderName.left = new FormAttachment(0, 0);
    fdFolderName.right = new FormAttachment(100, 0);
    wFolderName.setLayoutData(fdFolderName);
    // The table storing the set...
    // 
    Label wlBaseFilename = new Label(parent, SWT.LEFT);
    props.setLook(wlBaseFilename);
    wlBaseFilename.setText(BaseMessages.getString(PKG, "DataSetDialog.BaseFilename.Label"));
    FormData fdlBaseFilename = new FormData();
    fdlBaseFilename.top = new FormAttachment(wFolderName, margin);
    fdlBaseFilename.left = new FormAttachment(0, 0);
    fdlBaseFilename.right = new FormAttachment(100, 0);
    wlBaseFilename.setLayoutData(fdlBaseFilename);
    wBaseFilename = new Text(parent, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wBaseFilename);
    FormData fdBaseFilename = new FormData();
    fdBaseFilename.top = new FormAttachment(wlBaseFilename, margin);
    fdBaseFilename.left = new FormAttachment(0, 0);
    fdBaseFilename.right = new FormAttachment(100, 0);
    wBaseFilename.setLayoutData(fdBaseFilename);
    // The field mapping from the input to the data set...
    // 
    Label wlFieldMapping = new Label(parent, SWT.NONE);
    wlFieldMapping.setText(BaseMessages.getString(PKG, "DataSetDialog.FieldMapping.Label"));
    props.setLook(wlFieldMapping);
    FormData fdlUpIns = new FormData();
    fdlUpIns.left = new FormAttachment(0, 0);
    fdlUpIns.top = new FormAttachment(wBaseFilename, margin * 2);
    wlFieldMapping.setLayoutData(fdlUpIns);
    // the field mapping grid in between
    // 
    ColumnInfo[] columns = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "DataSetDialog.ColumnInfo.FieldName"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false), new ColumnInfo(BaseMessages.getString(PKG, "DataSetDialog.ColumnInfo.FieldType"), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMetaFactory.getAllValueMetaNames(), false), new ColumnInfo(BaseMessages.getString(PKG, "DataSetDialog.ColumnInfo.FieldFormat"), ColumnInfo.COLUMN_TYPE_FORMAT, 2), new ColumnInfo(BaseMessages.getString(PKG, "DataSetDialog.ColumnInfo.FieldLength"), ColumnInfo.COLUMN_TYPE_TEXT, true, false), new ColumnInfo(BaseMessages.getString(PKG, "DataSetDialog.ColumnInfo.FieldPrecision"), ColumnInfo.COLUMN_TYPE_TEXT, true, false), new ColumnInfo(BaseMessages.getString(PKG, "DataSetDialog.ColumnInfo.Comment"), ColumnInfo.COLUMN_TYPE_TEXT, false, false) };
    wFieldMapping = new TableView(new Variables(), parent, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, columns, getMetadata().getFields().size(), null, props);
    FormData fdFieldMapping = new FormData();
    fdFieldMapping.left = new FormAttachment(0, 0);
    fdFieldMapping.top = new FormAttachment(wlFieldMapping, margin);
    fdFieldMapping.right = new FormAttachment(100, 0);
    fdFieldMapping.bottom = new FormAttachment(100, -2 * margin);
    wFieldMapping.setLayoutData(fdFieldMapping);
    this.setWidgetsContent();
    // Add listener to detect change after loading data
    ModifyListener lsMod = e -> setChanged();
    wName.addModifyListener(lsMod);
    wDescription.addModifyListener(lsMod);
    wFolderName.addModifyListener(lsMod);
    wBaseFilename.addModifyListener(lsMod);
    wFieldMapping.addModifyListener(lsMod);
}
Also used : FormData(org.eclipse.swt.layout.FormData) TableView(org.apache.hop.ui.core.widget.TableView) HopException(org.apache.hop.core.exception.HopException) MetadataEditor(org.apache.hop.ui.core.metadata.MetadataEditor) HopGui(org.apache.hop.ui.hopgui.HopGui) Variables(org.apache.hop.core.variables.Variables) PreviewRowsDialog(org.apache.hop.ui.core.dialog.PreviewRowsDialog) ValueMetaFactory(org.apache.hop.core.row.value.ValueMetaFactory) DataSetField(org.apache.hop.testing.DataSetField) IRowMeta(org.apache.hop.core.row.IRowMeta) DataSet(org.apache.hop.testing.DataSet) HopVfs(org.apache.hop.core.vfs.HopVfs) ColumnInfo(org.apache.hop.ui.core.widget.ColumnInfo) BaseMessages(org.apache.hop.i18n.BaseMessages) FormData(org.eclipse.swt.layout.FormData) org.eclipse.swt.widgets(org.eclipse.swt.widgets) FormAttachment(org.eclipse.swt.layout.FormAttachment) FileObject(org.apache.commons.vfs2.FileObject) Const(org.apache.hop.core.Const) PropsUi(org.apache.hop.ui.core.PropsUi) LogChannel(org.apache.hop.core.logging.LogChannel) DataSetCsvUtil(org.apache.hop.testing.DataSetCsvUtil) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) List(java.util.List) TextVar(org.apache.hop.ui.core.widget.TextVar) ModifyListener(org.eclipse.swt.events.ModifyListener) SWT(org.eclipse.swt.SWT) StringUtil(org.apache.hop.core.util.StringUtil) MetadataManager(org.apache.hop.ui.core.metadata.MetadataManager) ModifyListener(org.eclipse.swt.events.ModifyListener) ColumnInfo(org.apache.hop.ui.core.widget.ColumnInfo) PropsUi(org.apache.hop.ui.core.PropsUi) TextVar(org.apache.hop.ui.core.widget.TextVar) Variables(org.apache.hop.core.variables.Variables) FormAttachment(org.eclipse.swt.layout.FormAttachment) TableView(org.apache.hop.ui.core.widget.TableView)

Example 2 with TableView

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

the class PipelineUnitTestEditor method createControl.

@Override
public void createControl(Composite parent) {
    PipelineUnitTest pipelineUnitTest = this.getMetadata();
    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;
    // The name of the unit test...
    // 
    Label wlName = new Label(parent, SWT.RIGHT);
    props.setLook(wlName);
    wlName.setText(BaseMessages.getString(PKG, "PipelineUnitTestDialog.Name.Label"));
    FormData fdlName = new FormData();
    fdlName.top = new FormAttachment(0, margin);
    fdlName.left = new FormAttachment(0, 0);
    fdlName.right = new FormAttachment(middle, -margin);
    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, 0);
    fdName.right = new FormAttachment(100, 0);
    wName.setLayoutData(fdName);
    Control lastControl = wName;
    // The description of the test...
    // 
    Label wlDescription = new Label(parent, SWT.RIGHT);
    props.setLook(wlDescription);
    wlDescription.setText(BaseMessages.getString(PKG, "PipelineUnitTestDialog.Description.Label"));
    FormData fdlDescription = new FormData();
    fdlDescription.top = new FormAttachment(lastControl, margin);
    fdlDescription.left = new FormAttachment(0, 0);
    fdlDescription.right = new FormAttachment(middle, -margin);
    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);
    fdDescription.left = new FormAttachment(middle, 0);
    fdDescription.right = new FormAttachment(100, 0);
    wDescription.setLayoutData(fdDescription);
    lastControl = wDescription;
    // The type of test...
    // 
    Label wlTestType = new Label(parent, SWT.RIGHT);
    props.setLook(wlTestType);
    wlTestType.setText(BaseMessages.getString(PKG, "PipelineUnitTestDialog.TestType.Label"));
    FormData fdlTestType = new FormData();
    fdlTestType.top = new FormAttachment(lastControl, margin);
    fdlTestType.left = new FormAttachment(0, 0);
    fdlTestType.right = new FormAttachment(middle, -margin);
    wlTestType.setLayoutData(fdlTestType);
    wTestType = new Combo(parent, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    FormData fdTestType = new FormData();
    fdTestType.top = new FormAttachment(wlTestType, 0, SWT.CENTER);
    fdTestType.left = new FormAttachment(middle, 0);
    fdTestType.right = new FormAttachment(100, 0);
    wTestType.setLayoutData(fdTestType);
    wTestType.setItems(DataSetConst.getTestTypeDescriptions());
    lastControl = wTestType;
    // The filename of the pipeline to test
    // 
    Label wlPipelineFilename = new Label(parent, SWT.RIGHT);
    props.setLook(wlPipelineFilename);
    wlPipelineFilename.setText(BaseMessages.getString(PKG, "PipelineUnitTestDialog.PipelineFilename.Label"));
    FormData fdlPipelineFilename = new FormData();
    fdlPipelineFilename.top = new FormAttachment(lastControl, margin);
    fdlPipelineFilename.left = new FormAttachment(0, 0);
    fdlPipelineFilename.right = new FormAttachment(middle, -margin);
    wlPipelineFilename.setLayoutData(fdlPipelineFilename);
    wPipelineFilename = new Text(parent, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wPipelineFilename);
    FormData fdPipelineFilename = new FormData();
    fdPipelineFilename.top = new FormAttachment(wlPipelineFilename, 0, SWT.CENTER);
    fdPipelineFilename.left = new FormAttachment(middle, 0);
    fdPipelineFilename.right = new FormAttachment(100, 0);
    wPipelineFilename.setLayoutData(fdPipelineFilename);
    lastControl = wPipelineFilename;
    // The optional filename of the test result...
    // 
    Label wlFilename = new Label(parent, SWT.RIGHT);
    props.setLook(wlFilename);
    wlFilename.setText(BaseMessages.getString(PKG, "PipelineUnitTestDialog.Filename.Label"));
    FormData fdlFilename = new FormData();
    fdlFilename.top = new FormAttachment(lastControl, margin);
    fdlFilename.left = new FormAttachment(0, 0);
    fdlFilename.right = new FormAttachment(middle, -margin);
    wlFilename.setLayoutData(fdlFilename);
    wFilename = new TextVar(manager.getVariables(), parent, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wFilename);
    FormData fdFilename = new FormData();
    fdFilename.top = new FormAttachment(wlFilename, 0, SWT.CENTER);
    fdFilename.left = new FormAttachment(middle, 0);
    fdFilename.right = new FormAttachment(100, 0);
    wFilename.setLayoutData(fdFilename);
    lastControl = wFilename;
    // The base path for relative test path resolution
    // 
    Label wlBasePath = new Label(parent, SWT.RIGHT);
    props.setLook(wlBasePath);
    wlBasePath.setText(BaseMessages.getString(PKG, "PipelineUnitTestDialog.BasePath.Label"));
    FormData fdlBasePath = new FormData();
    fdlBasePath.top = new FormAttachment(lastControl, margin);
    fdlBasePath.left = new FormAttachment(0, 0);
    fdlBasePath.right = new FormAttachment(middle, -margin);
    wlBasePath.setLayoutData(fdlBasePath);
    wBasePath = new TextVar(manager.getVariables(), parent, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wBasePath);
    FormData fdBasePath = new FormData();
    fdBasePath.top = new FormAttachment(wlBasePath, 0, SWT.CENTER);
    fdBasePath.left = new FormAttachment(middle, 0);
    fdBasePath.right = new FormAttachment(100, 0);
    wBasePath.setLayoutData(fdBasePath);
    lastControl = wBasePath;
    // The base path for relative test path resolution
    // 
    Label wlAutoOpen = new Label(parent, SWT.RIGHT);
    props.setLook(wlAutoOpen);
    wlAutoOpen.setText(BaseMessages.getString(PKG, "PipelineUnitTestDialog.AutoOpen.Label"));
    FormData fdlAutoOpen = new FormData();
    fdlAutoOpen.top = new FormAttachment(lastControl, margin);
    fdlAutoOpen.left = new FormAttachment(0, 0);
    fdlAutoOpen.right = new FormAttachment(middle, -margin);
    wlAutoOpen.setLayoutData(fdlAutoOpen);
    wAutoOpen = new Button(parent, SWT.CHECK);
    props.setLook(wAutoOpen);
    FormData fdAutoOpen = new FormData();
    fdAutoOpen.top = new FormAttachment(wlAutoOpen, 0, SWT.CENTER);
    fdAutoOpen.left = new FormAttachment(middle, 0);
    fdAutoOpen.right = new FormAttachment(100, 0);
    wAutoOpen.setLayoutData(fdAutoOpen);
    lastControl = wAutoOpen;
    // The list of database replacements in the unit test pipeline
    // 
    Label wlFieldMapping = new Label(parent, SWT.NONE);
    wlFieldMapping.setText(BaseMessages.getString(PKG, "PipelineUnitTestDialog.DbReplacements.Label"));
    props.setLook(wlFieldMapping);
    FormData fdlUpIns = new FormData();
    fdlUpIns.left = new FormAttachment(0, 0);
    fdlUpIns.top = new FormAttachment(lastControl, 3 * margin);
    wlFieldMapping.setLayoutData(fdlUpIns);
    lastControl = wlFieldMapping;
    // the database replacements
    // 
    List<String> dbNames;
    try {
        dbNames = metadataProvider.getSerializer(DatabaseMeta.class).listObjectNames();
        Collections.sort(dbNames);
    } catch (HopException e) {
        LogChannel.UI.logError("Error getting list of databases", e);
        dbNames = Collections.emptyList();
    }
    ColumnInfo[] columns = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "PipelineUnitTestDialog.DbReplacement.ColumnInfo.OriginalDb"), ColumnInfo.COLUMN_TYPE_CCOMBO, dbNames.toArray(new String[0]), false), new ColumnInfo(BaseMessages.getString(PKG, "PipelineUnitTestDialog.DbReplacement.ColumnInfo.ReplacementDb"), ColumnInfo.COLUMN_TYPE_CCOMBO, dbNames.toArray(new String[0]), false) };
    columns[0].setUsingVariables(true);
    columns[1].setUsingVariables(true);
    wDbReplacements = new TableView(new Variables(), parent, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, columns, pipelineUnitTest.getTweaks().size(), null, props);
    FormData fdDbReplacements = new FormData();
    fdDbReplacements.left = new FormAttachment(0, 0);
    fdDbReplacements.top = new FormAttachment(lastControl, margin);
    fdDbReplacements.right = new FormAttachment(100, 0);
    fdDbReplacements.bottom = new FormAttachment(lastControl, 250);
    wDbReplacements.setLayoutData(fdDbReplacements);
    lastControl = wDbReplacements;
    Label wlVariableValues = new Label(parent, SWT.NONE);
    wlVariableValues.setText(BaseMessages.getString(PKG, "PipelineUnitTestDialog.VariableValues.Label"));
    props.setLook(wlVariableValues);
    FormData fdlVariableValues = new FormData();
    fdlVariableValues.left = new FormAttachment(0, 0);
    fdlVariableValues.top = new FormAttachment(lastControl, margin);
    wlVariableValues.setLayoutData(fdlVariableValues);
    lastControl = wlVariableValues;
    ColumnInfo[] varValColumns = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "PipelineUnitTestDialog.VariableValues.ColumnInfo.VariableName"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "PipelineUnitTestDialog.VariableValues.ColumnInfo.VariableValue"), ColumnInfo.COLUMN_TYPE_TEXT, false) };
    varValColumns[0].setUsingVariables(true);
    varValColumns[1].setUsingVariables(true);
    wVariableValues = new TableView(new Variables(), parent, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, varValColumns, pipelineUnitTest.getVariableValues().size(), null, props);
    FormData fdVariableValues = new FormData();
    fdVariableValues.left = new FormAttachment(0, 0);
    fdVariableValues.top = new FormAttachment(lastControl, margin);
    fdVariableValues.right = new FormAttachment(100, 0);
    fdVariableValues.bottom = new FormAttachment(100, -2 * margin);
    wVariableValues.setLayoutData(fdVariableValues);
    setWidgetsContent();
    // Add listener to detect change after loading data
    Listener modifyListener = e -> setChanged();
    wName.addListener(SWT.Modify, modifyListener);
    wDescription.addListener(SWT.Modify, modifyListener);
    wTestType.addListener(SWT.Modify, modifyListener);
    wPipelineFilename.addListener(SWT.Modify, modifyListener);
    wFilename.addListener(SWT.Modify, modifyListener);
    wBasePath.addListener(SWT.Modify, modifyListener);
    wAutoOpen.addListener(SWT.Selection, modifyListener);
}
Also used : FormData(org.eclipse.swt.layout.FormData) DataSetConst(org.apache.hop.testing.util.DataSetConst) VariableValue(org.apache.hop.testing.VariableValue) ColumnInfo(org.apache.hop.ui.core.widget.ColumnInfo) BaseMessages(org.apache.hop.i18n.BaseMessages) TableView(org.apache.hop.ui.core.widget.TableView) FormData(org.eclipse.swt.layout.FormData) HopException(org.apache.hop.core.exception.HopException) IHopMetadataProvider(org.apache.hop.metadata.api.IHopMetadataProvider) MetadataEditor(org.apache.hop.ui.core.metadata.MetadataEditor) org.eclipse.swt.widgets(org.eclipse.swt.widgets) HopGui(org.apache.hop.ui.hopgui.HopGui) FormAttachment(org.eclipse.swt.layout.FormAttachment) Variables(org.apache.hop.core.variables.Variables) Const(org.apache.hop.core.Const) PropsUi(org.apache.hop.ui.core.PropsUi) LogChannel(org.apache.hop.core.logging.LogChannel) PipelineUnitTest(org.apache.hop.testing.PipelineUnitTest) PipelineUnitTestDatabaseReplacement(org.apache.hop.testing.PipelineUnitTestDatabaseReplacement) List(java.util.List) TextVar(org.apache.hop.ui.core.widget.TextVar) SWT(org.eclipse.swt.SWT) DatabaseMeta(org.apache.hop.core.database.DatabaseMeta) Collections(java.util.Collections) MetadataManager(org.apache.hop.ui.core.metadata.MetadataManager) HopException(org.apache.hop.core.exception.HopException) ColumnInfo(org.apache.hop.ui.core.widget.ColumnInfo) TextVar(org.apache.hop.ui.core.widget.TextVar) Variables(org.apache.hop.core.variables.Variables) PipelineUnitTest(org.apache.hop.testing.PipelineUnitTest) FormAttachment(org.eclipse.swt.layout.FormAttachment) TableView(org.apache.hop.ui.core.widget.TableView)

Example 3 with TableView

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

the class HopNeo4jPerspective method initialize.

@Override
public void initialize(HopGui hopGui, Composite parent) {
    this.hopGui = hopGui;
    this.parent = parent;
    PropsUi props = PropsUi.getInstance();
    int size = (int) Math.round((double) ConstUi.SMALL_ICON_SIZE * props.getZoomFactor());
    Image neo4jImage = SwtSvgImageUtil.getImage(hopGui.getDisplay(), this.getClass().getClassLoader(), "neo4j_logo.svg", size, size);
    Image lineageImage = SwtSvgImageUtil.getImage(hopGui.getDisplay(), this.getClass().getClassLoader(), "lineage.svg", size, size);
    errorLineBackground = new Color(hopGui.getDisplay(), 201, 232, 251);
    composite = new Composite(parent, SWT.NONE);
    props.setLook(composite);
    FormLayout layout = new FormLayout();
    layout.marginLeft = props.getMargin();
    layout.marginTop = props.getMargin();
    layout.marginLeft = props.getMargin();
    layout.marginBottom = props.getMargin();
    composite.setLayout(layout);
    FormData formData = new FormData();
    formData.left = new FormAttachment(0, 0);
    formData.top = new FormAttachment(0, 0);
    formData.right = new FormAttachment(100, 0);
    formData.bottom = new FormAttachment(100, 0);
    composite.setLayoutData(formData);
    int margin = (int) (props.getMargin() * props.getZoomFactor());
    // Add a simple label to test
    // 
    Label wlInfo = new Label(composite, SWT.LEFT);
    props.setLook(wlInfo);
    wlInfo.setText(BaseMessages.getString(PKG, "Neo4jPerspectiveDialog.Shell.Title"));
    wlInfo.setFont(GuiResource.getInstance().getFontBold());
    FormData fdInfo = new FormData();
    fdInfo.left = new FormAttachment(0, 0);
    fdInfo.right = new FormAttachment(100, 0);
    fdInfo.top = new FormAttachment(0, 0);
    wlInfo.setLayoutData(fdInfo);
    Control lastControl = wlInfo;
    Label wlSep1 = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
    props.setLook(wlSep1);
    FormData fdlSep1 = new FormData();
    fdlSep1.left = new FormAttachment(0, 0);
    fdlSep1.right = new FormAttachment(100, 0);
    fdlSep1.top = new FormAttachment(lastControl, margin);
    wlSep1.setLayoutData(fdlSep1);
    lastControl = wlSep1;
    Label wlUsedConnection = new Label(composite, SWT.LEFT);
    props.setLook(wlUsedConnection);
    wlUsedConnection.setText(BaseMessages.getString(PKG, "Neo4jPerspectiveDialog.Neo4J.Logging.Path.Label"));
    FormData fdlLoggingConnection = new FormData();
    fdlLoggingConnection.left = new FormAttachment(0, 0);
    fdlLoggingConnection.top = new FormAttachment(lastControl, margin);
    wlUsedConnection.setLayoutData(fdlLoggingConnection);
    wUsedConnection = new Text(composite, SWT.SINGLE | SWT.BORDER);
    wUsedConnection.setEditable(false);
    props.setLook(wUsedConnection);
    wUsedConnection.setText(BaseMessages.getString(PKG, "Neo4jPerspectiveDialog.Neo4J.Logging.Path.Label"));
    wUsedConnection.setFont(GuiResource.getInstance().getFontBold());
    FormData fdLoggingConnection = new FormData();
    fdLoggingConnection.left = new FormAttachment(wlUsedConnection, margin);
    fdLoggingConnection.right = new FormAttachment(50, 0);
    fdLoggingConnection.top = new FormAttachment(lastControl, margin);
    wUsedConnection.setLayoutData(fdLoggingConnection);
    lastControl = wUsedConnection;
    // The search query
    // 
    Label wlExecutions = new Label(composite, SWT.LEFT);
    props.setLook(wlExecutions);
    wlExecutions.setText(BaseMessages.getString(PKG, "Neo4jPerspectiveDialog.PipelineActionName.Label"));
    FormData fdlExecutions = new FormData();
    fdlExecutions.left = new FormAttachment(0, 0);
    fdlExecutions.top = new FormAttachment(lastControl, margin);
    wlExecutions.setLayoutData(fdlExecutions);
    lastControl = wlExecutions;
    wExecutions = new Combo(composite, SWT.BORDER | SWT.SINGLE);
    props.setLook(wExecutions);
    wExecutions.setFont(GuiResource.getInstance().getFontBold());
    FormData fdSearchString = new FormData();
    fdSearchString.left = new FormAttachment(0, 0);
    fdSearchString.top = new FormAttachment(lastControl, margin);
    fdSearchString.right = new FormAttachment(50, 0);
    wExecutions.setLayoutData(fdSearchString);
    wExecutions.addListener(SWT.DefaultSelection, this::search);
    wExecutions.addListener(SWT.Selection, this::search);
    Label wlAmount = new Label(composite, SWT.LEFT);
    props.setLook(wlAmount);
    wlAmount.setText(BaseMessages.getString(PKG, "Neo4jPerspectiveDialog.ShowLast.Label"));
    FormData fdlAmount = new FormData();
    fdlAmount.left = new FormAttachment(wExecutions, 2 * margin);
    fdlAmount.top = new FormAttachment(lastControl, margin);
    wlAmount.setLayoutData(fdlAmount);
    wAmount = new Combo(composite, SWT.BORDER | SWT.SINGLE);
    props.setLook(wAmount);
    wAmount.setItems("50", "100", "250", "500", "1000");
    wAmount.setText("50");
    FormData fdAmount = new FormData();
    fdAmount.left = new FormAttachment(wlAmount, margin);
    fdAmount.top = new FormAttachment(lastControl, margin);
    fdAmount.width = (int) (200 * props.getZoomFactor());
    wAmount.setLayoutData(fdAmount);
    wAmount.addListener(SWT.DefaultSelection, this::search);
    wAmount.addListener(SWT.Selection, this::search);
    wOnlyRoot = new Button(composite, SWT.CHECK);
    wOnlyRoot.setText(BaseMessages.getString(PKG, "Neo4jPerspectiveDialog.OnlyRoot.Label"));
    // default is to limit the amount of entries
    wOnlyRoot.setSelection(true);
    props.setLook(wOnlyRoot);
    FormData fdOnlyRoot = new FormData();
    fdOnlyRoot.left = new FormAttachment(wAmount, margin);
    fdOnlyRoot.top = new FormAttachment(lastControl, margin);
    wOnlyRoot.setLayoutData(fdOnlyRoot);
    wOnlyRoot.addListener(SWT.Selection, this::search);
    lastControl = wExecutions;
    Button wbSearch = new Button(composite, SWT.PUSH);
    props.setLook(wbSearch);
    wbSearch.setText(BaseMessages.getString(PKG, "Neo4jPerspectiveDialog.Search.Button"));
    FormData fdbSearch = new FormData();
    fdbSearch.left = new FormAttachment(0, 0);
    fdbSearch.top = new FormAttachment(lastControl, margin);
    wbSearch.setLayoutData(fdbSearch);
    wbSearch.addListener(SWT.Selection, this::search);
    lastControl = wExecutions;
    Button wbOpen = new Button(composite, SWT.PUSH);
    props.setLook(wbOpen);
    wbOpen.setText(BaseMessages.getString(PKG, "Neo4jPerspectiveDialog.Open.Button"));
    FormData fdbOpen = new FormData();
    fdbOpen.left = new FormAttachment(50, 0);
    fdbOpen.bottom = new FormAttachment(100, -margin);
    wbOpen.setLayoutData(fdbOpen);
    wbOpen.addListener(SWT.Selection, this::open);
    SashForm sashForm = new SashForm(composite, SWT.VERTICAL);
    props.setLook(sashForm);
    FormData fdSashForm = new FormData();
    fdSashForm.left = new FormAttachment(0, 0);
    fdSashForm.top = new FormAttachment(wbSearch, margin);
    fdSashForm.right = new FormAttachment(100, 0);
    fdSashForm.bottom = new FormAttachment(wbOpen, -margin);
    sashForm.setLayoutData(fdSashForm);
    // A table with the execution history results...
    // 
    ColumnInfo[] resultsColumns = { new ColumnInfo(BaseMessages.getString(PKG, "Neo4jPerspectiveDialog.Column.ID.Name"), ColumnInfo.COLUMN_TYPE_TEXT, false, true), new ColumnInfo(BaseMessages.getString(PKG, "Neo4jPerspectiveDialog.Column.Name.Name"), ColumnInfo.COLUMN_TYPE_TEXT, false, true), new ColumnInfo(BaseMessages.getString(PKG, "Neo4jPerspectiveDialog.Column.Type.Name"), ColumnInfo.COLUMN_TYPE_TEXT, false, true), new ColumnInfo(BaseMessages.getString(PKG, "Neo4jPerspectiveDialog.Column.Read.Name"), ColumnInfo.COLUMN_TYPE_TEXT, false, true), new ColumnInfo(BaseMessages.getString(PKG, "Neo4jPerspectiveDialog.Column.Written.Name"), ColumnInfo.COLUMN_TYPE_TEXT, false, true), new ColumnInfo(BaseMessages.getString(PKG, "Neo4jPerspectiveDialog.Column.Input.Name"), ColumnInfo.COLUMN_TYPE_TEXT, false, true), new ColumnInfo(BaseMessages.getString(PKG, "Neo4jPerspectiveDialog.Column.Output.Name"), ColumnInfo.COLUMN_TYPE_TEXT, false, true), new ColumnInfo(BaseMessages.getString(PKG, "Neo4jPerspectiveDialog.Column.Rejected.Name"), ColumnInfo.COLUMN_TYPE_TEXT, false, true), new ColumnInfo(BaseMessages.getString(PKG, "Neo4jPerspectiveDialog.Column.Errors.Name"), ColumnInfo.COLUMN_TYPE_TEXT, false, true), new ColumnInfo(BaseMessages.getString(PKG, "Neo4jPerspectiveDialog.Column.Date.Name"), ColumnInfo.COLUMN_TYPE_TEXT, false, true), new ColumnInfo(BaseMessages.getString(PKG, "Neo4jPerspectiveDialog.Column.Duration.Name"), ColumnInfo.COLUMN_TYPE_TEXT, false, true) };
    wResults = new TableView(hopGui.getVariables(), sashForm, SWT.V_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.BORDER, resultsColumns, 0, null, props);
    props.setLook(wResults);
    wResults.setReadonly(true);
    FormData fdResults = new FormData();
    fdResults.left = new FormAttachment(0, 0);
    fdResults.right = new FormAttachment(100, 0);
    fdResults.top = new FormAttachment(0, 0);
    fdResults.bottom = new FormAttachment(100, 0);
    wResults.setLayoutData(fdResults);
    wResults.table.addListener(SWT.DefaultSelection, this::open);
    wResults.table.addListener(SWT.Selection, this::analyze);
    tabFolder = new CTabFolder(sashForm, SWT.MULTI | SWT.BORDER);
    props.setLook(tabFolder, Props.WIDGET_STYLE_TAB);
    FormData fdLabel = new FormData();
    fdLabel.left = new FormAttachment(0, 0);
    fdLabel.right = new FormAttachment(100, 0);
    fdLabel.top = new FormAttachment(0, 0);
    fdLabel.bottom = new FormAttachment(100, 0);
    tabFolder.setLayoutData(fdLabel);
    CTabItem loggingTab = new CTabItem(tabFolder, SWT.NONE);
    loggingTab.setImage(GuiResource.getInstance().getImageShowLog());
    loggingTab.setText(BaseMessages.getString(PKG, "Neo4jPerspectiveDialog.Logging.Tab"));
    wLogging = new Text(tabFolder, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
    props.setLook(wLogging);
    wLogging.setFont(GuiResource.getInstance().getFontFixed());
    loggingTab.setControl(wLogging);
    CTabItem lineageTab = new CTabItem(tabFolder, SWT.NONE);
    lineageTab.setImage(lineageImage);
    lineageTab.setText(BaseMessages.getString(PKG, "Neo4jPerspectiveDialog.PathError.Tab"));
    wTree = new Tree(tabFolder, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    props.setLook(wTree);
    wTree.setHeaderVisible(true);
    lineageTab.setControl(wTree);
    {
        TreeColumn column = new TreeColumn(wTree, SWT.LEFT);
        column.setText("#");
        column.setWidth((int) (50 * props.getZoomFactor()));
    }
    {
        TreeColumn column = new TreeColumn(wTree, SWT.LEFT);
        column.setText("id");
        column.setWidth((int) (250 * props.getZoomFactor()));
    }
    {
        TreeColumn column = new TreeColumn(wTree, SWT.LEFT);
        column.setText("Name");
        column.setWidth((int) (300 * props.getZoomFactor()));
    }
    {
        TreeColumn column = new TreeColumn(wTree, SWT.LEFT);
        column.setText("Type");
        column.setWidth((int) (100 * props.getZoomFactor()));
    }
    {
        TreeColumn column = new TreeColumn(wTree, SWT.LEFT);
        column.setText("errors");
        column.setWidth((int) (50 * props.getZoomFactor()));
    }
    {
        TreeColumn column = new TreeColumn(wTree, SWT.LEFT);
        column.setText("date");
        column.setWidth((int) (200 * props.getZoomFactor()));
    }
    {
        TreeColumn column = new TreeColumn(wTree, SWT.LEFT);
        column.setText("duration");
        column.setWidth((int) (150 * props.getZoomFactor()));
    }
    CTabItem cypherTab = new CTabItem(tabFolder, SWT.NONE);
    cypherTab.setText(BaseMessages.getString(PKG, "Neo4jPerspectiveDialog.Cypher.Tab"));
    cypherTab.setImage(neo4jImage);
    wCypher = new Text(tabFolder, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    props.setLook(wCypher);
    wCypher.setFont(GuiResource.getInstance().getFontFixed());
    cypherTab.setControl(wCypher);
    tabFolder.setSelection(0);
    sashForm.setWeights(new int[] { 30, 70 });
    defaultTabFont = lineageTab.getFont();
    wTree.addListener(SWT.DefaultSelection, this::openItem);
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) CTabFolder(org.eclipse.swt.custom.CTabFolder) Color(org.eclipse.swt.graphics.Color) ColumnInfo(org.apache.hop.ui.core.widget.ColumnInfo) Image(org.eclipse.swt.graphics.Image) CTabItem(org.eclipse.swt.custom.CTabItem) PropsUi(org.apache.hop.ui.core.PropsUi) SashForm(org.eclipse.swt.custom.SashForm) FormAttachment(org.eclipse.swt.layout.FormAttachment) TableView(org.apache.hop.ui.core.widget.TableView)

Example 4 with TableView

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

the class CypherDialog method addParametersTab.

private void addParametersTab() {
    CTabItem wParametersTab = new CTabItem(wTabFolder, SWT.NONE);
    wParametersTab.setText(BaseMessages.getString(PKG, "CypherDialog.Tab.Parameters.Label"));
    wParametersTab.setToolTipText(BaseMessages.getString(PKG, "CypherDialog.Tab.Parameters.ToolTip"));
    Composite wParametersComp = new Composite(wTabFolder, SWT.NONE);
    props.setLook(wParametersComp);
    wParametersComp.setLayout(createFormLayout());
    // Get the input field names...
    // 
    String[] fieldNames;
    try {
        fieldNames = pipelineMeta.getPrevTransformFields(variables, transformName).getFieldNames();
    } catch (Exception e) {
        logError("Unable to get fields from previous transform", e);
        fieldNames = new String[] {};
    }
    // Table: parameter and field
    // 
    ColumnInfo[] parameterColumns = new ColumnInfo[] { new ColumnInfo("Parameter", ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo("Field", ColumnInfo.COLUMN_TYPE_CCOMBO, fieldNames, false), new ColumnInfo("Neo4j Type", ColumnInfo.COLUMN_TYPE_CCOMBO, GraphPropertyType.getNames(), false) };
    Label wlParameters = new Label(wParametersComp, SWT.LEFT);
    wlParameters.setText("Parameters: (NOTE that parameters for labels are not supported)");
    props.setLook(wlParameters);
    FormData fdlParameters = new FormData();
    fdlParameters.left = new FormAttachment(0, 0);
    fdlParameters.right = new FormAttachment(100, 0);
    fdlParameters.top = new FormAttachment(0, 0);
    wlParameters.setLayoutData(fdlParameters);
    Button wbGetParameters = new Button(wParametersComp, SWT.PUSH);
    wbGetParameters.setText("Get parameters");
    FormData fdbGetParameters = new FormData();
    fdbGetParameters.right = new FormAttachment(100, 0);
    fdbGetParameters.top = new FormAttachment(wlParameters, 0, SWT.BOTTOM);
    wbGetParameters.setLayoutData(fdbGetParameters);
    wbGetParameters.addListener(SWT.Selection, e -> {
        try {
            IRowMeta r = pipelineMeta.getPrevTransformFields(variables, transformMeta);
            BaseTransformDialog.getFieldsFromPrevious(r, wParameters, 2, new int[] { 2 }, new int[] {}, -1, -1, (item, valueMeta) -> Neo4JOutputDialog.getPropertyNameTypePrimary(item, valueMeta, new int[] { 1 }, new int[] { 3 }, -1));
        } catch (Exception ex) {
            new ErrorDialog(shell, "Error", "Error getting transform input fields", ex);
        }
    });
    wParameters = new TableView(variables, wParametersComp, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER, parameterColumns, input.getParameterMappings().size(), null, props);
    props.setLook(wParameters);
    FormData fdParameters = new FormData();
    fdParameters.left = new FormAttachment(0, 0);
    fdParameters.right = new FormAttachment(wbGetParameters, -margin);
    fdParameters.top = new FormAttachment(wlParameters, margin);
    fdParameters.bottom = new FormAttachment(100, 0);
    wParameters.setLayoutData(fdParameters);
    wParametersComp.layout();
    wParametersTab.setControl(wParametersComp);
}
Also used : FormData(org.eclipse.swt.layout.FormData) IRowMeta(org.apache.hop.core.row.IRowMeta) ColumnInfo(org.apache.hop.ui.core.widget.ColumnInfo) CTabItem(org.eclipse.swt.custom.CTabItem) HopTransformException(org.apache.hop.core.exception.HopTransformException) FormAttachment(org.eclipse.swt.layout.FormAttachment) TableView(org.apache.hop.ui.core.widget.TableView)

Example 5 with TableView

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

the class CypherDialog method addReturnsTab.

private void addReturnsTab() {
    CTabItem wReturnsTab = new CTabItem(wTabFolder, SWT.NONE);
    wReturnsTab.setText(BaseMessages.getString(PKG, "CypherDialog.Tab.Returns.Label"));
    wReturnsTab.setToolTipText(BaseMessages.getString(PKG, "CypherDialog.Tab.Returns.ToolTip"));
    Composite wReturnsComp = new Composite(wTabFolder, SWT.NONE);
    props.setLook(wReturnsComp);
    wReturnsComp.setLayout(createFormLayout());
    // Table: return field name and type
    // 
    ColumnInfo[] returnColumns = new ColumnInfo[] { new ColumnInfo("Field name", ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo("Return type", ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMetaFactory.getAllValueMetaNames(), false), new ColumnInfo("Source type", ColumnInfo.COLUMN_TYPE_CCOMBO, GraphPropertyDataType.getNames(), false) };
    Label wlReturns = new Label(wReturnsComp, SWT.LEFT);
    wlReturns.setText("Returns");
    props.setLook(wlReturns);
    FormData fdlReturns = new FormData();
    fdlReturns.left = new FormAttachment(0, 0);
    fdlReturns.right = new FormAttachment(middle, -margin);
    fdlReturns.top = new FormAttachment(0, 0);
    wlReturns.setLayoutData(fdlReturns);
    Button wbGetReturnFields = new Button(wReturnsComp, SWT.PUSH);
    wbGetReturnFields.setText("Get Output Fields");
    FormData fdbGetReturnFields = new FormData();
    fdbGetReturnFields.right = new FormAttachment(100, 0);
    fdbGetReturnFields.top = new FormAttachment(wlReturns, 0, SWT.BOTTOM);
    wbGetReturnFields.setLayoutData(fdbGetReturnFields);
    wbGetReturnFields.addListener(SWT.Selection, e -> getReturnValues());
    wReturns = new TableView(variables, wReturnsComp, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER, returnColumns, input.getReturnValues().size(), null, props);
    props.setLook(wReturns);
    FormData fdReturns = new FormData();
    fdReturns.left = new FormAttachment(0, 0);
    fdReturns.right = new FormAttachment(wbGetReturnFields, 0);
    fdReturns.top = new FormAttachment(wlReturns, margin);
    fdReturns.bottom = new FormAttachment(100, 0);
    wReturns.setLayoutData(fdReturns);
    wReturnsComp.layout();
    wReturnsTab.setControl(wReturnsComp);
}
Also used : FormData(org.eclipse.swt.layout.FormData) ColumnInfo(org.apache.hop.ui.core.widget.ColumnInfo) CTabItem(org.eclipse.swt.custom.CTabItem) FormAttachment(org.eclipse.swt.layout.FormAttachment) TableView(org.apache.hop.ui.core.widget.TableView)

Aggregations

TableView (org.apache.hop.ui.core.widget.TableView)181 ColumnInfo (org.apache.hop.ui.core.widget.ColumnInfo)180 FormAttachment (org.eclipse.swt.layout.FormAttachment)177 FormData (org.eclipse.swt.layout.FormData)177 FormLayout (org.eclipse.swt.layout.FormLayout)162 BaseMessages (org.apache.hop.i18n.BaseMessages)102 SWT (org.eclipse.swt.SWT)102 org.eclipse.swt.widgets (org.eclipse.swt.widgets)102 Const (org.apache.hop.core.Const)100 IVariables (org.apache.hop.core.variables.IVariables)97 BaseTransformDialog (org.apache.hop.ui.pipeline.transform.BaseTransformDialog)96 Utils (org.apache.hop.core.util.Utils)88 BaseDialog (org.apache.hop.ui.core.dialog.BaseDialog)87 ModifyListener (org.eclipse.swt.events.ModifyListener)84 HopException (org.apache.hop.core.exception.HopException)82 BaseTransformMeta (org.apache.hop.pipeline.transform.BaseTransformMeta)82 PipelineMeta (org.apache.hop.pipeline.PipelineMeta)80 ITransformDialog (org.apache.hop.pipeline.transform.ITransformDialog)77 IRowMeta (org.apache.hop.core.row.IRowMeta)75 TextVar (org.apache.hop.ui.core.widget.TextVar)74