Search in sources :

Example 6 with HierarchyListener

use of java.awt.event.HierarchyListener in project freeplane by freeplane.

the class UITextChanger method setFocusWhenShowed.

private void setFocusWhenShowed(final JTextField focusOwner) {
    focusOwner.addHierarchyListener(new HierarchyListener() {

        @Override
        public void hierarchyChanged(HierarchyEvent e) {
            if (focusOwner.isShowing()) {
                final Window windowAncestor = SwingUtilities.getWindowAncestor(focusOwner);
                if (windowAncestor.isFocused()) {
                    focusOwner.requestFocusInWindow();
                } else {
                    windowAncestor.addWindowFocusListener(new WindowFocusListener() {

                        @Override
                        public void windowLostFocus(WindowEvent e) {
                        // intentionally left blank
                        }

                        @Override
                        public void windowGainedFocus(WindowEvent e) {
                            focusOwner.requestFocusInWindow();
                            windowAncestor.removeWindowFocusListener(this);
                        }
                    });
                }
                focusOwner.removeHierarchyListener(this);
            }
        }
    });
}
Also used : Window(java.awt.Window) HierarchyEvent(java.awt.event.HierarchyEvent) WindowEvent(java.awt.event.WindowEvent) WindowFocusListener(java.awt.event.WindowFocusListener) HierarchyListener(java.awt.event.HierarchyListener)

Example 7 with HierarchyListener

use of java.awt.event.HierarchyListener in project cuba by cuba-platform.

the class DetachedFrame method initUI.

private void initUI() {
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    glassPane = new DisabledGlassPane();
    JRootPane rootPane = SwingUtilities.getRootPane(this);
    rootPane.setGlassPane(glassPane);
    final java.awt.Component topLevelGlassPane = DesktopComponentsHelper.getTopLevelFrame(parentContainer).getGlassPane();
    topLevelGlassPane.addHierarchyListener(new HierarchyListener() {

        @Override
        public void hierarchyChanged(HierarchyEvent e) {
            if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) == HierarchyEvent.SHOWING_CHANGED) {
                if (topLevelGlassPane.isVisible()) {
                    glassPane.activate(null);
                } else {
                    glassPane.deactivate();
                }
            }
        }
    });
}
Also used : HierarchyEvent(java.awt.event.HierarchyEvent) DisabledGlassPane(com.haulmont.cuba.desktop.sys.DisabledGlassPane) java.awt(java.awt) HierarchyListener(java.awt.event.HierarchyListener)

Example 8 with HierarchyListener

use of java.awt.event.HierarchyListener in project cuba by cuba-platform.

the class DesktopTabSheet method detachTab.

protected void detachTab(final int tabIndex) {
    final JComponent tabContent = (JComponent) impl.getComponentAt(tabIndex);
    TabImpl tabAtIndex = null;
    for (TabImpl tab : tabs) {
        if (DesktopComponentsHelper.getComposition(tab.getComponent()) == tabContent) {
            tabAtIndex = tab;
            if (tab.isLazy() && !tab.isLazyInitialized()) {
                initLazyTab(tabContent);
            }
            break;
        }
    }
    if (tabAtIndex == null) {
        throw new IllegalStateException("Unable to find tab to detach");
    }
    final TabImpl tabToDetach = tabAtIndex;
    final ButtonTabComponent tabComponent = tabToDetach.getButtonTabComponent();
    final JFrame frame = new DetachedFrame(tabComponent.getCaption(), impl);
    frame.setLocationRelativeTo(DesktopComponentsHelper.getTopLevelFrame(this));
    impl.remove(tabContent);
    updateTabsEnabledState();
    frame.setSize(impl.getSize());
    frame.add(tabContent);
    final HierarchyListener listener = new HierarchyListener() {

        @Override
        public void hierarchyChanged(HierarchyEvent e) {
            if ((e.getChangeFlags() & HierarchyEvent.DISPLAYABILITY_CHANGED) == HierarchyEvent.DISPLAYABILITY_CHANGED && !impl.isDisplayable()) {
                attachTab(frame, tabToDetach);
                impl.removeHierarchyListener(this);
            }
        }
    };
    frame.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            attachTab(frame, tabToDetach);
            impl.removeHierarchyListener(listener);
        }
    });
    impl.addHierarchyListener(listener);
    frame.setVisible(true);
}
Also used : ButtonTabComponent(com.haulmont.cuba.desktop.sys.ButtonTabComponent) HierarchyEvent(java.awt.event.HierarchyEvent) WindowEvent(java.awt.event.WindowEvent) DetachedFrame(com.haulmont.cuba.desktop.DetachedFrame) WindowAdapter(java.awt.event.WindowAdapter) HierarchyListener(java.awt.event.HierarchyListener)

Example 9 with HierarchyListener

use of java.awt.event.HierarchyListener in project freeplane by freeplane.

the class PresentationController method createPanel.

private Component createPanel() {
    final Component presentationEditor = presentationEditorController.createPanel(modeController);
    presentationEditor.addHierarchyListener(new HierarchyListener() {

        @Override
        public void hierarchyChanged(HierarchyEvent e) {
            if (0 != (e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED))
                presentationState.setHighlightsNodes(e.getComponent().isShowing());
        }
    });
    return new JAutoScrollBarPane(presentationEditor);
}
Also used : JAutoScrollBarPane(org.freeplane.core.ui.components.JAutoScrollBarPane) HierarchyEvent(java.awt.event.HierarchyEvent) Component(java.awt.Component) HierarchyListener(java.awt.event.HierarchyListener)

Example 10 with HierarchyListener

use of java.awt.event.HierarchyListener in project freeplane by freeplane.

the class SurveyRunner method runServey.

public void runServey(String id, String title, String question, String surveyUrl) {
    if (!freeplaneSurveyProperties.mayAskUserToFillSurvey(surveyId))
        return;
    this.surveyId = id;
    freeplaneSurveyProperties.setNextSurveyDay(MINIMAL_DAYS_BETWEEN_SURVEYS);
    final JButton go = new JButton("With pleasure");
    go.setToolTipText("Thank you so much!");
    final JButton notInterested = new JButton("Not interested");
    notInterested.setToolTipText("We shall not repeat this question, but may be ask you another one.");
    final JButton remindMeLater = new JButton("Remind me later");
    remindMeLater.setToolTipText("The same question can be repeated some days later.");
    final JButton never = new JButton("Don't ask me anything again");
    never.setToolTipText("We are sorry! We shall never ask you any question like this again.");
    final JButton[] options = new JButton[] { go, notInterested, remindMeLater, never };
    final OptionButtonListener optionButtonListener = new OptionButtonListener();
    for (JButton button : options) button.addActionListener(optionButtonListener);
    final List<Image> iconImages = UITools.getFrame().getIconImages();
    final JEditorPane messageComponent = new JEditorPane("text/html", question);
    messageComponent.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK), BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    messageComponent.addHyperlinkListener(new HyperlinkListener() {

        @Override
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                try {
                    final URL url = e.getURL();
                    openSurvey(url);
                } catch (Exception ex) {
                }
                userVisitedVotingLink = true;
                SwingUtilities.getWindowAncestor(messageComponent).setVisible(false);
            }
        }
    });
    messageComponent.setEditable(false);
    messageComponent.addHierarchyListener(new HierarchyListener() {

        @Override
        public void hierarchyChanged(HierarchyEvent e) {
            if (messageComponent.isShowing()) {
                messageComponent.removeHierarchyListener(this);
                final Window window = SwingUtilities.getWindowAncestor(messageComponent);
                if (window instanceof JDialog)
                    ((JDialog) window).setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
                window.setIconImages(iconImages);
            }
        }
    });
    final int userDecision = JOptionPane.showOptionDialog(UITools.getCurrentFrame(), messageComponent, title, JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION, null, options, remindMeLater);
    switch(userDecision) {
        case JOptionPane.CLOSED_OPTION:
            if (userVisitedVotingLink)
                freeplaneSurveyProperties.markSurveyAsFilled(surveyId);
            break;
        default:
            switch(Options.values()[userDecision]) {
                case GO_OPTION:
                    try {
                        freeplaneSurveyProperties.markSurveyAsFilled(surveyId);
                        final URL survey = new URL(surveyUrl);
                        openSurvey(survey);
                    } catch (Exception e) {
                    }
                    break;
                case NOT_INTERESTED_OPTION:
                    freeplaneSurveyProperties.markSurveyAsFilled(surveyId);
                    break;
                case REMIND_ME_LATER_OPTION:
                    freeplaneSurveyProperties.setNextSurveyDay(MINIMAL_DAYS_BETWEEN_SURVEY_REMINDERS);
                    freeplaneSurveyProperties.activateRemindMeLater();
                    break;
                case NEVER_OPTION:
                    freeplaneSurveyProperties.setNeverShowSurvey();
                    break;
            }
    }
}
Also used : Window(java.awt.Window) HyperlinkEvent(javax.swing.event.HyperlinkEvent) JButton(javax.swing.JButton) Image(java.awt.Image) URL(java.net.URL) HierarchyListener(java.awt.event.HierarchyListener) HyperlinkListener(javax.swing.event.HyperlinkListener) HierarchyEvent(java.awt.event.HierarchyEvent) JEditorPane(javax.swing.JEditorPane) JDialog(javax.swing.JDialog)

Aggregations

HierarchyListener (java.awt.event.HierarchyListener)20 HierarchyEvent (java.awt.event.HierarchyEvent)19 Window (java.awt.Window)5 WindowEvent (java.awt.event.WindowEvent)5 Component (java.awt.Component)4 WindowAdapter (java.awt.event.WindowAdapter)4 DetachedFrame (com.haulmont.cuba.desktop.DetachedFrame)2 ItemEvent (java.awt.event.ItemEvent)2 ItemListener (java.awt.event.ItemListener)2 JComboBox (javax.swing.JComboBox)2 JDialog (javax.swing.JDialog)2 RenderResult (com.android.tools.idea.rendering.RenderResult)1 ButtonTabComponent (com.haulmont.cuba.desktop.sys.ButtonTabComponent)1 DisabledGlassPane (com.haulmont.cuba.desktop.sys.DisabledGlassPane)1 Editor (com.intellij.openapi.editor.Editor)1 com.intellij.openapi.fileEditor (com.intellij.openapi.fileEditor)1 PsiFile (com.intellij.psi.PsiFile)1 Update (com.intellij.util.ui.update.Update)1 java.awt (java.awt)1 Dialog (java.awt.Dialog)1