Search in sources :

Example 1 with ModifyExtensionAction

use of org.talend.designer.components.exchange.ui.actions.ModifyExtensionAction 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();
                }
            }
        }
    }
}
Also used : UploadRevisionAction(org.talend.designer.components.exchange.ui.actions.UploadRevisionAction) ModifyExtensionAction(org.talend.designer.components.exchange.ui.actions.ModifyExtensionAction) InsertionExtensionAction(org.talend.designer.components.exchange.ui.actions.InsertionExtensionAction) JSONException(org.talend.utils.json.JSONException) JSONObject(org.talend.utils.json.JSONObject) ComponentExtension(org.talend.designer.components.exchange.model.ComponentExtension) List(java.util.List) VersionRevision(org.talend.designer.components.exchange.model.VersionRevision) DeleteExtensionAction(org.talend.designer.components.exchange.ui.actions.DeleteExtensionAction)

Aggregations

List (java.util.List)1 ComponentExtension (org.talend.designer.components.exchange.model.ComponentExtension)1 VersionRevision (org.talend.designer.components.exchange.model.VersionRevision)1 DeleteExtensionAction (org.talend.designer.components.exchange.ui.actions.DeleteExtensionAction)1 InsertionExtensionAction (org.talend.designer.components.exchange.ui.actions.InsertionExtensionAction)1 ModifyExtensionAction (org.talend.designer.components.exchange.ui.actions.ModifyExtensionAction)1 UploadRevisionAction (org.talend.designer.components.exchange.ui.actions.UploadRevisionAction)1 JSONException (org.talend.utils.json.JSONException)1 JSONObject (org.talend.utils.json.JSONObject)1