org.eclipse.swt.layout.FormData Java Examples

The following examples show how to use org.eclipse.swt.layout.FormData. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RadioTab.java    From hop with Apache License 2.0 8 votes vote down vote up
public Composite createContent( String radioText ) {
  Control[] existingButtons = radioGroup.getChildren();
  Button button = new Button( radioGroup, SWT.RADIO );
  button.setText( radioText );
  props.setLook( button );
  FormData fdButton = new FormData();
  fdButton.top = new FormAttachment( 0 );
  fdButton.left = existingButtons.length == 0
    ? new FormAttachment( 0 ) : new FormAttachment( existingButtons[ existingButtons.length - 1 ], 40 );
  button.setLayoutData( fdButton );
  button.setSelection( existingButtons.length == 0 );
  Composite content = new Composite( contentArea, SWT.NONE );
  content.setVisible( existingButtons.length == 0 );
  props.setLook( content );
  content.setLayout( noMarginLayout );
  content.setLayoutData( fdMaximize );
  button.addSelectionListener( new SelectionAdapter() {
    @Override public void widgetSelected( SelectionEvent selectionEvent ) {
      for ( Control control : contentArea.getChildren() ) {
        control.setVisible( false );
      }
      content.setVisible( true );
    }
  } );
  return content;
}
 
Example #2
Source File: HopGui.java    From hop with Apache License 2.0 6 votes vote down vote up
protected void addPerspectivesToolbar() {
  // We can't mix horizontal and vertical toolbars so we need to add a composite.
  //
  shell.setLayout( new FormLayout() );
  mainHopGuiComposite = new Composite( shell, SWT.NO_BACKGROUND );
  mainHopGuiComposite.setLayout( new FormLayout() );
  FormData formData = new FormData();
  formData.left = new FormAttachment( 0, 0 );
  formData.right = new FormAttachment( 100, 0 );
  formData.top = new FormAttachment( mainToolbar, 0 );
  formData.bottom = new FormAttachment( 100, 0 );
  mainHopGuiComposite.setLayoutData( formData );

  perspectivesToolbar = new ToolBar( mainHopGuiComposite, SWT.WRAP | SWT.RIGHT | SWT.VERTICAL );
  props.setLook( perspectivesToolbar, PropsUi.WIDGET_STYLE_TOOLBAR );
  FormData fdToolBar = new FormData();
  fdToolBar.left = new FormAttachment( 0, 0 );
  fdToolBar.top = new FormAttachment( 0, 0 );
  fdToolBar.bottom = new FormAttachment( 100, 0 );
  perspectivesToolbar.setLayoutData( fdToolBar );

  perspectivesToolbarWidgets = new GuiToolbarWidgets();
  perspectivesToolbarWidgets.registerGuiPluginObject( this );
  perspectivesToolbarWidgets.createToolbarWidgets( perspectivesToolbar, GUI_PLUGIN_PERSPECTIVES_PARENT_ID );
  perspectivesToolbar.pack();
}
 
Example #3
Source File: ConfigurationDialog.java    From hop with Apache License 2.0 6 votes vote down vote up
protected void optionsSectionLayout( Class<?> PKG, String prefix ) {
  gDetails = new Group( shell, SWT.SHADOW_ETCHED_IN );
  gDetails.setText( BaseMessages.getString( PKG, prefix + ".DetailsGroup.Label" ) );
  props.setLook( gDetails );

  // The layout
  gDetails.setLayout( new FormLayout() );
  fdDetails = new FormData();
  fdDetails.top = new FormAttachment( wRunConfigurationControl, 15 );
  fdDetails.right = new FormAttachment( 100, -15 );
  fdDetails.left = new FormAttachment( 0, 15 );
  gDetails.setBackground( shell.getBackground() ); // the default looks ugly
  gDetails.setLayoutData( fdDetails );

  optionsSectionControls();
}
 
Example #4
Source File: TeraFastDialog.java    From hop with Apache License 2.0 6 votes vote down vote up
/**
 * @param factory factory to use.
 */
protected void buildLogFileLine( final PluginWidgetFactory factory ) {
  final Control topControl = this.wFastLoadPath;

  this.wlLogFile = factory.createRightLabel( BaseMessages.getString( PKG, "TeraFastDialog.LogFile.Label" ) );
  this.props.setLook( this.wlLogFile );
  this.wlLogFile.setLayoutData( factory.createLabelLayoutData( topControl ) );

  this.wbLogFile = factory.createPushButton( BaseMessages.getString( PKG, "TeraFastDialog.Browse.Button" ) );
  this.props.setLook( this.wbLogFile );
  FormData formData = factory.createControlLayoutData( topControl );
  formData.left = null;
  this.wbLogFile.setLayoutData( formData );

  this.wLogFile = factory.createSingleTextVarLeft();
  this.props.setLook( this.wLogFile );
  formData = factory.createControlLayoutData( topControl );
  formData.right = new FormAttachment( this.wbLogFile, -factory.getMargin() );
  this.wLogFile.setLayoutData( formData );
}
 
Example #5
Source File: BrowserEnvironmentWarningDialog.java    From hop with Apache License 2.0 6 votes vote down vote up
private void setCloseButton() {
  closeButton = new Button( shell, SWT.PUSH );
  closeButton.setText( BaseMessages.getString( PKG, "System.Button.Close" ) );
  FormData fdbutton = new FormData();
  fdbutton.right = new FormAttachment( 100, 0 ); //Button should below the link and separated by 30
  fdbutton.top = new FormAttachment( link, padding );
  fdbutton.height = padding;
  closeButton.setLayoutData( fdbutton );
  props.setLook( closeButton );

  // Add listeners
  closeButton.addListener( SWT.Selection, new Listener() {
    public void handleEvent( Event e ) {
      close();
    }
  } );
}
 
Example #6
Source File: EnterOptionsDialog.java    From hop with Apache License 2.0 6 votes vote down vote up
/**
 * Setting the layout of a <i>Reset</i> option button. Either a button image is set - if existing - or a text.
 *
 * @param button The button
 */
private FormData layoutResetOptionButton( Button button ) {
  FormData fd = new FormData();
  Image editButton = GuiResource.getInstance().getResetOptionButton();
  if ( editButton != null ) {
    button.setImage( editButton );
    button.setBackground( GuiResource.getInstance().getColorWhite() );
    fd.width = editButton.getBounds().width + 20;
    fd.height = editButton.getBounds().height;
  } else {
    button.setText( BaseMessages.getString( PKG, "EnterOptionsDialog.Button.Reset" ) );
  }

  button.setToolTipText( BaseMessages.getString( PKG, "EnterOptionsDialog.Button.Reset.Tooltip" ) );
  return fd;
}
 
Example #7
Source File: EnterOptionsDialog.java    From hop with Apache License 2.0 6 votes vote down vote up
/**
 * Setting the layout of an <i>Edit</i> option button. Either a button image is set - if existing - or a text.
 *
 * @param button The button
 */
private FormData layoutEditOptionButton( Button button ) {
  FormData fd = new FormData();
  Image editButton = GuiResource.getInstance().getEditOptionButton();
  if ( editButton != null ) {
    button.setImage( editButton );
    button.setBackground( GuiResource.getInstance().getColorWhite() );
    fd.width = editButton.getBounds().width + 20;
    fd.height = editButton.getBounds().height;
  } else {
    button.setText( BaseMessages.getString( PKG, "EnterOptionsDialog.Button.Edit" ) );
  }

  button.setToolTipText( BaseMessages.getString( PKG, "EnterOptionsDialog.Button.Edit.Tooltip" ) );
  return fd;
}
 
Example #8
Source File: BaseTransformDialog.java    From hop with Apache License 2.0 6 votes vote down vote up
/**
 * Aligns the buttons as right-aligned on the dialog.
 *
 * @param buttons     the array of buttons to align
 * @param width       the standardized width of all the buttons
 * @param margin      the margin between buttons
 * @param lastControl (optional) the bottom most control used for aligning the buttons relative to the bottom of the
 *                    controls on the dialog
 */
protected static void rightAlignButtons( Button[] buttons, int width, int margin, Control lastControl ) {
  for ( int i = buttons.length - 1; i >= 0; --i ) {
    FormData formData = createDefaultFormData( buttons[ i ], width, margin, lastControl );

    // Set the right side of the buttons (either offset from the edge, or relative to the previous button)
    if ( i == buttons.length - 1 ) {
      formData.left = new FormAttachment( 100, -( width + margin ) );
    } else {
      formData.left = new FormAttachment( buttons[ i + 1 ], -( 2 * ( width + margin ) ) - margin );
    }

    // Apply the layout data
    buttons[ i ].setLayoutData( formData );
  }
}
 
Example #9
Source File: BaseTransformDialog.java    From hop with Apache License 2.0 6 votes vote down vote up
/**
 * Aligns the buttons as left-aligned on the dialog.
 *
 * @param buttons     the array of buttons to align
 * @param width       the standardized width of all the buttons
 * @param margin      the margin between buttons
 * @param lastControl (optional) the bottom most control used for aligning the buttons relative to the bottom of the
 *                    controls on the dialog
 */
protected static void leftAlignButtons( Button[] buttons, int width, int margin, Control lastControl ) {
  for ( int i = 0; i < buttons.length; ++i ) {
    FormData formData = createDefaultFormData( buttons[ i ], width, margin, lastControl );

    // Set the left side of the buttons (either offset from the edge, or relative to the previous button)
    if ( i == 0 ) {
      formData.left = new FormAttachment( 0, margin );
    } else {
      formData.left = new FormAttachment( buttons[ i - 1 ], margin );
    }

    // Apply the layout data
    buttons[ i ].setLayoutData( formData );
  }
}
 
Example #10
Source File: FormInput.java    From hop with Apache License 2.0 6 votes vote down vote up
/**
 * setter for the element position
 *
 * @param FormAttachment position
 * @param widget         to set position, [ lable, input ]
 * @param position       side, [ left, right, top, bottom ]
 */
public void setPosition( FormAttachment position, Widget widget, Position side ) {
  FormData layout = widget == Widget.LABEL ? getLabelFD() : getInputFD();

  switch ( side ) {
    case LEFT:
      layout.left = position;
      break;
    case RIGHT:
      layout.right = position;
      break;
    case TOP:
      layout.top = position;
      break;
    case BOTTOM:
      layout.bottom = position;
      break;
    default:
      break;
  }
}
 
Example #11
Source File: TeraFastDialog.java    From hop with Apache License 2.0 6 votes vote down vote up
/**
 * @param factory factory to use.
 */
protected void buildFastloadLine( final PluginWidgetFactory factory ) {
  final Control topControl = this.wVariableSubstitution;

  this.wlFastLoadPath =
    factory.createRightLabel( BaseMessages.getString( PKG, "TeraFastDialog.FastloadPath.Label" ) );
  this.props.setLook( this.wlFastLoadPath );
  this.wlFastLoadPath.setLayoutData( factory.createLabelLayoutData( topControl ) );

  this.wbFastLoadPath = factory.createPushButton( BaseMessages.getString( PKG, "TeraFastDialog.Browse.Button" ) );
  this.props.setLook( this.wbFastLoadPath );
  FormData formData = factory.createControlLayoutData( topControl );
  formData.left = null;
  this.wbFastLoadPath.setLayoutData( formData );

  this.wFastLoadPath = factory.createSingleTextVarLeft();
  this.props.setLook( this.wFastLoadPath );
  formData = factory.createControlLayoutData( topControl );
  formData.right = new FormAttachment( this.wbFastLoadPath, -factory.getMargin() );
  this.wFastLoadPath.setLayoutData( formData );
}
 
Example #12
Source File: BaseTransformDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
/**
 * Creats a default FormData object with the top / bottom / and left set (this is done to cut down on repetative code
 * lines.
 *
 * @param button      the button to which this form data will be applied
 * @param width       the width of the button
 * @param margin      the margin between buttons
 * @param lastControl the last control above the buttons
 * @return the newly created FormData object
 */
private static FormData createDefaultFormData( Button button, int width, int margin, Control lastControl ) {
  FormData formData = new FormData();
  if ( lastControl != null ) {
    formData.top = new FormAttachment( lastControl, margin * 3 );
  } else {
    formData.bottom = new FormAttachment( 100, 0 );
  }
  formData.right = new FormAttachment( button, width + margin );
  return formData;
}
 
Example #13
Source File: TeraFastDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
/**
 * @param factory factory to use.
 */
protected void buildAscLink( final PluginWidgetFactory factory ) {
  final Control topControl = this.wReturn;

  FormData formData = factory.createLabelLayoutData( topControl );
  formData.right = null;
}
 
Example #14
Source File: NumberRangeDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the table of rules
 */
private void createRulesTable( ModifyListener lsMod ) {
  Label rulesLable = new Label( shell, SWT.NONE );
  rulesLable.setText( BaseMessages.getString( PKG, "NumberRange.Ranges" ) );
  props.setLook( rulesLable );
  FormData lableFormData = new FormData();
  lableFormData.left = new FormAttachment( 0, 0 );
  lableFormData.right = new FormAttachment( props.getMiddlePct(), -props.getMargin() );
  lableFormData.top = new FormAttachment( fallBackValueControl, props.getMargin() );
  rulesLable.setLayoutData( lableFormData );

  final int FieldsRows = input.getRules().size();

  ColumnInfo[] colinf = new ColumnInfo[ 3 ];
  colinf[ 0 ] =
    new ColumnInfo(
      BaseMessages.getString( PKG, "NumberRange.LowerBound" ), ColumnInfo.COLUMN_TYPE_TEXT, false );
  colinf[ 1 ] =
    new ColumnInfo(
      BaseMessages.getString( PKG, "NumberRange.UpperBound" ), ColumnInfo.COLUMN_TYPE_TEXT, false );
  colinf[ 2 ] =
    new ColumnInfo( BaseMessages.getString( PKG, "NumberRange.Value" ), ColumnInfo.COLUMN_TYPE_TEXT, false );

  rulesControl =
    new TableView(
      pipelineMeta, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, FieldsRows, lsMod, props );

  fdFields = new FormData();
  fdFields.left = new FormAttachment( 0, 0 );
  fdFields.top = new FormAttachment( rulesLable, props.getMargin() );
  fdFields.right = new FormAttachment( 100, 0 );
  fdFields.bottom = new FormAttachment( 100, -50 );
  rulesControl.setLayoutData( fdFields );
}
 
Example #15
Source File: HopGuiPipelineLogDelegate.java    From hop with Apache License 2.0 5 votes vote down vote up
private void addToolBar() {
  toolbar = new ToolBar( pipelineLogComposite, SWT.BORDER | SWT.WRAP | SWT.SHADOW_OUT | SWT.LEFT | SWT.HORIZONTAL );
  FormData fdToolBar = new FormData();
  fdToolBar.left = new FormAttachment( 0, 0 );
  fdToolBar.top = new FormAttachment( 0, 0 );
  fdToolBar.right = new FormAttachment( 100, 0 );
  toolbar.setLayoutData( fdToolBar );
  hopGui.getProps().setLook( toolbar, Props.WIDGET_STYLE_TOOLBAR );

  toolBarWidgets = new GuiToolbarWidgets();
  toolBarWidgets.registerGuiPluginObject( this );
  toolBarWidgets.createToolbarWidgets( toolbar, GUI_PLUGIN_TOOLBAR_PARENT_ID );
  toolbar.pack();
}
 
Example #16
Source File: BaseTransformDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
/**
 * Aligns the buttons as centered on the dialog.
 *
 * @param buttons     the array of buttons to align
 * @param width       the standardized width of all the buttons
 * @param margin      the margin between buttons
 * @param lastControl (optional) the bottom most control used for aligning the buttons relative to the bottom of the
 *                    controls on the dialog
 */
protected static void centerButtons( Button[] buttons, int width, int margin, Control lastControl ) {
  // Setup the middle button
  int middleButtonIndex = buttons.length / 2;
  FormData formData = createDefaultFormData( buttons[ middleButtonIndex ], width, margin, lastControl );

  // See if we have an even or odd number of buttons...
  int leftOffset = 0;
  if ( buttons.length % 2 == 0 ) {
    // Even number of buttons - the middle is between buttons. The "middle" button is
    // actually to the right of middle
    leftOffset = margin;
  } else {
    // Odd number of buttons - tht middle is in the middle of the button
    leftOffset = -( width + margin ) / 2;
  }
  formData.left = new FormAttachment( 50, leftOffset );
  buttons[ middleButtonIndex ].setLayoutData( formData );

  // Do the buttons to the right of the middle
  for ( int i = middleButtonIndex + 1; i < buttons.length; ++i ) {
    formData = createDefaultFormData( buttons[ i ], width, margin, lastControl );
    formData.left = new FormAttachment( buttons[ i - 1 ], margin );
    buttons[ i ].setLayoutData( formData );
  }

  // Do the buttons to the left of the middle
  for ( int i = middleButtonIndex - 1; i >= 0; --i ) {
    formData = createDefaultFormData( buttons[ i ], width, margin, lastControl );
    formData.left = new FormAttachment( buttons[ i + 1 ], -( 2 * ( width + margin ) ) - margin );
    buttons[ i ].setLayoutData( formData );
  }
}
 
Example #17
Source File: WorkflowExecutionConfigurationDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
private void addRunConfigurationSectionLayout() {
  String runConfigLabel = BaseMessages.getString( PKG, "ConfigurationDialog.RunConfiguration.Label" );
  String runConfigTooltip = BaseMessages.getString( PKG, "ConfigurationDialog.RunConfiguration.Tooltip" );

  wRunConfiguration = new MetaSelectionLine<>( hopGui.getVariables(), hopGui.getMetadataProvider(), WorkflowRunConfiguration.class,
    shell, SWT.BORDER, runConfigLabel, runConfigTooltip, true );
  wRunConfigurationControl = wRunConfiguration;
  props.setLook( wRunConfiguration );
  FormData fdRunConfiguration = new FormData();
  fdRunConfiguration.right = new FormAttachment( 100, 0 );
  fdRunConfiguration.top = new FormAttachment( 0, props.getMargin() );
  fdRunConfiguration.left = new FormAttachment( 0, 0 );
  wRunConfiguration.setLayoutData( fdRunConfiguration );
}
 
Example #18
Source File: LabelCombo.java    From hop with Apache License 2.0 5 votes vote down vote up
public LabelCombo( Composite composite, int flags, String labelText, String toolTipText ) {
  super( composite, SWT.NONE );
  props.setLook( this );

  int middle = props.getMiddlePct();
  int margin = props.getMargin();

  FormLayout formLayout = new FormLayout();
  formLayout.marginWidth = 0;
  formLayout.marginHeight = 0;
  formLayout.marginTop = 0;
  formLayout.marginBottom = 0;

  this.setLayout( formLayout );

  int textFlags = SWT.SINGLE | SWT.LEFT | SWT.BORDER;
  if ( flags != SWT.NONE ) {
    textFlags = flags;
  }

  wCombo = new CCombo( this, textFlags );
  FormData fdText = new FormData();
  fdText.left = new FormAttachment( middle, margin );
  fdText.right = new FormAttachment( 100, 0 );
  wCombo.setLayoutData( fdText );
  wCombo.setToolTipText( toolTipText );

  wLabel = new Label( this, SWT.RIGHT );
  props.setLook( wLabel );
  wLabel.setText( labelText );
  FormData fdLabel = new FormData();
  fdLabel.left = new FormAttachment( 0, 0 );
  fdLabel.right = new FormAttachment( middle, 0 );
  fdLabel.top = new FormAttachment( wCombo, 0, SWT.CENTER );
  wLabel.setLayoutData( fdLabel );
  wLabel.setToolTipText( toolTipText );
}
 
Example #19
Source File: HopGuiPipelineGridDelegate.java    From hop with Apache License 2.0 5 votes vote down vote up
private void addToolBar() {

    toolbar = new ToolBar( pipelineGridComposite, SWT.BORDER | SWT.WRAP | SWT.SHADOW_OUT | SWT.LEFT | SWT.HORIZONTAL );
    FormData fdToolBar = new FormData();
    fdToolBar.left = new FormAttachment( 0, 0 );
    fdToolBar.top = new FormAttachment( 0, 0 );
    fdToolBar.right = new FormAttachment( 100, 0 );
    toolbar.setLayoutData( fdToolBar );
    hopGui.getProps().setLook( toolbar, Props.WIDGET_STYLE_TOOLBAR );

    toolbarWidget = new GuiToolbarWidgets();
    toolbarWidget.registerGuiPluginObject( this );
    toolbarWidget.createToolbarWidgets( toolbar, GUI_PLUGIN_TOOLBAR_PARENT_ID );
    toolbar.pack();
  }
 
Example #20
Source File: ActionSpecialDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
private void placeControl( Shell pShell, String text, Control control, Control under ) {
  int middle = props.getMiddlePct();
  int margin = props.getMargin();
  Label label = new Label( pShell, SWT.RIGHT );
  label.setText( text );
  props.setLook( label );
  FormData formDataLabel = new FormData();
  formDataLabel.left = new FormAttachment( 0, 0 );
  if ( under != null ) {
    formDataLabel.top = new FormAttachment( under, margin );
  } else {
    formDataLabel.top = new FormAttachment( 0, 0 );
  }
  formDataLabel.right = new FormAttachment( middle, 0 );
  label.setLayoutData( formDataLabel );

  props.setLook( control );
  FormData formDataControl = new FormData();
  formDataControl.left = new FormAttachment( middle, 0 );
  if ( under != null ) {
    formDataControl.top = new FormAttachment( under, margin );
  } else {
    formDataControl.top = new FormAttachment( 0, 0 );
  }
  formDataControl.right = new FormAttachment( 100, 0 );
  control.setLayoutData( formDataControl );
}
 
Example #21
Source File: HelpUtils.java    From hop with Apache License 2.0 5 votes vote down vote up
private static Button newButton( final Composite parent ) {
  Button button = new Button( parent, SWT.PUSH );
  button.setImage( GuiResource.getInstance().getImageHelpWeb() );
  button.setText( BaseMessages.getString( PKG, "System.Button.Help" ) );
  button.setToolTipText( BaseMessages.getString( PKG, "System.Tooltip.Help" ) );
  FormData fdButton = new FormData();
  fdButton.left = new FormAttachment( 0, 0 );
  fdButton.bottom = new FormAttachment( 100, 0 );
  button.setLayoutData( fdButton );
  return button;
}
 
Example #22
Source File: BrowserEnvironmentWarningDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
private void setWarningIcon( Display display ) {
  warningIcon = new Label( shell, SWT.NONE );
  Image image = display.getSystemImage( SWT.ICON_WARNING );
  warningIcon.setImage( image );
  props.setLook( warningIcon );
  FormData fdIcon = new FormData();
  fdIcon.left = new FormAttachment( 0, 0 );
  fdIcon.top = new FormAttachment( 0, 0 );
  fdIcon.right = new FormAttachment( 0, image.getBounds().width );
  fdIcon.bottom = new FormAttachment( 0, image.getBounds().height ); //icon should be at the top left corner
  warningIcon.setLayoutData( fdIcon );
}
 
Example #23
Source File: BrowserEnvironmentWarningDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
private void setWarningText( String message, int maxTextWidth ) {
  description = new Text( shell, SWT.MULTI | SWT.LEFT | SWT.WRAP | SWT.NO_FOCUS | SWT.HIDE_SELECTION );
  description.setText( message );
  description.setEditable( false );
  FormData fdlDesc = new FormData();
  fdlDesc.left = new FormAttachment( warningIcon, margin ); // Text should be right of the icon and at the top
  fdlDesc.top = new FormAttachment( 0, 0 );
  fdlDesc.width = maxTextWidth;
  description.setLayoutData( fdlDesc );
  props.setLook( description );
}
 
Example #24
Source File: TextFileImportWizardPage1.java    From hop with Apache License 2.0 5 votes vote down vote up
public void createControl( Composite parent ) {
  // create the composite to hold the widgets
  Composite composite = new Composite( parent, SWT.NONE );
  props.setLook( composite );

  FormLayout compLayout = new FormLayout();
  compLayout.marginHeight = Const.FORM_MARGIN;
  compLayout.marginWidth = Const.FORM_MARGIN;
  composite.setLayout( compLayout );

  MouseAdapter lsMouse = new MouseAdapter() {
    public void mouseDown( MouseEvent e ) {
      int s = getSize();
      setPageComplete( s > 0 );
    }
  };

  wTable = new TableDraw( composite, props, this, fields );
  wTable.setRows( rows );
  props.setLook( wTable );
  wTable.setFields( fields );
  fdTable = new FormData();
  fdTable.left = new FormAttachment( 0, 0 );
  fdTable.right = new FormAttachment( 100, 0 );
  fdTable.top = new FormAttachment( 0, 0 );
  fdTable.bottom = new FormAttachment( 100, 0 );
  wTable.setLayoutData( fdTable );
  wTable.addMouseListener( lsMouse );

  // set the composite as the control for this page
  setControl( composite );
}
 
Example #25
Source File: WidgetUtils.java    From hop with Apache License 2.0 5 votes vote down vote up
/**
 * 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, BaseTransformMeta transformMeta, FormData formData ) {
  PipelineMeta pipelineMeta = transformMeta.getParentTransformMeta().getParentPipelineMeta();
  ComboVar fieldDropDownCombo = new ComboVar( pipelineMeta, 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( 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;
}
 
Example #26
Source File: WidgetUtils.java    From hop with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a FormData object specifying placement below anchorControl, with pixelsBetweeenAnchor space between
 * anchor and the control.
 */
public static FormData formDataBelow( Control anchorControl, int width, int pixelsBetweenAnchor ) {
  FormData fdMessageField = new FormData();
  fdMessageField.left = new FormAttachment( 0, 0 );
  fdMessageField.top = new FormAttachment( anchorControl, pixelsBetweenAnchor );
  fdMessageField.right = new FormAttachment( 0, width );
  return fdMessageField;
}
 
Example #27
Source File: MultiMergeJoinDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
/**
 * Create widgets for join type selection
 *
 * @param lsMod
 */
private void createJoinTypeWidget( final ModifyListener lsMod ) {
  Label joinTypeLabel = new Label( shell, SWT.LEFT );
  joinTypeLabel.setText( BaseMessages.getString( PKG, "MultiMergeJoinDialog.Type.Label" ) );
  props.setLook( joinTypeLabel );
  FormData fdlType = new FormData();
  fdlType.left = new FormAttachment( 0, 0 );
  fdlType.right = new FormAttachment( 15, -margin );
  if ( wInputTransformArray.length > 0 ) {
    fdlType.top = new FormAttachment( wInputTransformArray[ wInputTransformArray.length - 1 ], margin );
  } else {
    fdlType.top = new FormAttachment( wTransformName, margin );
  }
  joinTypeLabel.setLayoutData( fdlType );
  joinTypeCombo = new CCombo( shell, SWT.BORDER );
  props.setLook( joinTypeCombo );

  joinTypeCombo.setItems( MultiMergeJoinMeta.join_types );

  joinTypeCombo.addModifyListener( lsMod );
  FormData fdType = new FormData();
  if ( wInputTransformArray.length > 0 ) {
    fdType.top = new FormAttachment( wInputTransformArray[ wInputTransformArray.length - 1 ], margin );
  } else {
    fdType.top = new FormAttachment( wTransformName, margin );
  }
  fdType.left = new FormAttachment( 15, 0 );
  fdType.right = new FormAttachment( 35, 0 );
  joinTypeCombo.setLayoutData( fdType );
}
 
Example #28
Source File: MetaSelectionLine.java    From hop with Apache License 2.0 5 votes vote down vote up
/**
 * Adds the connection line for the given parent and previous control, and returns a meta selection manager control
 *
 * @param parent   the parent composite object
 * @param previous the previous control
 * @param
 * @return the combo box UI component
 */
public void addToConnectionLine( Composite parent, Control previous, T selected, ModifyListener lsMod ) {

  try {
    fillItems();
  } catch ( Exception e ) {
    LogChannel.UI.logError( "Error getting list of element names from the metadata", e );
  }
  if (lsMod!=null) {
    addModifyListener( lsMod );
  }

  // Set a default value if there is only 1 connection in the list and nothing else is previously selected...
  //
  if ( selected == null ) {
    if ( getItemCount() == 1 ) {
      select( 0 );
    }
  } else {
    // Just set the value
    //
    setText( Const.NVL( selected.getName(), "" ) );
  }

  FormData fdConnection = new FormData();
  fdConnection.left = new FormAttachment( 0, 0 );
  fdConnection.right = new FormAttachment( 100, 0 );
  if ( previous != null ) {
    fdConnection.top = new FormAttachment( previous, props.getMargin() );
  } else {
    fdConnection.top = new FormAttachment( 0, 0 );
  }
  setLayoutData( fdConnection );
}
 
Example #29
Source File: LabelText.java    From hop with Apache License 2.0 5 votes vote down vote up
public LabelText( Composite composite, int textStyle, String labelText, String toolTipText, int middle,
                  int margin ) {
  super( composite, SWT.NONE );
  props.setLook( this );

  FormLayout formLayout = new FormLayout();
  formLayout.marginWidth = 0;
  formLayout.marginHeight = 0;
  this.setLayout( formLayout );

  wText = new Text( this, textStyle );
  FormData fdText = new FormData();
  fdText.left = new FormAttachment( middle, margin );
  fdText.right = new FormAttachment( 100, 0 );
  wText.setLayoutData( fdText );
  wText.setToolTipText( toolTipText );

  wLabel = new Label( this, SWT.RIGHT );
  props.setLook( wLabel );
  wLabel.setText( labelText );
  FormData fdLabel = new FormData();
  fdLabel.left = new FormAttachment( 0, 0 );
  fdLabel.right = new FormAttachment( middle, 0 );
  fdLabel.top = new FormAttachment( wText, 0, SWT.CENTER );
  wLabel.setLayoutData( fdLabel );
  wLabel.setToolTipText( toolTipText );
}
 
Example #30
Source File: HopGui.java    From hop with Apache License 2.0 5 votes vote down vote up
protected void addMainToolbar() {
  mainToolbar = new ToolBar( shell, SWT.WRAP | SWT.LEFT | SWT.HORIZONTAL );
  FormData fdToolBar = new FormData();
  fdToolBar.left = new FormAttachment( 0, 0 );
  fdToolBar.top = new FormAttachment( 0, 0 );
  fdToolBar.right = new FormAttachment( 100, 0 );
  mainToolbar.setLayoutData( fdToolBar );
  props.setLook( mainToolbar, Props.WIDGET_STYLE_TOOLBAR );

  mainToolbarWidgets = new GuiToolbarWidgets();
  mainToolbarWidgets.registerGuiPluginObject( this );
  mainToolbarWidgets.createToolbarWidgets( mainToolbar, ID_MAIN_TOOLBAR );
  mainToolbar.pack();
}