Disable JFace Wizard 'Cancel' button on last page of wizard - java

When the user reaches the very last page of my JFace Wizard, I want to disable the cancel button (since at that time you cannot really 'cancel').
How can that be done?
Update:
This does not relate to my previous question about the cancel button which was related to disabling the wizard dialog entirely while running an async operation and involved a different api.

What you are trying to do isn't good for the users :-) A user should be able to cancel the wizard at any given point of time.
There isn't a direct API. You need to extend WizardDialog for this. Use getButton(IDialogConstants.CANCEL_ID) to get the cancel button. You can do enable/disable on that button.

Related

How can I create a popup menu that allows user to choose a certain elements from a list on Java?

I am writing a Java program to record some events and their status, i.e., done or not. I have implemented the recording and calculations, but I also want to have a button that will open another window that will list the events with a checkbox corresponding to each of them, so I can pick which ones' statuses I will change to done. I have only used Swing libraries so far.
I want this window to contain one event per line, with a checkbox next to the event. Each checkbox should determine whether the status of the even should be changed or not. I had trouble even making such a window open and list the items, let alone put the checkbox.
Note: The design is not too important. This won't be a published project, I will mostly use it for personal work. I can do with buttons instead of checkboxes, where any click changes the status of the event next to it.
Thank you in advance for your valuable responses.

How to implement cancel button in JConfirmDialog

I have a java swing application. This application contains a mainframe window.
When the user clicks the close (X button on top right of window), my application pops up a JOPtionPane Confirm dialog with yes, no and cancel operations. Clicking on yes saves some files and closes the application, No closes the application without saving the results. This all has been implemented and working fine.
Now i need to implement cancel operation which should typically do something like close the ConfirmDialog and keep the application still open (contrary to this yes and no option closes the application)". I need to implement the idea of "application should not be closed upon clicking the cancel button". For any existing example one can consider the closing of excel sheet (after you edit the excel and try closing without saving).
Set the default close operation for the frame to do nothing:
frame.setDefaultCloseOperation( JFrame.DO_NOTHING_ON_CLOSE )
Your windowClosing event handler can then literally just return if the user clicks cancel and the program will continue as if nothing has happened.
If the user clicks yes or no then your code will need to programmatically close the frame.

Get all the events occurred till now in an Application

I need to know the events occurred in my web app, from the time it was loaded. Is there any way to get the events, The reason is I need to store those events is when ever user wants to go directly to result which he got after performing few actions, I can do PostEvent on series of events to reach that particular result, or is there any other way to do the same with out storing events?
Example:
User clicks on button1 -button1 is disabled,
User Click on button2 - button2 is disabled,
User clicks on button3 -button3 is disabled,
User Click on button4 - button4 is disabled,
Now user has performed 4 actions to get all the four button disable.
If user wants to reach the state when 1st 3 buttons I will do PostEvent of clicking 3 buttons for him.
Note Example is not exactly what I need. It's just for explanation purpose.
There's no support for this in GWT, you have to do it yourself. Record every action/event you're interested in, possibly using the command pattern, and log all of them for later replay.
In ZK , you could use Event Interceptor to log all event you need.
http://books.zkoss.org/wiki/ZK_Configuration_Reference/zk.xml/The_listener_Element/The_org.zkoss.zk.ui.util.EventInterceptor_interface

Can you disable the cancel button in a jface wizard?

When the user presses the 'next' button in my jface wizard, it will be communicating with my server asynchronouly.
However this operation cannnot be cancelled, so I want to basically disable the 'Cancel' button temporarily in my jface wizard and also if possible the 'close' button in the title bar.
Is this possible?
pass your long-running code wrapped by IRunnableWithProgress into wizard.getContainer().run(true, false, rwp). Inside your code you will have access to IProgressMonitor, which basically controls the visual progress bar.
How are you communicating with the server? Are you running it inside IWizardContainer.run()? you can pass cancellable = false.

Event handling in modal windows (Java swing)

I'm developing the Java Swing application. I'm quite new to Java, so got some questions. I have a modal window with some set of controls (text fields, buttons etc).
I want to handle click on the button in the parent window. I think the most efficient and accurate way is first to handle it in modal window, then raise some another event from the model form and handle it in the parent form.
Is this approach right and what are the best practices on doing that?
Thanks for your help!
In general, the dialog that contains the button should handle the button click.
However, maybe you can use a JOptionPane. It is designed to return which button was clicked and then you can do custom processing based on the clicked button. Check out the section from the Swing tutorial on How to Make Dialogs for some examples. Also not that you can add a panel to an option pane. In this case you may find the Dialog Focus tip usefull.
I suppose what you want is for the action (or an action listener) of a button in the parent window to process a mouse click on a button (or anything) in the modal dialog.
There are infinite ways to do that. You can pass the action to the modal dialog, pass the button and call doClick(), pass an implementation of an interface that can redirect mouse click (or anything), etc.
Or if instead you want to click the actual button in the parent window when the modal dialog is up, look up the definition of modal.

Categories

Resources