displaying a Message using SWT - java

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.

Related

setBezelStyle not working on SWT NSButton - java

I'm creating an SWT (ported Mac OSX version) application. I am trying to set a specific button to have the bezel style of "inline". Here is what I want my button to look like on mac.
(screenshotted in storyboard view in xcode)
The code I am using to try to get this inline button:
// created button named "inlineButton" and applied layout to it.
// here is where I set the bezel style and text.
NSButton nsInlineButton = (NSButton) inlineButton.view;
nsSaveButton.setBezelStyle(15); // NSBezelStyleInline is enum 15 for cocoa
this.inlineButton.setText("Inline Button");
And the result:
(screenshotted from my java program)
I have also tried to redraw and relayout the shell and a variety of other methods with no avail.
Is this a bug or am I doing something wrong?
Solved. I just needed to add the SWT style of "FLAT"
this.inlineButton = new Button(this, SWT.FLAT);
NSButton inlineButton = (NSButton) inlineButton.view;
inlineButton.setBezelStyle(15);

Appropriate object for typical window in Eclipse

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.

Appium ios app in JAVA : How to open a keyboard view in appium for ios app

We are automating an iOS app using Appium and JAVA
We stuck at below point
How to open a keyboard view in appium to type in UIAtextbox field as sendkeys of webdriver is not working without it ?
Please help ....
You should not use send_keys on iOS. It is notoriously unreliable. (read more about that here)
Here's my implementation in python:
textfield = driver.find_element_by_class_name('UIATextField')
text = 'ABCDEF'
driver.execute_script("au.getElement('%s').setValue('%s')" % (textfield.id, text))
driver.hide_keyboard('return') # Close the keyboard with the return button
So what you need to do is:
Get the webelement/textfield
On the driver, call ExecuteScript
Pass in the the webelement's id and the value you want to set the textfield to
Optional: Hide the keyboard afterward
To add some clarity:
When you use sendkeys, do the textfield appear clicked?
What is the response from the server regarding the request of the sendkeys action?
Can you show the line where you do the inputing part?
This may be caused by a) Appium doesn't see the UItextbox b) The action is called before the textbox is usable(init phase) c)there is sth completely wrong with your line of code :)
Awaiting your answer

Not Attached, <Window null#winPop>

I have a problem with my code using zk components.
I am trying to make a popup window without zul file but compose it within my java code.
This is the sample of the code of mine
#Listen("onClick = #btnPopUp")public void popUp(){
Window win = new Window();
win.setId("winPop");
/* i compose some rows, label and other component here...*/
win.doModal();
}
When i click the btnPopUp button, i got an error message ERROR org.zkoss - >> org.zkoss.zk.ui.SuspendNotAllowedException: Not attached, <Window null#winPop>
I got a clue to use Executions.createComponents() method. But is this method can really help? because i usually use this method with a zul file for ex: Window win = (Window) Executions.createComponents("myZul",parent, map);
Thanks guys, really appreciate your help
//Sorry for my bad english :(
‘Not attached‘ is ZK's way of saying the component (the ‘Window‘) doesn't have a parent component.
win.setParent(parent);
or
parent.appendChild(win);
I believe this needs to be done before ‘win.doModal()‘ is called.

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