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

The following examples show how to use org.eclipse.jface.dialogs.MessageDialog#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: CiviDialog.java    From civicrm-data-integration with GNU General Public License v3.0 6 votes vote down vote up
protected void getEntities() {
    try {
        if (civiCrmEntityList != null && civiCrmEntityList.size() > 0) {
            MessageDialog.setDefaultImage(GUIResource.getInstance().getImageSpoon());
            boolean goOn = MessageDialog.openConfirm(shell, BaseMessages.getString(PKG, "CiviCrmDialog.DoMapping.ReplaceFields.Title"),
                    BaseMessages.getString(PKG, "CiviCrmDialog.DoMapping.ReplaceFields.Msg"));
            if (!goOn) {
                return;
            }
        }

        String restUrl = variables.environmentSubstitute(wCiviCrmRestUrl.getText());
        String apiKey = variables.environmentSubstitute(wCiviCrmApiKey.getText());
        String siteKey = variables.environmentSubstitute(wCiviCrmSiteKey.getText());
        // String entity = wCiviCrmEntity.getText());

        CiviRestService crUtil = new CiviRestService(restUrl, apiKey, siteKey, "getfields", wCiviCrmEntity.getText());

        civiCrmEntityList = crUtil.getEntityList();
        String[] eArray = (String[]) civiCrmEntityList.toArray(new String[0]);
        wCiviCrmEntity.setItems(eArray);
    } catch (Exception e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "CiviCrmStep.Error.EntityListError"), e.toString().split(":")[0], e);
        logBasic(BaseMessages.getString(PKG, "CiviCrmStep.Error.APIExecError", e.toString()));
    }
}
 
Example 2
Source File: BaseTransformDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
static MessageDialog getFieldsChoiceDialog( Shell shell, int existingFields, int newFields ) {
  MessageDialog messageDialog =
    new MessageDialog( shell,
      BaseMessages.getString( PKG, "BaseTransformDialog.GetFieldsChoice.Title" ), // "Warning!"
      null,
      BaseMessages.getString( PKG, "BaseTransformDialog.GetFieldsChoice.Message", "" + existingFields, "" + newFields ),
      MessageDialog.WARNING, new String[] {
      BaseMessages.getString( PKG, "BaseTransformDialog.AddNew" ),
      BaseMessages.getString( PKG, "BaseTransformDialog.Add" ),
      BaseMessages.getString( PKG, "BaseTransformDialog.ClearAndAdd" ),
      BaseMessages.getString( PKG, "BaseTransformDialog.Cancel" ), }, 0 );
  MessageDialog.setDefaultImage( GuiResource.getInstance().getImageHopUi() );
  return messageDialog;
}
 
Example 3
Source File: BaseStepDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
static MessageDialog getFieldsChoiceDialog( Shell shell, int existingFields, int newFields ) {
  MessageDialog messageDialog =
    new MessageDialog( shell,
      BaseMessages.getString( PKG, "BaseStepDialog.GetFieldsChoice.Title" ), // "Warning!"
      null,
      BaseMessages.getString( PKG, "BaseStepDialog.GetFieldsChoice.Message", "" + existingFields, "" + newFields ),
      MessageDialog.WARNING, new String[] {
      BaseMessages.getString( PKG, "BaseStepDialog.AddNew" ),
      BaseMessages.getString( PKG, "BaseStepDialog.Add" ),
      BaseMessages.getString( PKG, "BaseStepDialog.ClearAndAdd" ),
      BaseMessages.getString( PKG, "BaseStepDialog.Cancel" ), }, 0 );
  MessageDialog.setDefaultImage( GUIResource.getInstance().getImageSpoon() );
  return messageDialog;
}
 
Example 4
Source File: BaseStepXulDialog.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public static void getFieldsFromPrevious( RowMetaInterface row, XulTree tableView, List<Object> fields,
  StepTableDataObject field, TableItemInsertXulListener listener ) {
  if ( row == null || row.size() == 0 ) {
    return; // nothing to do
  }

  // get a list of all the non-empty keys (names)
  //
  List<String> keys = new ArrayList<String>();
  for ( Object entry : fields ) {
    keys.add( ( (StepTableDataObject) entry ).getName() );
  }

  int choice = 0;

  if ( keys.size() > 0 ) {
    // Ask what we should do with the existing data in the step.
    //
    Shell shell = ( (TableViewer) tableView.getManagedObject() ).getTable().getShell();
    MessageDialog md =
      new MessageDialog( shell,
        BaseMessages.getString( PKG, "BaseStepDialog.GetFieldsChoice.Title" ), // "Warning!"
        null,
        BaseMessages.getString( PKG, "BaseStepDialog.GetFieldsChoice.Message", "" + keys.size(), "" + row.size() ),
        MessageDialog.WARNING, new String[] {
          BaseMessages.getString( PKG, "BaseStepDialog.AddNew" ),
          BaseMessages.getString( PKG, "BaseStepDialog.Add" ),
          BaseMessages.getString( PKG, "BaseStepDialog.ClearAndAdd" ),
          BaseMessages.getString( PKG, "BaseStepDialog.Cancel" ), }, 0 );
    MessageDialog.setDefaultImage( GUIResource.getInstance().getImageSpoon() );
    int idx = md.open();
    choice = idx & 0xFF;
  }

  if ( choice == 3 || choice == 255 ) {
    return; // Cancel clicked
  }

  if ( choice == 2 ) {
    fields.clear();
  }

  for ( int i = 0; i < row.size(); i++ ) {
    ValueMetaInterface v = row.getValueMeta( i );

    if ( choice == 0 ) { // hang on, see if it's not yet in the table view

      if ( keys.indexOf( v.getName() ) >= 0 ) {
        continue;
      }
    }

    if ( listener != null && !listener.tableItemInsertedFor( v ) ) {
      continue;
    }

    StepTableDataObject newField = field.createNew( v );
    fields.add( newField );
  }
}
 
Example 5
Source File: OpenERPObjectInputDialog.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
private void populateFielsTable( ArrayList<FieldMapping> mappings ) {

    int choice = 0;

    if ( tableViewFields.table.getItemCount() > 0 ) {
      // Ask what we should do with the existing data in the step.
      MessageDialog md =
        new MessageDialog(
          tableViewFields.getShell(),
          BaseMessages.getString( PKGStepInterface, "BaseStepDialog.GetFieldsChoice.Title" ), // "Warning!"
          null,
          BaseMessages.getString( PKGStepInterface, "BaseStepDialog.GetFieldsChoice.Message",
            "" + tableViewFields.table.getItemCount(), "" + mappings.size() ),
          MessageDialog.WARNING,
          new String[]{
            BaseMessages.getString( PKGStepInterface, "BaseStepDialog.AddNew" ),
            BaseMessages.getString( PKGStepInterface, "BaseStepDialog.ClearAndAdd" ),
            BaseMessages.getString( PKGStepInterface, "BaseStepDialog.Cancel" ),
          },
          0 );
      MessageDialog.setDefaultImage( GUIResource.getInstance().getImageSpoon() );
      int idx = md.open();
      choice = idx & 0xFF;
    }

    if ( choice == 2 || choice == 255 /* 255 = escape pressed */ ) {
      return; // Cancel clicked
    }

    if ( choice == 1 ) {
      tableViewFields.table.removeAll();
    }

    // Make a list of the old elements
    Hashtable<String, Object> currentMaps = new Hashtable<String, Object>();
    for ( int i = 0; i < tableViewFields.table.getItemCount(); i++ ) {
      currentMaps.put( tableViewFields.table.getItem( i ).getText( 1 ) + tableViewFields.table.getItem( i ).getText( 2 )
        + tableViewFields.table.getItem( i ).getText( 3 ), true );
    }
    sourceListMapping = mappings;
    for ( FieldMapping map : mappings ) {
      // Only add new elements
      if ( !currentMaps.containsKey( map.target_field_label + map.target_model + map.target_field ) ) {
        tableViewFields.add( map.target_field_label, map.target_model, map.target_field, map.source_model,
          map.source_field, String.valueOf( map.source_index ), String.valueOf( map.target_field_type ) );
      }
    }

    tableViewFields.setRowNums();
    tableViewFields.optWidth( true );
  }