Search in sources :

Example 1 with JobExportType

use of org.talend.repository.ui.wizards.exportjob.JavaJobScriptsExportWSWizardPage.JobExportType in project tdi-studio-se by Talend.

the class JobScriptsExportWizardPage method finish.

// protected String getDestinationValueSU() {
//        return this.suDestinationFilePath != null ? this.suDestinationFilePath : ""; //$NON-NLS-1$
//
// }
/**
     * The Finish button was pressed. Try to do the required work now and answer a boolean indicating success. If false
     * is returned then the wizard will not close.
     * 
     * @returns boolean
     */
@Override
public boolean finish() {
    // TODO
    if (treeViewer != null) {
        treeViewer.removeCheckStateListener(checkStateListener);
    }
    saveWidgetValues();
    if (manager == null) {
        manager = createJobScriptsManager();
    }
    if (!ensureTargetIsValid()) {
        return false;
    }
    if (ensureLog4jSettingIsValid()) {
        MessageDialog dialog = new MessageDialog(getShell(), "Question", null, Messages.getString("Log4jSettingPage.IlleagalBuild"), MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
        dialog.open();
        int result = dialog.getReturnCode();
        if (result != MessageDialog.OK) {
            return false;
        }
    }
    JobExportType jobExportType = getCurrentExportType1();
    if (JobExportType.POJO.equals(jobExportType)) {
        IRunnableWithProgress worker = new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                buildJobWithMaven(JobExportType.POJO, monitor);
            }
        };
        try {
            getContainer().run(false, true, worker);
        } catch (InvocationTargetException e) {
            MessageBoxExceptionHandler.process(e.getCause(), getShell());
            return false;
        } catch (InterruptedException e) {
            return false;
        }
    } else {
        List<ContextParameterType> contextEditableResultValuesList = null;
        if (manager != null) {
            contextEditableResultValuesList = manager.getContextEditableResultValuesList();
        }
        if (nodes.length == 1) {
            RepositoryNode node = nodes[0];
            if (node.getType() == ENodeType.SYSTEM_FOLDER) {
                manager.setTopFolderName(ProjectManager.getInstance().getCurrentProject().getLabel());
            } else {
                manager.setTopFolderName(getDefaultFileNameWithType());
            }
        } else {
            manager.setTopFolderName(getDefaultFileNameWithType());
        }
        // for feature:11976, recover back the old default manager value with ContextParameters
        if (contextEditableResultValuesList == null) {
            manager.setContextEditableResultValuesList(new ArrayList<ContextParameterType>());
        } else {
            manager.setContextEditableResultValuesList(contextEditableResultValuesList);
        }
        manager.setMultiNodes(isMultiNodes());
        // achen modify to fix bug 0006222
        IRunnableWithProgress worker = new JobExportAction(Arrays.asList(getCheckNodes()), getSelectedJobVersion(), manager, originalRootFolderName, getProcessType());
        try {
            getContainer().run(false, true, worker);
        } catch (InvocationTargetException e) {
            MessageBoxExceptionHandler.process(e.getCause(), getShell());
            return false;
        } catch (InterruptedException e) {
            return false;
        }
    }
    // see bug 7181
    if (zipOption != null && zipOption.equals("true")) {
        // unzip
        try {
            String zipFile;
            if (manager != null) {
                zipFile = manager.getDestinationPath();
            } else {
                zipFile = getDestinationValue();
                int separatorIndex = zipFile.lastIndexOf(File.separator);
                if (separatorIndex == -1) {
                    //$NON-NLS-1$
                    String userDir = System.getProperty("user.dir");
                    zipFile = userDir + File.separator + zipFile;
                }
            }
            // Added by Marvin Wang on Feb.1, 2012 for bug TDI-18824
            File file = new File(zipFile);
            if (file.exists()) {
                ZipToFile.unZipFile(zipFile, file.getParentFile().getAbsolutePath());
            }
        } catch (Exception e) {
            MessageBoxExceptionHandler.process(e, getShell());
            return false;
        }
    }
    if (treeViewer != null) {
        treeViewer.dispose();
    }
    // end
    return true;
}
Also used : JobExportAction(org.talend.repository.ui.wizards.exportjob.action.JobExportAction) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Point(org.eclipse.swt.graphics.Point) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) JobExportType(org.talend.repository.ui.wizards.exportjob.JavaJobScriptsExportWSWizardPage.JobExportType) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) ZipToFile(org.talend.repository.ui.utils.ZipToFile) File(java.io.File) ContextParameterType(org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 MessageDialog (org.eclipse.jface.dialogs.MessageDialog)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 Point (org.eclipse.swt.graphics.Point)1 ContextParameterType (org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType)1 IRepositoryNode (org.talend.repository.model.IRepositoryNode)1 RepositoryNode (org.talend.repository.model.RepositoryNode)1 ZipToFile (org.talend.repository.ui.utils.ZipToFile)1 JobExportType (org.talend.repository.ui.wizards.exportjob.JavaJobScriptsExportWSWizardPage.JobExportType)1 JobExportAction (org.talend.repository.ui.wizards.exportjob.action.JobExportAction)1