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

The following examples show how to use org.eclipse.swt.SWT#NO . 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: JobEntryJobDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
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 2
Source File: ImportRulesDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
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 3
Source File: JobEntryTransDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private boolean askToCreateNewTransformation( String prevName ) {
  MessageBox mb = new MessageBox( shell, SWT.YES | SWT.NO | SWT.ICON_QUESTION );
  mb.setMessage( BaseMessages.getString( PKG, "JobTrans.Dialog.CreateTransformationQuestion.Message" ) );
  mb.setText( BaseMessages.getString( PKG, "JobTrans.Dialog.CreateTransformationQuestion.Title" ) );
  int answer = mb.open();
  if ( answer == SWT.YES ) {
    Spoon spoon = Spoon.getInstance();
    spoon.newTransFile();
    TransMeta transMeta = spoon.getActiveTransformation();
    transMeta.initializeVariablesFrom( jobEntry );
    transMeta.setFilename( jobMeta.environmentSubstitute( prevName ) );
    wPath.setText( prevName );
    specificationMethod = ObjectLocationSpecificationMethod.FILENAME;
    spoon.saveFile();
    return true;
  }
  return false;
}
 
Example 4
Source File: Translator2.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public boolean quitFile() {
  java.util.List<MessagesStore> changedMessagesStores = store.getChangedMessagesStores();
  if ( !changedMessagesStores.isEmpty() ) {
    MessageBox mb = new MessageBox( shell, SWT.YES | SWT.NO | SWT.ICON_WARNING );
    mb.setMessage( BaseMessages.getString( PKG, "i18nDialog.ChangedFilesWhenExit", changedMessagesStores.size()
      + EMPTY_STRING ) );
    mb.setText( BaseMessages.getString( PKG, "i18nDialog.Warning" ) );

    int answer = mb.open();
    if ( answer == SWT.NO ) {
      return false;
    }
  }

  WindowProperty winprop = new WindowProperty( shell );
  props.setScreen( winprop );
  props.saveProps();

  shell.dispose();
  display.dispose();
  return true;
}
 
Example 5
Source File: NeoConnectionUtils.java    From knowbi-pentaho-pdi-neo4j-output with Apache License 2.0 6 votes vote down vote up
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 File: UserDefinedJavaClassDialog.java    From pentaho-kettle with 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 );
    box.setText( BaseMessages.getString( PKG, "UserDefinedJavaClassDialog.WarningDialogChanged.Title" ) );
    box.setMessage( BaseMessages.getString(
      PKG, "UserDefinedJavaClassDialog.WarningDialogChanged.Message", Const.CR ) );
    int answer = box.open();

    if ( answer == SWT.NO ) {
      return false;
    }
  }
  stepname = null;
  input.setChanged( changed );
  dispose();
  return true;
}
 
Example 7
Source File: RepositorySecurityUI.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * @param shell
 *          the parent shell.
 * @return true if we need to retry, false if we need to cancel the operation.
 */
public static boolean showVersionCommentMandatoryDialog( Shell shell ) {
  MessageBox box = new MessageBox( shell, SWT.YES | SWT.NO | SWT.ICON_ERROR );
  box.setMessage( "Version comments are mandatory for this repository."
    + Const.CR + "Do you want to enter a comment?" );
  box.setText( "Version comments are mandatory!" );
  return box.open() == SWT.YES;
}
 
Example 8
Source File: GraphModelUtils.java    From knowbi-pentaho-pdi-neo4j-output with Apache License 2.0 5 votes vote down vote up
public static GraphModel newModel( Shell shell, MetaStoreFactory<GraphModel> factory, RowMetaInterface inputRowMeta ) {
  GraphModel graphModel = new GraphModel();
  boolean ok = false;
  while ( !ok ) {
    GraphModelDialog dialog = new GraphModelDialog( shell, graphModel, inputRowMeta );
    if ( dialog.open() ) {

      // write to metastore...
      //
      try {
        if ( factory.loadElement( graphModel.getName() ) != null ) {
          MessageBox box = new MessageBox( shell, SWT.YES | SWT.NO | SWT.ICON_ERROR );
          box.setText( BaseMessages.getString( PKG, "GraphModelUtils.Error.ModelExists.Title" ) );
          box.setMessage( BaseMessages.getString( PKG, "GraphModelUtils.Error.ModelExists.Message" ) );
          int answer = box.open();
          if ( ( answer & SWT.YES ) != 0 ) {
            factory.saveElement( graphModel );
            ok = true;
          }
        } else {
          factory.saveElement( graphModel );
          ok = true;
        }
      } catch ( Exception exception ) {
        new ErrorDialog( shell,
          BaseMessages.getString( PKG, "GraphModelUtils.Error.ErrorSavingModel.Title" ),
          BaseMessages.getString( PKG, "GraphModelUtils.Error.ErrorSavingModel.Message" ),
          exception );
        return null;
      }
    } else {
      // Cancel
      return null;
    }
  }
  return graphModel;
}
 
Example 9
Source File: ShowMessageDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void cancel() {
  if ( ( flags & SWT.NO ) > 0 ) {
    quit( SWT.NO );
  } else {
    quit( SWT.CANCEL );
  }
}
 
Example 10
Source File: Neo4jPerspective.java    From knowbi-pentaho-pdi-neo4j-output with Apache License 2.0 5 votes vote down vote up
private void deleteGraphModel( Event event ) {
  String[] selection = wGraphModels.getSelection();
  if ( selection == null || selection.length < 1 ) {
    return;
  }
  String modelName = selection[ 0 ];

  try {
    MessageBox box = new MessageBox( Spoon.getInstance().getShell(), SWT.YES | SWT.NO | SWT.ICON_QUESTION );
    box.setText( BaseMessages.getString( PKG, "Neo4jPerspective.DeleteGraphModelConfirmation.Title" ) );
    box.setMessage( BaseMessages.getString( PKG, "Neo4jPerspective.DeleteGraphModelConfirmation.Message", modelName ) );
    int answer = box.open();
    if ( ( answer & SWT.YES ) != 0 ) {
      try {
        modelsFactory.deleteElement( modelName);
      } catch ( Exception exception ) {
        new ErrorDialog( Spoon.getInstance().getShell(),
          BaseMessages.getString( PKG, "NeoConnectionUtils.Error.ErrorDeletingConnection.Title" ),
          BaseMessages.getString( PKG, "NeoConnectionUtils.Error.ErrorDeletingConnection.Message", modelName ),
          exception );
      }
    }
    updateGraphModelsList();
  } catch ( Exception e ) {
    new ErrorDialog( Spoon.getInstance().getShell(), "Error", "Unable to delete graph model", e );
  }
}
 
Example 11
Source File: MainWindow.java    From ProtocolAnalyzer with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Delete the selected sample row, just exits if no row is selected
 * @param force if false, requester ask if sure
 */
protected void deleteSelectedRow(boolean force) {
	if (m_Table.getSelectionCount() != 1) return;
	int response;
	if (force) {
		response = SWT.YES;
	} else {
		MessageBox box = new MessageBox(m_Shell, SWT.ICON_QUESTION | SWT.YES | SWT.NO);
		box.setMessage(Messages.getString("MainWindow.ReallyDeleteSelected")); //$NON-NLS-1$
		response = box.open();
	}
	if (response == SWT.YES) {
		m_Table.remove(m_Table.getSelectionIndex());
	}
}
 
Example 12
Source File: ShowMessageDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
private void cancel() {
  if ( ( flags & SWT.NO ) > 0 ) {
    quit( SWT.NO );
  } else {
    quit( SWT.CANCEL );
  }
}
 
Example 13
Source File: TransHistoryDelegate.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * User requested to clear the log table.<br>
 * Better ask confirmation
 */
private void clearLogTable( int index ) {
  TransHistoryLogTab model = models[index];
  LogTableInterface logTable = model.logTable;

  if ( logTable.isDefined() ) {
    DatabaseMeta databaseMeta = logTable.getDatabaseMeta();

    MessageBox mb = new MessageBox( transGraph.getShell(), SWT.YES | SWT.NO | SWT.ICON_QUESTION );
    mb.setMessage( BaseMessages.getString( PKG, "TransGraph.Dialog.AreYouSureYouWantToRemoveAllLogEntries.Message",
      logTable.getQuotedSchemaTableCombination() ) );
    mb.setText( BaseMessages.getString( PKG, "TransGraph.Dialog.AreYouSureYouWantToRemoveAllLogEntries.Title" ) );
    if ( mb.open() == SWT.YES ) {
      Database database = new Database( loggingObject, databaseMeta );
      try {
        database.connect();
        database.truncateTable( logTable.getSchemaName(), logTable.getTableName() );
      } catch ( Exception e ) {
        new ErrorDialog( transGraph.getShell(),
          BaseMessages.getString( PKG, "TransGraph.Dialog.ErrorClearningLoggingTable.Title" ),
          BaseMessages.getString( PKG, "TransGraph.Dialog.ErrorClearningLoggingTable.Message" ), e );
      } finally {
        database.disconnect();

        refreshHistory();
        if ( model.logDisplayText != null ) {
          model.logDisplayText.setText( "" );
        }
      }
    }
  }
}
 
Example 14
Source File: UIExitUtilsSWT.java    From BiglyBT with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return true, if the user choosed OK in the exit dialog
 *
 * @author Rene Leonhardt
 */
private static boolean getExitConfirmation(boolean for_restart) {
	MessageBoxShell mb = new MessageBoxShell(SWT.ICON_WARNING | SWT.YES
			| SWT.NO, for_restart ? "MainWindow.dialog.restartconfirmation"
			: "MainWindow.dialog.exitconfirmation", (String[]) null);
	mb.open(null);

	return mb.waitUntilClosed() == SWT.YES;
}
 
Example 15
Source File: MetaInjectDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void showInvalidMappingDialog( Set<SourceStepField> unavailableSourceSteps,
    Set<TargetStepAttribute> unavailableTargetSteps, Set<TargetStepAttribute> missingTargetKeys ) {
  MessageBox mb = new MessageBox( shell, SWT.YES | SWT.NO | SWT.ICON_QUESTION );
  mb.setMessage( BaseMessages.getString( PKG, "MetaInjectDialog.InvalidMapping.Question" ) );
  mb.setText( BaseMessages.getString( PKG, "MetaInjectDialog.InvalidMapping.Title" ) );
  int id = mb.open();
  if ( id == SWT.YES ) {
    MetaInject.removeUnavailableStepsFromMapping( targetSourceMapping, unavailableSourceSteps,
        unavailableTargetSteps );
    for ( TargetStepAttribute target : missingTargetKeys ) {
      targetSourceMapping.remove( target );
    }
  }
}
 
Example 16
Source File: ProjectsGuiPlugin.java    From hop with Apache License 2.0 4 votes vote down vote up
@GuiToolbarElement(
  root = HopGui.ID_MAIN_TOOLBAR,
  id = ID_TOOLBAR_PROJECT_DELETE,
  toolTip = "Deleted the selected project",
  image = "project-delete.svg",
  separator = true
)
public void deleteSelectedProject() {
  Combo combo = getProjectsCombo();
  if ( combo == null ) {
    return;
  }
  String projectName = combo.getText();
  if ( StringUtils.isEmpty( projectName ) ) {
    return;
  }

  ProjectsConfig config = ProjectsConfigSingleton.getConfig();

  ProjectConfig projectConfig = config.findProjectConfig( projectName );
  if ( projectConfig == null ) {
    return;
  }
  String projectHome = projectConfig.getProjectHome();
  String configFilename = projectConfig.getConfigFilename();

  MessageBox box = new MessageBox( HopGui.getInstance().getShell(), SWT.YES | SWT.NO | SWT.ICON_QUESTION );
  box.setText( "Delete?" );
  box.setMessage( "Do you want to delete project '" + projectName + "' from the Hop configuration?" + Const.CR + "Please note that folder '" + projectHome
    + "' or the project configuration file " + configFilename + " in it are NOT removed or otherwise altered in any way." );
  int anwser = box.open();
  if ( ( anwser & SWT.YES ) != 0 ) {
    try {
      config.removeProjectConfig( projectName );
      ProjectsConfigSingleton.saveConfig();

      refreshProjectsList();
      selectProjectInList( null );
    } catch ( Exception e ) {
      new ErrorDialog( HopGui.getInstance().getShell(), "Error", "Error removing project '" + projectName + "'", e );
    }
  }
}
 
Example 17
Source File: EESpoonPlugin.java    From pentaho-kettle with 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 18
Source File: RepositoryExplorerDialog.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public boolean delSelectedObjects() {
  TreeItem[] items = wTree.getSelection();
  boolean error = false;

  MessageBox mb = new MessageBox( shell, SWT.ICON_WARNING | SWT.YES | SWT.NO );
  mb
    .setMessage( BaseMessages.getString( PKG, "RepositoryExplorerDialog.Trans.Delete.Confirm.Message1" )
      + ( items.length > 1
        ? BaseMessages.getString( PKG, "RepositoryExplorerDialog.Trans.Delete.Confirm.Message2" )
          + items.length + BaseMessages.getString( PKG, "RepositoryExplorerDialog.Trans.Delete.Confirm.Message3" )
        : BaseMessages.getString( PKG, "RepositoryExplorerDialog.Trans.Delete.Confirm.Message4" ) ) );
  mb.setText( BaseMessages.getString( PKG, "RepositoryExplorerDialog.Trans.Delete.Confirm.Title" ) );
  int answer = mb.open();

  if ( answer != SWT.YES ) {
    return false;
  }

  for ( int i = 0; i < items.length; i++ ) {
    final RepositoryElementMetaInterface repositoryObject = objectMap.get( ConstUI.getTreePath( items[i], 0 ) );
    if ( repositoryObject != null ) {

      try {
        switch ( repositoryObject.getObjectType() ) {
          case TRANSFORMATION:
            rep.deleteTransformation( repositoryObject.getObjectId() );
            break;
          case JOB:
            rep.deleteJob( repositoryObject.getObjectId() );
            break;
          default:
            break;
        }
      } catch ( Exception e ) {
        new ErrorDialog(
          shell,
          BaseMessages.getString( PKG, "RepositoryExplorerDialog.Trans.Delete.ErrorRemoving.Title" ), BaseMessages
            .getString( PKG, "RepositoryExplorerDialog.Trans.Delete.ErrorRemoving.Message" )
            + repositoryObject.getName() + "]", e );
        error = true;
      }
    }
  }
  refreshTree();

  return !error;
}
 
Example 19
Source File: AddOrUpdateLanguageDialog.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void okPressed() {
	if (txtCode.getText() == null || "".equals(txtCode.getText().trim())) { //$NON-NLS-1$
		MessageDialog.openInformation(getShell(),
				Messages.getString("languagecode.AddOrUpdateLanguageDialog.msgTitle"),
				Messages.getString("languagecode.AddOrUpdateLanguageDialog.msg1"));
		txtCode.forceFocus();
		return;
	}

	if (intType == DIALOG_ADD) {
		if (languageModel.getLanguagesMap().containsKey(txtCode.getText())) {
			MessageDialog.openInformation(getShell(),
					Messages.getString("languagecode.AddOrUpdateLanguageDialog.msgTitle"),
					Messages.getString("languagecode.AddOrUpdateLanguageDialog.msg2"));
			return;
		}
	} else if (intType == DIALOG_EDIT) {
		if (!txtCode.getText().equals(strCode) && languageModel.getLanguagesMap().containsKey(txtCode.getText())) {
			MessageDialog.openInformation(getShell(),
					Messages.getString("languagecode.AddOrUpdateLanguageDialog.msgTitle"),
					Messages.getString("languagecode.AddOrUpdateLanguageDialog.msg2"));
			return;
		}
	}

	if (txtName.getText() == null || "".equals(txtName.getText().trim())) { //$NON-NLS-1$
		MessageDialog.openInformation(getShell(),
				Messages.getString("languagecode.AddOrUpdateLanguageDialog.msgTitle"),
				Messages.getString("languagecode.AddOrUpdateLanguageDialog.msg3"));
		txtName.forceFocus();
		return;
	}

	String status = parse(txtCode.getText());
	if (!status.equals("")) { //$NON-NLS-1$
		MessageBox box = new MessageBox(getShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
		box.setMessage(status + Messages.getString("languagecode.AddOrUpdateLanguageDialog.msg4")); //$NON-NLS-1$
		if (box.open() == SWT.NO) {
			return;
		}
	}

	imagePath = (String) imageLabel.getData();
	if (imagePath == null) {
		imagePath = "";
	}
	strCode = txtCode.getText();
	strName = txtName.getText();
	blnIsBidi = btnIsBidi.getSelection();
	close();
}
 
Example 20
Source File: DeleteMessageBox.java    From pentaho-kettle with 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 stepList
 *          the text list of proposed steps to be deleted
 */
public DeleteMessageBox( Shell shell, String text, List<String> stepList ) {
  super( shell, SWT.YES | SWT.NO | SWT.ICON_WARNING );
  this.text = text;
  this.stepList = stepList;
}