Skip to content

Commit

Permalink
#306 | Enabled Wizard-based Project Import from the Welcome Screen
Browse files Browse the repository at this point in the history
  • Loading branch information
mlytvyn authored Mar 29, 2023
1 parent a6ea24b commit e725007
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 44 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ plugins {
idea
id("java")
id("org.jetbrains.kotlin.jvm") version "1.8.10"
id("org.jetbrains.intellij") version "1.13.2"
id("org.jetbrains.intellij") version "1.13.3"
}

repositories {
Expand Down
4 changes: 3 additions & 1 deletion resources/META-INF/plugin-release-info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,12 @@
<![CDATA[
<h3>2023.2.0</h3>
<ul>
<li><i>Feature:</i> Enabled Wizard-based Project Import from the Welcome Screen (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/306" target="_blank" rel="nofollow">#306</a>)</li>
<li><i>Feature:</i> Improved support of the custom DOM files (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/301" target="_blank" rel="nofollow">#301</a>)</li>
<li><i>Feature:</i> Enable selection of the CCv2 modules during Project import (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/303" target="_blank" rel="nofollow">#303</a>)</li>
<li><i>Other:</i> Added Project icon for Plugin repository (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/302" target="_blank" rel="nofollow">#302</a>)</li>
<li><i>Other:</i> Replaced Caffeine cache with IDEA user data (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/304" target="_blank" rel="nofollow">#304</a>)</li>
<li><i>Other:</i> Updated to Gradle plugin to 1.13.3</li>
</ul>
<h3>2023.1.2</h3>
<ul>
Expand Down Expand Up @@ -198,7 +200,7 @@
<li><i>Feature:</i> Added possibility to group by Item parent for Type System preview (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/211" target="_blank" rel="nofollow">#211</a>)</li>
<li><i>Feature:</i> Added completion and navigation for Index attributes within <code>items.xml</code> (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/207" target="_blank" rel="nofollow">#207</a>)</li>
<li><i>Feature:</i> Added completion for meta tags within <code>extensioninfo.xml</code> (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/230" target="_blank" rel="nofollow">#230</a>)</li>
<li><i>Feature:</i> Improved representation of the available extensions listing (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/233" target="_blank" rel="nofollow">#233</a>)</li>
<li><i>Feature:</i> Improved representation of the available extensions listing (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/234" target="_blank" rel="nofollow">#234</a>)</li>
<li><i>Feature:</i> Improved project startup performance (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/210" target="_blank" rel="nofollow">#210</a>)</li>
<li><i>Feature:</i> Added listing of references for <code>id</code> attribute within Business Process definition (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/214" target="_blank" rel="nofollow">#214</a>)</li>
<li><i>Feature:</i> Added listing of references for multiple Cockpitng definitions (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/216" target="_blank" rel="nofollow">#216</a>)</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,12 @@
*/
package com.intellij.idea.plugin.hybris.project

import com.intellij.ide.actions.ImportModuleAction
import com.intellij.ide.util.projectWizard.WizardContext
import com.intellij.idea.plugin.hybris.common.HybrisConstants
import com.intellij.idea.plugin.hybris.common.HybrisUtil
import com.intellij.idea.plugin.hybris.project.wizard.OpenSupport
import com.intellij.idea.plugin.hybris.project.wizard.RefreshSupport
import com.intellij.idea.plugin.hybris.settings.HybrisProjectSettings
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.projectImport.ProjectImportBuilder
import com.intellij.projectImport.ProjectImportProvider
import com.intellij.projectImport.ProjectOpenProcessorBase

class HybrisProjectOpenProcessor : ProjectOpenProcessorBase<OpenHybrisProjectImportBuilder>() {
Expand All @@ -34,28 +31,20 @@ class HybrisProjectOpenProcessor : ProjectOpenProcessorBase<OpenHybrisProjectImp
if (file.isDirectory) {
wizardContext.setProjectFileDirectory(file.path)
}
wizardContext.projectName = file.name
wizardContext.projectBuilder = builder

builder.refresh = false
builder.fileToImport = file.path

val temporarySettings = HybrisProjectSettings()
hybrisProjectImportProvider()
?.createSteps(wizardContext)
?.filterIsInstance<OpenSupport>()
?.forEach { it.open(temporarySettings) }

// it has to be set as last property
builder.isOpenProjectSettingsAfter = true
val providers = ImportModuleAction.getProviders(null)
ImportModuleAction.doImport(null) {
ImportModuleAction.createImportWizard(null, null, file, *providers.toTypedArray())
}

return true
return false
}

override fun canOpenProject(file: VirtualFile): Boolean {
val canOpenSimpleVerification = super.canOpenProject(file)
return if (canOpenSimpleVerification) { true }
else HybrisUtil.isPotentialHybrisProject(file)
return if (canOpenSimpleVerification) {
true
} else HybrisUtil.isPotentialHybrisProject(file)
}

override val supportedExtensions = arrayOf(
Expand All @@ -66,7 +55,4 @@ class HybrisProjectOpenProcessor : ProjectOpenProcessorBase<OpenHybrisProjectImp

override fun doGetBuilder() = ProjectImportBuilder.EXTENSIONS_POINT_NAME.findExtensionOrFail(OpenHybrisProjectImportBuilder::class.java)

private fun hybrisProjectImportProvider() = ProjectImportProvider.PROJECT_IMPORT_PROVIDER.extensions
.find { it is HybrisProjectImportProvider }

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/
package com.intellij.idea.plugin.hybris.project

import com.intellij.idea.plugin.hybris.startup.HybrisProjectImportStartupActivity
import com.intellij.openapi.module.ModifiableModuleModel
import com.intellij.openapi.module.Module
import com.intellij.openapi.project.Project
Expand All @@ -32,9 +31,6 @@ class OpenHybrisProjectImportBuilder : DefaultHybrisProjectImportBuilder() {
modulesProvider: ModulesProvider?,
artifactModel: ModifiableArtifactModel?
): MutableList<Module>? {
if (isOpenProjectSettingsAfter) {
project.putUserData(HybrisProjectImportStartupActivity.openSettingsKey, true)
}
getHybrisProjectDescriptor().setHybrisProject(project)

return super.commit(project, model, modulesProvider, artifactModel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,11 @@ import com.intellij.idea.plugin.hybris.project.descriptors.HybrisProjectDescript
import com.intellij.idea.plugin.hybris.settings.HybrisDeveloperSpecificProjectSettingsListener
import com.intellij.idea.plugin.hybris.settings.HybrisProjectSettingsComponent
import com.intellij.idea.plugin.hybris.toolwindow.HybrisToolWindowService
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.application.ModalityState
import com.intellij.openapi.project.Project
import com.intellij.openapi.roots.ui.configuration.IdeaProjectSettingsService
import com.intellij.openapi.startup.ProjectActivity
import com.intellij.openapi.util.Key
import com.intellij.openapi.util.removeUserData

private const val OPEN_SETTINGS_DIALOG = "hybrisProjectImportOpenSettingsDialog"
private const val SYNC_PROJECT_SETTINGS = "hybrisProjectImportSyncProjectSettings"
private const val FINALIZE_PROJECT_IMPORT = "hybrisProjectImportFinalize"

Expand All @@ -44,11 +40,6 @@ class HybrisProjectImportStartupActivity : ProjectActivity {
RunOnceUtil.runOnceForProject(project, "afterHybrisProjectImport") {
HybrisToolWindowService.getInstance(project).activateToolWindow()

project.getUserData(openSettingsKey)
?.let {
project.removeUserData(openSettingsKey)
openSettingsForProject(project)
}
project.getUserData(syncProjectSettingsKey)
?.let {
project.removeUserData(syncProjectSettingsKey)
Expand All @@ -68,11 +59,6 @@ class HybrisProjectImportStartupActivity : ProjectActivity {

}

// ensure the dialog is shown after all startup activities are done
private fun openSettingsForProject(project: Project) = ApplicationManager.getApplication().invokeLater({
IdeaProjectSettingsService.getInstance(project).openProjectSettings()
}, ModalityState.NON_MODAL, project.disposed)

private fun syncProjectSettingsForProject(project: Project) {
with (project.messageBus.syncPublisher(HybrisDeveloperSpecificProjectSettingsListener.TOPIC)) {
hacConnectionSettingsChanged()
Expand All @@ -82,7 +68,6 @@ class HybrisProjectImportStartupActivity : ProjectActivity {


companion object {
val openSettingsKey: Key<Boolean> = Key.create(OPEN_SETTINGS_DIALOG);
val syncProjectSettingsKey: Key<Boolean> = Key.create(SYNC_PROJECT_SETTINGS);
val finalizeProjectImportKey: Key<Triple<HybrisProjectDescriptor, List<HybrisModuleDescriptor>, Boolean>> = Key.create(FINALIZE_PROJECT_IMPORT);
}
Expand Down

0 comments on commit e725007

Please sign in to comment.