Search in sources :

Example 6 with WebserviceStatus

use of org.talend.designer.components.exchange.util.WebserviceStatus in project tdi-studio-se by Talend.

the class ModifyExtensionAction method updateUI.

/**
     * Update ui after job finished.
     * 
     * @param action
     * @param event
     */
private void updateUI(final ModifyExtensionJob modifyJob, final IJobChangeEvent event) {
    if (event.getResult().isOK()) {
        WebserviceStatus wbs = modifyJob.getWs();
        if (wbs.isResult()) {
            ExchangeManager.getInstance().setSelectedExtension(null);
            RefreshComponenentsAction action = new RefreshComponenentsAction();
            action.run(new String[] { RefreshComponenentsAction.REFRESH_MY_EXTENSIONS, RefreshComponenentsAction.REFRESH_AVAILABLES }, ContentConstants.UL_LIST_MY_EXTENSIONS);
        } else {
            String mainMsg = Messages.getString("ModifyExtensionJob.ModifyFailure") + " " + Messages.getString("ModifyExtensionJob.ModifyFailureTip");
            new ErrorDialogWidthDetailArea(null, ExchangePlugin.PLUGIN_ID, mainMsg, wbs.getMessageException());
        }
    }
}
Also used : ErrorDialogWidthDetailArea(org.talend.commons.ui.swt.dialogs.ErrorDialogWidthDetailArea) WebserviceStatus(org.talend.designer.components.exchange.util.WebserviceStatus)

Example 7 with WebserviceStatus

use of org.talend.designer.components.exchange.util.WebserviceStatus in project tdi-studio-se by Talend.

the class DeleteExtensionAction method updateUI.

/**
     * Update ui after job finished.
     * 
     * @param action
     * @param event
     */
private void updateUI(final DeleteExtensionJob delJob, final IJobChangeEvent event) {
    if (event.getResult().isOK()) {
        WebserviceStatus wbs = delJob.getWs();
        if (wbs.isResult()) {
            ExchangeManager.getInstance().setSelectedExtension(null);
            RefreshComponenentsAction action = new RefreshComponenentsAction();
            action.run(new String[] { RefreshComponenentsAction.REFRESH_ALL }, ContentConstants.UL_LIST_MY_EXTENSIONS);
        } else {
            String mainMsg = Messages.getString("DeleteExtensionJob.DeleteFailure") + " " + Messages.getString("DeleteExtensionJob.DeleteFailureTip");
            new ErrorDialogWidthDetailArea(null, ExchangePlugin.PLUGIN_ID, mainMsg, wbs.getMessageException());
        }
    }
    ExchangeManager.getInstance().setSelectedExtension(null);
}
Also used : ErrorDialogWidthDetailArea(org.talend.commons.ui.swt.dialogs.ErrorDialogWidthDetailArea) WebserviceStatus(org.talend.designer.components.exchange.util.WebserviceStatus)

Example 8 with WebserviceStatus

use of org.talend.designer.components.exchange.util.WebserviceStatus in project tdi-studio-se by Talend.

the class ExchangeUrlAction method run.

public void run(IIntroSite site, Properties params) {
    if (params != null) {
        if (EDIT_REVIEWS.equals(params.get(KEY_TYPE))) {
            Display current = Display.getCurrent();
            if (current == null) {
                current = Display.getDefault();
            }
            Shell shell = null;
            if (current != null) {
                shell = current.getActiveShell();
            }
            final Shell fShell = shell;
            if (ExchangeManager.getInstance().getSelectedExtension() != null) {
                ReviewComponentDialog reviewDialog = new ReviewComponentDialog(shell);
                if (reviewDialog.open() == IDialogConstants.OK_ID) {
                    final String title = reviewDialog.getTitle();
                    final String rate = reviewDialog.getRating() + "";
                    final String review = reviewDialog.getReview();
                    Display.getDefault().asyncExec(new Runnable() {

                        public void run() {
                            if (ExchangeUtils.checkUserAndPassword()) {
                                WebserviceStatus ws = ExchangeWebService.insertReviewService(ExchangeManager.getInstance().getSelectedExtension().getIdExtension(), ExchangeUtils.TYPEEXTENSION, ExchangeUtils.getUserName(), ExchangeUtils.getPasswordHash(), title, review, rate);
                                if (ws.isResult()) {
                                    RefreshComponenentsAction action = new RefreshComponenentsAction();
                                    action.run(new String[] { RefreshComponenentsAction.REFRESH_AVAILABLES }, ContentConstants.UL_LIST_AVAILABLE_EXTENSIONS);
                                } else {
                                    String mainMsg = Messages.getString("AvailableExtensionsComposite.ViewDetail.InsertionReviewFailure") + " " + Messages.getString("AvailableExtensionsComposite.ViewDetail.InsertionReviewFailureTip");
                                    new ErrorDialogWidthDetailArea(fShell, ExchangePlugin.PLUGIN_ID, mainMsg, ws.getMessageException());
                                }
                            } else {
                                MessageDialog.openInformation(fShell, Messages.getString("AvailableExtensionsComposite.ViewDetail.WriteReview"), //$NON-NLS-1$
                                Messages.getString("Exchange.logon.error"));
                            }
                        }
                    });
                }
            }
        }
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) ReviewComponentDialog(org.talend.designer.components.exchange.ui.ReviewComponentDialog) RefreshComponenentsAction(org.talend.designer.components.exchange.ui.actions.RefreshComponenentsAction) ErrorDialogWidthDetailArea(org.talend.commons.ui.swt.dialogs.ErrorDialogWidthDetailArea) Display(org.eclipse.swt.widgets.Display) WebserviceStatus(org.talend.designer.components.exchange.util.WebserviceStatus)

Example 9 with WebserviceStatus

use of org.talend.designer.components.exchange.util.WebserviceStatus in project tdi-studio-se by Talend.

the class UploadRevisionJob method run.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
     */
@Override
protected IStatus run(IProgressMonitor monitor) {
    monitor.beginTask(Messages.getString("UploadRevisionJob.Message"), IProgressMonitor.UNKNOWN);
    // run in another thread, make it possible to stop the remote procedure call when user press cancel
    // button
    ExecutorService executor = Executors.newSingleThreadExecutor();
    Future<WebserviceStatus> task = executor.submit(new Callable<WebserviceStatus>() {

        public WebserviceStatus call() throws Exception {
            WebserviceStatus webserviceStatus;
            if (ExchangeUtils.checkUserAndPassword()) {
                webserviceStatus = ExchangeWebService.insertionRevisionService(fe.getIdExtension(), ExchangeUtils.TYPEEXTENSION, ExchangeUtils.getUserName(), ExchangeUtils.getPasswordHash(), fe.getLastVersionAvailable(), fe.getListVersionCompatibles(), fe.getFilename(), "application/multipart-formdata", fe.getDescription(), "true");
            } else {
                webserviceStatus = new WebserviceStatus();
                webserviceStatus.setMessageException(Messages.getString("Exchange.logon.error"));
            }
            return webserviceStatus;
        }
    });
    while (true) {
        try {
            if (monitor.isCanceled()) {
                // stop the web service call
                task.cancel(true);
                return Status.CANCEL_STATUS;
            } else if (task.isDone()) {
                // web service call complete
                ws = task.get();
                break;
            }
        } catch (Exception e) {
            ExceptionHandler.process(e);
            return Status.CANCEL_STATUS;
        } finally {
            executor.shutdown();
        }
    }
    monitor.done();
    return Status.OK_STATUS;
}
Also used : ExecutorService(java.util.concurrent.ExecutorService) WebserviceStatus(org.talend.designer.components.exchange.util.WebserviceStatus)

Aggregations

WebserviceStatus (org.talend.designer.components.exchange.util.WebserviceStatus)9 ErrorDialogWidthDetailArea (org.talend.commons.ui.swt.dialogs.ErrorDialogWidthDetailArea)5 ExecutorService (java.util.concurrent.ExecutorService)4 Display (org.eclipse.swt.widgets.Display)1 Shell (org.eclipse.swt.widgets.Shell)1 ReviewComponentDialog (org.talend.designer.components.exchange.ui.ReviewComponentDialog)1 RefreshComponenentsAction (org.talend.designer.components.exchange.ui.actions.RefreshComponenentsAction)1