|
|
@ -15,6 +15,7 @@ import com.fr.esd.util.ESDUtils; |
|
|
|
import com.fr.locale.InterProviderFactory; |
|
|
|
import com.fr.locale.InterProviderFactory; |
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
|
|
|
import com.fr.third.org.quartz.CronExpression; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.AbstractAction; |
|
|
|
import javax.swing.AbstractAction; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.JPanel; |
|
|
@ -25,9 +26,11 @@ import java.awt.Desktop; |
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
import java.awt.event.ActionListener; |
|
|
|
import java.awt.event.ActionListener; |
|
|
|
import java.net.URI; |
|
|
|
import java.net.URI; |
|
|
|
|
|
|
|
import java.text.ParseException; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import java.util.Date; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @author rinoux |
|
|
|
* @author rinoux |
|
|
@ -36,7 +39,6 @@ import java.util.List; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class ESDStrategyConfigPane extends BasicBeanPane<StrategyConfig> { |
|
|
|
public class ESDStrategyConfigPane extends BasicBeanPane<StrategyConfig> { |
|
|
|
private static final String CRON_HELP_URL = "http://help.fanruan.com/finereport/doc-view-693.html"; |
|
|
|
private static final String CRON_HELP_URL = "http://help.fanruan.com/finereport/doc-view-693.html"; |
|
|
|
|
|
|
|
|
|
|
|
private UIRadioButton selectAutoUpdate; |
|
|
|
private UIRadioButton selectAutoUpdate; |
|
|
|
private UIRadioButton selectBySchema; |
|
|
|
private UIRadioButton selectBySchema; |
|
|
|
private UICheckBox shouldEvolve; |
|
|
|
private UICheckBox shouldEvolve; |
|
|
@ -131,8 +133,7 @@ public class ESDStrategyConfigPane extends BasicBeanPane<StrategyConfig> { |
|
|
|
ob = StrategyConfigHelper.createStrategyConfig(true, false, true); |
|
|
|
ob = StrategyConfigHelper.createStrategyConfig(true, false, true); |
|
|
|
} |
|
|
|
} |
|
|
|
this.strategyConfig = ob; |
|
|
|
this.strategyConfig = ob; |
|
|
|
|
|
|
|
this.updateInterval.setText(ob.getUpdateInterval() <= 0 ? "0" : String.format("%.0f", ob.getUpdateInterval() / (double) CacheConstants.MILLIS_OF_MINUTE)); |
|
|
|
this.updateInterval.setText(ob.getUpdateInterval() <= 0 ? "0" : String.valueOf(ob.getUpdateInterval() / (double) CacheConstants.MILLIS_OF_MINUTE)); |
|
|
|
|
|
|
|
this.schemaTime.setText(StringUtils.join(",", ob.getUpdateSchema().toArray(new String[0]))); |
|
|
|
this.schemaTime.setText(StringUtils.join(",", ob.getUpdateSchema().toArray(new String[0]))); |
|
|
|
this.shouldEvolve.setSelected(ob.shouldEvolve()); |
|
|
|
this.shouldEvolve.setSelected(ob.shouldEvolve()); |
|
|
|
this.selectBySchema.setSelected(ob.isScheduleBySchema()); |
|
|
|
this.selectBySchema.setSelected(ob.isScheduleBySchema()); |
|
|
@ -177,11 +178,22 @@ public class ESDStrategyConfigPane extends BasicBeanPane<StrategyConfig> { |
|
|
|
|
|
|
|
|
|
|
|
if (ESDUtils.checkUpdateTimeSchema(text)) { |
|
|
|
if (ESDUtils.checkUpdateTimeSchema(text)) { |
|
|
|
if (ESDUtils.isCronExpression(text)) { |
|
|
|
if (ESDUtils.isCronExpression(text)) { |
|
|
|
|
|
|
|
// 判断后两次更新时间间隔,如果小于1分钟就显示错误
|
|
|
|
|
|
|
|
CronExpression cron = new CronExpression(text); |
|
|
|
|
|
|
|
Date next1 = cron.getNextValidTimeAfter(new Date()); |
|
|
|
|
|
|
|
Date next2 = cron.getNextValidTimeAfter(next1); |
|
|
|
|
|
|
|
if (next2.getTime() - next1.getTime() < CacheConstants.MILLIS_OF_MINUTE) { |
|
|
|
|
|
|
|
this.schemaTimeCheckTips.setText(InterProviderFactory.getDesignI18nProvider().i18nText("Fine-Design_ESD_Error_Time_Interval_Too_Short")); |
|
|
|
|
|
|
|
this.schemaTimeCheckTips.setVisible(true); |
|
|
|
|
|
|
|
throw new IllegalArgumentException("[ESD]Update schema time interval is to short."); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
schemaTimes.add(text); |
|
|
|
schemaTimes.add(text); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
Collections.addAll(schemaTimes, text.split(",")); |
|
|
|
Collections.addAll(schemaTimes, text.split(",")); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
this.schemaTimeCheckTips.setText(InterProviderFactory.getDesignI18nProvider().i18nText("Fine-Design_ESD_Error_Time_Format")); |
|
|
|
this.schemaTimeCheckTips.setVisible(true); |
|
|
|
this.schemaTimeCheckTips.setVisible(true); |
|
|
|
throw new IllegalArgumentException("[ESD]Update schema time format error."); |
|
|
|
throw new IllegalArgumentException("[ESD]Update schema time format error."); |
|
|
|
} |
|
|
|
} |
|
|
@ -202,6 +214,8 @@ public class ESDStrategyConfigPane extends BasicBeanPane<StrategyConfig> { |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (CloneNotSupportedException e) { |
|
|
|
} catch (CloneNotSupportedException e) { |
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
|
|
|
|
} catch (ParseException e) { |
|
|
|
|
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -211,7 +225,7 @@ public class ESDStrategyConfigPane extends BasicBeanPane<StrategyConfig> { |
|
|
|
|
|
|
|
|
|
|
|
private boolean checkUpdateInterval(String intervalValue) { |
|
|
|
private boolean checkUpdateInterval(String intervalValue) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
return !StringUtils.isEmpty(intervalValue) && !(Double.parseDouble(intervalValue) <= 0); |
|
|
|
return !StringUtils.isEmpty(intervalValue) && !(Integer.parseInt(intervalValue) <= 0); |
|
|
|
} catch (NumberFormatException e) { |
|
|
|
} catch (NumberFormatException e) { |
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
} |
|
|
|
} |
|
|
|