@ -0,0 +1,176 @@ |
|||||||
|
package com.fr.design.dialog; |
||||||
|
|
||||||
|
|
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.utils.gui.GUICoreUtils; |
||||||
|
import java.awt.BorderLayout; |
||||||
|
import java.awt.Color; |
||||||
|
import java.awt.Dimension; |
||||||
|
import java.awt.Frame; |
||||||
|
import java.awt.event.MouseAdapter; |
||||||
|
import java.awt.event.MouseEvent; |
||||||
|
import java.awt.event.MouseListener; |
||||||
|
import javax.swing.BorderFactory; |
||||||
|
import javax.swing.Icon; |
||||||
|
import javax.swing.JDialog; |
||||||
|
import javax.swing.JPanel; |
||||||
|
import javax.swing.JScrollPane; |
||||||
|
import javax.swing.ScrollPaneConstants; |
||||||
|
import javax.swing.UIManager; |
||||||
|
|
||||||
|
/** |
||||||
|
* 带查看详情的简要通知框 |
||||||
|
* |
||||||
|
*/ |
||||||
|
public class NotificationDialog extends JDialog { |
||||||
|
public static final int ERROR_MESSAGE = 0; |
||||||
|
public static final int NEW_MESSAGE = 1; |
||||||
|
public static final int WARNING_MESSAGE = 2; |
||||||
|
public static final String HTML_TAG_1 = "<html>"; |
||||||
|
public static final String HTML_TAG_2 = "</html>"; |
||||||
|
private UILabel messageText; |
||||||
|
private NotificationDialogAction notificationDialogAction; |
||||||
|
|
||||||
|
public NotificationDialog(Frame owner, String title, boolean isModal, int messageType, String message,NotificationDialogAction action) { |
||||||
|
super(owner); |
||||||
|
setTitle(title); |
||||||
|
initComponents(messageType, message, isModal,action); |
||||||
|
} |
||||||
|
|
||||||
|
public NotificationDialog(Builder builder) { |
||||||
|
super(builder.owner); |
||||||
|
setTitle(builder.title); |
||||||
|
initComponents(builder.messageType, builder.message, builder.modal, builder.action); |
||||||
|
} |
||||||
|
|
||||||
|
public void initComponents(int messageType, String message, boolean isModal,NotificationDialogAction action) { |
||||||
|
notificationDialogAction = action; |
||||||
|
setModal(isModal); |
||||||
|
setResizable(false); |
||||||
|
|
||||||
|
//消息内容
|
||||||
|
UILabel icon = new UILabel(getIconForType(messageType)); |
||||||
|
JPanel iconPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||||
|
iconPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 8)); |
||||||
|
iconPanel.add(icon); |
||||||
|
add(iconPanel, BorderLayout.WEST); |
||||||
|
|
||||||
|
messageText = new UILabel(HTML_TAG_1 + message + HTML_TAG_2); |
||||||
|
messageText.setForeground(new Color(51, 51, 52)); |
||||||
|
JPanel centerPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||||
|
centerPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 10)); |
||||||
|
JScrollPane jScrollPane = new JScrollPane(messageText, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); |
||||||
|
jScrollPane.setBorder(BorderFactory.createEmptyBorder()); |
||||||
|
centerPanel.add(jScrollPane, BorderLayout.CENTER); |
||||||
|
add(centerPanel, BorderLayout.CENTER); |
||||||
|
|
||||||
|
//查看详情
|
||||||
|
UILabel detailLabel = new UILabel(); |
||||||
|
detailLabel.setText(Toolkit.i18nText("Fine_Designer_Look_Detail")); |
||||||
|
detailLabel.setForeground(Color.BLUE); |
||||||
|
JPanel detailPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||||
|
detailPanel.add(detailLabel, BorderLayout.EAST); |
||||||
|
add(detailPanel, BorderLayout.SOUTH); |
||||||
|
setPreferredSize(new Dimension(262, 135)); |
||||||
|
|
||||||
|
detailLabel.addMouseListener(detailClickListener); |
||||||
|
messageText.addMouseListener(detailClickListener); |
||||||
|
|
||||||
|
pack(); |
||||||
|
if (getOwner() != null) { |
||||||
|
GUICoreUtils.setWindowCenter(getOwner(), this); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private MouseListener detailClickListener = new MouseAdapter() { |
||||||
|
@Override |
||||||
|
public void mouseClicked(MouseEvent e) { |
||||||
|
if(notificationDialogAction != null){ |
||||||
|
hideDialog(); |
||||||
|
notificationDialogAction.doClick(); |
||||||
|
} |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 设置通知消息 |
||||||
|
*/ |
||||||
|
public void setMessage(String message){ |
||||||
|
messageText.setText(HTML_TAG_1 + message + HTML_TAG_2); |
||||||
|
} |
||||||
|
|
||||||
|
private void hideDialog(){ |
||||||
|
this.dispose(); |
||||||
|
} |
||||||
|
|
||||||
|
protected Icon getIconForType(int messageType) { |
||||||
|
String propertyName; |
||||||
|
switch (messageType) { |
||||||
|
case 0: |
||||||
|
propertyName = "OptionPane.circularErrorIcon"; |
||||||
|
break; |
||||||
|
case 1: |
||||||
|
propertyName = "OptionPane.newMessageIcon"; |
||||||
|
break; |
||||||
|
case 2: |
||||||
|
propertyName = "OptionPane.warningIcon"; |
||||||
|
break; |
||||||
|
default: |
||||||
|
return null; |
||||||
|
} |
||||||
|
return UIManager.getIcon(propertyName); |
||||||
|
} |
||||||
|
|
||||||
|
public static Builder Builder() { |
||||||
|
return new NotificationDialog.Builder(); |
||||||
|
} |
||||||
|
|
||||||
|
public static final class Builder { |
||||||
|
public int messageType = WARNING_MESSAGE; |
||||||
|
public String message; |
||||||
|
public boolean modal = true; |
||||||
|
public Frame owner = null; |
||||||
|
public String title; |
||||||
|
public NotificationDialogAction action; |
||||||
|
private Builder() { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public NotificationDialog build() { |
||||||
|
return new NotificationDialog(this); |
||||||
|
} |
||||||
|
|
||||||
|
public Builder owner(Frame owner) { |
||||||
|
this.owner = owner; |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public Builder messageType(int messageType) { |
||||||
|
this.messageType = messageType; |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public Builder message(String message) { |
||||||
|
this.message = message; |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public Builder modal(boolean modal) { |
||||||
|
this.modal = modal; |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public Builder title(String title) { |
||||||
|
this.title = title; |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public Builder notificationDialogAction(NotificationDialogAction action) { |
||||||
|
this.action = action; |
||||||
|
return this; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,5 @@ |
|||||||
|
package com.fr.design.dialog; |
||||||
|
|
||||||
|
public interface NotificationDialogAction { |
||||||
|
void doClick(); |
||||||
|
} |
@ -0,0 +1,87 @@ |
|||||||
|
package com.fr.design.ui.compatible; |
||||||
|
|
||||||
|
import com.fr.design.ui.ModernRequestClient; |
||||||
|
import com.fr.design.ui.ModernUIConstants; |
||||||
|
import com.fr.general.IOUtils; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
import com.fr.web.struct.AssembleComponent; |
||||||
|
import com.fr.web.struct.AtomBuilder; |
||||||
|
import com.fr.web.struct.PathGroup; |
||||||
|
import com.fr.web.struct.category.ScriptPath; |
||||||
|
import com.fr.web.struct.category.StylePath; |
||||||
|
import com.teamdev.jxbrowser.net.Network; |
||||||
|
import com.teamdev.jxbrowser.net.UrlRequest; |
||||||
|
import com.teamdev.jxbrowser.net.callback.InterceptRequestCallback; |
||||||
|
|
||||||
|
import java.io.InputStream; |
||||||
|
import java.nio.charset.StandardCharsets; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author richie |
||||||
|
* @version 10.0 |
||||||
|
* Created by richie on 2020/3/25 |
||||||
|
*/ |
||||||
|
public class NxComplexInterceptRequestCallback extends NxInterceptRequestCallback { |
||||||
|
|
||||||
|
private AssembleComponent component; |
||||||
|
|
||||||
|
public NxComplexInterceptRequestCallback(Network network, AssembleComponent component) { |
||||||
|
super(network); |
||||||
|
this.component = component; |
||||||
|
} |
||||||
|
|
||||||
|
public NxComplexInterceptRequestCallback(Network network, AssembleComponent component, Map<String, String> map) { |
||||||
|
super(network, map); |
||||||
|
this.component = component; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected Response next(UrlRequest urlRequest, String path) { |
||||||
|
if (path.startsWith("emb:dynamic")) { |
||||||
|
String text = htmlText(map); |
||||||
|
return InterceptRequestCallback.Response.intercept(generateBasicUrlRequestJob(urlRequest, "text/html", text.getBytes(StandardCharsets.UTF_8))); |
||||||
|
} else { |
||||||
|
int index = path.indexOf("="); |
||||||
|
if (index > 0) { |
||||||
|
path = path.substring(index + 1); |
||||||
|
} else { |
||||||
|
path = path.substring(4); |
||||||
|
} |
||||||
|
InputStream inputStream = IOUtils.readResource(path); |
||||||
|
return InterceptRequestCallback.Response.intercept(generateBasicUrlRequestJob(urlRequest, getMimeType(path), IOUtils.inputStream2Bytes(inputStream))); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private String htmlText(Map<String, String> map) { |
||||||
|
PathGroup pathGroup = AtomBuilder.create().buildAssembleFilePath(ModernRequestClient.KEY, component); |
||||||
|
StylePath[] stylePaths = pathGroup.toStylePathGroup(); |
||||||
|
StringBuilder styleText = new StringBuilder(); |
||||||
|
for (StylePath path : stylePaths) { |
||||||
|
if (StringUtils.isNotBlank(path.toFilePath())) { |
||||||
|
styleText.append("<link rel=\"stylesheet\" href=\"emb:"); |
||||||
|
styleText.append(path.toFilePath()); |
||||||
|
styleText.append("\"/>"); |
||||||
|
} |
||||||
|
} |
||||||
|
String result = ModernUIConstants.HTML_TPL.replaceAll("##style##", styleText.toString()); |
||||||
|
ScriptPath[] scriptPaths = pathGroup.toScriptPathGroup(); |
||||||
|
StringBuilder scriptText = new StringBuilder(); |
||||||
|
for (ScriptPath path : scriptPaths) { |
||||||
|
if (StringUtils.isNotBlank(path.toFilePath())) { |
||||||
|
scriptText.append("<script src=\"emb:"); |
||||||
|
scriptText.append(path.toFilePath()); |
||||||
|
scriptText.append("\"></script>"); |
||||||
|
} |
||||||
|
} |
||||||
|
result = result.replaceAll("##script##", scriptText.toString()); |
||||||
|
if (map != null) { |
||||||
|
for (Map.Entry<String, String> entry : map.entrySet()) { |
||||||
|
String key = entry.getKey(); |
||||||
|
String value = entry.getValue(); |
||||||
|
result = result.replaceAll("\\$\\{" + key + "}", value); |
||||||
|
} |
||||||
|
} |
||||||
|
return result; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,134 @@ |
|||||||
|
package com.fr.design.ui.compatible; |
||||||
|
|
||||||
|
import com.fr.base.TemplateUtils; |
||||||
|
import com.fr.general.IOUtils; |
||||||
|
import com.fr.log.FineLoggerFactory; |
||||||
|
import com.fr.stable.ArrayUtils; |
||||||
|
import com.fr.stable.EncodeConstants; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
import com.fr.third.org.apache.commons.codec.net.URLCodec; |
||||||
|
import com.teamdev.jxbrowser.net.HttpHeader; |
||||||
|
import com.teamdev.jxbrowser.net.HttpStatus; |
||||||
|
import com.teamdev.jxbrowser.net.Network; |
||||||
|
import com.teamdev.jxbrowser.net.UrlRequest; |
||||||
|
import com.teamdev.jxbrowser.net.UrlRequestJob; |
||||||
|
import com.teamdev.jxbrowser.net.callback.InterceptRequestCallback; |
||||||
|
|
||||||
|
import java.io.File; |
||||||
|
import java.io.IOException; |
||||||
|
import java.io.InputStream; |
||||||
|
import java.net.URI; |
||||||
|
import java.nio.charset.StandardCharsets; |
||||||
|
import java.nio.file.Files; |
||||||
|
import java.nio.file.Path; |
||||||
|
import java.util.Map; |
||||||
|
import java.util.Optional; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author richie |
||||||
|
* @version 10.0 |
||||||
|
* Created by richie on 2020/3/25 |
||||||
|
*/ |
||||||
|
public class NxInterceptRequestCallback implements InterceptRequestCallback { |
||||||
|
|
||||||
|
Network network; |
||||||
|
Map<String, String> map; |
||||||
|
|
||||||
|
public NxInterceptRequestCallback(Network network) { |
||||||
|
this.network = network; |
||||||
|
} |
||||||
|
|
||||||
|
public NxInterceptRequestCallback(Network network, Map<String, String> map) { |
||||||
|
this.network = network; |
||||||
|
this.map = map; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Response on(Params params) { |
||||||
|
UrlRequest urlRequest = params.urlRequest(); |
||||||
|
String path = urlRequest.url(); |
||||||
|
if (path.startsWith("file:")) { |
||||||
|
Optional<UrlRequestJob> optional = generateFileProtocolUrlRequestJob(urlRequest, path); |
||||||
|
if (optional.isPresent()) { |
||||||
|
return InterceptRequestCallback.Response.intercept(optional.get()); |
||||||
|
} |
||||||
|
} else { |
||||||
|
return next(urlRequest, path); |
||||||
|
} |
||||||
|
return Response.proceed(); |
||||||
|
} |
||||||
|
|
||||||
|
Response next(UrlRequest urlRequest, String path) { |
||||||
|
return Response.proceed(); |
||||||
|
} |
||||||
|
|
||||||
|
private Optional<UrlRequestJob> generateFileProtocolUrlRequestJob(UrlRequest urlRequest, String path) { |
||||||
|
try { |
||||||
|
String url = new URLCodec().decode(path); |
||||||
|
String filePath = TemplateUtils.renderParameter4Tpl(url, map); |
||||||
|
File file = new File(URI.create(filePath).getPath()); |
||||||
|
InputStream inputStream = IOUtils.readResource(file.getAbsolutePath()); |
||||||
|
String mimeType = getMimeType(path); |
||||||
|
byte[] bytes; |
||||||
|
if (isPlainText(mimeType)) { |
||||||
|
String text = IOUtils.inputStream2String(inputStream, EncodeConstants.ENCODING_UTF_8); |
||||||
|
text = TemplateUtils.renderParameter4Tpl(text, map); |
||||||
|
bytes = text.getBytes(StandardCharsets.UTF_8); |
||||||
|
} else { |
||||||
|
bytes = IOUtils.inputStream2Bytes(inputStream); |
||||||
|
} |
||||||
|
return Optional.of(generateBasicUrlRequestJob(urlRequest, mimeType, bytes)); |
||||||
|
} catch (Exception e) { |
||||||
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||||
|
} |
||||||
|
return Optional.empty(); |
||||||
|
} |
||||||
|
|
||||||
|
private boolean isPlainText(String mimeType) { |
||||||
|
return ArrayUtils.contains(new String[]{"text/html", "text/javascript", "text/css"}, mimeType); |
||||||
|
} |
||||||
|
|
||||||
|
UrlRequestJob generateBasicUrlRequestJob(UrlRequest urlRequest, String mimeType, byte[] bytes) { |
||||||
|
UrlRequestJob.Options options = UrlRequestJob.Options |
||||||
|
.newBuilder(urlRequest.id(), HttpStatus.OK) |
||||||
|
.addHttpHeader(HttpHeader.of("Content-Type", mimeType)) |
||||||
|
.build(); |
||||||
|
UrlRequestJob urlRequestJob = network.newUrlRequestJob(options); |
||||||
|
urlRequestJob.write(bytes); |
||||||
|
urlRequestJob.complete(); |
||||||
|
return urlRequestJob; |
||||||
|
} |
||||||
|
|
||||||
|
String getMimeType(String path) { |
||||||
|
if (StringUtils.isBlank(path)) { |
||||||
|
return "text/html"; |
||||||
|
} |
||||||
|
if (path.endsWith(".html")) { |
||||||
|
return "text/html"; |
||||||
|
} |
||||||
|
if (path.endsWith(".css")) { |
||||||
|
return "text/css"; |
||||||
|
} |
||||||
|
if (path.endsWith(".js")) { |
||||||
|
return "text/javascript"; |
||||||
|
} |
||||||
|
if (path.endsWith(".svg")) { |
||||||
|
return "image/svg+xml"; |
||||||
|
} |
||||||
|
if (path.endsWith(".png")) { |
||||||
|
return "image/png"; |
||||||
|
} |
||||||
|
if (path.endsWith(".jpeg")) { |
||||||
|
return "image/jpeg"; |
||||||
|
} |
||||||
|
if (path.endsWith(".gif")) { |
||||||
|
return "image/gif"; |
||||||
|
} |
||||||
|
Path file = new File(path).toPath(); |
||||||
|
try { |
||||||
|
return Files.probeContentType(file); |
||||||
|
} catch (IOException e) { |
||||||
|
return "text/html"; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,61 @@ |
|||||||
|
package com.fr.design.update.actions; |
||||||
|
|
||||||
|
import com.fr.decision.update.SyncExecutor; |
||||||
|
import com.fr.decision.update.info.UpdateCallBack; |
||||||
|
import com.fr.decision.update.info.UpdateProgressCallBack; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.versioncheck.VersionCheckUtils; |
||||||
|
import com.fr.log.FineLoggerFactory; |
||||||
|
import java.util.concurrent.ExecutionException; |
||||||
|
import javax.swing.JProgressBar; |
||||||
|
import javax.swing.SwingWorker; |
||||||
|
|
||||||
|
public abstract class SyncFileProcess extends SwingWorker<Boolean, Void> { |
||||||
|
private String buildNo; |
||||||
|
private JProgressBar bar; |
||||||
|
|
||||||
|
public SyncFileProcess(JProgressBar bar, String buildNo) { |
||||||
|
this.bar = bar; |
||||||
|
this.buildNo = buildNo; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected Boolean doInBackground() throws Exception { |
||||||
|
UpdateCallBack callBack = new UpdateProgressCallBack(bar); |
||||||
|
boolean result = SyncExecutor.getInstance().execute(callBack, buildNo); |
||||||
|
if (result) { |
||||||
|
bar.setValue(0); |
||||||
|
bar.setString(Toolkit.i18nText("Fine-Design_Basic_Sync_Plugins")); |
||||||
|
VersionCheckUtils.syncPlugins(VersionCheckUtils.checkLocalAndRemotePlugin()); |
||||||
|
} |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void done() { |
||||||
|
boolean success = false; |
||||||
|
try { |
||||||
|
success = get(); |
||||||
|
} catch (InterruptedException e) { |
||||||
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||||
|
Thread.currentThread().interrupt(); |
||||||
|
} catch (ExecutionException e) { |
||||||
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||||
|
} |
||||||
|
if (success) { |
||||||
|
onDownloadSuccess(); |
||||||
|
} else { |
||||||
|
onDownloadFailed(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 下载成功 |
||||||
|
*/ |
||||||
|
public abstract void onDownloadSuccess(); |
||||||
|
|
||||||
|
/** |
||||||
|
* 下载失败 |
||||||
|
*/ |
||||||
|
public abstract void onDownloadFailed(); |
||||||
|
} |
@ -0,0 +1,346 @@ |
|||||||
|
package com.fr.design.versioncheck; |
||||||
|
|
||||||
|
import com.fr.base.FRContext; |
||||||
|
import com.fr.design.DesignerEnvManager; |
||||||
|
import com.fr.design.dialog.NotificationDialog; |
||||||
|
import com.fr.design.env.DesignerWorkspaceInfo; |
||||||
|
import com.fr.design.env.DesignerWorkspaceType; |
||||||
|
import com.fr.design.env.RemoteWorkspace; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.mainframe.DesignerContext; |
||||||
|
import com.fr.env.CheckServiceDialog; |
||||||
|
import com.fr.env.VersionCheckMessageDialog; |
||||||
|
import com.fr.general.ComparatorUtils; |
||||||
|
import com.fr.general.GeneralUtils; |
||||||
|
import com.fr.invoke.Reflect; |
||||||
|
import com.fr.json.JSONArray; |
||||||
|
import com.fr.json.JSONObject; |
||||||
|
import com.fr.locale.InterProviderFactory; |
||||||
|
import com.fr.log.FineLoggerFactory; |
||||||
|
import com.fr.plugin.context.PluginContext; |
||||||
|
import com.fr.plugin.context.PluginMarker; |
||||||
|
import com.fr.plugin.manage.PluginManager; |
||||||
|
import com.fr.plugin.manage.control.PluginControllerHelper; |
||||||
|
import com.fr.plugin.manage.control.PluginTaskCallback; |
||||||
|
import com.fr.plugin.manage.control.PluginTaskResult; |
||||||
|
import com.fr.plugin.manage.control.ProgressCallback; |
||||||
|
import com.fr.rpc.Result; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
import com.fr.workspace.WorkContext; |
||||||
|
import com.fr.workspace.base.WorkspaceAPI; |
||||||
|
import com.fr.workspace.connect.WorkspaceConnectionInfo; |
||||||
|
import com.fr.workspace.engine.base.FineObjectPool; |
||||||
|
import com.fr.workspace.engine.channel.http.FunctionalHttpRequest; |
||||||
|
import com.fr.workspace.engine.exception.WorkspaceConnectionException; |
||||||
|
import com.fr.workspace.engine.rpc.WorkspaceProxyPool; |
||||||
|
import java.awt.event.MouseAdapter; |
||||||
|
import java.awt.event.MouseEvent; |
||||||
|
import java.awt.event.MouseListener; |
||||||
|
import java.lang.reflect.Method; |
||||||
|
import java.text.ParsePosition; |
||||||
|
import java.text.SimpleDateFormat; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.Date; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.HashSet; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
import java.util.Set; |
||||||
|
import java.util.concurrent.CountDownLatch; |
||||||
|
import java.util.concurrent.TimeUnit; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author pengda |
||||||
|
* @version 10.0 |
||||||
|
* Created on 2021-06-02 |
||||||
|
*/ |
||||||
|
public class VersionCheckUtils { |
||||||
|
public static final String INCONSISTENCY = "inconsistency"; |
||||||
|
public static final String MISSING = "missing"; |
||||||
|
private static final String ID = "id"; |
||||||
|
private static final String VERSION = "version"; |
||||||
|
private static final String NAME = "name"; |
||||||
|
|
||||||
|
|
||||||
|
public static boolean versionCheck(String envName) { |
||||||
|
return checkLocalAndRemoteJartime(envName) && checkLocalAndRemotePlugin().size() == 0; |
||||||
|
} |
||||||
|
|
||||||
|
public static boolean versionCheck(DesignerWorkspaceInfo selectedEnv) { |
||||||
|
return checkLocalAndRemoteJartime(selectedEnv) && checkLocalAndRemotePlugin().size() == 0; |
||||||
|
} |
||||||
|
|
||||||
|
public static void showVersionCheckDialog(String envName) { |
||||||
|
if (!VersionCheckUtils.versionCheck(envName)) { |
||||||
|
VersionCheckMessageDialog versionCheckMessageDialog = new VersionCheckMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Sync_Check_Brief_Info"), envName); |
||||||
|
versionCheckMessageDialog.setVisible(true); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static boolean checkLocalAndRemoteJartime(String envName) { |
||||||
|
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); |
||||||
|
DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(envName); |
||||||
|
return checkLocalAndRemoteJartime(selectedEnv); |
||||||
|
} |
||||||
|
|
||||||
|
public static boolean checkLocalAndRemoteJartime(DesignerWorkspaceInfo selectedEnv) { |
||||||
|
//是否需要做服务校验
|
||||||
|
if (needCheckBranch(selectedEnv)) { |
||||||
|
String localBranch; |
||||||
|
String remoteBranch = getRemoteBranch(selectedEnv); |
||||||
|
localBranch = GeneralUtils.readFullBuildNO(); |
||||||
|
//通过是否包含#来避免当前版本为非安装版本(主要是内部开发版本)
|
||||||
|
if (localBranch.contains("#") && ComparatorUtils.equals(localBranch, remoteBranch)) { |
||||||
|
//说明版本一致,仅做日志记录
|
||||||
|
FineLoggerFactory.getLogger().info("Remote Designer version consistency"); |
||||||
|
return true; |
||||||
|
} else { |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
public static List<String> getNoExistServiceDescription(String envName) { |
||||||
|
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); |
||||||
|
DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(envName); |
||||||
|
WorkspaceConnectionInfo connectionInfo = selectedEnv.getConnection(); |
||||||
|
List<String> noExistServiceDescription = new ArrayList<>(); |
||||||
|
Set<Class> noExistServiceSet = getNoExistServiceSet(connectionInfo); |
||||||
|
for (Class clazz : noExistServiceSet) { |
||||||
|
WorkspaceAPI workspaceAPI = (WorkspaceAPI) clazz.getAnnotation(WorkspaceAPI.class); |
||||||
|
if (workspaceAPI == null) { |
||||||
|
FineLoggerFactory.getLogger().info("workspace service {} get annotation failed", clazz); |
||||||
|
continue; |
||||||
|
} |
||||||
|
if (workspaceAPI.ignore()) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
String descriptionOfCN = InterProviderFactory.getProvider().getLocText(workspaceAPI.description()); |
||||||
|
noExistServiceDescription.add(descriptionOfCN); |
||||||
|
} |
||||||
|
return noExistServiceDescription; |
||||||
|
} |
||||||
|
|
||||||
|
public static String getRemoteBranch(String envName) { |
||||||
|
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); |
||||||
|
DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(envName); |
||||||
|
return getRemoteBranch(selectedEnv); |
||||||
|
} |
||||||
|
|
||||||
|
public static String getRemoteBranch(DesignerWorkspaceInfo selectedEnv) { |
||||||
|
String remoteBranch = StringUtils.EMPTY; |
||||||
|
WorkspaceConnectionInfo connectionInfo = selectedEnv.getConnection(); |
||||||
|
try { |
||||||
|
remoteBranch = new FunctionalHttpRequest(connectionInfo).getServerBranch(); |
||||||
|
} catch (WorkspaceConnectionException e) { |
||||||
|
remoteBranch = Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Branch_Is_Old") + formatBranch(GeneralUtils.readFullBuildNO()); |
||||||
|
} catch (Exception e) { |
||||||
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||||
|
} |
||||||
|
return remoteBranch; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取不存在的服务列表 |
||||||
|
* |
||||||
|
* @param info 环境连接信息 |
||||||
|
* @return 以Set形式返回不存在的服务 |
||||||
|
*/ |
||||||
|
public static Set<Class> getNoExistServiceSet(WorkspaceConnectionInfo info) { |
||||||
|
Set<Class> noExistServiceSet = new HashSet<Class>(); |
||||||
|
Set<Class> remoteServiceSet = new HashSet<Class>(); |
||||||
|
Set<Class> localServiceSet = FineObjectPool.getInstance().getServerPool().keySet(); |
||||||
|
|
||||||
|
try { |
||||||
|
JSONArray serviceArray = new FunctionalHttpRequest(info).getServiceList(); |
||||||
|
for (int i = 0; i < serviceArray.size(); i++) { |
||||||
|
try { |
||||||
|
Class clazz = Class.forName((String) serviceArray.get(i)); |
||||||
|
remoteServiceSet.add(clazz); |
||||||
|
} catch (Exception e) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
} |
||||||
|
noExistServiceSet.addAll(localServiceSet); |
||||||
|
noExistServiceSet.removeAll(remoteServiceSet); |
||||||
|
return noExistServiceSet; |
||||||
|
} catch (WorkspaceConnectionException e) { |
||||||
|
FineLoggerFactory.getLogger().info(e.getMessage()); |
||||||
|
//根据本地的服务列表做逐一检测
|
||||||
|
for (Class clazz : localServiceSet) { |
||||||
|
Method testMethod = Reflect.on(Method.class).create(clazz, "connectTest", new Class[0], String.class, new Class[0], 1025, 8, null, null, null, null).get(); |
||||||
|
WorkspaceProxyPool proxyPool = (WorkspaceProxyPool) (((RemoteWorkspace) WorkContext.getCurrent()).getClient()).getPool(); |
||||||
|
Result result = proxyPool.testInvoker(testMethod); |
||||||
|
Exception invokeException = (Exception) result.getException(); |
||||||
|
if (invokeException != null) { |
||||||
|
Exception cause = (Exception) invokeException.getCause(); |
||||||
|
//获取被包装最底层的异常
|
||||||
|
while (cause != null) { |
||||||
|
invokeException = cause; |
||||||
|
cause = (Exception) invokeException.getCause(); |
||||||
|
} |
||||||
|
//该异常表示服务不存在
|
||||||
|
if (invokeException instanceof ClassNotFoundException) { |
||||||
|
noExistServiceSet.add(clazz); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
return noExistServiceSet; |
||||||
|
} catch (Exception e) { |
||||||
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||||
|
return noExistServiceSet; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 格式化分支版本号 |
||||||
|
* |
||||||
|
* @param buildNO 初始的分支版本号 |
||||||
|
* @return 格式化后的版本号 |
||||||
|
*/ |
||||||
|
private static String formatBranch(String buildNO) { |
||||||
|
Date jarDate = (new SimpleDateFormat("yyyy.MM.dd")).parse(buildNO, new ParsePosition(buildNO.indexOf("-") + 1)); |
||||||
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); |
||||||
|
return df.format(jarDate); |
||||||
|
} |
||||||
|
|
||||||
|
private static boolean needCheckBranch(DesignerWorkspaceInfo selectedEnv) { |
||||||
|
if (selectedEnv.getType() == DesignerWorkspaceType.Remote) { |
||||||
|
return true; |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
public static JSONArray checkLocalAndRemotePlugin() { |
||||||
|
JSONArray differentPlugins = new JSONArray(); |
||||||
|
JSONArray remotePlugins = FRContext.getCommonOperator().getPluginStatus(); |
||||||
|
Map<String, PluginContext> localPluginsMap = new HashMap<>(); |
||||||
|
List<PluginContext> localPlugins = PluginManager.getContexts(); |
||||||
|
for (PluginContext pluginContext : localPlugins) { |
||||||
|
localPluginsMap.put(pluginContext.getID(), pluginContext); |
||||||
|
} |
||||||
|
JSONObject remotePlugin; |
||||||
|
for (int i = 0; i < remotePlugins.size(); i++) { |
||||||
|
remotePlugin = remotePlugins.getJSONObject(i); |
||||||
|
if (localPluginsMap.containsKey(remotePlugin.getString(ID))) { |
||||||
|
if (ComparatorUtils.equals(localPluginsMap.get(remotePlugin.getString(ID)).getVersion(), remotePlugin.getString(VERSION))) { |
||||||
|
continue; |
||||||
|
} else { |
||||||
|
if (remotePlugin.getString(NAME) == null) { |
||||||
|
remotePlugin.put(NAME, localPluginsMap.get(remotePlugin.getString(ID)).getName()); |
||||||
|
} |
||||||
|
remotePlugin.put("type", INCONSISTENCY); |
||||||
|
} |
||||||
|
} else { |
||||||
|
remotePlugin.put("type", MISSING); |
||||||
|
if (remotePlugin.getString(NAME) == null) { |
||||||
|
remotePlugin.put(NAME, remotePlugin.getString("id")); |
||||||
|
} |
||||||
|
} |
||||||
|
differentPlugins.put(remotePlugin); |
||||||
|
} |
||||||
|
return differentPlugins; |
||||||
|
} |
||||||
|
|
||||||
|
public static void syncPlugins(JSONArray differentPlugins) { |
||||||
|
Set<String> uninstallFailed = uninstallPlugins(differentPlugins); |
||||||
|
List<PluginMarker> plugins = getSyncPlugins(differentPlugins, uninstallFailed); |
||||||
|
installPlugins(plugins); |
||||||
|
} |
||||||
|
|
||||||
|
private static List<PluginMarker> getSyncPlugins(JSONArray differentPlugins, Set<String> uninstallFailed) { |
||||||
|
JSONObject differentPlugin; |
||||||
|
String id; |
||||||
|
String version; |
||||||
|
List<PluginMarker> plugins = new ArrayList<>(); |
||||||
|
if (differentPlugins != null) { |
||||||
|
for (int i = 0; i < differentPlugins.size(); i++) { |
||||||
|
differentPlugin = differentPlugins.getJSONObject(i); |
||||||
|
id = differentPlugin.getString(ID); |
||||||
|
if (uninstallFailed.contains(id)) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
version = differentPlugin.getString(VERSION); |
||||||
|
plugins.add(PluginMarker.create(id, version)); |
||||||
|
} |
||||||
|
} |
||||||
|
return plugins; |
||||||
|
} |
||||||
|
|
||||||
|
private static Set<String> uninstallPlugins(JSONArray differentPlugins) { |
||||||
|
Set<PluginMarker> pluginsNeedUninstall = new HashSet<>(); |
||||||
|
Map<String, PluginContext> localPluginsMap = new HashMap<>(); |
||||||
|
List<PluginContext> localPlugins = PluginManager.getContexts(); |
||||||
|
for (PluginContext pluginContext : localPlugins) { |
||||||
|
localPluginsMap.put(pluginContext.getID(), pluginContext); |
||||||
|
} |
||||||
|
for (int i = 0; i < differentPlugins.size(); i++) { |
||||||
|
String id = differentPlugins.getJSONObject(i).getString(ID); |
||||||
|
if (localPluginsMap.containsKey(id)) { |
||||||
|
pluginsNeedUninstall.add(localPluginsMap.get(id).getMarker()); |
||||||
|
} |
||||||
|
} |
||||||
|
Set<String> uninstallFailedID = new HashSet<>(); |
||||||
|
CountDownLatch latch = new CountDownLatch(pluginsNeedUninstall.size()); |
||||||
|
for (PluginMarker pluginMarker : pluginsNeedUninstall) { |
||||||
|
PluginManager.getController().uninstall(pluginMarker, true, new PluginTaskCallback() { |
||||||
|
@Override |
||||||
|
public void done(PluginTaskResult result) { |
||||||
|
latch.countDown(); |
||||||
|
if (!result.isSuccess()) { |
||||||
|
uninstallFailedID.add(pluginMarker.getPluginID()); |
||||||
|
} |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
try { |
||||||
|
latch.await(5000, TimeUnit.MILLISECONDS); |
||||||
|
} catch (Exception e) { |
||||||
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||||
|
} |
||||||
|
return uninstallFailedID; |
||||||
|
} |
||||||
|
|
||||||
|
public static JSONArray getPluginsSyncFailed(JSONArray differentPlugins){ |
||||||
|
JSONArray pluginsNeedSync = JSONArray.create(); |
||||||
|
List<PluginContext> localPlugins = PluginManager.getContexts(); |
||||||
|
Map<String, String> localPluginsInfo = new HashMap<>(); |
||||||
|
for (int i = 0; i < localPlugins.size(); i++) { |
||||||
|
localPluginsInfo.put(localPlugins.get(i).getID(), localPlugins.get(i).getVersion()); |
||||||
|
} |
||||||
|
for (int i = 0; i < differentPlugins.size(); i++) { |
||||||
|
JSONObject plugin = differentPlugins.getJSONObject(i); |
||||||
|
String id = plugin.getString(ID); |
||||||
|
if (localPluginsInfo.containsKey(id) && ComparatorUtils.equals(plugin.getString(VERSION), localPluginsInfo.get(id))) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
pluginsNeedSync.add(plugin); |
||||||
|
} |
||||||
|
return pluginsNeedSync; |
||||||
|
} |
||||||
|
|
||||||
|
private static void installPlugins(List<PluginMarker> plugins) { |
||||||
|
CountDownLatch latch = new CountDownLatch(plugins.size()); |
||||||
|
for (int i = 0; i < plugins.size(); i++) { |
||||||
|
PluginControllerHelper.installOnline(plugins.get(i), new ProgressCallback() { |
||||||
|
@Override |
||||||
|
public void updateProgress(String description, double progress) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void done(PluginTaskResult result) { |
||||||
|
latch.countDown(); |
||||||
|
FineLoggerFactory.getLogger().info("installPlugin: " + result.getCurrentTask().getMarker().getPluginID()); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
try { |
||||||
|
latch.await(); |
||||||
|
} catch (InterruptedException e) { |
||||||
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
@ -0,0 +1,73 @@ |
|||||||
|
package com.fr.env; |
||||||
|
|
||||||
|
import com.fr.design.dialog.link.MessageWithLink; |
||||||
|
import com.fr.design.gui.ibutton.UIButton; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.utils.gui.GUICoreUtils; |
||||||
|
import com.fr.general.CloudCenter; |
||||||
|
import com.fr.general.GeneralContext; |
||||||
|
import com.fr.general.IOUtils; |
||||||
|
import java.awt.BorderLayout; |
||||||
|
import java.awt.Dimension; |
||||||
|
import java.awt.Frame; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.ActionListener; |
||||||
|
import java.util.Locale; |
||||||
|
import javax.swing.BorderFactory; |
||||||
|
import javax.swing.JDialog; |
||||||
|
import javax.swing.JPanel; |
||||||
|
|
||||||
|
/** |
||||||
|
* 主jar下载失败的弹出框 |
||||||
|
* |
||||||
|
* */ |
||||||
|
|
||||||
|
public class ErrorDialog extends JDialog implements ActionListener { |
||||||
|
public ErrorDialog(Frame parent, String message) { |
||||||
|
super(parent, true); |
||||||
|
init(message); |
||||||
|
} |
||||||
|
|
||||||
|
private void init(String message){ |
||||||
|
//主体内容
|
||||||
|
JPanel centerPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||||
|
|
||||||
|
//带超链的提示信息
|
||||||
|
JPanel messagePanel = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); |
||||||
|
messagePanel.setBorder(BorderFactory.createEmptyBorder(5,0,0,0)); |
||||||
|
|
||||||
|
MessageWithLink messageWithLink = new MessageWithLink(message + ",", Toolkit.i18nText("Fine-Design_Basic_Sync_Help"), CloudCenter.getInstance().acquireUrlByKind("help.replacejars", "https://help.fanruan.com/finereport/doc-view-3268.html")); |
||||||
|
messageWithLink.setPreferredSize(new Dimension(108, 20)); |
||||||
|
JPanel messageLinkPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||||
|
messageLinkPane.setBorder(BorderFactory.createEmptyBorder(5, 8, 5, 0)); |
||||||
|
messageLinkPane.add(messageWithLink); |
||||||
|
|
||||||
|
//错误提示图标
|
||||||
|
UILabel imageLabel = new UILabel(IOUtils.readIcon("com/fr/design/icon/versioncheck/bigfail.png")); |
||||||
|
messagePanel.add(imageLabel); |
||||||
|
messagePanel.add(messageLinkPane); |
||||||
|
|
||||||
|
//确定按钮
|
||||||
|
UIButton ok = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Button_OK")); |
||||||
|
ok.addActionListener(this); |
||||||
|
ok.setSize(new Dimension(44, 20)); |
||||||
|
JPanel okPanel = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); |
||||||
|
okPanel.add(ok); |
||||||
|
|
||||||
|
centerPanel.add(messagePanel, BorderLayout.CENTER); |
||||||
|
centerPanel.add(okPanel, BorderLayout.SOUTH); |
||||||
|
|
||||||
|
this.setTitle(Toolkit.i18nText("Fine-Design_Basic_Tool_Tips")); |
||||||
|
this.setResizable(false); |
||||||
|
this.add(centerPanel, BorderLayout.CENTER); |
||||||
|
this.setSize(new Dimension(GeneralContext.getLocale().equals(Locale.US) ? 282 : 262, 118)); |
||||||
|
GUICoreUtils.centerWindow(this); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
this.dispose(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,120 @@ |
|||||||
|
package com.fr.env; |
||||||
|
|
||||||
|
import com.fr.design.RestartHelper; |
||||||
|
import com.fr.design.dialog.link.MessageWithLink; |
||||||
|
import com.fr.design.gui.ibutton.UIButton; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.gui.itextarea.UITextArea; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.mainframe.DesignerContext; |
||||||
|
import com.fr.design.utils.gui.GUICoreUtils; |
||||||
|
import com.fr.general.CloudCenter; |
||||||
|
import com.fr.general.GeneralContext; |
||||||
|
import com.fr.general.IOUtils; |
||||||
|
import com.fr.json.JSONArray; |
||||||
|
import com.fr.json.JSONObject; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
import java.awt.BorderLayout; |
||||||
|
import java.awt.Dimension; |
||||||
|
import java.awt.Frame; |
||||||
|
import java.awt.event.MouseAdapter; |
||||||
|
import java.awt.event.MouseEvent; |
||||||
|
import java.awt.event.MouseListener; |
||||||
|
import java.util.Locale; |
||||||
|
import javax.swing.BorderFactory; |
||||||
|
import javax.swing.Icon; |
||||||
|
import javax.swing.JDialog; |
||||||
|
import javax.swing.JLabel; |
||||||
|
import javax.swing.JPanel; |
||||||
|
import javax.swing.JScrollPane; |
||||||
|
import javax.swing.UIManager; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author pengda |
||||||
|
* @version 10.0 |
||||||
|
* Created on 2021-06-02 |
||||||
|
*/ |
||||||
|
public class SyncFailedPluginsDialog extends JDialog { |
||||||
|
private UILabel detailsLabel; |
||||||
|
private JScrollPane scrollPane; |
||||||
|
public SyncFailedPluginsDialog(Frame parent, JSONArray syncFailedPlugins) { |
||||||
|
super(parent, true); |
||||||
|
JPanel body = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||||
|
|
||||||
|
JPanel northPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||||
|
northPane.setBorder(BorderFactory.createEmptyBorder(0,0,5,0)); |
||||||
|
JPanel imagePanel = new JPanel(); |
||||||
|
Icon icon = IOUtils.readIcon("com/fr/design/icon/versioncheck/warning.png"); |
||||||
|
JLabel imageLabel = new JLabel(); |
||||||
|
imageLabel.setIcon(icon); |
||||||
|
imagePanel.add(imageLabel); |
||||||
|
imagePanel.setPreferredSize(new Dimension(20, 20)); |
||||||
|
|
||||||
|
JPanel messagePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
MessageWithLink messageWithLink = new MessageWithLink(Toolkit.i18nText("Fine-Design_Basic_Sync_Plugin_Fail_Suggestion"),Toolkit.i18nText("Fine-Design_Basic_Sync_Deal_Immediately"), |
||||||
|
CloudCenter.getInstance().acquireUrlByKind("help.installplugins", "https://help.fanruan.com/finereport/doc-view-2198.html")); |
||||||
|
messageWithLink.setPreferredSize(new Dimension(316, 20)); |
||||||
|
|
||||||
|
messagePane.add(messageWithLink); |
||||||
|
messagePane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 0)); |
||||||
|
|
||||||
|
northPane.add(imageLabel, BorderLayout.WEST); |
||||||
|
northPane.add(messagePane, BorderLayout.CENTER); |
||||||
|
|
||||||
|
JPanel centerPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
detailsLabel = new UILabel(Toolkit.i18nText("Fine_Designer_Look_Detail")); |
||||||
|
detailsLabel.setIcon(UIManager.getIcon("OptionPane.narrow.down")); |
||||||
|
detailsLabel.addMouseListener(detailsLabelClickListener); |
||||||
|
JPanel detailsTitlePanel = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); |
||||||
|
detailsTitlePanel.add(detailsLabel); |
||||||
|
detailsTitlePanel.setBorder(BorderFactory.createEmptyBorder(0,0,5,0)); |
||||||
|
|
||||||
|
UITextArea detailsTextArea = new UITextArea(); |
||||||
|
StringBuilder detailsText = new StringBuilder(StringUtils.EMPTY); |
||||||
|
for (int i = 0; i < syncFailedPlugins.size(); i++) { |
||||||
|
JSONObject plugin = syncFailedPlugins.getJSONObject(i); |
||||||
|
detailsText.append(plugin.getString("name")).append(",").append(Toolkit.i18nText("Fine-Design_Basic_Sync_Server_Version")).append(plugin.getString("version")).append("\n"); |
||||||
|
} |
||||||
|
detailsTextArea.setText(detailsText.toString()); |
||||||
|
detailsTextArea.setEditable(false); |
||||||
|
scrollPane = new JScrollPane(detailsTextArea); |
||||||
|
centerPanel.add(detailsTitlePanel,BorderLayout.NORTH); |
||||||
|
centerPanel.add(scrollPane,BorderLayout.CENTER); |
||||||
|
|
||||||
|
JPanel southPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); |
||||||
|
UIButton restartButton = new UIButton(Toolkit.i18nText("Fine-Design_Updater_Restart_Designer")); |
||||||
|
restartButton.addMouseListener(restartButtonClickListener); |
||||||
|
southPane.add(restartButton); |
||||||
|
|
||||||
|
body.add(northPane,BorderLayout.NORTH); |
||||||
|
body.add(centerPanel,BorderLayout.CENTER); |
||||||
|
body.add(southPane,BorderLayout.SOUTH); |
||||||
|
|
||||||
|
this.setTitle(Toolkit.i18nText("Fine-Design_Basic_Tool_Tips")); |
||||||
|
this.setResizable(false); |
||||||
|
this.add(body, BorderLayout.CENTER); |
||||||
|
this.setSize(new Dimension(GeneralContext.getLocale().equals(Locale.US) ? 400 : 380, 225)); |
||||||
|
GUICoreUtils.centerWindow(this); |
||||||
|
} |
||||||
|
|
||||||
|
private MouseListener detailsLabelClickListener = new MouseAdapter() { |
||||||
|
@Override |
||||||
|
public void mouseClicked(MouseEvent e) { |
||||||
|
if(scrollPane.isVisible()){ |
||||||
|
scrollPane.setVisible(false); |
||||||
|
detailsLabel.setIcon(UIManager.getIcon("OptionPane.narrow.right")); |
||||||
|
}else{ |
||||||
|
scrollPane.setVisible(true); |
||||||
|
detailsLabel.setIcon(UIManager.getIcon("OptionPane.narrow.down")); |
||||||
|
} |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
private MouseListener restartButtonClickListener = new MouseAdapter() { |
||||||
|
@Override |
||||||
|
public void mouseClicked(MouseEvent e) { |
||||||
|
RestartHelper.restartForUpdate(DesignerContext.getDesignerFrame()); |
||||||
|
} |
||||||
|
}; |
||||||
|
} |
@ -0,0 +1,105 @@ |
|||||||
|
package com.fr.env; |
||||||
|
|
||||||
|
import com.fr.design.versioncheck.VersionCheckUtils; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.mainframe.DesignerContext; |
||||||
|
import com.fr.design.utils.gui.GUICoreUtils; |
||||||
|
import com.fr.general.ComparatorUtils; |
||||||
|
import com.fr.general.GeneralContext; |
||||||
|
import com.fr.general.GeneralUtils; |
||||||
|
import com.fr.general.IOUtils; |
||||||
|
import java.awt.BorderLayout; |
||||||
|
import java.awt.Color; |
||||||
|
import java.awt.Dimension; |
||||||
|
import java.awt.Frame; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.ActionListener; |
||||||
|
import java.awt.event.MouseAdapter; |
||||||
|
import java.awt.event.MouseEvent; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Locale; |
||||||
|
import javax.swing.BorderFactory; |
||||||
|
import javax.swing.JDialog; |
||||||
|
import javax.swing.JPanel; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author pengda |
||||||
|
* @version 10.0 |
||||||
|
* Created on 2021-06-02 |
||||||
|
*/ |
||||||
|
public class VersionCheckMessageDialog extends JDialog implements ActionListener { |
||||||
|
private UILabel imageLabel; |
||||||
|
private UILabel detailLabel; |
||||||
|
private JPanel centerPanel; |
||||||
|
private JPanel detailPanel; |
||||||
|
private JPanel body; |
||||||
|
private String envName; |
||||||
|
|
||||||
|
public VersionCheckMessageDialog(Frame parent, String message, String envName) { |
||||||
|
super(parent, true); |
||||||
|
this.envName = envName; |
||||||
|
init(message); |
||||||
|
} |
||||||
|
|
||||||
|
private void init(String message) { |
||||||
|
JPanel imagePanel = new JPanel(); |
||||||
|
imageLabel = new UILabel(IOUtils.readIcon("com/fr/design/images/warnings/warning32.png")); |
||||||
|
imagePanel.add(imageLabel); |
||||||
|
JPanel messagePanel = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true); |
||||||
|
UILabel messageText = new UILabel(); |
||||||
|
messageText.setText("<html>" + message + "</html>"); |
||||||
|
messagePanel.add(messageText); |
||||||
|
|
||||||
|
centerPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||||
|
centerPanel.setBorder(BorderFactory.createEmptyBorder(15, 10, 10, 10)); |
||||||
|
centerPanel.add(imagePanel, BorderLayout.WEST); |
||||||
|
centerPanel.add(messagePanel, BorderLayout.CENTER); |
||||||
|
|
||||||
|
detailLabel = new UILabel(); |
||||||
|
detailLabel.setText(Toolkit.i18nText("Fine_Designer_Look_Detail")); |
||||||
|
detailLabel.setForeground(Color.BLUE); |
||||||
|
|
||||||
|
detailPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||||
|
detailPanel.add(detailLabel, BorderLayout.EAST); |
||||||
|
|
||||||
|
String localBranch = GeneralUtils.readFullBuildNO(); |
||||||
|
String remoteBranch = VersionCheckUtils.getRemoteBranch(envName); |
||||||
|
List<String> noExistServiceDescription; |
||||||
|
if(ComparatorUtils.equals(localBranch,remoteBranch)) { |
||||||
|
noExistServiceDescription = new ArrayList<>(); |
||||||
|
}else{ |
||||||
|
noExistServiceDescription = VersionCheckUtils.getNoExistServiceDescription(this.envName); |
||||||
|
} |
||||||
|
|
||||||
|
detailPanel.addMouseListener(new MouseAdapter() { |
||||||
|
@Override |
||||||
|
public void mouseClicked(MouseEvent e) { |
||||||
|
hideDialog(); |
||||||
|
CheckServiceDialog checkServiceDialog = new CheckServiceDialog(DesignerContext.getDesignerFrame(), localBranch, remoteBranch, noExistServiceDescription); |
||||||
|
checkServiceDialog.setVisible(true); |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
body = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
body.add(centerPanel, BorderLayout.CENTER); |
||||||
|
body.add(detailPanel, BorderLayout.SOUTH); |
||||||
|
|
||||||
|
this.setTitle(Toolkit.i18nText("Fine-Design_Basic_Sync_Prompt")); |
||||||
|
this.setResizable(false); |
||||||
|
this.add(body, BorderLayout.NORTH); |
||||||
|
this.setSize(new Dimension(GeneralContext.getLocale().equals(Locale.US) ? 300 : 280, 135)); |
||||||
|
GUICoreUtils.centerWindow(this); |
||||||
|
} |
||||||
|
|
||||||
|
private void hideDialog(){ |
||||||
|
this.dispose(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
hideDialog(); |
||||||
|
} |
||||||
|
} |
@ -1,4 +1,4 @@ |
|||||||
com.fr.design.mainframe.check.CheckButton=230*118 |
com.fr.design.mainframe.check.CheckButton=230*118 |
||||||
com.fr.design.mainframe.check.CheckFontInfoDialog.collapse=490*185 |
com.fr.design.mainframe.check.CheckFontInfoDialog.collapse=490*185 |
||||||
com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=490*31 |
com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=490*35 |
||||||
com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=490*280 |
com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=490*280 |
After Width: | Height: | Size: 179 B |
After Width: | Height: | Size: 722 B |
After Width: | Height: | Size: 377 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 410 B |
After Width: | Height: | Size: 942 B |
After Width: | Height: | Size: 346 B |
After Width: | Height: | Size: 345 B |
After Width: | Height: | Size: 423 B |
@ -0,0 +1,29 @@ |
|||||||
|
package com.fr.design.fun; |
||||||
|
|
||||||
|
import com.fr.design.designer.creator.XCreator; |
||||||
|
import com.fr.design.mainframe.BaseJForm; |
||||||
|
import com.fr.design.mainframe.FormDesigner; |
||||||
|
import com.fr.stable.fun.mark.Immutable; |
||||||
|
|
||||||
|
import javax.swing.JComponent; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* Created by kerry on 5/28/21 |
||||||
|
*/ |
||||||
|
public interface ShareWidgetUIProcessor extends Immutable { |
||||||
|
|
||||||
|
String MARK_STRING = "ShareWidgetUIProcessor"; |
||||||
|
|
||||||
|
int CURRENT_LEVEL = 1; |
||||||
|
|
||||||
|
/** |
||||||
|
* 生成属性配置界面 |
||||||
|
* |
||||||
|
* @param xCreator 选中的Xcreator |
||||||
|
* @param formDesigner 表单设计器 |
||||||
|
* @return 属性配置界面 |
||||||
|
*/ |
||||||
|
JComponent createToolPane(XCreator xCreator, BaseJForm jform, FormDesigner formDesigner); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,19 @@ |
|||||||
|
package com.fr.design.fun.impl; |
||||||
|
|
||||||
|
import com.fr.design.fun.ShareWidgetUIProcessor; |
||||||
|
import com.fr.stable.fun.mark.API; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by kerry on 5/28/21 |
||||||
|
*/ |
||||||
|
@API(level = ShareWidgetUIProcessor.CURRENT_LEVEL) |
||||||
|
public abstract class AbstractShareWidgetUIProcessor implements ShareWidgetUIProcessor { |
||||||
|
|
||||||
|
public int currentAPILevel() { |
||||||
|
return CURRENT_LEVEL; |
||||||
|
} |
||||||
|
|
||||||
|
public int layerIndex() { |
||||||
|
return DEFAULT_LAYER_INDEX; |
||||||
|
} |
||||||
|
} |
@ -1,13 +0,0 @@ |
|||||||
package com.fr.design.mainframe.share.util; |
|
||||||
|
|
||||||
import com.fr.form.share.encrypt.engine.SharableReadHelper; |
|
||||||
import com.fr.stable.xml.XMLConf; |
|
||||||
import com.fr.stable.xml.helper.XMLReadHelper; |
|
||||||
|
|
||||||
public class SharableXMLUtils { |
|
||||||
public static synchronized void registerSharableReadHelper() { |
|
||||||
XMLReadHelper readHelper = XMLConf.getReadHelper(); |
|
||||||
XMLReadHelper helper = new SharableReadHelper(readHelper); |
|
||||||
XMLConf.registerXMLHelper(helper); |
|
||||||
} |
|
||||||
} |
|