Search in sources :

Example 1 with PropsUi

use of org.apache.hop.ui.core.PropsUi 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 PropsUi

use of org.apache.hop.ui.core.PropsUi 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 3 with PropsUi

use of org.apache.hop.ui.core.PropsUi in project hop by apache.

the class NeoConnectionEditor method createControl.

@Override
public void createControl(Composite composite) {
    PropsUi props = PropsUi.getInstance();
    int middle = props.getMiddlePct();
    int margin = Const.MARGIN + 2;
    IVariables variables = getHopGui().getVariables();
    // The name
    Label wlName = new Label(composite, SWT.RIGHT);
    props.setLook(wlName);
    wlName.setText(BaseMessages.getString(PKG, "NeoConnectionEditor.Name.Label"));
    FormData fdlName = new FormData();
    fdlName.top = new FormAttachment(0, margin);
    // First one in the left top corner
    fdlName.left = new FormAttachment(0, 0);
    fdlName.right = new FormAttachment(middle, -margin);
    wlName.setLayoutData(fdlName);
    wName = new Text(composite, 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, 0);
    fdName.right = new FormAttachment(95, 0);
    wName.setLayoutData(fdName);
    wTabFolder = new CTabFolder(composite, SWT.BORDER);
    FormData fdTabFolder = new FormData();
    fdTabFolder.left = new FormAttachment(0, 0);
    fdTabFolder.right = new FormAttachment(100, 0);
    fdTabFolder.top = new FormAttachment(wName, 2 * margin);
    fdTabFolder.bottom = new FormAttachment(100, -2 * margin);
    wTabFolder.setLayoutData(fdTabFolder);
    addBasicTab(props, variables, middle, margin);
    addProtocolTab(props, variables, middle, margin);
    addAdvancedTab(props, variables, middle, margin);
    addUrlsTab(props, variables);
    // Always select the basic tab
    wTabFolder.setSelection(0);
    setWidgetsContent();
    enableFields();
    clearChanged();
    // Add modify listeners to all controls.
    // This will inform the Metadata perspective in the Hop GUI that this object was modified and
    // needs to be saved.
    // 
    Control[] controls = { wName, wAutomatic, wServer, wDatabaseName, wVersion4, wDatabasePort, wBrowserPort, wPolicy, wUsername, wRouting, wEncryption, wTrustAllCertificates, wConnectionLivenessCheckTimeout, wMaxConnectionLifetime, wMaxConnectionPoolSize, wConnectionAcquisitionTimeout, wConnectionTimeout, wMaxTransactionRetryTime };
    for (Control control : controls) {
        control.addListener(SWT.Modify, e -> setChanged());
        control.addListener(SWT.Selection, e -> setChanged());
    }
}
Also used : FormData(org.eclipse.swt.layout.FormData) CTabFolder(org.eclipse.swt.custom.CTabFolder) IVariables(org.apache.hop.core.variables.IVariables) FormAttachment(org.eclipse.swt.layout.FormAttachment) PropsUi(org.apache.hop.ui.core.PropsUi)

Example 4 with PropsUi

use of org.apache.hop.ui.core.PropsUi in project hop by apache.

the class GoogleAuthorizationDialog method createDialog.

private void createDialog(String title, String url, int options, Image logo) {
    Shell parent = getParent();
    display = parent.getDisplay();
    dialog = new Shell(parent, options);
    dialog.setText(title);
    dialog.setImage(logo);
    PropsUi props = PropsUi.getInstance();
    props.setLook(dialog);
    dialog.setSize(width, height);
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;
    dialog.setLayout(formLayout);
    try {
        Label helpButton = new Label(dialog, SWT.NONE);
        helpButton.setImage(new Image(display, GoogleAuthorizationDialog.class.getResourceAsStream("/images/help.png")));
        FormData helpButtonFormData = new FormData();
        helpButtonFormData.left = new FormAttachment(0, 15);
        helpButtonFormData.bottom = new FormAttachment(100, -24);
        helpButton.setLayoutData(helpButtonFormData);
        Text helpLabel = new Text(dialog, SWT.NONE);
        helpLabel.setText("Help");
        helpLabel.setEditable(false);
        props.setLook(helpLabel);
        helpLabel.setFont(new Font(display, "Open Sans Regular", 11, SWT.NORMAL));
        helpLabel.setForeground(new Color(display, props.contrastColor(0, 94, 170)));
        FormData helpLabelFormData = new FormData();
        helpLabelFormData.left = new FormAttachment(0, 40);
        helpLabelFormData.bottom = new FormAttachment(100, -27);
        helpLabel.setLayoutData(helpLabelFormData);
        helpLabel.addListener(SWT.MouseUp, event -> {
        });
        helpLabel.addListener(SWT.MouseEnter, event -> {
            helpLabel.setForeground(new Color(display, PropsUi.getInstance().contrastColor(0, 0, 0)));
            helpLabel.setCursor(new Cursor(display, SWT.CURSOR_HAND));
        });
        helpLabel.addListener(SWT.MouseExit, event -> helpLabel.setForeground(new Color(display, props.contrastColor(0, 94, 170))));
        Label cancelButton = new Label(dialog, SWT.NONE);
        Image closeImage = SwtSvgImageUtil.getImage(display, getClass().getClassLoader(), "/ui/images/close.svg", ConstUi.SMALL_ICON_SIZE, ConstUi.SMALL_ICON_SIZE);
        cancelButton.setImage(closeImage);
        FormData cancelButtonFormData = new FormData();
        cancelButtonFormData.right = new FormAttachment(100, -15);
        cancelButtonFormData.bottom = new FormAttachment(100, -15);
        cancelButton.setLayoutData(cancelButtonFormData);
        cancelButton.addListener(SWT.MouseUp, event -> {
            browser.dispose();
            dialog.close();
            dialog.dispose();
        });
        cancelButton.addListener(SWT.MouseEnter, new Listener() {

            @Override
            public void handleEvent(Event event) {
                Image closeImage = SwtSvgImageUtil.getImage(display, getClass().getClassLoader(), "/ui/images/close.svg", ConstUi.SMALL_ICON_SIZE, ConstUi.SMALL_ICON_SIZE);
                cancelButton.setImage(new Image(display, GoogleAuthorizationDialog.class.getResourceAsStream("/images/close-button-hover.png")));
                cancelButton.setCursor(new Cursor(display, SWT.CURSOR_HAND));
            }
        });
        cancelButton.addListener(SWT.MouseExit, event -> cancelButton.setImage(new Image(display, GoogleAuthorizationDialog.class.getResourceAsStream("/images/close-button.png"))));
        Label separator = new Label(dialog, SWT.HORIZONTAL | SWT.SEPARATOR);
        FormData separatorFormData = new FormData();
        separatorFormData.left = new FormAttachment(0, 15);
        separatorFormData.right = new FormAttachment(100, -15);
        separatorFormData.bottom = new FormAttachment(cancelButton, -15);
        separator.setLayoutData(separatorFormData);
        browser = new Browser(dialog, SWT.NONE);
        browser.setUrl(url);
        FormData browserFormData = new FormData();
        browserFormData.top = new FormAttachment(0, 5);
        browserFormData.bottom = new FormAttachment(separator, -5);
        browserFormData.left = new FormAttachment(0, 5);
        browserFormData.right = new FormAttachment(100, -5);
        browser.setLayoutData(browserFormData);
        browser.addCloseWindowListener(event -> {
            Browser browser = (Browser) event.widget;
            Shell shell = browser.getShell();
            shell.close();
        });
    } catch (Exception e) {
        MessageBox messageBox = new MessageBox(dialog, SWT.ICON_ERROR | SWT.OK);
        messageBox.setMessage("Browser cannot be initialized.");
        messageBox.setText("Exit");
        messageBox.open();
    }
    setPosition();
    dialog.open();
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) PropsUi(org.apache.hop.ui.core.PropsUi) FormAttachment(org.eclipse.swt.layout.FormAttachment) Browser(org.eclipse.swt.browser.Browser)

Example 5 with PropsUi

use of org.apache.hop.ui.core.PropsUi in project hop by apache.

the class MongoDbConnectionEditor method createControl.

@Override
public void createControl(Composite parent) {
    this.parent = parent;
    PropsUi props = PropsUi.getInstance();
    int margin = props.getMargin();
    int middle = props.getMiddlePct();
    // Name...
    // 
    Label wlName = new Label(parent, SWT.RIGHT);
    props.setLook(wlName);
    wlName.setText("MongoDB Connection name");
    FormData fdlName = new FormData();
    fdlName.top = new FormAttachment(0, margin * 2);
    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);
    // Rest of the widgets...
    // 
    widgets = new GuiCompositeWidgets(manager.getVariables());
    widgets.createCompositeWidgets(getMetadata(), null, parent, PARENT_WIDGET_ID, wName);
    // Set content on the widgets...
    // 
    setWidgetsContent();
    // Add changed listeners
    wName.addListener(SWT.Modify, e -> setChanged());
    widgets.setWidgetsListener(new GuiCompositeWidgetsAdapter() {

        @Override
        public void widgetModified(GuiCompositeWidgets compositeWidgets, Control changedWidget, String widgetId) {
            setChanged();
        }
    });
}
Also used : FormData(org.eclipse.swt.layout.FormData) GuiCompositeWidgets(org.apache.hop.ui.core.gui.GuiCompositeWidgets) GuiCompositeWidgetsAdapter(org.apache.hop.ui.core.gui.GuiCompositeWidgetsAdapter) FormAttachment(org.eclipse.swt.layout.FormAttachment) PropsUi(org.apache.hop.ui.core.PropsUi)

Aggregations

PropsUi (org.apache.hop.ui.core.PropsUi)52 FormAttachment (org.eclipse.swt.layout.FormAttachment)38 FormData (org.eclipse.swt.layout.FormData)38 FormLayout (org.eclipse.swt.layout.FormLayout)25 Const (org.apache.hop.core.Const)11 BaseMessages (org.apache.hop.i18n.BaseMessages)11 TextVar (org.apache.hop.ui.core.widget.TextVar)11 HopGui (org.apache.hop.ui.hopgui.HopGui)11 SWT (org.eclipse.swt.SWT)11 ColumnInfo (org.apache.hop.ui.core.widget.ColumnInfo)10 TableView (org.apache.hop.ui.core.widget.TableView)10 org.eclipse.swt.widgets (org.eclipse.swt.widgets)10 MetadataEditor (org.apache.hop.ui.core.metadata.MetadataEditor)9 MetadataManager (org.apache.hop.ui.core.metadata.MetadataManager)9 ErrorDialog (org.apache.hop.ui.core.dialog.ErrorDialog)7 CTabFolder (org.eclipse.swt.custom.CTabFolder)7 CTabItem (org.eclipse.swt.custom.CTabItem)7 Label (org.eclipse.swt.widgets.Label)7 Button (org.eclipse.swt.widgets.Button)6 ArrayList (java.util.ArrayList)5