Eclipse plugin-Control closing of editor - eclipse-plugin

What I am cunrrently doing is while closing the editor in doSave method I check for a condition If it is satisfied I allow super.doSave() be called else I display a dialog box displaying the error message.
Now I want to instead ask user again if he want to save it again and if he says yes he could save the wrong file or say no to edit it but in either case editor should not close.
However currently after the error it closes.

If your editor part implements ISaveablePart2 Eclipse will call the method:
public int promptToSaveOnClose();
to prompt for saving when closing. You can respond with ISaveablePart2.CANCEL to cancel the close, ISaveablePart2.YES to continue the save (by calling doSave), ISaveablePart2.NO to skip the save, or ISaveablePart2.DEFAULT to use the normal behavior.

Related

VBA: Before Save Event - Suspend Running Until User Confirms Save As

I only want my code to run if the workbook is going to be saved. At present, if Save As is selected, the code will run as soon as the user attempts to browse for a file/location. The problem is they can still cancel the save.
Alternatively, I want to be able to run some other code if the user decides to cancel the save. (I don't think the Cancel Boolean in the Before Save event can be used because once the user selects browse, it is assumed the file is being saved)
Maybe the Before Save event cannot be used in this instance but I want to avoid disabling/replacing the Save As functionality if possible.
I was able to handle this using the After Save event - I didn't realise that this could be used if the file wasn't actually saved.

Error Closing a Form Through a User Control

In the program I'm writing, there is just one form. I've made a user control visible and it contains several buttons. One of the buttons is supposed to close the form when clicked. I can't find any way to do this without getting the error: "Cannot access a disposed object. Object name: 'ShapeContainer.'" I'm pretty sure I understand the problem; after the form has been closed, the user control no longer exists, so there's an error when Form.Close() (I've tried Form.Dispose() too) has completed and it tries to go back to the code inside the button click event. Does anyone know how I could accomplish closing the form through this user control's button without getting the error?
Okay I'm pretty new to vb but I think if you get rid of the Form.Dispose() & Form.Close then try Me.Close() as you are referring to the current Form that the button control is located on.
You Should have got this error:
(Error 1 'NameSpace_.Form1' cannot refer to itself through its default instance; use 'Me' instead.)

Is it possible to have an extension library dialog box within a repeat control?

I'm running with an 8.5.3 UP1 server and I have a need to have many dialog boxes (for confirmation purposes) for a whole bunch of "action buttons" on an xpage. The code for these dialog boxes is almost exactly the same with the exception of the confirmation message being different and the client-side JS function they are calling if the Yes button is selected.
Since I really hate repeating code over and over, I was wondering if it is at all possible to put a xe:dialog control within a repeat control and specify the message and function call from an array of values? I know I can't compute the ID of the dialog control and without that I'm not sure how I would reference the dialog to open and close it.
Any ideas? Thanks
Yes, this is possible.
Make sure that you specify that the dialog box's property for keepComponents is set to False. You don;t have to do anything special for opening or closing the dialog box, just use whatever ID you give the dialog box in you client-side action to open the dialog box in the repeat such as XSP.openDialog('#{id:myDialog}')
The XPages renderer will automatically calculate the correct ID names for you.

Unable to handle confrimation box with selenium RC

i am trying to press the ok button from a confirmation box like this (i added Thread.spleep so i checked the button is pressed and the confirmation box is shown)
selenium.chooseOkOnNextConfirmation();
selenium.click("xpath=//a[contains(#href,'123')]");
assertTrue(selenium.getConfirmation().equalsIgnoreCase("123"));
but i get this
com.thoughtworks.selenium.SeleniumException: ERROR: There were no confirmations
at com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:97)
at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:91)
at com.thoughtworks.selenium.HttpCommandProcessor.getString(HttpCommandProcessor.java:262)
at com.thoughtworks.selenium.DefaultSelenium.getConfirmation(DefaultSelenium.java:429)
Thx for your help.
I got the same error with the code
selenium.chooseCancelOnNextConfirmation();//点击cancel按钮
selenium.click("link=Delete");
selenium.getConfirmation();
Finally I find the reason is that the developer used the jconfirm function of jquery instead of window.confirm, and the jconfirm function is override with div.
Finally I used assertTrue(selenium.isElementPresent("id=popup_container")).
from this information it is hard to say exactly. but i will give you some info which will help you
java script generates 3 types of pop-up windows
1) Alerts
2)Confirmations
3)Prompts
your case, i guess
1) may be the statement selenium.click() you used, is not triggering the confirmation box
OR
2) if it is triggering, then it may not be the Confirmation box.it could be any one of the other 2 boxes
so, you must make sure manually what type of pop-up window it is and call the statements accordingly.
ex : Confirmation window : conatins OK and Cancel buttons
Alert window : contains only OK button
Prompt window : contains Textbox and OK and Cancel buttons
so check and use that commands respectively
if it is not the above case please the HTML code also

Eclipse RCP : How to show message dialog after editor loads?

I am opening an editor from a view on click of a treenode. Now, when editor loads and controls are displayed to the user, I want to display a warning message dialog to the user based on certain values present on the editor.
I tried by putting the warning dialog at the end of createPartControl method of the editor. Dialog appears on double cliking the treenode as per the required functionality. But, the problem is that when the dialog appears, the controls on the editor are not yet visible. It's only when I close the dialog the editor controls are shown.
I want it to happen the other way around. i.e. The editor controls to show up first and then the warning dialog should appear. What changes should I do to achieve this effect?
You may want to call that MessageDialog in an asynchronous way, to leave the Editor the opportunity to complete itself, as suggested in this message.
show your warning dialog in an asyncExec() runnable would ensure that the editor's initialization all happens in the correct sequence.
So, something like (not tested) this code might do the trick:
getSite().getShell().getDisplay().asyncExec
(new Runnable() {
public void run() {
MessageDialog.openWarning(getSite().getShell(),"wrong","no)
}
});
}
Some other examples in this MapEditor class, where a MessageDialog is displayed through an asyncExec which waits for the result:
PlatformGIS.syncInDisplayThread