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

The following examples show how to use org.eclipse.swt.SWT#SYSTEM_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: nebula   File: TipOfTheDay.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Build the shell
 *
 * @param parent parent shell
 */
private void buildShell(final Shell parent) {
	shell = new Shell(parent, SWT.SYSTEM_MODAL | SWT.TITLE | SWT.BORDER | SWT.CLOSE | SWT.RESIZE);
	shell.setText(ResourceManager.getLabel(ResourceManager.TIP_OF_THE_DAY));
	shell.setLayout(new GridLayout(style == TipStyle.HEADER ? 1 : 2, false));

	shell.addListener(SWT.Traverse, event -> {
		switch (event.detail) {
			case SWT.TRAVERSE_ESCAPE:
				shell.dispose();
				event.detail = SWT.TRAVERSE_NONE;
				event.doit = false;
				break;
		}
	});
}
 
Example 2
Source Project: SWET   File: ChoicesDialog.java    License: MIT License 5 votes vote down vote up
private void checkStyle(int style) {
	if ((style & ~(SWT.APPLICATION_MODAL | SWT.PRIMARY_MODAL | SWT.SYSTEM_MODAL
			| SWT.MODELESS)) != 0) {
		throw new SWTException("Unsupported style");
	}
	if (Integer.bitCount(style) > 1) {
		throw new SWTException(
				"Unsupports only one of APPLICATION_MODAL, PRIMARY_MODAL, SYSTEM_MODAL or SWT.MODELESS");
	}
}
 
Example 3
private static String askForRetargetedFilename(DiskManagerFileInfo fileInfo) {
	// parg - removed SAVE option as this prevents the selection of existing read-only media when re-targetting	| SWT.SAVE);
	// tux - without SWT.SAVE on OSX, user can't choose a new file. RO seems to work on OSX with SWT.SAVE
	int flag = Constants.isOSX ? SWT.SAVE : SWT.NONE;
	FileDialog fDialog = new FileDialog(Utils.findAnyShell(), SWT.SYSTEM_MODAL | flag );
	File existing_file = fileInfo.getFile(true);
	fDialog.setFilterPath(existing_file.getParent());
	fDialog.setFileName(existing_file.getName());
	fDialog.setText(MessageText.getString("FilesView.rename.choose.path"));
	return fDialog.open();
}
 
Example 4
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 5
Source Project: nebula   File: LoginDialog.java    License: Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Build the shell
 */
private void buildShell() {
	shell = new Shell(SWT.SYSTEM_MODAL | SWT.TITLE | SWT.BORDER);
	shell.setText(ResourceManager.getLabel(ResourceManager.LOGIN));
	shell.setLayout(new GridLayout(4, false));
}
 
Example 6
Source Project: SWET   File: TipDayEx.java    License: MIT License 4 votes vote down vote up
public void open(final Shell parent, Display... parentDisplay) {
	if (TipDayEx.index == -1) {
		TipDayEx.index = new Random().nextInt(this.tips.size());
	}
	this.shell = new Shell(parent,
			SWT.SYSTEM_MODAL | SWT.TITLE | SWT.BORDER | SWT.CLOSE | SWT.RESIZE);
	this.shell.setText("Tip of the day");
	this.shell.setLayout(new GridLayout(2, false));

	this.shell.addListener(SWT.Traverse, new Listener() {
		@Override
		public void handleEvent(final Event event) {
			switch (event.detail) {
			case SWT.TRAVERSE_ESCAPE:
				TipDayEx.this.shell.dispose();
				event.detail = SWT.TRAVERSE_NONE;
				event.doit = false;
				break;
			}
		}
	});
	buildLeftColumn();
	buildTip();
	buildButtons();

	this.shell.setDefaultButton(this.buttonClose);
	this.shell.pack();
	this.shell.open();

	if (parentDisplay != null) {
		display = parentDisplay[0];
	} else {

		display = this.shell.getDisplay();
	}
	Monitor primary = display.getPrimaryMonitor();
	Rectangle bounds = primary.getBounds();
	Rectangle rect = shell.getBounds();

	int x = bounds.x + (bounds.width - rect.width) / 2;
	int y = bounds.y + (bounds.height - rect.height) / 2;

	shell.setLocation(x, y);

	while (!this.shell.isDisposed()) {
		if (!display.readAndDispatch()) {
			display.sleep();
		}
	}
}
 
Example 7
private void
setSavePath()
{
	if ( torrentOptions.isSimpleTorrent()){

		changeFileDestination( torrentOptions.getFiles(), false );

	}else{
		DirectoryDialog dDialog = new DirectoryDialog(shell,SWT.SYSTEM_MODAL);

		File filterPath = FileUtil.newFile( torrentOptions.getDataDir());

		if ( !filterPath.exists()){
			filterPath = filterPath.getParentFile();
		}
		dDialog.setFilterPath( filterPath.getAbsolutePath());
		dDialog.setMessage(MessageText.getString("MainWindow.dialog.choose.savepath")
				+ " (" + torrentOptions.getTorrentName() + ")");
		String sNewDir = dDialog.open();

		if (sNewDir == null){
			return;
		}

		File newDir = FileUtil.newFile(sNewDir).getAbsoluteFile();

		if ( !newDir.isDirectory()){

			if ( newDir.exists()){

				Debug.out( "new dir isn't a dir!" );

				return;

			}else if ( !newDir.mkdirs()){

				Debug.out( "Failed to create '" + newDir + "'" );

				return;
			}
		}

		setTopLevelFolder( newDir, false );
	}
}