renekton
2 months ago
14 changed files with 318 additions and 148 deletions
@ -0,0 +1,83 @@
|
||||
package com.fr.design.remote.ui.debug; |
||||
|
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import java.text.DecimalFormat; |
||||
import java.text.SimpleDateFormat; |
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* 帮助类 |
||||
* |
||||
* @author vito |
||||
* @since 11.0 |
||||
* Created on 2024/10/11 |
||||
*/ |
||||
public class RemoteDesignNetWorkHelper { |
||||
private static final int UNIT = 1000; |
||||
private static final int UNIT_BYTES = 1024; |
||||
private static final String SECOND = "s"; |
||||
private static final int K = 1024; |
||||
private static final int MS = 1000; |
||||
|
||||
static String dateFormat(Date date) { |
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); |
||||
return dateFormat.format(date); |
||||
} |
||||
|
||||
static String simpleTime(long time) { |
||||
if (time < 0) { |
||||
return time + ""; |
||||
} else if (time < MS) { |
||||
return time + " ms"; |
||||
} else { |
||||
DecimalFormat df = new DecimalFormat("#.0"); |
||||
return df.format((float) time / MS) + " s"; |
||||
} |
||||
} |
||||
|
||||
static String simpleSize(long bytes) { |
||||
if (bytes < 0) { |
||||
return bytes + ""; |
||||
} else if (bytes < K) { |
||||
return bytes + " B"; |
||||
} else { |
||||
DecimalFormat df = new DecimalFormat("#.00"); |
||||
return df.format((float) bytes / K) + " K"; |
||||
} |
||||
} |
||||
|
||||
static long parseCostToMS(String timeStr) { |
||||
String[] split = timeStr.split(" "); |
||||
if (split.length > 1) { |
||||
double number = Double.parseDouble(split[0]); |
||||
String unit = split[1].toLowerCase(); |
||||
|
||||
if (StringUtils.equals(unit, SECOND)) { |
||||
return (long) (number * UNIT); |
||||
} |
||||
return (long) number; |
||||
} |
||||
return 0; |
||||
} |
||||
|
||||
static long parseSizeToBytes(String sizeStr) { |
||||
String[] split = sizeStr.split(" "); |
||||
if (split.length > 1) { |
||||
double number = Double.parseDouble(split[0]); |
||||
String unit = split[1].toUpperCase(); |
||||
|
||||
switch (unit) { |
||||
case "K": |
||||
return (long) (number * UNIT_BYTES); |
||||
case "M": |
||||
return (long) (number * UNIT_BYTES * UNIT_BYTES); |
||||
case "G": |
||||
return (long) (number * UNIT_BYTES * UNIT_BYTES * UNIT_BYTES); |
||||
default: |
||||
return (long) number; |
||||
} |
||||
} |
||||
return 0; |
||||
} |
||||
} |
@ -0,0 +1,32 @@
|
||||
package com.fr.design.remote.ui.debug; |
||||
|
||||
import javax.swing.table.DefaultTableModel; |
||||
import javax.swing.table.TableRowSorter; |
||||
import java.util.Comparator; |
||||
|
||||
/** |
||||
* 行排序器 |
||||
* |
||||
* @author vito |
||||
* @since 11.0 |
||||
* Created on 2024/10/11 |
||||
*/ |
||||
public class RemoteDesignNetWorkTableRowSorter extends TableRowSorter<DefaultTableModel> { |
||||
|
||||
public RemoteDesignNetWorkTableRowSorter(DefaultTableModel model) { |
||||
super(model); |
||||
setComparator(0, (Comparator<Long>) Long::compareTo); |
||||
setComparator(4, Comparator.comparingLong(RemoteDesignNetWorkHelper::parseCostToMS)); |
||||
setComparator(5, Comparator.comparingLong(RemoteDesignNetWorkHelper::parseSizeToBytes)); |
||||
setComparator(6, Comparator.comparingLong(RemoteDesignNetWorkHelper::parseSizeToBytes)); |
||||
} |
||||
|
||||
@Override |
||||
public boolean isSortable(int column) { |
||||
return column == 0 |
||||
|| column == 4 |
||||
|| column == 5 |
||||
|| column == 6; |
||||
} |
||||
|
||||
} |
File diff suppressed because one or more lines are too long
@ -0,0 +1,51 @@
|
||||
package com.fanruan.config; |
||||
|
||||
import com.fanruan.repository.ConfigRepository; |
||||
import com.fr.config.utils.ConfData; |
||||
import com.fr.config.utils.ConfigReadUtils; |
||||
import com.fr.config.utils.PrefixHandler; |
||||
import com.fr.config.utils.SetupDataOperator; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
/** |
||||
* 设计器远程下获取Updata的操作类 |
||||
* |
||||
* @author Destiny.Lin |
||||
* @since 11.0 |
||||
* Created on 2024/10/14 |
||||
*/ |
||||
public class SetupDataDesignerRemoteOperator implements SetupDataOperator { |
||||
|
||||
private static final SetupDataDesignerRemoteOperator INSTANCE = new SetupDataDesignerRemoteOperator(); |
||||
|
||||
/** |
||||
* 单例 |
||||
*/ |
||||
public static SetupDataDesignerRemoteOperator getInstance() { |
||||
return INSTANCE; |
||||
} |
||||
|
||||
@Override |
||||
public ConfData getData(String prefix, String tenantId) { |
||||
return ConfigRepository.getInstance().getConfigByConfigsCache(getConfigNameSpace(prefix), () -> { |
||||
ConfData data = new ConfData(); |
||||
data.setDataMap(ConfigReadUtils.getData(prefix, tenantId)); |
||||
data.setMap(ConfigReadUtils.getClassInfo(prefix, tenantId)); |
||||
return data; |
||||
}); |
||||
} |
||||
|
||||
private String getConfigNameSpace(String id) { |
||||
|
||||
if (StringUtils.isEmpty(id)) { |
||||
throw new IllegalArgumentException("id cannot be null"); |
||||
} |
||||
int length = id.length(); |
||||
for (int i = 0; i < length; i++) { |
||||
if (PrefixHandler.SEPERATOR == id.charAt(i)) { |
||||
return id.substring(0, i); |
||||
} |
||||
} |
||||
throw new IllegalArgumentException("cannot resolve namespace of " + id); |
||||
} |
||||
} |
Loading…
Reference in new issue