Search in sources :

Example 1 with Repository

use of org.eclipse.flux.core.Repository in project flux by eclipse.

the class SyncConnectHandler method setEnabled.

@Override
public void setEnabled(Object evaluationContext) {
    Repository repository = org.eclipse.flux.core.Activator.getDefault().getRepository();
    if (repository != null && evaluationContext instanceof IEvaluationContext) {
        IEvaluationContext evalContext = (IEvaluationContext) evaluationContext;
        Object selection = evalContext.getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME);
        if (selection instanceof ISelection) {
            IProject[] selectedProjects = getSelectedProjects((ISelection) selection);
            for (IProject project : selectedProjects) {
                if (!repository.isConnected(project)) {
                    setBaseEnabled(true);
                    return;
                }
            }
        }
    }
    setBaseEnabled(false);
}
Also used : Repository(org.eclipse.flux.core.Repository) IEvaluationContext(org.eclipse.core.expressions.IEvaluationContext) ISelection(org.eclipse.jface.viewers.ISelection) IProject(org.eclipse.core.resources.IProject)

Example 2 with Repository

use of org.eclipse.flux.core.Repository in project flux by eclipse.

the class SyncDisconnectHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    ISelection selection = HandlerUtil.getCurrentSelection(event);
    IProject[] selectedProjects = getSelectedProjects(selection);
    //		selectedProjects[0].getLocalTimeStamp();
    //		selectedProjects[0].getFile(".project").getLocalTimeStamp();
    Repository repository = org.eclipse.flux.core.Activator.getDefault().getRepository();
    if (repository != null) {
        for (IProject project : selectedProjects) {
            if (repository.isConnected(project)) {
                repository.removeProject(project);
            }
        }
    }
    return null;
}
Also used : Repository(org.eclipse.flux.core.Repository) ISelection(org.eclipse.jface.viewers.ISelection) IProject(org.eclipse.core.resources.IProject)

Example 3 with Repository

use of org.eclipse.flux.core.Repository in project flux by eclipse.

the class SyncDisconnectHandler method setEnabled.

@Override
public void setEnabled(Object evaluationContext) {
    Repository repository = org.eclipse.flux.core.Activator.getDefault().getRepository();
    if (repository != null && evaluationContext instanceof IEvaluationContext) {
        IEvaluationContext evalContext = (IEvaluationContext) evaluationContext;
        Object selection = evalContext.getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME);
        if (selection instanceof ISelection) {
            IProject[] selectedProjects = getSelectedProjects((ISelection) selection);
            for (IProject project : selectedProjects) {
                if (repository.isConnected(project)) {
                    setBaseEnabled(true);
                    return;
                }
            }
        }
    }
    setBaseEnabled(false);
}
Also used : Repository(org.eclipse.flux.core.Repository) IEvaluationContext(org.eclipse.core.expressions.IEvaluationContext) ISelection(org.eclipse.jface.viewers.ISelection) IProject(org.eclipse.core.resources.IProject)

Example 4 with Repository

use of org.eclipse.flux.core.Repository 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)

Example 5 with Repository

use of org.eclipse.flux.core.Repository in project flux by eclipse.

the class SyncConnectHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    ISelection selection = HandlerUtil.getCurrentSelection(event);
    IProject[] selectedProjects = getSelectedProjects(selection);
    Repository repository = org.eclipse.flux.core.Activator.getDefault().getRepository();
    if (repository != null) {
        for (IProject project : selectedProjects) {
            if (!repository.isConnected(project)) {
                repository.addProject(project);
            }
        }
    }
    return null;
}
Also used : Repository(org.eclipse.flux.core.Repository) ISelection(org.eclipse.jface.viewers.ISelection) IProject(org.eclipse.core.resources.IProject)

Aggregations

Repository (org.eclipse.flux.core.Repository)6 IProject (org.eclipse.core.resources.IProject)5 ISelection (org.eclipse.jface.viewers.ISelection)4 IEvaluationContext (org.eclipse.core.expressions.IEvaluationContext)2 MessageConnector (org.eclipse.flux.client.MessageConnector)2 DownloadProject (org.eclipse.flux.core.DownloadProject)1 CompletionCallback (org.eclipse.flux.core.DownloadProject.CompletionCallback)1 LabelProvider (org.eclipse.jface.viewers.LabelProvider)1 Shell (org.eclipse.swt.widgets.Shell)1