Appropriate object for typical window in Eclipse - java

What object type (eg. JFace, Shell, ApplicationWindow) should I use to create my own window?
In my plugin, this window will have three 'panels', lots of components and what' s most important I want it to be on top, till it's closed - like any other window in Eclipse, so that user can' t do anything else in IDE till he close the window.
The window will be launched after clicking the icon in Eclipse's menu.

If you mean something like the Eclipse 'Find/Replace' dialog which does not block the main window use a JFace Dialog (org.eclipse.jface.dialogs.Dialog).
Set the dialog to be modeless and turn off 'block on open'.
This is what the Find/Replace dialog uses:
public FindReplaceDialog(Shell parentShell) {
super(parentShell);
// .... other code ...
setShellStyle(getShellStyle() ^ SWT.APPLICATION_MODAL | SWT.MODELESS);
setBlockOnOpen(false);
}

Add a command following tutorial at : http://www.vogella.com/tutorials/EclipseCommands/article.html
Create a handler for the command that opens a swt widget Dialog that is modal. ( use SWT.APPLICATION_MODAL ) populate the dialog with composites that you need.

Related

Is there any alternative for setWindowAnimations(Android) in Harmony OS?

I am developing a Harmony application and I want to animate the Dialog window
this code is from android and this type of animation I want to add
Window dialogWindow = dialog.getWindow();
dialogWindow.setWindowAnimations(R.style.CustomDialogAnimation);
// properties that needs to be attached to Dialog window
duration="75"
fromXScale="0"
fromYScale="0"
toXScale="1"
toYScale="1"
I didn't find anything matching documentation like setWindowAnimations.
I tried writing this code but hit a dead end after getting the dialog window. How to add animation properties to this dialog window.
CommonDialog commonDialog = new CommonDialog(getContext);
Window dialogWindow = commonDialog.getWindow();
Is there any other way to code this?
According to the team, HarmonyOS does not currently support to add animation properties to dialog window. Please stay tuned on HarmonyOS official websites.

Java Swing Dialog Window focus

In my application I have a main window and a utility popup dialog that is shown when the user clicks on a menu item. My issue is that if another program (say firefox) is opened over the java application, this obviously hides the java application. This is OK - but when the user then clicks on my java application again, only the main window is shown - the utility popup dialog is still hidden under firefox. I would like to design it such that when the user interacts with the main window in any way the utility popup dialog is also brought to the front.
I've tried adding a MouseInputListener to the main frame to bring the utility dialog to the front but this also transfers focus to it, which I don't want.
private MouseInputAdapter onWindowClick = new MouseInputAdapter() {
#Override
public void mousePressed(MouseEvent e) {
if (scheduleDialog != null)
scheduleDialog.toFront(); // the utility dialog
}
};
the utility popup dialog is still hidden
When the dialog is created you need to specify the main window as the owner of the dialog.
Then when you click on the icon for the window, the dialog will display as well.
Read the JDialog API for the proper constructor to use.

displaying a Message using SWT

I am trying to a display message when i will push save button saying that the content got saved using SWT. Can anyone please help me.
Note: I am not using Jface, Shell, Display. I am using a Composite.
Actually, you are using a Display and a base Shell. But these are hidden behind your Eclipse RCP app. I'm guessing you are creating your message dialog in the createContents(Composite) method of a ViewPart, correct?
You can access the Display with Display.getCurrent() anywhere in your code, and you can get the active Shell with parent.getActiveShell().
If you don't want to use JFace, use the MessageBox widget from SWT.
MessageBox box = new MessageBox(parent.getActiveShell(), SWT.CANCEL | SWT.OK);
box.setText("Title");
box.setMessage("This will be the message");
box.open(); // Call this on button pressed. Returns SWT.OK or SWT.CANCEL
If you want specific features for the MessageBox, you can either ask me in a comment, or check out these 18 Java code examples.
Alternatively you can use as below
MessageBox box = new MessageBox(comp.getShell(), SWT.CANCEL | SWT.OK);
Where comp is Composite.

Eclipse editor - detect tab switch on another document

I have an Eclipse Editor plugin associated with .xxx filetype, how can I detect when the user switches from a document to another?
I mean when a user switches from a tab with graph1.xxx to another opened tab with graph2.xxx
I would add an IPartListener (or IPartListener2) event listener to the PartService of the Active Workbench Window, and listen for the various changes. Something similar to the following code could be used (if you register the listener inside your editor code, you should get the workbench window through the inherited methods):
Workbench.getInstance().getActiveWorkbenchWindow()
.getPartService().addPartListener(new IPartListener2() { ... }
Be careful, that both Editors and Views are parts, so some notification will be unnecessary for your job.

How do I open a new workbench window (with its own WorkbenchWindowAdvisor) from an existing workbench window?

I have a RCP applicaton from which I need to show a GEF Editor in a modal "dialog". But since the editor framework seems to be tightly coupled to the use of a workbench window etc I need to find a why to open a new workbench window (with its own WorkbenchWindowAdvisor etc) so that I can open my GEF editor within this workbench window. Once I get this workbenchWindow opened I will set the style of the WorkbenchWindow's shell to be application modal.
I have done this in a customer project using the following components:
A static class with a method openNewWindow(String type, ...). This is the method you call to open a new window. The type argument specifies the wanted type of window.
The class looks up the specified type via a new extension point to get an ILocalWorkbenchWindowAdvisor and the initial perspective ID.
It then saves the information in global variables and calls IWorkbench.openWorkbenchWindow(perspectiveID, ...)
In ApplicationWorkbenchAdvisor.createWorkbenchWindowAdvisor(...) a new advisor is create based on the saved ILocalWorkbenchWindowAdvisor - the returned advisor basically delegates all the postWindowCreate(...), etc to the same methods in ILocalWorkbenchWindowAdvisor...
If no ILocalWorkbenchWindowAdvisor is saved - which is the case for the very first window to be opened - the type "mainWindow" is looked up and used...
It works pretty well and let all parts of the project add new windows as needed.
Use the command "org.eclipse.ui.window.newWindow" to open a new window. In your WorkbenchWindowAdvisor.preWindowOpen(), set the shell style on the IWorkbenchWindowConfigurer to be application modal. You can also hide the coolbar, menu and status bars, so it looks more like a dialog than a window.

Categories

Resources