• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

link-intersystems / lis-commons / #264

05 Nov 2023 11:38AM UTC coverage: 88.527% (-1.3%) from 89.804%
#264

Pull #7

renelink
Added tests.
Pull Request #7: Migrated swing-view stuff from java-swing-mvc-plugin-architecture.

249 of 400 new or added lines in 23 files covered. (62.25%)

7639 of 8629 relevant lines covered (88.53%)

0.89 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/lis-commons-swing-view/src/main/java/com/link_intersystems/swing/view/window/WindowView.java
1
package com.link_intersystems.swing.view.window;
2

3
import com.link_intersystems.swing.action.ActionTrigger;
4
import com.link_intersystems.swing.view.AbstractView;
5
import com.link_intersystems.swing.view.ViewContent;
6
import com.link_intersystems.swing.view.ViewSite;
7
import com.link_intersystems.util.context.Context;
8

9
import javax.swing.*;
10
import java.awt.*;
11
import java.awt.event.WindowAdapter;
12
import java.awt.event.WindowEvent;
13

14
import static javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE;
15

NEW
16
public abstract class WindowView extends AbstractView {
×
17

NEW
18
    public static final String DEFAULT_CLOSE_ACTION = WindowView.class.getName() + ".closeAction";
×
NEW
19
    private ActionTrigger actionTrigger = new ActionTrigger(this);
×
20

21
    private Window window;
22

NEW
23
    private WindowAdapter closeHandler = new WindowAdapter() {
×
24
        @Override
25
        public void windowClosing(WindowEvent e) {
NEW
26
            onCloseWindow(getViewSite());
×
NEW
27
        }
×
28
    };
29

30
    @Override
31
    protected void doInstall(ViewSite viewSite) {
NEW
32
        window = createWindow(viewSite);
×
NEW
33
        setDefaultCloseOperation(window, DO_NOTHING_ON_CLOSE);
×
NEW
34
        window.addWindowListener(closeHandler);
×
NEW
35
        ViewContent viewContent = viewSite.getViewContent();
×
NEW
36
        viewContent.setComponent(window);
×
NEW
37
    }
×
38

39
    protected void setDefaultCloseOperation(Window window, int closeOperation) {
NEW
40
        if (window instanceof JFrame) {
×
NEW
41
            JFrame frame = (JFrame) window;
×
NEW
42
            frame.setDefaultCloseOperation(closeOperation);
×
NEW
43
        } else if (window instanceof JDialog) {
×
NEW
44
            JDialog dialog = (JDialog) window;
×
NEW
45
            dialog.setDefaultCloseOperation(closeOperation);
×
46
        }
NEW
47
    }
×
48

49
    protected abstract Window createWindow(ViewSite viewSite);
50

51
    @Override
52
    protected void doUninstall(ViewSite viewSite) {
NEW
53
        super.doUninstall(viewSite);
×
54

NEW
55
        window.removeWindowListener(closeHandler);
×
NEW
56
        closeHandler = null;
×
57

NEW
58
        window.dispose();
×
NEW
59
        window = null;
×
NEW
60
    }
×
61

62
    protected void onCloseWindow(ViewSite viewSite) {
NEW
63
        uninstall();
×
NEW
64
        Context viewContext = viewSite.getViewContext();
×
NEW
65
        viewContext.ifContains(Action.class, DEFAULT_CLOSE_ACTION, actionTrigger::performAction);
×
NEW
66
    }
×
67
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc