Java Code Examples for org.eclipse.jface.dialogs.MessageDialogWithToggle#setDefaultImage()

The following examples show how to use org.eclipse.jface.dialogs.MessageDialogWithToggle#setDefaultImage() . 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: RepositoryImportProgressDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public boolean transOverwritePrompt( TransMeta transMeta ) {
  MessageDialogWithToggle md = new MessageDialogWithToggle( shell,
    BaseMessages.getString( PKG, "RepositoryImportDialog.OverwriteTrans.Title" ),
    null,
    BaseMessages.getString( PKG, "RepositoryImportDialog.OverwriteTrans.Message", transMeta.getName() ),
    MessageDialog.QUESTION, new String[] {
      BaseMessages.getString( PKG, "System.Button.Yes" ),
      BaseMessages.getString( PKG, "System.Button.No" ) },
    1,
    BaseMessages.getString( PKG, "RepositoryImportDialog.DontAskAgain.Label" ), !askOverwrite );
  MessageDialogWithToggle.setDefaultImage( GUIResource.getInstance().getImageSpoon() );
  int answer = md.open();

  askOverwrite = !md.getToggleState();

  return ( answer & 0xFF ) == 0;
}
 
Example 2
Source File: TransGraph.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void handleTransMetaChanges( TransMeta transMeta ) throws KettleException {
  if ( transMeta.hasChanged() ) {
    if ( spoon.props.getAutoSave() ) {
      spoon.saveToFile( transMeta );
    } else {
      MessageDialogWithToggle md =
        new MessageDialogWithToggle( shell, BaseMessages.getString( PKG, "TransLog.Dialog.FileHasChanged.Title" ),
          null, BaseMessages.getString( PKG, "TransLog.Dialog.FileHasChanged1.Message" ) + Const.CR
          + BaseMessages.getString( PKG, "TransLog.Dialog.FileHasChanged2.Message" ) + Const.CR,
          MessageDialog.QUESTION, new String[] { BaseMessages.getString( PKG, "System.Button.Yes" ),
          BaseMessages.getString( PKG, "System.Button.No" ) }, 0, BaseMessages.getString( PKG,
          "TransLog.Dialog.Option.AutoSaveTransformation" ), spoon.props.getAutoSave() );
      MessageDialogWithToggle.setDefaultImage( GUIResource.getInstance().getImageSpoon() );
      int answer = md.open();
      if ( ( answer & 0xFF ) == 0 ) {
        spoon.saveToFile( transMeta );
      }
      spoon.props.setAutoSave( md.getToggleState() );
    }
  }
}
 
Example 3
Source File: MultiMergeJoinDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void ok() {
  if ( Utils.isEmpty( wStepname.getText() ) ) {
    return;
  }
  getMeta( joinMeta );
  // Show a warning (optional)
  if ( "Y".equalsIgnoreCase( props.getCustomParameter( STRING_SORT_WARNING_PARAMETER, "Y" ) ) ) {
    MessageDialogWithToggle md =
      new MessageDialogWithToggle( shell,
        BaseMessages.getString( PKG, "MultiMergeJoinDialog.InputNeedSort.DialogTitle" ),
        null,
        BaseMessages.getString( PKG, "MultiMergeJoinDialog.InputNeedSort.DialogMessage", Const.CR ) + Const.CR,
        MessageDialog.WARNING,
        new String[] { BaseMessages.getString( PKG, "MultiMergeJoinDialog.InputNeedSort.Option1" ) },
        0,
        BaseMessages.getString( PKG, "MultiMergeJoinDialog.InputNeedSort.Option2" ),
        "N".equalsIgnoreCase( props.getCustomParameter( STRING_SORT_WARNING_PARAMETER, "Y" ) ) );
    MessageDialogWithToggle.setDefaultImage( GUIResource.getInstance().getImageSpoon() );
    md.open();
    props.setCustomParameter( STRING_SORT_WARNING_PARAMETER, md.getToggleState() ? "N" : "Y" );
    props.saveProps();
  }
  stepname = wStepname.getText(); // return value
  dispose();
}
 
Example 4
Source File: RepositoryImportProgressDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public boolean jobOverwritePrompt( JobMeta jobMeta ) {
  MessageDialogWithToggle md =
    new MessageDialogWithToggle(
      shell, BaseMessages.getString( PKG, "RepositoryImportDialog.OverwriteJob.Title" ), null, BaseMessages
        .getString( PKG, "RepositoryImportDialog.OverwriteJob.Message", jobMeta.getName() ),
      MessageDialog.QUESTION, new String[] {
        BaseMessages.getString( PKG, "System.Button.Yes" ),
        BaseMessages.getString( PKG, "System.Button.No" ) },
      1,
      BaseMessages.getString( PKG, "RepositoryImportDialog.DontAskAgain.Label" ),
      !askOverwrite );
  MessageDialogWithToggle.setDefaultImage( GUIResource.getInstance().getImageSpoon() );
  int answer = md.open();
  askOverwrite = !md.getToggleState();

  return ( answer & 0xFF ) == 0;
}
 
Example 5
Source File: MultiMergeJoinDialog.java    From hop with Apache License 2.0 6 votes vote down vote up
private void ok() {
  if ( Utils.isEmpty( wTransformName.getText() ) ) {
    return;
  }
  getMeta( joinMeta );
  // Show a warning (optional)
  if ( "Y".equalsIgnoreCase( props.getCustomParameter( STRING_SORT_WARNING_PARAMETER, "Y" ) ) ) {
    MessageDialogWithToggle md =
      new MessageDialogWithToggle( shell,
        BaseMessages.getString( PKG, "MultiMergeJoinDialog.InputNeedSort.DialogTitle" ),
        null,
        BaseMessages.getString( PKG, "MultiMergeJoinDialog.InputNeedSort.DialogMessage", Const.CR ) + Const.CR,
        MessageDialog.WARNING,
        new String[] { BaseMessages.getString( PKG, "MultiMergeJoinDialog.InputNeedSort.Option1" ) },
        0,
        BaseMessages.getString( PKG, "MultiMergeJoinDialog.InputNeedSort.Option2" ),
        "N".equalsIgnoreCase( props.getCustomParameter( STRING_SORT_WARNING_PARAMETER, "Y" ) ) );
    MessageDialogWithToggle.setDefaultImage( GUIResource.getInstance().getImageHopUi() );
    md.open();
    props.setCustomParameter( STRING_SORT_WARNING_PARAMETER, md.getToggleState() ? "N" : "Y" );
  }
  transformName = wTransformName.getText(); // return value
  dispose();
}
 
Example 6
Source File: HopGuiPipelineGraph.java    From hop with Apache License 2.0 6 votes vote down vote up
public void handlePipelineMetaChanges( PipelineMeta pipelineMeta ) throws HopException {
  if ( pipelineMeta.hasChanged() ) {
    if ( hopGui.getProps().getAutoSave() ) {
      save();
    } else {
      MessageDialogWithToggle md =
        new MessageDialogWithToggle( hopShell(), BaseMessages.getString( PKG, "PipelineLog.Dialog.FileHasChanged.Title" ),
          null, BaseMessages.getString( PKG, "PipelineLog.Dialog.FileHasChanged1.Message" ) + Const.CR
          + BaseMessages.getString( PKG, "PipelineLog.Dialog.FileHasChanged2.Message" ) + Const.CR,
          MessageDialog.QUESTION, new String[] { BaseMessages.getString( PKG, "System.Button.Yes" ),
          BaseMessages.getString( PKG, "System.Button.No" ) }, 0, BaseMessages.getString( PKG,
          "PipelineLog.Dialog.Option.AutoSavePipeline" ), hopGui.getProps().getAutoSave() );
      MessageDialogWithToggle.setDefaultImage( GuiResource.getInstance().getImageHopUi() );
      int answer = md.open();
      if ( ( answer & 0xFF ) == 0 ) {
        save();
      }
      hopGui.getProps().setAutoSave( md.getToggleState() );
    }
  }
}
 
Example 7
Source File: FieldsChangeSequenceDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
private void ok() {
  if ( Utils.isEmpty( wTransformName.getText() ) ) {
    return;
  }
  transformName = wTransformName.getText(); // return value

  input.setStart( wStart.getText() );
  input.setIncrement( wIncrement.getText() );
  input.setResultFieldName( wResult.getText() );

  int nrFields = wFields.nrNonEmpty();
  input.allocate( nrFields );
  for ( int i = 0; i < nrFields; i++ ) {
    TableItem ti = wFields.getNonEmpty( i );
    //CHECKSTYLE:Indentation:OFF
    input.getFieldName()[ i ] = ti.getText( 1 );
  }

  if ( "Y".equalsIgnoreCase( props.getCustomParameter( STRING_CHANGE_SEQUENCE_WARNING_PARAMETER, "Y" ) ) ) {
    MessageDialogWithToggle md =
      new MessageDialogWithToggle( shell,
        BaseMessages.getString( PKG, "FieldsChangeSequenceDialog.InputNeedSort.DialogTitle" ),
        null,
        BaseMessages.getString( PKG, "FieldsChangeSequenceDialog.InputNeedSort.DialogMessage", Const.CR ) + Const.CR,
        MessageDialog.WARNING,
        new String[] { BaseMessages.getString( PKG, "FieldsChangeSequenceDialog.InputNeedSort.Option1" ) },
        0,
        BaseMessages.getString( PKG, "FieldsChangeSequenceDialog.InputNeedSort.Option2" ), "N".equalsIgnoreCase(
        props.getCustomParameter( STRING_CHANGE_SEQUENCE_WARNING_PARAMETER, "Y" ) ) );
    MessageDialogWithToggle.setDefaultImage( GuiResource.getInstance().getImageHopUi() );
    md.open();
    props.setCustomParameter( STRING_CHANGE_SEQUENCE_WARNING_PARAMETER, md.getToggleState() ? "N" : "Y" );
  }

  dispose();
}
 
Example 8
Source File: MergeJoinDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
private void ok() {
  if ( Utils.isEmpty( wTransformName.getText() ) ) {
    return;
  }

  getMeta( input );

  // Show a warning (optional)
  //
  if ( "Y".equalsIgnoreCase( props.getCustomParameter( STRING_SORT_WARNING_PARAMETER, "Y" ) ) ) {
    MessageDialogWithToggle md =
      new MessageDialogWithToggle( shell,
        BaseMessages.getString( PKG, "MergeJoinDialog.InputNeedSort.DialogTitle" ),
        null,
        BaseMessages.getString( PKG, "MergeJoinDialog.InputNeedSort.DialogMessage", Const.CR ) + Const.CR,
        MessageDialog.WARNING,
        new String[] { BaseMessages.getString( PKG, "MergeJoinDialog.InputNeedSort.Option1" ) },
        0,
        BaseMessages.getString( PKG, "MergeJoinDialog.InputNeedSort.Option2" ), "N".equalsIgnoreCase(
        props.getCustomParameter( STRING_SORT_WARNING_PARAMETER, "Y" ) ) );
    MessageDialogWithToggle.setDefaultImage( GuiResource.getInstance().getImageHopUi() );
    md.open();
    props.setCustomParameter( STRING_SORT_WARNING_PARAMETER, md.getToggleState() ? "N" : "Y" );
  }

  transformName = wTransformName.getText(); // return value

  dispose();
}
 
Example 9
Source File: SortedMergeDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
private void ok() {
  if ( Utils.isEmpty( wTransformName.getText() ) ) {
    return;
  }

  transformName = wTransformName.getText(); // return value

  int nrFields = wFields.nrNonEmpty();

  input.allocate( nrFields );

  //CHECKSTYLE:Indentation:OFF
  for ( int i = 0; i < nrFields; i++ ) {
    TableItem ti = wFields.getNonEmpty( i );
    input.getFieldName()[ i ] = ti.getText( 1 );
    input.getAscending()[ i ] =
      BaseMessages.getString( PKG, "System.Combo.Yes" ).equalsIgnoreCase( ti.getText( 2 ) );
  }

  // Show a warning (optional)
  //
  if ( "Y".equalsIgnoreCase( props.getCustomParameter( STRING_SORT_WARNING_PARAMETER, "Y" ) ) ) {
    MessageDialogWithToggle md =
      new MessageDialogWithToggle( shell,
        BaseMessages.getString( PKG, "SortedMergeDialog.InputNeedSort.DialogTitle" ),
        null,
        BaseMessages.getString( PKG, "SortedMergeDialog.InputNeedSort.DialogMessage", Const.CR ) + Const.CR,
        MessageDialog.WARNING,
        new String[] { BaseMessages.getString( PKG, "SortedMergeDialog.InputNeedSort.Option1" ) },
        0,
        BaseMessages.getString( PKG, "SortedMergeDialog.InputNeedSort.Option2" ),
        "N".equalsIgnoreCase( props.getCustomParameter( STRING_SORT_WARNING_PARAMETER, "Y" ) ) );
    MessageDialogWithToggle.setDefaultImage( GuiResource.getInstance().getImageHopUi() );
    md.open();
    props.setCustomParameter( STRING_SORT_WARNING_PARAMETER, md.getToggleState() ? "N" : "Y" );
  }

  dispose();
}
 
Example 10
Source File: FieldsChangeSequenceDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void ok() {
  if ( Utils.isEmpty( wStepname.getText() ) ) {
    return;
  }
  stepname = wStepname.getText(); // return value

  input.setStart( wStart.getText() );
  input.setIncrement( wIncrement.getText() );
  input.setResultFieldName( wResult.getText() );

  int nrfields = wFields.nrNonEmpty();
  input.allocate( nrfields );
  for ( int i = 0; i < nrfields; i++ ) {
    TableItem ti = wFields.getNonEmpty( i );
    //CHECKSTYLE:Indentation:OFF
    input.getFieldName()[i] = ti.getText( 1 );
  }

  if ( "Y".equalsIgnoreCase( props.getCustomParameter( STRING_CHANGE_SEQUENCE_WARNING_PARAMETER, "Y" ) ) ) {
    MessageDialogWithToggle md =
      new MessageDialogWithToggle( shell,
        BaseMessages.getString( PKG, "FieldsChangeSequenceDialog.InputNeedSort.DialogTitle" ),
        null,
        BaseMessages.getString( PKG, "FieldsChangeSequenceDialog.InputNeedSort.DialogMessage", Const.CR ) + Const.CR,
        MessageDialog.WARNING,
        new String[] { BaseMessages.getString( PKG, "FieldsChangeSequenceDialog.InputNeedSort.Option1" ) },
        0,
        BaseMessages.getString( PKG, "FieldsChangeSequenceDialog.InputNeedSort.Option2" ), "N".equalsIgnoreCase(
          props.getCustomParameter( STRING_CHANGE_SEQUENCE_WARNING_PARAMETER, "Y" ) ) );
    MessageDialogWithToggle.setDefaultImage( GUIResource.getInstance().getImageSpoon() );
    md.open();
    props.setCustomParameter( STRING_CHANGE_SEQUENCE_WARNING_PARAMETER, md.getToggleState() ? "N" : "Y" );
    props.saveProps();
  }

  dispose();
}
 
Example 11
Source File: MergeJoinDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void ok() {
  if ( Utils.isEmpty( wStepname.getText() ) ) {
    return;
  }

  getMeta( input );

  // Show a warning (optional)
  //
  if ( "Y".equalsIgnoreCase( props.getCustomParameter( STRING_SORT_WARNING_PARAMETER, "Y" ) ) ) {
    MessageDialogWithToggle md =
      new MessageDialogWithToggle( shell,
        BaseMessages.getString( PKG, "MergeJoinDialog.InputNeedSort.DialogTitle" ),
        null,
        BaseMessages.getString( PKG, "MergeJoinDialog.InputNeedSort.DialogMessage", Const.CR ) + Const.CR,
        MessageDialog.WARNING,
        new String[] { BaseMessages.getString( PKG, "MergeJoinDialog.InputNeedSort.Option1" ) },
        0,
        BaseMessages.getString( PKG, "MergeJoinDialog.InputNeedSort.Option2" ), "N".equalsIgnoreCase(
          props.getCustomParameter( STRING_SORT_WARNING_PARAMETER, "Y" ) ) );
    MessageDialogWithToggle.setDefaultImage( GUIResource.getInstance().getImageSpoon() );
    md.open();
    props.setCustomParameter( STRING_SORT_WARNING_PARAMETER, md.getToggleState() ? "N" : "Y" );
    props.saveProps();
  }

  stepname = wStepname.getText(); // return value

  dispose();
}
 
Example 12
Source File: SortedMergeDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void ok() {
  if ( Utils.isEmpty( wStepname.getText() ) ) {
    return;
  }

  stepname = wStepname.getText(); // return value

  int nrfields = wFields.nrNonEmpty();

  input.allocate( nrfields );

  //CHECKSTYLE:Indentation:OFF
  for ( int i = 0; i < nrfields; i++ ) {
    TableItem ti = wFields.getNonEmpty( i );
    input.getFieldName()[i] = ti.getText( 1 );
    input.getAscending()[i] =
      BaseMessages.getString( PKG, "System.Combo.Yes" ).equalsIgnoreCase( ti.getText( 2 ) );
  }

  // Show a warning (optional)
  //
  if ( "Y".equalsIgnoreCase( props.getCustomParameter( STRING_SORT_WARNING_PARAMETER, "Y" ) ) ) {
    MessageDialogWithToggle md =
      new MessageDialogWithToggle( shell,
        BaseMessages.getString( PKG, "SortedMergeDialog.InputNeedSort.DialogTitle" ),
        null,
        BaseMessages.getString( PKG, "SortedMergeDialog.InputNeedSort.DialogMessage", Const.CR ) + Const.CR,
        MessageDialog.WARNING,
        new String[] { BaseMessages.getString( PKG, "SortedMergeDialog.InputNeedSort.Option1" ) },
        0,
        BaseMessages.getString( PKG, "SortedMergeDialog.InputNeedSort.Option2" ),
        "N".equalsIgnoreCase( props.getCustomParameter( STRING_SORT_WARNING_PARAMETER, "Y" ) ) );
    MessageDialogWithToggle.setDefaultImage( GUIResource.getInstance().getImageSpoon() );
    md.open();
    props.setCustomParameter( STRING_SORT_WARNING_PARAMETER, md.getToggleState() ? "N" : "Y" );
    props.saveProps();
  }

  dispose();
}
 
Example 13
Source File: JobGraph.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * Go from serial to parallel to serial execution
 */
public void editEntryParallel() {

  JobEntryCopy je = getJobEntry();
  JobEntryCopy jeOld = (JobEntryCopy) je.clone_deep();

  je.setLaunchingInParallel( !je.isLaunchingInParallel() );
  JobEntryCopy jeNew = (JobEntryCopy) je.clone_deep();

  spoon.addUndoChange( jobMeta, new JobEntryCopy[] { jeOld }, new JobEntryCopy[] { jeNew }, new int[] { jobMeta
    .indexOfJobEntry( jeNew ) } );
  jobMeta.setChanged();

  if ( getJobEntry().isLaunchingInParallel() ) {
    // Show a warning (optional)
    //
    if ( "Y".equalsIgnoreCase( spoon.props.getCustomParameter( STRING_PARALLEL_WARNING_PARAMETER, "Y" ) ) ) {
      MessageDialogWithToggle md =
        new MessageDialogWithToggle( shell,
          BaseMessages.getString( PKG, "JobGraph.ParallelJobEntriesWarning.DialogTitle" ),
          null,
          BaseMessages.getString( PKG, "JobGraph.ParallelJobEntriesWarning.DialogMessage", Const.CR ) + Const.CR,
          MessageDialog.WARNING,
          new String[] { BaseMessages.getString( PKG, "JobGraph.ParallelJobEntriesWarning.Option1" ) },
          0,
          BaseMessages.getString( PKG, "JobGraph.ParallelJobEntriesWarning.Option2" ),
          "N".equalsIgnoreCase( spoon.props.getCustomParameter( STRING_PARALLEL_WARNING_PARAMETER, "Y" ) ) );
      MessageDialogWithToggle.setDefaultImage( GUIResource.getInstance().getImageSpoon() );
      md.open();
      spoon.props.setCustomParameter( STRING_PARALLEL_WARNING_PARAMETER, md.getToggleState() ? "N" : "Y" );
      spoon.props.saveProps();
    }
  }
  spoon.refreshGraph();

}
 
Example 14
Source File: UniqueRowsDialog.java    From hop with Apache License 2.0 4 votes vote down vote up
private void ok() {
  if ( Utils.isEmpty( wTransformName.getText() ) ) {
    return;
  }

  int nrFields = wFields.nrNonEmpty();
  input.allocate( nrFields );

  //CHECKSTYLE:Indentation:OFF
  for ( int i = 0; i < nrFields; i++ ) {
    TableItem item = wFields.getNonEmpty( i );
    input.getCompareFields()[ i ] = item.getText( 1 );
    input.getCaseInsensitive()[ i ] = "Y".equalsIgnoreCase( item.getText( 2 ) );
  }

  input.setCountField( wCountField.getText() );
  input.setCountRows( wCount.getSelection() );
  input.setRejectDuplicateRow( wRejectDuplicateRow.getSelection() );
  input.setErrorDescription( wErrorDesc.getText() );
  transformName = wTransformName.getText(); // return value

  if ( "Y".equalsIgnoreCase( props.getCustomParameter( STRING_SORT_WARNING_PARAMETER, "Y" ) ) ) {
    MessageDialogWithToggle md = new MessageDialogWithToggle( shell,
      BaseMessages.getString( PKG, "UniqueRowsDialog.InputNeedSort.DialogTitle" ),
      null,
      BaseMessages.getString( PKG, "UniqueRowsDialog.InputNeedSort.DialogMessage", Const.CR ) + Const.CR,
      MessageDialog.WARNING,
      new String[] { BaseMessages.getString( PKG, "UniqueRowsDialog.InputNeedSort.Option1" ) },
      0,
      BaseMessages.getString( PKG, "UniqueRowsDialog.InputNeedSort.Option2" ),
      "N".equalsIgnoreCase( props.getCustomParameter( STRING_SORT_WARNING_PARAMETER, "Y" ) ) );
    MessageDialogWithToggle.setDefaultImage( GuiResource.getInstance().getImageHopUi() );
    md.open();
    props.setCustomParameter( STRING_SORT_WARNING_PARAMETER, md.getToggleState() ? "N" : "Y" );
  }

  // Remove any error hops coming out of UniqueRows when Reject Duplicate Rows checkbox is unselected.
  if ( wRejectDuplicateRow.getSelection() == false ) {
    List<PipelineHopMeta> hops = this.pipelineMeta.getPipelineHops();
    IntStream.range( 0, hops.size() )
      .filter( hopInd -> {
        PipelineHopMeta hop = hops.get( hopInd );
        return (
          hop.isErrorHop()
            && hop.getFromTransform().getTransformPluginId().equals( this.input.getParentTransformMeta().getTransformPluginId() ) );
      } )
      .forEach( hopInd -> this.pipelineMeta.removePipelineHop( hopInd ) );
  }

  dispose();
}
 
Example 15
Source File: SetVariableDialog.java    From hop with Apache License 2.0 4 votes vote down vote up
private void ok() {
  if ( Utils.isEmpty( wTransformName.getText() ) ) {
    return;
  }

  transformName = wTransformName.getText(); // return value

  int count = wFields.nrNonEmpty();
  input.allocate( count );

  //CHECKSTYLE:Indentation:OFF
  for ( int i = 0; i < count; i++ ) {
    TableItem item = wFields.getNonEmpty( i );
    input.getFieldName()[ i ] = item.getText( 1 );
    input.getVariableName()[ i ] = item.getText( 2 );
    input.getVariableType()[ i ] = SetVariableMeta.getVariableType( item.getText( 3 ) );
    input.getDefaultValue()[ i ] = item.getText( 4 );
  }

  input.setUsingFormatting( wFormat.getSelection() );

  // Show a warning (optional)
  //
  if ( "Y".equalsIgnoreCase( props.getCustomParameter( STRING_USAGE_WARNING_PARAMETER, "Y" ) ) ) {
    MessageDialogWithToggle md =
      new MessageDialogWithToggle( shell,
        BaseMessages.getString( PKG, "SetVariableDialog.UsageWarning.DialogTitle" ),
        null,
        BaseMessages.getString( PKG, "SetVariableDialog.UsageWarning.DialogMessage", Const.CR ) + Const.CR,
        MessageDialog.WARNING,
        new String[] { BaseMessages.getString( PKG, "SetVariableDialog.UsageWarning.Option1" ) },
        0,
        BaseMessages.getString( PKG, "SetVariableDialog.UsageWarning.Option2" ),
        "N".equalsIgnoreCase( props.getCustomParameter( STRING_USAGE_WARNING_PARAMETER, "Y" ) ) );
    MessageDialogWithToggle.setDefaultImage( GuiResource.getInstance().getImageHopUi() );
    md.open();
    props.setCustomParameter( STRING_USAGE_WARNING_PARAMETER, md.getToggleState() ? "N" : "Y" );
  }

  dispose();
}
 
Example 16
Source File: Neo4JOutputDialog.java    From knowbi-pentaho-pdi-neo4j-output with Apache License 2.0 4 votes vote down vote up
private void validateAndWarn( Neo4JOutputMeta input ) {
  StringBuffer message = new StringBuffer();

  // Warn about running too many small UNWIND statements when using dynamic labels
  //
  boolean dynamicFrom = input.dynamicFromLabels() && input.isUsingCreate();
  if ( dynamicFrom ) {
    message.append( Const.CR );
    message.append( BaseMessages.getString( PKG, "Neo4JOutputDialog.Warning.SortDynamicFromLabels", Const.CR ) );
  }
  boolean dynamicTo = input.dynamicToLabels() && input.isUsingCreate();
  if ( dynamicTo ) {
    message.append( Const.CR );
    message.append( BaseMessages.getString( PKG, "Neo4JOutputDialog.Warning.SortDynamicToLabels", Const.CR ) );
  }
  if ( input.isOnlyCreatingRelationships() && input.isCreatingRelationships() && ( input.dynamicFromLabels() || input.dynamicToLabels() ) ) {
    message.append( Const.CR );
    message.append( BaseMessages.getString( PKG, "Neo4JOutputDialog.Warning.SortDynamicRelationshipLabel", Const.CR ) );
  }

  // Verify that the defined connection is available
  //
  try {
    MetaStoreFactory<NeoConnection> factory = new MetaStoreFactory<>( NeoConnection.class, metaStore, Neo4jDefaults.NAMESPACE );
    NeoConnection connection = factory.loadElement( input.getConnection() );
    if ( connection == null ) {
      message.append( Const.CR );
      message.append( BaseMessages.getString( PKG, "Neo4JOutputDialog.Warning.ReferencedNeo4jConnectionDoesntExist", input.getConnection(), Const.CR ) );
    }
  } catch ( Exception e ) {
    message.append( "There was an error verifying the existence of the used Neo4j connection" )
      .append( Const.CR )
      .append( Const.getStackTracker( e ) )
      .append( Const.CR );
  }

  // Warn people about the "Create indexes" button
  //
  if ( input.isCreatingIndexes() && ( input.dynamicFromLabels() || input.dynamicToLabels() ) ) {
    message.append( Const.CR );
    message.append( BaseMessages.getString( PKG, "Neo4JOutputDialog.Warning.CreateIndexesIsLimited", Const.CR ) );
  }

  if ( message.length() > 0 && "Y".equalsIgnoreCase( props.getCustomParameter( STRING_DYNAMIC_LABELS_WARNING, "Y" ) ) ) {

    MessageDialogWithToggle md =
      new MessageDialogWithToggle( shell,
        BaseMessages.getString( PKG, "Neo4JOutputDialog.DynamicLabelsWarning.DialogTitle" ), null,
        message.toString() + Const.CR,
        MessageDialog.WARNING,
        new String[] { BaseMessages.getString( PKG, "Neo4JOutputDialog.DynamicLabelsWarning.Understood" ) },
        0,
        BaseMessages.getString( PKG, "Neo4JOutputDialog.DynamicLabelsWarning.HideNextTime" ), "N".equalsIgnoreCase(
        props.getCustomParameter( STRING_DYNAMIC_LABELS_WARNING, "Y" ) ) );
    MessageDialogWithToggle.setDefaultImage( GUIResource.getInstance().getImageSpoon() );
    md.open();
    props.setCustomParameter( STRING_DYNAMIC_LABELS_WARNING, md.getToggleState() ? "N" : "Y" );
    props.saveProps();
  }

}
 
Example 17
Source File: HopGuiPipelineHopDelegate.java    From hop with Apache License 2.0 4 votes vote down vote up
public void verifyCopyDistribute( PipelineMeta pipelineMeta, TransformMeta fr ) {
  List<TransformMeta> nextTransforms = pipelineMeta.findNextTransforms( fr );
  int nrNextTransforms = nextTransforms.size();

  // don't show it for 3 or more hops, by then you should have had the
  // message
  if ( nrNextTransforms == 2 ) {
    boolean distributes = fr.getTransform().excludeFromCopyDistributeVerification();
    boolean customDistribution = false;

    if ( props.showCopyOrDistributeWarning()
      && !fr.getTransform().excludeFromCopyDistributeVerification() ) {
      MessageDialogWithToggle md =
        new MessageDialogWithToggle(
          hopGui.getShell(), BaseMessages.getString( PKG, "System.Warning" ), null, BaseMessages.getString(
          PKG, "HopGui.Dialog.CopyOrDistribute.Message", fr.getName(), Integer.toString( nrNextTransforms ) ),
          MessageDialog.WARNING, getRowDistributionLabels(), 0, BaseMessages.getString(
          PKG, "HopGui.Message.Warning.NotShowWarning" ), !props.showCopyOrDistributeWarning() );
      MessageDialogWithToggle.setDefaultImage( GuiResource.getInstance().getImageHopUi() );
      int idx = md.open();
      props.setShowCopyOrDistributeWarning( !md.getToggleState() );

      distributes = idx == MESSAGE_DIALOG_WITH_TOGGLE_YES_BUTTON_ID;
      customDistribution = idx == MESSAGE_DIALOG_WITH_TOGGLE_CUSTOM_DISTRIBUTION_BUTTON_ID;
    }

    if ( distributes ) {
      fr.setDistributes( true );
      fr.setRowDistribution( null );
    } else if ( customDistribution ) {

      IRowDistribution rowDistribution = pipelineGraph.askUserForCustomDistributionMethod();

      fr.setDistributes( true );
      fr.setRowDistribution( rowDistribution );
    } else {
      fr.setDistributes( false );
      fr.setDistributes( false );
    }

    pipelineGraph.redraw();
  }
}
 
Example 18
Source File: HopGuiWorkflowGraph.java    From hop with Apache License 2.0 4 votes vote down vote up
/**
 * Go from serial to parallel to serial execution
 */
@GuiContextAction(
  id = "workflow-graph-transform-10600-parallel",
  parentId = HopGuiWorkflowActionContext.CONTEXT_ID,
  type = GuiActionType.Modify,
  name = "Parallel execution",
  tooltip = "Enable of disable parallel execution of next actions",
  image = "ui/images/parallel-hop.svg"
)
public void editEntryParallel( HopGuiWorkflowActionContext context ) {

  ActionCopy action = context.getActionCopy();
  ActionCopy originalAction = (ActionCopy) action.cloneDeep();

  action.setLaunchingInParallel( !action.isLaunchingInParallel() );
  ActionCopy jeNew = (ActionCopy) action.cloneDeep();

  hopGui.undoDelegate.addUndoChange( workflowMeta, new ActionCopy[] { originalAction }, new ActionCopy[] { jeNew }, new int[] { workflowMeta.indexOfAction( jeNew ) } );
  workflowMeta.setChanged();

  if ( action.isLaunchingInParallel() ) {
    // Show a warning (optional)
    //
    if ( "Y".equalsIgnoreCase( hopGui.getProps().getCustomParameter( STRING_PARALLEL_WARNING_PARAMETER, "Y" ) ) ) {
      MessageDialogWithToggle md =
        new MessageDialogWithToggle( hopShell(),
          BaseMessages.getString( PKG, "WorkflowGraph.ParallelActionsWarning.DialogTitle" ),
          null,
          BaseMessages.getString( PKG, "WorkflowGraph.ParallelActionsWarning.DialogMessage", Const.CR ) + Const.CR,
          MessageDialog.WARNING,
          new String[] { BaseMessages.getString( PKG, "WorkflowGraph.ParallelActionsWarning.Option1" ) },
          0,
          BaseMessages.getString( PKG, "WorkflowGraph.ParallelActionsWarning.Option2" ),
          "N".equalsIgnoreCase( hopGui.getProps().getCustomParameter( STRING_PARALLEL_WARNING_PARAMETER, "Y" ) ) );
      MessageDialogWithToggle.setDefaultImage( GuiResource.getInstance().getImageHopUi() );
      md.open();
      hopGui.getProps().setCustomParameter( STRING_PARALLEL_WARNING_PARAMETER, md.getToggleState() ? "N" : "Y" );
    }
  }
  redraw();

}
 
Example 19
Source File: UniqueRowsDialog.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
private void ok() {
  if ( Utils.isEmpty( wStepname.getText() ) ) {
    return;
  }

  int nrfields = wFields.nrNonEmpty();
  input.allocate( nrfields );

  //CHECKSTYLE:Indentation:OFF
  for ( int i = 0; i < nrfields; i++ ) {
    TableItem item = wFields.getNonEmpty( i );
    input.getCompareFields()[i] = item.getText( 1 );
    input.getCaseInsensitive()[i] = "Y".equalsIgnoreCase( item.getText( 2 ) );
  }

  input.setCountField( wCountField.getText() );
  input.setCountRows( wCount.getSelection() );
  input.setRejectDuplicateRow( wRejectDuplicateRow.getSelection() );
  input.setErrorDescription( wErrorDesc.getText() );
  stepname = wStepname.getText(); // return value

  if ( "Y".equalsIgnoreCase( props.getCustomParameter( STRING_SORT_WARNING_PARAMETER, "Y" ) ) ) {
    MessageDialogWithToggle md = new MessageDialogWithToggle( shell,
      BaseMessages.getString( PKG, "UniqueRowsDialog.InputNeedSort.DialogTitle" ),
      null,
      BaseMessages.getString( PKG, "UniqueRowsDialog.InputNeedSort.DialogMessage", Const.CR ) + Const.CR,
      MessageDialog.WARNING,
      new String[] { BaseMessages.getString( PKG, "UniqueRowsDialog.InputNeedSort.Option1" ) },
      0,
      BaseMessages.getString( PKG, "UniqueRowsDialog.InputNeedSort.Option2" ),
      "N".equalsIgnoreCase( props.getCustomParameter( STRING_SORT_WARNING_PARAMETER, "Y" ) ) );
    MessageDialogWithToggle.setDefaultImage( GUIResource.getInstance().getImageSpoon() );
    md.open();
    props.setCustomParameter( STRING_SORT_WARNING_PARAMETER, md.getToggleState() ? "N" : "Y" );
    props.saveProps();
  }

  // Remove any error hops coming out of UniqueRows when Reject Duplicate Rows checkbox is unselected.
  if ( wRejectDuplicateRow.getSelection() == false ) {
    List<TransHopMeta> hops = this.transMeta.getTransHops();
    IntStream.range( 0, hops.size() )
      .filter( hopInd -> {
        TransHopMeta hop = hops.get( hopInd );
        return (
          hop.isErrorHop()
          && hop.getFromStep().getName().equals( this.input.getParentStepMeta().getName() ) );
      } )
      .forEach( hopInd -> this.transMeta.removeTransHop( hopInd ) );
  }

  dispose();
}
 
Example 20
Source File: SetVariableDialog.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
private void ok() {
  if ( Utils.isEmpty( wStepname.getText() ) ) {
    return;
  }

  stepname = wStepname.getText(); // return value

  int count = wFields.nrNonEmpty();
  input.allocate( count );

  //CHECKSTYLE:Indentation:OFF
  for ( int i = 0; i < count; i++ ) {
    TableItem item = wFields.getNonEmpty( i );
    input.getFieldName()[i] = item.getText( 1 );
    input.getVariableName()[i] = item.getText( 2 );
    input.getVariableType()[i] = SetVariableMeta.getVariableType( item.getText( 3 ) );
    input.getDefaultValue()[i] = item.getText( 4 );
  }

  input.setUsingFormatting( wFormat.getSelection() );

  // Show a warning (optional)
  //
  if ( "Y".equalsIgnoreCase( props.getCustomParameter( STRING_USAGE_WARNING_PARAMETER, "Y" ) ) ) {
    MessageDialogWithToggle md =
      new MessageDialogWithToggle( shell,
        BaseMessages.getString( PKG, "SetVariableDialog.UsageWarning.DialogTitle" ),
        null,
        BaseMessages.getString( PKG, "SetVariableDialog.UsageWarning.DialogMessage", Const.CR ) + Const.CR,
        MessageDialog.WARNING,
        new String[] { BaseMessages.getString( PKG, "SetVariableDialog.UsageWarning.Option1" ) },
        0,
        BaseMessages.getString( PKG, "SetVariableDialog.UsageWarning.Option2" ),
        "N".equalsIgnoreCase( props.getCustomParameter( STRING_USAGE_WARNING_PARAMETER, "Y" ) ) );
    MessageDialogWithToggle.setDefaultImage( GUIResource.getInstance().getImageSpoon() );
    md.open();
    props.setCustomParameter( STRING_USAGE_WARNING_PARAMETER, md.getToggleState() ? "N" : "Y" );
    props.saveProps();
  }

  dispose();
}