/** * Default constructor. * * @param main reference to the main window */ public DialogNew(final GUI main) { super(main, CREATE_DATABASE); // define buttons first to assign simplest mnemonics buttons = okCancel(); db = List.list(main.context.soptions); final MainOptions opts = gui.context.options; final GUIOptions gopts = main.gopts; dbname = new BaseXTextField(gopts.get(GUIOptions.DBNAME), this); final BaseXBack pnl = new BaseXBack(new TableLayout(2, 1)); pnl.add(new BaseXLabel(NAME_OF_DB + COLS, false, true).border(8, 0, 6, 0)); pnl.add(dbname); // option panels final BaseXTabs tabs = new BaseXTabs(this); final DialogParsing parsing = new DialogParsing(this, tabs); general = new DialogImport(this, pnl, parsing); // index panel final BaseXBack indexes = new BaseXBack(new TableLayout(6, 1, 0, 0)).border(8); txtindex = new BaseXCheckBox(TEXT_INDEX, MainOptions.TEXTINDEX, opts, this).bold().large(); indexes.add(txtindex); indexes.add(new BaseXLabel(H_TEXT_INDEX, true, false)); atvindex = new BaseXCheckBox(ATTRIBUTE_INDEX, MainOptions.ATTRINDEX, opts, this).bold().large(); indexes.add(atvindex); indexes.add(new BaseXLabel(H_ATTR_INDEX, true, false)); // full-text panel ftxindex = new BaseXCheckBox(FULLTEXT_INDEX, MainOptions.FTINDEX, opts, this).bold().large(); indexes.add(ftxindex); ft = new DialogFT(this, true); indexes.add(ft); tabs.addTab(GENERAL, general); tabs.addTab(PARSING, parsing); tabs.addTab(INDEXES, indexes); set(tabs, BorderLayout.CENTER); set(buttons, BorderLayout.SOUTH); general.setType(general.input()); action(general.parsers); setResizable(true); finish(null); }
@Override public void createView(final BaseXBack panel) { // skip invisible layouts if (!isVisible()) return; final BaseXBack split = new BaseXSplit(horiz); for (final ViewLayout c : comp) c.createView(split); panel.add(split); }
@Override public void paintComponent(final Graphics g) { super.paintComponent(g); init(g, bar.pos()); while (more(g)) write(g); wordW = 0; final int s = text.size(); if (cursor && s == text.cursor()) drawCursor(g, x); if (s == text.error()) drawError(g); }
/** * Adds a new editor tab. * * @return editor reference */ EditorArea addTab() { final EditorArea edit = new EditorArea(this, newTabFile()); edit.setFont(GUIConstants.mfont); final BaseXBack tab = new BaseXBack(new BorderLayout(10, 0)).mode(Fill.NONE); tab.add(edit.label, BorderLayout.CENTER); final BaseXButton close = tabButton("e_close"); close.setRolloverIcon(BaseXLayout.icon("e_close2")); close.addActionListener( new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { close(edit); } }); tab.add(close, BorderLayout.EAST); tabs.add(edit, tab, tabs.getComponentCount() - 2); return edit; }
/** * Default constructor. * * @param man view manager */ public TextView(final ViewNotifier man) { super(TEXTVIEW, man); border(5).layout(new BorderLayout(0, 5)); header = new BaseXHeader(RESULT); home = BaseXButton.command(GUIMenuCmd.C_HOME, gui); home.setEnabled(false); text = new TextPanel(false, gui); text.setSyntax(new SyntaxXML()); search = new SearchEditor(gui, text); final AbstractButton save = BaseXButton.get("c_save", SAVE, false, gui); final AbstractButton find = search.button(FIND); final BaseXBack buttons = new BaseXBack(false); buttons.layout(new TableLayout(1, 3, 1, 0)).border(0, 0, 4, 0); buttons.add(save); buttons.add(home); buttons.add(find); final BaseXBack b = new BaseXBack(false).layout(new BorderLayout()); b.add(buttons, BorderLayout.WEST); b.add(header, BorderLayout.EAST); add(b, BorderLayout.NORTH); add(search, BorderLayout.CENTER); save.addActionListener( new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { save(); } }); refreshLayout(); }
/** * Default constructor. * * @param main reference to the main window */ public DialogExport(final GUI main) { super(main, EXPORT); // create checkboxes final BaseXBack p = new BaseXBack(new TableLayout(4, 1, 0, 0)); p.add(new BaseXLabel(OUTPUT_DIR + COL, true, true).border(0, 0, 6, 0)); // output label BaseXBack pp = new BaseXBack(new TableLayout(1, 2, 8, 0)); path = new BaseXTextField(main.gopts.get(GUIOptions.INPUTPATH), this); pp.add(path.history(GUIOptions.INPUTS, this)); final BaseXButton browse = new BaseXButton(BROWSE_D, this); browse.addActionListener( new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { choose(); } }); pp.add(browse); p.add(pp); // provide components for method and encoding final MainOptions opts = gui.context.options; final SerializerOptions sopts = opts.get(MainOptions.EXPORTER); // method (ignore last entry) final StringList sl = new StringList(); for (final SerialMethod sm : SerialMethod.values()) sl.add(sm.name()); sl.remove(sl.size() - 1); method = new BaseXCombo(this, sl.finish()); final SerialMethod sm = sopts.get(SerializerOptions.METHOD); method.setSelectedItem((sm == null ? SerialMethod.BASEX : sm).name()); mparams = new BaseXTextField(this); mparams.setColumns(24); final BaseXBack mth = new BaseXBack(new TableLayout(1, 2, 8, 0)); mth.add(method); mth.add(mparams); encoding = new BaseXCombo(this, ENCODINGS); String enc = sopts.get(SerializerOptions.ENCODING); boolean f = false; for (final String s : ENCODINGS) f |= s.equals(enc); if (!f) { enc = enc.toUpperCase(Locale.ENGLISH); for (final String s : ENCODINGS) f |= s.equals(enc); } encoding.setSelectedItem(f ? enc : sopts.get(SerializerOptions.ENCODING)); params = new BaseXTextField(sopts.toString(), this); params.setToolTipText(tooltip(SerializerMode.DEFAULT.get())); pp = new BaseXBack(new TableLayout(3, 2, 16, 6)).border(8, 0, 8, 0); pp.add(new BaseXLabel(METHOD + COL, true, true)); pp.add(mth); pp.add(new BaseXLabel(ENCODING + COL, true, true)); pp.add(encoding); pp.add(new BaseXLabel(PARAMETERS + COL, true, true)); pp.add(params); p.add(pp); info = new BaseXLabel(" ").border(8, 0, 0, 0); p.add(info); // indentation set(p, BorderLayout.CENTER); // buttons pp = new BaseXBack(new BorderLayout()); buttons = okCancel(); pp.add(buttons, BorderLayout.EAST); set(pp, BorderLayout.SOUTH); action(method); finish(null); }
/** * Default constructor. * * @param man view manager */ public EditorView(final ViewNotifier man) { super(EDITORVIEW, man); if (Prop.langright) applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); border(6, 6, 6, 6).layout(new BorderLayout(0, 2)).setFocusable(false); header = new BaseXLabel(EDITOR, true, false); final BaseXButton srch = new BaseXButton(gui, "search", H_REPLACE); final BaseXButton openB = BaseXButton.command(GUICommands.C_EDITOPEN, gui); final BaseXButton saveB = new BaseXButton(gui, "save", H_SAVE); hist = new BaseXButton(gui, "hist", H_RECENTLY_OPEN); final BaseXBack buttons = new BaseXBack(Fill.NONE); buttons.layout(new TableLayout(1, 4, 1, 0)); buttons.add(srch); buttons.add(openB); buttons.add(saveB); buttons.add(hist); final BaseXBack b = new BaseXBack(Fill.NONE).layout(new BorderLayout(8, 0)); if (Prop.langright) { b.add(header, BorderLayout.EAST); b.add(buttons, BorderLayout.WEST); } else { b.add(header, BorderLayout.CENTER); b.add(buttons, BorderLayout.EAST); } add(b, BorderLayout.NORTH); tabs = new BaseXTabs(gui); tabs.setFocusable(false); final SearchEditor se = new SearchEditor(gui, tabs, null).button(srch); search = se.panel(); addCreateTab(); add(se, BorderLayout.CENTER); // status and query pane search.editor(addTab(), false); info = new BaseXLabel().setText(OK, Msg.SUCCESS); pos = new BaseXLabel(" "); posCode.invokeLater(); stop = new BaseXButton(gui, "stop", H_STOP_PROCESS); stop.addKeyListener(this); stop.setEnabled(false); go = new BaseXButton(gui, "go", H_EXECUTE_QUERY); go.addKeyListener(this); filter = BaseXButton.command(GUICommands.C_FILTER, gui); filter.addKeyListener(this); filter.setEnabled(false); final BaseXBack status = new BaseXBack(Fill.NONE).layout(new BorderLayout(4, 0)); status.add(info, BorderLayout.CENTER); status.add(pos, BorderLayout.EAST); final BaseXBack query = new BaseXBack(Fill.NONE).layout(new TableLayout(1, 3, 1, 0)); query.add(stop); query.add(go); query.add(filter); final BaseXBack south = new BaseXBack(Fill.NONE).border(4, 0, 0, 0); south.layout(new BorderLayout(8, 0)); south.add(status, BorderLayout.CENTER); south.add(query, BorderLayout.EAST); add(south, BorderLayout.SOUTH); refreshLayout(); // add listeners saveB.addActionListener( new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { final JPopupMenu pop = new JPopupMenu(); final StringBuilder mnem = new StringBuilder(); final JMenuItem sa = GUIMenu.newItem(GUICommands.C_EDITSAVE, gui, mnem); final JMenuItem sas = GUIMenu.newItem(GUICommands.C_EDITSAVEAS, gui, mnem); GUICommands.C_EDITSAVE.refresh(gui, sa); GUICommands.C_EDITSAVEAS.refresh(gui, sas); pop.add(sa); pop.add(sas); pop.show(saveB, 0, saveB.getHeight()); } }); hist.addActionListener( new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { final JPopupMenu pm = new JPopupMenu(); final ActionListener al = new ActionListener() { @Override public void actionPerformed(final ActionEvent ac) { open(new IOFile(ac.getActionCommand())); } }; final StringList sl = new StringList(); for (final EditorArea ea : editors()) sl.add(ea.file.path()); for (final String en : new StringList().add(gui.gprop.strings(GUIProp.EDITOR)).sort(!Prop.WIN, true)) { final JMenuItem it = new JMenuItem(en); it.setEnabled(!sl.contains(en)); pm.add(it).addActionListener(al); } pm.show(hist, 0, hist.getHeight()); } }); refreshHistory(null); info.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(final MouseEvent e) { EditorArea ea = getEditor(); if (errFile != null) { ea = find(IO.get(errFile), false); if (ea == null) ea = open(new IOFile(errFile)); tabs.setSelectedComponent(ea); } if (errPos == -1) return; ea.jumpError(errPos); posCode.invokeLater(); } }); stop.addActionListener( new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { stop.setEnabled(false); go.setEnabled(false); gui.stop(); } }); go.addActionListener( new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { getEditor().release(Action.EXECUTE); } }); tabs.addChangeListener( new ChangeListener() { @Override public void stateChanged(final ChangeEvent e) { final EditorArea ea = getEditor(); if (ea == null) return; search.editor(ea, true); gui.refreshControls(); posCode.invokeLater(); } }); BaseXLayout.addDrop( this, new DropHandler() { @Override public void drop(final Object file) { if (file instanceof File) open(new IOFile((File) file)); } }); }
@Override public void paintComponent(final Graphics g) { super.paintComponent(g); write(g, bar.pos()); }
/** * Default constructor. * * @param main reference to the main window */ public DialogNew(final GUI main) { super(main, CREATE_DATABASE); // define buttons first to assign simplest mnemonics buttons = okCancel(); final MainOptions opts = gui.context.options; final GUIOptions gopts = main.gopts; dbName = new BaseXTextField(gopts.get(GUIOptions.DBNAME), this); final BaseXBack pnl = new BaseXBack(new TableLayout(2, 1)); pnl.add(new BaseXLabel(NAME_OF_DB + COLS, false, true).border(8, 0, 6, 0)); pnl.add(dbName); // option panels final BaseXTabs tabs = new BaseXTabs(this); final DialogParsing parsePanel = new DialogParsing(this, tabs); general = new DialogImport(this, pnl, parsePanel); index = new DialogIndex[] { new DialogValues(this, IndexType.TEXT), new DialogValues(this, IndexType.ATTRIBUTE), new DialogValues(this, IndexType.TOKEN), new DialogFT(this, true) }; textindex = new BaseXCheckBox(TEXT_INDEX, MainOptions.TEXTINDEX, opts, this).bold().large(); attrindex = new BaseXCheckBox(ATTRIBUTE_INDEX, MainOptions.ATTRINDEX, opts, this).bold().large(); tokenindex = new BaseXCheckBox(TOKEN_INDEX, MainOptions.TOKENINDEX, opts, this).bold().large(); ftindex = new BaseXCheckBox(FULLTEXT_INDEX, MainOptions.FTINDEX, opts, this).bold().large(); // index panel final BaseXBack indexPanel = new BaseXBack(new TableLayout(8, 1)).border(8); indexPanel.add(textindex); indexPanel.add(index[0]); indexPanel.add(new BaseXBack()); indexPanel.add(attrindex); indexPanel.add(index[1]); indexPanel.add(new BaseXBack()); indexPanel.add(tokenindex); indexPanel.add(index[2]); // full-text index panel final BaseXBack ftPanel = new BaseXBack(new TableLayout(2, 1)).border(8); ftPanel.add(ftindex); ftPanel.add(index[3]); // options panel options = new DialogOptions(this, null); tabs.addTab(GENERAL, general); tabs.addTab(PARSING, parsePanel); tabs.addTab(INDEXES, indexPanel); tabs.addTab(FULLTEXT, ftPanel); tabs.addTab(OPTIONS, options); set(tabs, BorderLayout.CENTER); set(buttons, BorderLayout.SOUTH); general.setType(general.input()); action(general.parsers); setResizable(true); finish(); }