Search in sources :

Example 1 with CompletionCallback

use of org.eclipse.flux.core.DownloadProject.CompletionCallback in project flux by eclipse.

the class InitializeServiceEnvironment method initializeProject.

private void initializeProject(String projectName) {
    try {
        // already connected project
        if (repository.isConnected(projectName))
            return;
        // project doesn't exist in workspace
        DownloadProject downloadProject = new DownloadProject(messagingConnector, projectName, repository.getUsername());
        downloadProject.run(new CompletionCallback() {

            @Override
            public void downloadFailed() {
            }

            @Override
            public void downloadComplete(IProject downloadedProject) {
                try {
                    downloadedProject.build(IncrementalProjectBuilder.FULL_BUILD, null);
                } catch (CoreException e) {
                    e.printStackTrace();
                }
                repository.addProject(downloadedProject);
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) CompletionCallback(org.eclipse.flux.core.DownloadProject.CompletionCallback) DownloadProject(org.eclipse.flux.core.DownloadProject) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) JSONException(org.json.JSONException)

Example 2 with CompletionCallback

use of org.eclipse.flux.core.DownloadProject.CompletionCallback in project flux by eclipse.

the class SyncDownloadHandler method execute.

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    final Repository repository = org.eclipse.flux.core.Activator.getDefault().getRepository();
    final MessageConnector messagingConnector = org.eclipse.flux.core.Activator.getDefault().getMessageConnector();
    if (repository == null || messagingConnector == null) {
        return null;
    }
    final Shell shell = FluxUiPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell();
    SyncDownloadSelectionDialog selectionDialog = new SyncDownloadSelectionDialog(shell, new LabelProvider(), messagingConnector, repository.getUsername());
    int result = selectionDialog.open();
    if (result == Dialog.OK) {
        Object[] selectedProjects = selectionDialog.getResult();
        for (Object selectedProject : selectedProjects) {
            if (selectedProject instanceof String) {
                DownloadProject downloadProject = new DownloadProject(messagingConnector, (String) selectedProject, repository.getUsername());
                downloadProject.run(new CompletionCallback() {

                    @Override
                    public void downloadFailed() {
                    }

                    @Override
                    public void downloadComplete(IProject project) {
                        repository.addProject(project);
                    }
                });
            }
        }
    }
    return null;
}
Also used : MessageConnector(org.eclipse.flux.client.MessageConnector) IProject(org.eclipse.core.resources.IProject) Repository(org.eclipse.flux.core.Repository) Shell(org.eclipse.swt.widgets.Shell) CompletionCallback(org.eclipse.flux.core.DownloadProject.CompletionCallback) LabelProvider(org.eclipse.jface.viewers.LabelProvider) DownloadProject(org.eclipse.flux.core.DownloadProject)

Aggregations

IProject (org.eclipse.core.resources.IProject)2 DownloadProject (org.eclipse.flux.core.DownloadProject)2 CompletionCallback (org.eclipse.flux.core.DownloadProject.CompletionCallback)2 CoreException (org.eclipse.core.runtime.CoreException)1 MessageConnector (org.eclipse.flux.client.MessageConnector)1 Repository (org.eclipse.flux.core.Repository)1 LabelProvider (org.eclipse.jface.viewers.LabelProvider)1 Shell (org.eclipse.swt.widgets.Shell)1 JSONException (org.json.JSONException)1