generated from JetBrains/intellij-platform-plugin-template
-
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.
Merge pull request #1 from bluelhf/main
Several fixes and QOL changes
- Loading branch information
Showing
26 changed files
with
519 additions
and
318 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
.gradle | ||
.idea | ||
**/.idea | ||
.qodana | ||
build |
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 |
---|---|---|
@@ -1,7 +1,17 @@ | ||
<!-- Keep a Changelog guide -> https://keepachangelog.com --> | ||
|
||
# testaustime-intellij Changelog | ||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [Unreleased] | ||
|
||
## [0.2.0] - 2022-08-04 | ||
|
||
### Added | ||
- Initial scaffold created from [IntelliJ Platform Plugin Template](https://github.com/JetBrains/intellij-platform-plugin-template) | ||
- Input verification on the settings page. | ||
- Project-level Testaustime notifications. | ||
### Changed | ||
- Improved some English messages. | ||
- Fixed tracking when multiple projects are open. | ||
- Split notifications into Testaustime Information and Testaustime Warnings. |
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 |
---|---|---|
@@ -1,37 +1,29 @@ | ||
# Testaustime IntelliJ Plugin | ||
|
||
![Build](https://github.com/developerfromjokela/testaustime-intellij/workflows/Build/badge.svg) | ||
[![Version](https://img.shields.io/jetbrains/plugin/v/PLUGIN_ID.svg)](https://plugins.jetbrains.com/plugin/PLUGIN_ID) | ||
[![Downloads](https://img.shields.io/jetbrains/plugin/d/PLUGIN_ID.svg)](https://plugins.jetbrains.com/plugin/PLUGIN_ID) | ||
|
||
## Template ToDo list | ||
- [x] Create a new [IntelliJ Platform Plugin Template][template] project. | ||
- [ ] Get familiar with the [template documentation][template]. | ||
- [ ] Verify the [pluginGroup](/gradle.properties), [plugin ID](/src/main/resources/META-INF/plugin.xml) and [sources package](/src/main/kotlin). | ||
- [ ] Review the [Legal Agreements](https://plugins.jetbrains.com/docs/marketplace/legal-agreements.html). | ||
- [ ] [Publish a plugin manually](https://plugins.jetbrains.com/docs/intellij/publishing-plugin.html?from=IJPluginTemplate) for the first time. | ||
- [ ] Set the Plugin ID in the above README badges. | ||
- [ ] Set the [Deployment Token](https://plugins.jetbrains.com/docs/marketplace/plugin-upload.html). | ||
- [ ] Click the <kbd>Watch</kbd> button on the top of the [IntelliJ Platform Plugin Template][template] to be notified about releases containing new features and fixes. | ||
[![Version](https://img.shields.io/jetbrains/plugin/v/19408.svg)](https://plugins.jetbrains.com/plugin/19408) | ||
[![Downloads](https://img.shields.io/jetbrains/plugin/d/19408.svg)](https://plugins.jetbrains.com/plugin/19408) | ||
--- | ||
|
||
<!-- Plugin description --> | ||
Testaustime is the ultimate tool for tracking time of your coding sessions. Show the world how dedicated you are to your projects, now available for IntelliJ IDEs! | ||
<!-- Plugin description end --> | ||
|
||
## Installation | ||
> **Note** | ||
> Here from [testaustime.fi](https://testaustime.fi)? You can skip steps 2 and 5! | ||
- Using IDE built-in plugin system: | ||
1. Install the Testaustime IntelliJ Plugin | ||
- Using the IDE's built-in plugin system | ||
- <kbd>Settings</kbd> > <kbd>Plugins</kbd> > <kbd>Marketplace</kbd> > <kbd>Search for "Testaustime"</kbd> > <kbd>Install Plugin</kbd> | ||
|
||
<kbd>Settings/Preferences</kbd> > <kbd>Plugins</kbd> > <kbd>Marketplace</kbd> > <kbd>Search for "Testaustime"</kbd> > | ||
<kbd>Install Plugin</kbd> | ||
|
||
- Manually: | ||
|
||
Download the [latest release](https://github.com/developerfromjokela/testaustime-intellij/releases/latest) and install it manually using | ||
<kbd>Settings/Preferences</kbd> > <kbd>Plugins</kbd> > <kbd>⚙️</kbd> > <kbd>Install plugin from disk...</kbd> | ||
|
||
|
||
--- | ||
Plugin based on the [IntelliJ Platform Plugin Template][template]. | ||
|
||
[template]: https://github.com/JetBrains/intellij-platform-plugin-template | ||
- Manually: | ||
1. Download the [latest release](https://github.com/developerfromjokela/testaustime-intellij/releases/latest) and install it manually using | ||
2. <kbd>Settings</kbd> > <kbd>Plugins</kbd> > <kbd>⚙️</kbd> > <kbd>Install plugin from disk...</kbd> | ||
|
||
2. <sup>(Optional)</sup> Set your Testaustime API endpoint | ||
- <kbd>Settings</kbd> > <kbd>Tools</kbd> > <kbd>Testaustime Settings</kbd> > <kbd>Testaustime API base URL</kbd> | ||
3. Set your Testaustime API token | ||
- <kbd>Settings</kbd> > <kbd>Tools</kbd> > <kbd>Testaustime Settings</kbd> > <kbd>Testaustime Authentication token</kbd> | ||
4. Start coding! | ||
5. View your stats on your favourite Testaustime front-end! |
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
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
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
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
40 changes: 0 additions & 40 deletions
40
src/main/kotlin/fi/testaustime/plugin_intellij/configuration/IntellijSettingsComponent.kt
This file was deleted.
Oops, something went wrong.
111 changes: 111 additions & 0 deletions
111
src/main/kotlin/fi/testaustime/plugin_intellij/configuration/SettingsComponent.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,111 @@ | ||
package fi.testaustime.plugin_intellij.configuration | ||
|
||
import com.intellij.openapi.ui.ComponentValidator | ||
import com.intellij.openapi.ui.ValidationInfo | ||
import com.intellij.ui.components.JBLabel | ||
import com.intellij.ui.components.JBTextField | ||
import com.intellij.util.ui.FormBuilder | ||
import fi.testaustime.plugin_intellij.TestaustimeBundle.message | ||
import fi.testaustime.plugin_intellij.network.TestaustimeAPIClient | ||
import org.jetbrains.annotations.NotNull | ||
import java.net.MalformedURLException | ||
import java.net.URL | ||
import java.util.function.Supplier | ||
import javax.swing.InputVerifier | ||
import javax.swing.JComponent | ||
import javax.swing.JPanel | ||
|
||
|
||
class SettingsComponent { | ||
fun validate(): Boolean { | ||
var valid = baseUrlText.inputVerifier?.verify(baseUrlText) ?: false; | ||
valid = valid and (authTokenText.inputVerifier?.verify(authTokenText) ?: false); | ||
return valid | ||
} | ||
|
||
val panel: JPanel | ||
private val baseUrlText = JBTextField() | ||
private val authTokenText = JBTextField() | ||
|
||
init { | ||
panel = FormBuilder.createFormBuilder() | ||
.addLabeledComponent(JBLabel(message("settings.apiBaseURL") + ": "), baseUrlText, 1, false) | ||
.addLabeledComponent(JBLabel(message("settings.apiToken") + ": "), authTokenText, 1, false) | ||
.addComponentFillVertically(JPanel(), 0) | ||
.panel | ||
|
||
run { | ||
val validator = ComponentValidator { }.withValidator(Supplier { | ||
if (baseUrlText.text.endsWith("/")) { | ||
return@Supplier ValidationInfo(message("settings.apiBaseURL.noSlash"), baseUrlText) | ||
} else { | ||
try { | ||
URL(baseUrlText.text) | ||
} catch (ex: MalformedURLException) { | ||
return@Supplier ValidationInfo(message("settings.apiBaseURL.mustBeURL"), baseUrlText) | ||
} | ||
} | ||
|
||
return@Supplier ValidationInfo("").withOKEnabled(); | ||
}).installOn(baseUrlText) | ||
|
||
baseUrlText.inputVerifier = object : InputVerifier() { | ||
override fun verify(input: JComponent?): Boolean { | ||
validator.revalidate() | ||
return validator.validationInfo?.okEnabled ?: true; | ||
} | ||
} | ||
} | ||
|
||
|
||
run { | ||
val validator = ComponentValidator { }.withValidator(Supplier { | ||
if (authTokenText.text.isEmpty()) { | ||
return@Supplier ValidationInfo(message("settings.apiToken.needToken"), authTokenText).asWarning(); | ||
} | ||
|
||
if (!authTokenText.text.chars().allMatch(Character::isLetterOrDigit)) { | ||
return@Supplier ValidationInfo(message("settings.apiToken.mustBeAlphanumeric"), authTokenText); | ||
} | ||
|
||
if (authTokenText.text.length != 32) { | ||
return@Supplier ValidationInfo(message("settings.apiToken.invalidLength", authTokenText.text.length), | ||
authTokenText); | ||
} | ||
|
||
if (!TestaustimeAPIClient.verifyToken(baseUrlText.text, authTokenText.text)) { | ||
return@Supplier ValidationInfo(message("settings.apiToken.invalid", baseUrl ?: "The API"), authTokenText); | ||
} | ||
|
||
return@Supplier ValidationInfo("").withOKEnabled(); | ||
}).installOn(authTokenText) | ||
|
||
authTokenText.inputVerifier = object : InputVerifier() { | ||
override fun verify(input: JComponent?): Boolean { | ||
validator.revalidate() | ||
validator.validationInfo?.let { | ||
return it.okEnabled or it.warning; | ||
} | ||
return false; | ||
} | ||
} | ||
} | ||
} | ||
|
||
val preferredFocusedComponent: JComponent | ||
get() = baseUrlText | ||
|
||
@get:NotNull | ||
var baseUrl: String? | ||
get() = baseUrlText.text | ||
set(newText) { | ||
baseUrlText.text = newText | ||
} | ||
|
||
@get:NotNull | ||
var authToken: String? | ||
get() = authTokenText.text | ||
set(newText) { | ||
authTokenText.text = newText | ||
} | ||
} |
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
Oops, something went wrong.