use of org.talend.designer.components.exchange.ui.actions.UploadRevisionAction 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();
}
}
}
}
}
Aggregations