Canceling windowDeactivated event

I'm writing a plug-in for ImageJ and operate on two images that are in seperate windows.
The plug-in places pairs of markers on an image. I have implemented the WindowListener interface to capture the windowDeactivated event which checks if a marker pair is complete and if it's not asks the user if the placement should be cancelled.
The event handler gets called as it should and I can display the dialog box and all but when a user wants to resume placing markers and not switch to the other window the event should be cancelled and focus reset on the original window.
Resetting focus to the original window isn't that much of a problem but I can't cancel the event. After resetting focus the focus is then reset to the other window which I obviously don't want.
I'm a little out of idea's since the consume method isn't available and I really don't know how to do this otherwise.

Hi,
I think your problem is the following: The event is only sort of a notification-event - this means it is not a signal that something will happen but a notification that something has happend (in your case the window lost the state of being the active window). So there is no need (it makes no sense) to cnacel or consume this event - this event is no reason for further system-actions like a key-event or a mouse-event.
Your problem with re-gaining the focus has - in my opinion - the following reason: The system is at the moment when you get this event in the state that your window lost the focus (or the active-state) but the window which should gain the focus (from the point of view of the system) still hasn't got the focus. So after the actions of your listener are performed one of the systemactions will be to give the focus to the other window.
That's the reason why setting the focus direct in your listener can't work. Normally it would help if you use the invokeLater-technique. This will guarantee that your work is done after(!) all the work the system has to do in this moment.
HTH and greetings from
Holger

Similar Messages

  • How to cancel the event in Item Adding and display javascript message and prevent the page from redirecting to the SharePoint Error Page?

    How to cancel the event in Item Adding without going to the SharePoint Error Page?
    Prevent duplicate item in a SharePoint List
    The following Event Handler code will prevent users from creating duplicate value in "Title" field.
    ItemAdding Event Handler
    public override void ItemAdding(SPItemEventProperties properties)
    base.ItemAdding(properties);
    if (properties.ListTitle.Equals("My List"))
    try
    using(SPSite thisSite = new SPSite(properties.WebUrl))
    SPWeb thisWeb = thisSite.OpenWeb();
    SPList list = thisWeb.Lists[properties.ListId];
    SPQuery query = new SPQuery();
    query.Query = @"<Where><Eq><FieldRef Name='Title' /><Value Type='Text'>" + properties.AfterProperties["Title"] + "</Value></Eq></Where>";
    SPListItemCollection listItem = list.GetItems(query);
    if (listItem.Count > 0)
    properties.Cancel = true;
    properties.ErrorMessage = "Item with this Name already exists. Please create a unique Name.";
    catch (Exception ex)
    PortalLog.LogString("Error occured in event ItemAdding(SPItemEventProperties properties)() @ AAA.BBB.PreventDuplicateItem class. Exception Message:" + ex.Message.ToString());
    throw new SPException("An error occured while processing the My List Feature. Please contact your Portal Administrator");
    Feature.xml
    <?xml version="1.0" encoding="utf-8"?>
    <Feature Id="1c2100ca-bad5-41f5-9707-7bf4edc08383"
    Title="Prevents Duplicate Item"
    Description="Prevents duplicate Name in the "My List" List"
    Version="12.0.0.0"
    Hidden="FALSE"
    Scope="Web"
    DefaultResourceFile="core"
    xmlns="http://schemas.microsoft.com/sharepoint/">
    <ElementManifests>
    <ElementManifest Location="elements.xml"/>
    </ElementManifests>
    </Feature>
    Element.xml
    <?xml version="1.0" encoding="utf-8" ?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <Receivers ListTemplateId="100">
    <Receiver>
    <Name>AddingEventHandler</Name>
    <Type>ItemAdding</Type>
    <SequenceNumber>10000</SequenceNumber>
    <Assembly>AAA.BBB, Version=1.0.0.0, Culture=neutral, PublicKeyToken=8003cf0cbff32406</Assembly>
    <Class>AAA.BBB.PreventDuplicateItem</Class>
    <Data></Data>
    <Filter></Filter>
    </Receiver>
    </Receivers>
    </Elements>
    Below link explains adding the list events.
    http://www.dotnetspark.com/kb/1369-step-by-step-guide-to-list-events-handling.aspx
    Reference link:
    http://msdn.microsoft.com/en-us/library/ms437502(v=office.12).aspx
    http://msdn.microsoft.com/en-us/library/ff713710(v=office.12).aspx
    Amalaraja Fernando,
    SharePoint Architect
    Please Mark As Answer if my post solves your problem or Vote As Helpful if a post has been helpful for you. This post is provided "AS IS" with no warrenties and confers no rights.

    Recommended way for binding the list event handler to the list instance is through feature receivers.
    You need to create a feature file like the below sample
    <?xmlversion="1.0"encoding="utf-8"?>
    <Feature xmlns="http://schemas.microsoft.com/sharepoint/"
    Id="{20FF80BB-83D9-41bc-8FFA-E589067AF783}"
    Title="Installs MyFeatureReceiver"
    Description="Installs MyFeatureReceiver" Hidden="False" Version="1.0.0.0" Scope="Site"
    ReceiverClass="ClassLibrary1.MyFeatureReceiver"
    ReceiverAssembly="ClassLibrary1, Version=1.0.0.0, Culture=neutral,
    PublicKeyToken=6c5894e55cb0f391">
    </Feature>For registering/binding the list event handler to the list instance, use the below sample codeusing System;
    using Microsoft.SharePoint;
    namespace ClassLibrary1
        public class MyFeatureReceiver: SPFeatureReceiver
            public override void FeatureActivated(SPFeatureReceiverProperties properties)
                SPSite siteCollection = properties.Feature.Parent as SPSite;
                SPWeb site = siteCollection.AllWebs["Docs"];
                SPList list = site.Lists["MyList"];
                SPEventReceiverDefinition rd = list.EventReceivers.Add();
                rd.Name = "My Event Receiver";
                rd.Class = "ClassLibrary1.MyListEventReceiver1";
                rd.Assembly = "ClassLibrary1, Version=1.0.0.0, Culture=neutral,
                    PublicKeyToken=6c5894e55cb0f391";
                rd.Data = "My Event Receiver data";
                rd.Type = SPEventReceiverType.FieldAdding;
                rd.Update();
            public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
                SPSite sitecollection = properties.Feature.Parent as SPSite;
                SPWeb site = sitecollection.AllWebs["Docs"];
                SPList list = site.Lists["MyList"];
                foreach (SPEventReceiverDefinition rd in list.EventReceivers)
                    if (rd.Name == "My Event Receiver")
                        rd.Delete();
            public override void FeatureInstalled(SPFeatureReceiverProperties properties)
            public override void FeatureUninstalling(SPFeatureReceiverProperties properties)
    }Reference link: http://msdn.microsoft.com/en-us/library/ff713710(v=office.12).aspxOther ways of registering the list event handlers to the List instance are through code, stsadm commands and content types.
    Amalaraja Fernando,
    SharePoint Architect
    Please Mark As Answer if my post solves your problem or Vote As Helpful if a post has been helpful for you. This post is provided "AS IS" with no warrenties and confers no rights.

  • Cancelled (detached) events showing on shared calendar - help!

    I can't figure out how to remove cancelled events from showing in iCal on a shared calendar. We use Zimbra for mail, etc. I subscribe to my boss' calendar and it is showing his cancelled (detached) events. They do not show in his iCal on his computer and they don't show in Zimbra. They only show in my iCal. I've looking in every preference I can find....I've tried un-subscribing to the calendar and then re-subscribing. Nothing seems to work. Any ideas??

    Consequently........it only seems to happen with recurring events we migrated from Microsoft Exchange. I cannot replicate it with a new appointment. I would still, however, like to be able to remove ones that are currently here. Since, they are recurring, they do show in the future, as well.

  • Why iCal cancel of event edits issue is still not fixed after over 2 years?

    Why iCal "cancel of event edits" issue is still not fixed after over 2 years?
    I have been in the software engineering industry for over 14 years, but I have never seen a large corporation being so slow at addressing major issues like these.
    What would it take for Apple to start working on this issue?

    Yup. This is fully ridiculous that you can't cancel your updates once you start. I love the tool but this is on pretty significant issue.
    Sometimes I accidentally move a mtg or make some edit while viewing and you can't back you!!
    If you feel the same way, you should post a note here:
    http://www.apple.com/feedback/ical.html
    Message was edited by: SteveMc10123

  • Cancel selection event in chart

    Hi all,
    Is it possible to cancel selection event on first bar in column chart when chart display at first time?
    Thanks,
    Ola

    This solution worked for me:  Visual Composer Tips and Tricks
    The tip applies to disabling the first select from a table, but it works for charts too.
    Hope that helps.
    Karen Waller

  • Can't fire cancelled editing event in a JTable

    Hi,
    I have a JTable and I'm listening to it's cell editor events editing canceled and editing stopped.
    When editing is stopped i verify the value of the cell and if it's not valid i throw a warning message, then select I the cell and turn its editing on in order to give user a new chance.
    It works fine, but, when I enter an invalid value onto a cell and press ok, then the warning pops up (as desired), i accept it and then I pres the Esc key, it just places the last value for that cell, which was the same invalid string (due to editing was stopped and I turned it on again), not even the "editing is canceled" event is called in order to place the last valid value for that cell.
    Don't know what I'm doing wrong since "editing stopped" event is working fine.
    Does anyone know how to fire the "editing canceled" event when Esc key is pressed?
    Thanks in advance!
    Edited by: raveko on Jun 5, 2008 7:05 AM

    I found the following way to force cancel editing event (or just treat the event here)
    Do you know a better way?
    Thanks!
    // Handle escape key on a JTable
    Action escapeAction2 = new AbstractAction()
    public void actionPerformed(ActionEvent e)
    if (table.isEditing())
    int row = table.getEditingRow();
    int col = table.getEditingColumn();
    table.getCellEditor(row, col).cancelCellEditing();
    KeyStroke escape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);
    table.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(escape, "ESCAPE");
    table.getActionMap().put("ESCAPE", escapeAction2);

  • InputListofValue PopUp window CANCEL button event capture ?

    HI All ,
    Jdeveloper version 11.X.6.
    i have explained the outline of issue below:
    User enter some data on InpuLIstOfValue text field and click on the maginfied Glass, the pop opens and selects some data and click 'OK' ,it will display appropriately on below fields.
    but if user enters the wrong data on InpuLIstOfValue text field and clicks on maginfier Glass,no results found on the popup window, so upon click of "CANCEL" button on popup window ,
    is there any way to remove the old data on InpuLIstOfValue Filed ?
    Basicaly i am looking for the capturing the CANCEL button event on the popUpwindow ,based on event status .
    PLase let us know if any hints ?
    Thanks

    Step by step:
    1. Create the converter class:
    package view.converters;
    import java.util.Collection;
    import java.util.Collections;
    import javax.faces.component.UIComponent;
    import javax.faces.context.FacesContext;
    import javax.faces.convert.Converter;
    import org.apache.myfaces.trinidad.convert.ClientConverter;
    import org.apache.commons.lang.StringUtils;
    public class LOVConverter implements Converter, ClientConverter {
      public Object getAsObject(FacesContext facesContext, UIComponent uiComponent, String value) {
        if (StringUtils.isBlank(value)) {
          // cancel event was triggered, so do something
        return value; // if value is not an instance of String you need to convert it to its primary type (Number, Date, String, etc)
      public String getAsString(FacesContext facesContext, UIComponent uiComponent, Object value)
        if (value == null || /* value is empty in its primary type */) {
          // cancel event was triggered, so do something
        return value.toString();
      public String getClientLibrarySource(FacesContext facesContext)
        return null;
      public Collection<String> getClientImportNames()
        return Collections.emptySet();
      public String getClientScript(FacesContext facesContext, UIComponent uiComponent)
        return null;
      public String getClientConversion(FacesContext facesContext, UIComponent uiComponent)
        return null;
    }2. Declare the converter in faces-config.xml:
    <converter>
      <converter-id>LOVConverter</converter-id>
      <converter-class>view.converters.LOVConverter</converter-class>
    </converter>3. Your inputListOfValues should look like this (see the property converter="LOVConverter"):
    <af:inputListOfValues popupTitle="Search"
                          value="#{row.bindings.DepartmentId.inputValue}"
                          model="#{row.bindings.DepartmentId.listOfValuesModel}"
                          required="#{bindings.EmployeesView1.hints.DepartmentId.mandatory}"
                          columns="#{bindings.EmployeesView1.hints.DepartmentId.displayWidth}"
                          shortDesc="#{bindings.EmployeesView1.hints.DepartmentId.tooltip}"
                          converter="LOVConverter"
                          id="ilov1">After that, when the user clicks the Cancel button, both methods (getAsObject and getAsString) should be invoked, and then you would be able to reset the component value (using uiComponent parameter).
    AP

  • How do I cancel an event without deleting it in my calendar

    iCal shows sybols "A line through an event’s name indicates that it’s canceled." -- How do I do that?

    iCal shows sybols "A line through an event’s name indicates that it’s canceled." -- How do I do that?

  • How to cancel resource event?

    Hi,
    I have configured the subscription service in my repository just for "on creation" event. I would like to know if is possible cancel the subcription when some kinds of documents are created in this repository. I have created a property metadata that the publisher checks when he or she wants to send the notificacions to the recipients.
    Any idea?.
    Best Regards
    Manuel.

    Manuel,
          If you don't want to write a code, you could use taxonomies. I mean, when a user upload a new document set the property metadata created by you. This metadata means if you want o not send a notifications about this event.
    Using taxonomies, you need to create an index and this one has assign as data source your repository, you can create a new folder and classify documents by your metadata. 
    Then, the system index and classify them documents whose metadata means sent notification.
    Then you subscribe your end-users to this folder in taxonomies repository. Don't forget to enable repository services.
    Patricio.

  • Cancel dialog event code

    hi, if i click on the cancel button in the open or save dialog, get an error of an empty string, so how do i fix that, did try googling it, but found a lot of rather clumsy, examples, or real complex, but nothing i could see for my specific problem. any
    one point me to some good articles. thanks.
    http://startrekcafe.stevesdomain.net http://groups.yahoo.com/groups/JawsOz

    "when i try the frmData.disposed event"
    I have no idea what you're talking about here.  Dispose has nothing to do with any of this.
    All forms support ShowDialog and the returning of DialogResult. It is built into the framework.  For any common dialog (including open/save) the approach is pretty standard.
    var dlg = new OpenFileDialog();
    //Init dialog settings
    //Show the dialog
    if (dlg.ShowDialog() != DialogResult.OK)
       //User canceled so abort out
    //Open file or whatever other work you wanted to do
    If this doesn't answer your question then please provide the exact block of code causing problems and what you expecting to do.

  • How can I cancel an event update without emailing attendees?

    Hi all,
    I'm using iCal 4.04 on OS 10.6.8, and when I hit "Edit" on an event with attendees, there is no "Cancel" button. Your only two choices are "update" and if you click off the area, "edit" or "send." This happens even if there are no updates to the event (lets say you type a note, then delete the note, you're still forced to send an update).
    This is very odd behavior for OSX and something that I'm surprised to see. People make mistakes, they correct mistakes, and shouldn't have to explain to a 30 person attendee list "oops, sorry there are no edits, I just couldn't cancel this behavior."
    If someone knows of a work-around, please let me know.
    Thanks!

    I found a solution: Upgrade to Lion
    There's now a "revert" button that's long overdue. Thanks Apple!

  • Servlet cancel query event

    Hi all,
    I wrote a servlet which queries a database and returs the results to the calling client. Now I want to enable the client to cancel long-running queries. Is it possible to catch an event in the servlet e.g. if the client-user hits a "cancel" button?
    Thank you!
    Benni

    I doubt it. Once the database gets the query, it begins processing it. I dont think anything in your server side JDBC will be sent to interrupt it. Even if it did, what is the user to do next? He can only retry the same query.
    How about instead looking at your sql statement again and seeing if you can:
    A: add a filter to the JSP page that allows the user to limit the returned amount of data. Example: If user enters 'B' in a textfield, then the sql becomes: "select * from person where lastName like '%B'.
    Most users only want to see at most 30 or so rows returned, not 10000.
    B: Optomize your sql statement - such as provide indexes on the database side. Also, only return those database table fields that the user needs, not all fields.

  • Cancelling following events on error

    HI,
    I have a input field where the user can enter some values. After he made some changes, I fire an OnChangeEvent, where I check the entries. On the same view there is also a button, where the user can order items. When the user change a value and clicks on the button, the events are fired. First the OnChangeEvent und then the event of the button.
    When an error occurs in the onChangeEvent, the event of the button should be ignored.
    I tried wdComponentAPI.getMessageManager().cancelNavigation(); but this didn't work.
    I also tried to use a context anttribute to indicate the error, but the problem is, that when the user just change a value without clicking a button, and an error occur, than I the button won't work because in the onChangeEvent the error flag was set.
    I hope someone understands my weird explanation and I hope someone has an idea to solve my problem.
    Best regareds,
    Peter

    Hi Peter,
    As per my understanding in your case wdComponentAPI.getMessageManager().cancelNavigation() should work. You need to put this statement in your component controller in wdDoBeforeNavigation method.
    Can you share your code of onChangeEvent and on action of your button and the code in wdDoBeforeNavigation ?
    Cheers
    Abhinav

  • Cancel a Event and it's further execution from a Subroutine called from that event.

    First I will explain my requirement:
    Consider the following snippet.
    Private Sub SomeEvent(Byval sender as Object) Handles SomeControl.SomeEvent
    --Do Something_1
    --Do Something_2
    --Do Something_3
    call A()
    --Do Something_4
    --Do Something_5
    --Do Something_6
    End Sub
    Private Sub Procedure_A ()
    --Do Something_1
    --Do Something_2
    --Do Something_3
    call B()
    --Do Something_4
    --Do Something_5
    --Do Something_6
    End Sub
    Private Sub Procedure_B ()
    --Do Something_1
    --Do Something_2
    --Do Something_3
    'Exception Ocurs...Here
    --Do Something_4
    --Do Something_5
    --Do Something_6
    End Sub
    In the above exception, if the exception occurs at the said location in Procedure_B then, 
    1. Remaining Statements in Procedure_B should not execute.
    2. Remaining Statements in Procedure_A should not execute.
    3. Remaining Statements in SomeEvent should not execute.
    Please not that:
    I know this can be handled by using Try..Catch in every Subroutine and Raise an exception from there. But it cannot be implemented due to some reason.
    The solution I am looking for is
    1. To somehow cancel the ProcessThread the SomeEvent has started.
    Or
    2. If I could programatically Set Next Statement

    I think that you only need Try-Catch in
    SomeEvent, not in every procedure:
        --Do Something_1
        --Do Something_2
        --Do Something_3
        Try
            Call A()
            --Do Something_4
            --Do Something_5
            --Do Something_6
        Catch
        End Try
    It is also possible to distinguish specific exceptions.
    It is not clear why you cannot use Try-Catch. Then use
    On Error instead:
        --Do Something_1
        --Do Something_2
        --Do Something_3
        On Error GoTo Error1
        Call A()
         --Do Something_4
         --Do Something_5
         --Do Something_6
        Return
    Error1:

  • JDialog Ok/Cancel button events

    Dear Java gurus,
    I have something that's been bugging me for days. Now, maybe it's really obvious but my cold has bunged up my head too much to think clearly. Anyway, I thought I'd pass it this way for expert opinion..
    I have a class that extends JDialog, with various textboxes, comboboxes etc. It also has the usual OK + Cancel buttons. The only thing left to implement is something like this:
    MyCustomDialog d = new MyCustomDialog();
    int returnVal = d.showDialog();
    This is similar to most of the dialogs provided with Swing, where the return value is a static field something along the lines of 0 == OK button pressed, 1 == Cancel.
    This allows me to only start "getting" the values from the dialog only if the user selects ok. The problem is, I can't see how to accomplish this. I've been looking at the source for JFileChooser and JColorChooser, but they are more complicated than I can follow. (I am relatively novice when it comes to Swing) I promise, I have been looking on the net for examples, but I've had no luck. Maybe because any searching for JDialog tends to bring back simple examples of the supplied Swing dialogs.
    So, any suggestions?
    TIA

    arooaroo wrote: Shame, because I thought you were on to something.
    I was. Trust me.
    Look at the signature for JOptionPane.showConfirmDialog(). This is the simplest version, but the others look like this and then some:
    static int showConfirmDialog(Component parentComponent, Object message)
    Note that the message parameter is of type  object. This means you can theoretically pass any type of object. A component is an object. Therefore, you can pass a JPanel as the message parameter.
    Look at this quote from the JOptionPane description in the API:
    message
        A descriptive message to be placed in the dialog box. In the most common usage, message is just a String or String constant. However, the type of this parameter is actually Object. Its interpretation depends on its type:
        Object[]
            An array of objects is interpreted as a series of messages (one per object) arranged in a vertical stack. The interpretation is recursive -- each object in the array is interpreted according to its type.
        Component
            The Component is displayed in the dialog.
        Icon
            The Icon is wrapped in a JLabel and displayed in the dialog.
        others
            The object is converted to a String by calling its toString method. The result is wrapped in a JLabel and displayed.
    I was going to suggest the modal option on JDialog, but for some reason I thought it wouldn't work.  I still think using JOptionPane would be easier; that's what it was designed for.
    Dusty

Maybe you are looking for