-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,9 @@ package com.alvincezy.tinypic2.actions | |
import com.alvincezy.tinypic2.* | ||
import com.alvincezy.tinypic2.exts.supportTinify | ||
import com.alvincezy.tinypic2.model.VirtualFileAware | ||
import com.alvincezy.tinypic2.tinify.PluginStat | ||
import com.alvincezy.tinypic2.tinify.TinifyBackgroundTask | ||
import com.alvincezy.tinypic2.tinify.getTopSelection | ||
import com.alvincezy.tinypic2.tinify.prepare | ||
import com.intellij.openapi.actionSystem.AnActionEvent | ||
import com.intellij.openapi.diagnostic.Logger | ||
|
@@ -16,14 +18,15 @@ import com.intellij.openapi.project.Project | |
import com.intellij.openapi.ui.Messages | ||
import com.intellij.openapi.vfs.VfsUtilCore | ||
import com.intellij.openapi.vfs.VirtualFile | ||
import com.intellij.openapi.vfs.VirtualFileManager | ||
import com.intellij.openapi.vfs.VirtualFileVisitor | ||
import com.tinify.Tinify | ||
|
||
/** | ||
* Created by alvince on 2017/6/28. | ||
* | ||
* @author [email protected] | ||
* @version 1.1.1, 2018/8/21 | ||
* @version 1.1.1, 2018/8/24 | ||
* @since 1.0 | ||
*/ | ||
class TinyPicUploadAction : TinifyAction() { | ||
|
@@ -47,11 +50,19 @@ class TinyPicUploadAction : TinifyAction() { | |
|
||
private fun pickAndTinify(project: Project) { | ||
val descriptor = FileChooserDescriptor(true, true, false, false, false, true) | ||
val selectedFiles = FileChooser.chooseFiles(descriptor, project, project.baseDir) | ||
val urlSelectTo = PluginStat.urlSelectToTinify(project) | ||
console("base directory: $urlSelectTo") | ||
val selectedFiles = FileChooser.chooseFiles(descriptor, project, | ||
VirtualFileManager.getInstance().findFileByUrl(urlSelectTo)) | ||
if (selectedFiles.isEmpty()) { | ||
return@pickAndTinify | ||
} | ||
|
||
val rootSelection = getTopSelection(selectedFiles) | ||
if (rootSelection != null) { | ||
console("select root dir: $rootSelection") | ||
PluginStat.pickFileDefault = rootSelection.path | ||
} | ||
enable(false) | ||
ProgressManager.getInstance().run(object : Task.Backgroundable(project, Constants.APP_NAME, true) { | ||
override fun run(indicator: ProgressIndicator) { | ||
|
21 changes: 21 additions & 0 deletions
21
src/main/kotlin/com/alvincezy/tinypic2/tinify/PluginStat.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.alvincezy.tinypic2.tinify | ||
|
||
import com.intellij.openapi.project.Project | ||
|
||
/** | ||
* Singleton plugin stat wrapper | ||
* | ||
* Created by alvince on 18-8-24. | ||
* | ||
* @author [email protected] | ||
* @version 1.1.1, 2018/8/24 | ||
*/ | ||
object PluginStat { | ||
|
||
var pickFileDefault: String = "" | ||
|
||
/** | ||
* Obtain files dir-url select to | ||
*/ | ||
fun urlSelectToTinify(project: Project): String = "file://${if (pickFileDefault.isEmpty()) project.baseDir.path else pickFileDefault}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters