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

The following examples show how to use org.eclipse.swt.SWT#APPLICATION_MODAL . 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: 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 2
Source Project: hop   File: ScriptValuesMetaModDialog.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 3
Source Project: pentaho-kettle   File: BaseDialog.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Returns a {@link org.eclipse.swt.events.SelectionAdapter} that is used to "submit" the dialog.
 */
private Display prepareLayout() {

  // Prep the parent shell and the dialog shell
  final Shell parent = getParent();
  final Display display = parent.getDisplay();

  shell = new Shell( parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.SHEET );
  shell.setImage( GUIResource.getInstance().getImageSpoon() );
  props.setLook( shell );
  // Detect X or ALT-F4 or something that kills this window...
  shell.addShellListener( new ShellAdapter() {
    @Override
    public void shellClosed( ShellEvent e ) {
      dispose();
    }
  } );

  final FormLayout formLayout = new FormLayout();
  formLayout.marginWidth = MARGIN_SIZE;
  formLayout.marginHeight = MARGIN_SIZE;

  shell.setLayout( formLayout );
  shell.setText( this.title );
  return display;
}
 
Example 4
public KettleDatabaseRepositoryDialog( Shell parent, int style,
                                       RepositoryMeta repositoryMeta,
                                       RepositoriesMeta repositoriesMeta ) {
  this.display = parent.getDisplay();
  this.props = PropsUI.getInstance();
  this.input = (KettleDatabaseRepositoryMeta) repositoryMeta;
  this.repositories = repositoriesMeta;
  this.masterRepositoriesMeta = repositoriesMeta.clone();
  this.masterRepositoryName = repositoryMeta.getName();

  shell =
      new Shell( parent, style | SWT.DIALOG_TRIM | SWT.RESIZE
              | SWT.MAX | SWT.MIN | SWT.APPLICATION_MODAL | SWT.SHEET );
  shell.setText( BaseMessages.getString( PKG, "RepositoryDialog.Dialog.Main.Title" ) );

}
 
Example 5
/**
 *
 * @param shell
 *          the shell.
 */
public TeraFastAboutDialog( 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, "TeraFastDialog.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 6
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 7
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 8
static private int fixupStyle(int style) {
	if ((style & (SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL | SWT.PRIMARY_MODAL)) != 0
			&& Utils.anyShellHaveStyle(SWT.ON_TOP | SWT.TITLE)) {
		UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
		if (uiFunctions != null && uiFunctions.getMainShell() != null) {
			style |= SWT.ON_TOP;
		}
	}
	return style;
}
 
Example 9
/**
 * 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 10
Source Project: hop   File: ProjectDialog.java    License: Apache License 2.0 5 votes vote down vote up
public ProjectDialog( Shell parent, Project project, ProjectConfig projectConfig, IVariables variables ) {
  super( parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE );

  this.project = project;
  this.projectConfig = projectConfig;

  props = PropsUi.getInstance();

  this.variables = new Variables();
  this.variables.initializeVariablesFrom( null );
  project.modifyVariables( variables, projectConfig, Collections.emptyList(), null );
}
 
Example 11
Source Project: hop   File: LifecycleEnvironmentDialog.java    License: Apache License 2.0 5 votes vote down vote up
public LifecycleEnvironmentDialog( Shell parent, LifecycleEnvironment environment, IVariables variables ) {
  super( parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE );

  this.environment = environment;
  this.variables = variables;

  props = PropsUi.getInstance();
}
 
Example 12
Source Project: BiglyBT   File: Utils.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Waits until modal dialogs are disposed.  Assumes we are on SWT thread
 *
 * @since 3.0.1.3
 */
public static void waitForModals() {
	SWTThread swt = SWTThread.getInstance();

	Display display;
	if (swt == null) {
		display = Display.getDefault();
		if (display == null) {
			System.err.println("SWT Thread not started yet!");
			return;
		}
	} else {
		if (swt.isTerminated()) {
			return;
		}
		display = swt.getDisplay();
	}

	if (display == null || display.isDisposed()) {
		return;
	}

	Shell[] shells = display.getShells();
	Shell modalShell = null;
	for (int i = 0; i < shells.length; i++) {
		Shell shell = shells[i];
		if ((shell.getStyle() & SWT.APPLICATION_MODAL) != 0) {
			modalShell = shell;
			break;
		}
	}

	if (modalShell != null) {
		while (!modalShell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}
}
 
Example 13
public void open(int minValue, int maxValue) {
	childShell = new Shell(shell.getDisplay(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
	childShell.setText("Exporting to Excel.. please wait");

	progressBar = new ProgressBar(childShell, SWT.SMOOTH);
	progressBar.setMinimum(minValue);
	progressBar.setMaximum(maxValue);
	progressBar.setBounds(0, 0, 400, 25);
	progressBar.setFocus();

	childShell.pack();
	childShell.open();
}
 
Example 14
private List<WordIndexerWrapper> findAll(String keyWord, boolean matchCase, boolean wholeWord, boolean regex,
		Point searchBounds) {

	String wholeText = text.getText();
	if (!matchCase) {
		keyWord = keyWord.toLowerCase();
		wholeText = wholeText.toLowerCase();
	}
	if (!regex) {
		String temp = "";
		for (int i = 0; i < keyWord.length(); i++)
			temp += ("[" + keyWord.charAt(i) + "]");
		keyWord = temp;
	}
	if (wholeWord)
		keyWord = "\\b" + keyWord + "\\b";
	System.out.println("looking for: " + keyWord);
	WordIndexer finder = new WordIndexer(wholeText);
	List<WordIndexerWrapper> indexes = new LinkedList<WordIndexerWrapper>();
	try {
		indexes = finder.findIndexesForKeyword(keyWord, searchBounds.x, searchBounds.y);
	} catch (PatternSyntaxException e) {
		MessageBox diag = new MessageBox(Display.getCurrent().getActiveShell(),
				SWT.APPLICATION_MODAL | SWT.ICON_ERROR | SWT.OK);
		diag.setMessage("Regular expression error.\n\n" + e.getMessage());
		diag.open();
	}
	return indexes;
}
 
Example 15
protected void setShellStyle( int newShellStyle )
{
	super.setShellStyle( newShellStyle
			| SWT.DIALOG_TRIM
			| SWT.RESIZE
			| SWT.APPLICATION_MODAL );
}
 
Example 16
protected void setShellStyle( int newShellStyle )
{
	super.setShellStyle( newShellStyle
			| SWT.DIALOG_TRIM
			| SWT.RESIZE
			| SWT.APPLICATION_MODAL );
}
 
Example 17
protected void setShellStyle( int newShellStyle )
{
	super.setShellStyle( newShellStyle
			| SWT.DIALOG_TRIM | SWT.RESIZE | SWT.APPLICATION_MODAL );
}
 
Example 18
public AbstractStyleEditorDialog(Shell parent) {
	super(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
}
 
Example 19
public SWTWindow(SWTWindow parent, boolean modal, boolean resizable) {
	this(new Shell(parent.getControl(), SWT.DIALOG_TRIM | (modal ? SWT.APPLICATION_MODAL : 0) | (resizable ? SWT.RESIZE | SWT.MAX : 0)), parent);
}
 
Example 20
@Override
public Shell showCoreWaitDlg() {
	final SkinnedDialog closeDialog = new SkinnedDialog(
			"skin3_dlg_coreloading", "coreloading.body", SWT.TITLE | SWT.BORDER
			| SWT.APPLICATION_MODAL);

	closeDialog.setTitle(MessageText.getString("dlg.corewait.title"));
	SWTSkin skin = closeDialog.getSkin();
	SWTSkinObjectButton soButton = (SWTSkinObjectButton) skin.getSkinObject("close");

	final SWTSkinObjectText soWaitTask = (SWTSkinObjectText) skin.getSkinObject("task");

	final SWTSkinObject soWaitProgress = skin.getSkinObject("progress");
	if (soWaitProgress != null) {
		soWaitProgress.getControl().addPaintListener(new PaintListener() {
			@Override
			public void paintControl(PaintEvent e) {
				Control c = (Control) e.widget;
				Point size = c.getSize();
				e.gc.setBackground(ColorCache.getColor(e.display, "#23a7df"));
				Object data = soWaitProgress.getData("progress");
				if (data instanceof Long) {
					int waitProgress = ((Long) data).intValue();
					int breakX = size.x * waitProgress / 100;
					e.gc.fillRectangle(0, 0, breakX, size.y);
					e.gc.setBackground(ColorCache.getColor(e.display, "#cccccc"));
					e.gc.fillRectangle(breakX, 0, size.x - breakX, size.y);
				}
			}
		});
	}

	if (!CoreFactory.isCoreRunning()) {
		final Initializer initializer = Initializer.getLastInitializer();
		if (initializer != null) {
			initializer.addListener(new InitializerListener() {
				@Override
				public void reportPercent(final int percent) {
					Utils.execSWTThread(new AERunnable() {
						@Override
						public void runSupport() {
							if (soWaitProgress != null && !soWaitProgress.isDisposed()) {
								soWaitProgress.setData("progress", new Long(percent));
								soWaitProgress.getControl().redraw();
								soWaitProgress.getControl().update();
							}
						}
					});
					if (percent > 100) {
						initializer.removeListener(this);
					}
				}

				@Override
				public void reportCurrentTask(String currentTask) {
					if (soWaitTask != null && !soWaitTask.isDisposed()) {
						soWaitTask.setText(currentTask);
					}
				}
			});
		}
	}

	if (soButton != null) {
		soButton.addSelectionListener(new ButtonListenerAdapter() {
			@Override
			public void pressed(SWTSkinButtonUtility buttonUtility,
			                    SWTSkinObject skinObject, int stateMask) {
				closeDialog.close();
			}
		});
	}

	closeDialog.addCloseListener(new SkinnedDialogClosedListener() {
		@Override
		public void skinDialogClosed(SkinnedDialog dialog) {
		}
	});

	closeDialog.open();
	return closeDialog.getShell();
}