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

The following examples show how to use org.eclipse.swt.SWT#SHEET . 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
public static MessageDialogWithPrompt openWithDetails(int kind,
        Shell parent,
        String title,
        String message,
        String detailMessage,
        Listener linkSelectionListener,
        int style) {
    MessageDialogWithPrompt dialog = new MessageDialogWithPrompt(parent,
            title,
            null,
            message,
            linkSelectionListener,
            kind,
            getButtonLabelsFor(kind),
            0,
            null,
            false);
    style &= SWT.SHEET;
    dialog.setShellStyle(dialog.getShellStyle() | style);
    dialog.setDetails(detailMessage);
    dialog.open();
    return dialog;
}
 
Example 2
private int promptForTraceOverwrite(TracePackageTraceElement packageElement) {
    String name = packageElement.getDestinationElementPath();
    final MessageDialog dialog = new MessageDialog(getContainer().getShell(),
            Messages.ImportTracePackageWizardPage_AlreadyExistsTitle,
            null,
            MessageFormat.format(Messages.ImportTracePackageWizardPage_TraceAlreadyExists, name),
            MessageDialog.QUESTION, new String[] {
                    IDialogConstants.NO_TO_ALL_LABEL,
                    IDialogConstants.NO_LABEL,
                    IDialogConstants.YES_TO_ALL_LABEL,
                    IDialogConstants.YES_LABEL },
            3) {
        @Override
        protected int getShellStyle() {
            return super.getShellStyle() | SWT.SHEET;
        }
    };
    return dialog.open();
}
 
Example 3
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 4
private void handleBrowseButtonPressed() {
	final DirectoryDialog dialog = new DirectoryDialog(
			directoryPathField.getShell(), SWT.SHEET);
	dialog.setMessage("Select search directory");

	String dirName = directoryPathField.getText().trim();
	if (dirName.isEmpty()) {
		dirName = previouslyBrowsedDirectory;
	}

	if (dirName.isEmpty()) {
		dialog.setFilterPath(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString());
	} else {
		File path = new File(dirName);
		if (path.exists()) {
			dialog.setFilterPath(new Path(dirName).toOSString());
		}
	}
	
	String selectedDirectory = dialog.open();
	if (selectedDirectory != null) {
		previouslyBrowsedDirectory = selectedDirectory;
		directoryPathField.setText(previouslyBrowsedDirectory);
		updateProjectsList(selectedDirectory);
	}
}
 
Example 5
private int promptForOverwrite(IPath tracePath) {
    final MessageDialog dialog = new MessageDialog(fShell,
            Messages.ImportTraceWizard_MessageTitle, null, NLS.bind(Messages.ImportTraceWizard_TraceAlreadyExists, tracePath.makeRelativeTo(fTraceFolderElement.getProject().getPath())),
            MessageDialog.QUESTION, new String[] {
                    ImportConfirmation.RENAME.getInName(),
                    ImportConfirmation.RENAME_ALL.getInName(),
                    ImportConfirmation.OVERWRITE.getInName(),
                    ImportConfirmation.OVERWRITE_ALL.getInName(),
                    ImportConfirmation.SKIP.getInName(),
                    ImportConfirmation.SKIP_ALL.getInName(),
            }, 4) {
        @Override
        protected int getShellStyle() {
            return super.getShellStyle() | SWT.SHEET;
        }
    };

    final int[] returnValue = new int[1];
    fShell.getDisplay().syncExec(() -> returnValue[0] = dialog.open());
    return returnValue[0];
}
 
Example 6
public static MessageDialogWithPrompt open(int kind, Shell parent, String title,
        String message,
        Listener linkSelectionListener,
        String toggleMessage,
        boolean toggleState,
        IPreferenceStore store,
        String key,
        int style) {
    final MessageDialogWithPrompt dialog = new MessageDialogWithPrompt(parent,
            title,
            null, // accept the default window icon
            message,
            linkSelectionListener,
            kind,
            getButtonLabelsFor(kind),
            0,
            toggleMessage,
            toggleState);
    style &= SWT.SHEET;
    dialog.setShellStyle(dialog.getShellStyle() | style);
    dialog.setPrefStore(store);
    dialog.setPrefKey(key);
    dialog.open();
    return dialog;
}
 
Example 7
/**
 *
 * @param shell
 *          the shell.
 */
public OlapInputAboutDialog( final Shell shell ) {
  this.dialog = new Shell( shell, SWT.BORDER | SWT.CLOSE | SWT.APPLICATION_MODAL | SWT.SHEET );
  GridLayout gridLayout = new GridLayout();
  gridLayout.numColumns = 2;

  this.dialog.setLayout( gridLayout );
  this.dialog.setText( BaseMessages.getString( PKG, "OlapInputDialog.About.Shell.Title" ) );
  this.dialog.setImage( shell.getImage() );

  this.buildIconCell();
  this.buildPluginInfoCell();
  this.buildOkButton();

  this.dialog.pack();
  Rectangle shellBounds = shell.getBounds();
  Point dialogSize = this.dialog.getSize();

  this.dialog.setLocation( shellBounds.x + ( shellBounds.width - dialogSize.x ) / 2, shellBounds.y
    + ( shellBounds.height - dialogSize.y ) / 2 );
}
 
Example 8
Source Project: pentaho-kettle   File: PropsUI.java    License: Apache License 2.0 6 votes vote down vote up
private int parseStyle( String sStyle ) {
  int style = SWT.DIALOG_TRIM;
  String[] styles = sStyle.split( "," );
  for ( String style1 : styles ) {
    if ( "APPLICATION_MODAL".equals( style1 ) ) {
      style |= SWT.APPLICATION_MODAL | SWT.SHEET;
    } else if ( "RESIZE".equals( style1 ) ) {
      style |= SWT.RESIZE;
    } else if ( "MIN".equals( style1 ) ) {
      style |= SWT.MIN;
    } else if ( "MAX".equals( style1 ) ) {
      style |= SWT.MAX;
    }
  }

  return style;
}
 
Example 9
/**
 * The browse button has been selected. Select the location.
 */
protected void handleLocationArchiveButtonPressed() {

	FileDialog dialog = new FileDialog(archivePathField.getShell(), SWT.SHEET);
	dialog.setFilterExtensions(FILE_IMPORT_MASK);
	dialog
			.setText(DataTransferMessages.WizardProjectsImportPage_SelectArchiveDialogTitle);

	String fileName = archivePathField.getText().trim();
	if (fileName.length() == 0) {
		fileName = previouslyBrowsedArchive;
	}

	if (fileName.length() == 0) {
		dialog.setFilterPath(IDEWorkbenchPlugin.getPluginWorkspace()
				.getRoot().getLocation().toOSString());
	} else {
		File path = new File(fileName).getParentFile();
		if (path != null && path.exists()) {
			dialog.setFilterPath(path.toString());
		}
	}

	String selectedArchive = dialog.open();
	if (selectedArchive != null) {
		previouslyBrowsedArchive = selectedArchive;
		archivePathField.setText(previouslyBrowsedArchive);
		updateProjectsList(selectedArchive);
	}

}
 
Example 10
/**
 * Import the rules from an XML rules file...
 */
protected void importRules() {
  if ( !importRules.getRules().isEmpty() ) {
    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 load a new set of rules, replacing the current list?" );
    int answer = box.open();
    if ( answer != SWT.YES ) {
      return;
    }
  }

  FileDialog dialog = new FileDialog( shell, SWT.OPEN );
  dialog.setFilterExtensions( new String[] { "*.xml;*.XML", "*" } );
  dialog.setFilterNames( new String[] {
    BaseMessages.getString( PKG, "System.FileType.XMLFiles" ),
    BaseMessages.getString( PKG, "System.FileType.AllFiles" ) } );
  if ( dialog.open() != null ) {
    String filename = dialog.getFilterPath() + System.getProperty( "file.separator" ) + dialog.getFileName();

    ImportRules newRules = new ImportRules();
    try {
      newRules.loadXML( XMLHandler.getSubNode( XMLHandler.loadXMLFile( filename ), ImportRules.XML_TAG ) );
      importRules = newRules;

      // Re-load the dialog.
      //
      getCompositesData();

    } catch ( Exception e ) {
      new ErrorDialog(
        shell, "Error",
        "There was an error during the import of the import rules file, verify the XML format.", e );
    }

  }
}
 
Example 11
private void getFromDirectory() {
  DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.SHEET);
  dialog.setMessage("Task source directories");

  String currentValue = getText().getText();
  if (currentValue != null && new File(currentValue).isDirectory()) {
    dialog.setFilterPath(currentValue);
  }
  String newValue = dialog.open();
  if (newValue != null) {
    getText().setText(newValue);
  }
}
 
Example 12
/**
 * 创建关闭对话框
 * @return MessageDalog
 */
private MessageDialog createWizardClosingDialog() {
	MessageDialog result = new MessageDialog(getShell(),
			Messages.getString("dialog.HsabstractProgressDialog.closeTtile"), //$NON-NLS-1$
			null, Messages.getString("dialog.HsabstractProgressDialog.closeMsg"), //$NON-NLS-1$
			MessageDialog.QUESTION, new String[] { IDialogConstants.OK_LABEL }, 0) {
		protected int getShellStyle() {
			return super.getShellStyle() | SWT.SHEET;
		}
	};
	return result;
}
 
Example 13
/**
 * The browse button has been selected. Select the location.
 */
protected void handleLocationDirectoryButtonPressed() {

	final DirectoryDialog dialog = new DirectoryDialog(directoryPathField.getShell(), SWT.SHEET);
	dialog.setMessage(DataTransferMessages.WizardProjectsImportPage_SelectDialogTitle);

	String dirName = directoryPathField.getText().trim();
	if (dirName.length() == 0) {
		dirName = previouslyBrowsedDirectory;
	}

	if (dirName.length() == 0) {
		dialog.setFilterPath(IDEWorkbenchPlugin.getPluginWorkspace().getRoot().getLocation().toOSString());
	} else {
		final File path = new File(dirName);
		if (path.exists()) {
			dialog.setFilterPath(new Path(dirName).toOSString());
		}
	}

	final String selectedDirectory = dialog.open();
	if (selectedDirectory != null) {
		previouslyBrowsedDirectory = selectedDirectory;
		directoryPathField.setText(previouslyBrowsedDirectory);
		updateProjectsList(selectedDirectory);
	}

}
 
Example 14
/**
 * The browse button has been selected. Select the location.
 */
protected void handleLocationArchiveButtonPressed() {

	final FileDialog dialog = new FileDialog(archivePathField.getShell(), SWT.SHEET);
	dialog.setFilterExtensions(FILE_IMPORT_MASK);
	dialog.setText(DataTransferMessages.WizardProjectsImportPage_SelectArchiveDialogTitle);

	String fileName = archivePathField.getText().trim();
	if (fileName.length() == 0) {
		fileName = previouslyBrowsedArchive;
	}

	if (fileName.length() == 0) {
		dialog.setFilterPath(IDEWorkbenchPlugin.getPluginWorkspace().getRoot().getLocation().toOSString());
	} else {
		final File path = new File(fileName).getParentFile();
		if (path != null && path.exists()) {
			dialog.setFilterPath(path.toString());
		}
	}

	final String selectedArchive = dialog.open();
	if (selectedArchive != null) {
		previouslyBrowsedArchive = selectedArchive;
		archivePathField.setText(previouslyBrowsedArchive);
		updateProjectsList(selectedArchive);
	}

}
 
Example 15
/**
 * Creates and return a new wizard closing dialog without opening it.
 * 
 * @return MessageDalog
 */
private MessageDialog createWizardClosingDialog() {
	MessageDialog result = new MessageDialog(getShell(),
			JFaceResources.getString("WizardClosingDialog.title"), //$NON-NLS-1$
			null,
			JFaceResources.getString("WizardClosingDialog.message"), //$NON-NLS-1$
			MessageDialog.QUESTION,
			new String[] { IDialogConstants.OK_LABEL }, 0) {
		protected int getShellStyle() {
			return super.getShellStyle() | SWT.SHEET;
		}
	};
	return result;
}
 
Example 16
protected Optional<String> getPath(Shell shell, IRepositoryFileStore fStore) {
    final FileDialog fd = new FileDialog(shell, SWT.SAVE | SWT.SHEET);
    fd.setFileName(fStore.getName());
    fd.setFilterExtensions(new String[] { "*.xml" });
    fd.setText(getExportTitle());
    return Optional.ofNullable(fd.open());
}
 
Example 17
Source Project: pentaho-kettle   File: WarningDialog.java    License: Apache License 2.0 4 votes vote down vote up
public void open() {
  Shell parent = getParent();
  Display display = parent.getDisplay();

  shell = new Shell( parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.SHEET | SWT.RESIZE );
  shell.setImage( GUIResource.getInstance().getImageSpoon() );
  shell.setLayout( new FormLayout() );
  shell.setText( title );
  props.setLook( shell );

  Label wlImage = new Label( shell, SWT.NONE );
  wlImage.setImage( GUIResource.getInstance().getImageWarning32() );
  FormData fdWarnImage = new FormData();
  fdWarnImage.left = new FormAttachment( 0, 15 );
  fdWarnImage.top = new FormAttachment( 0, 15 );
  fdWarnImage.height = 32;
  fdWarnImage.width = 32;
  wlImage.setLayoutData( fdWarnImage );
  props.setLook( wlImage );

  Label wlMessage = new Label( shell, SWT.FLAT  | SWT.WRAP );
  wlMessage.setText( message );
  FormData fdMessage = new FormData();
  fdMessage.left = new FormAttachment( wlImage, 15, SWT.RIGHT );
  fdMessage.right = new FormAttachment( 100, -15 );
  fdMessage.top = new FormAttachment( wlImage, 0, SWT.TOP );
  wlMessage.setLayoutData( fdMessage );
  props.setLook( wlMessage );


  Button spacer = new Button( shell, SWT.NONE );
  FormData fdSpacer = new FormData();
  fdSpacer.right = new FormAttachment( 100, 0 );
  fdSpacer.bottom = new FormAttachment( 100, -15 );
  fdSpacer.left = new FormAttachment( 100, -11 );
  fdSpacer.top = new FormAttachment( wlMessage, 15, SWT.BOTTOM );
  spacer.setLayoutData( fdSpacer );
  spacer.setVisible( false );
  props.setLook( spacer );

  Control attachTo = spacer;
  for ( String label : listenerMap.keySet() ) {
    Button wButton = new Button( shell, SWT.PUSH );
    wButton.setText( label );
    FormData fdButton = new FormData();
    fdButton.right = new FormAttachment( attachTo, -Const.MARGIN, SWT.LEFT );
    fdButton.bottom = new FormAttachment( attachTo, 0, SWT.BOTTOM );
    wButton.setLayoutData( fdButton );
    wButton.addListener( SWT.Selection, listenAndDispose( listenerMap.get( label ) ) );
    props.setLook( wButton );
    attachTo = wButton;
  }
  Point point = shell.computeSize( 436, SWT.DEFAULT );
  shell.setSize( point );
  shell.open();
  while ( !shell.isDisposed() ) {
    if ( !display.readAndDispatch() ) {
      display.sleep();
    }
  }
}
 
Example 18
public RelativeFileFieldSetter(Text fileField, IPath basePath, String[] filterExtensions) {
  this(fileField, basePath, filterExtensions, new FileDialog(fileField.getShell(), SWT.SHEET));
}
 
Example 19
public FileFieldSetter(Text fileField, String[] filterExtensions) {
  this(fileField, filterExtensions, new FileDialog(fileField.getShell(), SWT.SHEET));
}
 
Example 20
/**
 * Open an appropriate directory browser
 */
private void handleLocationBrowseButtonPressed()
{

	String selectedDirectory = null;
	String dirName = getPathFromLocationField();

	if (!dirName.equals(IDEResourceInfoUtils.EMPTY_STRING))
	{
		IFileInfo info;
		info = IDEResourceInfoUtils.getFileInfo(dirName);

		if (info == null || !(info.exists()))
			dirName = IDEResourceInfoUtils.EMPTY_STRING;
	}
	else
	{
		String value = getDialogSettings().get(SAVED_LOCATION_ATTR);
		if (value != null)
		{
			dirName = value;
		}
	}

	FileSystemConfiguration config = getSelectedConfiguration();
	if (config == null || config.equals(FileSystemSupportRegistry.getInstance().getDefaultConfiguration()))
	{
		DirectoryDialog dialog = new DirectoryDialog(locationPathField.getShell(), SWT.SHEET);
		dialog.setMessage(IDEWorkbenchMessages.ProjectLocationSelectionDialog_directoryLabel);

		dialog.setFilterPath(dirName);

		selectedDirectory = dialog.open();

	}
	else
	{
		URI uri = getSelectedConfiguration().getContributor().browseFileSystem(dirName, browseButton.getShell());
		if (uri != null)
			selectedDirectory = uri.toString();
	}

	if (selectedDirectory != null)
	{
		updateLocationField(selectedDirectory);
		getDialogSettings().put(SAVED_LOCATION_ATTR, selectedDirectory);
	}
}