no message
This commit is contained in:
@@ -34,7 +34,7 @@ public abstract class Database {
|
||||
// UI.Print(DebugPrintLevel.Database, "соединение с базой данных " + file.getAbsolutePath());
|
||||
connect();
|
||||
}
|
||||
public void Activate() throws Exception{
|
||||
public void Activate() throws Exception {
|
||||
Connect();
|
||||
CreateAllTables();
|
||||
prepareTablesStatements();
|
||||
@@ -310,7 +310,7 @@ public abstract class Database {
|
||||
}
|
||||
public abstract PassCode_ getSynchronizePassCode(); //если бд есть на сервере.
|
||||
//--
|
||||
public void ReplaceFileAndReconnect(File file_in) throws Exception{
|
||||
public void ReplaceFileAndReconnect(File file_in) throws Exception {
|
||||
Disconnect();
|
||||
Utils_.forceDeleteWithCheck(getFile());
|
||||
FileUtils.moveFile(file_in, getFile());
|
||||
@@ -318,10 +318,10 @@ public abstract class Database {
|
||||
prepareTablesStatements();
|
||||
Synchronize();
|
||||
}
|
||||
public void DropUI(){
|
||||
public void DropUI() {
|
||||
SaveLastSelections();
|
||||
}
|
||||
public void ResetUI(){
|
||||
public void ResetUI() {
|
||||
RestoreLastSelections();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,5 +255,4 @@ public abstract class SQLiteDatabase extends Database {
|
||||
}
|
||||
//--
|
||||
//https://stackoverflow.com/questions/8558099/sqlite-query-with-byte-where-clause
|
||||
|
||||
}
|
||||
@@ -22,10 +22,6 @@ public class Pass<T> {
|
||||
//--------------
|
||||
public boolean ui_visible = true;
|
||||
public Vector<PassControl> controls = new Vector<>();
|
||||
public void addControl(PassControl control_in){
|
||||
control_in.setVisible(ui_visible);
|
||||
controls.add(control_in);
|
||||
}
|
||||
public TextLog Log; //внутренний журнал прохода.
|
||||
protected boolean interrupt;
|
||||
protected SwingWorker dispatcher = null;
|
||||
@@ -34,6 +30,10 @@ public class Pass<T> {
|
||||
private JButton button = null;
|
||||
private JButton tabButton = null;
|
||||
private Exception last_error; //последнее пойманное исключение выполнения.
|
||||
public void addControl(PassControl control_in) {
|
||||
control_in.setVisible(ui_visible);
|
||||
controls.add(control_in);
|
||||
}
|
||||
//->>
|
||||
public Throwable getCauseRec(Throwable ex) {
|
||||
Throwable cause = ex.getCause();
|
||||
@@ -79,7 +79,7 @@ public class Pass<T> {
|
||||
control.setEnabled(flag);
|
||||
}
|
||||
public void setControlsVisible(boolean flag) {
|
||||
ui_visible =flag;
|
||||
ui_visible = flag;
|
||||
for (PassControl control : controls)
|
||||
control.setVisible(ui_visible);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,11 @@ import java.util.LinkedHashMap;
|
||||
public class Properties {
|
||||
protected LinkedHashMap<String, JMenuItem> controls = new LinkedHashMap<>();
|
||||
private File file = null; //файл где хранятся настройки.
|
||||
public Properties() {
|
||||
}
|
||||
public Properties(File file_in) {
|
||||
setFile(file_in);
|
||||
}
|
||||
public File getFile() {
|
||||
return file;
|
||||
}
|
||||
@@ -24,11 +29,6 @@ public class Properties {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public Properties() {
|
||||
}
|
||||
public Properties(File file_in) {
|
||||
setFile(file_in);
|
||||
}
|
||||
public boolean updateField(String name, Object newValue) {
|
||||
try {
|
||||
Field field = getClass().getField(name);
|
||||
@@ -50,7 +50,7 @@ public class Properties {
|
||||
return "?";
|
||||
}
|
||||
public boolean controlAction(String fieldName, JMenuItem control
|
||||
){
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
public JMenuItem getMenuItem(String fieldName) {
|
||||
@@ -86,8 +86,8 @@ public class Properties {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void setControlVisible(String settingName, boolean flag){
|
||||
if (controls.containsKey(settingName)){
|
||||
public void setControlVisible(String settingName, boolean flag) {
|
||||
if (controls.containsKey(settingName)) {
|
||||
controls.get(settingName).setVisible(flag);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package Common.Utils;
|
||||
import Common.Visual.UI;
|
||||
import _VisualDVM.Visual.Windows.ReadOnlyMultilineTextForm;
|
||||
import Common.Visual.Windows.ReadOnlyMultilineTextForm;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
|
||||
@@ -2,7 +2,6 @@ package Common.Visual;
|
||||
import Common.CommonConstants;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import Common.Database.Objects.Grid.TableVisualData;
|
||||
import Common.Database.Objects.riDBObject;
|
||||
import Common.Database.Tables.DBTable;
|
||||
import Common.Database.Tables.DataSet;
|
||||
import Common.Database.Tables.FKBehaviour;
|
||||
@@ -15,7 +14,6 @@ import Common.Visual.Menus.TableMenu;
|
||||
import Common.Visual.Tables.*;
|
||||
import Common.Visual.Tables.Grid.GridAnchestor;
|
||||
import Common.Visual.Windows.Dialog.DBObjectDialog;
|
||||
import _VisualDVM.Global;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.TableColumn;
|
||||
@@ -42,8 +40,6 @@ public abstract class DataSetControlForm<D extends DBObject> extends ControlForm
|
||||
//--
|
||||
Object savedCurrentKey = null;
|
||||
Vector<Object> savedSelectedKeys = new Vector<>();
|
||||
//--
|
||||
public DataMenuBar getMenuBar() {return bar;}
|
||||
public DataSetControlForm(DataSet<?, D> dataSource_in, JPanel mountPanel_in) {
|
||||
super(DataTable.class, mountPanel_in);
|
||||
dataSource = dataSource_in;
|
||||
@@ -71,7 +67,7 @@ public abstract class DataSetControlForm<D extends DBObject> extends ControlForm
|
||||
//--
|
||||
counter_ui = (count -> bar.countLabel.setText(String.valueOf(count)));
|
||||
//--фильтры всегда в конец бара.
|
||||
// bar.add(new JSeparator());
|
||||
// bar.add(new JSeparator());
|
||||
for (FilterFlag filter : getFilters(FilterFlag.class)) {
|
||||
bar.add(filter.getControl());
|
||||
}
|
||||
@@ -84,6 +80,10 @@ public abstract class DataSetControlForm<D extends DBObject> extends ControlForm
|
||||
}
|
||||
}
|
||||
}
|
||||
//--
|
||||
public DataMenuBar getMenuBar() {
|
||||
return bar;
|
||||
}
|
||||
protected boolean isPKVisible() {
|
||||
return true;
|
||||
}
|
||||
@@ -575,12 +575,10 @@ public abstract class DataSetControlForm<D extends DBObject> extends ControlForm
|
||||
public PassCode_ getDeletePassCode() {
|
||||
return null;
|
||||
}
|
||||
public Object getCurrentPK(Object nanValue){
|
||||
return current==null? nanValue: current.getPK();
|
||||
public Object getCurrentPK(Object nanValue) {
|
||||
return current == null ? nanValue : current.getPK();
|
||||
}
|
||||
//todo временное решение ? ->>>
|
||||
public boolean canModifyCurrent(TextLog Log){
|
||||
return CheckCurrent(Log) && (
|
||||
!(current instanceof riDBObject) || Global.mainModule.getAccount().CheckAuthorship(((riDBObject)current).sender_address,Log));
|
||||
public boolean canModifyCurrent(TextLog Log) {
|
||||
return CheckCurrent(Log);
|
||||
}
|
||||
}
|
||||
|
||||
145
src/Common/Visual/Editor/BaseEditor.java
Normal file
145
src/Common/Visual/Editor/BaseEditor.java
Normal file
@@ -0,0 +1,145 @@
|
||||
package Common.Visual.Editor;
|
||||
import Common.Utils.Utils_;
|
||||
import Common.Visual.Menus.StyledPopupMenu;
|
||||
import Common.Visual.Menus.TextEditorMenu;
|
||||
import Common.Visual.Themes.ThemeElement;
|
||||
import Common.Visual.UI;
|
||||
import Common.Visual.Windows.Dialog.DialogFields;
|
||||
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
||||
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import javax.swing.event.HyperlinkListener;
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.net.URI;
|
||||
public class BaseEditor extends RSyntaxTextArea implements ThemeElement, DialogFields {
|
||||
protected final StyledPopupMenu menu;
|
||||
// protected int changesCount = 0;
|
||||
// protected int insertsCount = 0;
|
||||
// protected int removesCount = 0;
|
||||
// protected boolean ctrlZ = false;
|
||||
protected String startText = "";
|
||||
private boolean search_enabled = true;
|
||||
public BaseEditor() {
|
||||
setTabSize(6);
|
||||
setPaintTabLines(true);
|
||||
setCodeFoldingEnabled(true);
|
||||
addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if (e.isControlDown()) {
|
||||
switch (e.getKeyCode()) {
|
||||
case KeyEvent.VK_ADD: //num lock +
|
||||
case KeyEvent.VK_EQUALS: //+
|
||||
FontUp();
|
||||
break;
|
||||
case KeyEvent.VK_SUBTRACT: //num lock -
|
||||
case KeyEvent.VK_MINUS: //-
|
||||
FontDown();
|
||||
break;
|
||||
case KeyEvent.VK_S:
|
||||
saveText();
|
||||
break;
|
||||
//todo переход в нужную строку по ctrl+g?
|
||||
case KeyEvent.VK_Z:
|
||||
if (getText().equals(startText)) {
|
||||
UI.Info("Начальная версия текста достигнута.");
|
||||
e.consume();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
setPopupMenu(menu = createMenu());
|
||||
applyTheme();
|
||||
//-
|
||||
this.setHyperlinksEnabled(true);
|
||||
HyperlinkListener listener = new HyperlinkListener() {
|
||||
@Override
|
||||
public void hyperlinkUpdate(HyperlinkEvent event) {
|
||||
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
|
||||
try {
|
||||
Desktop.getDesktop().browse(new URI(event.getURL().toString()));
|
||||
} catch (Exception ioe) {
|
||||
System.err.println("Error loading url from link: " + ioe);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
this.addHyperlinkListener(listener);
|
||||
}
|
||||
@Override
|
||||
public void setText(String t) {
|
||||
super.setText(t);
|
||||
startText = t;
|
||||
}
|
||||
public void setSearchEnabled(boolean f_in) {
|
||||
search_enabled = f_in;
|
||||
}
|
||||
protected StyledPopupMenu createMenu() {
|
||||
return new TextEditorMenu(this);
|
||||
}
|
||||
private void changeFont(int size) {
|
||||
if ((size > 1) && (size < 48)) {
|
||||
setFont(getFont().deriveFont((float) size));
|
||||
saveFont();
|
||||
}
|
||||
}
|
||||
protected void saveFont() {
|
||||
}
|
||||
protected void saveText() {
|
||||
}
|
||||
public void ClearSelection() {
|
||||
setSelectionStart(0);
|
||||
setSelectionEnd(0);
|
||||
}
|
||||
public void gotoLine(int LineNum) {
|
||||
gotoLine_(LineNum - 1);
|
||||
}
|
||||
//без вычитания.
|
||||
public void gotoLine_(int LineNum) {
|
||||
//requestFocus();
|
||||
try {
|
||||
//особеннсть контрола.
|
||||
//нельзя полностью скинуть текущую позицию. пэтому если надо
|
||||
//освежить 0 строку, передергиваем до последней.
|
||||
if (LineNum == 0)
|
||||
setCaretPosition(getLineStartOffset(getLineCount() - 1));
|
||||
ClearSelection();
|
||||
if (LineNum > 0) {
|
||||
setCaretPosition(getLineStartOffset(LineNum));
|
||||
setSelectionStart(getLineStartOffset(LineNum));
|
||||
setSelectionEnd(getLineStartOffset(LineNum));
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Utils_.MainLog.Print("Не удалось перейти на строку " + LineNum);
|
||||
Utils_.MainLog.PrintException(ex);
|
||||
}
|
||||
}
|
||||
//------------------------------------------
|
||||
public void FontUp() {
|
||||
changeFont(getFont().getSize() + 1);
|
||||
}
|
||||
public void FontDown() {
|
||||
changeFont(getFont().getSize() - 1);
|
||||
}
|
||||
@Override
|
||||
public Component getContent() {
|
||||
return this;
|
||||
}
|
||||
public void ShowBegin() {
|
||||
setCaretPosition(0);
|
||||
}
|
||||
public boolean lineIsVisible(int lineNum) {
|
||||
boolean res = false;
|
||||
Rectangle rectangle = this.getVisibleRect();
|
||||
try {
|
||||
res = rectangle.contains(rectangle.x, yForLine(lineNum));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
8
src/Common/Visual/Editor/Viewer.java
Normal file
8
src/Common/Visual/Editor/Viewer.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package Common.Visual.Editor;
|
||||
public class Viewer extends BaseEditor {
|
||||
public Viewer() {
|
||||
setLineWrap(true);
|
||||
setWrapStyleWord(true);
|
||||
setEditable(false);
|
||||
}
|
||||
}
|
||||
@@ -8,12 +8,12 @@ import java.awt.*;
|
||||
import java.awt.event.ActionListener;
|
||||
public class DataMenuBar extends VisualiserMenuBar {
|
||||
public JLabel countLabel = null;
|
||||
private DataSet dataSource = null;
|
||||
//-
|
||||
public ActionListener selectAllListener = null;
|
||||
public ActionListener unselectAllListener = null;
|
||||
JButton selectAllButton = null;
|
||||
JButton unselectAllButton = null;
|
||||
private DataSet dataSource = null;
|
||||
//-
|
||||
public DataMenuBar(String dataName, PassCode_... passes) {
|
||||
add(new JLabel(dataName + " : "));
|
||||
|
||||
@@ -21,7 +21,7 @@ public class TableMenu extends StyledPopupMenu {
|
||||
mcopy.addActionListener(e -> Utils_.CopyToClipboard(target.toString()));
|
||||
add(mcopy);
|
||||
//
|
||||
add(value_scroll= new JScrollPane(value_view = new JTextArea()));
|
||||
add(value_scroll = new JScrollPane(value_view = new JTextArea()));
|
||||
value_view.setEditable(false);
|
||||
//value_view.setLineWrap(true);
|
||||
//value_view.setWrapStyleWord(true);
|
||||
@@ -33,13 +33,13 @@ public class TableMenu extends StyledPopupMenu {
|
||||
if ((row >= 0) && (column >= 0)) {
|
||||
target = owner.getValueAt(row, column);
|
||||
mcopy.setVisible(true);
|
||||
Dimension d= new Dimension(Math.max(mcopy.getWidth(), 300),100);
|
||||
Dimension d = new Dimension(Math.max(mcopy.getWidth(), 300), 100);
|
||||
value_view.setVisible(true);
|
||||
String res = target.toString();
|
||||
if (target instanceof Vector){
|
||||
if (target instanceof Vector) {
|
||||
Vector<Object> v = (Vector<Object>) target;
|
||||
Vector<String> res_ = new Vector<>();
|
||||
for (Object o: v){
|
||||
for (Object o : v) {
|
||||
res_.add(o.toString());
|
||||
}
|
||||
res = String.join("\n", res_);
|
||||
|
||||
@@ -21,8 +21,8 @@ public class VisualiserMenuBar extends JToolBar {
|
||||
}
|
||||
}
|
||||
}
|
||||
public void addPasses(Pass...passes){
|
||||
for (Pass pass: passes)
|
||||
public void addPasses(Pass... passes) {
|
||||
for (Pass pass : passes)
|
||||
add(pass.createButton());
|
||||
}
|
||||
public JMenuBar addMenus(JMenu... menus) {
|
||||
|
||||
@@ -18,26 +18,26 @@ public class HeaderTextFilter<D extends DBObject> implements DBObjectFilter_<D>
|
||||
int columnIndex = CommonConstants.Nan; //номер столбца к которому привязан фильтр.
|
||||
JTextField textField = null;
|
||||
JPopupMenu popup = null;
|
||||
boolean contains = true;
|
||||
private String filterValue = "";
|
||||
private int offset = 0;
|
||||
boolean contains = true;
|
||||
//при одиночном клике, показать поверх заголовка столбца выпавшее меню с полем фильтра.
|
||||
public HeaderTextFilter(DataSet dataSet_in, int columnIndex_in, int offset_in, boolean contains_in) {
|
||||
dataSet = dataSet_in;
|
||||
columnIndex = columnIndex_in;
|
||||
offset = offset_in;
|
||||
contains=contains_in;
|
||||
contains = contains_in;
|
||||
}
|
||||
public HeaderTextFilter(DataSet dataSet_in, int columnIndex_in, int offset_in) {
|
||||
this(dataSet_in,columnIndex_in,offset_in, true);
|
||||
this(dataSet_in, columnIndex_in, offset_in, true);
|
||||
}
|
||||
@Override
|
||||
public boolean Validate(D object) {
|
||||
Object field = dataSet.getUI().getColumnInfo(columnIndex).getFieldAt(object);
|
||||
if (field instanceof String){
|
||||
String s = field.toString().toLowerCase();
|
||||
return contains?s.contains(filterValue):
|
||||
(filterValue.isEmpty()||s.equals(filterValue)) || (filterValue.trim().isEmpty()&&s.isEmpty());
|
||||
if (field instanceof String) {
|
||||
String s = field.toString().toLowerCase();
|
||||
return contains ? s.contains(filterValue) :
|
||||
(filterValue.isEmpty() || s.equals(filterValue)) || (filterValue.trim().isEmpty() && s.isEmpty());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
package Common.Visual.Tables;
|
||||
import Common.MainModule_;
|
||||
import Common.Utils.Utils_;
|
||||
import Common.Visual.Fonts.VisualiserFonts;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.Date;
|
||||
public class RendererMilliseconds extends RendererCell<Long>{
|
||||
public class RendererMilliseconds extends RendererCell<Long> {
|
||||
@Override
|
||||
public Long Init(JTable table, Object value, int row, int column) {
|
||||
return (Long) value;
|
||||
|
||||
@@ -4,5 +4,7 @@ public interface ThemeElement {
|
||||
}
|
||||
default void FontDown() {
|
||||
}
|
||||
void applyTheme();
|
||||
default void applyTheme() {
|
||||
}
|
||||
;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,6 @@ public class TreeForm<C extends StyledTree> extends ControlForm<C> {
|
||||
}
|
||||
@Override
|
||||
protected void redrawControl() {
|
||||
((DefaultTreeModel)getTree().getModel()).reload();
|
||||
((DefaultTreeModel) getTree().getModel()).reload();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ public class Dialog<T, F extends DialogFields> extends JDialog implements ThemeE
|
||||
}
|
||||
getContentPane().add(buttonsPane, BorderLayout.SOUTH);
|
||||
}
|
||||
public void BlockButtons(){
|
||||
public void BlockButtons() {
|
||||
btnOK.setVisible(false);
|
||||
btnCancel.setVisible(false);
|
||||
}
|
||||
|
||||
26
src/Common/Visual/Windows/MultilineTextForm.java
Normal file
26
src/Common/Visual/Windows/MultilineTextForm.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package Common.Visual.Windows;
|
||||
import Common.Visual.Editor.BaseEditor;
|
||||
import Common.Visual.Windows.Dialog.Text.TextDialog;
|
||||
public class MultilineTextForm extends TextDialog<BaseEditor> {
|
||||
public MultilineTextForm() {
|
||||
super(BaseEditor.class);
|
||||
}
|
||||
//при наследовании по умолчанию поля не присваивать!
|
||||
//инициализация полей работает после конструктора предка!!
|
||||
@Override
|
||||
public void ProcessResult() {
|
||||
Result = fields.getText();
|
||||
}
|
||||
@Override
|
||||
public void InitFields() {
|
||||
fields.setSearchEnabled(false);
|
||||
fields.setLineWrap(true);
|
||||
fields.setWrapStyleWord(true);
|
||||
fields.setHighlightCurrentLine(false);
|
||||
}
|
||||
@Override
|
||||
public void setText(String text_in) {
|
||||
fields.setText(text_in);
|
||||
fields.setCaretPosition(0);
|
||||
}
|
||||
}
|
||||
12
src/Common/Visual/Windows/ReadOnlyMultilineTextForm.java
Normal file
12
src/Common/Visual/Windows/ReadOnlyMultilineTextForm.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package Common.Visual.Windows;
|
||||
public class ReadOnlyMultilineTextForm extends MultilineTextForm {
|
||||
public ReadOnlyMultilineTextForm() {
|
||||
}
|
||||
@Override
|
||||
public void InitFields() {
|
||||
fields.setEditable(false);
|
||||
}
|
||||
@Override
|
||||
public void CreateButtons() {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user