diff --git a/META-INF/plugin.xml b/META-INF/plugin.xml index eb1553b..403a57a 100644 --- a/META-INF/plugin.xml +++ b/META-INF/plugin.xml @@ -1,4 +1,4 @@ - + com.floobits.unique.plugin.id Floobits 1.6.8 @@ -23,12 +23,6 @@ on how to target different products --> com.intellij.modules.lang - - - floobits.FloobitsApplication - - - @@ -141,8 +135,7 @@ - - + diff --git a/intellij-plugin.iml b/intellij-plugin.iml index 3752822..3a27ba5 100644 --- a/intellij-plugin.iml +++ b/intellij-plugin.iml @@ -1,14 +1,14 @@ - + - + @@ -27,5 +27,4 @@ - - + \ No newline at end of file diff --git a/src/floobits/FloobitsApplication.java b/src/floobits/FloobitsApplicationService.java similarity index 92% rename from src/floobits/FloobitsApplication.java rename to src/floobits/FloobitsApplicationService.java index 0db15f8..f3a6128 100644 --- a/src/floobits/FloobitsApplication.java +++ b/src/floobits/FloobitsApplicationService.java @@ -4,7 +4,8 @@ import com.intellij.ide.plugins.IdeaPluginDescriptor; import com.intellij.ide.plugins.PluginManager; import com.intellij.openapi.application.ApplicationInfo; -import com.intellij.openapi.components.ApplicationComponent; +import com.intellij.openapi.components.Service; +import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.extensions.PluginId; import com.intellij.openapi.fileChooser.impl.FileChooserUtil; import com.intellij.openapi.project.Project; @@ -20,31 +21,26 @@ import floobits.utilities.Flog; import floobits.utilities.IntelliBrowserOpener; import floobits.utilities.SelectFolder; -import org.jetbrains.annotations.NotNull; import java.awt.*; import java.io.File; import java.net.URI; -public class FloobitsApplication implements ApplicationComponent { - public static FloobitsApplication self; +@Service +public class FloobitsApplicationService { private Boolean createAccount = true; - public FloobitsApplication() { - self = this; + public static FloobitsApplicationService getInstance() { + return ServiceManager.getService(FloobitsApplicationService.class); } - public void initComponent() { + public void constructor() { BrowserOpener.replaceSingleton(new IntelliBrowserOpener()); ApplicationInfo instance = ApplicationInfo.getInstance(); IdeaPluginDescriptor plugin = PluginManager.getPlugin(PluginId.getId("com.floobits.unique.plugin.id")); createAccount = Bootstrap.bootstrap(instance.getVersionName(), instance.getMajorVersion(), instance.getMinorVersion(), plugin != null ? plugin.getVersion() : "???"); } - public void disposeComponent() { - // TODO: insert component disposal logic here - } - public synchronized void projectOpened(ContextImpl context) { if (!createAccount) { return; @@ -60,11 +56,6 @@ public synchronized void projectOpened(ContextImpl context) { createAccountDialog.show(); } - @NotNull - public String getComponentName() { - return "FloobitsApplication"; - } - public void joinWorkspace(final String url) { final FlooUrl f; try { @@ -175,7 +166,8 @@ private Project getProject(String path) { VirtualFile file = LocalFileSystem.getInstance().findFileByIoFile(new File(path)); Project openedProject; if (ProjectAttachProcessor.canAttachToProject() && file != null) { - openedProject = PlatformProjectOpenProcessor.doOpenProject(file, null, false, -1, null, false); + PlatformProjectOpenProcessor platformProjectOpenProcessor = PlatformProjectOpenProcessor.getInstance(); + openedProject = platformProjectOpenProcessor.doOpenProject(file, null, false); } else { openedProject = ProjectUtil.openOrImport(path, null, false); } @@ -197,5 +189,4 @@ private Project getProject(String path) { FileChooserUtil.setLastOpenedFile(openedProject, file); return openedProject; } - } diff --git a/src/floobits/FloobitsPlugin.java b/src/floobits/FloobitsPlugin.java index a5b88ca..323ddb5 100644 --- a/src/floobits/FloobitsPlugin.java +++ b/src/floobits/FloobitsPlugin.java @@ -1,6 +1,7 @@ package floobits; import com.intellij.openapi.components.ProjectComponent; +import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.project.Project; import floobits.impl.ContextImpl; import floobits.utilities.Flog; @@ -23,7 +24,8 @@ public FloobitsPlugin(Project project) { @Override public void projectOpened() { - FloobitsApplication.self.projectOpened(context); + FloobitsApplicationService floobitsApplicationService = ServiceManager.getService(FloobitsApplicationService.class); + floobitsApplicationService.projectOpened(context); context.loadFloobitsWindow(); } diff --git a/src/floobits/actions/OpenProjectInWorkspace.java b/src/floobits/actions/OpenProjectInWorkspace.java index b64fe7c..762e67e 100644 --- a/src/floobits/actions/OpenProjectInWorkspace.java +++ b/src/floobits/actions/OpenProjectInWorkspace.java @@ -1,8 +1,9 @@ package floobits.actions; import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.project.Project; -import floobits.FloobitsApplication; +import floobits.FloobitsApplicationService; import floobits.FloobitsPlugin; import floobits.common.*; import floobits.dialogs.HandleNoWorkspaceJoin; @@ -16,8 +17,9 @@ public class OpenProjectInWorkspace extends CanFloobits { public void actionPerformed(AnActionEvent actionEvent, Project project, FloobitsPlugin plugin, ContextImpl context) { FlooUrl flooUrl = DotFloo.read(project.getBasePath()); + FloobitsApplicationService floobitsApplicationService = ServiceManager.getService(FloobitsApplicationService.class); if (flooUrl != null) { - FloobitsApplication.self.joinWorkspace(context, flooUrl.toString()); + floobitsApplicationService.joinWorkspace(context, flooUrl.toString()); return; } @@ -34,7 +36,7 @@ public void actionPerformed(AnActionEvent actionEvent, Project project, Floobits Flog.error(e); continue; } - FloobitsApplication.self.joinWorkspace(context, flooUrl.toString()); + floobitsApplicationService.joinWorkspace(context, flooUrl.toString()); return; } } diff --git a/src/floobits/actions/QuickStartJoin.java b/src/floobits/actions/QuickStartJoin.java index 0805993..ffe5cd2 100644 --- a/src/floobits/actions/QuickStartJoin.java +++ b/src/floobits/actions/QuickStartJoin.java @@ -1,7 +1,8 @@ package floobits.actions; import com.intellij.openapi.actionSystem.AnActionEvent; -import floobits.FloobitsApplication; +import com.intellij.openapi.components.ServiceManager; +import floobits.FloobitsApplicationService; import javax.swing.*; @@ -11,7 +12,7 @@ public void actionPerformedHasAccount(AnActionEvent e) { if (inputValue == null) { return; } - - FloobitsApplication.self.joinWorkspace(inputValue); + FloobitsApplicationService applicationService = ServiceManager.getService(FloobitsApplicationService.class); + applicationService.joinWorkspace(inputValue); } } diff --git a/src/floobits/dialogs/JoinWorkspaceDialog.java b/src/floobits/dialogs/JoinWorkspaceDialog.java index 3ace297..99374af 100644 --- a/src/floobits/dialogs/JoinWorkspaceDialog.java +++ b/src/floobits/dialogs/JoinWorkspaceDialog.java @@ -1,6 +1,7 @@ package floobits.dialogs; -import floobits.FloobitsApplication; +import com.intellij.openapi.components.ServiceManager; +import floobits.FloobitsApplicationService; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -23,7 +24,8 @@ public void run() { if (inputValue == null) { return; } - FloobitsApplication.self.joinWorkspace(inputValue); + FloobitsApplicationService applicationService = ServiceManager.getService(FloobitsApplicationService.class); + applicationService.joinWorkspace(inputValue); } }); joinAction.putValue(FOCUSED_ACTION, true); diff --git a/src/floobits/dialogs/SelectRecentWorkspace.java b/src/floobits/dialogs/SelectRecentWorkspace.java index 1186a98..cb5f6a6 100644 --- a/src/floobits/dialogs/SelectRecentWorkspace.java +++ b/src/floobits/dialogs/SelectRecentWorkspace.java @@ -1,8 +1,9 @@ package floobits.dialogs; +import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; -import floobits.FloobitsApplication; +import floobits.FloobitsApplicationService; import floobits.FloobitsPlugin; import floobits.impl.ContextImpl; import org.jetbrains.annotations.Nullable; @@ -46,12 +47,13 @@ public void doCancelAction() { @Override protected void doOKAction() { super.doOKAction(); + FloobitsApplicationService floobitsApplicationService = ServiceManager.getService(FloobitsApplicationService.class); if (project != null) { ContextImpl context = project.getComponent(FloobitsPlugin.class).context; - FloobitsApplication.self.joinWorkspace(context, selectWorkspace.getSelectedItem()); + floobitsApplicationService.joinWorkspace(context, selectWorkspace.getSelectedItem()); return; } - FloobitsApplication.self.joinWorkspace(null, selectWorkspace.getSelectedItem()); + floobitsApplicationService.joinWorkspace(null, selectWorkspace.getSelectedItem()); } }