no message
This commit is contained in:
111
src/_VisualDVM/Visual/Windows/VersionsComparisonForm.java
Normal file
111
src/_VisualDVM/Visual/Windows/VersionsComparisonForm.java
Normal file
@@ -0,0 +1,111 @@
|
||||
package _VisualDVM.Visual.Windows;
|
||||
import Common.Utils.CommonUtils;
|
||||
import _VisualDVM.Current;
|
||||
import _VisualDVM.Utils;
|
||||
import GlobalData.GlobalDatabase;
|
||||
import GlobalData.Settings.SettingName;
|
||||
import ProjectData.Files.DBProjectFile;
|
||||
import ProjectData.Files.ProjectFile;
|
||||
import ProjectData.Project.db_project_info;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.Vector;
|
||||
public class VersionsComparisonForm extends ComparisonForm<db_project_info> {
|
||||
private final JComboBox<DBProjectFile> cbFile;
|
||||
protected DBProjectFile file = null;
|
||||
private VersionsComparisonForm getMaster() {
|
||||
return (VersionsComparisonForm) master;
|
||||
}
|
||||
private VersionsComparisonForm getSlave() {
|
||||
return (VersionsComparisonForm) slave;
|
||||
}
|
||||
public VersionsComparisonForm(VersionsComparisonForm slave_in) {
|
||||
super(db_project_info.class, slave_in);
|
||||
cbFile = new JComboBox<>();
|
||||
tools.add(cbFile, 3);
|
||||
file = (cbFile.getSelectedItem() instanceof DBProjectFile) ?
|
||||
((DBProjectFile) cbFile.getSelectedItem()) : null;
|
||||
cbFile.addActionListener(e -> {
|
||||
file = (cbFile.getSelectedItem() instanceof DBProjectFile) ?
|
||||
((DBProjectFile) cbFile.getSelectedItem()) : null;
|
||||
//-->>
|
||||
if (isMaster()) {
|
||||
if (isReady() && !getSlave().selectSameFile(file))
|
||||
DoShowPass(true);
|
||||
} else {
|
||||
if (isReady()) {
|
||||
if (getMaster().isReady()) {
|
||||
boolean ExtensionsOn = ((GlobalDatabase)CommonUtils.db).settings.get(SettingName.ExtensionsOn).toBoolean();
|
||||
String name1 = ExtensionsOn ? getMaster().file.file.getName() : CommonUtils.getFileNameWithoutExtension(getMaster().file.file);
|
||||
String name2 = ExtensionsOn ? file.file.getName() : CommonUtils.getFileNameWithoutExtension(file.file);
|
||||
if (((GlobalDatabase)CommonUtils.db).settings.get(SettingName.ComparsionDiffMergeOn).toBoolean()) {
|
||||
if (name1.equalsIgnoreCase(name2))
|
||||
master.DoComparePass(true);
|
||||
} else
|
||||
master.DoShowPass(true);
|
||||
} else {
|
||||
master.DoShowPass(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
protected Current getCurrentObjectName() {
|
||||
return Current.Version;
|
||||
}
|
||||
@Override
|
||||
protected String getText() {
|
||||
return isReady() ? Utils.ReadAllText(file.file) : "объект не назначен";
|
||||
}
|
||||
@Override
|
||||
protected void removeObject() {
|
||||
cbFile.removeAllItems();
|
||||
file = null;
|
||||
}
|
||||
@Override
|
||||
public boolean isReady() {
|
||||
return super.isReady() && file != null;
|
||||
}
|
||||
@Override
|
||||
protected void showObject() {
|
||||
lObjectName.setText(object.name);
|
||||
lObjectName.setToolTipText(
|
||||
object.getVersionTooltip()
|
||||
);
|
||||
cbFile.removeAllItems();
|
||||
Vector<DBProjectFile> files = object.getFilesForComparsion();
|
||||
for (DBProjectFile file : files)
|
||||
cbFile.addItem(file);
|
||||
}
|
||||
public boolean selectSameFile(ProjectFile file_in) {
|
||||
file = null;
|
||||
cbFile.setSelectedIndex(-1);
|
||||
for (int i = 0; i < cbFile.getItemCount(); ++i) {
|
||||
ProjectFile projectFile = cbFile.getItemAt(i);
|
||||
if (((GlobalDatabase)CommonUtils.db).settings.get(SettingName.ExtensionsOn).toBoolean()) {
|
||||
//если учитываем расширения, ищем полное совпадение
|
||||
if (projectFile.file.getName().equals(file_in.file.getName())) {
|
||||
cbFile.setSelectedIndex(i);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (CommonUtils.getNameWithoutExtension(projectFile.file.getName()).equals(
|
||||
CommonUtils.getNameWithoutExtension(file_in.file.getName()))) {
|
||||
cbFile.setSelectedIndex(i);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return (cbFile.getSelectedItem() != null) && (cbFile.getSelectedItem() instanceof ProjectFile);
|
||||
}
|
||||
public void CheckVersion(db_project_info version_in) {
|
||||
if ((object != null) && version_in.Home.equals(object.Home)) {
|
||||
RemoveObject();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected boolean fortranWrapsOn() {
|
||||
return ((GlobalDatabase)CommonUtils.db).settings.get(SettingName.FortranWrapsOn).toBoolean();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user