Search in sources :

Example 26 with ProgressMonitorDialog

use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project cubrid-manager by CUBRID.

the class DataCompareDetailEditorPart method createContent.

private void createContent(Composite parent) {
    compareTableViewer = new TableViewer(parent, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    compareTableViewer.setUseHashlookup(true);
    CommonUITool.createGridLayout(compareTableViewer.getTable(), 1, 0, 10, 0, 10, 0, 0, 0, 0);
    compareTableViewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    compareTableViewer.getTable().setLinesVisible(true);
    compareTableViewer.getTable().setHeaderVisible(true);
    try {
        new ProgressMonitorDialog(this.getSite().getShell()).run(true, false, new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) {
                monitor.beginTask(Messages.msgLoadingData, 1);
                loadData(1);
                monitor.done();
                Display.getDefault().syncExec(new Runnable() {

                    public void run() {
                        initTableViewer();
                        compareTableViewer.setInput(dataList);
                        CommonUITool.packTable(compareTableViewer.getTable(), 20, 200);
                    }
                });
            }
        });
    } catch (Exception e) {
        LOGGER.error("", e);
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) GridData(org.eclipse.swt.layout.GridData) TableViewer(org.eclipse.jface.viewers.TableViewer) SQLException(java.sql.SQLException) PartInitException(org.eclipse.ui.PartInitException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 27 with ProgressMonitorDialog

use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project cubrid-manager by CUBRID.

the class DataCompareDetailEditorPart method showPage.

private void showPage(int direction) {
    int newPage = page;
    if (direction == -1) {
        newPage -= 1;
    } else if (direction == 1) {
        newPage += 1;
    } else {
        newPage = 1;
    }
    if (newPage < 1) {
        page = 1;
        CommonUITool.openWarningBox(Messages.msgStartPageAlert);
        return;
    }
    final int newPageParam = newPage;
    try {
        new ProgressMonitorDialog(this.getSite().getShell()).run(true, false, new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) {
                monitor.beginTask(Messages.msgLoadingData, 1);
                if (loadData(newPageParam)) {
                    Display.getDefault().syncExec(new Runnable() {

                        public void run() {
                            compareTableViewer.setInput(dataList);
                            CommonUITool.packTable(compareTableViewer.getTable(), 20, 200);
                        }
                    });
                    page = newPageParam;
                } else {
                    Display.getDefault().syncExec(new Runnable() {

                        public void run() {
                            CommonUITool.openWarningBox(Messages.msgLastPageAlert);
                        }
                    });
                }
                monitor.done();
            }
        });
    } catch (Exception e) {
        LOGGER.error("", e);
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) SQLException(java.sql.SQLException) PartInitException(org.eclipse.ui.PartInitException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 28 with ProgressMonitorDialog

use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project cubrid-manager by CUBRID.

the class DataCompareEditorPart method exportData.

private boolean exportData(final String basePath) {
    if (compareList == null || compareList.size() == 0) {
        CommonUITool.openErrorBox(Messages.msgNotExistsToExportData);
        return false;
    }
    printToConsole("\n", false);
    printToConsole(Messages.msgBeginToCompareData + "\n", true);
    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    IRunnableWithProgress progress = new IRunnableWithProgress() {

        public void run(final IProgressMonitor monitor) {
            int total = compareList.size();
            monitor.beginTask(Messages.msgLoadingData, total);
            Display.getDefault().syncExec(new Runnable() {

                public void run() {
                    for (DataCompare comp : compareList) {
                        int counts = exportDataToFile(basePath, comp.getTableName());
                        if (counts == -1) {
                            if (comp.getRecordsTarget() == -1) {
                                String msg = Messages.bind(Messages.msgDataCompareNoTable, comp.getTableName()) + "\n";
                                printToConsoleOnWorkThread(msg, true);
                            } else {
                                String msg = Messages.bind(Messages.msgDataCompareNoData, comp.getTableName()) + "\n";
                                printToConsoleOnWorkThread(msg, true);
                            }
                        } else {
                            String msg = Messages.bind(Messages.msgDataCompareResultStatus, comp.getTableName(), counts) + "\n";
                            printToConsoleOnWorkThread(msg, true);
                        }
                        monitor.worked(1);
                    }
                    monitor.done();
                }
            });
        }
    };
    try {
        new ProgressMonitorDialog(shell).run(true, false, progress);
    } catch (InvocationTargetException e) {
        LOGGER.error(e.getMessage(), e);
    } catch (InterruptedException e) {
        LOGGER.error(e.getMessage(), e);
    }
    String msg = Messages.bind(Messages.msgEndToCompareData, basePath) + "\n";
    printToConsole(msg, true);
    return true;
}
Also used : Shell(org.eclipse.swt.widgets.Shell) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) DataCompare(com.cubrid.common.ui.compare.data.model.DataCompare) Constraint(com.cubrid.common.core.common.model.Constraint) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 29 with ProgressMonitorDialog

use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project cubrid-manager by CUBRID.

the class ExportErrorDataProgress method export.

/**
	 * export to excel
	 * @return
	 */
public boolean export() {
    Display display = Display.getDefault();
    display.syncExec(new Runnable() {

        public void run() {
            try {
                new ProgressMonitorDialog(null).run(true, false, ExportErrorDataProgress.this);
            } catch (Exception e) {
                LOGGER.error("", e);
            }
        }
    });
    return success;
}
Also used : ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) InvocationTargetException(java.lang.reflect.InvocationTargetException) WriteException(jxl.write.WriteException) Display(org.eclipse.swt.widgets.Display)

Example 30 with ProgressMonitorDialog

use of org.eclipse.jface.dialogs.ProgressMonitorDialog 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)

Aggregations

ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)315 InvocationTargetException (java.lang.reflect.InvocationTargetException)250 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)241 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)207 CoreException (org.eclipse.core.runtime.CoreException)79 IOException (java.io.IOException)68 ArrayList (java.util.ArrayList)66 Shell (org.eclipse.swt.widgets.Shell)55 PartInitException (org.eclipse.ui.PartInitException)49 List (java.util.List)44 HashMap (java.util.HashMap)41 IResource (org.eclipse.core.resources.IResource)38 WorkspaceModifyOperation (org.eclipse.ui.actions.WorkspaceModifyOperation)37 LinkedHashMap (java.util.LinkedHashMap)34 Display (org.eclipse.swt.widgets.Display)32 EventObject (java.util.EventObject)30 BasicCommandStack (org.eclipse.emf.common.command.BasicCommandStack)30 Resource (org.eclipse.emf.ecore.resource.Resource)30 IFile (org.eclipse.core.resources.IFile)25 File (java.io.File)23