Default constructor. @param context database context @param gopts gui options
(final Context context, final GUIOptions gopts)
| 115 | * @param gopts gui options |
| 116 | */ |
| 117 | public GUI(final Context context, final GUIOptions gopts) { |
| 118 | this.context = context; |
| 119 | this.gopts = gopts; |
| 120 | |
| 121 | if(Prop.MAC) BaseXLayout.initMac(this); |
| 122 | setIconImage(BaseXImages.get("logo_small")); |
| 123 | setTitle(); |
| 124 | |
| 125 | // set window size |
| 126 | final Dimension scr = Toolkit.getDefaultToolkit().getScreenSize(); |
| 127 | final int[] loc = gopts.get(GUIOptions.GUILOC); |
| 128 | final int[] size = gopts.get(GUIOptions.GUISIZE); |
| 129 | final int x = Math.max(0, Math.min(scr.width - size[0], loc[0])); |
| 130 | final int y = Math.max(0, Math.min(scr.height - size[1], loc[1])); |
| 131 | setBounds(x, y, size[0], size[1]); |
| 132 | if(gopts.get(GUIOptions.MAXSTATE)) { |
| 133 | setExtendedState(MAXIMIZED_HORIZ); |
| 134 | setExtendedState(MAXIMIZED_VERT); |
| 135 | setExtendedState(MAXIMIZED_BOTH); |
| 136 | } |
| 137 | |
| 138 | top = new BaseXBack(new BorderLayout()); |
| 139 | |
| 140 | // add header |
| 141 | control = new BaseXBack(new BorderLayout()); |
| 142 | |
| 143 | // add menu bar |
| 144 | menu = new GUIMenu(this); |
| 145 | setJMenuBar(menu); |
| 146 | |
| 147 | buttons = new BaseXBack(new BorderLayout()); |
| 148 | toolbar = new GUIToolBar(TOOLBAR, this); |
| 149 | buttons.add(toolbar, BorderLayout.WEST); |
| 150 | |
| 151 | results = new BaseXLabel(" ").border(-2, 0, 0, 4).resize(1.7f); |
| 152 | results.setHorizontalAlignment(SwingConstants.RIGHT); |
| 153 | |
| 154 | BaseXBack b = new BaseXBack(); |
| 155 | b.add(results); |
| 156 | |
| 157 | buttons.add(b, BorderLayout.EAST); |
| 158 | if(this.gopts.get(GUIOptions.SHOWBUTTONS)) control.add(buttons, BorderLayout.CENTER); |
| 159 | |
| 160 | mode = new BaseXCombo(this, FIND, "XQuery", COMMAND); |
| 161 | mode.setSelectedIndex(2); |
| 162 | |
| 163 | input = new GUIInput(this); |
| 164 | input.mode(mode.getSelectedItem()); |
| 165 | |
| 166 | mode.addActionListener(e -> { |
| 167 | final int s = mode.getSelectedIndex(); |
| 168 | if(s == gopts.get(GUIOptions.SEARCHMODE) || !mode.isEnabled()) return; |
| 169 | |
| 170 | gopts.set(GUIOptions.SEARCHMODE, s); |
| 171 | input.mode(mode.getSelectedItem()); |
| 172 | }); |
| 173 | |
| 174 | b = new BaseXBack(new BorderLayout(4, 0)); |
nothing calls this directly
no test coverage detected