帆软报表设计器源代码。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

111 lines
3.2 KiB

package com.fr.design.mainframe.alphafine.cell.model;
import com.fr.design.mainframe.alphafine.AlphaFineCloudConstants;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import java.awt.Desktop;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
/**
* Created by XiaXiang on 2017/4/20.
*/
public class DocumentModel extends AlphaCellModel {
private String documentUrl;
private String informationUrl;
private int documentId;
public static final String TITLE = "title";
public static final String CONTENT = "content";
public static final String DID = "did";
public static final String SEARCHCOUNT = "searchcount";
public DocumentModel(String name, String content, int documentId) {
super(name, content, CellType.DOCUMENT);
this.documentId = documentId;
this.informationUrl = AlphaFineCloudConstants.getDocumentInformationUrl() + documentId;
this.documentUrl = AlphaFineCloudConstants.getDocumentDocUrl() + documentId + ".html";
}
public DocumentModel(String name, String content, int documentId, int searchCount) {
this(name, content, documentId);
setSearchCount(searchCount);
}
public String getDocumentUrl() {
return documentUrl;
}
public void setDocumentUrl(String documentUrl) {
this.documentUrl = documentUrl;
}
@Override
public JSONObject modelToJson() {
JSONObject object = JSONObject.create();
JSONObject modelObject = JSONObject.create();
modelObject.put(TITLE, getName()).put(CONTENT, getContent()).put(DID, getDocumentId()).put(SEARCHCOUNT, getSearchCount());
object.put("result", modelObject).put("cellType", getType().getTypeValue());
return object;
}
@Override
public String getStoreInformation() {
return getInformationUrl();
}
@Override
public void doAction() {
openInBrowser(getDocumentUrl());
}
/**
* 方便埋点
* */
void openInBrowser(String url) {
try {
Desktop.getDesktop().browse(new URI(url));
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} catch (URISyntaxException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof DocumentModel)) {
return false;
}
DocumentModel that = (DocumentModel) o;
return documentUrl != null ? documentUrl.equals(that.documentUrl) : that.documentUrl == null;
}
@Override
public int hashCode() {
return documentUrl != null ? documentUrl.hashCode() : 0;
}
public int getDocumentId() {
return documentId;
}
public void setDocumentId(int documentId) {
this.documentId = documentId;
}
public String getInformationUrl() {
return informationUrl;
}
public void setInformationUrl(String informationUrl) {
this.informationUrl = informationUrl;
}
}