Java Code Examples for org.eclipse.swt.SWT#YES

The following examples show how to use org.eclipse.swt.SWT#YES . These examples are extracted from open source projects. 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 Project: pentaho-kettle   File: TableView.java    License: Apache License 2.0 6 votes vote down vote up
public void clearAll( boolean ask ) {
  int id = SWT.YES;
  if ( ask ) {
    MessageBox mb = new MessageBox( parent.getShell(), SWT.YES | SWT.NO | SWT.ICON_QUESTION );
    mb.setMessage( BaseMessages.getString( PKG, "TableView.MessageBox.ClearTable.message" ) );
    mb.setText( BaseMessages.getString( PKG, "TableView.MessageBox.ClearTable.title" ) );
    id = mb.open();
  }

  if ( id == SWT.YES ) {
    table.removeAll();
    new TableItem( table, SWT.NONE );
    if ( !readonly ) {
      parent.getDisplay().asyncExec( new Runnable() {
        @Override
        public void run() {
          edit( 0, 1 );
        }
      } );
    }
    this.setModified(); // timh
  }
}
 
Example 2
/**
 * @return true if the transcription was closed, false if the operation was
 *         cancelled
 */
protected boolean closeTranscription() {
	if (!textEditor.isDisposed()) {
		if (textEditor.isChanged()) {
			MessageBox diag = new MessageBox(shell,
					SWT.APPLICATION_MODAL | SWT.ICON_QUESTION | SWT.YES | SWT.NO | SWT.CANCEL);
			diag.setMessage("You have unsaved changes, would you like to save them?");
			int opt = diag.open();
			if (opt == SWT.YES)
				saveTranscription();
			if (opt == SWT.CANCEL)
				return false;
		}
		textEditor.clear();
		transcriptionFile = null;
	}
	return true;
}
 
Example 3
private boolean askToCreateNewJob( String prevName ) {
  MessageBox mb = new MessageBox( shell, SWT.YES | SWT.NO | SWT.ICON_QUESTION );
  mb.setMessage( BaseMessages.getString( PKG, "JobJob.Dialog.CreateJobQuestion.Message" ) );
  mb.setText( BaseMessages.getString( PKG, "JobJob.Dialog.CreateJobQuestion.Title" ) );
  int answer = mb.open();
  if ( answer == SWT.YES ) {
    Spoon spoon = Spoon.getInstance();
    spoon.newJobFile();
    JobMeta newJobMeta = spoon.getActiveJob();
    newJobMeta.initializeVariablesFrom( jobEntry );
    newJobMeta.setFilename( jobMeta.environmentSubstitute( prevName ) );
    wPath.setText( prevName );
    specificationMethod = ObjectLocationSpecificationMethod.FILENAME;
    spoon.saveFile();
    return true;
  }
  return false;
}
 
Example 4
public void deleteUnitTest( String unitTestName ) {
  MessageBox box = new MessageBox( Spoon.getInstance().getShell(), SWT.YES | SWT.NO );
  box.setText( BaseMessages.getString( PKG, "DataSetHelper.YouSureToDelete.Title" ) );
  box.setMessage( BaseMessages.getString( PKG, "DataSetHelper.YouSureToDelete.Message", unitTestName ) );
  int answer = box.open();
  if ( ( answer & SWT.YES ) != 0 ) {
    try {
      FactoriesHierarchy hierarchy = getHierarchy();
      hierarchy.getTestFactory().deleteElement( unitTestName );
      DataSetHelper.getInstance().detachUnitTest();
    } catch ( Exception exception ) {
      new ErrorDialog( Spoon.getInstance().getShell(),
        BaseMessages.getString( PKG, "DataSetHelper.ErrorDeletingUnitTest.Title" ),
        BaseMessages.getString( PKG, "DataSetHelper.ErrorDeletingUnitTest.Message", unitTestName ),
        exception );

    }
  }
}
 
Example 5
public static void deleteConnection( Shell shell, MetaStoreFactory<NeoConnection> factory, String connectionName ) {
  if ( StringUtils.isEmpty( connectionName ) ) {
    return;
  }

  MessageBox box = new MessageBox( shell, SWT.YES | SWT.NO | SWT.ICON_ERROR );
  box.setText( BaseMessages.getString( PKG, "NeoConnectionUtils.DeleteConnectionConfirmation.Title" ) );
  box.setMessage( BaseMessages.getString( PKG, "NeoConnectionUtils.DeleteConnectionConfirmation.Message", connectionName ) );
  int answer = box.open();
  if ( ( answer & SWT.YES ) != 0 ) {
    try {
      factory.deleteElement( connectionName );
    } catch ( Exception exception ) {
      new ErrorDialog( shell,
        BaseMessages.getString( PKG, "NeoConnectionUtils.Error.ErrorDeletingConnection.Title" ),
        BaseMessages.getString( PKG, "NeoConnectionUtils.Error.ErrorDeletingConnection.Message", connectionName ),
        exception );
    }
  }
}
 
Example 6
Source Project: hop   File: ScriptValuesModDialog.java    License: Apache License 2.0 6 votes vote down vote up
private boolean cancel() {
  if ( input.hasChanged() ) {
    MessageBox box = new MessageBox( shell, SWT.YES | SWT.NO | SWT.APPLICATION_MODAL | SWT.SHEET );
    box.setText( BaseMessages.getString( PKG, "ScriptValuesModDialog.WarningDialogChanged.Title" ) );
    box
      .setMessage( BaseMessages
        .getString( PKG, "ScriptValuesModDialog.WarningDialogChanged.Message", Const.CR ) );
    int answer = box.open();

    if ( answer == SWT.NO ) {
      return false;
    }
  }
  transformName = null;
  input.setChanged( changed );
  dispose();
  return true;
}
 
Example 7
private boolean cancel() {
  if ( input.hasChanged() ) {
    MessageBox box = new MessageBox( shell, SWT.YES | SWT.NO | SWT.APPLICATION_MODAL | SWT.SHEET );
    box.setText( BaseMessages.getString( PKG, "ScriptValuesModDialog.WarningDialogChanged.Title" ) );
    box
      .setMessage( BaseMessages
        .getString( PKG, "ScriptValuesModDialog.WarningDialogChanged.Message", Const.CR ) );
    int answer = box.open();

    if ( answer == SWT.NO ) {
      return false;
    }
  }
  stepname = null;
  input.setChanged( changed );
  dispose();
  return true;
}
 
Example 8
public void removeRule() {
  MessageBox box =
    new MessageBox( shell, SWT.ICON_WARNING | SWT.APPLICATION_MODAL | SWT.SHEET | SWT.YES | SWT.NO );
  box.setText( "Warning" );
  box.setMessage( "Are you sure you want to remove the selected rules from the list?" );
  int answer = box.open();
  if ( answer != SWT.YES ) {
    return;
  }

  int[] indices = table.getSelectionIndices();
  Arrays.sort( indices );

  for ( int i = indices.length - 1; i >= 0; i-- ) {
    importRules.getRules().remove( indices[i] );
  }

  // Refresh the whole list..
  //
  getCompositesData();
}
 
Example 9
public void delete( RunConfiguration runConfiguration ) {
  RunConfigurationDeleteDialog deleteDialog = new RunConfigurationDeleteDialog( spoonSupplier.get().getShell() );
  int response = deleteDialog.open();
  if ( response == SWT.YES ) {
    configurationManager.delete( runConfiguration.getName() );
    refreshTree();
  }
}
 
Example 10
Source Project: hop   File: HopGuiPipelineGraph.java    License: Apache License 2.0 5 votes vote down vote up
@Override public boolean isCloseable() {
  try {
    // Check if the file is saved. If not, ask for it to be saved.
    //
    if ( pipelineMeta.hasChanged() ) {

      MessageBox messageDialog = new MessageBox( hopShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO | SWT.CANCEL );
      messageDialog.setText( "Save file?" );
      messageDialog.setMessage( "Do you want to save file '" + buildTabName() + "' before closing?" );
      int answer = messageDialog.open();
      if ( ( answer & SWT.YES ) != 0 ) {
        save();
        return true;
      }
      if ( ( answer & SWT.NO ) != 0 ) {
        // User doesn't want to save but close
        return true;
      }
      return false;
    } else {
      return true;
    }
  } catch ( Exception e ) {
    new ErrorDialog( hopShell(), "Error", "Error preparing file close", e );
  }
  return false;
}
 
Example 11
Source Project: pentaho-kettle   File: ExecSQLDialog.java    License: Apache License 2.0 5 votes vote down vote up
private void checkCancel( ShellEvent e ) {
  if ( changedInDialog ) {
    int save = JobGraph.showChangedWarning( shell, wStepname.getText() );
    if ( save == SWT.CANCEL ) {
      e.doit = false;
    } else if ( save == SWT.YES ) {
      ok();
    } else {
      cancel();
    }
  } else {
    cancel();
  }
}
 
Example 12
Source Project: hop   File: TableInputDialog.java    License: Apache License 2.0 5 votes vote down vote up
private void checkCancel( ShellEvent e ) {
  if ( changedInDialog ) {
    int save = HopGuiWorkflowGraph.showChangedWarning( shell, wTransformName.getText() );
    if ( save == SWT.CANCEL ) {
      e.doit = false;
    } else if ( save == SWT.YES ) {
      ok();
    } else {
      cancel();
    }
  } else {
    cancel();
  }
}
 
Example 13
Source Project: RepDev   File: MainShell.java    License: GNU General Public License v3.0 5 votes vote down vote up
private boolean confirmClose(CTabItem item) {
	if (item != null && item.getData("modified") != null && ((Boolean) item.getData("modified"))) {
		MessageBox dialog = new MessageBox(shell, SWT.ICON_QUESTION | SWT.YES | SWT.NO | SWT.CANCEL);
		dialog.setText("Confirm File Close");

		if (item.getData("loc") instanceof Integer)
			dialog.setMessage("The file '" + item.getData("file") + "' on Sym " + item.getData("loc") + " has been modified, do you want to save it before closing it?");
		else
			dialog.setMessage("The file '" + item.getData("file") + "' in directory " + item.getData("loc") + " has been modified, do you want to save it before closing it?");

		int result = dialog.open();

		if (result == SWT.CANCEL)
			return false;
		else if (result == SWT.YES) {
			((EditorComposite) item.getControl()).saveFile(false);
		}
	}

	if (mainfolder.getSelection().getControl() instanceof EditorComposite)
		for (TableItem tItem : tblErrors.getItems())
			if (tItem.getData("file").equals(mainfolder.getSelection().getData("file")) && tItem.getData("sym").equals(mainfolder.getSelection().getData("sym"))){
				tItem.dispose();
				//EditorCompositeList.remove(mainfolder.getSelection().getControl());
			}
	// Remove entries matching this tab from the tabHistory stack since we are closing the file
	List<CTabItem> closingTab = Arrays.asList(item);
	tabHistory.removeAll(closingTab);
	if(!tabHistory.isEmpty())
		setMainFolderSelection(tabHistory.get(tabHistory.size()-1));
	return true;
}
 
Example 14
/**
 * @param confirm Pops up an SWT Message box if true, confirms wether the repgen should be installed or not
 */
public void installRepgen(boolean confirm) {
	if( file.getType() != FileType.REPGEN || file.isLocal() ) {
		return;
	}

	MessageBox dialog = new MessageBox(Display.getCurrent().getActiveShell(),SWT.YES | SWT.NO | SWT.ICON_QUESTION);
	MessageBox dialog2 = null;

	dialog.setText("Confirm Repgen Installation");
	dialog.setMessage("Are you sure you want to save this file and install this repgen?");

	if( !confirm || dialog.open() == SWT.YES ){
		getShell().setCursor(getDisplay().getSystemCursor(SWT.CURSOR_WAIT));

		if(modified) saveFile(true);
		ErrorCheckResult result = RepDevMain.SYMITAR_SESSIONS.get(sym).installRepgen(file.getName());

		getShell().setCursor(getDisplay().getSystemCursor(SWT.CURSOR_ARROW));


		dialog2 = new MessageBox(Display.getCurrent().getActiveShell(),SWT.OK | ( result.getType() == ErrorCheckResult.Type.INSTALLED_SUCCESSFULLY ? SWT.ICON_INFORMATION : SWT.ICON_ERROR ));
		dialog2.setText("Installation Result");

		if( result.getType() != ErrorCheckResult.Type.INSTALLED_SUCCESSFULLY )
			dialog2.setMessage("Error Installing Repgen: \n" + result.getErrorMessage());
		else
			dialog2.setMessage("Repgen Installed, Size: " + result.getInstallSize());

		dialog2.open();
	}
}
 
Example 15
Source Project: kettle-beam   File: BeamHelper.java    License: Apache License 2.0 5 votes vote down vote up
public void createBeamJobConfig() {

    MetaStoreFactory<BeamJobConfig> factory = new MetaStoreFactory<>( BeamJobConfig.class, spoon.getMetaStore(), PentahoDefaults.NAMESPACE );

    BeamJobConfig config = new BeamJobConfig();
    config.setName( "My Beam Job Config" );
    boolean ok = false;
    while ( !ok ) {
      BeamJobConfigDialog dialog = new BeamJobConfigDialog( spoon.getShell(), config );
      if ( dialog.open() ) {
        // write to metastore...
        try {
          if ( factory.loadElement( config.getName() ) != null ) {
            MessageBox box = new MessageBox( spoon.getShell(), SWT.YES | SWT.NO | SWT.ICON_ERROR );
            box.setText( BaseMessages.getString( PKG, "BeamHelper.Error.BeamJobConfigExists.Title" ) );
            box.setMessage( BaseMessages.getString( PKG, "BeamHelper.Error.BeamJobConfigExists.Message" ) );
            int answer = box.open();
            if ( ( answer & SWT.YES ) != 0 ) {
              factory.saveElement( config );
              ok = true;
            }
          } else {
            factory.saveElement( config );
            ok = true;
          }
        } catch ( Exception exception ) {
          new ErrorDialog( spoon.getShell(),
            BaseMessages.getString( PKG, "BeamHelper.Error.ErrorSavingJobConfig.Title" ),
            BaseMessages.getString( PKG, "BeamHelper.Error.ErrorSavingJobConfig.Message" ),
            exception );
          return;
        }
      } else {
        // Cancel
        return;
      }
    }
  }
 
Example 16
Source Project: hop   File: HopGuiWorkflowGraph.java    License: Apache License 2.0 4 votes vote down vote up
public static void showOnlyStartOnceMessage( Shell shell ) {
  MessageBox mb = new MessageBox( shell, SWT.YES | SWT.ICON_ERROR );
  mb.setMessage( BaseMessages.getString( PKG, "WorkflowGraph.Dialog.OnlyUseStartOnce.Message" ) );
  mb.setText( BaseMessages.getString( PKG, "WorkflowGraph.Dialog.OnlyUseStartOnce.Title" ) );
  mb.open();
}
 
Example 17
Source Project: hop   File: ExcelInputDialog.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Get the list of fields in the Excel workbook and put the result in the fields table view.
 */
public void getFields() {
  IRowMeta fields = new RowMeta();

  ExcelInputMeta info = new ExcelInputMeta();
  getInfo( info );

  int clearFields = SWT.YES;
  if ( wFields.nrNonEmpty() > 0 ) {
    MessageBox messageBox = new MessageBox( shell, SWT.YES | SWT.NO | SWT.CANCEL | SWT.ICON_QUESTION );
    messageBox.setMessage( BaseMessages.getString( PKG, "ExcelInputDialog.ClearFieldList.DialogMessage" ) );
    messageBox.setText( BaseMessages.getString( PKG, "ExcelInputDialog.ClearFieldList.DialogTitle" ) );
    clearFields = messageBox.open();
    if ( clearFields == SWT.CANCEL ) {
      return;
    }
  }

  FileInputList fileList = info.getFileList( pipelineMeta );
  for ( FileObject file : fileList.getFiles() ) {
    try {
      IKWorkbook workbook =
        WorkbookFactory.getWorkbook( info.getSpreadSheetType(), HopVfs.getFilename( file ), info
          .getEncoding() );
      processingWorkbook( fields, info, workbook );
      workbook.close();
    } catch ( Exception e ) {
      new ErrorDialog( shell, BaseMessages.getString( PKG, "System.Dialog.Error.Title" ), BaseMessages
        .getString( PKG, "ExcelInputDialog.ErrorReadingFile2.DialogMessage", HopVfs.getFilename( file ), e
          .toString() ), e );
    }
  }

  if ( fields.size() > 0 ) {
    if ( clearFields == SWT.YES ) {
      wFields.clearAll( false );
    }
    for ( int j = 0; j < fields.size(); j++ ) {
      IValueMeta field = fields.getValueMeta( j );
      wFields.add( new String[] { field.getName(), field.getTypeDesc(), "", "", "none", "N" } );
    }
    wFields.removeEmptyRows();
    wFields.setRowNums();
    wFields.optWidth( true );
  } else {
    MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_WARNING );
    mb.setMessage( BaseMessages.getString( PKG, "ExcelInputDialog.UnableToFindFields.DialogMessage" ) );
    mb.setText( BaseMessages.getString( PKG, "ExcelInputDialog.UnableToFindFields.DialogTitle" ) );
    mb.open();
  }
  checkAlerts();
}
 
Example 18
Source Project: pentaho-kettle   File: EESpoonPlugin.java    License: Apache License 2.0 4 votes vote down vote up
private void warnClosingOfOpenTabsBasedOnPerms( Spoon spoon ) throws KettleException {
  Class<PurRepositoryDialog> PKG = PurRepositoryDialog.class;
  // Check to see if there are any open jobs/trans
  Repository repository = spoon.getRepository();
  if ( spoon.getActiveMeta() == null ) {
    return;
  }

  String warningTitle = BaseMessages.getString( PKG, "PurRepository.Dialog.WarnToCloseAllForce.Connect.Title" );
  String warningText =
      BaseMessages.getString( PKG, "PurRepository.Dialog.WarnToCloseAllOptionAdditional.Connect.Message" );
  String additionalWarningText = "";
  int buttons = SWT.OK;

  IAbsSecurityProvider absSecurityProvider =
      (IAbsSecurityProvider) repository.getService( IAbsSecurityProvider.class );
  if ( absSecurityProvider != null ) {
    boolean createPerms = false;
    boolean executePerms = false;
    boolean readPerms = false;
    try {
      createPerms = absSecurityProvider.isAllowed( IAbsSecurityProvider.CREATE_CONTENT_ACTION );
      executePerms = absSecurityProvider.isAllowed( IAbsSecurityProvider.EXECUTE_CONTENT_ACTION );
      readPerms = absSecurityProvider.isAllowed( IAbsSecurityProvider.READ_CONTENT_ACTION );
    } catch ( KettleException e ) {
      // No nothing - we are just checking perms
    }

    // Check to see if display of warning dialog has been disabled
    if ( readPerms && createPerms && executePerms ) {
      warningTitle = BaseMessages.getString( PKG, "PurRepository.Dialog.WarnToCloseAllOption.Connect.Title" );
      warningText = BaseMessages.getString( PKG, "PurRepository.Dialog.WarnToCloseAllOption.Connect.Message" );
      buttons = SWT.YES | SWT.NO | SWT.ICON_INFORMATION;
    } else {
      warningText = BaseMessages.getString( PKG, "PurRepository.Dialog.WarnToCloseAllForce.Connect.Message" );
      if ( createPerms ) {
        additionalWarningText =
            BaseMessages.getString( PKG, "PurRepository.Dialog.WarnToCloseAllForceAdditional.Connect.Message" );
        buttons = SWT.YES | SWT.NO | SWT.ICON_WARNING;
      } else {
        additionalWarningText =
            BaseMessages.getString( PKG, "PurRepository.Dialog.WarnToCloseAllOptionAdditional.Connect.Message" );
        buttons = SWT.OK | SWT.ICON_WARNING;
      }
    }
  }

  MessageBox mb = new MessageBox( spoon.getShell(), buttons );
  mb.setMessage( additionalWarningText.length() != 0 ? warningText + "\n\n" + additionalWarningText : warningText );
  mb.setText( warningTitle );
  final int isCloseAllFiles = mb.open();

  // If user has create content perms, then they can leave the tabs open.
  // Otherwise, we force close the tabs
  if ( ( isCloseAllFiles == SWT.YES ) || ( isCloseAllFiles == SWT.OK ) ) {
    spoon.closeAllFiles();
  }
}
 
Example 19
Source Project: hop   File: TestingGuiPlugin.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Create a new data set with the output from
 */
@GuiContextAction(
  id = "pipeline-graph-transform-20400-clear-golden-data-set",
  parentId = HopGuiPipelineTransformContext.CONTEXT_ID,
  type = GuiActionType.Delete,
  name = "Create data set",
  tooltip = "Create an empty dataset with the output fields of this transform ",
  image = "dataset.svg"
)
public void createDataSetFromTransform( HopGuiPipelineTransformContext context ) {
  HopGui hopGui = HopGui.getInstance();
  IHopMetadataProvider metadataProvider = hopGui.getMetadataProvider();

  TransformMeta transformMeta = context.getTransformMeta();
  PipelineMeta pipelineMeta = context.getPipelineMeta();

  try {
    IHopMetadataSerializer<DataSet> setSerializer = metadataProvider.getSerializer( DataSet.class );

    DataSet dataSet = new DataSet();
    dataSet.initializeVariablesFrom( pipelineMeta );

    IRowMeta rowMeta = pipelineMeta.getTransformFields( transformMeta );
    for ( int i = 0; i < rowMeta.size(); i++ ) {
      IValueMeta valueMeta = rowMeta.getValueMeta( i );
      String setFieldName = valueMeta.getName();
      DataSetField field = new DataSetField( setFieldName, valueMeta.getType(), valueMeta.getLength(),
        valueMeta.getPrecision(), valueMeta.getComments(), valueMeta.getFormatMask() );
      dataSet.getFields().add( field );
    }

    DataSetDialog dataSetDialog = new DataSetDialog( hopGui.getShell(), metadataProvider, dataSet );
    String dataSetName = dataSetDialog.open();
    if ( dataSetName != null ) {
      setSerializer.save( dataSet );

      PipelineUnitTest unitTest = getCurrentUnitTest( pipelineMeta );
      if ( unitTest == null ) {
        return;
      }

      // Now that the data set is created and we have an active unit test, perhaps the user wants to use it on the transform?
      //
      MessageBox box = new MessageBox( hopGui.getShell(), SWT.YES | SWT.NO | SWT.CANCEL | SWT.ICON_QUESTION );
      box.setText( "Use this data set?" );
      box.setMessage( "Do you want to use the new data set called '" + dataSet.getName() + "' on transform '" + transformMeta.getName() + "'?" + Const.CR +
        "Yes: as an input data set" + Const.CR +
        "No: as a golden data set" + Const.CR +
        "Cancel: not using it at this time" + Const.CR );
      int answer = box.open();
      if ( ( answer & SWT.YES ) != 0 ) {
        // set the new data set as an input
        //
        setInputDataSetOnTransform( metadataProvider, pipelineMeta, transformMeta, unitTest, dataSet );
      }
      if ( ( answer & SWT.NO ) != 0 ) {
        setGoldenDataSetOnTransform( metadataProvider, pipelineMeta, transformMeta, unitTest, dataSet );
      }
    }
  } catch ( Exception e ) {
    new ErrorDialog( hopGui.getShell(), "Error", "Error creating a new data set", e );
  }
}
 
Example 20
Source Project: hop   File: DeleteMessageBox.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Creates a message box to confirm the deletion of the items
 *
 * @param shell    the shell which will be the parent of the new instance
 * @param text     the title for the dialog
 * @param transformList the text list of proposed transforms to be deleted
 */
public DeleteMessageBox( Shell shell, String text, List<String> transformList ) {
  super( shell, SWT.YES | SWT.NO | SWT.ICON_WARNING );
  this.text = text;
  this.transformList = transformList;
}