промежуточный. частичный рефакторинг с прицелом на библиотечную часть
This commit is contained in:
499
src/Common_old/Constants.java
Normal file
499
src/Common_old/Constants.java
Normal file
@@ -0,0 +1,499 @@
|
||||
package Common_old;
|
||||
import Common.Utils.Vector_;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
|
||||
import java.util.Vector;
|
||||
import java.util.regex.Pattern;
|
||||
public class Constants {
|
||||
public static final int Nan = -1;
|
||||
public static final int planner_version = 3;
|
||||
//--
|
||||
public static final String ComponentsDirectoryName = "Components";
|
||||
public static final String DataDirectoryName = "Data";
|
||||
public static final String BugsDirectoryName = "Bugs";
|
||||
public static final String BackUpsDirectoryName = "BackUps";
|
||||
public static final String DataBackUpsDirectoryName = "DataBackUps";
|
||||
public static final String TempDirectoryName = "Temp";
|
||||
public static final String ProjectsDirectoryName = "Projects";
|
||||
public static final String CompilationTasksDirectoryName = "CompilationTasks";
|
||||
public static final String RunTasksDirectoryName = "RunTasks";
|
||||
public static final String StsDirectoryName = "Sts";
|
||||
public static final String RepoDirectoryName = "Repo";
|
||||
public static final String TestsDirectoryName = "Tests";
|
||||
public static final String DVMPackagesDirectoryName = "DVMPackages";
|
||||
public static final String PerformanceAnalyzerDirectoryName = "PerformanceAnalyzer";
|
||||
//--
|
||||
//SVN vmk-post@yandex.ru
|
||||
public static final String REPOSITORY_AUTHENTICATION = "--username dvmhuser --password dvmh2013 --non-interactive";
|
||||
public static final String DVM_REPOSITORY = "http://svn.dvm-system.org/svn/dvmhrepo/dvm";
|
||||
public static final String SAPFOR_REPOSITORY = "http://svn.dvm-system.org/svn/dvmhrepo/sapfor";
|
||||
public static final String SAPFOR_REPOSITORY_BIN = "/sapfor/experts/Sapfor_2017/_bin";
|
||||
//--
|
||||
//-файлы-признаки
|
||||
public static final String LOADED = "LOADED";
|
||||
public static final String STARTED = "STARTED";
|
||||
public static final String ABORTED = "ABORTED";
|
||||
public static final String INTERRUPT = "INTERRUPT"; //файл признак прерывания.
|
||||
public final static String DONE = "DONE";
|
||||
public final static String TIMEOUT = "TIMEOUT";
|
||||
//-вывод задач
|
||||
public final static String parse_out_file = "parse_out.txt";
|
||||
public final static String parse_err_file = "parse_err.txt";
|
||||
public final static String out_file = "out.txt";
|
||||
public final static String err_file = "err.txt";
|
||||
public final static String script = "script.sh";
|
||||
public final static String time_file = "total_time";
|
||||
//-служебные разделы проекта.
|
||||
public static final String data = "visualiser_data";
|
||||
public static final String MailAddress = "sapfor.tracker@internet.ru";
|
||||
// public static final String MailPassword = "3s4w9e5fs3c1a89AA"; основной пароль.
|
||||
public static final String MailPassword = "knKn2PpfrC348ZxHtMnT"; //пароль для сапфора как внешнего приложения.
|
||||
//--
|
||||
public static final String package_json = "package_json";
|
||||
public static final String results_json = "results_json";
|
||||
//--
|
||||
public static final PassCode_2021[] startingSapforTestingCodes_old = new PassCode_2021[]{
|
||||
PassCode_2021.SPF_InsertIncludesPass
|
||||
};
|
||||
public static final PassCode_2021[] terminalSapforTestingCodes_old = new PassCode_2021[]{
|
||||
PassCode_2021.CreateParallelVariants,
|
||||
PassCode_2021.SPF_SharedMemoryParallelization,
|
||||
PassCode_2021.SPF_InsertDvmhRegions
|
||||
};
|
||||
//--
|
||||
public static final Vector<PassCode_2021> startSapforCodes =
|
||||
new Vector_<>(PassCode_2021.SPF_InsertIncludesPass);
|
||||
|
||||
public static final Vector<PassCode_2021> terminalSapforCodes =
|
||||
new Vector_<>( PassCode_2021.CreateParallelVariants,
|
||||
PassCode_2021.SPF_SharedMemoryParallelization,
|
||||
PassCode_2021.SPF_InsertDvmhRegions);
|
||||
//---
|
||||
public static final int parser_group = -1;
|
||||
public static final int compiler_group = -2;
|
||||
// DBProjectFile
|
||||
public static final String no_data = "Нет данных";
|
||||
public static final String dep = ".dep";
|
||||
public static final String out = ".out";
|
||||
public static final String err = ".err";
|
||||
public static final String makefile = "Makefile";
|
||||
//db_project_info
|
||||
public static final String launch_script_name = "run";
|
||||
public static final String default_binary_name = "0";
|
||||
public static final String spf = "spf.proj";
|
||||
public static final String options = "options";
|
||||
public static final String gcov = "gcov";
|
||||
public static final String attachments = "attachments";
|
||||
public static final String statistic = "statistic";
|
||||
public static final String unknown_metric = " — ";
|
||||
public static final String old_tests_db_name = "tests2026";
|
||||
public static final String tests_db_name = "tests2027";
|
||||
public static final String dateNaN = "NaN";
|
||||
//------
|
||||
public static final String[] crushed_cases = new String[]{
|
||||
"rts err",
|
||||
"rts stack trace",
|
||||
"rts fatal err",
|
||||
"sigegv",
|
||||
"there are not enough slots available in the system to satisfy the",
|
||||
"forrtl: severe",
|
||||
"invalid pointer",
|
||||
"forrtl: error",
|
||||
"fatal error",
|
||||
"unknown error class",
|
||||
"failed",
|
||||
"killed by signal",
|
||||
"bad termination"
|
||||
};
|
||||
//-------------------------------------------------------
|
||||
public static String[] resourses_names = new String[]{
|
||||
//--
|
||||
"Process_r.h",
|
||||
"starter.cpp",
|
||||
"launcher.cpp",
|
||||
//--
|
||||
"Array.h",
|
||||
"CompilationSupervisor.h",
|
||||
"CompilationTask.h",
|
||||
"File.h",
|
||||
"Global.h",
|
||||
"planner.cpp",
|
||||
"RunSupervisor.h",
|
||||
"RunTask.h",
|
||||
"String.h",
|
||||
"Supervisor.h",
|
||||
"Task.h",
|
||||
"Text.h",
|
||||
"Utils.h",
|
||||
"version.h"
|
||||
|
||||
};
|
||||
//пробный коммит. изменение комментария.++
|
||||
//кронтаб и перезагрузка
|
||||
//https://snipp.ru/raznoe/crontab
|
||||
// /var/spool/cron/crontabs/testuser что менять
|
||||
//https://saribzhanov.ru/tehno/perezagruzka-ubuntu-po-cron/ //раз в сутки
|
||||
//testuser ALL=NOPASSWD:/sbin/reboot
|
||||
//0 2 2,15 * * reboot &>/var/log/reboot.log
|
||||
//https://unix.stackexchange.com/questions/117148/how-can-i-run-reboot-as-a-normal-user-without-needing-to-enter-a-password
|
||||
//--
|
||||
//https://losst.ru/komandy-terminala-linux
|
||||
public static String[] linux_system_commands = new String[]{
|
||||
//<editor-fold desc="все линуксовые команды. их МНОГО">
|
||||
"a2p",
|
||||
"ac",
|
||||
"addgroup",
|
||||
"adduser",
|
||||
"agrep",
|
||||
"alias",
|
||||
"apropos",
|
||||
"apt",
|
||||
"aptitude",
|
||||
"ar",
|
||||
"arch",
|
||||
"arp",
|
||||
"as",
|
||||
"aspell",
|
||||
"at",
|
||||
"awk",
|
||||
"basename",
|
||||
"bash",
|
||||
"bс",
|
||||
"bdiff",
|
||||
"bfs",
|
||||
"bg",
|
||||
"biff",
|
||||
"break",
|
||||
"bs",
|
||||
"bye",
|
||||
"cal",
|
||||
"calendar",
|
||||
"cancel",
|
||||
"cat",
|
||||
"cc",
|
||||
"cd",
|
||||
"cfdisk",
|
||||
"chdir",
|
||||
"checkeq",
|
||||
"checknr",
|
||||
"chfn",
|
||||
"chgrp",
|
||||
"chmod",
|
||||
"chown",
|
||||
"chroot",
|
||||
"chsh",
|
||||
"cksum",
|
||||
"clear",
|
||||
"cmp",
|
||||
"col",
|
||||
"comm",
|
||||
"compress",
|
||||
"continue",
|
||||
"cp",
|
||||
"cpio",
|
||||
"crontab",
|
||||
"csh",
|
||||
"csplit",
|
||||
"ctags",
|
||||
"cu",
|
||||
"curl",
|
||||
"cut",
|
||||
"date",
|
||||
"dc",
|
||||
"dd",
|
||||
"delgroup",
|
||||
"deluser",
|
||||
"depmod",
|
||||
"deroff",
|
||||
"df",
|
||||
"dhclient",
|
||||
"dig",
|
||||
"dircmp",
|
||||
"dirname",
|
||||
"dmesg",
|
||||
"dos2unix",
|
||||
"dpkg",
|
||||
"dpost",
|
||||
"du",
|
||||
"echo",
|
||||
"ed",
|
||||
"edit",
|
||||
"egrep",
|
||||
"eject",
|
||||
"elm",
|
||||
"emacs",
|
||||
"emerge",
|
||||
"enable",
|
||||
"env",
|
||||
"eqn",
|
||||
"ex",
|
||||
"exit",
|
||||
"expand",
|
||||
"expr",
|
||||
"fc",
|
||||
"fdisk",
|
||||
"fg",
|
||||
"fgrep",
|
||||
"file",
|
||||
"find",
|
||||
"findsmb",
|
||||
"finger",
|
||||
"fmt",
|
||||
"fold",
|
||||
"for",
|
||||
"foreach",
|
||||
"free",
|
||||
"fsck",
|
||||
"ftp",
|
||||
"fuser",
|
||||
"gawk",
|
||||
"getfacl",
|
||||
"gpasswd",
|
||||
"gprof",
|
||||
"grep",
|
||||
"groupadd",
|
||||
"groupdel",
|
||||
"groupmod",
|
||||
"gnuzip",
|
||||
"gview",
|
||||
"gvim",
|
||||
"gzip",
|
||||
"halt",
|
||||
"head",
|
||||
"help",
|
||||
"history",
|
||||
"host",
|
||||
"hostid",
|
||||
"hostname",
|
||||
"htop",
|
||||
"id",
|
||||
"ifconfig",
|
||||
"ifdown",
|
||||
"ifquery",
|
||||
"ifup",
|
||||
"info",
|
||||
"insmod",
|
||||
"iostat",
|
||||
"ip",
|
||||
"iwconfig",
|
||||
"jobs",
|
||||
"join",
|
||||
"kill",
|
||||
"killall",
|
||||
"ksh",
|
||||
"last",
|
||||
"ld",
|
||||
"ldd",
|
||||
"less",
|
||||
"link",
|
||||
"ln",
|
||||
"lo",
|
||||
"locate",
|
||||
"login",
|
||||
"logname",
|
||||
"logout",
|
||||
"losetup",
|
||||
"ls",
|
||||
"lsmod",
|
||||
"lsof",
|
||||
"lzcat",
|
||||
"lzma",
|
||||
"mach",
|
||||
"mailx",
|
||||
"make",
|
||||
"man",
|
||||
"merge",
|
||||
"mesg",
|
||||
"mkdir",
|
||||
"mkfs",
|
||||
"mkswap",
|
||||
"modinfo",
|
||||
"modprobe",
|
||||
"more",
|
||||
"mount",
|
||||
"mt",
|
||||
"mv",
|
||||
"mysql",
|
||||
"mysqldump",
|
||||
"nc",
|
||||
"netstat",
|
||||
"newgrp",
|
||||
"nice",
|
||||
"niscat",
|
||||
"nischmod",
|
||||
"nischown",
|
||||
"nischttl",
|
||||
"nisdefaults",
|
||||
"nistbladm",
|
||||
"nl",
|
||||
"nmap",
|
||||
"nohup",
|
||||
"nroff",
|
||||
"nslookup",
|
||||
"od",
|
||||
"on",
|
||||
"onintr",
|
||||
"pack",
|
||||
"pacman",
|
||||
"pagesize",
|
||||
"parted",
|
||||
"partprobe",
|
||||
"passwd",
|
||||
"paste",
|
||||
"pax",
|
||||
"pact",
|
||||
"perl",
|
||||
"pg",
|
||||
"pico",
|
||||
"pine",
|
||||
"pkill",
|
||||
"poweroff",
|
||||
"pr",
|
||||
"printenv",
|
||||
"printf",
|
||||
"ps",
|
||||
"pstree",
|
||||
"pvs",
|
||||
"pwd",
|
||||
"quit",
|
||||
"rcp",
|
||||
"readlink",
|
||||
"reboot",
|
||||
"red",
|
||||
"rename",
|
||||
"repeat",
|
||||
"replace",
|
||||
"rlogin",
|
||||
"rm",
|
||||
"rmdir",
|
||||
"rmmod",
|
||||
"route",
|
||||
"rpcinfo",
|
||||
"rsh",
|
||||
"rsync",
|
||||
"s2p",
|
||||
"scp",
|
||||
"screen",
|
||||
"script",
|
||||
"sdiff",
|
||||
"sed",
|
||||
"sendmail",
|
||||
"service",
|
||||
"set",
|
||||
"setfacl",
|
||||
"sfdisk",
|
||||
"sftp",
|
||||
"sh",
|
||||
"shred",
|
||||
"shutdown",
|
||||
"sleep",
|
||||
"slogin",
|
||||
"smbclient",
|
||||
"sort",
|
||||
"spell",
|
||||
"split",
|
||||
"startx",
|
||||
"ss",
|
||||
"ssh",
|
||||
"stat",
|
||||
"stop",
|
||||
"strftime",
|
||||
"strip",
|
||||
"stty",
|
||||
"su",
|
||||
"sudo",
|
||||
"swapoff",
|
||||
"swapon",
|
||||
"systemctl",
|
||||
"tabs",
|
||||
"tac",
|
||||
"tail",
|
||||
"talk",
|
||||
"tar",
|
||||
"tcopy",
|
||||
"tcpdump",
|
||||
"tcsh",
|
||||
"tee",
|
||||
"telnet",
|
||||
"test",
|
||||
"time",
|
||||
"timex",
|
||||
"todos",
|
||||
"top",
|
||||
"touch",
|
||||
"traceroute",
|
||||
"tree",
|
||||
"tty",
|
||||
"umask",
|
||||
"umount",
|
||||
"unalias",
|
||||
"uname",
|
||||
"uncompress",
|
||||
"uniq",
|
||||
"unlink",
|
||||
"unlzma",
|
||||
"unpack",
|
||||
"until",
|
||||
"unxz",
|
||||
"unzip",
|
||||
"uptime",
|
||||
"useradd",
|
||||
"userdel",
|
||||
"usermod",
|
||||
"vacation",
|
||||
"vi",
|
||||
"vim",
|
||||
"w",
|
||||
"wait",
|
||||
"wall",
|
||||
"wc",
|
||||
"wget",
|
||||
"whereis",
|
||||
"which",
|
||||
"while",
|
||||
"who",
|
||||
"whoami",
|
||||
"whois",
|
||||
"Xorg",
|
||||
"xargs",
|
||||
"xfd",
|
||||
"xhost",
|
||||
"xlsfonts",
|
||||
"xrdb",
|
||||
"xset",
|
||||
"xz",
|
||||
"xzcat",
|
||||
"yacc",
|
||||
"yes",
|
||||
"yppasswd",
|
||||
"yum",
|
||||
"zcat",
|
||||
"zipcloack",
|
||||
"zipinfo",
|
||||
"zipnote",
|
||||
"zipsplit",
|
||||
"zypper"
|
||||
//</editor-fold>
|
||||
};
|
||||
public static char toStrike = (char) 822;
|
||||
public static char boop = (char) 7;
|
||||
public static final Pattern VALID_EMAIL_ADDRESS_REGEX =
|
||||
Pattern.compile("^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,6}$", Pattern.CASE_INSENSITIVE);
|
||||
public static char[] forbidden_file_name_characters = new char[]{
|
||||
'#', '%', '&', '{', '}',
|
||||
'<', '>', '*', '?', '!',
|
||||
'$', '\'', '\"', '@', '+',
|
||||
'`', '|', '=', '#', ':', '/', '\\',
|
||||
'~', '^'
|
||||
};
|
||||
public static char[] regular_metasymbols = new char[]{
|
||||
'<', '>', '(', ')', '[', ']', '{', '}', '^', '-', '=', '$', '!', '|', '?', '*', '+', '.'
|
||||
};
|
||||
//все запретные символы через пробел.
|
||||
public static String all_forbidden_characters_string = "";
|
||||
public static Vector<String> admins_mails = new Vector_<>(
|
||||
|
||||
"vmk-post@yandex.ru"
|
||||
// "79854210702@ya.ru"
|
||||
);
|
||||
}
|
||||
498
src/Common_old/Current.java
Normal file
498
src/Common_old/Current.java
Normal file
@@ -0,0 +1,498 @@
|
||||
package Common_old;
|
||||
import Common.Database.Objects.iDBObject;
|
||||
import Common_old.UI.Themes.VisualiserTheme;
|
||||
import Common.Utils.TextLog;
|
||||
import GlobalData.Account.Account;
|
||||
import GlobalData.Compiler.Compiler;
|
||||
import GlobalData.Machine.Machine;
|
||||
import GlobalData.Makefile.Makefile;
|
||||
import GlobalData.Module.Module;
|
||||
import GlobalData.RemoteFile.RemoteFile;
|
||||
import GlobalData.RunConfiguration.RunConfiguration;
|
||||
import GlobalData.Tasks.CompilationTask.CompilationTask;
|
||||
import GlobalData.Tasks.RunTask.RunTask;
|
||||
import GlobalData.User.User;
|
||||
import ProjectData.Files.DBProjectFile;
|
||||
import ProjectData.Project.db_project_info;
|
||||
import ProjectData.SapforData.Functions.FuncInfo;
|
||||
import ProjectData.SapforData.Regions.ParallelRegion;
|
||||
import Repository.BugReport.BugReport;
|
||||
import Repository.Subscribes.Subscriber;
|
||||
import TestingSystem.Common.Test.Test;
|
||||
import TestingSystem.DVM.DVMConfiguration.DVMConfiguration;
|
||||
import TestingSystem.SAPFOR.SapforConfiguration.SapforConfiguration;
|
||||
import TestingSystem.SAPFOR.SapforSettings.SapforSettings;
|
||||
import Visual_DVM_2021.Passes.UI.PassForm;
|
||||
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import java.io.File;
|
||||
import java.util.LinkedHashMap;
|
||||
public enum Current {
|
||||
Undefined,
|
||||
//--
|
||||
DVMPackage,
|
||||
SapforPackage,
|
||||
//--
|
||||
ServerSapfor,
|
||||
SapforEtalonVersion,//самый левый пакет
|
||||
SapforVersion,
|
||||
//--
|
||||
//--
|
||||
ComponentServerBackup,
|
||||
Subscriber,
|
||||
Theme,
|
||||
FileGraphElement,
|
||||
InlineGraphElement,
|
||||
InlineGraphElement2,
|
||||
IncludeGraphElement,
|
||||
Component,
|
||||
Project,
|
||||
File,
|
||||
Root,
|
||||
Version,
|
||||
BugReport,
|
||||
Account,
|
||||
DBArray,
|
||||
ProjectArray,
|
||||
ParallelRegionInfo,
|
||||
ParallelVariant,
|
||||
Machine,
|
||||
User,
|
||||
Compiler,
|
||||
Makefile,
|
||||
Module,
|
||||
RunConfiguration,
|
||||
EnvironmentValue,
|
||||
CompilationTask,
|
||||
RunTask,
|
||||
ProjectNode, //узел в дереве проекта. нужен для отображения добавленных файлов
|
||||
SelectedDirectory,
|
||||
SelectedFile,
|
||||
//текущий выбранный удаленный файл
|
||||
RemoteFile,
|
||||
PassForm, //текущее окно анимации. нужно для сообщений сапфора по сокету.
|
||||
RunStsRecord,
|
||||
//только для того, чтобы закодировать таблицу.
|
||||
Array,
|
||||
ParallelRegion,
|
||||
Dimensions,
|
||||
//----------
|
||||
Warnings,
|
||||
Errors,
|
||||
Notes,
|
||||
Recommendations,
|
||||
//-
|
||||
Sapfor,
|
||||
//-
|
||||
Scenario,
|
||||
ScenarioCommand,
|
||||
//-
|
||||
DVMConfiguration,
|
||||
Group,
|
||||
//-
|
||||
DVMParameterValue,
|
||||
Test,
|
||||
Function,
|
||||
SelectedFunction,
|
||||
//-
|
||||
Credentials,
|
||||
//-
|
||||
DialogWindow,
|
||||
//-
|
||||
PackageVersion,
|
||||
SapforConfiguration,
|
||||
SapforProfile,
|
||||
SapforProfileSetting,
|
||||
//--
|
||||
ProjectView,
|
||||
SubscriberWorkspace,
|
||||
DVMRunTask,
|
||||
SapforSettings,
|
||||
SapforSettingsCommand,
|
||||
DVMSettings,
|
||||
;
|
||||
//-
|
||||
private static final LinkedHashMap<Current, Object> objects = new LinkedHashMap<>();
|
||||
public static Mode mode;
|
||||
public static boolean hasUI() {
|
||||
return Current.mode.equals(Current.Mode.Normal);
|
||||
}
|
||||
public static boolean HasProject() {
|
||||
return get(Project) != null;
|
||||
}
|
||||
public static boolean HasFile() {
|
||||
return get(File) != null;
|
||||
}
|
||||
public static boolean HasSelectedFile() {
|
||||
return get(SelectedFile) != null;
|
||||
}
|
||||
public static boolean HasAccount() {
|
||||
return get(Account) != null;
|
||||
}
|
||||
public static boolean HasMachine() {
|
||||
return get(Machine) != null;
|
||||
}
|
||||
public static boolean HasUser() {
|
||||
return get(User) != null;
|
||||
}
|
||||
public static boolean HasCompiler() {
|
||||
return get(Compiler) != null;
|
||||
}
|
||||
public static boolean HasRemoteFile() {
|
||||
return get(RemoteFile) != null;
|
||||
}
|
||||
public static boolean HasMakefile() {
|
||||
return get(Makefile) != null;
|
||||
}
|
||||
public static boolean HasRunConfiguration() {
|
||||
return get(RunConfiguration) != null;
|
||||
}
|
||||
public static boolean HasCompilationTask() {
|
||||
return get(CompilationTask) != null;
|
||||
}
|
||||
public static boolean HasRunTask() {
|
||||
return get(RunTask) != null;
|
||||
}
|
||||
public static boolean HasPassForm() {
|
||||
return get(PassForm) != null;
|
||||
}
|
||||
public static boolean HasProjectView() {
|
||||
return get(ProjectView) != null;
|
||||
}
|
||||
//для быстрого доступа на чтение. слишком много на нем завязано.
|
||||
public static SapforSettings getSapforSettings() {
|
||||
return (SapforSettings) get(SapforSettings);
|
||||
}
|
||||
public static boolean HasSapforSettings() {
|
||||
return get(SapforSettings) != null;
|
||||
}
|
||||
|
||||
public static db_project_info getProject() {
|
||||
return (db_project_info) get(Project);
|
||||
}
|
||||
public static DBProjectFile getFile() {
|
||||
return (DBProjectFile) get(File);
|
||||
}
|
||||
public static Repository.Component.Component getComponent() {
|
||||
return (Repository.Component.Component) get(Component);
|
||||
}
|
||||
public static Repository.BugReport.BugReport getBugReport() {
|
||||
return (BugReport) get(BugReport);
|
||||
}
|
||||
public static db_project_info getRoot() {
|
||||
return (db_project_info) get(Root);
|
||||
}
|
||||
public static boolean HasRoot() {
|
||||
return get(Root) != null;
|
||||
}
|
||||
public static db_project_info getVersion() {
|
||||
return (db_project_info) get(Version);
|
||||
}
|
||||
public static Account getAccount() {
|
||||
return (Account) get(Account);
|
||||
}
|
||||
public static boolean HasSubscriber() {
|
||||
return get(Current.Subscriber) != null;
|
||||
}
|
||||
public static Repository.Subscribes.Subscriber getSubscriber() {
|
||||
return (Subscriber) get(Current.Subscriber);
|
||||
}
|
||||
public static Machine getMachine() {
|
||||
return (Machine) get(Current.Machine);
|
||||
}
|
||||
public static User getUser() {
|
||||
return (User) get(Current.User);
|
||||
}
|
||||
public static Compiler getCompiler() {
|
||||
return (Compiler) get(Current.Compiler);
|
||||
}
|
||||
public static CompilationTask getCompilationTask() {
|
||||
return (CompilationTask) get(Current.CompilationTask);
|
||||
}
|
||||
public static RunTask getRunTask() {
|
||||
return (RunTask) get(Current.RunTask);
|
||||
}
|
||||
public static RemoteFile getRemoteFile() {
|
||||
return (RemoteFile) get(Current.RemoteFile);
|
||||
}
|
||||
public static Makefile getMakefile() {
|
||||
return (Makefile) get(Current.Makefile);
|
||||
}
|
||||
public static Module getModule() {
|
||||
return (Module) get(Current.Module);
|
||||
}
|
||||
public static RunConfiguration getRunConfiguration() {
|
||||
return (RunConfiguration) get(Current.RunConfiguration);
|
||||
}
|
||||
public static Repository.Component.Sapfor.Sapfor getSapfor() {
|
||||
return (Repository.Component.Sapfor.Sapfor) get(Current.Sapfor);
|
||||
}
|
||||
public static boolean HasGroup() {
|
||||
return get(Current.Group) != null;
|
||||
}
|
||||
public static TestingSystem.Common.Group.Group getGroup() {
|
||||
return (TestingSystem.Common.Group.Group) get(Current.Group);
|
||||
}
|
||||
//--
|
||||
public static boolean HasConfiguration() {
|
||||
return get(Current.DVMConfiguration) != null;
|
||||
}
|
||||
public static DVMConfiguration getDVMConfiguration() {
|
||||
return (DVMConfiguration) get(Current.DVMConfiguration);
|
||||
}
|
||||
public static SapforConfiguration getSapforConfiguration() {
|
||||
return (TestingSystem.SAPFOR.SapforConfiguration.SapforConfiguration) get(Current.SapforConfiguration);
|
||||
}
|
||||
//--
|
||||
public static Test getTest() {
|
||||
return (TestingSystem.Common.Test.Test) get(Current.Test);
|
||||
}
|
||||
public static boolean HasTest() {
|
||||
return get(Current.Test) != null;
|
||||
}
|
||||
public static boolean HasVersion() {
|
||||
return get(Current.Version) != null;
|
||||
}
|
||||
public static RemoteFile getComponentServerBackup() {
|
||||
return (RemoteFile) get(Current.ComponentServerBackup);
|
||||
}
|
||||
public static boolean HasComponentServerBackup() {
|
||||
return get(Current.ComponentServerBackup) != null;
|
||||
}
|
||||
//-
|
||||
public static DefaultMutableTreeNode getProjectNode() {
|
||||
return (DefaultMutableTreeNode) get(Current.ProjectNode);
|
||||
}
|
||||
public static DefaultMutableTreeNode getProjectCurrentParentNode() {
|
||||
DefaultMutableTreeNode node = Current.getProjectNode();
|
||||
//если в дереве еще никто не выделялся, берем корень.
|
||||
if (node == null)
|
||||
return Current.getProject().filesTreeRoot;
|
||||
return (node.getUserObject() instanceof DBProjectFile) ? (DefaultMutableTreeNode) node.getParent() : node;
|
||||
}
|
||||
public static File getSelectedDirectory() {
|
||||
return (File) get(Current.SelectedDirectory);
|
||||
}
|
||||
public static DBProjectFile getSelectedFile() {
|
||||
return (DBProjectFile) get(Current.SelectedFile);
|
||||
}
|
||||
//-
|
||||
public static boolean HasBugReport() {
|
||||
return get(Current.BugReport) != null;
|
||||
}
|
||||
public static PassForm getPassForm() {
|
||||
return (Visual_DVM_2021.Passes.UI.PassForm) get(Current.PassForm);
|
||||
}
|
||||
public static VisualiserTheme getTheme() {
|
||||
return (VisualiserTheme) get(Current.Theme);
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
public static ParallelRegion getParallelRegion() {
|
||||
return (ParallelRegion) get(Current.ParallelRegion);
|
||||
}
|
||||
public static boolean HasParallelRegion() {
|
||||
return get(Current.ParallelRegion) != null;
|
||||
}
|
||||
public static boolean HasFunction() {
|
||||
return get(Current.Function) != null;
|
||||
}
|
||||
public static boolean HasSelectedFunction() {
|
||||
return get(Current.SelectedFunction) != null;
|
||||
}
|
||||
public static FuncInfo getFunction() {
|
||||
return (FuncInfo) get(Current.Function);
|
||||
}
|
||||
public static FuncInfo getSelectionFunction() {
|
||||
return (FuncInfo) get(Current.SelectedFunction);
|
||||
}
|
||||
public static boolean HasScenario() {
|
||||
return get(Current.Scenario) != null;
|
||||
}
|
||||
public static db_project_info getPackageVersion() {
|
||||
return (db_project_info) get(Current.PackageVersion);
|
||||
}
|
||||
public static boolean HasPackageVersion() {
|
||||
return get(Current.PackageVersion) != null;
|
||||
}
|
||||
public static boolean HasSapforConfiguration() {
|
||||
return get(Current.SapforConfiguration) != null;
|
||||
}
|
||||
public static ProjectData.ProjectView getProjectView() {
|
||||
return (ProjectData.ProjectView) get(ProjectView);
|
||||
}
|
||||
public static boolean Check(TextLog Log, Current... names) {
|
||||
for (Current name : names)
|
||||
if (get(name) == null)
|
||||
Log.Writeln_(name.getDescription() + " не выбран(а)");
|
||||
return Log.isEmpty();
|
||||
}
|
||||
public static void CreateAll() {
|
||||
for (Current c : values())
|
||||
objects.put(c, null);
|
||||
}
|
||||
//-----------------------------------------
|
||||
public static Object get(Current name) {
|
||||
return objects.get(name);
|
||||
}
|
||||
public static Object set(Current name, Object object) {
|
||||
objects.replace(name, object);
|
||||
return object;
|
||||
}
|
||||
//применять только для наследников iDBObject
|
||||
public static boolean CheckID(Current name, int id) {
|
||||
return (get(name) != null) && (((iDBObject) get(name)).id == id);
|
||||
}
|
||||
public static boolean HasSapforProfile() {
|
||||
return get(Current.SapforProfile) != null;
|
||||
}
|
||||
public static GlobalData.SapforProfile.SapforProfile getSapforProfile() {
|
||||
return (GlobalData.SapforProfile.SapforProfile) get(Current.SapforProfile);
|
||||
}
|
||||
//сапфоры установленные на тестовый сервер.
|
||||
public static boolean HasServerSapfor() {
|
||||
return get(Current.ServerSapfor) != null;
|
||||
}
|
||||
public static TestingSystem.SAPFOR.ServerSapfor.ServerSapfor getServerSapfor() {
|
||||
return (TestingSystem.SAPFOR.ServerSapfor.ServerSapfor) get(Current.ServerSapfor);
|
||||
}
|
||||
public static boolean HasSubscriberWorkspace() {
|
||||
return get(Current.SubscriberWorkspace) != null;
|
||||
}
|
||||
public static Repository.SubscriberWorkspace.SubscriberWorkspace getSubscriberWorkspace() {
|
||||
return (Repository.SubscriberWorkspace.SubscriberWorkspace) get(Current.SubscriberWorkspace);
|
||||
}
|
||||
//----->>
|
||||
public static boolean HasDVMPackage() {
|
||||
return get(Current.DVMPackage) != null;
|
||||
}
|
||||
public static TestingSystem.DVM.DVMPackage.DVMPackage getDVMPackage() {
|
||||
return (TestingSystem.DVM.DVMPackage.DVMPackage) get(Current.DVMPackage);
|
||||
}
|
||||
public static boolean HasSapforPackage() {
|
||||
return get(Current.SapforPackage) != null;
|
||||
}
|
||||
public static TestingSystem.SAPFOR.SapforPackage.SapforPackage getSapforPackage() {
|
||||
return (TestingSystem.SAPFOR.SapforPackage.SapforPackage) get(Current.SapforPackage);
|
||||
}
|
||||
public static boolean HasDVMRunTask() {
|
||||
return get(Current.DVMRunTask) != null;
|
||||
}
|
||||
public static TestingSystem.DVM.DVMTasks.DVMRunTask getDVMRunTask() {
|
||||
return (TestingSystem.DVM.DVMTasks.DVMRunTask) Current.get(Current.DVMRunTask);
|
||||
}
|
||||
//--------------------------------------------
|
||||
public String getDescription() {
|
||||
switch (this) {
|
||||
case DVMSettings:
|
||||
return "Параметры тестирования DVM системы";
|
||||
case SapforSettings:
|
||||
return "Параметры тестирования системы SAPFOR";
|
||||
case SapforSettingsCommand:
|
||||
return "Команда SAPFOR";
|
||||
case DVMRunTask:
|
||||
return "Задача DVM тестирования";
|
||||
case SapforPackage:
|
||||
return "Пакет тестирования SAPFOR";
|
||||
case DVMPackage:
|
||||
return "Пакет тестирования DVM";
|
||||
case DVMConfiguration:
|
||||
return "Конфигурация тестирования";
|
||||
case ServerSapfor:
|
||||
return "тестовая версия SAPFOR";
|
||||
case SubscriberWorkspace:
|
||||
return "рабочее пространство пользователя";
|
||||
case SapforProfile:
|
||||
return "Профиль SAPFOR";
|
||||
case SapforProfileSetting:
|
||||
return "Настройка профиля SAPFOR";
|
||||
case SapforEtalonVersion:
|
||||
return "Версия SAPFOR(Эталон)";
|
||||
case SapforVersion:
|
||||
return "Версия SAPFOR";
|
||||
case ComponentServerBackup:
|
||||
return "Версия компонента для восстановления с сервера";
|
||||
case Subscriber:
|
||||
return "Адресат";
|
||||
case SelectedFunction:
|
||||
return "Выбранный узел графа процедур";
|
||||
case SapforConfiguration:
|
||||
return "Конфигурация тестирования SAPFOR";
|
||||
case PackageVersion:
|
||||
return "Версия пакетного режима";
|
||||
case Credentials:
|
||||
return "Учётные данные";
|
||||
case Function:
|
||||
return "Функция";
|
||||
case DVMParameterValue:
|
||||
return "Параметр DVM системы";
|
||||
case ParallelRegion:
|
||||
return "Область распараллеливания";
|
||||
case Group:
|
||||
return "Группа тестов DVM";
|
||||
case Scenario:
|
||||
return "Сценарий";
|
||||
case ScenarioCommand:
|
||||
return "Команда сценария";
|
||||
case ProjectNode:
|
||||
return "текущий узел дерева проектов"; //служебка
|
||||
case Test:
|
||||
return "Тест";
|
||||
case Sapfor:
|
||||
return "SAPFOR";
|
||||
case Theme:
|
||||
return "Тема";
|
||||
case EnvironmentValue:
|
||||
return "Значение переменной окружения";
|
||||
case SelectedDirectory:
|
||||
return "Папка проекта";
|
||||
case SelectedFile:
|
||||
return "Файл проекта";
|
||||
case RunConfiguration:
|
||||
return "Конфигурация запуска";
|
||||
case RunTask:
|
||||
return "Задача на запуск";
|
||||
case CompilationTask:
|
||||
return "Задача на компиляцию";
|
||||
case Makefile:
|
||||
return "Мейкфайл";
|
||||
case Module:
|
||||
return "Языковой модуль мейкфайла";
|
||||
case RemoteFile:
|
||||
return "Удалённый файл";
|
||||
case Component:
|
||||
return "Компонент";
|
||||
case Project:
|
||||
return "Проект";
|
||||
case File:
|
||||
return "Файл";
|
||||
case Root:
|
||||
return "Корень дерева версий";
|
||||
case Version:
|
||||
return "Версия";
|
||||
case BugReport:
|
||||
return "Отчёт об ошибке";
|
||||
case Account:
|
||||
return "Аккаунт";
|
||||
case Machine:
|
||||
return "Машина";
|
||||
case User:
|
||||
return "Пользователь";
|
||||
case Compiler:
|
||||
return "Компилятор";
|
||||
case DialogWindow:
|
||||
return "Диалоговое окно";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
//---
|
||||
public enum Mode {
|
||||
Undefined,
|
||||
Normal,
|
||||
Server,
|
||||
Testing,
|
||||
Package,
|
||||
MachineQueue,
|
||||
LocalMachineQueue
|
||||
}
|
||||
}
|
||||
168
src/Common_old/GlobalProperties.java
Normal file
168
src/Common_old/GlobalProperties.java
Normal file
@@ -0,0 +1,168 @@
|
||||
package Common_old;
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Paths;
|
||||
public class GlobalProperties extends Properties {
|
||||
@Override
|
||||
public String getFieldDescription(String fieldName) {
|
||||
switch (fieldName) {
|
||||
case "ShowPassesDone":
|
||||
return "Сообщать об успешном выполнении проходов";
|
||||
case "ConfirmPassesStart":
|
||||
return "Запрашивать подтверждения начала выполнения проходов";
|
||||
case "FocusPassesResult":
|
||||
return "Переходить на результирующую вкладку проходов по их завершении";
|
||||
case "collapseCredentials":
|
||||
return "Свернуть раздел машин";
|
||||
case "collapseFileGraphs":
|
||||
return "Свернуть раздел графов файла";
|
||||
case "collapseFileMessages":
|
||||
return "Свернуть раздел сообщений файла";
|
||||
case "collapseProjectTrees":
|
||||
return "Свернуть раздел деревьев проекта";
|
||||
default:
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
@Expose
|
||||
public Current.Mode Mode = Current.Mode.Normal;
|
||||
@Expose
|
||||
public String ServerAddress = "alex-freenas.ddns.net";
|
||||
@Expose
|
||||
public String ServerUserName = "testuser";
|
||||
@Expose
|
||||
public int ServerUserSHHPort = 23;
|
||||
@Expose
|
||||
public int ComponentsServerPort = 7995;
|
||||
@Expose
|
||||
public int TestingServerPort = 7998;
|
||||
//---
|
||||
@Expose
|
||||
public int SocketTimeout = 5000;
|
||||
@Expose
|
||||
public boolean OldServer = false;
|
||||
//---
|
||||
@Expose
|
||||
public String SMTPHost = "smtp.mail.ru";
|
||||
@Expose
|
||||
public int SMTPPort = 465;
|
||||
@Expose
|
||||
public int MailSocketPort = 465;
|
||||
//---
|
||||
//СВОРАЧИВАНИЕ ОБЛАСТЕЙ----------------------
|
||||
@Expose
|
||||
public boolean collapseCredentials = false;
|
||||
@Expose
|
||||
public boolean collapseFileGraphs = false;
|
||||
@Expose
|
||||
public boolean collapseFileMessages = false;
|
||||
@Expose
|
||||
public boolean collapseProjectTrees = false;
|
||||
//-------------------------------------------
|
||||
@Expose
|
||||
public String BackupWorkspace = "_sapfor_x64_backups";
|
||||
@Expose
|
||||
public int BackupHour = 5;
|
||||
@Expose
|
||||
public int BackupMinute = 0;
|
||||
@Expose
|
||||
public boolean EmailAdminsOnStart = false;
|
||||
//---
|
||||
@Expose
|
||||
public boolean AutoUpdateSearch = true;
|
||||
@Expose
|
||||
public boolean ConfirmPassesStart = true;
|
||||
@Expose
|
||||
public boolean ShowPassesDone = true;
|
||||
@Expose
|
||||
public boolean FocusPassesResult = true;
|
||||
@Expose
|
||||
public String GlobalDBName = "db7.sqlite";
|
||||
@Expose
|
||||
public String ProjectDBName = "new_project_base.sqlite";
|
||||
@Expose
|
||||
public String BugReportsDBName = "bug_reports.sqlite";
|
||||
@Expose
|
||||
public String TestsDBName = "tests.sqlite";
|
||||
//-
|
||||
@Expose
|
||||
public int ComponentsWindowWidth = 650;
|
||||
@Expose
|
||||
public int ComponentsWindowHeight = 250;
|
||||
//-
|
||||
@Expose
|
||||
public String VisualiserPath = "";
|
||||
@Expose
|
||||
public String Sapfor_FPath = "";
|
||||
@Expose
|
||||
public String Visualizer_2Path = "";
|
||||
@Expose
|
||||
public String InstructionPath = "";
|
||||
@Expose
|
||||
public String PerformanceAnalyzerPath = "";
|
||||
@Expose
|
||||
public int ComponentsBackUpsCount = 10;
|
||||
//- тестирование.
|
||||
@Expose
|
||||
public int TestingKernels = 4; //число ядер для тестирования
|
||||
@Expose
|
||||
public boolean AutoCheckTesting = false; // проверять ли задачи тестирования при включенном визуализаторе.
|
||||
@Expose
|
||||
public int CheckTestingIntervalSeconds = 10; //интервал автопроверки тестирования
|
||||
@Expose
|
||||
public boolean EmailOnTestingProgress = false; //включено ли оповещение по email о результатах тестирования.
|
||||
@Expose
|
||||
public boolean eraseTestingWorkspaces = true; //удалять ли рабочее пространство пакетов тестирования после его завершения.
|
||||
//-
|
||||
@Override
|
||||
public File getFile() {
|
||||
return Paths.get(System.getProperty("user.dir"), "properties").toFile();
|
||||
}
|
||||
//--
|
||||
public GlobalProperties() {
|
||||
}
|
||||
public GlobalProperties(GlobalProperties p) {
|
||||
super();
|
||||
Mode = p.Mode;
|
||||
ServerAddress = p.ServerAddress;
|
||||
ServerUserName = p.ServerUserName;
|
||||
ServerUserSHHPort = p.ServerUserSHHPort;
|
||||
ComponentsServerPort = p.ComponentsServerPort;
|
||||
TestingServerPort = p.TestingServerPort;
|
||||
SocketTimeout = p.SocketTimeout;
|
||||
OldServer = p.OldServer;
|
||||
SMTPHost = p.SMTPHost;
|
||||
SMTPPort = p.SMTPPort;
|
||||
MailSocketPort = p.MailSocketPort;
|
||||
collapseCredentials = p.collapseCredentials;
|
||||
collapseFileGraphs = p.collapseFileGraphs;
|
||||
collapseFileMessages = p.collapseFileMessages;
|
||||
collapseProjectTrees = p.collapseProjectTrees;
|
||||
BackupWorkspace = p.BackupWorkspace;
|
||||
BackupHour = p.BackupHour;
|
||||
BackupMinute = p.BackupMinute;
|
||||
EmailAdminsOnStart = p.EmailAdminsOnStart;
|
||||
AutoUpdateSearch = p.AutoUpdateSearch;
|
||||
ConfirmPassesStart = p.ConfirmPassesStart;
|
||||
ShowPassesDone = p.ShowPassesDone;
|
||||
FocusPassesResult = p.FocusPassesResult;
|
||||
GlobalDBName = p.GlobalDBName;
|
||||
ProjectDBName = p.ProjectDBName;
|
||||
BugReportsDBName = p.BugReportsDBName;
|
||||
TestsDBName = p.TestsDBName;
|
||||
ComponentsWindowWidth = p.ComponentsWindowWidth;
|
||||
ComponentsWindowHeight = p.ComponentsWindowHeight;
|
||||
VisualiserPath = p.VisualiserPath;
|
||||
Sapfor_FPath = p.Sapfor_FPath;
|
||||
Visualizer_2Path = p.Visualizer_2Path;
|
||||
InstructionPath = p.InstructionPath;
|
||||
PerformanceAnalyzerPath = p.PerformanceAnalyzerPath;
|
||||
ComponentsBackUpsCount = p.ComponentsBackUpsCount;
|
||||
TestingKernels = p.TestingKernels;
|
||||
AutoCheckTesting = p.AutoCheckTesting;
|
||||
CheckTestingIntervalSeconds = p.CheckTestingIntervalSeconds;
|
||||
EmailOnTestingProgress = p.EmailOnTestingProgress;
|
||||
eraseTestingWorkspaces = p.eraseTestingWorkspaces;
|
||||
}
|
||||
}
|
||||
82
src/Common_old/Properties.java
Normal file
82
src/Common_old/Properties.java
Normal file
@@ -0,0 +1,82 @@
|
||||
package Common_old;
|
||||
import Common.Utils.CommonUtils;
|
||||
import Common_old.UI.Menus_2023.StableMenuItem;
|
||||
import Common_old.Utils.Utils;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.Pass_2021;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
public abstract class Properties {
|
||||
public void addFlagMenuItem(JMenu menu, String fieldName) {
|
||||
JMenuItem menu_item = new StableMenuItem(getFieldDescription(fieldName),
|
||||
getFlag(fieldName) ? "/Common/icons/Pick.png" : "/Common/icons/NotPick.png");
|
||||
//-
|
||||
menu_item.addActionListener(e -> {
|
||||
if (Pass_2021.passes.get(PassCode_2021.UpdateProperty).Do(fieldName, !getFlag(fieldName)))
|
||||
menu_item.setIcon(Utils.getIcon(getFlag(fieldName) ? "/Common/icons/Pick.png" : "/Common/icons/NotPick.png"));
|
||||
});
|
||||
menu.add(menu_item);
|
||||
}
|
||||
public boolean getFlag(String fieldName) {
|
||||
boolean field = false;
|
||||
try {
|
||||
field = (boolean) GlobalProperties.class.getField(fieldName).get(this);
|
||||
//
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return field;
|
||||
}
|
||||
public void switchFlag(String fieldName) {
|
||||
boolean field = false;
|
||||
try {
|
||||
field = (boolean) GlobalProperties.class.getField(fieldName).get(this);
|
||||
GlobalProperties.class.getField(fieldName).set(this, !field);
|
||||
//
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void Update() {
|
||||
try {
|
||||
CommonUtils.jsonToFile(this, getFile());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
//--
|
||||
public abstract String getFieldDescription(String fieldName);
|
||||
public abstract File getFile();
|
||||
public boolean updateField(String name, Object newValue) {
|
||||
try {
|
||||
Field field = getClass().getField(name);
|
||||
Object oldValue = field.get(this);
|
||||
//---
|
||||
if (newValue.equals(oldValue))
|
||||
return false;
|
||||
//--
|
||||
field.set(this, newValue);
|
||||
this.Update();
|
||||
return true;
|
||||
//--
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void switchAndUpdateFlag(String name) {
|
||||
try {
|
||||
Field field = getClass().getField(name);
|
||||
boolean oldValue = (boolean) field.get(this);
|
||||
boolean newValue = !oldValue;
|
||||
//---
|
||||
field.set(this, newValue);
|
||||
this.Update();
|
||||
//--
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
9
src/Common_old/UI/ComboBox/StyledTextComboBox.java
Normal file
9
src/Common_old/UI/ComboBox/StyledTextComboBox.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package Common_old.UI.ComboBox;
|
||||
import Common_old.UI.Menus.TextComboBoxMenu;
|
||||
|
||||
import javax.swing.*;
|
||||
public class StyledTextComboBox extends JComboBox<String> {
|
||||
public StyledTextComboBox() {
|
||||
setComponentPopupMenu(new TextComboBoxMenu(this));
|
||||
}
|
||||
}
|
||||
53
src/Common_old/UI/ControlForm.java
Normal file
53
src/Common_old/UI/ControlForm.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package Common_old.UI;
|
||||
import _VisualDVM.Global;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
//класс, представляющий собой прокручиваемую панель, на которой лежит нечто.
|
||||
public class ControlForm<C extends Component> {
|
||||
public C control = null;
|
||||
protected Class<C> control_class;
|
||||
protected JPanel content; //задник.
|
||||
public JScrollPane scroll = null;
|
||||
public ControlForm(Class<C> class_in) {
|
||||
control_class = class_in;
|
||||
setContent(new JPanel(new BorderLayout()));
|
||||
}
|
||||
//нужно будет вывестии сделать нормальные формы для деревьев а не ручное создание.
|
||||
public JPanel getContent() {
|
||||
return content;
|
||||
}
|
||||
public void setContent(JPanel content_in) {
|
||||
|
||||
content = content_in;
|
||||
}
|
||||
//-
|
||||
public void Show() {
|
||||
Clear();
|
||||
CreateControl();
|
||||
//------------------------
|
||||
scroll = new JScrollPane(control);
|
||||
scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
|
||||
scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
}
|
||||
public void CreateControl() {
|
||||
try {
|
||||
control = control_class.newInstance();
|
||||
} catch (Exception e) {
|
||||
Global.Log.PrintException(e);
|
||||
}
|
||||
}
|
||||
public boolean isShown() {
|
||||
return control != null;
|
||||
}
|
||||
public void Clear() {
|
||||
control = null; //очищено.
|
||||
}
|
||||
public void Refresh() {
|
||||
if (control != null)
|
||||
refresh();
|
||||
}
|
||||
//-
|
||||
protected void refresh() {
|
||||
} //перерисовать контрол.
|
||||
}
|
||||
19
src/Common_old/UI/ControlWithCurrentForm.java
Normal file
19
src/Common_old/UI/ControlWithCurrentForm.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package Common_old.UI;
|
||||
import Common_old.Current;
|
||||
|
||||
import java.awt.*;
|
||||
public class ControlWithCurrentForm<C extends Component> extends ControlForm<C> {
|
||||
public ControlWithCurrentForm(Class<C> class_in) {
|
||||
super(class_in);
|
||||
}
|
||||
//-
|
||||
public Current CurrentName() {
|
||||
return Current.Undefined;
|
||||
}
|
||||
public void ShowCurrentObject() throws Exception {
|
||||
}
|
||||
public void ShowNoCurrentObject() throws Exception {
|
||||
}
|
||||
public void MouseAction2() throws Exception {
|
||||
}
|
||||
}
|
||||
7
src/Common_old/UI/DataControl.java
Normal file
7
src/Common_old/UI/DataControl.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package Common_old.UI;
|
||||
import Common.Database.Objects.DBObject;
|
||||
public interface DataControl {
|
||||
DBObject getRowObject(int rowIndex); //получить объект, сответствующий данной строке.
|
||||
void SelectRowByPK(Object pk);
|
||||
//выделить строку где лежит объект с данным первичным ключом.
|
||||
}
|
||||
13
src/Common_old/UI/DataControl_OLD.java
Normal file
13
src/Common_old/UI/DataControl_OLD.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package Common_old.UI;
|
||||
import Common_old.Current;
|
||||
public interface DataControl_OLD {
|
||||
//todo скорее всего устареет.
|
||||
default Current getCurrent() {
|
||||
return Current.Undefined;
|
||||
}
|
||||
//-?
|
||||
default void ShowCurrentObject() throws Exception {
|
||||
}
|
||||
default void ShowNoCurrentObject() throws Exception {
|
||||
}
|
||||
}
|
||||
325
src/Common_old/UI/DataSetControlForm.java
Normal file
325
src/Common_old/UI/DataSetControlForm.java
Normal file
@@ -0,0 +1,325 @@
|
||||
package Common_old.UI;
|
||||
import Common_old.Constants;
|
||||
import Common_old.Current;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import Common.Database.Tables.DBTable;
|
||||
import Common.Database.Tables.DataSet;
|
||||
import Common.Database.Tables.FKBehaviour;
|
||||
import _VisualDVM.Global;
|
||||
import Common_old.UI.Menus.TableMenu;
|
||||
import Common_old.UI.Tables.ColumnInfo;
|
||||
import Common_old.UI.Tables.DataTable;
|
||||
import Common_old.UI.Tables.Grid.GridAnchestor;
|
||||
import GlobalData.Grid.Grid;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.TableColumn;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.Arrays;
|
||||
import java.util.Vector;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import static Common_old.UI.Tables.TableEditors.EditorSelect;
|
||||
import static Common_old.UI.Tables.TableRenderers.RendererSelect;
|
||||
public class DataSetControlForm extends ControlWithCurrentForm<DataTable> {
|
||||
protected JPanel dataPanel;
|
||||
protected DataSet dataSource;
|
||||
public JPanel getDataPanel() {
|
||||
return dataPanel;
|
||||
}
|
||||
protected int current_row_i;
|
||||
protected boolean events_on = true;
|
||||
protected String colNamesAndSizes = "";
|
||||
protected Vector<ColumnInfo> columns = new Vector<>();
|
||||
public DataSetControlForm(DataSet dataSource_in) {
|
||||
this(dataSource_in, DataTable.class);
|
||||
}
|
||||
public DataSetControlForm(DataSet dataSource_in, Class tableClass) {
|
||||
super(tableClass);
|
||||
dataSource = dataSource_in;
|
||||
//---
|
||||
dataPanel = new JPanel(new BorderLayout());
|
||||
content.add(dataPanel, BorderLayout.CENTER);
|
||||
}
|
||||
@Override
|
||||
public void Show() {
|
||||
super.Show();
|
||||
dataPanel.add(scroll);
|
||||
dataPanel.updateUI();
|
||||
}
|
||||
@Override
|
||||
public void Clear() {
|
||||
super.Clear();
|
||||
UI.Clear(dataPanel);
|
||||
}
|
||||
public DataSet getDataSource() {
|
||||
return dataSource;
|
||||
}
|
||||
@Override
|
||||
public Current CurrentName() {
|
||||
return getDataSource().CurrentName();
|
||||
}
|
||||
public void SaveColumns() {
|
||||
if (Global.db != null) {
|
||||
try {
|
||||
if ((CurrentName() != Current.Undefined)) {
|
||||
Vector<String> widths = IntStream.range(0, columns.size()).mapToObj(i -> String.valueOf(control.getColumnModel().getColumn(i).getWidth())).collect(Collectors.toCollection(Vector::new));
|
||||
String packed = String.join("|", widths);
|
||||
Grid grid;
|
||||
if (Global.db.grids.containsKey(CurrentName())) {
|
||||
grid = Global.db.grids.get(CurrentName());
|
||||
} else {
|
||||
grid = new Grid(CurrentName());
|
||||
Global.db.Insert(grid);
|
||||
}
|
||||
grid.sizes = packed;
|
||||
Global.db.Update(grid);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
public boolean hasCheckBox() {
|
||||
return false;
|
||||
}
|
||||
private Vector<String> getHeaders() {
|
||||
return columns.stream().map(ColumnInfo::getName).collect(Collectors.toCollection(Vector::new));
|
||||
}
|
||||
protected void CreateColumnsInfo() {
|
||||
columns.clear();
|
||||
columns.add(new ColumnInfo(getDataSource().getPKName()));
|
||||
if (hasCheckBox()) {
|
||||
columns.add(new ColumnInfo("", RendererSelect, EditorSelect));
|
||||
columns.get(1).setMinWidth(25);
|
||||
columns.get(1).setMaxWidth(25);
|
||||
}
|
||||
Arrays.stream(getDataSource().getUIColumnNames()).forEach(name -> columns.add(new ColumnInfo(name)));
|
||||
AdditionalInitColumns();
|
||||
}
|
||||
protected void AdditionalInitColumns() {
|
||||
//уточнение инфы по столбцам.
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void CreateControl() {
|
||||
CreateColumnsInfo();
|
||||
GridAnchestor table_data_model = new GridAnchestor(getHeaders(), dataSource.getVisibleKeys()) {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Object getValueAt(int rowIndex, int columnIndex) {
|
||||
Object key = data.get(rowIndex);
|
||||
if (columnIndex == 0)
|
||||
return key;
|
||||
DBObject object = getDataSource().get((key));
|
||||
if ((columnIndex == 1) && hasCheckBox())
|
||||
return object.isSelected();
|
||||
return getDataSource().getFieldAt(object, columnIndex);
|
||||
}
|
||||
@Override
|
||||
public boolean isCellEditable(int row, int col) {
|
||||
return columns.get(col).isEditable();
|
||||
}
|
||||
//------------------------------------------------------------------------------------
|
||||
@Override
|
||||
public void setValueAt(Object value, int row, int col) {
|
||||
fireTableCellUpdated(row, col);
|
||||
}
|
||||
};
|
||||
control = new DataTable(table_data_model) {
|
||||
@Override
|
||||
public TableMenu CreateMenu() {
|
||||
return new TableMenu(this);
|
||||
}
|
||||
//строго говоря эта штука нужна только для рендереров и едиторов клеток.
|
||||
@Override
|
||||
public DBObject getRowObject(int rowIndex) {
|
||||
//вот так делать НЕЛЬЗЯ. модель только для внутреннего пользования
|
||||
// Object key = table_data_model.data.get(rowIndex);
|
||||
//из таблицы можно пользоваться только getValueAt
|
||||
//иначе сортировка не будет работать.
|
||||
Object key = getValueAt(rowIndex, 0);
|
||||
return getDataSource().get(key);
|
||||
}
|
||||
//-----------------------------NEW-------------------------------------
|
||||
@Override
|
||||
public void CorrectColumnsSizes() {
|
||||
if ((Global.db != null) && CurrentName() != Current.Undefined && Global.db.grids.containsKey(CurrentName())) {
|
||||
//Undefined может оказаться в таблице, например если енум устарел. Поэтому надо проверять.
|
||||
if (!getColumnsProfile().equalsIgnoreCase(colNamesAndSizes)) {
|
||||
Grid grid = Global.db.grids.get(CurrentName());
|
||||
String[] data = grid.sizes.split("\\|");
|
||||
for (int i = 0; i < columns.size(); ++i) {
|
||||
if (i <= (data.length - 1)) {
|
||||
int width = Integer.parseInt(data[i]);
|
||||
getColumnModel().getColumn(i).setPreferredWidth(width);
|
||||
getColumnModel().getColumn(i).setWidth(width);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
super.CorrectColumnsSizes(); //обычный авторазмер.
|
||||
}
|
||||
public String getColumnsProfile() {
|
||||
String res = "";
|
||||
for (int i = 0; i < getColumnModel().getColumnCount(); i++) {
|
||||
if (i > 0) res += ",";
|
||||
TableColumn column = getColumnModel().getColumn(i);
|
||||
res += column.getHeaderValue();
|
||||
res += ":";
|
||||
res += column.getWidth();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@Override
|
||||
public void Init() {
|
||||
for (int i = 0; i < columns.size(); i++) {
|
||||
ColumnInfo columnInfo = columns.get(i);
|
||||
if (columnInfo.isVisible()) {
|
||||
if (columnInfo.hasRenderer())
|
||||
getColumnModel().getColumn(i).setCellRenderer(UI.TableRenderers.get(columnInfo.getRenderer()));
|
||||
if (columnInfo.hasEditor())
|
||||
getColumnModel().getColumn(i).setCellEditor(UI.TableEditors.get(columnInfo.getEditor()));
|
||||
if (columnInfo.hasMaxWidth())
|
||||
getColumnModel().getColumn((i)).setMaxWidth(columnInfo.getMaxWidth());
|
||||
if (columnInfo.hasMinWidth())
|
||||
getColumnModel().getColumn((i)).setMinWidth(columnInfo.getMinWidth());
|
||||
} else {
|
||||
getColumnModel().getColumn(i).setMinWidth(0);
|
||||
getColumnModel().getColumn(i).setMaxWidth(0);
|
||||
}
|
||||
}
|
||||
//обновление в БД при ручном изменении размера столбиков.--------->>
|
||||
getTableHeader().addMouseListener(new MouseAdapter() {
|
||||
public void mouseReleased(MouseEvent arg0) {
|
||||
String new_colNamesAndSizes = getColumnsProfile();
|
||||
// check if changed, if yes, persist...
|
||||
if (!colNamesAndSizes.equals(new_colNamesAndSizes)) {
|
||||
colNamesAndSizes = new_colNamesAndSizes;
|
||||
SaveColumns();
|
||||
}
|
||||
}
|
||||
});
|
||||
//------------------------->>
|
||||
}
|
||||
};
|
||||
if (CurrentName() != Current.Undefined) {
|
||||
current_row_i = Constants.Nan;
|
||||
ListSelectionModel selModel = control.getSelectionModel();
|
||||
selModel.addListSelectionListener(e -> {
|
||||
int row = control.getSelectedRow();
|
||||
if ((row >= 0)) {
|
||||
if (row != current_row_i) {
|
||||
current_row_i = row;
|
||||
getDataSource().setCurrent(control.getRowObject(row));
|
||||
if (events_on) {
|
||||
try {
|
||||
ShowCurrentObject();
|
||||
} catch (Exception ex) {
|
||||
Global.Log.PrintException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
current_row_i = Constants.Nan;
|
||||
getDataSource().dropCurrent();
|
||||
if (events_on) {
|
||||
try {
|
||||
ShowNoCurrentObject();
|
||||
} catch (Exception ex) {
|
||||
Global.Log.PrintException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
//двойной клик мыши.------------------------------------------------------
|
||||
control.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if ((e.getClickCount() == 2) && (dataSource.getCurrent() != null)) {
|
||||
try {
|
||||
MouseAction2();
|
||||
} catch (Exception ex) {
|
||||
Global.Log.PrintException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
//----------------------------------------------------------------------------
|
||||
//при переотображении таблицы скидываем текущий объект!!
|
||||
getDataSource().dropCurrent();
|
||||
try {
|
||||
ShowNoCurrentObject();
|
||||
} catch (Exception e) {
|
||||
Global.Log.PrintException(e);
|
||||
}
|
||||
}
|
||||
//---
|
||||
/*
|
||||
if (hasCheckBox()) {
|
||||
TableColumn column = control.getColumnModel().getColumn(1)
|
||||
column.setHeaderRenderer(new TableCellRenderer() {
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
return null;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
*/
|
||||
}
|
||||
@Override
|
||||
protected void refresh() {
|
||||
control.CorrectSizes();
|
||||
}
|
||||
public void Show(Object pk) {
|
||||
Show();
|
||||
Select(pk);
|
||||
}
|
||||
public void Select(Object pk) {
|
||||
if (isShown())
|
||||
control.SelectRowByPK(pk);
|
||||
}
|
||||
public void ClearSelection() {
|
||||
if (isShown())
|
||||
control.clearSelection(); //строка сбросится сама. благодаря сбросу события выбора
|
||||
}
|
||||
public int getRowCount() {
|
||||
return control.getRowCount();
|
||||
}
|
||||
@Override
|
||||
public void ShowCurrentObject() throws Exception {
|
||||
if (dataSource instanceof DBTable) {
|
||||
DBTable table = (DBTable) dataSource;
|
||||
for (Class dep : table.getFKDependencies().keySet()) {
|
||||
FKBehaviour behaviour = table.getFKDependencies().get(dep);
|
||||
switch (behaviour.ui) {
|
||||
case ACTIVE:
|
||||
table.getDb().tables.get(dep).ShowUI();
|
||||
break;
|
||||
case PASSIVE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void ShowNoCurrentObject() throws Exception {
|
||||
if (dataSource instanceof DBTable) {
|
||||
DBTable table = (DBTable) dataSource;
|
||||
for (Class dep : table.getFKDependencies().keySet()) {
|
||||
FKBehaviour behaviour = table.getFKDependencies().get(dep);
|
||||
switch (behaviour.ui) {
|
||||
case ACTIVE:
|
||||
table.getDb().tables.get(dep).ClearUI();
|
||||
break;
|
||||
case PASSIVE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
17
src/Common_old/UI/DebugPrintLevel.java
Normal file
17
src/Common_old/UI/DebugPrintLevel.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package Common_old.UI;
|
||||
public enum DebugPrintLevel {
|
||||
Undefined,
|
||||
Passes,
|
||||
Project;
|
||||
public String getDescription() {
|
||||
return toString();
|
||||
}
|
||||
public boolean isEnabled() {
|
||||
switch (this) {
|
||||
case Passes:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
33
src/Common_old/UI/DragDrop/ExampleDrop.java
Normal file
33
src/Common_old/UI/DragDrop/ExampleDrop.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package Common_old.UI.DragDrop;
|
||||
import javax.swing.*;
|
||||
/**
|
||||
* A simple example showing how to use {@link FileDrop}
|
||||
*
|
||||
* @author Robert Harder, rob@iharder.net
|
||||
*/
|
||||
public class ExampleDrop {
|
||||
/*
|
||||
/** Runs a sample program that shows dropped files */
|
||||
public static void kek(String[] args) {
|
||||
javax.swing.JFrame frame = new javax.swing.JFrame("FileDrop");
|
||||
//javax.swing.border.TitledBorder dragBorder = new javax.swing.border.TitledBorder( "Drop 'em" );
|
||||
final javax.swing.JTextArea text = new javax.swing.JTextArea();
|
||||
frame.getContentPane().add(
|
||||
new javax.swing.JScrollPane(text),
|
||||
java.awt.BorderLayout.CENTER);
|
||||
new FileDrop(System.out, text, /*dragBorder,*/ new FileDrop.Listener() {
|
||||
public void filesDropped(java.io.File[] files) {
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
try {
|
||||
text.append(files[i].getCanonicalPath() + "\n");
|
||||
} // end try
|
||||
catch (java.io.IOException e) {
|
||||
}
|
||||
} // end for: through each dropped file
|
||||
} // end filesDropped
|
||||
}); // end FileDrop.Listener
|
||||
frame.setBounds(100, 100, 300, 400);
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.setVisible(true);
|
||||
} // end main
|
||||
}
|
||||
792
src/Common_old/UI/DragDrop/FileDrop.java
Normal file
792
src/Common_old/UI/DragDrop/FileDrop.java
Normal file
@@ -0,0 +1,792 @@
|
||||
package Common_old.UI.DragDrop;
|
||||
import _VisualDVM.Global;
|
||||
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.io.*;
|
||||
/**
|
||||
* This class makes it easy to drag and drop files from the operating
|
||||
* system to a Java program. Any <tt>java.awt.Component</tt> can be
|
||||
* dropped onto, but only <tt>javax.swing.JComponent</tt>s will indicate
|
||||
* the drop event with a changed border.
|
||||
* <p/>
|
||||
* To use this class, construct a new <tt>FileDrop</tt> by passing
|
||||
* it the target component and a <tt>Listener</tt> to receive notification
|
||||
* when file(s) have been dropped. Here is an example:
|
||||
* <p/>
|
||||
* <code><pre>
|
||||
* JPanel myPanel = new JPanel();
|
||||
* new FileDrop( myPanel, new FileDrop.Listener()
|
||||
* { public void filesDropped( java.io.File[] files )
|
||||
* {
|
||||
* // handle file drop
|
||||
* ...
|
||||
* } // end filesDropped
|
||||
* }); // end FileDrop.Listener
|
||||
* </pre></code>
|
||||
* <p/>
|
||||
* You can specify the border that will appear when files are being dragged by
|
||||
* calling the constructor with a <tt>javax.swing.border.Border</tt>. Only
|
||||
* <tt>JComponent</tt>s will show any indication with a border.
|
||||
* <p/>
|
||||
* You can turn on some debugging features by passing a <tt>PrintStream</tt>
|
||||
* object (such as <tt>System.out</tt>) into the full constructor. A <tt>null</tt>
|
||||
* value will result in no extra debugging information being output.
|
||||
* <p/>
|
||||
*
|
||||
* <p>I'm releasing this code into the Public Domain. Enjoy.
|
||||
* </p>
|
||||
* <p><em>Original author: Robert Harder, rharder@usa.net</em></p>
|
||||
* <p>2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added.</p>
|
||||
*
|
||||
* @author Robert Harder
|
||||
* @author rharder@users.sf.net
|
||||
* @version 1.0.1
|
||||
*/
|
||||
public class FileDrop {
|
||||
// Default border color
|
||||
private static final java.awt.Color defaultBorderColor = new java.awt.Color(0f, 0f, 1f, 0.25f);
|
||||
// BEGIN 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added.
|
||||
private static final String ZERO_CHAR_STRING = "" + (char) 0;
|
||||
/**
|
||||
* Discover if the running JVM is modern enough to have drag and drop.
|
||||
*/
|
||||
private static Boolean supportsDnD;
|
||||
private transient javax.swing.border.Border normalBorder;
|
||||
private transient java.awt.dnd.DropTargetListener dropListener;
|
||||
/**
|
||||
* Constructs a {@link FileDrop} with a default light-blue border
|
||||
* and, if <var>c</var> is a {@link java.awt.Container}, recursively
|
||||
* sets all elements contained within as drop targets, though only
|
||||
* the top level container will change borders.
|
||||
*
|
||||
* @param c Component on which files will be dropped.
|
||||
* @param listener Listens for <tt>filesDropped</tt>.
|
||||
* @since 1.0
|
||||
*/
|
||||
public FileDrop(
|
||||
final java.awt.Component c,
|
||||
final Listener listener) {
|
||||
this(null, // Logging stream
|
||||
c, // Drop target
|
||||
javax.swing.BorderFactory.createMatteBorder(2, 2, 2, 2, defaultBorderColor), // Drag border
|
||||
true, // Recursive
|
||||
listener);
|
||||
} // end constructor
|
||||
/**
|
||||
* Constructor with a default border and the option to recursively set drop targets.
|
||||
* If your component is a <tt>java.awt.Container</tt>, then each of its children
|
||||
* database.Objects.components will also listen for drops, though only the parent will change borders.
|
||||
*
|
||||
* @param c Component on which files will be dropped.
|
||||
* @param recursive Recursively set children as drop targets.
|
||||
* @param listener Listens for <tt>filesDropped</tt>.
|
||||
* @since 1.0
|
||||
*/
|
||||
public FileDrop(
|
||||
final java.awt.Component c,
|
||||
final boolean recursive,
|
||||
final Listener listener) {
|
||||
this(null, // Logging stream
|
||||
c, // Drop target
|
||||
javax.swing.BorderFactory.createMatteBorder(2, 2, 2, 2, defaultBorderColor), // Drag border
|
||||
recursive, // Recursive
|
||||
listener);
|
||||
} // end constructor
|
||||
/**
|
||||
* Constructor with a default border and debugging optionally turned on.
|
||||
* With Debugging turned on, more status messages will be displayed to
|
||||
* <tt>out</tt>. A common way to use this constructor is with
|
||||
* <tt>System.out</tt> or <tt>System.err</tt>. A <tt>null</tt> value for
|
||||
* the parameter <tt>out</tt> will result in no debugging output.
|
||||
*
|
||||
* @param out PrintStream to record debugging info or null for no debugging.
|
||||
* @param out
|
||||
* @param c Component on which files will be dropped.
|
||||
* @param listener Listens for <tt>filesDropped</tt>.
|
||||
* @since 1.0
|
||||
*/
|
||||
public FileDrop(
|
||||
final PrintStream out,
|
||||
final java.awt.Component c,
|
||||
final Listener listener) {
|
||||
this(out, // Logging stream
|
||||
c, // Drop target
|
||||
javax.swing.BorderFactory.createMatteBorder(2, 2, 2, 2, defaultBorderColor),
|
||||
false, // Recursive
|
||||
listener);
|
||||
} // end constructor
|
||||
/**
|
||||
* Constructor with a default border, debugging optionally turned on
|
||||
* and the option to recursively set drop targets.
|
||||
* If your component is a <tt>java.awt.Container</tt>, then each of its children
|
||||
* database.Objects.components will also listen for drops, though only the parent will change borders.
|
||||
* With Debugging turned on, more status messages will be displayed to
|
||||
* <tt>out</tt>. A common way to use this constructor is with
|
||||
* <tt>System.out</tt> or <tt>System.err</tt>. A <tt>null</tt> value for
|
||||
* the parameter <tt>out</tt> will result in no debugging output.
|
||||
*
|
||||
* @param out PrintStream to record debugging info or null for no debugging.
|
||||
* @param out
|
||||
* @param c Component on which files will be dropped.
|
||||
* @param recursive Recursively set children as drop targets.
|
||||
* @param listener Listens for <tt>filesDropped</tt>.
|
||||
* @since 1.0
|
||||
*/
|
||||
public FileDrop(
|
||||
final PrintStream out,
|
||||
final java.awt.Component c,
|
||||
final boolean recursive,
|
||||
final Listener listener) {
|
||||
this(out, // Logging stream
|
||||
c, // Drop target
|
||||
javax.swing.BorderFactory.createMatteBorder(2, 2, 2, 2, defaultBorderColor), // Drag border
|
||||
recursive, // Recursive
|
||||
listener);
|
||||
} // end constructor
|
||||
/**
|
||||
* Constructor with a specified border
|
||||
*
|
||||
* @param c Component on which files will be dropped.
|
||||
* @param dragBorder Border to use on <tt>JComponent</tt> when dragging occurs.
|
||||
* @param listener Listens for <tt>filesDropped</tt>.
|
||||
* @since 1.0
|
||||
*/
|
||||
public FileDrop(
|
||||
final java.awt.Component c,
|
||||
final javax.swing.border.Border dragBorder,
|
||||
final Listener listener) {
|
||||
this(
|
||||
null, // Logging stream
|
||||
c, // Drop target
|
||||
dragBorder, // Drag border
|
||||
false, // Recursive
|
||||
listener);
|
||||
} // end constructor
|
||||
/**
|
||||
* Constructor with a specified border and the option to recursively set drop targets.
|
||||
* If your component is a <tt>java.awt.Container</tt>, then each of its children
|
||||
* database.Objects.components will also listen for drops, though only the parent will change borders.
|
||||
*
|
||||
* @param c Component on which files will be dropped.
|
||||
* @param dragBorder Border to use on <tt>JComponent</tt> when dragging occurs.
|
||||
* @param recursive Recursively set children as drop targets.
|
||||
* @param listener Listens for <tt>filesDropped</tt>.
|
||||
* @since 1.0
|
||||
*/
|
||||
public FileDrop(
|
||||
final java.awt.Component c,
|
||||
final javax.swing.border.Border dragBorder,
|
||||
final boolean recursive,
|
||||
final Listener listener) {
|
||||
this(
|
||||
null,
|
||||
c,
|
||||
dragBorder,
|
||||
recursive,
|
||||
listener);
|
||||
} // end constructor
|
||||
/**
|
||||
* Constructor with a specified border and debugging optionally turned on.
|
||||
* With Debugging turned on, more status messages will be displayed to
|
||||
* <tt>out</tt>. A common way to use this constructor is with
|
||||
* <tt>System.out</tt> or <tt>System.err</tt>. A <tt>null</tt> value for
|
||||
* the parameter <tt>out</tt> will result in no debugging output.
|
||||
*
|
||||
* @param out PrintStream to record debugging info or null for no debugging.
|
||||
* @param c Component on which files will be dropped.
|
||||
* @param dragBorder Border to use on <tt>JComponent</tt> when dragging occurs.
|
||||
* @param listener Listens for <tt>filesDropped</tt>.
|
||||
* @since 1.0
|
||||
*/
|
||||
public FileDrop(
|
||||
final PrintStream out,
|
||||
final java.awt.Component c,
|
||||
final javax.swing.border.Border dragBorder,
|
||||
final Listener listener) {
|
||||
this(
|
||||
out, // Logging stream
|
||||
c, // Drop target
|
||||
dragBorder, // Drag border
|
||||
false, // Recursive
|
||||
listener);
|
||||
} // end constructor
|
||||
/**
|
||||
* Full constructor with a specified border and debugging optionally turned on.
|
||||
* With Debugging turned on, more status messages will be displayed to
|
||||
* <tt>out</tt>. A common way to use this constructor is with
|
||||
* <tt>System.out</tt> or <tt>System.err</tt>. A <tt>null</tt> value for
|
||||
* the parameter <tt>out</tt> will result in no debugging output.
|
||||
*
|
||||
* @param out PrintStream to record debugging info or null for no debugging.
|
||||
* @param c Component on which files will be dropped.
|
||||
* @param dragBorder Border to use on <tt>JComponent</tt> when dragging occurs.
|
||||
* @param recursive Recursively set children as drop targets.
|
||||
* @param listener Listens for <tt>filesDropped</tt>.
|
||||
* @since 1.0
|
||||
*/
|
||||
public FileDrop(
|
||||
final PrintStream out,
|
||||
final java.awt.Component c,
|
||||
final javax.swing.border.Border dragBorder,
|
||||
final boolean recursive,
|
||||
final Listener listener) {
|
||||
if (supportsDnD()) { // Make a drop listener
|
||||
dropListener = new java.awt.dnd.DropTargetListener() {
|
||||
public void dragEnter(java.awt.dnd.DropTargetDragEvent evt) {
|
||||
log(out, "FileDrop: dragEnter event.");
|
||||
// Is this an acceptable drag event?
|
||||
if (isDragOk(out, evt)) {
|
||||
// If it's a Swing component, set its border
|
||||
if (c instanceof javax.swing.JComponent) {
|
||||
javax.swing.JComponent jc = (javax.swing.JComponent) c;
|
||||
normalBorder = jc.getBorder();
|
||||
log(out, "FileDrop: normal border saved.");
|
||||
jc.setBorder(dragBorder);
|
||||
log(out, "FileDrop: drag border set.");
|
||||
} // end if: JComponent
|
||||
// Acknowledge that it's okay to enter
|
||||
//evt.acceptDrag( java.awt.dnd.DnDConstants.ACTION_COPY_OR_MOVE );
|
||||
evt.acceptDrag(java.awt.dnd.DnDConstants.ACTION_COPY);
|
||||
log(out, "FileDrop: event accepted.");
|
||||
} // end if: drag ok
|
||||
else { // Reject the drag event
|
||||
evt.rejectDrag();
|
||||
log(out, "FileDrop: event rejected.");
|
||||
} // end else: drag not ok
|
||||
} // end dragEnter
|
||||
public void dragOver(java.awt.dnd.DropTargetDragEvent evt) { // This is called continually as long as the mouse is
|
||||
// over the drag target.
|
||||
} // end dragOver
|
||||
public void drop(java.awt.dnd.DropTargetDropEvent evt) {
|
||||
log(out, "FileDrop: drop event.");
|
||||
try { // Get whatever was dropped
|
||||
java.awt.datatransfer.Transferable tr = evt.getTransferable();
|
||||
// Is it a file list?
|
||||
if (tr.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
|
||||
// Say we'll take it.
|
||||
//evt.acceptDrop ( java.awt.dnd.DnDConstants.ACTION_COPY_OR_MOVE );
|
||||
evt.acceptDrop(java.awt.dnd.DnDConstants.ACTION_COPY);
|
||||
log(out, "FileDrop: file list accepted.");
|
||||
// Get a useful list
|
||||
java.util.List fileList = (java.util.List)
|
||||
tr.getTransferData(DataFlavor.javaFileListFlavor);
|
||||
java.util.Iterator iterator = fileList.iterator();
|
||||
// Convert list to array
|
||||
File[] filesTemp = new File[fileList.size()];
|
||||
fileList.toArray(filesTemp);
|
||||
final File[] files = filesTemp;
|
||||
// Alert listener to drop.
|
||||
if (listener != null)
|
||||
listener.filesDropped(files);
|
||||
// Mark that drop is completed.
|
||||
evt.getDropTargetContext().dropComplete(true);
|
||||
log(out, "FileDrop: drop complete.");
|
||||
} // end if: file list
|
||||
else // this section will check for a reader flavor.
|
||||
{
|
||||
// Thanks, Nathan!
|
||||
// BEGIN 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added.
|
||||
DataFlavor[] flavors = tr.getTransferDataFlavors();
|
||||
boolean handled = false;
|
||||
for (int zz = 0; zz < flavors.length; zz++) {
|
||||
if (flavors[zz].isRepresentationClassReader()) {
|
||||
// Say we'll take it.
|
||||
//evt.acceptDrop ( java.awt.dnd.DnDConstants.ACTION_COPY_OR_MOVE );
|
||||
evt.acceptDrop(java.awt.dnd.DnDConstants.ACTION_COPY);
|
||||
log(out, "FileDrop: reader accepted.");
|
||||
Reader reader = flavors[zz].getReaderForText(tr);
|
||||
BufferedReader br = new BufferedReader(reader);
|
||||
if (listener != null)
|
||||
listener.filesDropped(createFileArray(br, out));
|
||||
// Mark that drop is completed.
|
||||
evt.getDropTargetContext().dropComplete(true);
|
||||
log(out, "FileDrop: drop complete.");
|
||||
handled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!handled) {
|
||||
log(out, "FileDrop: not a file list or reader - abort.");
|
||||
evt.rejectDrop();
|
||||
}
|
||||
// END 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added.
|
||||
} // end else: not a file list
|
||||
} // end try
|
||||
catch (IOException io) {
|
||||
log(out, "FileDrop: IOException - abort:");
|
||||
Global.Log.PrintException(io);
|
||||
evt.rejectDrop();
|
||||
} // end catch IOException
|
||||
catch (java.awt.datatransfer.UnsupportedFlavorException ufe) {
|
||||
log(out, "FileDrop: UnsupportedFlavorException - abort:");
|
||||
Global.Log.PrintException(ufe);
|
||||
evt.rejectDrop();
|
||||
} // end catch: UnsupportedFlavorException
|
||||
finally {
|
||||
// If it's a Swing component, reset its border
|
||||
if (c instanceof javax.swing.JComponent) {
|
||||
javax.swing.JComponent jc = (javax.swing.JComponent) c;
|
||||
jc.setBorder(normalBorder);
|
||||
log(out, "FileDrop: normal border restored.");
|
||||
} // end if: JComponent
|
||||
} // end finally
|
||||
} // end drop
|
||||
public void dragExit(java.awt.dnd.DropTargetEvent evt) {
|
||||
log(out, "FileDrop: dragExit event.");
|
||||
// If it's a Swing component, reset its border
|
||||
if (c instanceof javax.swing.JComponent) {
|
||||
javax.swing.JComponent jc = (javax.swing.JComponent) c;
|
||||
jc.setBorder(normalBorder);
|
||||
log(out, "FileDrop: normal border restored.");
|
||||
} // end if: JComponent
|
||||
} // end dragExit
|
||||
public void dropActionChanged(java.awt.dnd.DropTargetDragEvent evt) {
|
||||
log(out, "FileDrop: dropActionChanged event.");
|
||||
// Is this an acceptable drag event?
|
||||
if (isDragOk(out, evt)) { //evt.acceptDrag( java.awt.dnd.DnDConstants.ACTION_COPY_OR_MOVE );
|
||||
evt.acceptDrag(java.awt.dnd.DnDConstants.ACTION_COPY);
|
||||
log(out, "FileDrop: event accepted.");
|
||||
} // end if: drag ok
|
||||
else {
|
||||
evt.rejectDrag();
|
||||
log(out, "FileDrop: event rejected.");
|
||||
} // end else: drag not ok
|
||||
} // end dropActionChanged
|
||||
}; // end DropTargetListener
|
||||
// Make the component (and possibly children) drop targets
|
||||
makeDropTarget(out, c, recursive);
|
||||
} // end if: supports dnd
|
||||
else {
|
||||
log(out, "FileDrop: Drag and drop is not supported with this JVM");
|
||||
} // end else: does not support DnD
|
||||
} // end constructor
|
||||
private static boolean supportsDnD() { // Static Boolean
|
||||
if (supportsDnD == null) {
|
||||
boolean support = false;
|
||||
try {
|
||||
Class arbitraryDndClass = Class.forName("java.awt.dnd.DnDConstants");
|
||||
support = true;
|
||||
} // end try
|
||||
catch (Exception e) {
|
||||
support = false;
|
||||
} // end catch
|
||||
supportsDnD = new Boolean(support);
|
||||
} // end if: first time through
|
||||
return supportsDnD.booleanValue();
|
||||
} // end supportsDnD
|
||||
private static File[] createFileArray(BufferedReader bReader, PrintStream out) {
|
||||
try {
|
||||
java.util.List list = new java.util.ArrayList();
|
||||
String line = null;
|
||||
while ((line = bReader.readLine()) != null) {
|
||||
try {
|
||||
// kde seems to append a 0 char to the end of the reader
|
||||
if (ZERO_CHAR_STRING.equals(line)) continue;
|
||||
File file = new File(new java.net.URI(line));
|
||||
list.add(file);
|
||||
} catch (Exception ex) {
|
||||
log(out, "Error with " + line + ": " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
return (File[]) list.toArray(new File[list.size()]);
|
||||
} catch (IOException ex) {
|
||||
log(out, "FileDrop: IOException");
|
||||
}
|
||||
return new File[0];
|
||||
}
|
||||
/**
|
||||
* Outputs <tt>message</tt> to <tt>out</tt> if it's not null.
|
||||
*/
|
||||
private static void log(PrintStream out, String message) { // Log message if requested
|
||||
// if (out != null)
|
||||
// UI.Print(DebugPrintLevel.DragDrop, message);
|
||||
} // end log
|
||||
/**
|
||||
* Removes the drag-and-drop hooks from the component and optionally
|
||||
* from the all children. You should call this if you add and remove
|
||||
* database.Objects.components after you've set up the drag-and-drop.
|
||||
* This will recursively unregister all database.Objects.components contained within
|
||||
* <var>c</var> if <var>c</var> is a {@link java.awt.Container}.
|
||||
*
|
||||
* @param c The component to unregister as a drop target
|
||||
* @since 1.0
|
||||
*/
|
||||
public static boolean remove(java.awt.Component c) {
|
||||
return remove(null, c, true);
|
||||
} // end remove
|
||||
/**
|
||||
* Removes the drag-and-drop hooks from the component and optionally
|
||||
* from the all children. You should call this if you add and remove
|
||||
* database.Objects.components after you've set up the drag-and-drop.
|
||||
*
|
||||
* @param out Optional {@link PrintStream} for logging drag and drop messages
|
||||
* @param c The component to unregister
|
||||
* @param recursive Recursively unregister database.Objects.components within a container
|
||||
* @since 1.0
|
||||
*/
|
||||
public static boolean remove(PrintStream out, java.awt.Component c, boolean recursive) { // Make sure we support dnd.
|
||||
if (supportsDnD()) {
|
||||
log(out, "FileDrop: Removing drag-and-drop hooks.");
|
||||
c.setDropTarget(null);
|
||||
if (recursive && (c instanceof java.awt.Container)) {
|
||||
java.awt.Component[] comps = ((java.awt.Container) c).getComponents();
|
||||
for (int i = 0; i < comps.length; i++)
|
||||
remove(out, comps[i], recursive);
|
||||
return true;
|
||||
} // end if: recursive
|
||||
else return false;
|
||||
} // end if: supports DnD
|
||||
else return false;
|
||||
} // end remove
|
||||
// END 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added.
|
||||
private void makeDropTarget(final PrintStream out, final java.awt.Component c, boolean recursive) {
|
||||
// Make drop target
|
||||
final java.awt.dnd.DropTarget dt = new java.awt.dnd.DropTarget();
|
||||
try {
|
||||
dt.addDropTargetListener(dropListener);
|
||||
} // end try
|
||||
catch (java.util.TooManyListenersException e) {
|
||||
Global.Log.PrintException(e);
|
||||
log(out, "FileDrop: Drop will not work due to previous error. Do you have another listener attached?");
|
||||
} // end catch
|
||||
// Listen for hierarchy changes and remove the drop target when the parent gets cleared out.
|
||||
c.addHierarchyListener(new java.awt.event.HierarchyListener() {
|
||||
public void hierarchyChanged(java.awt.event.HierarchyEvent evt) {
|
||||
log(out, "FileDrop: Hierarchy changed.");
|
||||
java.awt.Component parent = c.getParent();
|
||||
if (parent == null) {
|
||||
c.setDropTarget(null);
|
||||
log(out, "FileDrop: Drop target cleared from component.");
|
||||
} // end if: null parent
|
||||
else {
|
||||
new java.awt.dnd.DropTarget(c, dropListener);
|
||||
log(out, "FileDrop: Drop target added to component.");
|
||||
} // end else: parent not null
|
||||
} // end hierarchyChanged
|
||||
}); // end hierarchy listener
|
||||
if (c.getParent() != null)
|
||||
new java.awt.dnd.DropTarget(c, dropListener);
|
||||
if (recursive && (c instanceof java.awt.Container)) {
|
||||
// Get the container
|
||||
java.awt.Container cont = (java.awt.Container) c;
|
||||
// Get it's database.Objects.components
|
||||
java.awt.Component[] comps = cont.getComponents();
|
||||
// Set it's database.Objects.components as listeners also
|
||||
for (int i = 0; i < comps.length; i++)
|
||||
makeDropTarget(out, comps[i], recursive);
|
||||
} // end if: recursively set database.Objects.components as listener
|
||||
} // end dropListener
|
||||
/**
|
||||
* Determine if the dragged data is a file list.
|
||||
*/
|
||||
private boolean isDragOk(final PrintStream out, final java.awt.dnd.DropTargetDragEvent evt) {
|
||||
boolean ok = false;
|
||||
// Get data flavors being dragged
|
||||
DataFlavor[] flavors = evt.getCurrentDataFlavors();
|
||||
// See if any of the flavors are a file list
|
||||
int i = 0;
|
||||
while (!ok && i < flavors.length) {
|
||||
// BEGIN 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added.
|
||||
// Is the flavor a file list?
|
||||
final DataFlavor curFlavor = flavors[i];
|
||||
if (curFlavor.equals(DataFlavor.javaFileListFlavor) ||
|
||||
curFlavor.isRepresentationClassReader()) {
|
||||
ok = true;
|
||||
}
|
||||
// END 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added.
|
||||
i++;
|
||||
} // end while: through flavors
|
||||
// If logging is enabled, show data flavors
|
||||
if (out != null) {
|
||||
if (flavors.length == 0)
|
||||
log(out, "FileDrop: no data flavors.");
|
||||
for (i = 0; i < flavors.length; i++)
|
||||
log(out, flavors[i].toString());
|
||||
} // end if: logging enabled
|
||||
return ok;
|
||||
} // end isDragOk
|
||||
|
||||
|
||||
|
||||
|
||||
/* ******** I N N E R I N T E R F A C E L I S T E N E R ******** */
|
||||
/**
|
||||
* Implement this inner interface to listen for when files are dropped. For example
|
||||
* your class declaration may begin like this:
|
||||
* <code><pre>
|
||||
* public class MyClass implements FileDrop.Listener
|
||||
* ...
|
||||
* public void filesDropped( java.io.File[] files )
|
||||
* {
|
||||
* ...
|
||||
* } // end filesDropped
|
||||
* ...
|
||||
* </pre></code>
|
||||
*
|
||||
* @since 1.1
|
||||
*/
|
||||
public interface Listener {
|
||||
/**
|
||||
* This method is called when files have been successfully dropped.
|
||||
*
|
||||
* @param files An array of <tt>File</tt>s that were dropped.
|
||||
* @since 1.0
|
||||
*/
|
||||
void filesDropped(File[] files);
|
||||
} // end inner-interface Listener
|
||||
|
||||
|
||||
/* ******** I N N E R C L A S S ******** */
|
||||
/**
|
||||
* This is the event that is passed to the
|
||||
* {@link FileDropListener#filesDropped filesDropped(...)} method in
|
||||
* your {@link FileDropListener} when files are dropped onto
|
||||
* a registered drop target.
|
||||
*
|
||||
* <p>I'm releasing this code into the Public Domain. Enjoy.</p>
|
||||
*
|
||||
* @author Robert Harder
|
||||
* @author rob@iharder.net
|
||||
* @version 1.2
|
||||
*/
|
||||
public static class Event extends java.util.EventObject {
|
||||
private final File[] files;
|
||||
/**
|
||||
* Constructs an {@link Event} with the array
|
||||
* of files that were dropped and the
|
||||
* {@link FileDrop} that initiated the event.
|
||||
*
|
||||
* @param files The array of files that were dropped
|
||||
* @source The event source
|
||||
* @since 1.1
|
||||
*/
|
||||
public Event(File[] files, Object source) {
|
||||
super(source);
|
||||
this.files = files;
|
||||
} // end constructor
|
||||
/**
|
||||
* Returns an array of files that were dropped on a
|
||||
* registered drop target.
|
||||
*
|
||||
* @return array of files that were dropped
|
||||
* @since 1.1
|
||||
*/
|
||||
public File[] getFiles() {
|
||||
return files;
|
||||
} // end getFiles
|
||||
} // end inner class Event
|
||||
|
||||
|
||||
|
||||
/* ******** I N N E R C L A S S ******** */
|
||||
/**
|
||||
* At last an easy way to encapsulate your custom objects for dragging and dropping
|
||||
* in your Java programs!
|
||||
* When you need to create a {@link java.awt.datatransfer.Transferable} object,
|
||||
* use this class to wrap your object.
|
||||
* For example:
|
||||
* <pre><code>
|
||||
* ...
|
||||
* MyCoolClass myObj = new MyCoolClass();
|
||||
* Transferable xfer = new TransferableObject( myObj );
|
||||
* ...
|
||||
* </code></pre>
|
||||
* Or if you need to know when the data was actually dropped, like when you're
|
||||
* moving data out of a list, say, you can use the {@link Fetcher}
|
||||
* inner class to return your object Just in Time.
|
||||
* For example:
|
||||
* <pre><code>
|
||||
* ...
|
||||
* final MyCoolClass myObj = new MyCoolClass();
|
||||
*
|
||||
* TransferableObject.Fetcher fetcher = new TransferableObject.Fetcher()
|
||||
* { public Object getObject(){ return myObj; }
|
||||
* }; // end fetcher
|
||||
*
|
||||
* Transferable xfer = new TransferableObject( fetcher );
|
||||
* ...
|
||||
* </code></pre>
|
||||
* <p>
|
||||
* The {@link DataFlavor} associated with
|
||||
* {@link TransferableObject} has the representation class
|
||||
* <tt>net.iharder.dnd.TransferableObject.class</tt> and MIME type
|
||||
* <tt>application/x-net.iharder.dnd.TransferableObject</tt>.
|
||||
* This data flavor is accessible via the static
|
||||
* {@link #DATA_FLAVOR} property.
|
||||
*
|
||||
*
|
||||
* <p>I'm releasing this code into the Public Domain. Enjoy.</p>
|
||||
*
|
||||
* @author Robert Harder
|
||||
* @author rob@iharder.net
|
||||
* @version 1.2
|
||||
*/
|
||||
public static class TransferableObject implements java.awt.datatransfer.Transferable {
|
||||
/**
|
||||
* The MIME type for {@link #DATA_FLAVOR} is
|
||||
* <tt>application/x-net.iharder.dnd.TransferableObject</tt>.
|
||||
*
|
||||
* @since 1.1
|
||||
*/
|
||||
public final static String MIME_TYPE = "application/x-net.iharder.dnd.TransferableObject";
|
||||
/**
|
||||
* The default {@link DataFlavor} for
|
||||
* {@link TransferableObject} has the representation class
|
||||
* <tt>net.iharder.dnd.TransferableObject.class</tt>
|
||||
* and the MIME type
|
||||
* <tt>application/x-net.iharder.dnd.TransferableObject</tt>.
|
||||
*
|
||||
* @since 1.1
|
||||
*/
|
||||
public final static DataFlavor DATA_FLAVOR =
|
||||
new DataFlavor(TransferableObject.class, MIME_TYPE);
|
||||
private Fetcher fetcher;
|
||||
private Object data;
|
||||
private DataFlavor customFlavor;
|
||||
/**
|
||||
* Creates a new {@link TransferableObject} that wraps <var>data</var>.
|
||||
* Along with the {@link #DATA_FLAVOR} associated with this class,
|
||||
* this creates a custom data flavor with a representation class
|
||||
* determined from <code>data.getClass()</code> and the MIME type
|
||||
* <tt>application/x-net.iharder.dnd.TransferableObject</tt>.
|
||||
*
|
||||
* @param data The data to transfer
|
||||
* @since 1.1
|
||||
*/
|
||||
public TransferableObject(Object data) {
|
||||
this.data = data;
|
||||
this.customFlavor = new DataFlavor(data.getClass(), MIME_TYPE);
|
||||
} // end constructor
|
||||
/**
|
||||
* Creates a new {@link TransferableObject} that will return the
|
||||
* object that is returned by <var>fetcher</var>.
|
||||
* No custom data flavor is set other than the default
|
||||
* {@link #DATA_FLAVOR}.
|
||||
*
|
||||
* @param fetcher The {@link Fetcher} that will return the data object
|
||||
* @see Fetcher
|
||||
* @since 1.1
|
||||
*/
|
||||
public TransferableObject(Fetcher fetcher) {
|
||||
this.fetcher = fetcher;
|
||||
} // end constructor
|
||||
/**
|
||||
* Creates a new {@link TransferableObject} that will return the
|
||||
* object that is returned by <var>fetcher</var>.
|
||||
* Along with the {@link #DATA_FLAVOR} associated with this class,
|
||||
* this creates a custom data flavor with a representation class <var>dataClass</var>
|
||||
* and the MIME type
|
||||
* <tt>application/x-net.iharder.dnd.TransferableObject</tt>.
|
||||
*
|
||||
* @param dataClass The {@link Class} to use in the custom data flavor
|
||||
* @param fetcher The {@link Fetcher} that will return the data object
|
||||
* @see Fetcher
|
||||
* @since 1.1
|
||||
*/
|
||||
public TransferableObject(Class dataClass, Fetcher fetcher) {
|
||||
this.fetcher = fetcher;
|
||||
this.customFlavor = new DataFlavor(dataClass, MIME_TYPE);
|
||||
} // end constructor
|
||||
/**
|
||||
* Returns the custom {@link DataFlavor} associated
|
||||
* with the encapsulated object or <tt>null</tt> if the {@link Fetcher}
|
||||
* constructor was used without passing a {@link Class}.
|
||||
*
|
||||
* @return The custom data flavor for the encapsulated object
|
||||
* @since 1.1
|
||||
*/
|
||||
public DataFlavor getCustomDataFlavor() {
|
||||
return customFlavor;
|
||||
} // end getCustomDataFlavor
|
||||
|
||||
|
||||
/* ******** T R A N S F E R A B L E M E T H O D S ******** */
|
||||
/**
|
||||
* Returns a two- or three-element array containing first
|
||||
* the custom data flavor, if one was created in the constructors,
|
||||
* second the default {@link #DATA_FLAVOR} associated with
|
||||
* {@link TransferableObject}, and third the
|
||||
* {@link DataFlavor.stringFlavor}.
|
||||
*
|
||||
* @return An array of supported data flavors
|
||||
* @since 1.1
|
||||
*/
|
||||
public DataFlavor[] getTransferDataFlavors() {
|
||||
if (customFlavor != null)
|
||||
return new DataFlavor[]
|
||||
{customFlavor,
|
||||
DATA_FLAVOR,
|
||||
DataFlavor.stringFlavor
|
||||
}; // end flavors array
|
||||
else
|
||||
return new DataFlavor[]
|
||||
{DATA_FLAVOR,
|
||||
DataFlavor.stringFlavor
|
||||
}; // end flavors array
|
||||
} // end getTransferDataFlavors
|
||||
/**
|
||||
* Returns the data encapsulated in this {@link TransferableObject}.
|
||||
* If the {@link Fetcher} constructor was used, then this is when
|
||||
* the {@link Fetcher#getObject getObject()} method will be called.
|
||||
* If the requested data flavor is not supported, then the
|
||||
* {@link Fetcher#getObject getObject()} method will not be called.
|
||||
*
|
||||
* @param flavor The data flavor for the data to return
|
||||
* @return The dropped data
|
||||
* @since 1.1
|
||||
*/
|
||||
public Object getTransferData(DataFlavor flavor)
|
||||
throws java.awt.datatransfer.UnsupportedFlavorException, IOException {
|
||||
// Native object
|
||||
if (flavor.equals(DATA_FLAVOR))
|
||||
return fetcher == null ? data : fetcher.getObject();
|
||||
// String
|
||||
if (flavor.equals(DataFlavor.stringFlavor))
|
||||
return fetcher == null ? data.toString() : fetcher.getObject().toString();
|
||||
// We can't do anything else
|
||||
throw new java.awt.datatransfer.UnsupportedFlavorException(flavor);
|
||||
} // end getTransferData
|
||||
/**
|
||||
* Returns <tt>true</tt> if <var>flavor</var> is one of the supported
|
||||
* flavors. Flavors are supported using the <code>equals(...)</code> method.
|
||||
*
|
||||
* @param flavor The data flavor to check
|
||||
* @return Whether or not the flavor is supported
|
||||
* @since 1.1
|
||||
*/
|
||||
public boolean isDataFlavorSupported(DataFlavor flavor) {
|
||||
// Native object
|
||||
if (flavor.equals(DATA_FLAVOR))
|
||||
return true;
|
||||
// String
|
||||
return flavor.equals(DataFlavor.stringFlavor);
|
||||
// We can't do anything else
|
||||
} // end isDataFlavorSupported
|
||||
|
||||
|
||||
/* ******** I N N E R I N T E R F A C E F E T C H E R ******** */
|
||||
/**
|
||||
* Instead of passing your data directly to the {@link TransferableObject}
|
||||
* constructor, you may want to know exactly when your data was received
|
||||
* in case you need to remove it from its source (or do anyting else to it).
|
||||
* When the {@link #getTransferData getTransferData(...)} method is called
|
||||
* on the {@link TransferableObject}, the {@link Fetcher}'s
|
||||
* {@link #getObject getObject()} method will be called.
|
||||
*
|
||||
* @author Robert Harder
|
||||
* @version 1.1
|
||||
* @copyright 2001
|
||||
* @since 1.1
|
||||
*/
|
||||
public interface Fetcher {
|
||||
/**
|
||||
* Return the object being encapsulated in the
|
||||
* {@link TransferableObject}.
|
||||
*
|
||||
* @return The dropped object
|
||||
* @since 1.1
|
||||
*/
|
||||
Object getObject();
|
||||
} // end inner interface Fetcher
|
||||
} // end class TransferableObject
|
||||
} // end class FileDrop
|
||||
154
src/Common_old/UI/Editor/BaseEditor.java
Normal file
154
src/Common_old/UI/Editor/BaseEditor.java
Normal file
@@ -0,0 +1,154 @@
|
||||
package Common_old.UI.Editor;
|
||||
import Common_old.Current;
|
||||
import _VisualDVM.Global;
|
||||
import Common_old.UI.Menus.StyledPopupMenu;
|
||||
import Common_old.UI.Menus.TextEditorMenu;
|
||||
import Common_old.UI.Themes.ThemeElement;
|
||||
import Common_old.UI.UI;
|
||||
import Common_old.UI.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 {
|
||||
private 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) {
|
||||
Global.Log.Print("Не удалось перейти на строку " + LineNum);
|
||||
Global.Log.PrintException(ex);
|
||||
}
|
||||
}
|
||||
//------------------------------------------
|
||||
public void FontUp() {
|
||||
changeFont(getFont().getSize() + 1);
|
||||
}
|
||||
public void FontDown() {
|
||||
changeFont(getFont().getSize() - 1);
|
||||
}
|
||||
@Override
|
||||
public void applyTheme() {
|
||||
float font_size = (float) getFont().getSize();
|
||||
Current.getTheme().getEditorTheme().apply(this);
|
||||
setFont(getFont().deriveFont(font_size));
|
||||
menu.applyTheme();
|
||||
//меню связано с редактором. поэтому тема меняется только вместе с ним.
|
||||
}
|
||||
@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;
|
||||
}
|
||||
}
|
||||
30
src/Common_old/UI/Editor/CaretInfo.java
Normal file
30
src/Common_old/UI/Editor/CaretInfo.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package Common_old.UI.Editor;
|
||||
import _VisualDVM.Global;
|
||||
import ProjectData.Files.UI.Editor.SPFEditor;
|
||||
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
||||
public class CaretInfo {
|
||||
public String current_line = ""; //полный текст текущей строки
|
||||
public String before = ""; //кусок строки перед кареткой
|
||||
public String after = ""; //кусок строки после каретки
|
||||
public String prefix_word = ""; //слово перед кареткой
|
||||
public String suffix_word = ""; //слово после каретки
|
||||
public CaretInfo(RSyntaxTextArea Body) {
|
||||
try {
|
||||
int start = Body.getLineStartOffset(Body.getCaretLineNumber());
|
||||
int before_length = Body.getCaretOffsetFromLineStart();
|
||||
int end = Body.getLineEndOffset(Body.getCaretLineNumber());
|
||||
int after_length = end - start - before_length;
|
||||
before = Body.getText(start, before_length).toUpperCase();
|
||||
after = Body.getText(start + before_length, after_length).toUpperCase();
|
||||
//нужно чтобы перевод строки не влезал
|
||||
after = after.replace("\n", "");
|
||||
current_line = (before + after);
|
||||
prefix_word = SPFEditor.getLastWord(before, ' ', ',', ':', '.', '(', ')');
|
||||
suffix_word = SPFEditor.getFirstWord(after, ' ', ',', ':', '.', '(', ')');
|
||||
} catch (Exception ex) {
|
||||
Global.Log.PrintException(ex);
|
||||
}
|
||||
}
|
||||
public CaretInfo() {
|
||||
}
|
||||
}
|
||||
8
src/Common_old/UI/Editor/Viewer.java
Normal file
8
src/Common_old/UI/Editor/Viewer.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package Common_old.UI.Editor;
|
||||
public class Viewer extends BaseEditor {
|
||||
public Viewer() {
|
||||
setLineWrap(true);
|
||||
setWrapStyleWord(true);
|
||||
setEditable(false);
|
||||
}
|
||||
}
|
||||
11
src/Common_old/UI/EmptyDialogFields.form
Normal file
11
src/Common_old/UI/EmptyDialogFields.form
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="Common_old.UI.EmptyDialogFields">
|
||||
<grid id="27dc6" binding="content" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="500" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
</form>
|
||||
12
src/Common_old/UI/EmptyDialogFields.java
Normal file
12
src/Common_old/UI/EmptyDialogFields.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package Common_old.UI;
|
||||
import Common_old.UI.Windows.Dialog.DialogFields;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
public class EmptyDialogFields implements DialogFields {
|
||||
private JPanel content;
|
||||
@Override
|
||||
public Component getContent() {
|
||||
return content;
|
||||
}
|
||||
}
|
||||
15
src/Common_old/UI/Label/ShortLabel.java
Normal file
15
src/Common_old/UI/Label/ShortLabel.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package Common_old.UI.Label;
|
||||
import javax.swing.*;
|
||||
public class ShortLabel extends JLabel {
|
||||
int max = 0;
|
||||
public ShortLabel(int max_in) {
|
||||
max = max_in;
|
||||
}
|
||||
@Override
|
||||
public void setText(String text_in) {
|
||||
if ((max > 0) && (text_in.length() > max)) {
|
||||
super.setText(text_in.substring(0, max - 1) + "...");
|
||||
} else super.setText(text_in);
|
||||
setToolTipText(text_in);
|
||||
}
|
||||
}
|
||||
10
src/Common_old/UI/List/HyperlinksStyledList.java
Normal file
10
src/Common_old/UI/List/HyperlinksStyledList.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package Common_old.UI.List;
|
||||
import Common_old.Current;
|
||||
import Common_old.UI.Themes.VisualiserFonts;
|
||||
public class HyperlinksStyledList extends StyledList {
|
||||
@Override
|
||||
public void applyTheme() {
|
||||
super.applyTheme();
|
||||
setFont(Current.getTheme().Fonts.get(VisualiserFonts.Hyperlink));
|
||||
}
|
||||
}
|
||||
17
src/Common_old/UI/List/StyledList.java
Normal file
17
src/Common_old/UI/List/StyledList.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package Common_old.UI.List;
|
||||
import Common_old.Current;
|
||||
import Common_old.UI.Themes.ThemeElement;
|
||||
import Common_old.UI.Themes.VisualiserFonts;
|
||||
|
||||
import javax.swing.*;
|
||||
public class StyledList extends JList implements ThemeElement {
|
||||
public StyledList() {
|
||||
setFont(Current.getTheme().Fonts.get(VisualiserFonts.TreePlain));
|
||||
applyTheme();
|
||||
}
|
||||
@Override
|
||||
public void applyTheme() {
|
||||
setBackground(Current.getTheme().table_background);
|
||||
setForeground(Current.getTheme().foreground);
|
||||
}
|
||||
}
|
||||
30
src/Common_old/UI/Menus/AttachementsMenu.java
Normal file
30
src/Common_old/UI/Menus/AttachementsMenu.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package Common_old.UI.Menus;
|
||||
import Common_old.Current;
|
||||
import _VisualDVM.Global;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.Pass_2021;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
public class AttachementsMenu extends StyledPopupMenu {
|
||||
JMenuItem mscreenshot;
|
||||
JMenuItem mExplorer;
|
||||
public AttachementsMenu() {
|
||||
add(mscreenshot = Pass_2021.passes.get(PassCode_2021.MakeScreenShot).createMenuItem());
|
||||
addSeparator();
|
||||
mExplorer = new VisualiserMenuItem("Открыть вложения в проводнике...", "/icons/Explorer.png");
|
||||
mExplorer.addActionListener(
|
||||
new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
Desktop.getDesktop().open(Current.getProject().getAttachmentsDirectory());
|
||||
} catch (Exception ex) {
|
||||
Global.Log.PrintException(ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
add(mExplorer);
|
||||
}
|
||||
}
|
||||
24
src/Common_old/UI/Menus/FileStyleMenu.java
Normal file
24
src/Common_old/UI/Menus/FileStyleMenu.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package Common_old.UI.Menus;
|
||||
import Common_old.Current;
|
||||
import ProjectData.Files.LanguageStyle;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
public class FileStyleMenu extends StyledPopupMenu {
|
||||
public FileStyleMenu() {
|
||||
for (LanguageStyle s : LanguageStyle.values()) {
|
||||
JMenuItem m = new VisualiserMenuItem(s.getDescription());
|
||||
m.addActionListener(
|
||||
new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (Current.getFile().UpdateStyle(s)) {
|
||||
Current.getSapfor().ResetAllAnalyses();
|
||||
Current.getFile().form.ShowStyle();
|
||||
}
|
||||
}
|
||||
});
|
||||
add(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
35
src/Common_old/UI/Menus/GraphMenu.java
Normal file
35
src/Common_old/UI/Menus/GraphMenu.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package Common_old.UI.Menus;
|
||||
import Common_old.UI.Trees.StyledTree;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
public class GraphMenu<T extends StyledTree> extends StyledPopupMenu {
|
||||
public T tree;
|
||||
public GraphMenu(T tree_in, String branches_name) {
|
||||
tree = tree_in;
|
||||
JMenuItem m = null;
|
||||
m = new VisualiserMenuItem("Свернуть все " + branches_name);
|
||||
m.addActionListener(new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tree.CollapseAll();
|
||||
}
|
||||
});
|
||||
add(m);
|
||||
m = new VisualiserMenuItem("Развернуть все " + branches_name);
|
||||
m.addActionListener(new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tree.ExpandAll();
|
||||
}
|
||||
});
|
||||
add(m);
|
||||
}
|
||||
public GraphMenu(T tree) {
|
||||
this(tree, tree.getBranchesName());
|
||||
}
|
||||
public void Show(MouseEvent mouseEvent) {
|
||||
show(tree, mouseEvent.getX(), mouseEvent.getY());
|
||||
}
|
||||
}
|
||||
342
src/Common_old/UI/Menus/MainEditorMenu.java
Normal file
342
src/Common_old/UI/Menus/MainEditorMenu.java
Normal file
@@ -0,0 +1,342 @@
|
||||
package Common_old.UI.Menus;
|
||||
import Common_old.Current;
|
||||
import _VisualDVM.Global;
|
||||
import Common_old.UI.Editor.CaretInfo;
|
||||
import Common_old.Utils.Utils;
|
||||
import ProjectData.Files.DBProjectFile;
|
||||
import ProjectData.Files.UI.Editor.SPFEditor;
|
||||
import ProjectData.SapforData.Functions.FuncCall;
|
||||
import ProjectData.SapforData.Functions.FuncInfo;
|
||||
import ProjectData.SapforData.Functions.FunctionType;
|
||||
import ProjectData.SapforData.Loops.Loop;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.Pass_2021;
|
||||
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
public class MainEditorMenu extends TextEditorMenu {
|
||||
FuncCall call = null;
|
||||
FuncInfo decl = null;
|
||||
Loop loop = null;
|
||||
DBProjectFile header = null;
|
||||
//------------------
|
||||
JMenuItem m_comment;
|
||||
JMenuItem m_uncomment;
|
||||
JMenuItem m_inline;
|
||||
JMenuItem m_add_lines_to_region;
|
||||
JMenuItem m_remove_lines_from_region;
|
||||
JMenuItem m_loop_union;
|
||||
JMenuItem m_undo;
|
||||
JMenuItem m_gotoFunction;
|
||||
JMenuItem m_gotoHeader;
|
||||
//-----------------
|
||||
public MainEditorMenu(RSyntaxTextArea editor_in) {
|
||||
super(editor_in);
|
||||
addSeparator();
|
||||
m_gotoHeader = new VisualiserMenuItem("Перейти к заголовочному файлу", "/icons/Transformations/SPF_InsertIncludesPass.png");
|
||||
m_gotoHeader.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Pass_2021.passes.get(PassCode_2021.OpenCurrentFile).Do(header);
|
||||
}
|
||||
});
|
||||
add(m_gotoHeader);
|
||||
addSeparator();
|
||||
m_gotoFunction = new VisualiserMenuItem("Перейти к объявлению процедуры", "/icons/versions/currentVersion.png");
|
||||
m_gotoFunction.addActionListener(
|
||||
new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
decl.Show(true);
|
||||
}
|
||||
});
|
||||
add(m_gotoFunction);
|
||||
m_inline = new VisualiserMenuItem("Подставить вызов процедуры", "/icons/Transformations/SPF_InlineProcedures.png");
|
||||
m_inline.addActionListener(
|
||||
new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Pass_2021.passes.get(PassCode_2021.SPF_InlineProcedure).Do(call);
|
||||
}
|
||||
});
|
||||
add(m_inline);
|
||||
addSeparator();
|
||||
m_loop_union = new VisualiserMenuItem("Объединить цикл со следующим", "/icons/Transformations/SPF_LoopUnion.png");
|
||||
m_loop_union.addActionListener(
|
||||
new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Pass_2021.passes.get(PassCode_2021.SPF_LoopUnionCurrent).Do();
|
||||
}
|
||||
});
|
||||
add(m_loop_union);
|
||||
m_add_lines_to_region = new VisualiserMenuItem("Добавить строки в область", "/icons/Menu/AddLines.png");
|
||||
m_add_lines_to_region.addActionListener(
|
||||
new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
Pass_2021.passes.get(PassCode_2021.SPF_ChangeSpfIntervals).Do(
|
||||
((RSyntaxTextArea) editor).getLineOfOffset(editor.getSelectionStart()) + 1,
|
||||
((RSyntaxTextArea) editor).getLineOfOffset(editor.getSelectionEnd()) + 1,
|
||||
1
|
||||
);
|
||||
} catch (Exception ex) {
|
||||
Global.Log.PrintException(ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
add(m_add_lines_to_region);
|
||||
m_remove_lines_from_region = new VisualiserMenuItem("Удалить строки из области", "/icons/Menu/RemoveLines.png");
|
||||
m_remove_lines_from_region.addActionListener(
|
||||
new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
Pass_2021.passes.get(PassCode_2021.SPF_ChangeSpfIntervals).Do(
|
||||
((RSyntaxTextArea) editor).getLineOfOffset(editor.getSelectionStart()) + 1,
|
||||
((RSyntaxTextArea) editor).getLineOfOffset(editor.getSelectionEnd()) + 1,
|
||||
0
|
||||
);
|
||||
} catch (Exception ex) {
|
||||
Global.Log.PrintException(ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
add(m_remove_lines_from_region);
|
||||
addSeparator();
|
||||
m_comment = new VisualiserMenuItem("Закомментировать блок", "/icons/Editor/Comment.png");
|
||||
m_comment.addActionListener(
|
||||
new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String new_ = "";
|
||||
String[] data = selectedText.split("\n");
|
||||
int i = 0;
|
||||
switch (Current.getFile().languageName) {
|
||||
case fortran:
|
||||
for (String line : data) {
|
||||
if (!line.startsWith("!")) {
|
||||
new_ += "!" + line;
|
||||
} else new_ += line;
|
||||
if (i < data.length - 1) new_ += "\n";
|
||||
++i;
|
||||
}
|
||||
break;
|
||||
case c:
|
||||
case cpp:
|
||||
for (String line : data) {
|
||||
if (!line.startsWith("//")) {
|
||||
new_ += "//" + line;
|
||||
} else new_ += line;
|
||||
if (i < data.length - 1) new_ += "\n";
|
||||
++i;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
new_ = selectedText;
|
||||
break;
|
||||
}
|
||||
editor.replaceSelection(new_);
|
||||
}
|
||||
});
|
||||
add(m_comment);
|
||||
m_uncomment = new VisualiserMenuItem("Раскомментировать блок", "/icons/Editor/Uncomment.png");
|
||||
m_uncomment.addActionListener(
|
||||
new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String new_ = "";
|
||||
String[] data = selectedText.split("\n");
|
||||
int i = 0;
|
||||
switch (Current.getFile().languageName) {
|
||||
case fortran:
|
||||
for (String line : data) {
|
||||
if (line.startsWith("!")) {
|
||||
new_ += line.substring(1);
|
||||
} else new_ += line;
|
||||
if (i < data.length - 1) new_ += "\n";
|
||||
++i;
|
||||
}
|
||||
break;
|
||||
case c:
|
||||
case cpp:
|
||||
for (String line : data) {
|
||||
if (line.startsWith("//")) {
|
||||
new_ += line.substring(2);
|
||||
} else new_ += line;
|
||||
if (i < data.length - 1) new_ += "\n";
|
||||
++i;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
new_ = selectedText;
|
||||
break;
|
||||
}
|
||||
//todo. возможно, изменить концепцию на выделенные строки?
|
||||
editor.replaceSelection(new_);
|
||||
}
|
||||
});
|
||||
add(m_uncomment);
|
||||
addSeparator();
|
||||
m_undo = new VisualiserMenuItem("Отменить последнюю модификацию", "/icons/Menu/Undo.png");
|
||||
m_undo.addActionListener(
|
||||
new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
Current.getSapfor().UpdateProjectFiles(false);
|
||||
} catch (Exception ex) {
|
||||
Global.Log.PrintException(ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
add(m_undo);
|
||||
}
|
||||
private void checkFunction() {
|
||||
call = null;
|
||||
decl = null;
|
||||
//--
|
||||
m_inline.setEnabled(false);
|
||||
m_gotoFunction.setEnabled(false);
|
||||
//--
|
||||
m_inline.setToolTipText("");
|
||||
m_gotoFunction.setToolTipText("");
|
||||
//--
|
||||
if (selectedText == null) {
|
||||
m_inline.setText("Невозможно подставить вызов процедуры. Не выделено имя процедуры.");
|
||||
m_gotoFunction.setText("Невозможно перейти к объявлению процедуры. Не выделено имя процедуры");
|
||||
return;
|
||||
}
|
||||
if (selectedText.contains("\n")) {
|
||||
m_inline.setText("Невозможно подставить вызов процедуры. Выделено несколько строк");
|
||||
m_gotoFunction.setText("Невозможно перейти к объявлению процедуры. Выделено несколько строк.");
|
||||
return;
|
||||
}
|
||||
if (!Utils.isFunctionName(selectedText)) {
|
||||
String tip = "Имя процедуры может содержать только английские буквы, цифры и подчеркивания, и не может начинаться с цифры.";
|
||||
//-
|
||||
m_inline.setText("Невозможно подставить вызов процедуры " + Utils.Brackets(selectedText) +
|
||||
" . Выделено некорректное имя.");
|
||||
m_gotoFunction.setText("Невозможно перейти к объявлению процедуры " + Utils.Brackets(selectedText) +
|
||||
" . Выделено некорректное имя.");
|
||||
//-
|
||||
m_inline.setToolTipText(tip);
|
||||
m_gotoFunction.setToolTipText(tip);
|
||||
return;
|
||||
}
|
||||
if (!Pass_2021.passes.get(PassCode_2021.SPF_GetGraphFunctions).isDone()) {
|
||||
m_inline.setText("Невозможно подставить вызов процедуры " + Utils.Brackets(selectedText) +
|
||||
" . Выполните проход \"Граф процедур \".");
|
||||
m_gotoFunction.setText("Невозможно перейти к объявлению процедуры " + Utils.Brackets(selectedText) +
|
||||
" . Выполните проход \"Граф процедур \"");
|
||||
return;
|
||||
}
|
||||
if (Current.getSapfor().isIntrinsic(selectedText)) {
|
||||
m_inline.setText("Невозможно подставить вызов процедуры " + Utils.Brackets(selectedText) +
|
||||
" . Процедура является стандартной.");
|
||||
m_gotoFunction.setText("Невозможно перейти к объявлению процедуры " + Utils.Brackets(selectedText) +
|
||||
" . Процедура является стандартной.");
|
||||
return;
|
||||
}
|
||||
call = Current.getFile().find_func_call(selectedText);
|
||||
if (call == null) {
|
||||
m_inline.setText("Невозможно подставить вызов процедуры " + Utils.Brackets(selectedText) +
|
||||
" . Вызов не найден в текущей строке.");
|
||||
m_gotoFunction.setText("Невозможно перейти к объявлению процедуры " + Utils.Brackets(selectedText) +
|
||||
" . Объявление процедуры уже находится в текущей строке.");
|
||||
return;
|
||||
}
|
||||
decl = Current.getProject().allFunctions.get(call.funcName);
|
||||
if (decl.type.equals(FunctionType.NotFound)) {
|
||||
m_inline.setText("Невозможно подставить вызов процедуры " + Utils.Brackets(selectedText) +
|
||||
" . Объявление процедуры не найдено в проекте.");
|
||||
m_gotoFunction.setText("Невозможно перейти к объявлению процедуры " + Utils.Brackets(selectedText) +
|
||||
" . Объявление процедуры не найдено в проекте.");
|
||||
return;
|
||||
}
|
||||
//---
|
||||
m_inline.setEnabled(true);
|
||||
m_gotoFunction.setEnabled(true);
|
||||
m_inline.setText("Подставить вызов процедуры " + Utils.Brackets(selectedText));
|
||||
m_gotoFunction.setText("Перейти к объявлению процедуры " + Utils.Brackets(selectedText));
|
||||
//--
|
||||
}
|
||||
private void checkHeader() {
|
||||
header = null;
|
||||
m_gotoHeader.setEnabled(false);
|
||||
//--
|
||||
CaretInfo caretInfo = ((SPFEditor) editor).getCaretInfo();
|
||||
if (caretInfo != null) {
|
||||
String header_ = Utils.extractHeaderName(caretInfo.current_line);
|
||||
if (header_ == null) {
|
||||
m_gotoHeader.setText("Невозможно перейти к заголовочному файлу. В текущей строке не найдено включений.");
|
||||
return;
|
||||
}
|
||||
if (!Pass_2021.passes.get(PassCode_2021.SPF_GetIncludeDependencies).isDone()) {
|
||||
m_gotoHeader.setText("Невозможно перейти к заголовочному файлу. Выполните проход \"Поиск зависимостей по включению\"");
|
||||
return;
|
||||
}
|
||||
if (!Current.getFile().relativeHeaders.containsKey(header_)) {
|
||||
m_gotoHeader.setText("Невозможно перейти к заголовочному файлу " + Utils.Brackets(header_) + " . Файл не найден среди включений текущего файла.");
|
||||
return;
|
||||
}
|
||||
header = Current.getFile().relativeHeaders.get(header_);
|
||||
m_gotoHeader.setText("Переход к заголовочному файлу " + Utils.Brackets(header_));
|
||||
m_gotoHeader.setEnabled(true);
|
||||
}
|
||||
}
|
||||
private void checkLoop() {
|
||||
loop = null;
|
||||
m_loop_union.setEnabled(false);
|
||||
if (!Pass_2021.passes.get(PassCode_2021.SPF_GetGraphLoops).isDone()) {
|
||||
m_loop_union.setText("Невозможно объединить цикл в текущей строке со следующим. " +
|
||||
"Выполните проход \"Граф циклов\"");
|
||||
return;
|
||||
}
|
||||
loop = Current.getFile().find_current_loop();
|
||||
if (loop == null) {
|
||||
m_loop_union.setText("Невозможно объединить цикл в текущей строке со следующим. Не найдено циклов в текущей строке.");
|
||||
return;
|
||||
}
|
||||
m_loop_union.setEnabled(true);
|
||||
m_loop_union.setText("Объединить цикл в строке " + Utils.Brackets(loop.line) + " со следующим");
|
||||
}
|
||||
@Override
|
||||
public void CheckElementsVisibility() {
|
||||
super.CheckElementsVisibility();
|
||||
m_strike.setVisible(false);
|
||||
m_unstrike.setVisible(false);
|
||||
checkFunction();
|
||||
checkHeader();
|
||||
checkLoop();
|
||||
if (selectedText == null) {
|
||||
m_comment.setEnabled(false);
|
||||
m_uncomment.setEnabled(false);
|
||||
m_add_lines_to_region.setEnabled(false);
|
||||
m_remove_lines_from_region.setEnabled(false);
|
||||
m_comment.setText("Невозможно закомментировать блок. Не выделено ни одной строки.");
|
||||
m_uncomment.setText("Невозможно раскомментировать блок. Не выделено ни одной строки.");
|
||||
m_add_lines_to_region.setText("Невозможно добавить строки в область. Не выделено ни одной строки.");
|
||||
m_remove_lines_from_region.setText("Невозможно удалить строки из области. Не выделено ни одной строки.");
|
||||
} else {
|
||||
m_comment.setEnabled(true);
|
||||
m_uncomment.setEnabled(true);
|
||||
m_add_lines_to_region.setEnabled(true);
|
||||
m_remove_lines_from_region.setEnabled(true);
|
||||
m_comment.setText("Закомментировать блок");
|
||||
m_uncomment.setText("Раскомментировать блок");
|
||||
m_add_lines_to_region.setText("Добавить строки в область");
|
||||
m_remove_lines_from_region.setText("Удалить строки из области");
|
||||
}
|
||||
if (Current.getSapfor().OldFiles.isEmpty()) {
|
||||
m_undo.setEnabled(false);
|
||||
m_undo.setText("Невозможно отменить последнюю модификацию. Модификации отсутствуют.");
|
||||
} else {
|
||||
m_undo.setEnabled(true);
|
||||
m_undo.setText("Отменить последнюю модификацию.");
|
||||
}
|
||||
}
|
||||
}
|
||||
18
src/Common_old/UI/Menus/PassesSubMenu.java
Normal file
18
src/Common_old/UI/Menus/PassesSubMenu.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package Common_old.UI.Menus;
|
||||
import Common_old.Current;
|
||||
import Common_old.UI.Themes.VisualiserFonts;
|
||||
import Common_old.Utils.Utils;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.Pass_2021;
|
||||
|
||||
import javax.swing.*;
|
||||
public class PassesSubMenu extends JMenu {
|
||||
public PassesSubMenu(String title, String icon, PassCode_2021... passes) {
|
||||
super(title);
|
||||
setIcon(Utils.getIcon(icon));
|
||||
setFont(Current.getTheme().Fonts.get(VisualiserFonts.Menu));
|
||||
for (PassCode_2021 code : passes) {
|
||||
add(Pass_2021.passes.get(code).createMenuItem());
|
||||
}
|
||||
}
|
||||
}
|
||||
135
src/Common_old/UI/Menus/ProjectFilesMenu.java
Normal file
135
src/Common_old/UI/Menus/ProjectFilesMenu.java
Normal file
@@ -0,0 +1,135 @@
|
||||
package Common_old.UI.Menus;
|
||||
import Common_old.Current;
|
||||
import _VisualDVM.Global;
|
||||
import Common_old.UI.Menus_2023.LanguagesSubmenu;
|
||||
import Common_old.UI.Menus_2023.StableMenuItem;
|
||||
import Common_old.UI.Menus_2023.StylesSubmenu;
|
||||
import Common_old.UI.Menus_2023.TypesSubmenu;
|
||||
import Common_old.UI.Trees.StyledTree;
|
||||
import Common_old.UI.UI;
|
||||
import Common_old.Utils.Utils;
|
||||
import ProjectData.Files.FileType;
|
||||
import ProjectData.Files.LanguageStyle;
|
||||
import ProjectData.LanguageName;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.Pass_2021;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
public class ProjectFilesMenu extends GraphMenu {
|
||||
VisualiserMenuItem m_select_all;
|
||||
VisualiserMenuItem m_unselect_all;
|
||||
VisualiserMenuItem m_multiselection;
|
||||
JMenu mLanguage;
|
||||
JMenu mStyle;
|
||||
JMenu mType;
|
||||
public ProjectFilesMenu(StyledTree tree) {
|
||||
super(tree, "подпапки");
|
||||
addSeparator();
|
||||
JMenuItem m = new VisualiserMenuItem("Открыть в проводнике...", "/icons/Explorer.png");
|
||||
m.addActionListener(
|
||||
new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
Desktop.getDesktop().open(Current.getProject().Home);
|
||||
} catch (Exception ex) {
|
||||
Global.Log.PrintException(ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
add(m);
|
||||
addSeparator();
|
||||
add(new PassesSubMenu("Добавить", "/icons/RedAdd.png",
|
||||
PassCode_2021.AddFile,
|
||||
PassCode_2021.CreateEmptyDirectory,
|
||||
PassCode_2021.ImportFiles));
|
||||
addSeparator();
|
||||
add(new PassesSubMenu("Переименовать", "/icons/Menu/Rename.png",
|
||||
PassCode_2021.RenameFile,
|
||||
PassCode_2021.RenameDirectory));
|
||||
add(new VisualiserMenuItem("Удалить текущий проект", "/icons/Delete.png") {
|
||||
{
|
||||
addActionListener(e -> {
|
||||
if (Current.HasProject()) {
|
||||
UI.getVersionsWindow().getVersionsForm().getTree().SelectNode(Current.getProject().node);
|
||||
Pass_2021.passes.get(PassCode_2021.DeleteVersion).Do();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
addSeparator();
|
||||
m_multiselection = new VisualiserMenuItem("Массовый режим работы с файлами");
|
||||
m_multiselection.setIcon(Utils.getIcon(Global.files_multiselection ? "/icons/Pick.png" : "/icons/NotPick.png"));
|
||||
m_multiselection.addActionListener(e -> {
|
||||
Global.files_multiselection = !Global.files_multiselection;
|
||||
m_multiselection.setIcon(Utils.getIcon(Global.files_multiselection ? "/icons/Pick.png" : "/icons/NotPick.png"));
|
||||
Current.getProject().SelectAllFiles(false);
|
||||
UI.getMainWindow().getProjectWindow().RefreshProjectFiles();
|
||||
|
||||
//-
|
||||
});
|
||||
add(m_multiselection);
|
||||
addSeparator();
|
||||
//-
|
||||
m_select_all = new StableMenuItem("Выбрать всё", "/icons/SelectAll.png");
|
||||
m_select_all.addActionListener(e -> {
|
||||
Current.getProject().SelectAllFiles(true);
|
||||
tree.updateUI();
|
||||
});
|
||||
add(m_select_all);
|
||||
m_unselect_all = new StableMenuItem("Отменить всё", "/icons/UnselectAll.png");
|
||||
m_unselect_all.addActionListener(e -> {
|
||||
Current.getProject().SelectAllFiles(false);
|
||||
tree.updateUI();
|
||||
});
|
||||
add(m_unselect_all);
|
||||
//--------------------------------------------------
|
||||
add(mLanguage = new LanguagesSubmenu(PassCode_2021.SetSelectedFilesLanguage.getDescription()) {
|
||||
@Override
|
||||
public void action(LanguageName languageName) {
|
||||
Pass_2021.passes.get(PassCode_2021.SetSelectedFilesLanguage).Do(languageName);
|
||||
}
|
||||
});
|
||||
add(mStyle = new StylesSubmenu(PassCode_2021.SetSelectedFilesStyle.getDescription()) {
|
||||
@Override
|
||||
public void action(LanguageStyle languageStyle) {
|
||||
Pass_2021.passes.get(PassCode_2021.SetSelectedFilesStyle).Do(languageStyle);
|
||||
}
|
||||
});
|
||||
add(mType = new TypesSubmenu(PassCode_2021.SetSelectedFilesType.getDescription()) {
|
||||
@Override
|
||||
public void action(FileType fileType) {
|
||||
Pass_2021.passes.get(PassCode_2021.SetSelectedFilesType).Do(fileType);
|
||||
}
|
||||
});
|
||||
//--------------------------------------------------
|
||||
add(Pass_2021.passes.get(PassCode_2021.ExcludeSelectedFiles).createMenuItem());
|
||||
add(Pass_2021.passes.get(PassCode_2021.IncludeSelectedFiles).createMenuItem());
|
||||
add(Pass_2021.passes.get(PassCode_2021.ExcludeFile).createMenuItem());
|
||||
add(Pass_2021.passes.get(PassCode_2021.IncludeFile).createMenuItem());
|
||||
add(Pass_2021.passes.get(PassCode_2021.DeleteFile).createMenuItem());
|
||||
add(Pass_2021.passes.get(PassCode_2021.DeleteDirectory).createMenuItem());
|
||||
add(Pass_2021.passes.get(PassCode_2021.DeleteSelectedFiles).createMenuItem());
|
||||
}
|
||||
@Override
|
||||
public void CheckElementsVisibility() {
|
||||
m_select_all.setVisible(Global.files_multiselection);
|
||||
m_unselect_all.setVisible(Global.files_multiselection);
|
||||
mLanguage.setVisible(Global.files_multiselection);
|
||||
mStyle.setVisible(Global.files_multiselection);
|
||||
mType.setVisible(Global.files_multiselection);
|
||||
//-
|
||||
Pass_2021.passes.get(PassCode_2021.ExcludeFile).setControlsVisible(!Global.files_multiselection);
|
||||
Pass_2021.passes.get(PassCode_2021.IncludeFile).setControlsVisible(!Global.files_multiselection);
|
||||
//-
|
||||
Pass_2021.passes.get(PassCode_2021.DeleteFile).setControlsVisible(!Global.files_multiselection);
|
||||
Pass_2021.passes.get(PassCode_2021.DeleteDirectory).setControlsVisible(!Global.files_multiselection);
|
||||
//--
|
||||
Pass_2021.passes.get(PassCode_2021.ExcludeSelectedFiles).setControlsVisible(Global.files_multiselection);
|
||||
Pass_2021.passes.get(PassCode_2021.IncludeSelectedFiles).setControlsVisible(Global.files_multiselection);
|
||||
Pass_2021.passes.get(PassCode_2021.DeleteSelectedFiles).setControlsVisible(Global.files_multiselection);
|
||||
}
|
||||
}
|
||||
|
||||
18
src/Common_old/UI/Menus/PropertiesSubmenu.java
Normal file
18
src/Common_old/UI/Menus/PropertiesSubmenu.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package Common_old.UI.Menus;
|
||||
import Common_old.Current;
|
||||
import _VisualDVM.Global;
|
||||
import Common_old.UI.Themes.VisualiserFonts;
|
||||
import Common_old.Utils.Utils;
|
||||
|
||||
import javax.swing.*;
|
||||
public class PropertiesSubmenu extends JMenu {
|
||||
public PropertiesSubmenu(String title, String icon, String... settings) {
|
||||
super(title);
|
||||
if (icon != null)
|
||||
setIcon(Utils.getIcon(icon));
|
||||
setFont(Current.getTheme().Fonts.get(VisualiserFonts.Menu));
|
||||
for (String name : settings) {
|
||||
Global.properties.addFlagMenuItem(this, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
86
src/Common_old/UI/Menus/SelectionTreeMenu.java
Normal file
86
src/Common_old/UI/Menus/SelectionTreeMenu.java
Normal file
@@ -0,0 +1,86 @@
|
||||
package Common_old.UI.Menus;
|
||||
import Common_old.Current;
|
||||
import Common_old.UI.Menus_2023.StableMenuItem;
|
||||
import Common_old.UI.Selectable;
|
||||
import Common_old.UI.Trees.DataTree;
|
||||
import Common_old.UI.Trees.SelectableTree;
|
||||
import Common_old.Utils.Utils;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
public abstract class SelectionTreeMenu extends GraphMenu<DataTree> {
|
||||
VisualiserMenuItem m_select_for_current;
|
||||
VisualiserMenuItem m_unselect_for_current;
|
||||
VisualiserMenuItem m_select_all;
|
||||
VisualiserMenuItem m_unselect_all;
|
||||
public SelectionTreeMenu(SelectableTree tree_in) {
|
||||
super(tree_in, "");
|
||||
addSeparator();
|
||||
//-
|
||||
m_select_all = new StableMenuItem("Выбрать всё", "/icons/SelectAll.png");
|
||||
m_select_all.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
SelectAll(true);
|
||||
tree.updateUI();
|
||||
}
|
||||
});
|
||||
add(m_select_all);
|
||||
m_unselect_all = new StableMenuItem("Отменить всё", "/icons/UnselectAll.png");
|
||||
m_unselect_all.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
SelectAll(false);
|
||||
tree.updateUI();
|
||||
}
|
||||
});
|
||||
add(m_unselect_all);
|
||||
addSeparator();
|
||||
m_select_for_current = new VisualiserMenuItem("");
|
||||
m_select_for_current.addActionListener(new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Object o = Current.get(tree.getCurrent());
|
||||
if (o instanceof Selectable) {
|
||||
((Selectable) o).SelectAllChildren(true);
|
||||
}
|
||||
tree.updateUI();
|
||||
}
|
||||
});
|
||||
add(m_select_for_current);
|
||||
//--------
|
||||
m_unselect_for_current = new VisualiserMenuItem("");
|
||||
m_unselect_for_current.addActionListener(new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Object o = Current.get(tree.getCurrent());
|
||||
if (o instanceof Selectable) {
|
||||
((Selectable) o).SelectAllChildren(false);
|
||||
}
|
||||
tree.updateUI();
|
||||
}
|
||||
});
|
||||
//-------
|
||||
add(m_unselect_for_current);
|
||||
}
|
||||
public abstract Class getTargetClass(); //для кого позволяется выбирать всех потомков.
|
||||
public abstract void SelectAll(boolean select);
|
||||
@Override
|
||||
public void CheckElementsVisibility() {
|
||||
Object current = Current.get(tree.getCurrent());
|
||||
if ((current != null) && (current.getClass().equals(getTargetClass()))) {
|
||||
String name = ((Selectable) current).getSelectionText();
|
||||
m_select_for_current.setText("Выбрать всё для " +
|
||||
Utils.Brackets(name));
|
||||
m_unselect_for_current.setText("Отменить выбор всех для " +
|
||||
Utils.Brackets(name));
|
||||
//-
|
||||
m_select_for_current.setVisible(true);
|
||||
m_unselect_for_current.setVisible(true);
|
||||
} else {
|
||||
m_select_for_current.setVisible(false);
|
||||
m_unselect_for_current.setVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
38
src/Common_old/UI/Menus/StyledPopupMenu.java
Normal file
38
src/Common_old/UI/Menus/StyledPopupMenu.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package Common_old.UI.Menus;
|
||||
import Common_old.Current;
|
||||
import Common_old.UI.Themes.ThemeElement;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.PopupMenuEvent;
|
||||
import javax.swing.event.PopupMenuListener;
|
||||
public class StyledPopupMenu extends JPopupMenu implements ThemeElement {
|
||||
public StyledPopupMenu() {
|
||||
addPopupMenuListener(new PopupMenuListener() {
|
||||
@Override
|
||||
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
|
||||
CheckElementsVisibility();
|
||||
}
|
||||
@Override
|
||||
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
|
||||
}
|
||||
@Override
|
||||
public void popupMenuCanceled(PopupMenuEvent e) {
|
||||
}
|
||||
});
|
||||
}
|
||||
private void refreshTheme_r(MenuElement element) {
|
||||
element.getComponent().setBackground(Current.getTheme().background);
|
||||
element.getComponent().setForeground(Current.getTheme().foreground);
|
||||
for (MenuElement se : element.getSubElements())
|
||||
refreshTheme_r(se);
|
||||
}
|
||||
@Override
|
||||
public void applyTheme() {
|
||||
setBackground(Current.getTheme().background);
|
||||
setForeground(Current.getTheme().foreground);
|
||||
refreshTheme_r(this);
|
||||
}
|
||||
public void CheckElementsVisibility() {
|
||||
applyTheme();
|
||||
}
|
||||
}
|
||||
30
src/Common_old/UI/Menus/TableMenu.java
Normal file
30
src/Common_old/UI/Menus/TableMenu.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package Common_old.UI.Menus;
|
||||
import Common_old.Constants;
|
||||
import Common_old.Utils.Utils;
|
||||
|
||||
import javax.swing.*;
|
||||
public class TableMenu extends StyledPopupMenu {
|
||||
int row = Constants.Nan;
|
||||
int column = Constants.Nan;
|
||||
Object target = null;
|
||||
//-
|
||||
JTable owner = null;
|
||||
VisualiserMenuItem mcopy;
|
||||
public TableMenu(JTable owner_in) {
|
||||
owner = owner_in;
|
||||
mcopy = new VisualiserMenuItem("Копировать текст текущей ячейки", "/icons/Editor/Copy.png");
|
||||
//если удалось нажать значит все условия выполнены
|
||||
mcopy.addActionListener(e -> Utils.CopyToClipboard(target.toString()));
|
||||
add(mcopy);
|
||||
}
|
||||
@Override
|
||||
public void CheckElementsVisibility() {
|
||||
row = owner.getSelectedRow();
|
||||
column = owner.getSelectedColumn();
|
||||
if ((row >= 0) && (column >= 0)) {
|
||||
target = owner.getValueAt(row, column);
|
||||
mcopy.setVisible(true);
|
||||
} else mcopy.setVisible(false);
|
||||
super.CheckElementsVisibility();
|
||||
}
|
||||
}
|
||||
28
src/Common_old/UI/Menus/TestsCompilationFilterMenu.java
Normal file
28
src/Common_old/UI/Menus/TestsCompilationFilterMenu.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package Common_old.UI.Menus;
|
||||
import GlobalData.Tasks.TaskState;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionListener;
|
||||
public class TestsCompilationFilterMenu extends StyledPopupMenu{
|
||||
public void CreateStateItem(TaskState state, ActionListener listener){
|
||||
JMenuItem m = new VisualiserMenuItem(state.getDescription());
|
||||
m.addActionListener(listener);
|
||||
add(m);
|
||||
}
|
||||
public TestsCompilationFilterMenu(){
|
||||
for (TaskState taskState: TaskState.values()){
|
||||
switch (taskState){
|
||||
case Queued:
|
||||
case FailedToQueue:
|
||||
case NoSuchTask:
|
||||
case AbortingByUser:
|
||||
break;
|
||||
case Waiting:
|
||||
CreateStateItem(taskState, e -> {
|
||||
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
42
src/Common_old/UI/Menus/TextComboBoxMenu.java
Normal file
42
src/Common_old/UI/Menus/TextComboBoxMenu.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package Common_old.UI.Menus;
|
||||
import Common_old.UI.UI;
|
||||
import Common_old.Utils.Utils;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
public class TextComboBoxMenu extends StyledPopupMenu {
|
||||
protected JComboBox<String> box;
|
||||
protected String selectedText = null;
|
||||
//-------------------------------------------------
|
||||
JMenuItem m_copy;
|
||||
JMenuItem m_paste;
|
||||
//-------------------------------------------------
|
||||
public TextComboBoxMenu(JComboBox<String> box_in) {
|
||||
box = box_in;
|
||||
m_copy = new VisualiserMenuItem("Копировать", "/icons/Editor/Copy.png");
|
||||
m_copy.addActionListener(
|
||||
new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Utils.CopyToClipboard(box.getSelectedItem().toString());
|
||||
}
|
||||
});
|
||||
add(m_copy);
|
||||
m_paste = new VisualiserMenuItem("Вставить", "/icons/Editor/Paste.png");
|
||||
m_paste.addActionListener(
|
||||
new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
UI.TrySelect(box, Utils.getFromClipboard());
|
||||
}
|
||||
});
|
||||
add(m_paste);
|
||||
}
|
||||
@Override
|
||||
public void CheckElementsVisibility() {
|
||||
boolean visible_ = box.getSelectedIndex() >= 0;
|
||||
m_paste.setVisible(visible_);
|
||||
m_copy.setVisible(visible_);
|
||||
super.CheckElementsVisibility();
|
||||
}
|
||||
}
|
||||
86
src/Common_old/UI/Menus/TextEditorMenu.java
Normal file
86
src/Common_old/UI/Menus/TextEditorMenu.java
Normal file
@@ -0,0 +1,86 @@
|
||||
package Common_old.UI.Menus;
|
||||
import Common_old.Utils.Utils;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.text.JTextComponent;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.Vector;
|
||||
public class TextEditorMenu extends StyledPopupMenu {
|
||||
protected JTextComponent editor;
|
||||
protected String selectedText = null;
|
||||
//-------------------------------------------------
|
||||
JMenuItem m_cut;
|
||||
JMenuItem m_copy;
|
||||
JMenuItem m_paste;
|
||||
protected JMenuItem m_strike;
|
||||
protected JMenuItem m_unstrike;
|
||||
//-------------------------------------------------
|
||||
public TextEditorMenu(JTextComponent editor_in) {
|
||||
editor = editor_in;
|
||||
m_cut = new VisualiserMenuItem("Вырезать", "/icons/Editor/Cut.png");
|
||||
m_cut.addActionListener(new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
editor.cut();
|
||||
}
|
||||
});
|
||||
add(m_cut);
|
||||
m_copy = new VisualiserMenuItem("Копировать", "/icons/Editor/Copy.png");
|
||||
m_copy.addActionListener(
|
||||
new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
editor.copy();
|
||||
}
|
||||
});
|
||||
add(m_copy);
|
||||
m_paste = new VisualiserMenuItem("Вставить", "/icons/Editor/Paste.png");
|
||||
m_paste.addActionListener(
|
||||
new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
editor.paste();
|
||||
}
|
||||
});
|
||||
add(m_paste);
|
||||
//--
|
||||
m_strike = new VisualiserMenuItem("Вычеркнуть","/icons/Editor/Strikethrough.png");
|
||||
m_strike.addActionListener(
|
||||
new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String[] data = selectedText.split("\n");
|
||||
Vector<String> new_data = new Vector<>();
|
||||
for (String line: data){
|
||||
new_data.add(Utils.strikeThrough(line));
|
||||
}
|
||||
editor.replaceSelection(String.join("\n", new_data));
|
||||
}
|
||||
});
|
||||
add(m_strike);
|
||||
m_unstrike = new VisualiserMenuItem("Отменить вычёркивание","/icons/Editor/NoStrike.png");
|
||||
m_unstrike.addActionListener(
|
||||
new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String[] data = selectedText.split("\n");
|
||||
Vector<String> new_data = new Vector<>();
|
||||
for (String line: data){
|
||||
new_data.add(Utils.noStrikeThrough(line));
|
||||
}
|
||||
editor.replaceSelection(String.join("\n", new_data));
|
||||
}
|
||||
});
|
||||
add(m_unstrike);
|
||||
}
|
||||
@Override
|
||||
public void CheckElementsVisibility() {
|
||||
selectedText = editor.getSelectedText();
|
||||
m_cut.setVisible(editor.isEditable() && (selectedText != null));
|
||||
m_paste.setVisible(editor.isEditable());
|
||||
m_copy.setVisible(selectedText != null);
|
||||
m_strike.setVisible(editor.isEditable() && (selectedText != null));
|
||||
m_unstrike.setVisible(editor.isEditable() && (selectedText != null));
|
||||
super.CheckElementsVisibility();
|
||||
}
|
||||
}
|
||||
53
src/Common_old/UI/Menus/VersionsMenu.java
Normal file
53
src/Common_old/UI/Menus/VersionsMenu.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package Common_old.UI.Menus;
|
||||
import Common_old.Current;
|
||||
import _VisualDVM.Global;
|
||||
import Common_old.UI.Menus_2023.StableMenuItem;
|
||||
import Common_old.UI.Trees.DataTree;
|
||||
import Common_old.UI.UI;
|
||||
import Common_old.Utils.Utils;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.Pass_2021;
|
||||
public class VersionsMenu extends GraphMenu<DataTree> {
|
||||
VisualiserMenuItem m_select_all;
|
||||
VisualiserMenuItem m_unselect_all;
|
||||
VisualiserMenuItem m_multiselection;
|
||||
public VersionsMenu(DataTree tree) {
|
||||
super(tree, "подверсии");
|
||||
add(Pass_2021.passes.get(PassCode_2021.DeleteSubversions).createMenuItem());
|
||||
add(Pass_2021.passes.get(PassCode_2021.DeleteLonelyM).createMenuItem());
|
||||
addSeparator();
|
||||
m_multiselection = new VisualiserMenuItem("Массовый режим работы с версиями");
|
||||
m_multiselection.setIcon(Utils.getIcon(Global.versions_multiselection ? "/icons/Pick.png" : "/icons/NotPick.png"));
|
||||
m_multiselection.addActionListener(e -> {
|
||||
Global.versions_multiselection = !Global.versions_multiselection;
|
||||
m_multiselection.setIcon(Utils.getIcon(Global.versions_multiselection ? "/icons/Pick.png" : "/icons/NotPick.png"));
|
||||
Current.getRoot().SelectAllVersions(false);
|
||||
UI.getVersionsWindow().getVersionsForm().getTree().updateUI();
|
||||
});
|
||||
add(m_multiselection);
|
||||
addSeparator();
|
||||
add(Pass_2021.passes.get(PassCode_2021.DeleteVersion).createMenuItem());
|
||||
//-
|
||||
m_select_all = new StableMenuItem("Выбрать всё, кроме резервных копий","/icons/SelectAll.png");
|
||||
m_select_all.addActionListener(e -> {
|
||||
Current.getRoot().SelectAllVersions(true);
|
||||
tree.updateUI();
|
||||
});
|
||||
add(m_select_all);
|
||||
m_unselect_all = new StableMenuItem("Отменить всё","/icons/UnselectAll.png");
|
||||
m_unselect_all.addActionListener(e -> {
|
||||
Current.getRoot().SelectAllVersions(false);
|
||||
tree.updateUI();
|
||||
});
|
||||
add(m_unselect_all);
|
||||
add(Pass_2021.passes.get(PassCode_2021.DeleteSelectedVersions).createMenuItem());
|
||||
}
|
||||
@Override
|
||||
public void CheckElementsVisibility() {
|
||||
Pass_2021.passes.get(PassCode_2021.DeleteSelectedVersions).setControlsVisible(!Global.versions_multiselection);
|
||||
Pass_2021.passes.get(PassCode_2021.DeleteSelectedVersions).setControlsVisible(Global.versions_multiselection);
|
||||
Pass_2021.passes.get(PassCode_2021.DeleteVersion).setControlsVisible(!Global.versions_multiselection);
|
||||
m_select_all.setVisible(Global.versions_multiselection);
|
||||
m_unselect_all.setVisible(Global.versions_multiselection);
|
||||
}
|
||||
}
|
||||
21
src/Common_old/UI/Menus/VisualiserMenuItem.java
Normal file
21
src/Common_old/UI/Menus/VisualiserMenuItem.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package Common_old.UI.Menus;
|
||||
import Common_old.Current;
|
||||
import Common_old.UI.Themes.VisualiserFonts;
|
||||
import Common_old.Utils.Utils;
|
||||
|
||||
import javax.swing.*;
|
||||
public class VisualiserMenuItem extends JMenuItem {
|
||||
public VisualiserMenuItem(String text) {
|
||||
super(text, null);
|
||||
setFont(Current.getTheme().Fonts.get(VisualiserFonts.Menu));
|
||||
}
|
||||
public VisualiserMenuItem(String text, String icon_path) {
|
||||
super(text);
|
||||
setFont(Current.getTheme().Fonts.get(VisualiserFonts.Menu));
|
||||
if (icon_path != null)
|
||||
setIcon(Utils.getIcon(icon_path));
|
||||
}
|
||||
public VisualiserMenuItem(){
|
||||
setFont(Current.getTheme().Fonts.get(VisualiserFonts.Menu));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package Common_old.UI.Menus_2023.CredentialsBar;
|
||||
import Common_old.Current;
|
||||
import Common_old.UI.Menus_2023.MenuBarButton;
|
||||
import Common_old.UI.Menus_2023.VisualiserMenuBar;
|
||||
import Common_old.UI.Themes.VisualiserFonts;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.Pass_2021;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
public class CredentialsBar extends VisualiserMenuBar {
|
||||
public MenuBarButton MachineButton;
|
||||
public MenuBarButton UserButton;
|
||||
MenuBarButton bExpand;
|
||||
public CredentialsBar(){
|
||||
this.add(bExpand = new MenuBarButton() {
|
||||
{
|
||||
setIcon("/icons/ExpandDown.png");
|
||||
setToolTipText("Развернуть");
|
||||
addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Pass_2021.passes.get(PassCode_2021.UpdateProperty).Do("collapseCredentials", false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, 0);
|
||||
add(MachineButton = new MenuBarButton() {
|
||||
{
|
||||
setIcon("/icons/Machine.png");
|
||||
setFont(VisualiserFonts.TreeBold);
|
||||
setToolTipText("Текущая машина");
|
||||
}
|
||||
});
|
||||
//--
|
||||
add(UserButton = new MenuBarButton() {
|
||||
{
|
||||
setIcon("/icons/User.png");
|
||||
setFont(VisualiserFonts.TreeBold);
|
||||
setToolTipText("Текущий пользователь");
|
||||
}
|
||||
});
|
||||
}
|
||||
public void ShowMachine(){
|
||||
MachineButton.setText(Current.getMachine().getURL());
|
||||
}
|
||||
public void ShowUser(){
|
||||
UserButton.setText(Current.getUser().login);
|
||||
}
|
||||
public void ShowNoMachine(){
|
||||
MachineButton.setText("?");
|
||||
}
|
||||
public void ShowNoUser(){
|
||||
UserButton.setText("?");
|
||||
}
|
||||
}
|
||||
54
src/Common_old/UI/Menus_2023/DataMenuBar.java
Normal file
54
src/Common_old/UI/Menus_2023/DataMenuBar.java
Normal file
@@ -0,0 +1,54 @@
|
||||
package Common_old.UI.Menus_2023;
|
||||
import Common.Database.Tables.DataSet;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionListener;
|
||||
public class DataMenuBar extends VisualiserMenuBar {
|
||||
public JLabel countLabel = null;
|
||||
JButton selectAllButton = null;
|
||||
JButton unselectAllButton = null;
|
||||
//-
|
||||
public ActionListener selectAllListener = null;
|
||||
public ActionListener unselectAllListener = null;
|
||||
//-
|
||||
public DataMenuBar(String dataName, PassCode_2021... passes) {
|
||||
// Font font = Current.getTheme().Fonts.get(VisualiserFonts.TreeBoldItalic).deriveFont(12.0F);
|
||||
add(new JLabel(dataName + " : "));
|
||||
add(countLabel = new JLabel("?"));
|
||||
addPasses(passes);
|
||||
}
|
||||
public void createSelectionButtons(DataSet dataSet) {
|
||||
java.awt.Dimension d = new Dimension(25, 25);
|
||||
if (selectAllButton == null) {
|
||||
add(selectAllButton = new MenuBarButton() {
|
||||
{
|
||||
setIcon("/icons/SelectAll.png");
|
||||
setToolTipText("Выбрать всё");
|
||||
setPreferredSize(d);
|
||||
setMinimumSize(d);
|
||||
setMaximumSize(d);
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
if (unselectAllButton == null) {
|
||||
add(unselectAllButton = new MenuBarButton() {
|
||||
{
|
||||
setIcon("/icons/UnselectAll.png");
|
||||
setToolTipText("Отменить всё");
|
||||
setPreferredSize(d);
|
||||
setMinimumSize(d);
|
||||
setMaximumSize(d);
|
||||
}
|
||||
}, 1);
|
||||
}
|
||||
if (selectAllListener != null) {
|
||||
selectAllButton.removeActionListener(selectAllListener); }
|
||||
selectAllButton.addActionListener(selectAllListener = e -> dataSet.CheckAll(true));
|
||||
if (unselectAllListener != null) {
|
||||
unselectAllButton.removeActionListener(unselectAllListener);
|
||||
}
|
||||
unselectAllButton.addActionListener(unselectAllListener = e -> dataSet.CheckAll(false));
|
||||
}
|
||||
}
|
||||
7
src/Common_old/UI/Menus_2023/ECButtonPosition.java
Normal file
7
src/Common_old/UI/Menus_2023/ECButtonPosition.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package Common_old.UI.Menus_2023;
|
||||
public enum ECButtonPosition {
|
||||
Up,
|
||||
Down,
|
||||
Left,
|
||||
Right
|
||||
}
|
||||
51
src/Common_old/UI/Menus_2023/ExpandCollapseButton.java
Normal file
51
src/Common_old/UI/Menus_2023/ExpandCollapseButton.java
Normal file
@@ -0,0 +1,51 @@
|
||||
package Common_old.UI.Menus_2023;
|
||||
public class ExpandCollapseButton extends MenuBarButton {
|
||||
protected String description;
|
||||
protected ECButtonPosition position;
|
||||
public ExpandCollapseButton(String description_in, ECButtonPosition position_in) {
|
||||
description = description_in;
|
||||
position = position_in;
|
||||
Switch(true);
|
||||
}
|
||||
public void Switch(boolean flag) {
|
||||
String prefix = "?";
|
||||
String icon_name = "Help";
|
||||
if (flag) {
|
||||
prefix = "Развернуть";
|
||||
switch (position) {
|
||||
case Up:
|
||||
icon_name = "ExpandDown";
|
||||
break;
|
||||
case Down:
|
||||
icon_name = "CollapseUp";
|
||||
break;
|
||||
case Left:
|
||||
icon_name = "SilwerArrowLeft";
|
||||
break;
|
||||
case Right:
|
||||
icon_name = "SilwerArrowRight";
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
prefix = "Свернуть";
|
||||
switch (position) {
|
||||
case Up:
|
||||
icon_name = "CollapseUp";
|
||||
break;
|
||||
case Down:
|
||||
icon_name = "ExpandDown";
|
||||
break;
|
||||
case Left:
|
||||
icon_name = "SilwerArrowRight";
|
||||
break;
|
||||
case Right:
|
||||
icon_name = "SilwerArrowLeft";
|
||||
break;
|
||||
}
|
||||
}
|
||||
setToolTipText(prefix + " " + description);
|
||||
setIcon("/icons/" + icon_name + ".png");
|
||||
revalidate();
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package Common_old.UI.Menus_2023.FastAccessMenuBar;
|
||||
import _VisualDVM.Global;
|
||||
import Common_old.UI.Menus_2023.VisualiserMenuBar;
|
||||
import Common_old.UI.UI;
|
||||
import GlobalData.Settings.SettingName;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.Pass_2021;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.LinkedHashMap;
|
||||
public class FastAccessMenuBar extends VisualiserMenuBar {
|
||||
LinkedHashMap<PassCode_2021, JButton> passesButtons = new LinkedHashMap<>();
|
||||
public FastAccessMenuBar() {
|
||||
Refresh();
|
||||
}
|
||||
@Override
|
||||
public void setSizeLimits() {
|
||||
//если задавать PreffredSize 0, скролл НЕ РАБОТАЕТ. Магия!
|
||||
}
|
||||
public void showPass(Pass_2021 pass) {
|
||||
JButton button = null;
|
||||
if (passesButtons.containsKey(pass.code()))
|
||||
button = passesButtons.get((pass.code()));
|
||||
else {
|
||||
button = pass.createButton();
|
||||
passesButtons.put(pass.code(), button);
|
||||
}
|
||||
add(button);
|
||||
Dimension d = button.getPreferredSize();
|
||||
button.setPreferredSize(new Dimension(d.width, 30));
|
||||
revalidate();
|
||||
repaint();
|
||||
}
|
||||
public void Refresh() {
|
||||
UI.Clear(this);
|
||||
int i = 1;
|
||||
for (Pass_2021 pass : Pass_2021.FAPasses) {
|
||||
if (pass.stats.HasUsages()) {
|
||||
showPass(pass);
|
||||
++i;
|
||||
if (i > (Global.db.settings.get(SettingName.FastAccessPassesCount).toInt32())) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Drop(){
|
||||
UI.Clear(this);
|
||||
}
|
||||
}
|
||||
84
src/Common_old/UI/Menus_2023/FileMenuBar/FileMenuBar.java
Normal file
84
src/Common_old/UI/Menus_2023/FileMenuBar/FileMenuBar.java
Normal file
@@ -0,0 +1,84 @@
|
||||
package Common_old.UI.Menus_2023.FileMenuBar;
|
||||
import Common_old.UI.Menus_2023.MenuBarButton;
|
||||
import Common_old.UI.Menus_2023.VisualiserMenuBar;
|
||||
import Common_old.UI.UI;
|
||||
import ProjectData.Files.UI.Editor.SPFEditor;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
public class FileMenuBar extends VisualiserMenuBar {
|
||||
public JSpinner sToGo;
|
||||
JLabel LineCountLabel;
|
||||
public JLabel CurrentSymbolLabel;
|
||||
SPFEditor editor;
|
||||
FileSettingsMenu fileSettingsMenu;
|
||||
public FileMenuBar(SPFEditor editor_in) {
|
||||
editor = editor_in;
|
||||
add(new MenuBarButton() {
|
||||
{
|
||||
setToolTipText("Поиск(Ctrl+F)");
|
||||
setIcon("/icons/LastOpened.png");
|
||||
addActionListener(e -> UI.ShowSearchForm());
|
||||
}
|
||||
});
|
||||
addPasses(PassCode_2021.Save);
|
||||
add(new MenuBarButton() {
|
||||
{
|
||||
setToolTipText("Увеличить шрифт(Ctrl+'+')");
|
||||
setIcon("/icons/Editor/Font+.png");
|
||||
addActionListener(e -> editor.FontUp());
|
||||
}
|
||||
});
|
||||
add(new MenuBarButton() {
|
||||
{
|
||||
setToolTipText("Уменьшить шрифт(Ctrl+'-')");
|
||||
setIcon("/icons/Editor/Font-.png");
|
||||
addActionListener(e -> editor.FontDown());
|
||||
}
|
||||
});
|
||||
add(new MenuBarButton() {
|
||||
boolean isOn = false;
|
||||
{
|
||||
setToolTipText("Отображать спецсимволы");
|
||||
setIcon("/icons/Editor/ShowNoSigns.png");
|
||||
addActionListener(e-> {
|
||||
isOn = !isOn;
|
||||
if (isOn) {
|
||||
setIcon("/icons/Editor/ShowAllSigns.png");
|
||||
setToolTipText("Скрыть спецсимволы");
|
||||
editor.setWhitespaceVisible(true);
|
||||
editor.setEOLMarkersVisible(true);
|
||||
} else {
|
||||
setIcon("/icons/Editor/ShowNoSigns.png");
|
||||
setToolTipText("Отображать спецсимволы");
|
||||
editor.setWhitespaceVisible(false);
|
||||
editor.setEOLMarkersVisible(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
add(new JLabel(" Строка "));
|
||||
add(sToGo = new JSpinner());
|
||||
sToGo.setPreferredSize(new Dimension(60, 25));
|
||||
sToGo.setMaximumSize(new Dimension(60, 25));
|
||||
add(new JLabel(" из "));
|
||||
add(LineCountLabel = new JLabel("?"));
|
||||
add(new JLabel(" | "));
|
||||
add(new JLabel("Позиция "));
|
||||
add(CurrentSymbolLabel = new JLabel());
|
||||
add(new JSeparator());
|
||||
addMenus(fileSettingsMenu = new FileSettingsMenu());
|
||||
//--
|
||||
// addPasses(PassCode_2021.CloseCurrentFile);
|
||||
//-
|
||||
setPreferredSize(new Dimension(0, 30));
|
||||
}
|
||||
public void ShowLinesCount() {
|
||||
LineCountLabel.setText(String.valueOf(editor.getLineCount()));
|
||||
}
|
||||
//-
|
||||
public void ShowLanguage(){fileSettingsMenu.ShowLanguage();}
|
||||
public void ShowType(){fileSettingsMenu.ShowType();}
|
||||
public void ShowStyle(){fileSettingsMenu.ShowStyle();}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package Common_old.UI.Menus_2023.FileMenuBar;
|
||||
import Common_old.Current;
|
||||
import Common_old.UI.Menus_2023.LanguagesSubmenu;
|
||||
import Common_old.UI.Menus_2023.StylesSubmenu;
|
||||
import Common_old.UI.Menus_2023.TypesSubmenu;
|
||||
import Common_old.UI.Menus_2023.VisualiserMenu;
|
||||
import Common_old.UI.UI;
|
||||
import ProjectData.Files.FileType;
|
||||
import ProjectData.Files.LanguageStyle;
|
||||
import ProjectData.LanguageName;
|
||||
|
||||
import javax.swing.*;
|
||||
public class FileSettingsMenu extends VisualiserMenu {
|
||||
JMenu mLanguage;
|
||||
JMenu mStyle;
|
||||
JMenu mType;
|
||||
public FileSettingsMenu() {
|
||||
super("Настройки файла", "/icons/Settings.png");
|
||||
add(mLanguage = new LanguagesSubmenu() {
|
||||
@Override
|
||||
public void action(LanguageName languageName) {
|
||||
if (Current.getFile().UpdateLanguage(languageName)) {
|
||||
Current.getSapfor().ResetAllAnalyses();
|
||||
Current.getFile().form.ShowLanguage();
|
||||
UI.getMainWindow().getProjectWindow().getFilesTreeForm().getTree().RefreshNode(Current.getFile().node);
|
||||
}
|
||||
}
|
||||
});
|
||||
ShowLanguage();
|
||||
//--
|
||||
add(mStyle = new StylesSubmenu() {
|
||||
@Override
|
||||
public void action(LanguageStyle languageStyle) {
|
||||
if (Current.getFile().UpdateStyle(languageStyle)) {
|
||||
Current.getSapfor().ResetAllAnalyses();
|
||||
Current.getFile().form.ShowStyle();
|
||||
}
|
||||
}
|
||||
});
|
||||
ShowStyle();
|
||||
//--
|
||||
add(mType = new TypesSubmenu() {
|
||||
@Override
|
||||
public void action(FileType fileType) {
|
||||
if (Current.getFile().UpdateType(fileType)) {
|
||||
Current.getSapfor().ResetAllAnalyses();
|
||||
UI.getMainWindow().getProjectWindow().getFilesTreeForm().getTree().RefreshNode(Current.getFile().node);
|
||||
Current.getFile().form.ShowType();
|
||||
}
|
||||
}
|
||||
});
|
||||
ShowType();
|
||||
}
|
||||
public void ShowLanguage() {
|
||||
mLanguage.setText("Язык: " + Current.getFile().languageName.getDescription());
|
||||
}
|
||||
public void ShowStyle() {
|
||||
mStyle.setText("Стиль: " + Current.getFile().style.getDescription());
|
||||
}
|
||||
public void ShowType() {
|
||||
mType.setText("Тип: " + Current.getFile().fileType.getDescription());
|
||||
}
|
||||
}
|
||||
34
src/Common_old/UI/Menus_2023/LanguagesSubmenu.java
Normal file
34
src/Common_old/UI/Menus_2023/LanguagesSubmenu.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package Common_old.UI.Menus_2023;
|
||||
import Common_old.Utils.Utils;
|
||||
import ProjectData.LanguageName;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
public abstract class LanguagesSubmenu extends VisualiserMenu {
|
||||
public LanguagesSubmenu() {
|
||||
this("Язык");
|
||||
}
|
||||
public LanguagesSubmenu(String text) {
|
||||
super(text, "/icons/Language.png", true);
|
||||
for (LanguageName languageName : LanguageName.values()) {
|
||||
if (languageName.equals(LanguageName.fortran) ||
|
||||
(languageName.equals(LanguageName.c) ||
|
||||
(languageName.equals(LanguageName.cpp)))) {
|
||||
|
||||
JMenuItem languageItem = new StableMenuItem(languageName.getDescription());
|
||||
String li = languageName.getIcon();
|
||||
if (!li.isEmpty())
|
||||
languageItem.setIcon(Utils.getIcon(li));
|
||||
languageItem.addActionListener(
|
||||
new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
action(languageName);
|
||||
}
|
||||
});
|
||||
add(languageItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
public abstract void action(LanguageName languageName);
|
||||
}
|
||||
14
src/Common_old/UI/Menus_2023/MainMenuBar/AnalysesMenu.java
Normal file
14
src/Common_old/UI/Menus_2023/MainMenuBar/AnalysesMenu.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package Common_old.UI.Menus_2023.MainMenuBar;
|
||||
import Common_old.UI.Menus_2023.VisualiserMenu;
|
||||
import Repository.Component.Sapfor.Sapfor;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.Pass_2021;
|
||||
public class AnalysesMenu extends VisualiserMenu {
|
||||
public AnalysesMenu() {
|
||||
super("Анализаторы","/icons/Analyses.png" );
|
||||
for (PassCode_2021 code : Sapfor.getAnalysesCodes())
|
||||
add(Pass_2021.passes.get(code).createMenuItem());
|
||||
addSeparator();
|
||||
add(Pass_2021.passes.get(PassCode_2021.SPF_GetGCovInfo).createMenuItem());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package Common_old.UI.Menus_2023.MainMenuBar;
|
||||
import Common_old.UI.Menus_2023.VisualiserMenu;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.Pass_2021;
|
||||
public class GlobalCleaningMenu extends VisualiserMenu {
|
||||
public GlobalCleaningMenu() {
|
||||
super("Очистка", "/icons/Clean.png", false);
|
||||
add(Pass_2021.passes.get(PassCode_2021.DropLastProjects).createMenuItem());
|
||||
add(Pass_2021.passes.get(PassCode_2021.DropFastAccess).createMenuItem());
|
||||
addSeparator();
|
||||
add(Pass_2021.passes.get(PassCode_2021.DeleteDownloadedBugReports).createMenuItem());
|
||||
addSeparator();
|
||||
add(Pass_2021.passes.get(PassCode_2021.DropAnalyses).createMenuItem());
|
||||
add(Pass_2021.passes.get(PassCode_2021.CleanAnalyses).createMenuItem());
|
||||
add(Pass_2021.passes.get(PassCode_2021.DropSavedArrays).createMenuItem());
|
||||
add(Pass_2021.passes.get(PassCode_2021.DeleteDebugResults).createMenuItem());
|
||||
addSeparator();
|
||||
add(Pass_2021.passes.get(PassCode_2021.ResetCurrentProject).createMenuItem());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package Common_old.UI.Menus_2023.MainMenuBar;
|
||||
import _VisualDVM.Global;
|
||||
import Common_old.UI.Menus.VisualiserMenuItem;
|
||||
import Common_old.UI.Menus_2023.VisualiserMenu;
|
||||
import GlobalData.DBLastProject.DBLastProject;
|
||||
import GlobalData.Settings.SettingName;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.Pass_2021;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.MenuEvent;
|
||||
import javax.swing.event.MenuListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.io.File;
|
||||
import java.util.Vector;
|
||||
public class LastOpenedProjectsMenu extends VisualiserMenu {
|
||||
public LastOpenedProjectsMenu() {
|
||||
super("Недавние проекты", "/icons/LastOpened.png");
|
||||
addMenuListener(new MenuListener() {
|
||||
@Override
|
||||
public void menuSelected(MenuEvent e) {
|
||||
removeAll();
|
||||
Vector<DBLastProject> projects = Global.db.lastProjects.getOrdered();
|
||||
int k = 1;
|
||||
for (DBLastProject p : projects) {
|
||||
if (new File(p.HomePath).exists() && p.lastOpened != 0) {
|
||||
VisualiserMenuItem i = new VisualiserMenuItem(p.HomePath);
|
||||
i.addActionListener(new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Pass_2021.passes.get(PassCode_2021.OpenCurrentProject).Do(new File(p.HomePath));
|
||||
}
|
||||
});
|
||||
add(i);
|
||||
++k;
|
||||
if (k > (Global.db.settings.get(SettingName.LastOpenedProjectsCount).toInt32())) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void menuDeselected(MenuEvent e) {
|
||||
}
|
||||
@Override
|
||||
public void menuCanceled(MenuEvent e) {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
89
src/Common_old/UI/Menus_2023/MainMenuBar/MainMenuBar.java
Normal file
89
src/Common_old/UI/Menus_2023/MainMenuBar/MainMenuBar.java
Normal file
@@ -0,0 +1,89 @@
|
||||
package Common_old.UI.Menus_2023.MainMenuBar;
|
||||
import _VisualDVM.Global;
|
||||
import Common_old.UI.Menus_2023.MenuBarButton;
|
||||
import Common_old.UI.Menus_2023.VisualiserMenuBar;
|
||||
import Common_old.UI.Menus_2023.MainMenuBar.VisualiserSettingsMenu.VisualiserSettingsMenu;
|
||||
import Common_old.UI.UI;
|
||||
import Repository.Component.PerformanceAnalyzer.PerformanceAnalyzer;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.Pass_2021;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
public class MainMenuBar extends VisualiserMenuBar {
|
||||
JMenu analyses;
|
||||
JMenu transformations;
|
||||
MenuBarButton components;
|
||||
public MainMenuBar() {
|
||||
addMenus(new LastOpenedProjectsMenu());
|
||||
addPasses(PassCode_2021.OpenCurrentProject, PassCode_2021.CreateEmptyProject);
|
||||
addMenus(
|
||||
analyses = new AnalysesMenu(),
|
||||
transformations = new TransformationsMenu(),
|
||||
new GlobalCleaningMenu(),
|
||||
new VisualiserSettingsMenu()
|
||||
);
|
||||
add(components = new MenuBarButton() {
|
||||
{
|
||||
setToolTipText("Компоненты");
|
||||
setIcon("/icons/ComponentsActual.png");
|
||||
addActionListener(e -> {
|
||||
if (PerformanceAnalyzer.isActive) {
|
||||
UI.Info("Перед работой с компонентами закройте анализатор производительности!");
|
||||
} else {
|
||||
Pass_2021.passes.get(PassCode_2021.GetComponentsActualVersions).Do();
|
||||
Global.RefreshUpdatesStatus();
|
||||
UI.ShowComponentsWindow();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
/*
|
||||
add(new MenuBarButton() {
|
||||
{
|
||||
setIcon("/icons/Comparsion.png");
|
||||
setToolTipText("Анализатор статистик");
|
||||
addActionListener(e -> {
|
||||
Global.performanceAnalyzer.Start();
|
||||
});
|
||||
}
|
||||
});
|
||||
*/
|
||||
addPasses(PassCode_2021.ShowInstruction);
|
||||
//-
|
||||
setPreferredSize(new Dimension(0, 30));
|
||||
//---
|
||||
|
||||
|
||||
add(new MenuBarButton() {
|
||||
{
|
||||
setIcon("/icons/Apply.png");
|
||||
setToolTipText("Test");
|
||||
addActionListener(e -> {
|
||||
Pass_2021.passes.get(PassCode_2021.TestPass).Do();
|
||||
});
|
||||
}
|
||||
});
|
||||
ShowProject(false);
|
||||
}
|
||||
public void ShowUpdatesIcon() {
|
||||
components.setIcon(
|
||||
(Global.need_update > 0) || (Global.bad_state > 0)
|
||||
? "/icons/ComponentsNeedUpdate.gif"
|
||||
: (Global.need_publish > 0 ? "/icons/ComponentsNeedPublish_2023.gif" : "/icons/ComponentsActual.png"));
|
||||
}
|
||||
public void ShowProject(boolean flag) {
|
||||
analyses.setEnabled(flag);
|
||||
transformations.setEnabled(flag);
|
||||
Pass_2021[] cleaningPasses = new Pass_2021[]{
|
||||
Pass_2021.passes.get(PassCode_2021.DropAnalyses),
|
||||
Pass_2021.passes.get(PassCode_2021.DropSavedArrays),
|
||||
Pass_2021.passes.get(PassCode_2021.CleanAnalyses),
|
||||
Pass_2021.passes.get(PassCode_2021.DeleteDebugResults),
|
||||
Pass_2021.passes.get(PassCode_2021.ResetCurrentProject)
|
||||
};
|
||||
for (Pass_2021 pass : cleaningPasses) {
|
||||
pass.setControlsEnabled(flag);
|
||||
}
|
||||
}
|
||||
}
|
||||
20
src/Common_old/UI/Menus_2023/MainMenuBar/MainWindow.java
Normal file
20
src/Common_old/UI/Menus_2023/MainMenuBar/MainWindow.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package Common_old.UI.Menus_2023.MainMenuBar;
|
||||
import Visual_DVM_2021.UI.Interface.*;
|
||||
public interface MainWindow {
|
||||
void Show();
|
||||
void ShowProject();
|
||||
void ShowNoProject();
|
||||
ProjectWindow getProjectWindow();
|
||||
CallbackWindow getCallbackWindow();
|
||||
TestsWindow getTestsWindow();
|
||||
TestingWindow getTestingWindow();
|
||||
//-
|
||||
void ShowUpdatesIcon();
|
||||
void FocusProject();
|
||||
void FocusCallback();
|
||||
void FocusTests();
|
||||
void FocusTesting();
|
||||
void SwitchTestingTabs(boolean flag);
|
||||
//-
|
||||
void ShowCheckedTestsCount();
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package Common_old.UI.Menus_2023.MainMenuBar;
|
||||
import Common_old.UI.Menus.PassesSubMenu;
|
||||
import Common_old.UI.Menus_2023.VisualiserMenu;
|
||||
import Repository.Component.Sapfor.Sapfor;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.Pass_2021;
|
||||
public class TransformationsMenu extends VisualiserMenu {
|
||||
public TransformationsMenu() {
|
||||
super("Преобразования", "/icons/Transformations.png");
|
||||
add(new PassesSubMenu("Циклы", "/icons/Menu/Loops.png",
|
||||
Sapfor.getLoopsTransformationsCodes()));
|
||||
addSeparator();
|
||||
add(new PassesSubMenu("Приватные переменные", "/icons/Menu/Privates.png",
|
||||
Sapfor.getPrivatesTransformationsCodes()));
|
||||
addSeparator();
|
||||
add(new PassesSubMenu("Процедуры", "/icons/Menu/Functions.png",
|
||||
Sapfor.getProceduresTransformationsCodes()));
|
||||
addSeparator();
|
||||
add(new PassesSubMenu("Директивы", "/icons/Directives.png",
|
||||
Sapfor.getDVMTransformationsCodes()));
|
||||
addSeparator();
|
||||
add(new PassesSubMenu("Интервалы", "/icons/Menu/Intervals.png",
|
||||
Sapfor.getIntervalsTransformationsCodes()
|
||||
));
|
||||
addSeparator();
|
||||
add(new PassesSubMenu("Области распараллеливания", "/icons/Menu/Regions.png",
|
||||
Sapfor.getRegionsTransformationsCodes()
|
||||
));
|
||||
addSeparator();
|
||||
add(Pass_2021.passes.get(PassCode_2021.SPF_SharedMemoryParallelization).createMenuItem());
|
||||
addSeparator();
|
||||
add(new PassesSubMenu("Предобработка проекта", "/icons/Menu/Preprocessing.png",
|
||||
Sapfor.getPreparationTransformationsCodes()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package Common_old.UI.Menus_2023.MainMenuBar.VisualiserSettingsMenu;
|
||||
import _VisualDVM.Global;
|
||||
import Common_old.UI.Menus_2023.SettingsSubmenu;
|
||||
import GlobalData.Settings.SettingName;
|
||||
public class CompactnessSettingsMenu extends SettingsSubmenu {
|
||||
public CompactnessSettingsMenu(){
|
||||
super("Компактность отображения", null,
|
||||
SettingName.SmallScreen,
|
||||
SettingName.ShowFullTabsNames,
|
||||
SettingName.ShowFullArraysDeclarations,
|
||||
SettingName.FastAccessPassesCount,
|
||||
SettingName.LastOpenedProjectsCount
|
||||
);
|
||||
addSeparator();
|
||||
String [] propertiesNames = new String[]{
|
||||
// "collapseCredentials",
|
||||
"collapseProjectTrees",
|
||||
"collapseFileGraphs",
|
||||
"collapseFileMessages"
|
||||
};
|
||||
for (String name: propertiesNames){
|
||||
Global.properties.addFlagMenuItem(this, name);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package Common_old.UI.Menus_2023.MainMenuBar.VisualiserSettingsMenu;
|
||||
import _VisualDVM.Global;
|
||||
import Common_old.UI.Menus.PropertiesSubmenu;
|
||||
import Common_old.UI.Menus_2023.SettingsSubmenu;
|
||||
import Common_old.UI.Menus_2023.VisualiserMenu;
|
||||
import GlobalData.Settings.SettingName;
|
||||
public class VisualiserSettingsMenu extends VisualiserMenu {
|
||||
public VisualiserSettingsMenu() {
|
||||
super("Настройки визуализатора", "/icons/Settings.png");
|
||||
//-
|
||||
add(new PropertiesSubmenu("Подтверждения и уведомления", null,
|
||||
"ShowPassesDone",
|
||||
"ConfirmPassesStart",
|
||||
"FocusPassesResult"
|
||||
));
|
||||
add(new CompactnessSettingsMenu());
|
||||
if (Global.isWindows) {
|
||||
add(new SettingsSubmenu("Компиляция на локальной машине", null,
|
||||
SettingName.LocalMakePathWindows,
|
||||
SettingName.Kernels
|
||||
));
|
||||
} else {
|
||||
add(new SettingsSubmenu("Компиляция на локальной машине", null,
|
||||
SettingName.Kernels
|
||||
));
|
||||
}
|
||||
add(new SettingsSubmenu("Синхронизация", null,
|
||||
SettingName.AutoBugReportsLoad,
|
||||
SettingName.AutoTestsLoad
|
||||
));
|
||||
add(new SettingsSubmenu("Сравнение", null,
|
||||
SettingName.ExtensionsOn,
|
||||
SettingName.RegisterOn,
|
||||
SettingName.SpacesOn,
|
||||
SettingName.EmptyLinesOn,
|
||||
SettingName.FortranWrapsOn,
|
||||
SettingName.ComparsionDiffMergeOn
|
||||
));
|
||||
add(Global.db.settings.get(SettingName.Workspace).getMenuItem());
|
||||
add(Global.db.settings.get(SettingName.BugReportsAgeLimit).getMenuItem());
|
||||
}
|
||||
}
|
||||
35
src/Common_old/UI/Menus_2023/MenuBarButton.java
Normal file
35
src/Common_old/UI/Menus_2023/MenuBarButton.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package Common_old.UI.Menus_2023;
|
||||
import Common_old.Current;
|
||||
import Common_old.UI.Themes.VisualiserFonts;
|
||||
import Common_old.Utils.Utils;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
//https://java-online.ru/swing-jbutton.xhtml
|
||||
public class MenuBarButton extends JButton {
|
||||
public MenuBarButton() {
|
||||
super();
|
||||
setFont(Current.getTheme().Fonts.get(VisualiserFonts.Menu));
|
||||
//
|
||||
setBorderPainted(false);
|
||||
setContentAreaFilled(false);
|
||||
setOpaque(false);
|
||||
//setFocusPainted(false);
|
||||
//-
|
||||
setMinimumSize(new Dimension(38, 30)); //иначе сужаются вертикально.
|
||||
}
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
if (getModel().isPressed()) {
|
||||
g.setColor(new Color(163, 184, 204));
|
||||
g.fillRect(0, 0, getWidth(), getHeight());
|
||||
}
|
||||
super.paintComponent(g);
|
||||
}
|
||||
public void setIcon(String icon_path) {
|
||||
setIcon(Utils.getIcon(icon_path));
|
||||
}
|
||||
public void setFont(VisualiserFonts font_in){
|
||||
setFont(Current.getTheme().Fonts.get(font_in));
|
||||
}
|
||||
}
|
||||
25
src/Common_old/UI/Menus_2023/PassButton.java
Normal file
25
src/Common_old/UI/Menus_2023/PassButton.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package Common_old.UI.Menus_2023;
|
||||
import Visual_DVM_2021.Passes.Pass_2021;
|
||||
|
||||
import java.awt.*;
|
||||
public class PassButton extends MenuBarButton implements PassControl {
|
||||
public PassButton(Pass_2021 pass, boolean tab) {
|
||||
setText(pass.getButtonText());
|
||||
setToolTipText(pass.getDescription());
|
||||
if (pass.getIconPath() != null) {
|
||||
if (tab) {
|
||||
setIcon(pass.getTabIcon());
|
||||
setPreferredSize(new Dimension(18,18));
|
||||
setMaximumSize(new Dimension(18,18));
|
||||
setMinimumSize(new Dimension(18,18));
|
||||
}
|
||||
else
|
||||
setIcon(pass.getIconPath());
|
||||
}
|
||||
addActionListener(pass.getControlAction());
|
||||
pass.controls.add(this);
|
||||
}
|
||||
public PassButton(Pass_2021 pass) {
|
||||
this(pass, false);
|
||||
}
|
||||
}
|
||||
8
src/Common_old/UI/Menus_2023/PassControl.java
Normal file
8
src/Common_old/UI/Menus_2023/PassControl.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package Common_old.UI.Menus_2023;
|
||||
public interface PassControl {
|
||||
void setIcon(String icon_path);
|
||||
void setEnabled(boolean flag);
|
||||
void setVisible(boolean flag);
|
||||
void setToolTipText(String text);
|
||||
void setText(String text);
|
||||
}
|
||||
17
src/Common_old/UI/Menus_2023/PassMenuItem.java
Normal file
17
src/Common_old/UI/Menus_2023/PassMenuItem.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package Common_old.UI.Menus_2023;
|
||||
import Common_old.UI.Menus.VisualiserMenuItem;
|
||||
import Common_old.Utils.Utils;
|
||||
import Visual_DVM_2021.Passes.Pass_2021;
|
||||
public class PassMenuItem extends VisualiserMenuItem implements PassControl {
|
||||
@Override
|
||||
public void setIcon(String icon_path) {
|
||||
setIcon(Utils.getIcon(icon_path));
|
||||
}
|
||||
public PassMenuItem(Pass_2021 pass) {
|
||||
setText(pass.getDescription());
|
||||
setToolTipText(pass.getDescription());
|
||||
if (pass.getIconPath() != null) setIcon(pass.getIconPath());
|
||||
addActionListener(pass.getControlAction());
|
||||
pass.controls.add(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package Common_old.UI.Menus_2023.ProjectMenuBar;
|
||||
import Common_old.UI.Menus_2023.VisualiserMenu;
|
||||
public class FilesOperationsMenu extends VisualiserMenu {
|
||||
public FilesOperationsMenu() {
|
||||
super("Массовые операции над файлами","/icons/MassFiles.png" );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package Common_old.UI.Menus_2023.ProjectMenuBar;
|
||||
import Common_old.UI.Menus_2023.MenuBarButton;
|
||||
import Common_old.UI.Menus_2023.VisualiserMenuBar;
|
||||
import Common_old.UI.UI;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
public class ProjectMenuBar extends VisualiserMenuBar {
|
||||
public ProjectViewMenu projectViewMenu;
|
||||
public ProjectMenuBar() {
|
||||
addMenus(projectViewMenu = new ProjectViewMenu());
|
||||
add(new JSeparator());
|
||||
addMenus(
|
||||
new ProjectSettingsMenu()
|
||||
);
|
||||
add(new MenuBarButton() {
|
||||
{
|
||||
setToolTipText("Профили");
|
||||
setIcon("/icons/Profiles.png");
|
||||
addActionListener(e -> {
|
||||
UI.ShowProfilesWindow();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
public ProjectViewMenu getProjectViewMenu() {
|
||||
return projectViewMenu;
|
||||
}
|
||||
@Override
|
||||
public void setSizeLimits() {
|
||||
setPreferredSize(new Dimension(0, 32));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package Common_old.UI.Menus_2023.ProjectMenuBar;
|
||||
import Common_old.Current;
|
||||
import _VisualDVM.Global;
|
||||
import Common_old.UI.Menus_2023.LanguagesSubmenu;
|
||||
import Common_old.UI.Menus_2023.SettingsSubmenu;
|
||||
import Common_old.UI.Menus_2023.StylesSubmenu;
|
||||
import Common_old.UI.Menus_2023.VisualiserMenu;
|
||||
import GlobalData.Settings.SettingName;
|
||||
import ProjectData.Files.LanguageStyle;
|
||||
import ProjectData.LanguageName;
|
||||
|
||||
import javax.swing.*;
|
||||
public class ProjectSettingsMenu extends VisualiserMenu {
|
||||
JMenu mLanguage;
|
||||
JMenu mStyle;
|
||||
public ProjectSettingsMenu() {
|
||||
super("Настройки проекта", "/icons/Settings.png");
|
||||
add(mLanguage = new LanguagesSubmenu() {
|
||||
@Override
|
||||
public void action(LanguageName languageName) {
|
||||
if (Current.getProject().UpdateLanguage(languageName)) {
|
||||
Current.getSapfor().ResetAllAnalyses();
|
||||
ShowLanguage();
|
||||
}
|
||||
}
|
||||
});
|
||||
ShowLanguage();
|
||||
//--
|
||||
add(mStyle = new StylesSubmenu() {
|
||||
@Override
|
||||
public void action(LanguageStyle languageStyle) {
|
||||
if (Current.getProject().UpdateStyle(languageStyle))
|
||||
ShowStyle();
|
||||
}
|
||||
});
|
||||
ShowStyle();
|
||||
addSeparator();
|
||||
add(new SettingsSubmenu("Анализ", null,
|
||||
SettingName.Precompilation,
|
||||
SettingName.STATIC_SHADOW_ANALYSIS,
|
||||
SettingName.KEEP_DVM_DIRECTIVES,
|
||||
SettingName.IGNORE_IO_SAPFOR,
|
||||
SettingName.MPI_PROGRAM,
|
||||
SettingName.ANALYSIS_OPTIONS
|
||||
));
|
||||
addSeparator();
|
||||
add(new SettingsSubmenu("Построение системы интервалов", null,
|
||||
SettingName.KEEP_LOOPS_CLOSE_NESTING,
|
||||
SettingName.KEEP_GCOV
|
||||
));
|
||||
addSeparator();
|
||||
add(new SettingsSubmenu("Построение версий", null,
|
||||
SettingName.FREE_FORM,
|
||||
SettingName.KEEP_SPF_DIRECTIVES,
|
||||
SettingName.KEEP_SPF_DIRECTIVES_AMONG_TRANSFORMATIONS,
|
||||
SettingName.OUTPUT_UPPER,
|
||||
SettingName.MAX_SHADOW_WIDTH,
|
||||
SettingName.DVMConvertationOptions,
|
||||
SettingName.SaveModifications
|
||||
));
|
||||
addSeparator();
|
||||
add(Global.db.settings.get(SettingName.TRANSLATE_MESSAGES).getMenuItem());
|
||||
add(Global.db.settings.get(SettingName.DEBUG_PRINT_ON).getMenuItem());
|
||||
add(Global.db.settings.get(SettingName.GCOVLimit).getMenuItem());
|
||||
}
|
||||
public void ShowLanguage() {
|
||||
mLanguage.setText("Язык: " + Current.getProject().languageName.getDescription());
|
||||
}
|
||||
public void ShowStyle() {
|
||||
mStyle.setText("Стиль: " + Current.getProject().style.getDescription());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package Common_old.UI.Menus_2023.ProjectMenuBar;
|
||||
import Common_old.Current;
|
||||
import Common_old.UI.Menus_2023.VisualiserMenu;
|
||||
import Common_old.UI.Themes.VisualiserFonts;
|
||||
import Common_old.UI.UI;
|
||||
import Common_old.Utils.Utils;
|
||||
import ProjectData.ProjectView;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.LinkedHashMap;
|
||||
public class ProjectViewMenu extends VisualiserMenu {
|
||||
LinkedHashMap<ProjectView, JMenuItem> views;
|
||||
public ProjectViewMenu() {
|
||||
super("", "");
|
||||
views = new LinkedHashMap<>();
|
||||
for (ProjectView view : ProjectView.values()) {
|
||||
JMenuItem m = new JMenuItem(view.getDescription()) {
|
||||
{
|
||||
setIcon(Utils.getIcon(view.getIcon()));
|
||||
setFont(Current.getTheme().Fonts.get(VisualiserFonts.TreeItalic));
|
||||
addActionListener(e -> {
|
||||
Current.set(Current.ProjectView, view);
|
||||
UI.getMainWindow().getProjectWindow().ShowProjectView();
|
||||
});
|
||||
}
|
||||
};
|
||||
add(m);
|
||||
views.put(view, m);
|
||||
}
|
||||
}
|
||||
public void SelectView(ProjectView view){
|
||||
views.get(view).doClick();
|
||||
}
|
||||
}
|
||||
19
src/Common_old/UI/Menus_2023/SettingsSubmenu.java
Normal file
19
src/Common_old/UI/Menus_2023/SettingsSubmenu.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package Common_old.UI.Menus_2023;
|
||||
import Common_old.Current;
|
||||
import _VisualDVM.Global;
|
||||
import Common_old.UI.Themes.VisualiserFonts;
|
||||
import Common_old.Utils.Utils;
|
||||
import GlobalData.Settings.SettingName;
|
||||
|
||||
import javax.swing.*;
|
||||
public class SettingsSubmenu extends JMenu {
|
||||
public SettingsSubmenu(String title, String icon, SettingName... settings) {
|
||||
super(title);
|
||||
if (icon != null)
|
||||
setIcon(Utils.getIcon(icon));
|
||||
setFont(Current.getTheme().Fonts.get(VisualiserFonts.Menu));
|
||||
for (SettingName c : settings) {
|
||||
add(Global.db.settings.get(c).getMenuItem());
|
||||
}
|
||||
}
|
||||
}
|
||||
41
src/Common_old/UI/Menus_2023/StableMenuItem.java
Normal file
41
src/Common_old/UI/Menus_2023/StableMenuItem.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package Common_old.UI.Menus_2023;
|
||||
import Common_old.UI.Menus.VisualiserMenuItem;
|
||||
import Common_old.UI.UI;
|
||||
import Common_old.Utils.Utils;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.plaf.basic.BasicMenuItemUI;
|
||||
//неичезающий меню итем. нужен для настроек
|
||||
//https://translated.turbopages.org/proxy_u/en-ru.ru.64537f6c-6460c460-8e74a1ab-74722d776562/https/tips4java.wordpress.com/2010/09/12/keeping-menus-open/
|
||||
class StableItemUI extends BasicMenuItemUI {
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
return new StableItemUI();
|
||||
}
|
||||
@Override
|
||||
protected void doClick(MenuSelectionManager msm) {
|
||||
menuItem.doClick(0);
|
||||
if (UI.last_menu_path != null)
|
||||
MenuSelectionManager.defaultManager().setSelectedPath(UI.last_menu_path);
|
||||
}
|
||||
}
|
||||
public class StableMenuItem extends VisualiserMenuItem {
|
||||
{
|
||||
getModel().addChangeListener(e -> {
|
||||
if (getModel().isArmed() && isShowing())
|
||||
UI.last_menu_path = MenuSelectionManager.defaultManager().getSelectedPath();
|
||||
});
|
||||
}
|
||||
public StableMenuItem(String text) {
|
||||
super(text);
|
||||
setUI(new StableItemUI());
|
||||
}
|
||||
public StableMenuItem(String text, String icon_path) {
|
||||
super(text);
|
||||
setIcon(Utils.getIcon(icon_path));
|
||||
setUI(new StableItemUI());
|
||||
}
|
||||
public StableMenuItem() {
|
||||
setUI(new StableItemUI());
|
||||
}
|
||||
}
|
||||
16
src/Common_old/UI/Menus_2023/StablePassMenuItem.java
Normal file
16
src/Common_old/UI/Menus_2023/StablePassMenuItem.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package Common_old.UI.Menus_2023;
|
||||
import Common_old.Utils.Utils;
|
||||
import Visual_DVM_2021.Passes.Pass_2021;
|
||||
public class StablePassMenuItem extends StableMenuItem implements PassControl {
|
||||
@Override
|
||||
public void setIcon(String icon_path) {
|
||||
setIcon(Utils.getIcon(icon_path));
|
||||
}
|
||||
public StablePassMenuItem(Pass_2021 pass) {
|
||||
setText(pass.getDescription());
|
||||
setToolTipText(pass.getDescription());
|
||||
if (pass.getIconPath() != null) setIcon(pass.getIconPath());
|
||||
addActionListener(pass.getControlAction());
|
||||
pass.controls.add(this);
|
||||
}
|
||||
}
|
||||
25
src/Common_old/UI/Menus_2023/StylesSubmenu.java
Normal file
25
src/Common_old/UI/Menus_2023/StylesSubmenu.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package Common_old.UI.Menus_2023;
|
||||
import ProjectData.Files.LanguageStyle;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
public abstract class StylesSubmenu extends VisualiserMenu {
|
||||
public StylesSubmenu() {
|
||||
this("Стиль");
|
||||
}
|
||||
public StylesSubmenu(String text) {
|
||||
super(text, "/icons/Style.png", true);
|
||||
for (LanguageStyle languageStyle : LanguageStyle.values()) {
|
||||
JMenuItem m = new StableMenuItem(languageStyle.getDescription());
|
||||
m.addActionListener(
|
||||
new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
action(languageStyle);
|
||||
}
|
||||
});
|
||||
add(m);
|
||||
}
|
||||
}
|
||||
public abstract void action(LanguageStyle languageStyle);
|
||||
}
|
||||
26
src/Common_old/UI/Menus_2023/TypesSubmenu.java
Normal file
26
src/Common_old/UI/Menus_2023/TypesSubmenu.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package Common_old.UI.Menus_2023;
|
||||
import ProjectData.Files.FileType;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
public abstract class TypesSubmenu extends VisualiserMenu {
|
||||
public TypesSubmenu() {
|
||||
this("Тип");
|
||||
}
|
||||
public TypesSubmenu(String text) {
|
||||
super(text, "/icons/type.png", true);
|
||||
for (FileType fileType : FileType.values()) {
|
||||
if (fileType != FileType.forbidden) {
|
||||
JMenuItem m = new StableMenuItem(fileType.getDescription());
|
||||
m.addActionListener(new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
action(fileType);
|
||||
}
|
||||
});
|
||||
add(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
public abstract void action(FileType fileType);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package Common_old.UI.Menus_2023.VariantsMenuBar;
|
||||
import Common_old.UI.Menus_2023.DataMenuBar;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
public class VariantsMenuBar extends DataMenuBar {
|
||||
public VariantsMenuBar() {
|
||||
super("варианты");
|
||||
addPasses(PassCode_2021.ShowAllParallelVariants, PassCode_2021.ShowParallelVariantsCoverage,
|
||||
PassCode_2021.PredictParallelVariants, PassCode_2021.CreateParallelVariants);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package Common_old.UI.Menus_2023.VersionsMenuBar;
|
||||
import Common_old.UI.Menus_2023.VisualiserMenuBar;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
public class VersionsMenuBar extends VisualiserMenuBar {
|
||||
public VersionsMenuBar(){
|
||||
addPasses(PassCode_2021.CreateTestsGroupFromSelectedVersions);
|
||||
}
|
||||
}
|
||||
27
src/Common_old/UI/Menus_2023/VisualiserMenu.java
Normal file
27
src/Common_old/UI/Menus_2023/VisualiserMenu.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package Common_old.UI.Menus_2023;
|
||||
import Common_old.Current;
|
||||
import Common_old.UI.Themes.VisualiserFonts;
|
||||
import Common_old.Utils.Utils;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.Pass_2021;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
public class VisualiserMenu extends JMenu {
|
||||
public VisualiserMenu(String text, String iconPath, boolean textVisible) {
|
||||
setMinimumSize(new Dimension(38, 30)); //иначе сужаются вертикально.
|
||||
setToolTipText(text);
|
||||
if (textVisible)
|
||||
setText(text);
|
||||
setFont(Current.getTheme().Fonts.get(VisualiserFonts.TreeItalic));
|
||||
if (!iconPath.isEmpty())
|
||||
setIcon(Utils.getIcon(iconPath));
|
||||
}
|
||||
public VisualiserMenu(String text, String iconPath) {
|
||||
this(text, iconPath, false);
|
||||
}
|
||||
public void addPasses(PassCode_2021... codes) {
|
||||
for (PassCode_2021 code : codes)
|
||||
add(Pass_2021.passes.get(code).createMenuItem());
|
||||
}
|
||||
}
|
||||
49
src/Common_old/UI/Menus_2023/VisualiserMenuBar.java
Normal file
49
src/Common_old/UI/Menus_2023/VisualiserMenuBar.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package Common_old.UI.Menus_2023;
|
||||
import Common_old.Current;
|
||||
import Common_old.UI.Themes.VisualiserFonts;
|
||||
import Common_old.Utils.Utils;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.Pass_2021;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
//https://java-online.ru/swing-menu.xhtml
|
||||
public class VisualiserMenuBar extends JToolBar {
|
||||
public VisualiserMenuBar() {
|
||||
setFloatable(false);
|
||||
setSizeLimits();
|
||||
}
|
||||
public void addPasses(PassCode_2021... codes) {
|
||||
//- кнопки. связать их с проходами. (!)
|
||||
for (PassCode_2021 code : codes)
|
||||
add(Pass_2021.passes.get(code).createButton());
|
||||
}
|
||||
public JMenuBar addMenus(JMenu... menus) {
|
||||
JMenuBar bar = new JMenuBar() {
|
||||
{
|
||||
for (JMenu menu : menus)
|
||||
add(menu);
|
||||
}
|
||||
};
|
||||
add(bar);
|
||||
return bar;
|
||||
}
|
||||
public JLabel addLabel(String text_in) {
|
||||
return addLabel(text_in, null);
|
||||
}
|
||||
public JLabel addLabel(String text_in, String icon_path_in) {
|
||||
JLabel res = new JLabel(text_in) {
|
||||
{
|
||||
setFont(Current.getTheme().Fonts.get(VisualiserFonts.TreeItalic));
|
||||
if (icon_path_in != null) {
|
||||
setIcon(Utils.getIcon(icon_path_in));
|
||||
}
|
||||
}
|
||||
};
|
||||
add(res);
|
||||
return res;
|
||||
}
|
||||
public void setSizeLimits() {
|
||||
setPreferredSize(new Dimension(0, 30));
|
||||
}
|
||||
}
|
||||
16
src/Common_old/UI/ProgressBar/StyledProgressBar.java
Normal file
16
src/Common_old/UI/ProgressBar/StyledProgressBar.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package Common_old.UI.ProgressBar;
|
||||
import Common_old.Current;
|
||||
import Common_old.UI.Themes.ThemeElement;
|
||||
|
||||
import javax.swing.*;
|
||||
public class StyledProgressBar extends JProgressBar implements ThemeElement {
|
||||
public StyledProgressBar() {
|
||||
setStringPainted(true);
|
||||
applyTheme();
|
||||
}
|
||||
@Override
|
||||
public void applyTheme() {
|
||||
setBackground(Current.getTheme().bar_background);
|
||||
setForeground(Current.getTheme().bar_foreground);
|
||||
}
|
||||
}
|
||||
38
src/Common_old/UI/Selectable.java
Normal file
38
src/Common_old/UI/Selectable.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package Common_old.UI;
|
||||
import Common_old.Utils.Utils;
|
||||
|
||||
import javax.swing.*;
|
||||
public interface Selectable {
|
||||
boolean isSelected();
|
||||
default void Select(boolean flag) {
|
||||
if (isSelectionEnabled())
|
||||
select(flag);
|
||||
}
|
||||
void select(boolean flag);
|
||||
//-
|
||||
default ImageIcon GetSelectionIcon() {
|
||||
return
|
||||
isSelectionEnabled() ?
|
||||
Utils.getIcon("/Common/icons/" + (isSelected() ? "Pick" : "NotPick") + ".png") :
|
||||
GetDisabledIcon();
|
||||
}
|
||||
default ImageIcon GetDisabledIcon() {
|
||||
return Utils.getIcon("/Common/icons/Arrays/Unknown.png");
|
||||
}
|
||||
default void SwitchSelection() {
|
||||
Select(!isSelected());
|
||||
}
|
||||
//строчный контент для передачи параметров проходам.
|
||||
default String getSelectionContent() {
|
||||
return toString();
|
||||
}
|
||||
//-
|
||||
default String getSelectionText() {
|
||||
return toString();
|
||||
}
|
||||
default boolean isSelectionEnabled() {
|
||||
return true;
|
||||
}
|
||||
default void SelectAllChildren(boolean select) {
|
||||
}
|
||||
}
|
||||
8
src/Common_old/UI/StatusEnum.java
Normal file
8
src/Common_old/UI/StatusEnum.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package Common_old.UI;
|
||||
import Common_old.UI.Themes.VisualiserFonts;
|
||||
public interface StatusEnum {
|
||||
default String getDescription() {
|
||||
return toString();
|
||||
}
|
||||
default VisualiserFonts getFont() {return VisualiserFonts.UnknownState;}
|
||||
}
|
||||
78
src/Common_old/UI/Tables/ColumnFilter.java
Normal file
78
src/Common_old/UI/Tables/ColumnFilter.java
Normal file
@@ -0,0 +1,78 @@
|
||||
package Common_old.UI.Tables;
|
||||
import Common.Database.Tables.DataSet;
|
||||
import Common_old.UI.TextField.StyledTextField;
|
||||
import Common_old.Utils.Utils;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.MatteBorder;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
public class ColumnFilter {
|
||||
public JTextField textField;
|
||||
public JPopupMenu popup;
|
||||
public ColumnFilter(DataSet dataSet, int columnIndex) {
|
||||
textField = new StyledTextField() {
|
||||
{
|
||||
setBorder(null);
|
||||
addActionListener(e -> {
|
||||
popup.setVisible(false);
|
||||
dataSet.ui_.control.getTableHeader().repaint();
|
||||
});
|
||||
getDocument().addDocumentListener(new DocumentListener() {
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
dataSet.changeColumnFilterValue(columnIndex, getText());
|
||||
dataSet.ShowUI();
|
||||
}
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
dataSet.changeColumnFilterValue(columnIndex, getText());
|
||||
dataSet.ShowUI();
|
||||
}
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
popup = new JPopupMenu() {
|
||||
{
|
||||
setBorder(new MatteBorder(0, 1, 1, 1, Color.DARK_GRAY));
|
||||
}
|
||||
};
|
||||
popup.add(textField);
|
||||
//--
|
||||
dataSet.getUi().control.getColumnModel().getColumn(columnIndex).setHeaderRenderer((table, value, isSelected, hasFocus, row, column1) -> new JLabel() {
|
||||
{
|
||||
setIcon(Utils.getIcon("/icons/Filter.png"));
|
||||
setForeground(dataSet.getUi().control.getTableHeader().getForeground());
|
||||
setBackground(dataSet.getUi().control.getTableHeader().getBackground());
|
||||
setFont(dataSet.getUi().control.getTableHeader().getFont());
|
||||
setBorder(new MatteBorder(0, 0, 1, 1, Color.DARK_GRAY));
|
||||
setText("текст : "+dataSet.getColumnFilterValue(columnIndex));
|
||||
}
|
||||
});
|
||||
//--
|
||||
dataSet.getUi().control.getTableHeader().addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent event) {
|
||||
if (event.getClickCount() == 1) {
|
||||
int columnIndex = dataSet.getUi().control.getTableHeader().columnAtPoint(event.getPoint());
|
||||
if (dataSet.columnsFilters.containsKey(columnIndex)) {
|
||||
Rectangle columnRectangle = dataSet.getUi().control.getTableHeader().getHeaderRect(columnIndex);
|
||||
Dimension d = new Dimension(columnRectangle.width - 72, columnRectangle.height - 1);
|
||||
popup.setPreferredSize(d);
|
||||
popup.setMaximumSize(d);
|
||||
popup.show(dataSet.getUi().control.getTableHeader(), columnRectangle.x + 72, 0);
|
||||
textField.setText(dataSet.getColumnFilterValue(columnIndex).toString());
|
||||
textField.requestFocusInWindow();
|
||||
textField.selectAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
94
src/Common_old/UI/Tables/ColumnInfo.java
Normal file
94
src/Common_old/UI/Tables/ColumnInfo.java
Normal file
@@ -0,0 +1,94 @@
|
||||
package Common_old.UI.Tables;
|
||||
import Common_old.Constants;
|
||||
public class ColumnInfo {
|
||||
private String Name = "?";
|
||||
private boolean visible = true;
|
||||
private boolean editable = false;
|
||||
private TableRenderers renderer = TableRenderers.RendererDefault;
|
||||
private TableEditors editor = TableEditors.EditorDefault;
|
||||
private int maxWidth = Constants.Nan;
|
||||
private int minWidth = Constants.Nan;
|
||||
//private int lastWidth = Utils.Nan;
|
||||
// public void setLastWidth(int width_in) {
|
||||
// lastWidth = width_in;
|
||||
// }
|
||||
// public int getLastWidth() {
|
||||
// return lastWidth;
|
||||
// }
|
||||
public ColumnInfo(String name_in) {
|
||||
setName(name_in);
|
||||
}
|
||||
public ColumnInfo(String name_in, TableRenderers renderer_in, TableEditors editor_in) {
|
||||
setName(name_in);
|
||||
setRenderer(renderer_in);
|
||||
setEditable(true);
|
||||
setEditor(editor_in);
|
||||
}
|
||||
public ColumnInfo(String name_in, TableRenderers renderer_in) {
|
||||
setName(name_in);
|
||||
setRenderer(renderer_in);
|
||||
}
|
||||
public String getName() {
|
||||
return Name;
|
||||
}
|
||||
public void setName(String name_in) {
|
||||
Name = name_in;
|
||||
}
|
||||
public boolean isVisible() {
|
||||
return visible;
|
||||
}
|
||||
public void setVisible(boolean visible_in) {
|
||||
this.visible = visible_in;
|
||||
}
|
||||
public boolean isEditable() {
|
||||
return editable;
|
||||
}
|
||||
public void setEditable(boolean editable_in) {
|
||||
this.editable = editable_in;
|
||||
}
|
||||
public TableRenderers getRenderer() {
|
||||
return renderer;
|
||||
}
|
||||
public void setRenderer(TableRenderers renderer_in) {
|
||||
this.renderer = renderer_in;
|
||||
}
|
||||
public TableEditors getEditor() {
|
||||
return editor;
|
||||
}
|
||||
public void setEditor(TableEditors editor_in) {
|
||||
this.editor = editor_in;
|
||||
setEditable(editor != TableEditors.EditorDefault);
|
||||
}
|
||||
public boolean hasRenderer() {
|
||||
return getRenderer() != TableRenderers.RendererDefault;
|
||||
}
|
||||
public boolean hasEditor() {
|
||||
return getEditor() != TableEditors.EditorDefault;
|
||||
}
|
||||
public int getMaxWidth() {
|
||||
return maxWidth;
|
||||
}
|
||||
public void setMaxWidth(int maxWidth_in) {
|
||||
this.maxWidth = maxWidth_in;
|
||||
}
|
||||
public boolean hasMaxWidth() {
|
||||
return maxWidth != Constants.Nan;
|
||||
}
|
||||
//-
|
||||
public int getMinWidth() {
|
||||
return minWidth;
|
||||
}
|
||||
public void setMinWidth(int minWidth_in) {
|
||||
this.minWidth = minWidth_in;
|
||||
}
|
||||
public boolean hasMinWidth() {
|
||||
return minWidth != Constants.Nan;
|
||||
}
|
||||
|
||||
/*
|
||||
public boolean hasLastWidth() {
|
||||
return lastWidth != Utils.Nan;
|
||||
}
|
||||
*/
|
||||
//-
|
||||
}
|
||||
10
src/Common_old/UI/Tables/ConfigurationAutoRenderer.java
Normal file
10
src/Common_old/UI/Tables/ConfigurationAutoRenderer.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package Common_old.UI.Tables;
|
||||
import TestingSystem.Common.Configuration.Configuration;
|
||||
public class ConfigurationAutoRenderer extends DBObjectRenderer {
|
||||
@Override
|
||||
public void Display() {
|
||||
if (value != null) {
|
||||
setIcon(((Configuration)value).GetAutoIcon());
|
||||
}
|
||||
}
|
||||
}
|
||||
38
src/Common_old/UI/Tables/ConfigurationAutoSwitcher.java
Normal file
38
src/Common_old/UI/Tables/ConfigurationAutoSwitcher.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package Common_old.UI.Tables;
|
||||
import _VisualDVM.Global;
|
||||
import Common_old.UI.VisualCache.VisualCaches;
|
||||
import TestingSystem.Common.Configuration.Configuration;
|
||||
import TestingSystem.Common.TestingServer;
|
||||
import TestingSystem.SAPFOR.SapforConfiguration.SapforConfiguration;
|
||||
import Visual_DVM_2021.Passes.Pass_2021;
|
||||
import Visual_DVM_2021.Passes.Server.EditServerObject;
|
||||
public class ConfigurationAutoSwitcher extends DBObjectEditor<Configuration> {
|
||||
@Override
|
||||
public void Action() {
|
||||
value.SwitchAuto();
|
||||
setIcon(value.GetAutoIcon());
|
||||
///-
|
||||
Pass_2021 pass = new EditServerObject<TestingServer,Configuration> (Global.testingServer, Configuration.class){
|
||||
@Override
|
||||
protected boolean canStart(Object... args) throws Exception {
|
||||
target = (Configuration) args[0];
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Обновить флаг автоматического тестирования";
|
||||
}
|
||||
@Override
|
||||
protected void showDone() throws Exception {
|
||||
VisualCaches.RefreshCache(target);
|
||||
if (target instanceof SapforConfiguration)
|
||||
Global.testingServer.db.sapforConfigurations.ShowUI(target.id);
|
||||
}
|
||||
};
|
||||
pass.Do(value);
|
||||
}
|
||||
@Override
|
||||
public Object getCellEditorValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
88
src/Common_old/UI/Tables/DBObjectEditor.java
Normal file
88
src/Common_old/UI/Tables/DBObjectEditor.java
Normal file
@@ -0,0 +1,88 @@
|
||||
package Common_old.UI.Tables;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import Common_old.UI.DataControl;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.CellEditorListener;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.table.TableCellEditor;
|
||||
import java.awt.*;
|
||||
import java.util.EventObject;
|
||||
import java.util.Objects;
|
||||
public abstract class DBObjectEditor<T extends DBObject> extends EditorCell implements TableCellEditor {
|
||||
//задается при редактировании клетки.
|
||||
public T value = null;
|
||||
protected transient ChangeEvent changeEvent;
|
||||
public abstract void Action();
|
||||
public void InitValue(JTable table, Object value_in, int row, int column) {
|
||||
value = (T) ((DataControl) table).getRowObject(row);
|
||||
}
|
||||
@Override
|
||||
public Component getTableCellEditorComponent(
|
||||
JTable table, Object value_in, boolean isSelected, int row, int column) {
|
||||
this.setBackground(table.getSelectionBackground());
|
||||
InitValue(table, value_in, row, column);
|
||||
Action();
|
||||
return this;
|
||||
}
|
||||
//Copied from AbstractCellEditor
|
||||
//protected EventListenerList listenerList = new EventListenerList();
|
||||
@Override
|
||||
public boolean isCellEditable(EventObject e) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean shouldSelectCell(EventObject anEvent) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean stopCellEditing() {
|
||||
fireEditingStopped();
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public void cancelCellEditing() {
|
||||
fireEditingCanceled();
|
||||
}
|
||||
@Override
|
||||
public void addCellEditorListener(CellEditorListener l) {
|
||||
listenerList.add(CellEditorListener.class, l);
|
||||
}
|
||||
@Override
|
||||
public void removeCellEditorListener(CellEditorListener l) {
|
||||
listenerList.remove(CellEditorListener.class, l);
|
||||
}
|
||||
public CellEditorListener[] getCellEditorListeners() {
|
||||
return listenerList.getListeners(CellEditorListener.class);
|
||||
}
|
||||
protected void fireEditingStopped() {
|
||||
// Guaranteed to return a non-null array
|
||||
Object[] listeners = listenerList.getListenerList();
|
||||
// Process the listeners last to first, notifying
|
||||
// those that are interested in this event
|
||||
for (int i = listeners.length - 2; i >= 0; i -= 2) {
|
||||
if (listeners[i] == CellEditorListener.class) {
|
||||
// Lazily create the event:
|
||||
if (Objects.isNull(changeEvent)) {
|
||||
changeEvent = new ChangeEvent(this);
|
||||
}
|
||||
((CellEditorListener) listeners[i + 1]).editingStopped(changeEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
protected void fireEditingCanceled() {
|
||||
// Guaranteed to return a non-null array
|
||||
Object[] listeners = listenerList.getListenerList();
|
||||
// Process the listeners last to first, notifying
|
||||
// those that are interested in this event
|
||||
for (int i = listeners.length - 2; i >= 0; i -= 2) {
|
||||
if (listeners[i] == CellEditorListener.class) {
|
||||
// Lazily create the event:
|
||||
if (Objects.isNull(changeEvent)) {
|
||||
changeEvent = new ChangeEvent(this);
|
||||
}
|
||||
((CellEditorListener) listeners[i + 1]).editingCanceled(changeEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
src/Common_old/UI/Tables/DBObjectRenderer.java
Normal file
11
src/Common_old/UI/Tables/DBObjectRenderer.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package Common_old.UI.Tables;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import Common_old.UI.DataControl;
|
||||
|
||||
import javax.swing.*;
|
||||
public abstract class DBObjectRenderer extends RendererCell<DBObject> {
|
||||
@Override
|
||||
public DBObject Init(JTable table, Object value, int row, int column) {
|
||||
return ((DataControl) table).getRowObject(row);
|
||||
}
|
||||
}
|
||||
14
src/Common_old/UI/Tables/DBObjectSelectionRenderer.java
Normal file
14
src/Common_old/UI/Tables/DBObjectSelectionRenderer.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package Common_old.UI.Tables;
|
||||
public class DBObjectSelectionRenderer extends DBObjectRenderer {
|
||||
/*
|
||||
@Override
|
||||
public Dimension getMinimumSize() {
|
||||
return new Dimension(25,25);
|
||||
}
|
||||
*/
|
||||
@Override
|
||||
public void Display() {
|
||||
if (value != null)
|
||||
setIcon(value.GetSelectionIcon());
|
||||
}
|
||||
}
|
||||
13
src/Common_old/UI/Tables/DBObjectSelector.java
Normal file
13
src/Common_old/UI/Tables/DBObjectSelector.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package Common_old.UI.Tables;
|
||||
import Common.Database.Objects.DBObject;
|
||||
public class DBObjectSelector<T extends DBObject> extends DBObjectEditor<T> {
|
||||
@Override
|
||||
public void Action() {
|
||||
value.SwitchSelection();
|
||||
setIcon(value.GetSelectionIcon());
|
||||
}
|
||||
@Override
|
||||
public Object getCellEditorValue() {
|
||||
return value.isSelected();
|
||||
}
|
||||
}
|
||||
64
src/Common_old/UI/Tables/DataTable.java
Normal file
64
src/Common_old/UI/Tables/DataTable.java
Normal file
@@ -0,0 +1,64 @@
|
||||
package Common_old.UI.Tables;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import Common_old.UI.DataControl;
|
||||
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
public abstract class DataTable extends StyledTable implements DataControl {
|
||||
public DataTable(AbstractTableModel model) {
|
||||
super(model);
|
||||
}
|
||||
@Override
|
||||
public void SelectRowByPK(Object pk) {
|
||||
for (int i = 0; i < getRowCount(); ++i) {
|
||||
DBObject o = getRowObject(i);
|
||||
if (o!=null) {
|
||||
if (o.getPK()
|
||||
.equals(pk)) {
|
||||
SelectRow(i);
|
||||
scrollToVisible(i, 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//-------------------------------
|
||||
/*
|
||||
public void SelectRow(int r) {
|
||||
getSelectionModel().setSelectionInterval(r, r);
|
||||
}
|
||||
public Object getRowKey(int r) {
|
||||
return getValueAt(r, 0);
|
||||
}
|
||||
public DBObject getRowObject(int row) {
|
||||
return (DBObject) getGrid().getDataSource().get(getRowKey(row));
|
||||
}
|
||||
//-------------------------------
|
||||
|
||||
public int getRowByKey(Object key) {
|
||||
for (int i = 0; i < getRowCount(); ++i) {
|
||||
if (getRowKey(i).equals(key)) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
public void SelectRowByKey(Object key) {
|
||||
int r = getRowByKey(key);
|
||||
if (r >= 0)
|
||||
SelectRow(r);
|
||||
}
|
||||
public void ClearSelectionSync() {
|
||||
events_on = false;
|
||||
getSelectionModel().clearSelection();
|
||||
current_row_i = Utils.Nan;
|
||||
events_on = true;
|
||||
}
|
||||
public void SelectRowByKeySync(Object key) {
|
||||
int r = getRowByKey(key);
|
||||
events_on = false;
|
||||
if (r >= 0)
|
||||
SelectRow(r);
|
||||
events_on = true;
|
||||
current_row_i = r;
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
18
src/Common_old/UI/Tables/DateRenderer_.java
Normal file
18
src/Common_old/UI/Tables/DateRenderer_.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package Common_old.UI.Tables;
|
||||
import Common_old.Utils.Utils;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.Date;
|
||||
//название пересекается с встроенным классом поэтому подчеркивание.
|
||||
public class DateRenderer_ extends RendererCell<Date> {
|
||||
private static final Date zero = new Date(0);
|
||||
@Override
|
||||
public Date Init(JTable table, Object value, int row, int column) {
|
||||
return (Date) value;
|
||||
}
|
||||
@Override
|
||||
public void Display() {
|
||||
if (value != null)
|
||||
setText(value.equals(zero) ? "нет" : Utils.print_date(value));
|
||||
}
|
||||
}
|
||||
82
src/Common_old/UI/Tables/EditableHeaderRenderer.java
Normal file
82
src/Common_old/UI/Tables/EditableHeaderRenderer.java
Normal file
@@ -0,0 +1,82 @@
|
||||
package Common_old.UI.Tables;
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.JTableHeader;
|
||||
import javax.swing.table.TableCellRenderer;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
public class EditableHeaderRenderer implements TableCellRenderer {
|
||||
private JTable table = null;
|
||||
private MouseEventReposter reporter = null;
|
||||
private JComponent editor;
|
||||
public EditableHeaderRenderer(JComponent editor) {
|
||||
this.editor = editor;
|
||||
this.editor.setBorder(UIManager.getBorder("TableHeader.cellBorder"));
|
||||
}
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
|
||||
if (table != null && this.table != table) {
|
||||
this.table = table;
|
||||
final JTableHeader header = table.getTableHeader();
|
||||
if (header != null) {
|
||||
this.editor.setForeground(header.getForeground());
|
||||
this.editor.setBackground(header.getBackground());
|
||||
this.editor.setFont(header.getFont());
|
||||
reporter = new MouseEventReposter(header, col, this.editor);
|
||||
header.addMouseListener(reporter);
|
||||
}
|
||||
}
|
||||
if (reporter != null) reporter.setColumn(col);
|
||||
return this.editor;
|
||||
}
|
||||
static public class MouseEventReposter extends MouseAdapter {
|
||||
private Component dispatchComponent;
|
||||
private JTableHeader header;
|
||||
private int column = -1;
|
||||
private Component editor;
|
||||
public MouseEventReposter(JTableHeader header, int column, Component editor) {
|
||||
this.header = header;
|
||||
this.column = column;
|
||||
this.editor = editor;
|
||||
}
|
||||
public void setColumn(int column) {
|
||||
this.column = column;
|
||||
}
|
||||
private void setDispatchComponent(MouseEvent e) {
|
||||
int col = header.getTable().columnAtPoint(e.getPoint());
|
||||
if (col != column || col == -1) return;
|
||||
Point p = e.getPoint();
|
||||
Point p2 = SwingUtilities.convertPoint(header, p, editor);
|
||||
dispatchComponent = SwingUtilities.getDeepestComponentAt(editor, p2.x, p2.y);
|
||||
}
|
||||
private boolean repostEvent(MouseEvent e) {
|
||||
if (dispatchComponent == null) {
|
||||
return false;
|
||||
}
|
||||
MouseEvent e2 = SwingUtilities.convertMouseEvent(header, e, dispatchComponent);
|
||||
dispatchComponent.dispatchEvent(e2);
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (header.getResizingColumn() == null) {
|
||||
Point p = e.getPoint();
|
||||
int col = header.getTable().columnAtPoint(p);
|
||||
if (col != column || col == -1) return;
|
||||
int index = header.getColumnModel().getColumnIndexAtX(p.x);
|
||||
if (index == -1) return;
|
||||
editor.setBounds(header.getHeaderRect(index));
|
||||
header.add(editor);
|
||||
editor.validate();
|
||||
setDispatchComponent(e);
|
||||
repostEvent(e);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
repostEvent(e);
|
||||
dispatchComponent = null;
|
||||
header.remove(editor);
|
||||
}
|
||||
}
|
||||
}
|
||||
7
src/Common_old/UI/Tables/EditorCell.java
Normal file
7
src/Common_old/UI/Tables/EditorCell.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package Common_old.UI.Tables;
|
||||
import java.awt.*;
|
||||
public class EditorCell extends StyledCellLabel {
|
||||
public EditorCell() {
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
}
|
||||
}
|
||||
28
src/Common_old/UI/Tables/Grid/GridAnchestor.java
Normal file
28
src/Common_old/UI/Tables/Grid/GridAnchestor.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package Common_old.UI.Tables.Grid;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import java.util.Collection;
|
||||
import java.util.Vector;
|
||||
public abstract class GridAnchestor extends AbstractTableModel {
|
||||
public Vector<Object> data = new Vector<>();
|
||||
protected Vector<String> columnNames = new Vector<>(); //массив имен столбцов.
|
||||
public GridAnchestor(Collection columnNames_in, Collection data_in) {
|
||||
columnNames.addAll(columnNames_in);
|
||||
data.addAll(data_in);
|
||||
}
|
||||
@Override
|
||||
public String getColumnName(int col) {
|
||||
return columnNames.get(col);
|
||||
}
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return columnNames.size();
|
||||
}
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return data.size();
|
||||
}
|
||||
@Override
|
||||
public Class getColumnClass(int column) {
|
||||
return getValueAt(0, column).getClass();
|
||||
}
|
||||
}
|
||||
17
src/Common_old/UI/Tables/HiddenListRenderer.java
Normal file
17
src/Common_old/UI/Tables/HiddenListRenderer.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package Common_old.UI.Tables;
|
||||
import Common_old.Current;
|
||||
import Common_old.UI.Themes.VisualiserFonts;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.Vector;
|
||||
public class HiddenListRenderer extends RendererCell<Vector<String>> {
|
||||
@Override
|
||||
public Vector<String> Init(JTable table, Object value, int row, int column) {
|
||||
return (Vector<String>) value;
|
||||
}
|
||||
@Override
|
||||
public void Display() {
|
||||
setText(String.join(";", value));
|
||||
setFont(Current.getTheme().Fonts.get(VisualiserFonts.TreePlain).deriveFont(12.0f));
|
||||
}
|
||||
}
|
||||
15
src/Common_old/UI/Tables/HyperlinksRenderer.java
Normal file
15
src/Common_old/UI/Tables/HyperlinksRenderer.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package Common_old.UI.Tables;
|
||||
import Common_old.UI.List.HyperlinksStyledList;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.TableCellRenderer;
|
||||
import java.awt.*;
|
||||
import java.util.Vector;
|
||||
public class HyperlinksRenderer extends HyperlinksStyledList implements TableCellRenderer {
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
setBackground(isSelected ? table.getSelectionBackground() : table.getBackground());
|
||||
setListData((Vector) value);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
18
src/Common_old/UI/Tables/MaskedIntegerValueRenderer.java
Normal file
18
src/Common_old/UI/Tables/MaskedIntegerValueRenderer.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package Common_old.UI.Tables;
|
||||
import javax.swing.*;
|
||||
public class MaskedIntegerValueRenderer extends RendererCell<Long> {
|
||||
@Override
|
||||
public Long Init(JTable table, Object value, int row, int column) {
|
||||
return (Long) value;
|
||||
}
|
||||
public long getMask() {
|
||||
return -1;
|
||||
}
|
||||
public String getMaskText() {
|
||||
return " — ";
|
||||
}
|
||||
public void Display() {
|
||||
if (value != null)
|
||||
setText(value.equals((getMask())) ? getMaskText() : String.valueOf(value));
|
||||
}
|
||||
}
|
||||
16
src/Common_old/UI/Tables/MultilineRenderer.java
Normal file
16
src/Common_old/UI/Tables/MultilineRenderer.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package Common_old.UI.Tables;
|
||||
import Common_old.UI.List.StyledList;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.TableCellRenderer;
|
||||
import java.awt.*;
|
||||
import java.util.Vector;
|
||||
public class MultilineRenderer extends StyledList implements TableCellRenderer {
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
setBackground(isSelected ? table.getSelectionBackground() : table.getBackground());
|
||||
setListData((Vector) value);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
15
src/Common_old/UI/Tables/ProgressBarRenderer.java
Normal file
15
src/Common_old/UI/Tables/ProgressBarRenderer.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package Common_old.UI.Tables;
|
||||
import Common_old.UI.ProgressBar.StyledProgressBar;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.TableCellRenderer;
|
||||
public class ProgressBarRenderer extends StyledProgressBar implements TableCellRenderer {
|
||||
@Override
|
||||
public java.awt.Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
setBackground(isSelected ? table.getSelectionBackground() : table.getBackground());
|
||||
setValue((Integer) value);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
16
src/Common_old/UI/Tables/RendererCell.java
Normal file
16
src/Common_old/UI/Tables/RendererCell.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package Common_old.UI.Tables;
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.TableCellRenderer;
|
||||
import java.awt.*;
|
||||
public abstract class RendererCell<T> extends StyledCellLabel implements TableCellRenderer {
|
||||
public T value;
|
||||
public abstract T Init(JTable table, Object value, int row, int column); //получить значение
|
||||
public abstract void Display(); //отобразить его.
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value_in, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
setBackground(isSelected ? table.getSelectionBackground() : table.getBackground());
|
||||
value = Init(table, value_in, row, column);
|
||||
Display();
|
||||
return this;
|
||||
}
|
||||
}
|
||||
18
src/Common_old/UI/Tables/StatusEnumRenderer.java
Normal file
18
src/Common_old/UI/Tables/StatusEnumRenderer.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package Common_old.UI.Tables;
|
||||
import Common_old.Current;
|
||||
import Common_old.UI.StatusEnum;
|
||||
|
||||
import javax.swing.*;
|
||||
public class StatusEnumRenderer extends RendererCell<StatusEnum> {
|
||||
@Override
|
||||
public StatusEnum Init(JTable table, Object value, int row, int column) {
|
||||
return (StatusEnum) value;
|
||||
}
|
||||
@Override
|
||||
public void Display() {
|
||||
if (value != null) {
|
||||
setText(value.getDescription());
|
||||
setFont(Current.getTheme().Fonts.get(value.getFont()));
|
||||
}
|
||||
}
|
||||
}
|
||||
21
src/Common_old/UI/Tables/StyledCellLabel.java
Normal file
21
src/Common_old/UI/Tables/StyledCellLabel.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package Common_old.UI.Tables;
|
||||
import Common_old.Current;
|
||||
import Common_old.UI.Themes.ThemeElement;
|
||||
import Common_old.UI.Themes.VisualiserFonts;
|
||||
|
||||
import javax.swing.*;
|
||||
//наиболее распространенный случай. переотображение текста и/или изображения в ячейке таблицы.
|
||||
public class StyledCellLabel extends JLabel implements ThemeElement {
|
||||
public StyledCellLabel() {
|
||||
setFont(Current.getTheme().Fonts.get(VisualiserFonts.TreePlain));
|
||||
setHorizontalAlignment(SwingConstants.LEFT);
|
||||
setVerticalAlignment(SwingConstants.CENTER);
|
||||
setOpaque(true);
|
||||
applyTheme();
|
||||
}
|
||||
@Override
|
||||
public void applyTheme() {
|
||||
setBackground(Current.getTheme().table_background);
|
||||
setForeground(Current.getTheme().foreground);
|
||||
}
|
||||
}
|
||||
101
src/Common_old/UI/Tables/StyledTable.java
Normal file
101
src/Common_old/UI/Tables/StyledTable.java
Normal file
@@ -0,0 +1,101 @@
|
||||
package Common_old.UI.Tables;
|
||||
import Common_old.Current;
|
||||
import Common_old.UI.Menus.TableMenu;
|
||||
import Common_old.UI.Themes.ThemeElement;
|
||||
import Common_old.UI.Themes.VisualiserFonts;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.*;
|
||||
import java.awt.*;
|
||||
public abstract class StyledTable extends JTable implements ThemeElement {
|
||||
//https://askdev.ru/q/kak-upravlyat-stilem-cvetom-i-razmerom-shrifta-vnutri-jtable-455196/
|
||||
//https://stackoverflow.com/questions/4129666/how-to-convert-hex-to-rgb-using-java цвета
|
||||
public StyledTable(AbstractTableModel model) {
|
||||
super(model);
|
||||
setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
||||
setFillsViewportHeight(true);
|
||||
setAutoCreateRowSorter(dataModel.getRowCount() > 0);
|
||||
Init();
|
||||
setFont(Current.getTheme().Fonts.get(VisualiserFonts.TreePlain));
|
||||
JTableHeader header = getTableHeader();
|
||||
header.setFont(Current.getTheme().Fonts.get(VisualiserFonts.TreePlain));
|
||||
putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
|
||||
setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
//текущий объет может определяться по первому столбцу. могут быть баги если не запретить
|
||||
getTableHeader().setReorderingAllowed(false);
|
||||
CorrectSizes();
|
||||
setComponentPopupMenu(CreateMenu());
|
||||
applyTheme();
|
||||
}
|
||||
public TableMenu CreateMenu() {
|
||||
return new TableMenu(this);
|
||||
}
|
||||
public void Init() {
|
||||
}
|
||||
private void adjustColumnSizes(int column, int margin) {
|
||||
DefaultTableColumnModel colModel = (DefaultTableColumnModel) getColumnModel();
|
||||
TableColumn col = colModel.getColumn(column);
|
||||
int width;
|
||||
TableCellRenderer renderer = col.getHeaderRenderer();
|
||||
if (renderer == null) {
|
||||
renderer = getTableHeader().getDefaultRenderer();
|
||||
}
|
||||
Component comp = renderer.getTableCellRendererComponent(this, col.getHeaderValue(), false, false, 0, 0);
|
||||
width = comp.getPreferredSize().width;
|
||||
for (int r = 0; r < getRowCount(); r++) {
|
||||
renderer = getCellRenderer(r, column);
|
||||
comp = renderer.getTableCellRendererComponent(this, getValueAt(r, column), false, false, r, column);
|
||||
int currentWidth = comp.getPreferredSize().width;
|
||||
width = Math.max(width, currentWidth);
|
||||
}
|
||||
width += 2 * margin;
|
||||
col.setPreferredWidth(width);
|
||||
col.setWidth(width);
|
||||
}
|
||||
private void adjustJTableRowSizes() {
|
||||
for (int row = 0; row < getRowCount(); row++) {
|
||||
int maxHeight = 0;
|
||||
for (int column = 0; column < getColumnCount(); column++) {
|
||||
TableCellRenderer cellRenderer = getCellRenderer(row, column);
|
||||
Object valueAt = getValueAt(row, column);
|
||||
Component tableCellRendererComponent = cellRenderer.getTableCellRendererComponent(this, valueAt, false, false, row, column);
|
||||
int heightPreferable = tableCellRendererComponent.getPreferredSize().height;
|
||||
maxHeight = Math.max(heightPreferable, maxHeight);
|
||||
}
|
||||
setRowHeight(row, maxHeight);
|
||||
}
|
||||
}
|
||||
public void CorrectSizes() {
|
||||
adjustJTableRowSizes();
|
||||
CorrectColumnsSizes();
|
||||
this.removeEditor();//отлючение редактирования клеток если таковые были.
|
||||
}
|
||||
public void CorrectColumnsSizes() {
|
||||
for (int i = 0; i < getColumnCount(); i++) {
|
||||
adjustColumnSizes(i, 2);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void applyTheme() {
|
||||
setBackground(Current.getTheme().table_background);
|
||||
setForeground(Current.getTheme().foreground);
|
||||
setSelectionBackground(Current.getTheme().selection_background);
|
||||
setSelectionForeground(Current.getTheme().foreground);
|
||||
}
|
||||
public void SelectRow(int r) {
|
||||
getSelectionModel().setSelectionInterval(r, r);
|
||||
}
|
||||
public void scrollToVisible(int rowIndex, int vColIndex) {
|
||||
if (!(getParent() instanceof JViewport)) {
|
||||
return;
|
||||
}
|
||||
JViewport viewport = (JViewport) getParent();
|
||||
Rectangle rect = getCellRect(rowIndex, vColIndex, true);
|
||||
Point pt = viewport.getViewPosition();
|
||||
rect.setLocation(rect.x - pt.x, rect.y - pt.y);
|
||||
viewport.scrollRectToVisible(rect);
|
||||
}
|
||||
public void scrollToLastRow() {
|
||||
scrollToVisible(getRowCount() - 1, 0);
|
||||
}
|
||||
}
|
||||
10
src/Common_old/UI/Tables/TableEditors.java
Normal file
10
src/Common_old/UI/Tables/TableEditors.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package Common_old.UI.Tables;
|
||||
public enum TableEditors {
|
||||
EditorDefault,
|
||||
EditorSelect,
|
||||
EditorHyperlinks,
|
||||
EditorDimension,
|
||||
EditorCompilerEnvironmentValue,
|
||||
EditorCompilerOptionParameterValue,
|
||||
EditorAutoConfiguration
|
||||
}
|
||||
20
src/Common_old/UI/Tables/TableRenderers.java
Normal file
20
src/Common_old/UI/Tables/TableRenderers.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package Common_old.UI.Tables;
|
||||
public enum TableRenderers {
|
||||
RendererDefault,
|
||||
RendererDate,
|
||||
RendererProgress,
|
||||
RendererSelect,
|
||||
RendererDimension,
|
||||
RendererMultiline,
|
||||
RendererHyperlinks,
|
||||
RendererTopLeft,
|
||||
RendererMaskedInt,
|
||||
RendererVariantRank,
|
||||
RendererHiddenList,
|
||||
RendererWrapText,
|
||||
RendererCompilerOptionParameterValue,
|
||||
RendererCompilerEnvironmentValue,
|
||||
RendererCompilerOptionParameterName,
|
||||
RendererStatusEnum,
|
||||
RendererAutoConfiguration
|
||||
}
|
||||
13
src/Common_old/UI/Tables/TopLeftRenderer.java
Normal file
13
src/Common_old/UI/Tables/TopLeftRenderer.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package Common_old.UI.Tables;
|
||||
import javax.swing.*;
|
||||
public class TopLeftRenderer extends RendererCell {
|
||||
@Override
|
||||
public Object Init(JTable table, Object value, int row, int column) {
|
||||
return value;
|
||||
}
|
||||
@Override
|
||||
public void Display() {
|
||||
if (value != null)
|
||||
setText(value.toString());
|
||||
}
|
||||
}
|
||||
89
src/Common_old/UI/Tables/VectorEditor.java
Normal file
89
src/Common_old/UI/Tables/VectorEditor.java
Normal file
@@ -0,0 +1,89 @@
|
||||
package Common_old.UI.Tables;
|
||||
import ProjectData.Files.UI.FilesHyperlinksPanel;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.CellEditorListener;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.table.TableCellEditor;
|
||||
import java.awt.*;
|
||||
import java.util.EventObject;
|
||||
import java.util.Objects;
|
||||
import java.util.Vector;
|
||||
public class VectorEditor extends FilesHyperlinksPanel implements TableCellEditor {
|
||||
protected transient ChangeEvent changeEvent;
|
||||
@Override
|
||||
public Component getTableCellEditorComponent(
|
||||
JTable table, Object value, boolean isSelected, int row, int column) {
|
||||
if (value instanceof Vector) {
|
||||
UpdateByCell((Vector) value);
|
||||
this.Hyperlinks.setBackground(table.getSelectionBackground());
|
||||
Hyperlinks.setSelectionBackground(table.getSelectionBackground());
|
||||
Hyperlinks.setSelectionForeground(table.getSelectionForeground());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public Object getCellEditorValue() {
|
||||
return links;
|
||||
}
|
||||
//Copied from AbstractCellEditor
|
||||
//protected EventListenerList listenerList = new EventListenerList();
|
||||
@Override
|
||||
public boolean isCellEditable(EventObject e) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean shouldSelectCell(EventObject anEvent) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean stopCellEditing() {
|
||||
fireEditingStopped();
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public void cancelCellEditing() {
|
||||
fireEditingCanceled();
|
||||
}
|
||||
@Override
|
||||
public void addCellEditorListener(CellEditorListener l) {
|
||||
listenerList.add(CellEditorListener.class, l);
|
||||
}
|
||||
@Override
|
||||
public void removeCellEditorListener(CellEditorListener l) {
|
||||
listenerList.remove(CellEditorListener.class, l);
|
||||
}
|
||||
public CellEditorListener[] getCellEditorListeners() {
|
||||
return listenerList.getListeners(CellEditorListener.class);
|
||||
}
|
||||
protected void fireEditingStopped() {
|
||||
// Guaranteed to return a non-null array
|
||||
Object[] listeners = listenerList.getListenerList();
|
||||
// Process the listeners last to first, notifying
|
||||
// those that are interested in this event
|
||||
for (int i = listeners.length - 2; i >= 0; i -= 2) {
|
||||
if (listeners[i] == CellEditorListener.class) {
|
||||
// Lazily create the event:
|
||||
if (Objects.isNull(changeEvent)) {
|
||||
changeEvent = new ChangeEvent(this);
|
||||
}
|
||||
((CellEditorListener) listeners[i + 1]).editingStopped(changeEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
protected void fireEditingCanceled() {
|
||||
// Guaranteed to return a non-null array
|
||||
Object[] listeners = listenerList.getListenerList();
|
||||
// Process the listeners last to first, notifying
|
||||
// those that are interested in this event
|
||||
for (int i = listeners.length - 2; i >= 0; i -= 2) {
|
||||
if (listeners[i] == CellEditorListener.class) {
|
||||
// Lazily create the event:
|
||||
if (Objects.isNull(changeEvent)) {
|
||||
changeEvent = new ChangeEvent(this);
|
||||
}
|
||||
((CellEditorListener) listeners[i + 1]).editingCanceled(changeEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
25
src/Common_old/UI/Tables/WrapTextRenderer.java
Normal file
25
src/Common_old/UI/Tables/WrapTextRenderer.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package Common_old.UI.Tables;
|
||||
import Common_old.Current;
|
||||
import Common_old.UI.Themes.VisualiserFonts;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.TableCellRenderer;
|
||||
import java.awt.*;
|
||||
public class WrapTextRenderer extends JTextArea implements TableCellRenderer {
|
||||
public WrapTextRenderer() {
|
||||
setLineWrap(true);
|
||||
setWrapStyleWord(true);
|
||||
// setOpaque(false);
|
||||
setFont(Current.getTheme().Fonts.get(VisualiserFonts.Distribution).deriveFont(14.0f));
|
||||
}
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
setBackground(isSelected ? table.getSelectionBackground() : table.getBackground());
|
||||
setText((value == null) ? "" : value.toString());
|
||||
setSize(table.getColumnModel().getColumn(column).getWidth(),
|
||||
getPreferredSize().height);
|
||||
if (table.getRowHeight(row) != getPreferredSize().height) {
|
||||
table.setRowHeight(row, getPreferredSize().height);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
9
src/Common_old/UI/TextArea/StyledTextArea.java
Normal file
9
src/Common_old/UI/TextArea/StyledTextArea.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package Common_old.UI.TextArea;
|
||||
import Common_old.UI.Menus.TextEditorMenu;
|
||||
|
||||
import javax.swing.*;
|
||||
public class StyledTextArea extends JTextArea {
|
||||
public StyledTextArea() {
|
||||
setComponentPopupMenu(new TextEditorMenu(this));
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user