Skip to content

Commit

Permalink
Rewrite notification service (#275)
Browse files Browse the repository at this point in the history
  • Loading branch information
thepieterdc authored Dec 29, 2023
1 parent d06ab43 commit 5816855
Show file tree
Hide file tree
Showing 9 changed files with 466 additions and 347 deletions.
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ dependencies {
testImplementation group: 'io.github.thepieterdc.random', name: 'random', version: '1.0.2'
}

task calculateNextVersion {
tasks.register('calculateNextVersion') {
doLast {
def version = (project.version as String).split('\\.').collect { Integer.parseInt(it) }
println(String.format("%s.%s.%s", version[0], version[1], version[2] + 1))
}
}

task generateBuildConfig {
tasks.register('generateBuildConfig') {
var outputDir = file("$projectDir/src/main/java/")
doFirst {
def srcFile = new File(outputDir, "io/github/thepieterdc/dodona/plugin/BuildConfig.java")
Expand Down Expand Up @@ -87,9 +87,9 @@ static def getVerifiableVersions() {
intellij {
downloadSources.set(false)
pluginName.set('dodona')
plugins.set(['java', 'PythonCore:211.7628.24'])
plugins.set(['java', 'PythonCore:221.6008.17'])
updateSinceUntilBuild.set(false)
version.set('211.7628.21')
version.set('221.6008.13')
}

jacocoTestReport {
Expand All @@ -107,7 +107,7 @@ patchPluginXml {

pluginDescription = 'Companion plugin for the Ghent University Dodona platform, which allows you to submit exercises right from your favourite JetBrains IDE. More information can be found at <a href="https://docs.dodona.be/en/guides/pycharm-plugin/">https://docs.dodona.be/en/guides/pycharm-plugin/</a>'

sinceBuild = '211.7628.21'
sinceBuild = '221.6008.13'
}

publishPlugin {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@
public class DodonaAccountPanel extends BorderLayoutPanel implements Disposable {
private final CollectionListModel<DodonaAccount> accountListModel;
private final JBList<DodonaAccount> accountList;

private boolean modified;

@Nullable
private String newToken;

/**
* DodonaAccountPanel constructor.
*/
Expand All @@ -53,12 +53,12 @@ public DodonaAccountPanel() {
this.accountListModel = new CollectionListModel<>();
this.accountList = this.createAccountsList();
this.modified = false;

this.newToken = null;

this.addToCenter(this.createCenterComponent());
}

/**
* Shows an add account dialog.
*/
Expand All @@ -68,35 +68,35 @@ private void addAccount() {
// Create a new account.
final DodonaAccount account = DodonaAccountManager
.createAccount(dialog.getServer(), dialog.getUser());

// Remove the previous account.
this.removeAccount();

// Store the token.
this.newToken = dialog.getToken();

// Add the new account to the model.
this.accountListModel.add(account);

// Set the modification status.
this.modified = true;
}
}

/**
* Clears the modification status.
*/
public void clearModified() {
this.modified = false;
}

/**
* Clears the map of new authentication data.
*/
public void clearNewData() {
this.newToken = null;
}

/**
* Creates the list of Dodona accounts.
*
Expand All @@ -113,10 +113,10 @@ private JBList<DodonaAccount> createAccountsList() {
.appendText(DodonaBundle.message("auth.accounts.empty"))
.appendSecondaryText(DodonaBundle.message("auth.accounts.add"), SimpleTextAttributes.LINK_ATTRIBUTES, e -> this.addAccount())
.appendSecondaryText(String.format(" (%s)", KeymapUtil.getFirstKeyboardShortcutText(CommonShortcuts.getNew())), StatusText.DEFAULT_ATTRIBUTES, null);
UIUtil.putClientProperty(this, UIUtil.NOT_IN_HIERARCHY_COMPONENTS, Collections.singletonList(renderer));
this.putClientProperty(UIUtil.NOT_IN_HIERARCHY_COMPONENTS, Collections.singletonList(renderer));
return ret;
}

/**
* Creates the center component of the panel.
*
Expand All @@ -132,12 +132,12 @@ private Component createCenterComponent() {
.setPanelBorder(IdeBorderFactory.createBorder(SideBorder.TOP | SideBorder.BOTTOM))
.createPanel();
}

@Override
public void dispose() {
// Not implemented.
}

/**
* Gets the account and its access token, if the account was newly added.
*
Expand All @@ -150,14 +150,14 @@ public Pair<DodonaAccount, String> getAccount() {
if (this.accountListModel.isEmpty()) {
return Pair.empty();
}

// Return the account and its token.
return Pair.create(
this.accountListModel.getElementAt(0),
this.newToken
);
}

/**
* Gets whether the accounts were modified.
*
Expand All @@ -166,7 +166,7 @@ public Pair<DodonaAccount, String> getAccount() {
public boolean isModified() {
return this.modified;
}

/**
* Removes the selected account.
*/
Expand All @@ -176,7 +176,7 @@ private void removeAccount() {
this.modified = true;
}
}

/**
* Sets the account from the settings.
*/
Expand Down
Loading

0 comments on commit 5816855

Please sign in to comment.