View Javadoc
1   package org.woehlke.computer.kurzweil.tabs;
2   
3   import lombok.EqualsAndHashCode;
4   import lombok.Getter;
5   import lombok.ToString;
6   import lombok.extern.log4j.Log4j2;
7   import org.woehlke.computer.kurzweil.application.ComputerKurzweilContext;
8   import org.woehlke.computer.kurzweil.commons.widgets.PanelSubtitle;
9   import org.woehlke.computer.kurzweil.commons.layouts.BoxLayoutVertical;
10  
11  import javax.swing.*;
12  import javax.swing.border.Border;
13  
14  @Log4j2
15  @Getter
16  @ToString(callSuper = true, exclude = {"ctx","tabbedPane","border","layout","panelSubtitle"})
17  @EqualsAndHashCode(callSuper=true, exclude = {"ctx","tabbedPane","border","layout","panelSubtitle"})
18  public abstract class TabPanel extends JPanel implements Tab {
19  
20      protected final ComputerKurzweilTabbedPane tabbedPane;
21      protected final ComputerKurzweilContext ctx;
22      protected final Border border;
23      protected final BoxLayoutVertical layout;
24      protected final PanelSubtitle panelSubtitle;
25  
26      protected final String title;
27      protected final String subTitle;
28  
29      protected final TabType tabType;
30  
31      protected TabPanel(ComputerKurzweilTabbedPane tabbedPane, TabType tabType) {
32          this.tabbedPane = tabbedPane;
33          this.tabType = tabType;
34          this.ctx = this.tabbedPane.getCtx();
35          this.layout = new BoxLayoutVertical(this);
36          this.border = this.ctx.getTabBorder();
37          this.title =  this.ctx.getProperties().getTitle(tabType);
38          this.subTitle = this.ctx.getProperties().getSubtitle(tabType);
39          this.setName(title);
40          this.panelSubtitle = new PanelSubtitle(subTitle);
41          this.setLayout(layout);
42          //this.setBorder(border);
43      }
44  
45      @Override
46      public String getTitle() {
47          return tabType.getTitle();
48      }
49  
50      @Override
51      public String getSubTitle() {
52          return tabType.getSubTitle();
53      }
54  
55      @Override
56      public Icon getIcon() {
57          return null;
58      }
59  
60      @Override
61      public int getKeyEvent() {
62          return tabType.getKeyEvent();
63      }
64  
65  }