рефакторинг. переносил текущие объекты в другое место
This commit is contained in:
@@ -7,26 +7,4 @@ public interface Current_ {
|
||||
default String getDescription(){
|
||||
return "?";
|
||||
}
|
||||
LinkedHashMap<Current_, Object> objects = new LinkedHashMap<>();
|
||||
static Object get(Current_ name) {
|
||||
if (!objects.containsKey(name))
|
||||
objects.put(name,null);
|
||||
return objects.get(name);
|
||||
}
|
||||
static Object set(Current_ name, Object object) {
|
||||
if (objects.containsKey(name))
|
||||
objects.replace(name, object);
|
||||
else objects.put(name, object);
|
||||
return object;
|
||||
}
|
||||
static boolean Check(TextLog Log, Current_... names) {
|
||||
for (Current_ name : names)
|
||||
if (Current_.get(name) == null)
|
||||
Log.Writeln_(name.getDescription() + " не выбран(а)");
|
||||
return Log.isEmpty();
|
||||
}
|
||||
//применять только для наследников iDBObject
|
||||
static boolean matchCurrentID(Current_ name, int id) {
|
||||
return (Current_.get(name) != null) && (((iDBObject) Current_.get(name)).id == id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import Common.Utils.TextLog;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import Common.Visual.UI_;
|
||||
import Common.Visual.FilterInterface;
|
||||
import _VisualDVM.Global;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -244,19 +245,19 @@ public class DataSet<K, D extends DBObject> extends DataSetAnchestor {
|
||||
return null;
|
||||
}
|
||||
public boolean CheckCurrent(TextLog log) {
|
||||
return Current_.Check(log, CurrentName());
|
||||
return Global.mainModule.Check(log, CurrentName());
|
||||
}
|
||||
public boolean hasCurrent() {
|
||||
return Current_.get(CurrentName()) != null;
|
||||
return Global.mainModule.get(CurrentName()) != null;
|
||||
}
|
||||
public void dropCurrent() {
|
||||
Current_.set(CurrentName(), null);
|
||||
Global.mainModule.set(CurrentName(), null);
|
||||
}
|
||||
public D getCurrent() {
|
||||
return (D) Current_.get(CurrentName());
|
||||
return (D) Global.mainModule.get(CurrentName());
|
||||
}
|
||||
public void setCurrent(D o) {
|
||||
Current_.set(CurrentName(), o);
|
||||
Global.mainModule.set(CurrentName(), o);
|
||||
}
|
||||
public Vector<D> getCheckedOrCurrent() {
|
||||
Vector<D> res = new Vector<>();
|
||||
|
||||
@@ -130,7 +130,7 @@ public class Pass<T> {
|
||||
try {
|
||||
Global.mainModule.getDb().Update(stats);
|
||||
FAPasses.sort(new SortPassesByStats());
|
||||
if (Current.HasProject())
|
||||
if (Global.mainModule.HasProject())
|
||||
UI.fastAccessMenuBar.Refresh();
|
||||
} catch (Exception ex) {
|
||||
Utils_.MainLog.PrintException(ex);
|
||||
@@ -306,10 +306,10 @@ public class Pass<T> {
|
||||
animation_sem.acquire();
|
||||
//---
|
||||
form = null;
|
||||
Current_.set(Current.PassForm, null);
|
||||
Global.mainModule.set(Current.PassForm, null);
|
||||
System.gc();
|
||||
//--
|
||||
Current_.set(Current.PassForm, form = new PassForm(this));
|
||||
Global.mainModule.set(Current.PassForm, form = new PassForm(this));
|
||||
dispatcher = new SwingWorker() {
|
||||
@Override
|
||||
protected Object doInBackground() {
|
||||
|
||||
@@ -2,6 +2,7 @@ package Common.Visual.Trees;
|
||||
import Common.Current_;
|
||||
import Common.Utils.Utils_;
|
||||
import Common.Visual.DataControl_OLD;
|
||||
import _VisualDVM.Global;
|
||||
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.TreePath;
|
||||
@@ -11,7 +12,7 @@ public class DataTree extends StyledTree implements DataControl_OLD {
|
||||
}
|
||||
public void ChangeCurrentObject(DefaultMutableTreeNode node) {
|
||||
if (getCurrent() != null)
|
||||
Current_.set(getCurrent(), node.getUserObject());
|
||||
Global.mainModule.set(getCurrent(), node.getUserObject());
|
||||
}
|
||||
@Override
|
||||
public void ShowCurrentObject() throws Exception {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package Common.Visual.Trees;
|
||||
import Common.Current_;
|
||||
import Common.Visual.Selectable;
|
||||
import _VisualDVM.Global;
|
||||
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
public class SelectableTree extends DataTree {
|
||||
@@ -9,7 +10,7 @@ public class SelectableTree extends DataTree {
|
||||
}
|
||||
@Override
|
||||
public void LeftMouseAction1() {
|
||||
Object element = Current_.get(getCurrent());
|
||||
Object element = Global.mainModule.get(getCurrent());
|
||||
if ((element instanceof Selectable)) {
|
||||
((Selectable) element).SwitchSelection();
|
||||
updateUI();
|
||||
|
||||
Reference in New Issue
Block a user