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

The following examples show how to use org.eclipse.swt.SWT#ICON_QUESTION . 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: hop   File: TableView.java    License: Apache License 2.0 7 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
Source Project: hop   File: HopGuiPipelineGraph.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void saveAs( String filename ) throws HopException {

  try {
    FileObject fileObject = HopVfs.getFileObject( filename );
    if ( fileObject.exists() ) {
      MessageBox box = new MessageBox( hopGui.getShell(), SWT.YES | SWT.NO | SWT.ICON_QUESTION );
      box.setText( "Overwrite?" );
      box.setMessage( "Are you sure you want to overwrite file '" + filename + "'?" );
      int answer = box.open();
      if ( ( answer & SWT.YES ) == 0 ) {
        return;
      }
    }

    pipelineMeta.setFilename( filename );
    save();
  } catch ( Exception e ) {
    new HopException( "Error validating file existence for '" + filename + "'", e );
  }

}
 
Example 3
/**
 * Prompts the user to rename a trace
 *
 * @param element the conflicting element
 * @return the new name to use or null if rename is canceled
 */
private static String promptRename(ITmfProjectModelElement element) {
    MessageBox mb = new MessageBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.ICON_QUESTION | SWT.CANCEL | SWT.OK);
    mb.setText(Messages.DropAdapterAssistant_RenameTraceTitle);
    mb.setMessage(NLS.bind(Messages.DropAdapterAssistant_RenameTraceMessage, element.getName()));
    if (mb.open() != SWT.OK) {
        return null;
    }
    IContainer folder = element.getResource().getParent();
    int i = 2;
    while (true) {
        String name = element.getName() + '(' + Integer.toString(i++) + ')';
        IResource resource = folder.findMember(name);
        if (resource == null) {
            return name;
        }
    }
}
 
Example 4
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 5
Source Project: RepDev   File: MainShell.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void removeDir(TreeItem currentItem) {
	String dir;

	while (!(currentItem.getData() instanceof String)) {
		currentItem = currentItem.getParentItem();

		if (currentItem == null)
			return;
	}

	dir = (String) currentItem.getData();

	MessageBox dialog = new MessageBox(shell, SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL);
	dialog.setText("Confirm Directory Close");
	dialog.setMessage("Are you sure you want to close this directory?");

	if (dialog.open() == SWT.OK) {
		ProjectManager.saveProjects(dir);
		Config.getMountedDirs().remove(dir);

		currentItem.dispose();
	}

	tree.notifyListeners(SWT.Selection, null);
}
 
Example 6
Source Project: ermaster-b   File: DBSelectTabWrapper.java    License: Apache License 2.0 6 votes vote down vote up
private void changeDatabase() {
	MessageBox messageBox = new MessageBox(PlatformUI.getWorkbench()
			.getActiveWorkbenchWindow().getShell(), SWT.ICON_QUESTION
			| SWT.OK | SWT.CANCEL);
	messageBox.setText(ResourceString
			.getResourceString("dialog.title.change.database"));
	messageBox.setMessage(ResourceString
			.getResourceString("dialog.message.change.database"));

	if (messageBox.open() == SWT.OK) {
		String database = this.databaseCombo.getText();
		this.settings.setDatabase(database);
		this.dialog.initTab();

	} else {
		this.setData();
	}
}
 
Example 7
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 8
Source Project: ADT_Frontend   File: GitCredentialsService.java    License: MIT License 6 votes vote down vote up
public static boolean showPopUpAskingToStoreCredentials(Shell shell, String url, String user, String pass) {
	//since the credentials are proper ask if they should be stored in secure store
	MessageBox messageBox = new MessageBox(shell, SWT.ICON_QUESTION | SWT.YES | SWT.NO);
	messageBox.setText(Messages.AbapGitWizardPageRepositoryAndCredentials_credentials_manager_popup_title);
	messageBox.setMessage(Messages.AbapGitWizardPageRepositoryAndCredentials_store_creds_in_secure_storage);
	int rc = messageBox.open();

	if (rc == SWT.YES) {
		//Store credentials in Secure Store if user chose to in credentials page

		IExternalRepositoryInfoRequest credentials = AbapgitexternalrepoFactoryImpl.eINSTANCE.createExternalRepositoryInfoRequest();
		credentials.setUser(user);
		credentials.setPassword(pass);
		credentials.setUrl(url);
		GitCredentialsService.storeCredentialsInSecureStorage(credentials, url);
	} else {

		//delete credentials from secure store
		GitCredentialsService.deleteCredentialsFromSecureStorage(url);
	}

	return true;
}
 
Example 9
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 10
Source Project: hop   File: LoadFileInputDialog.java    License: Apache License 2.0 5 votes vote down vote up
private void get() {

    int clearFields = SWT.NO;
    int nrInputFields = wFields.nrNonEmpty();

    if ( nrInputFields > 0 ) {
      MessageBox mb = new MessageBox( shell, SWT.YES | SWT.NO | SWT.ICON_QUESTION );
      mb.setMessage( BaseMessages.getString( PKG, "LoadFileInputDialog.ClearFieldList.DialogMessage" ) );
      mb.setText( BaseMessages.getString( PKG, "LoadFileInputDialog.ClearFieldList.DialogTitle" ) );
      clearFields = mb.open();
    }

    if ( clearFields == SWT.YES ) {
      // Clear Fields Grid
      wFields.table.removeAll();
    }

    TableItem item = new TableItem( wFields.table, SWT.NONE );
    item.setText( 1, LoadFileInputField.ElementTypeDesc[ 0 ] );
    item.setText( 2, LoadFileInputField.ElementTypeDesc[ 0 ] );
    item.setText( 3, "String" );
    // file size
    item = new TableItem( wFields.table, SWT.NONE );
    item.setText( 1, LoadFileInputField.ElementTypeDesc[ 1 ] );
    item.setText( 2, LoadFileInputField.ElementTypeDesc[ 1 ] );
    item.setText( 3, "Integer" );

    wFields.removeEmptyRows();
    wFields.setRowNums();
    wFields.optWidth( true );
  }
 
Example 11
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 12
Source Project: erflute   File: ERDiagramEditPart.java    License: Apache License 2.0 5 votes vote down vote up
private void changeDatabase(PropertyChangeEvent event) {
    final MessageBox messageBox =
            new MessageBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL);
    messageBox.setText(DisplayMessages.getMessage("dialog.title.change.database"));
    messageBox.setMessage(DisplayMessages.getMessage("dialog.message.change.database"));
    if (messageBox.open() == SWT.OK) {
        event.setPropagationId("consumed");
    } else {
        final ERDiagram diagram = (ERDiagram) getModel();
        diagram.restoreDatabase(String.valueOf(event.getOldValue()));
    }
}
 
Example 13
Source Project: pentaho-kettle   File: SQLEditor.java    License: Apache License 2.0 5 votes vote down vote up
private void clearCache() {
  MessageBox mb = new MessageBox( shell, SWT.ICON_QUESTION | SWT.NO | SWT.YES | SWT.CANCEL );
  mb.setMessage( BaseMessages.getString( PKG, "SQLEditor.ClearWholeCache.Message", connection.getName() ) );
  mb.setText( BaseMessages.getString( PKG, "SQLEditor.ClearWholeCache.Title" ) );
  int answer = mb.open();

  switch ( answer ) {
    case SWT.NO:
      DBCache.getInstance().clear( connection.getName() );

      mb = new MessageBox( shell, SWT.ICON_INFORMATION | SWT.OK );
      mb.setMessage( BaseMessages.getString( PKG, "SQLEditor.ConnectionCacheCleared.Message", connection
        .getName() ) );
      mb.setText( BaseMessages.getString( PKG, "SQLEditor.ConnectionCacheCleared.Title" ) );
      mb.open();

      break;
    case SWT.YES:
      DBCache.getInstance().clear( null );

      mb = new MessageBox( shell, SWT.ICON_INFORMATION | SWT.OK );
      mb.setMessage( BaseMessages.getString( PKG, "SQLEditor.WholeCacheCleared.Message" ) );
      mb.setText( BaseMessages.getString( PKG, "SQLEditor.WholeCacheCleared.Title" ) );
      mb.open();

      break;
    case SWT.CANCEL:
      break;
    default:
      break;
  }
}
 
Example 14
/**
 * 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 15
/**
 * Delete all sample rows
 */
protected void deleteAllRows() {
	MessageBox box = new MessageBox(m_Shell, SWT.ICON_QUESTION | SWT.YES | SWT.NO);
	box.setMessage(Messages.getString("MainWindow.ReallyDeleteAll")); //$NON-NLS-1$
	int response = box.open();
	if (response == SWT.YES) {
		m_Table.removeAll();
	}
}
 
Example 16
Source Project: erflute   File: DBSelectTabWrapper.java    License: Apache License 2.0 5 votes vote down vote up
private void changeDatabase() {
    final MessageBox messageBox =
            new MessageBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL);
    messageBox.setText(DisplayMessages.getMessage("dialog.title.change.database"));
    messageBox.setMessage(DisplayMessages.getMessage("dialog.message.change.database"));

    if (messageBox.open() == SWT.OK) {
        final String database = databaseCombo.getText();
        settings.setDatabase(database);
        dialog.initTab();
    } else {
        setupData();
    }
}
 
Example 17
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 18
private int ask0() {
	int style = 0;
	switch (this.input_type) {
		case INPUT_OK_CANCEL:
			style |= SWT.CANCEL;
		case INPUT_OK:
			style |= SWT.OK;
			break;

		case INPUT_RETRY_CANCEL_IGNORE:
			style |= SWT.IGNORE;
		case INPUT_RETRY_CANCEL:
			style |= SWT.RETRY;
			style |= SWT.CANCEL;
			break;

		case INPUT_YES_NO_CANCEL:
			style |= SWT.CANCEL;
		case INPUT_YES_NO:
			style |= SWT.YES;
			style |= SWT.NO;
			break;
	}

	switch (this.message_type) {
		case MSG_ERROR:
			style |= SWT.ICON_ERROR;
			break;
		case MSG_INFO:
			style |= SWT.ICON_INFORMATION;
			break;
		case MSG_QUESTION:
			style |= SWT.ICON_QUESTION;
			break;
		case MSG_WARN:
			style |= SWT.ICON_WARNING;
			break;
		case MSG_WORKING:
			style |= SWT.ICON_WORKING;
			break;
	}

	MessageBoxShell mb = new MessageBoxShell(style, this.title,
			this.messagesAsString());
	mb.open(null);
	int result = mb.waitUntilClosed();

	switch (result) {
		case SWT.OK:
			return ANSWER_OK;
		case SWT.YES:
			return ANSWER_YES;
		case SWT.NO:
			return ANSWER_NO;
		case SWT.ABORT:
			return ANSWER_ABORT;
		case SWT.RETRY:
			return ANSWER_RETRY;
		case SWT.IGNORE:
			return ANSWER_IGNORE;
		default: // Cancel if anything else is returned.
			return ANSWER_CANCEL;
	}

}
 
Example 19
Source Project: hop   File: ProjectsGuiPlugin.java    License: Apache License 2.0 4 votes vote down vote up
@GuiToolbarElement(
  root = HopGui.ID_MAIN_TOOLBAR,
  id = ID_TOOLBAR_ENVIRONMENT_DELETE,
  toolTip = "Deleted the selected environment",
  image = "environment-delete.svg",
  separator = true
)
public void deleteSelectedEnvironment() {
  Combo combo = getEnvironmentsCombo();
  if ( combo == null ) {
    return;
  }
  String environmentName = combo.getText();
  if ( StringUtils.isEmpty( environmentName ) ) {
    return;
  }

  ProjectsConfig config = ProjectsConfigSingleton.getConfig();

  LifecycleEnvironment environment = config.findEnvironment( environmentName );
  if ( environment == null ) {
    return;
  }

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

      refreshEnvironmentsList();
      selectEnvironmentInList( null );
    } catch ( Exception e ) {
      new ErrorDialog( HopGui.getInstance().getShell(), "Error", "Error removing environment " + environmentName + "'", e );
    }
  }
}
 
Example 20
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 );
  }
}