рефакторин методов связанных с компонентами.
This commit is contained in:
@@ -1,10 +1,21 @@
|
||||
package _VisualDVM.Repository.Component;
|
||||
import Common.Database.Tables.DataSet;
|
||||
import Common.Visual.DataSetControlForm;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.Repository.Component.UI.ComponentsForm;
|
||||
|
||||
import javax.swing.*;
|
||||
public class ComponentsSet extends DataSet<ComponentType, Component> {
|
||||
public boolean bad_state = false;
|
||||
public boolean need_update = false;
|
||||
public boolean need_publish = false;
|
||||
public boolean needWindow() {
|
||||
return bad_state || need_update;
|
||||
}
|
||||
public String getButtonIconPath() {
|
||||
return needWindow() ? "/icons/ComponentsNeedUpdate.gif"
|
||||
: (need_publish ? "/icons/ComponentsNeedPublish_2023.gif" : "/icons/ComponentsActual.png");
|
||||
}
|
||||
public ComponentsSet() {
|
||||
super(ComponentType.class, Component.class);
|
||||
}
|
||||
@@ -20,4 +31,38 @@ public class ComponentsSet extends DataSet<ComponentType, Component> {
|
||||
protected DataSetControlForm createUI(JPanel mountPanel) {
|
||||
return new ComponentsForm(this, mountPanel);
|
||||
}
|
||||
//--
|
||||
public void RefreshUpdatesStatus() {
|
||||
if (getUI() != null)
|
||||
getUI().Refresh();
|
||||
validateStates();
|
||||
if (Global.mainModule.getUI().hasMainWindow())
|
||||
Global.mainModule.getUI().getMainWindow().ShowUpdatesIcon();
|
||||
}
|
||||
public boolean validateStates() {
|
||||
bad_state = need_update = need_publish = false;
|
||||
for (Component component : Data.values()) {
|
||||
switch (component.getState()) {
|
||||
case Not_found:
|
||||
case Unknown_version:
|
||||
case Old_version:
|
||||
if (component.isNecessary())
|
||||
bad_state = true;
|
||||
component.Select(true);
|
||||
break;
|
||||
case Needs_update:
|
||||
need_update = true;
|
||||
component.Select(true);
|
||||
break;
|
||||
case Needs_publish:
|
||||
need_publish = true;
|
||||
break;
|
||||
default:
|
||||
component.Select(false);
|
||||
break;
|
||||
}
|
||||
// }
|
||||
}
|
||||
return !bad_state;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user