рефакторин методов связанных с компонентами.
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ public class ComponentsFields implements DialogFields {
|
||||
public JPanel content;
|
||||
private JPanel componentsPanel;
|
||||
public ComponentsFields() {
|
||||
Global.Components.mountUI(componentsPanel);
|
||||
Global.components.mountUI(componentsPanel);
|
||||
}
|
||||
@Override
|
||||
public Component getContent() {
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
package _VisualDVM.Repository.Component.UI;
|
||||
import Common.Visual.Windows.Dialog.Dialog;
|
||||
import _VisualDVM.Global;
|
||||
|
||||
import java.awt.*;
|
||||
public class ComponentsWindow extends Dialog<Object, ComponentsFields> {
|
||||
public ComponentsWindow() {
|
||||
super(ComponentsFields.class);
|
||||
}
|
||||
@Override
|
||||
public boolean NeedsScroll() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public int getDefaultWidth() {
|
||||
return Global.properties.ComponentsWindowWidth;
|
||||
}
|
||||
@Override
|
||||
public int getDefaultHeight() {
|
||||
return Global.properties.ComponentsWindowHeight;
|
||||
}
|
||||
@Override
|
||||
public void CreateButtons() {
|
||||
}
|
||||
@Override
|
||||
public void Init(Object... params) {
|
||||
Global.Components.ShowUI();
|
||||
}
|
||||
@Override
|
||||
public void LoadSize() {
|
||||
setMinimumSize(new Dimension(650, 250));
|
||||
Dimension dimension = new Dimension(getDefaultWidth(), getDefaultHeight());
|
||||
setPreferredSize(dimension);
|
||||
setSize(dimension);
|
||||
}
|
||||
@Override
|
||||
public void onClose() {
|
||||
super.onClose();
|
||||
Global.properties.ComponentsWindowWidth = getWidth();
|
||||
Global.properties.ComponentsWindowHeight = getHeight();
|
||||
Global.properties.Update();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user