Veto closing of Tab in TabPane

Hi,
I'm showing multiple editors inside a tab-folder and if the user closes a Tab which is dirty I'd like to step in and show a confirmation dialog to the user asking if he'd really like to close the tab and else leave it open. Maybe I'm missing something obvious but it looks like such a feature is not available yet, right?
Tom

I filed http://javafx-jira.kenai.com/browse/RT-24088 and attached a draft implementation

Similar Messages

  • How to restrict closing the tab in tabpane after clicking the close button.

    Hi all,
    Greetings.
    I am implementing a TabPane with different 'user form's in each Tab. And all the tabs are *'closable'*.
    If the user enters some data in the form, and tries to close the tab without saving the form , i need to show a confirm dialogue box that the user should go ahead or not.
    If he clicks cancel, the tab should not close.
    But currently i am searching for a method something like 'setOnClosing' method for tab.
    There is only tab.setOnClosed() method, which will call the event after closing the tab.
    Some thing the code is like below.
    tab.setOnClosed(new EventHandler<javafx.event.Event>() {
         @Override
         public void handle(javafx.event.Event e) {
            // TODO: Actions to be taken on close of tab.
               // Logic to show the confirm dialouge box.
               //  if YES - close the tab
               //  if NO - don't close the tab.
    });But my logic is executing after closing the tab. (ofcourse, as it is on setOnClosed() ;) ). Can anyone tell me how to get control before closing the tab ?
    Thanks in Advance.
    Sai Pradeep Dandem.

    Hi All,
    Finally I managed to get the handler before closing the tab pane. :)
    Though this is a bit weird work around, my requirement is fulfilled at-least.
    Let me explain the workaround I did.
    Tab tab = new Tab(title);
    tab.setClosable(false); // This line of code  makes sure that the “default” close button of the tab is not appeared.
    setClosableButton(tab);Then I am setting the custom close button as a graphic to the label ( Title of the tab), and aligning that graphic position to make an effect, that it is rendered exactly at the position of “Close” button.
    From this Custom Close Button, I am handling the events and if confirmed I am closing the tab manually, by calling the closeTab() method in the TabPaneBehavior class.
    Below is the code that is implemented as per the above logic.
          * Method to set the custom Closable Button to the given tab.
          * @param tab - Tab
         private void setClosableButton(final Tab tab,final boolean closeCheck){
              final StackPane closeBtn = new StackPane(){
                   @Override
                   protected void layoutChildren() {
                        super.layoutChildren();
                        // Setting the orientation of graphic(button) to the right side.
                        ((Label)((LabelSkin)getParent()).getSkinnable()).setStyle("-fx-content-display:right;");
              closeBtn.getStyleClass().setAll(new String[] { "tab-close-button" });
              closeBtn.setStyle("-fx-cursor:hand;");
              closeBtn.setPadding(new Insets(0,7,0,7));
              closeBtn.visibleProperty().bind(tab.selectedProperty());
              final EventHandler<ActionEvent> closeEvent = new EventHandler<ActionEvent>() {
                   @Override
                   public void handle(ActionEvent paramT) {
                        ((TabPaneSkin)TabPaneComponent.this.getSkin()).getBehavior().closeTab(tab);
              // Handler for the close button.
              closeBtn.setOnMouseReleased(new EventHandler<MouseEvent>() {
                   @Override
                   public void handle(MouseEvent paramT) {
                        // My logic to handle the close event or not.
                                    if( logic satisfied){
                             closeEvent.handle(null);
                                    }else{
                                           // Dont close the tab.
              // Showing the close button if the tab is selected.
              tab.selectedProperty().addListener(new ChangeListener<Boolean>() {
                   @Override
                   public void changed(ObservableValue<? extends Boolean> paramObservableValue,Boolean paramT1, Boolean isSelected) {
                        if(isSelected){
                             tab.setGraphic(closeBtn);
                        }else{
                             tab.setGraphic(null);
         }There are some drawbacks in the above code. In practice, it is suggested not to use the classes (*LabelSkin* & TabPaneSkin) that are in com.sun.javafx package. But I couldn’t get a better solution other than using those classes. And another one is I could'nt set the actual graphic for tab, as i am already using that graphic property to show the close button.
    I would like to thank Narayan, for giving some inputs which has helped me to think and get the above solution. :)

  • If FF is set to "Never Remember History" and I try to close it with multiple tabs open, it doesn't warn me first. If it remembers history, it warns me about closing multiple tabs. I want that warning AND Don't Remember History back again!

    At work I set my PC to not remember history for privacy reasons.
    I always have many tabs open, and the warning about closing multiple tabs was a good thing - but now it only works if it remembers history!
    I have the "Warn me when closing...." box checked AND all of the lines in about:config regarding these warnings are set to true. I have tried turning it off and back on, restarted the PC.
    I discovered this yesterday with FF 3.something, tried updating to FF4.

    The "Use custom settings for history" selection allows to see the current history and cookie settings, but selecting this doesn't make any changes to history and cookie settings.
    Firefox shows "Use custom settings for history" as an indication that at least one of the history and cookie settings is not the default to make you aware that changes were made.
    If all History settings are default then the custom settings are hidden and you see "Firefox will: (Never) Remember History".
    "Never Remember History" means that Private Browsing is active and "Always use private browsing mode" gets a checkmark.
    You need to remove the checkmark on "Always use private browsing mode" to leave Private Browsing mode or chose the "Remember History" setting.
    *https://support.mozilla.org/kb/Private+Browsing

  • How do I set Safari to prompt before closing multiple tabs OR reopen all of the closed tabs when when I relaunch the application?  The "Reopen all windows from last session" is unselectable.

    How do I set Safari to prompt before closing multiple tabs OR reopen all of the closed tabs when when I relaunch the application?  The "Reopen all windows from last session" is unselectable.

    It would seem if your choose "Show my windows and tabs from last time" '''''and''''',
    *when you last closed Firefox, you had no web site open (just a blank tab), that it would open just that blank tab
    *when you last closed Firefox, you had one or more tabs/web site open, that would allow you to "Restore Previous Session"
    #Have you tried that?
    #If so, what is happening in each circumstance when you reopen Firefox?
    '''Restore Previous Session'''<br />
    Open tabs are automatically saved when closing Firefox beginning in Firefox 4. To open your last session, after Firefox starts, click History > Restore Previous Session. For this to work
    #You must be remembering history (Options > Privacy > Remember my browsing history).
    #*See [https://support.mozilla.com/en-US/kb/Options%20window%20-%20Privacy%20panel Options window-Privacy panel]
    #You must not be using Private Browsing or permanent Private Browsing
    #*See [https://support.mozilla.com/en-US/kb/Private%20Browsing Private Browsing]
    #You must not use Clear Recent History or Clear history when Firefox closes
    #*See [https://support.mozilla.com/en-US/kb/Clear%20Recent%20History Clear Recent History]
    #*See [https://support.mozilla.com/en-US/kb/Options%20window%20-%20Privacy%20panel Options window-Privacy panel]
    '''If this reply solves your problem, please click "Solved It" next to this reply when <u>signed-in</u> to the forum.'''
    Not related to your question, but...
    You need to update some plug-ins:
    *Plug-in check: https://www-trunk.stage.mozilla.com/en-US/plugincheck/
    *Adobe PDF Plug-In For Firefox and Netscape: [https://support.mozilla.com/en-US/kb/Using%20the%20Adobe%20Reader%20plugin%20with%20Firefox#w_installing-and-updating-adobe-reader Installing/Updating Adobe Reader in Firefox]

  • Even after enabling "Warn me when closing multiple tabs", firefox closes without any warning even if multiple tabs are open.

    I recently installed Firefox 4.0 and in the options, under the section "Tabs", I have enabled "Warn me when closing multiple tabs". But if I have multiple tabs opened with websites loaded in them, and then try to close the browser, it simply closes. No warnings are shown (which was there in previous versions). Couple of times I clicked on the close button of browser and then realized that I had some important sites opened in different tabs, which I lost as it didn't warn me. Can you please let me know whether this is a bug or a mistake from my side?

    I'm sure you are using Private Browsing mode in Firefox 4. I have also the same problem and I tried to uncheck this option after many times accessing about:config\browser.warnOnquit. And it's wonderful, the warning cameback. I think it's a bug about Private Browsing mode. Hope Mozilla's Developers will fix it.

  • When closing firefox 4.0 with multiple tabs open, i wish to save this setup when i reopen firefox. the option to save my setup is now not in the prompt. only that i'm closing multiple tabs. how do i do this?

    in the older version of firefox, you were prompted when you were closing multiple tabs. but you were also given the option of saving the current setup so that when you reopened firefox, this current setup would reopen also. how do i make this happen with firefox 4.0?since i updated to firefox 4.0, there is no obtion given to save my current setup.

    You can change Firefox preferences so that you also get the option to save the current tabs when quiting:<BR><BR>
    # Type '''about:config''' into the location bar and press enter
    # Accept the warning message about being careful and you will see a list of settings.
    # Type '''browser.showQuitWarning''' into the ''Filter'' box at the top.
    # If its value is ''false'', double-click on it to change it to ''true''.

  • Firefox 25.0.1 Warn when closing multiple tabs (on) conflicts with "show windows und tabs from last time" (on); need both, but only one or the other works.

    Using Firefox 25.0.1 on Windows 7 Home Premium
    I've poured through support forums for Mozilla Firefox searching for a fix to my initial problem of the "Warn when closing multiple tabs" pop up not popping up when I have it selected.
    Went through About:Config, making sure warnings for tabs und closing, und showing on quit, und quitting, etc. were all set to true, which were "possible" fixes for the issue I was having, there are like five or six things set to true for warnings/quitting/etc. No avail. They are all set to true.
    Then I stumbled across one that suggested a conflict with the "Warn When Closing Multiple Tabs" und the "Show Windows und Tabs from last time".
    I use both features. However, I found if I want the warning pop up for closing multiple tabs, I have to have "show homepage" or "show blank page" selected instead of "Show windows und tabs from last time" selected. (Tools>Options>General>Start Up>When Firefox Starts:) The problem with this is, yes, I get my warning pop up, BUT, I don't get my tabs from my last session.
    The warning in settings (Tools>Options>Tabs>Warn Me When Closing Multiple Tabs) is checked.
    To have my tabs restored from last session, I simply select it for "when firefox starts". Bam, I have my tabs that were open from the last time I quit. Und again, full circle, I don't have my warning pop up.
    There were also suggestions of the warning on close for tabs is conflicting with add-ons.
    However, I don't have many. Und I have yet to test them to see if they interfere. These are according to my Add Ons tab when I check it myself.
    Extensions:
    1. Avast WebRep (disabled)
    2. HP Smart Web Printing (disabled)
    Plugins:
    1. Adobe Acrobat
    2. Google Update
    3. iTunes Application Detector
    4. Java (TM) Platform SE 7 U45
    5. Shockwave Flash
    6. Shockwave For Director
    7. Silverlight Plug-In
    8. VLC Web Plugin
    9. Windows Live Photo Gallery
    10. Java Deployment Toolkit (disabled)
    Note: The Details Firefox provides says I have these for Plugins
    * Shockwave Flash 11.9 r900
    * Adobe Shockwave for Director Netscape plug-in, version 12.0.5.146
    * Next Generation Java Plug-in 10.45.2 for Mozilla browsers
    * Google Update
    * Adobe PDF Plug-In For Firefox and Netscape 11.0.05
    * VLC media player Web Plugin 2.1.0
    * 5.1.20913.0
    * iTunes Detector Plug-in
    * NPWLPG
    Unsure of what the "5.1.20913.0" und the "NPWLPG" plugins are, but they don't appear to me under Add Ons.
    Und as usual, I'm assuming the solution lies within About:Config, I will show here now what I have set to True.
    browser.tabs.warnOnClose - True
    browser.tabs.warnOnCloseOtherTabs - True
    browser.tabs.warnOnOpen - True
    browser.warnOnQuit - True
    browser.showQuitWarning - True
    As aforementioned:
    The seemingly only issue is the conflict between Show Windows/Tabs From Last Time und the Warn On Quit pop up. Und again, I need/want both of them. More so the tabs from the last session, but I really really really really really want the warning.
    So, if anyone knows a work around, preferably without having to download anything to fix this, I would be extremely grateful.

    You mention a second subject.
    ''I'm probably going to downgrade to another version of firefox that was suggested to me since I'm also having issues with shockwave flash causing firefox to hang und ultimately needs to be force closed otherwise having to have flash disabled to use firefox.''
    <u>Downgrading Firefox </u><br />
    Flash is notorious for causing Firefox problems. I suggest you start a new thread about that. If at all possible you should try to avoid downgrading to an unsecure & unsupported version of Firefox. it will increase risks to your system and Personal data. (There are methods of mitigating the risks, using a virtual machine or operating within a secure intranet for instance)
    *(Do Not) [[Install an older version of Firefox]]
    <u>Try Flash with Protected Mode Off</u><br/>
    Worth a try as it takes minimal effort & often solves Flash Problems whilst allowing current and more secure FlashPlayer to be used. See
    * http://kb.mozillazine.org/Flash#Flash_Player_11.3_Protected_Mode_-_Windows
    * http://forums.adobe.com/thread/1018071#TemporaryWorkaround
    If you wish to pursue these subjects further I note you have already started a thread you may as well continue the discussion in that thread, but also post back here so we can follow both.
    * ''Firefox is having "Script" issues (Not Responding) und possibly Flash issues?'' [/questions/978181]
    ** try ensuring you close down Firefox using the menu, that may even help with Flash problems.
    <u>Your experience in submitting troubleshooting information on the forum</u><br />
    (This is out of curiosity, but with the intention of pressing for changes if forum faults are discovered.)
    There are yet more changes to this forum underway. Mozilla recently tried to improve the experience for first time users of the forum and a troubleshooting app option was included in the workflow to try to encourage users to submit full troubleshooting information.
    I would be interested to know what you thought
    I sometimes wonder if users are not trying to use that, or whether forum users run into problems in using it. At one point I wondered whether there was a problem if too much data was included but never actually proved that conjecture.
    Assuming you are using the forum, and not merely replying by email look towards the top in the right hand margin for clickable buttons
    * Question Details -V- More System Details -> [Additional System Details]
    You will note that includes only partial information. There are no changed prefs or extensions listed. Compare for instance the information in this thread [/questions/978130] with full information.
    I believe your mystery plugins are Windows related
    * NPWLPG relates usually to Windows Live Photo Gallery
    * 5.1.20913.0 will be Silverlight

  • When closing multiple tabs, is there any way to get back the option of saving those tabs OR NOT for your next session, within the warning dialogue box itself?

    For brief period of time, not in FF4, there was the option whereby when I closed multiple tabs, a firefox dialogue box opened warning me that I'm about to close multiple tabs, '''AND ALSO''' asking me if wanted to save those tabs for my next session, or trash them.
    The primary issue IS NOT about saving tabs. The primary question here is about getting THE OPTION back to the CLOSING MULTIPLE TABS WARNING DIALOGUE.
    The use case here should be obvious. However, since it is clearly not obvious that different people work in a variety of ways, and neither of those methods of working is "wrong" or "right" I will elaborate: Some people, for whatever reason, it doesn't matter why, want to save all their tabs on some occasions, and on other occasions don't.
    This preference varies throughout the day. Therefore it is inefficient to constantly go to preferences and change whether or not I want firefox to open all my tabs from my last session. It is more LOGICAL to place an option in the multiple tab warning dialogue as well, for people whose preference constantly changes.
    This option was available for a time in most of the Firefox 3 versions. Is there any way to get back this option in Firefox 4?

    Firefox 4 saves the previous session automatically, so there is no need for asking if you want to save the current session.
    You can use "Firefox > History > Restore Previous Session" to get the previous session.<br />
    There is also a "Restore Previous Session" button on the default <b>about:home</b> Home page.
    You can set the warn prefs on the <b>about:config</b> page to <b>true</b> via the right-click context menu or toggle the value with a double left-click.
    * browser.showQuitWarning, see http://blog.zpao.com/post/3174360617/about-that-quit-dialog
    * browser.tabs.warnOnClose, see http://kb.mozillazine.org/About%3Aconfig_entries
    * browser.warnOnQuit , see http://kb.mozillazine.org/browser.warnOnQuit
    * browser.warnOnRestart , see http://kb.mozillazine.org/browser.warnOnRestart
    To open the <i>about:config</i> page, type <b>about:config</b> in the location (address) bar and press the "<i>Enter</i>" key, just like you type the url of a website to open a website.<br />
    If you see a warning then you can confirm that you want to access that page.<br />

  • In Firefox 29 center clicking at the top of a tab in a maximized window will open a previously closed tab instead of closing the tab you clicked

    In Firefox 29 center clicking at the top of a tab in a maximized window will open a previously closed tab instead of closing the tab you clicked.
    Is this this the intended behavior? And if so is there any way to disable it?
    Thanks

    Middle-clicking a tab closes it, while middle-clicking an empty area of the tab bar opens a new tab.
    Different behavior is probably caused by a tab-related add-on like Tab Mix Plus. If you're not sure if you have such an add-on, restart Firefox with add-ons disabled and check if the problem still occurs.
    * [[Troubleshoot Firefox issues using Safe Mode]]

  • I have a looped music sound that will not stop playing after closing the tab.

    I played a lottery game online with background music. When I closed the tab and left the site the music keeps playing every time I open Firefox. It appears to be looped and I cannot stop it.

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • Sometimes I just want to close ONLY one window, but Firefox is closing ALL TABS, and I don't want this!

    I sometimes will open several windows, especially from my Comcast mailbox. When I am through with that window, I will close it, but leave the other ones open. FIrefox won't do this any more, When I close 1 window, Firefox send me a message stating that it is CLOSING ALL TABS. I DONT WANT TO CLOSE all of them, I just want to close the window I am closing!. This is very annoying, because I have to re-log back into everything, because FIrefox is "CLOSING ALL TABS", and all I want to to close ONE window...I am about ready to chuck this browser....I tried to find an answer to this in tools, but was unable to do so. Please help me with this

    Use CTRL+W - to close the surrent tab.
    '''Try the Firefox Safe Mode''' to see how it works there. The Safe Mode is a troubleshooting mode, which disables most add-ons.''
    ''(If you're not using it, switch to the Default theme.)''
    * You can open the Firefox 4.0+ Safe Mode by holding the '''Shift''' key when you use the Firefox desktop or Start menu shortcut.
    * Or use the Help menu item and click on the '''Restart with Add-ons Disabled...''' menu item while Firefox is running.
    ''Don't select anything right now, just use "'Start in Safe Mode"''
    ''To exit the Firefox Safe Mode, just close Firefox and wait a few seconds before using the Firefox shortcut (without the Shift key) to open it again.''
    '''''If it is good in the Firefox Safe Mode''''', your problem is probably caused by an extension, and you need to figure out which one.
    Please follow the [[Troubleshooting extensions and themes]] article for that.
    ''When you figure out what's causing your issues, please let us know. It might help other users who have the same problem.''

  • How do I make firefox focus on the left tab by default after closing a tab?

    In all Firefox versions before 3, when closing a tab, focus automatically goes to the tab to the left of the viewed tab. This was consistent with the way Firefox opened tabs, which was to the right.
    For example: I have 3 tabs, ABC.
    I'm currently viewing tab B, and open a new tab using a link.
    Now I have tabs ABDC, with focus on D. Once I'm finished looking at D, I close tab D and should be viewing B again. Current settings eject me to tab C, which is unrelated.
    Is there a way to revert this behavior?

    Try Tabberwocky: https://addons.mozilla.org/firefox/addon/14439

  • How to set reminder that I am closing multiple tabs?

    On another computer, I had set a reminder to warn me if I was
    closing more then one tab. I cannot find a way to set this warning on a different computer.
    Handicapped and need simple answer.

    Tools > Options > Tabs: [√] "Warn me when closing multiple tabs"

  • If you check the don't show this again box when closing multiple tabs, how do you get it to warn you when closing multiple tabs, or to save previous tabs? Checking the warn me when closing multiple tabs box under tools/tabs does not work to solve this?

    I accidentally checked the do not ask me again box when closing multiple tabs. Now I no longer get a warning when closing multiple tabs, and it saves my previous session. I have tried checking and un-checking the warn me box under tools which has not worked. If I open a second window and try to close multiple tabs it will warn me but not on the first window.

    You can reset the warn prefs on the about:config page via the right-click context menu.
    browser.tabs.warnOnClose , see http://kb.mozillazine.org/About%3Aconfig_entries
    browser.warnOnQuit , see http://kb.mozillazine.org/browser.warnOnQuit
    browser.warnOnRestart , see http://kb.mozillazine.org/browser.warnOnRestart
    To open the <i>about:config</i> page, type <b>about:config</b> in the location (address) bar and press the "<i>Enter</i>" key, just like you type the url of a website to open a website.<br />
    If you see a warning then you can confirm that you want to access that page.<br />

  • How to close window only if closing last tab is about:newtab

    Is there a way to achieve this behaviour:
    Let's say I have a last tab left open, for example mozilla.org or any other site. When closing that tab I want firefox to open about:newtab. This can be achieved by setting closeWindowWithLastTab flag in config. But here is the catch when closing that about:newtab I want to close window.
    So basically - Close window with last tab only if it is about:newtab. Also I want the close button on last tab to remain there.
    P.S. Last tab close button extension did not help.

    See:
    *Close Button: https://addons.mozilla.org/firefox/addon/close-button/

Maybe you are looking for

  • Use of max stock level w/o lot size HB

    hello champs.. need  a help on below functionality Can I have the functionlity of max stock level without using "lot size - HB" in material master. my requirement..tht system should not create any procurement proposal if stock reachs at max level.. b

  • The new U2 album that I never asked for keep playing on my Ipad, how do I get rid of it ? seems to come from the iCloud....

    need to delete this album from my ipad... icons of iCloud on the right of the songs. the album appears under artists doesn't appear on lists doesn't appear on the Imac when Ipad connected ? how do I suppress this music I don't want ?

  • How to read Blueprint Structure using ABAP

    Hello All, We are creating a report for which we need to read the projects blueprint structures (from ABAP). Anyone any ideas what tables to read from, or what bapi calls we can make for this? Thanks, Jurjen

  • Any fix for bugs caused by 8.1 yet

    Since the bug filled update 8.1 downloaded on my machines I've had *nothing* but problems... i even went so far as to buy a new IPad Air thinking my older model was the problem. Nope, the new ipad still freezes up when loading pages, locks up for no

  • Clearing the cache in production...

    What effect if any does clearing out the cache have on session variables? Also, is anyone aware of any potential adverse side effects on user experience when clearing out the cache durring normal business hours? Thank you, Mike