Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 278333 Details for
Bug 546558
Shell is not coming to top after maximizing and minimizing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Clean Application.java file with the logic
Application.java (text/plain), 5.57 KB, created by
Valerija Miklausic
on 2019-04-18 08:19:59 EDT
(
hide
)
Description:
Clean Application.java file with the logic
Filename:
MIME Type:
Creator:
Valerija Miklausic
Created:
2019-04-18 08:19:59 EDT
Size:
5.57 KB
patch
obsolete
>package reprorapstuck; > >import java.util.Random; > >import org.eclipse.equinox.app.IApplication; >import org.eclipse.equinox.app.IApplicationContext; >import org.eclipse.swt.SWT; >import org.eclipse.swt.events.ShellAdapter; >import org.eclipse.swt.events.ShellEvent; >import org.eclipse.swt.graphics.Point; >import org.eclipse.swt.graphics.Rectangle; >import org.eclipse.swt.layout.FillLayout; >import org.eclipse.swt.widgets.Button; >import org.eclipse.swt.widgets.Display; >import org.eclipse.swt.widgets.Event; >import org.eclipse.swt.widgets.Label; >import org.eclipse.swt.widgets.Listener; >import org.eclipse.swt.widgets.Menu; >import org.eclipse.swt.widgets.MenuItem; >import org.eclipse.swt.widgets.Shell; >import org.eclipse.swt.widgets.Text; >import org.eclipse.swt.widgets.Tree; >import org.eclipse.swt.widgets.TreeItem; >import org.eclipse.ui.IWorkbench; >import org.eclipse.ui.PlatformUI; > >public class Application implements IApplication { > > private static int shellX = 600; > private static int shellY = 600; > > private static int xPosition = 30; > private static int yPosition = 50; > private Shell mainWindowShell; > > @Override > public Object start(IApplicationContext context) throws Exception { > Display display = PlatformUI.createDisplay(); > mainWindowShell = new Shell(display); > mainWindowShell.setSize(shellX, shellY); > mainWindowShell.setText("controller shell"); > addMainWindowControlButtons(display, mainWindowShell); > mainWindowShell.open(); > while (!mainWindowShell.isDisposed()) { > if (!display.readAndDispatch()) > display.sleep(); > } > // --------------------------------- > > try { > int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor()); > if (returnCode == PlatformUI.RETURN_RESTART) > return IApplication.EXIT_RESTART; > else > return IApplication.EXIT_OK; > } finally { > display.dispose(); > } > > } > > private void addMainWindowControlButtons(Display display, Shell shell) { > Label openFileLabel = new Label(shell, SWT.NONE); > openFileLabel.setSize(75, 20); > openFileLabel.setLocation(xPosition, yPosition); > openFileLabel.setText("open file: "); > > xPosition += 100; > > Button openFileButton = new Button(shell, SWT.PUSH); > openFileButton.setLocation(xPosition, yPosition); > openFileButton.setSize(75, 20); > openFileButton.setText("open"); > > xPosition -= 100; > yPosition += 100; > > Label showFilesLabel = new Label(shell, SWT.NONE); > showFilesLabel.setText("show files: "); > showFilesLabel.setLocation(xPosition, yPosition); > showFilesLabel.setSize(75, 20); > > xPosition += 100; > > Button showFilesButton = new Button(shell, SWT.PUSH); > showFilesButton.setText("show files"); > showFilesButton.setLocation(xPosition, yPosition); > showFilesButton.setSize(75, 20); > > xPosition = 30; > yPosition = 50; > > openFileButton.addListener(SWT.Selection, new Listener() { > @Override > public void handleEvent(Event event) { > openNewShell(event.display); > } > > }); > > showFilesButton.addListener(SWT.Selection, new Listener() { > > @Override > public void handleEvent(Event event) { > createMenu(event.display, shell); > > } > > private void createMenu(Display display, Shell shell) { > Menu menu = new Menu(shell, SWT.POP_UP); > > Rectangle bounds = showFilesButton.getBounds(); > Point point = showFilesButton.getParent().toDisplay(bounds.x, bounds.y + bounds.height); > > menu.setLocation(point); > menu.setVisible(true); > > createDynamicalTree(shell, menu); > > shell.setMenu(menu); > } > > private void createDynamicalTree(Shell shell, Menu menu) { > Shell[] shells = display.getShells(); > for (int i = 0; i < shells.length - 1; i++) { > MenuItem menuItem = new MenuItem(menu, SWT.PUSH); > menuItem.setText(shells[i].getText()); > final Shell currentShell = shells[i]; > menuItem.addListener(SWT.Selection, new Listener() { > > @Override > public void handleEvent(Event event) { > forceActive(currentShell); > } > > }); > > } > menu.setEnabled(true); > } > > }); > > } > > private void openNewShell(Display display) { > Shell newShell = new Shell(display); > newShell.setSize(600, 600); > newShell.setLocation(xPosition, yPosition); > int shellNumber = display.getShells().length; > newShell.setText("Shell " + shellNumber); > > newShell.setLayout(new FillLayout()); > > Text tf = new Text(newShell, SWT.BORDER); > tf.setText("Text field in Shell: " + shellNumber); > newShell.pack(); > newShell.addShellListener(new ShellAdapter() { > > @Override > public void shellClosed(ShellEvent e) { > super.shellClosed(e); > Shell[] shells = e.display.getShells(); > for (int n = shells.length - 1; n >= 0; n--) { > Shell shell = shells[n]; > if (shell != e.widget && shell != mainWindowShell) { > bringToTop(shell); > System.out.println(String.format("Shell with title '%s' brought to top.", shell.getText())); > break; > } > } > } > }); > newShell.open(); > } > > @Override > public void stop() { > if (!PlatformUI.isWorkbenchRunning()) > return; > final IWorkbench workbench = PlatformUI.getWorkbench(); > final Display display = workbench.getDisplay(); > display.syncExec(new Runnable() { > public void run() { > if (!display.isDisposed()) > workbench.close(); > } > }); > > } > > private static void forceActive(Shell shell) { > shell.setMinimized(false); > shell.setFocus(); > shell.forceActive(); > } > > private static void bringToTop(Shell shell) { > if (shell.getMinimized()) { > shell.setMinimized(false); > } > shell.forceActive(); > } > >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 546558
: 278333