use of org.talend.designer.components.exchange.model.ComponentExtension in project tdi-studio-se by Talend.
the class MyExchangeContentProvider method createContent.
public void createContent(String id, Element parent) {
Document dom = parent.getOwnerDocument();
if (ContentConstants.LAST_AVAILABLE_VERSION.equals(id)) {
if (componentExtension != null) {
Element inputText = dom.createElement("input");
inputText.setAttribute("id", "lastVersionAvailable_update");
inputText.setAttribute("name", "lastVersionAvailable");
inputText.setAttribute("type", "text");
inputText.setAttribute("style", "width:300px;margin-left:5px");
inputText.setAttribute("value", componentExtension.getLastVersionAvailable());
parent.appendChild(inputText);
}
} else if (ContentConstants.EXTENSION_LABEL.equals(id)) {
if (componentExtension != null) {
Element inputText = dom.createElement("input");
inputText.setAttribute("id", "extension_label_modify");
inputText.setAttribute("name", "extension_label");
inputText.setAttribute("type", "text");
inputText.setAttribute("style", "width:300px;margin-left:5px;background:#AAAAAA;");
inputText.setAttribute("value", componentExtension.getLabel());
inputText.setAttribute("readonly", "true");
parent.appendChild(inputText);
}
} else if (ContentConstants.LIST_MY_EXTENSION.equals(id)) {
Element tr = dom.createElement("tr");
Element td = dom.createElement("td");
String style = "border-top:1px solid #9BB9F5;border-left:1px solid #9BB9F5;background:#EBEBDB";
if (myExtensions == null || myExtensions.isEmpty()) {
style = style + ";border-bottom:1px solid #9BB9F5";
}
td.setAttribute("style", style);
Element span = dom.createElement("span");
span.setAttribute("class", "style_2 style_3");
span.appendChild(dom.createTextNode("Extension Name"));
td.appendChild(span);
tr.appendChild(td);
td = dom.createElement("td");
style = "border-top:1px solid #9BB9F5;border-left:1px solid #cccccc;background:#EBEBDB";
if (myExtensions == null || myExtensions.isEmpty()) {
style = style + ";border-bottom:1px solid #9BB9F5";
}
td.setAttribute("style", style);
span = dom.createElement("span");
span.setAttribute("class", "style_2 style_3");
span.appendChild(dom.createTextNode("Version"));
td.appendChild(span);
tr.appendChild(td);
td = dom.createElement("td");
style = "border-top:1px solid #9BB9F5;border-left:1px solid #cccccc;background:#EBEBDB";
if (myExtensions == null || myExtensions.isEmpty()) {
style = style + ";border-bottom:1px solid #9BB9F5";
}
td.setAttribute("style", style);
span = dom.createElement("span");
span.setAttribute("class", "style_2 style_3");
span.appendChild(dom.createTextNode("Upload Date"));
td.appendChild(span);
tr.appendChild(td);
td = dom.createElement("td");
style = "border-top:1px solid #9BB9F5;border-left:1px solid #cccccc;border-right:1px solid #9BB9F5;background:#EBEBDB";
if (myExtensions == null || myExtensions.isEmpty()) {
style = style + ";border-bottom:1px solid #9BB9F5";
}
td.setAttribute("style", style);
span = dom.createElement("span");
span.setAttribute("class", "style_2 style_3");
span.appendChild(dom.createTextNode("Operation"));
td.appendChild(span);
tr.appendChild(td);
parent.appendChild(tr);
componentMap.clear();
if (myExtensions == null || myExtensions.isEmpty()) {
return;
}
for (int i = 0; i < myExtensions.size(); i++) {
ComponentExtension extension = myExtensions.get(i);
Element trExtension = dom.createElement("tr");
// extension name
Element tdExtension = dom.createElement("td");
style = "border-top:1px solid #cccccc;border-left:1px solid #9BB9F5";
if (i == myExtensions.size() - 1) {
style = "border-top:1px solid #cccccc;border-left:1px solid #9BB9F5;border-bottom:1px solid #9BB9F5";
}
if (i % 2 == 0) {
style = style + ";background:#F7F7F7";
}
tdExtension.setAttribute("style", style);
tdExtension.appendChild(dom.createTextNode(extension.getLabel() == null ? "" : extension.getLabel()));
trExtension.appendChild(tdExtension);
// version
tdExtension = dom.createElement("td");
style = "border-top:1px solid #cccccc;border-left:1px solid #cccccc";
if (i == myExtensions.size() - 1) {
style = "border-top:1px solid #cccccc;border-left:1px solid #cccccc;border-bottom:1px solid #9BB9F5";
}
if (i % 2 == 0) {
style = style + ";background:#F7F7F7";
}
tdExtension.setAttribute("style", style);
tdExtension.appendChild(dom.createTextNode(extension.getLastVersionAvailable() == null ? "" : extension.getLastVersionAvailable()));
trExtension.appendChild(tdExtension);
// upload date
tdExtension = dom.createElement("td");
style = "border-top:1px solid #cccccc;border-left:1px solid #cccccc";
if (i == myExtensions.size() - 1) {
style = "border-top:1px solid #cccccc;border-left:1px solid #cccccc;border-bottom:1px solid #9BB9F5";
}
if (i % 2 == 0) {
style = style + ";background:#F7F7F7";
}
tdExtension.setAttribute("style", style);
Date publicationDate = extension.getPublicationDate();
tdExtension.appendChild(dom.createTextNode(publicationDate == null ? "" : formatter.format(publicationDate)));
trExtension.appendChild(tdExtension);
// operations
tdExtension = dom.createElement("td");
style = "border-top:1px solid #cccccc;border-left:1px solid #cccccc;border-right:1px solid #9BB9F5";
if (i == myExtensions.size() - 1) {
style = "border-top:1px solid #cccccc;border-left:1px solid #cccccc;border-right:1px solid #9BB9F5;border-bottom:1px solid #9BB9F5";
}
if (i % 2 == 0) {
style = style + ";background:#F7F7F7";
}
tdExtension.setAttribute("style", style);
String actionUrl = "http://org.eclipse.ui.intro/runAction?pluginId=org.talend.designer.components.exchange&" + "class=org.talend.designer.components.exchange.ui.htmlcontent.MyExtensionAction&" + "id=org.talend.designer.components.exchange.ui.htmlcontent.MyExtensionAction&";
Element hyperlink = dom.createElement("a");
String url = actionUrl + ContentConstants.KEY_TYPE + "=" + ContentConstants.UPLOAD_NEW_VERSION_ACTION + "&" + ContentConstants.KEY_EXTENSION_ID + "=" + extension.getIdExtension();
hyperlink.setAttribute("href", url);
Element imgElem = dom.createElement("img");
imgElem.setAttribute("src", "imgs/upload.gif");
imgElem.setAttribute("title", "Upload New Version");
hyperlink.appendChild(imgElem);
tdExtension.appendChild(hyperlink);
hyperlink = dom.createElement("a");
url = actionUrl + ContentConstants.KEY_TYPE + "=" + ContentConstants.MODIFY_ACTION + "&" + ContentConstants.KEY_EXTENSION_ID + "=" + extension.getIdExtension();
hyperlink.setAttribute("href", url);
imgElem = dom.createElement("img");
imgElem.setAttribute("src", "imgs/modify.gif");
imgElem.setAttribute("title", "Modify");
hyperlink.appendChild(imgElem);
tdExtension.appendChild(hyperlink);
hyperlink = dom.createElement("a");
url = actionUrl + ContentConstants.KEY_TYPE + "=" + ContentConstants.DELETE_ACTION + "&" + ContentConstants.KEY_EXTENSION_ID + "=" + extension.getIdExtension();
hyperlink.setAttribute("href", url);
imgElem = dom.createElement("img");
imgElem.setAttribute("src", "imgs/delete.gif");
imgElem.setAttribute("title", "Delete");
hyperlink.appendChild(imgElem);
tdExtension.appendChild(hyperlink);
trExtension.appendChild(tdExtension);
componentMap.put(extension.getIdExtension(), extension);
parent.appendChild(trExtension);
}
}
}
use of org.talend.designer.components.exchange.model.ComponentExtension in project tdi-studio-se by Talend.
the class MyExtensionAction method run.
public void run(IIntroSite site, Properties params) {
if (params != null) {
Object actionType = params.get(ContentConstants.KEY_TYPE);
if (ContentConstants.UPLOAD_MY_EXTENSION.equals(actionType)) {
try {
String values = (String) params.get(ContentConstants.EXTENSIONVALUES);
if (values != null) {
List<VersionRevision> versionRevisions = ExchangeManager.getInstance().getVersionRevisions();
ComponentExtension extension = ExchangeFactory.eINSTANCE.createComponentExtension();
setValuesForExension(extension, values, versionRevisions);
ExchangeManager.getInstance().setSelectedExtension(extension);
InsertionExtensionAction uploadAction = new InsertionExtensionAction(extension);
uploadAction.run();
}
} catch (JSONException e) {
ExceptionHandler.process(e);
}
} else if (ContentConstants.UPDATE_MY_EXTENSION.equals(actionType) || ContentConstants.MODIFY_MY_EXTENSION.equals(actionType)) {
try {
String values = (String) params.get(ContentConstants.EXTENSIONVALUES);
if (values != null) {
List<VersionRevision> versionRevisions = ExchangeManager.getInstance().getVersionRevisions();
ComponentExtension selectedExtension = ExchangeManager.getInstance().getSelectedExtension();
setValuesForExension(selectedExtension, values, versionRevisions);
if (ContentConstants.UPDATE_MY_EXTENSION.equals(actionType)) {
UploadRevisionAction uploadAction = new UploadRevisionAction(selectedExtension);
uploadAction.run();
} else {
ModifyExtensionAction modifyAction = new ModifyExtensionAction();
modifyAction.run();
}
}
} catch (JSONException e) {
ExceptionHandler.process(e);
}
} else if (ContentConstants.UPLOAD_NEW_VERSION_ACTION.equals(actionType) || ContentConstants.MODIFY_ACTION.equals(actionType)) {
Object object = params.get(ContentConstants.KEY_EXTENSION_ID);
String key = null;
if (object instanceof String) {
key = (String) object;
}
ComponentExtension componentExtension = MyExchangeContentProvider.componentMap.get(key);
if (componentExtension != null) {
ExchangeManager.getInstance().setSelectedExtension(componentExtension);
if (ContentConstants.UPLOAD_NEW_VERSION_ACTION.equals(actionType)) {
ExchangeManager.getInstance().generateXHTMLPage(ContentConstants.UL_UPLOAD_EXTENSION_VERSION, new String[] { ContentConstants.LAST_AVAILABLE_VERSION });
} else {
ExchangeManager.getInstance().generateXHTMLPage(ContentConstants.UL_MODIFY_MY_EXTENSION_PAGE, new String[] { ContentConstants.EXTENSION_LABEL });
}
}
} else if (ContentConstants.DELETE_ACTION.equals(actionType)) {
Object object = params.get(ContentConstants.KEY_EXTENSION_ID);
String key = null;
if (object instanceof String) {
key = (String) object;
}
ComponentExtension componentExtension = MyExchangeContentProvider.componentMap.get(key);
ExchangeManager.getInstance().setSelectedExtension(componentExtension);
if (componentExtension != null) {
final DeleteExtensionAction delAction = new DeleteExtensionAction(componentExtension);
if (delAction != null) {
delAction.run();
}
}
}
}
}
use of org.talend.designer.components.exchange.model.ComponentExtension in project tdi-studio-se by Talend.
the class DownloadComponenentsAction method run.
@Override
public void run() {
try {
final ComponentExtension selectedExtension = ExchangeManager.getInstance().getSelectedExtension();
Job job = new DownloadJob(selectedExtension);
fExtensionDownloaded = 0;
fDownloadedComponents = new ArrayList<ComponentExtension>();
job.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(final IJobChangeEvent event) {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
updateUI(event);
}
});
}
});
ExchangeUtils.scheduleUserJob(job);
} catch (Throwable e) {
ExceptionHandler.process(e);
}
}
use of org.talend.designer.components.exchange.model.ComponentExtension in project tdi-studio-se by Talend.
the class DownloadExtensionProvider method createContent.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.intro.config.IIntroXHTMLContentProvider#createContent(java.lang.String, org.w3c.dom.Element)
*/
public void createContent(String id, Element parent) {
Document dom = parent.getOwnerDocument();
if (ContentConstants.DOWNLOADEXTENSION_DATA.equals(id)) {
Element tr = dom.createElement("tr");
Element td = dom.createElement("td");
String style = "border-top:1px solid #9BB9F5;border-left:1px solid #9BB9F5;background:#EBEBDB";
if (fInstalledExtensions == null || fInstalledExtensions.isEmpty()) {
style = style + ";border-bottom:1px solid #9BB9F5";
}
td.setAttribute("style", style);
Element span = dom.createElement("span");
span.setAttribute("class", "style_2 style_3");
span.appendChild(dom.createTextNode("Extension Name"));
td.appendChild(span);
tr.appendChild(td);
td = dom.createElement("td");
style = "border-top:1px solid #9BB9F5;border-left:1px solid #cccccc;background:#EBEBDB";
if (fInstalledExtensions == null || fInstalledExtensions.isEmpty()) {
style = style + ";border-bottom:1px solid #9BB9F5";
}
td.setAttribute("style", style);
span = dom.createElement("span");
span.setAttribute("class", "style_2 style_3");
span.appendChild(dom.createTextNode("Downloaded Version"));
td.appendChild(span);
tr.appendChild(td);
td = dom.createElement("td");
style = "border-top:1px solid #9BB9F5;border-left:1px solid #cccccc;background:#EBEBDB";
if (fInstalledExtensions == null || fInstalledExtensions.isEmpty()) {
style = style + ";border-bottom:1px solid #9BB9F5";
}
td.setAttribute("style", style);
span = dom.createElement("span");
span.setAttribute("class", "style_2 style_3");
span.appendChild(dom.createTextNode("Download Date"));
td.appendChild(span);
tr.appendChild(td);
td = dom.createElement("td");
style = "border-top:1px solid #9BB9F5;border-left:1px solid #cccccc;border-right:1px solid #9BB9F5;background:#EBEBDB";
if (fInstalledExtensions == null || fInstalledExtensions.isEmpty()) {
style = style + ";border-bottom:1px solid #9BB9F5";
}
td.setAttribute("style", style);
span = dom.createElement("span");
span.setAttribute("class", "style_2 style_3");
span.appendChild(dom.createTextNode("Install/Update"));
td.appendChild(span);
tr.appendChild(td);
parent.appendChild(tr);
componentMap.clear();
if (fInstalledExtensions != null) {
Iterator ite = fInstalledExtensions.iterator();
int size = fInstalledExtensions.size();
count = 0;
while (ite.hasNext()) {
count++;
ComponentExtension object = (ComponentExtension) ite.next();
// hide null entries directly
if (object.getLabel().equals("null")) {
continue;
}
// set 0.1 as a default version
if (object.getDownloadedVersion().equals("") || object.getDownloadedVersion().equals("null")) {
object.setDownloadedVersion("0.1");
}
Element trExtension = dom.createElement("tr");
Element tdExtension = dom.createElement("td");
style = "border-top:1px solid #cccccc;border-left:1px solid #9BB9F5";
if (count == size) {
style = "border-top:1px solid #cccccc;border-left:1px solid #9BB9F5;border-bottom:1px solid #9BB9F5";
}
if (count % 2 == 0) {
style = style + ";background:#F7F7F7";
}
tdExtension.setAttribute("style", style);
tdExtension.appendChild(dom.createTextNode(object.getLabel()));
trExtension.appendChild(tdExtension);
tdExtension = dom.createElement("td");
style = "border-top:1px solid #cccccc;border-left:1px solid #cccccc";
if (count == size) {
style = "border-top:1px solid #cccccc;border-left:1px solid #cccccc;border-bottom:1px solid #9BB9F5";
}
if (count % 2 == 0) {
style = style + ";background:#F7F7F7";
}
tdExtension.setAttribute("style", style);
// set 0.1 as a default version
tdExtension.appendChild(dom.createTextNode(object.getDownloadedVersion()));
trExtension.appendChild(tdExtension);
tdExtension = dom.createElement("td");
style = "border-top:1px solid #cccccc;border-left:1px solid #cccccc";
if (count == size) {
style = "border-top:1px solid #cccccc;border-left:1px solid #cccccc;border-bottom:1px solid #9BB9F5";
}
if (count % 2 == 0) {
style = style + ";background:#F7F7F7";
}
tdExtension.setAttribute("style", style);
tdExtension.appendChild(dom.createTextNode(formatter.format(object.getDateDownload())));
trExtension.appendChild(tdExtension);
if (object != null && fDownloadedExtensions != null && fDownloadedExtensions.containsKey(object.getIdExtension())) {
if (object.getVersionExtension().equals(object.getDownloadedVersion())) {
tdExtension = dom.createElement("td");
style = "border-top:1px solid #cccccc;border-left:1px solid #cccccc;border-right:1px solid #9BB9F5";
if (count == size) {
style = "border-top:1px solid #cccccc;border-left:1px solid #cccccc;border-right:1px solid #9BB9F5;border-bottom:1px solid #9BB9F5";
}
if (count % 2 == 0) {
style = style + ";background:#F7F7F7";
}
tdExtension.setAttribute("style", style);
Text view = dom.createTextNode(Messages.getString("DownloadedExtensionsComposite.installedOperateStatus"));
tdExtension.appendChild(view);
trExtension.appendChild(tdExtension);
} else {
tdExtension = dom.createElement("td");
style = "border-top:1px solid #cccccc;border-left:1px solid #cccccc;border-right:1px solid #9BB9F5";
if (count == size) {
style = "border-top:1px solid #cccccc;border-left:1px solid #cccccc;border-right:1px solid #9BB9F5;border-bottom:1px solid #9BB9F5";
}
if (count % 2 == 0) {
style = style + ";background:#F7F7F7";
}
tdExtension.setAttribute("style", style);
Element hyperlink = dom.createElement("a");
String url = "http://org.eclipse.ui.intro/runAction?pluginId=org.talend.designer.components.exchange&" + "class=org.talend.designer.components.exchange.ui.actions.UpdateAction&" + "id=org.talend.designer.components.exchange.ui.actions.UpdateAction&" + AvailableCompositeProvider.NUMBER + "=" + count;
;
hyperlink.setAttribute("href", url);
Text view = dom.createTextNode(Messages.getString("DownloadedExtensionsComposite.updateOperateStatus"));
hyperlink.appendChild(view);
tdExtension.appendChild(hyperlink);
trExtension.appendChild(tdExtension);
}
} else {
tdExtension = dom.createElement("td");
style = "border-top:1px solid #cccccc;border-left:1px solid #cccccc;border-right:1px solid #9BB9F5";
if (count == size) {
style = "border-top:1px solid #cccccc;border-left:1px solid #cccccc;border-right:1px solid #9BB9F5;border-bottom:1px solid #9BB9F5";
}
if (count % 2 == 0) {
style = style + ";background:#F7F7F7";
}
tdExtension.setAttribute("style", style);
Element hyperlink = dom.createElement("a");
String url = "http://org.eclipse.ui.intro/runAction?pluginId=org.talend.designer.components.exchange&" + "class=org.talend.designer.components.exchange.ui.actions.InstallAction&" + "id=org.talend.designer.components.exchange.ui.actions.InstallAction&" + AvailableCompositeProvider.NUMBER + "=" + count;
hyperlink.setAttribute("href", url);
Text view = dom.createTextNode(Messages.getString("DownloadedExtensionsComposite.installOperateStatus"));
hyperlink.appendChild(view);
tdExtension.appendChild(hyperlink);
trExtension.appendChild(tdExtension);
}
componentMap.put("" + count, object);
parent.appendChild(trExtension);
}
}
}
}
use of org.talend.designer.components.exchange.model.ComponentExtension in project tdi-studio-se by Talend.
the class ComponentSearcher method getAvailableExtensionViewDetail.
public static ComponentExtension getAvailableExtensionViewDetail(String idExtension, String typeExtension) {
ComponentExtension extension = null;
try {
JSONObject extensionJSONObject = ExchangeWebService.searchExtensionViewDetail(idExtension, typeExtension);
Map<String, ComponentExtension> extensionsMap = new HashMap<String, ComponentExtension>();
extension = extensionsMap.get(extensionJSONObject.getString("label"));
if (extension == null) {
extension = ExchangeFactory.eINSTANCE.createComponentExtension();
extension.setIdExtension(extensionJSONObject.getString("idExtension"));
extension.setLabel(extensionJSONObject.getString("label"));
extension.setLastVersionAvailable(extensionJSONObject.getString("lastVersionAvailable"));
extension.setPublicationDate(formatter.parse(extensionJSONObject.getString("publicationDate")));
extension.setDescription(extensionJSONObject.getString("description"));
extension.setRate(extensionJSONObject.getString("rate"));
extension.setAuthor(extensionJSONObject.getString("author"));
//
List<AvailableExtensionViewDetail> reviews = new ArrayList<AvailableExtensionViewDetail>();
JSONArray o = extensionJSONObject.getJSONArray("Reviews");
int size = o.length();
for (int i = 0; i < size; i++) {
JSONObject review = o.getJSONObject(i);
AvailableExtensionViewDetail extensionViewDetail = ExchangeFactory.eINSTANCE.createAvailableExtensionViewDetail();
extensionViewDetail.setAuthor(review.getString("author"));
extensionViewDetail.setTitle(review.getString("title"));
extensionViewDetail.setComment(review.getString("comment"));
extensionViewDetail.setReviewrate(review.getString("rate"));
reviews.add(extensionViewDetail);
}
extensionsMap.put(extension.getIdExtension(), extension);
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
return extension;
}
Aggregations