Package floobits.actions

Source Code of floobits.actions.OpenProjectInWorkspace

package floobits.actions;

import com.intellij.openapi.actionSystem.AnActionEvent;
import floobits.FloobitsApplication;
import floobits.FloobitsPlugin;
import floobits.common.*;
import floobits.impl.ContextImpl;
import floobits.utilities.Flog;

import java.net.MalformedURLException;
import java.util.Map;

/**
* Created by kans on 2/18/14.
*/
public class OpenProjectInWorkspace extends CanFloobits {
    public void actionPerformed(AnActionEvent actionEvent) {
        ContextImpl context = FloobitsPlugin.getInstance(actionEvent.getProject()).context;
        FlooUrl flooUrl = DotFloo.read(context.project.getBasePath());
        if (flooUrl != null) {
            FloobitsApplication.self.joinWorkspace(context, flooUrl.toString());
            return;
        }

        String project_path = context.project.getBasePath();
        PersistentJson persistentJson = PersistentJson.getInstance();
        for (Map.Entry<String, Map<String, Workspace>> i : persistentJson.workspaces.entrySet()) {
            Map<String, Workspace> workspaces = i.getValue();
            for (Map.Entry<String, Workspace> j : workspaces.entrySet()) {
                Workspace w = j.getValue();
                if (Utils.isSamePath(w.path, project_path)) {
                    try {
                        flooUrl = new FlooUrl(w.url);
                    } catch (MalformedURLException e) {
                        Flog.warn(e);
                        continue;
                    }
                    FloobitsApplication.self.joinWorkspace(context, flooUrl.toString());
                    return;
                }
            }
        }
        context.errorMessage("This project doesn't seem to be associated with a Floobits workspace.");
    }
}
TOP

Related Classes of floobits.actions.OpenProjectInWorkspace

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.