Search in sources :

Example 1 with IDataModel

use of org.eclipse.wst.common.frameworks.datamodel.IDataModel in project azure-tools-for-java by Microsoft.

the class AzureDockerUIResources method createArtifact.

public static void createArtifact(Shell shell, IProject project) {
    if (project == null) {
        return;
    }
    String projectName = project.getName();
    String destinationPath = project.getLocation() + "/" + projectName + ".war";
    ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
    try {
        dialog.run(true, true, new IRunnableWithProgress() {

            public void run(IProgressMonitor progressMonitor) {
                progressMonitor.beginTask("Creating WAR artifact", 100);
                try {
                    progressMonitor.subTask(String.format("Building selected project: %s ...", project.getName()));
                    progressMonitor.worked(35);
                    project.build(IncrementalProjectBuilder.FULL_BUILD, null);
                    progressMonitor.subTask("Exporting to WAR ...");
                    progressMonitor.worked(75);
                    IDataModel dataModel = DataModelFactory.createDataModel(new WebComponentExportDataModelProvider());
                    dataModel.setProperty(IJ2EEComponentExportDataModelProperties.PROJECT_NAME, projectName);
                    dataModel.setProperty(IJ2EEComponentExportDataModelProperties.ARCHIVE_DESTINATION, destinationPath);
                    if (dataModel.getDefaultOperation() != null)
                        try {
                            dataModel.getDefaultOperation().execute(null, null);
                        } catch (Exception ignored) {
                        }
                    //						progressMonitor.subTask("");
                    //						progressMonitor.worked(1);
                    //						if (progressMonitor.isCanceled()) {
                    //							if (displayWarningOnCreateKeyVaultCancelAction() == 0) {
                    //								progressMonitor.done();
                    //								return Status.CANCEL_STATUS;
                    //							}
                    //						}
                    progressMonitor.done();
                } catch (Exception e) {
                    String msg = "An error occurred while attempting to create WAR artifact" + "\n" + e.getMessage();
                    log.log(Level.SEVERE, "createArtifact: " + msg, e);
                    e.printStackTrace();
                }
                progressMonitor.done();
            }
        });
    } catch (Exception e) {
        CANCELED = true;
        log.log(Level.SEVERE, "updateAzureResourcesWithProgressDialog: " + e.getMessage(), e);
        e.printStackTrace();
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) WebComponentExportDataModelProvider(org.eclipse.jst.j2ee.internal.web.archive.operations.WebComponentExportDataModelProvider) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) IDataModel(org.eclipse.wst.common.frameworks.datamodel.IDataModel) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 2 with IDataModel

use of org.eclipse.wst.common.frameworks.datamodel.IDataModel in project azure-tools-for-java by Microsoft.

the class WebAppDeployDialog method export.

public void export(String projectName, String destinationPath) throws Exception {
    System.out.println("Building project '" + projectName + "'...");
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
    project.build(IncrementalProjectBuilder.FULL_BUILD, null);
    System.out.println("Exporting to WAR...");
    IDataModel dataModel = DataModelFactory.createDataModel(new WebComponentExportDataModelProvider());
    dataModel.setProperty(IJ2EEComponentExportDataModelProperties.PROJECT_NAME, projectName);
    dataModel.setProperty(IJ2EEComponentExportDataModelProperties.ARCHIVE_DESTINATION, destinationPath);
    dataModel.getDefaultOperation().execute(null, null);
    System.out.println("Done.");
}
Also used : WebComponentExportDataModelProvider(org.eclipse.jst.j2ee.internal.web.archive.operations.WebComponentExportDataModelProvider) IDataModel(org.eclipse.wst.common.frameworks.datamodel.IDataModel) IProject(org.eclipse.core.resources.IProject)

Example 3 with IDataModel

use of org.eclipse.wst.common.frameworks.datamodel.IDataModel in project azure-tools-for-java by Microsoft.

the class WAExportWarEar method exportEarComponent.

/**
	 * This method export dependent enterprise application project as ear
	 * with their dependent libraries if any.
	 * @param projName
	 * @param destPath
	 * @throws ExecutionException
	 */
public static void exportEarComponent(String projName, String destPath) throws ExecutionException {
    IDataModel earModel = DataModelFactory.createDataModel(new EARComponentExportDataModelProvider());
    earModel.setProperty(IEARComponentExportDataModelProperties.PROJECT_NAME, projName);
    earModel.setProperty(IEARComponentExportDataModelProperties.ARCHIVE_DESTINATION, destPath);
    earModel.setProperty(IEARComponentExportDataModelProperties.OVERWRITE_EXISTING, true);
    try {
        earModel.getDefaultOperation().execute(null, null);
    } catch (org.eclipse.core.commands.ExecutionException e) {
        errorMessage = String.format("%s%s%s%s%s", Messages.crtErrMsg, " ", "EAR", " of project: ", projName);
        Activator.getDefault().log(errorMessage, e);
    }
}
Also used : EARComponentExportDataModelProvider(org.eclipse.jst.j2ee.application.internal.operations.EARComponentExportDataModelProvider) IDataModel(org.eclipse.wst.common.frameworks.datamodel.IDataModel)

Example 4 with IDataModel

use of org.eclipse.wst.common.frameworks.datamodel.IDataModel in project azure-tools-for-java by Microsoft.

the class WAExportWarEar method exportWarComponent.

/**
	 * This method export dependent dynamic web project as war
	 * with their dependent libraries if any.
	 * @param projName
	 * @param destPath
	 * @throws ExecutionException
	 */
public static void exportWarComponent(String projName, String destPath) throws ExecutionException {
    IDataModel warModel = DataModelFactory.createDataModel(new WebComponentExportDataModelProvider());
    warModel.setProperty(IWebComponentExportDataModelProperties.PROJECT_NAME, projName);
    warModel.setProperty(IWebComponentExportDataModelProperties.ARCHIVE_DESTINATION, destPath);
    warModel.setProperty(IWebComponentExportDataModelProperties.OVERWRITE_EXISTING, true);
    try {
        warModel.getDefaultOperation().execute(null, null);
    } catch (org.eclipse.core.commands.ExecutionException e) {
        errorMessage = String.format("%s%s%s%s%s", Messages.crtErrMsg, " ", "WAR", " of project: ", projName);
        Activator.getDefault().log(errorMessage, e);
    }
}
Also used : WebComponentExportDataModelProvider(org.eclipse.jst.j2ee.internal.web.archive.operations.WebComponentExportDataModelProvider) IDataModel(org.eclipse.wst.common.frameworks.datamodel.IDataModel)

Aggregations

IDataModel (org.eclipse.wst.common.frameworks.datamodel.IDataModel)4 WebComponentExportDataModelProvider (org.eclipse.jst.j2ee.internal.web.archive.operations.WebComponentExportDataModelProvider)3 IProject (org.eclipse.core.resources.IProject)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 EARComponentExportDataModelProvider (org.eclipse.jst.j2ee.application.internal.operations.EARComponentExportDataModelProvider)1