Skip to content

Commit e85a198

Browse files
committed
Add About, Open profile and small enhancements to TMC menu
1 parent 084b65a commit e85a198

File tree

7 files changed

+284
-2
lines changed

7 files changed

+284
-2
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package fi.helsinki.cs.tmc.actions;
2+
3+
import fi.helsinki.cs.tmc.ui.ConvenientDialogDisplayer;
4+
5+
import java.awt.event.ActionEvent;
6+
import java.net.MalformedURLException;
7+
import java.net.URL;
8+
import javax.swing.AbstractAction;
9+
10+
import org.openide.awt.ActionID;
11+
import org.openide.awt.ActionReference;
12+
import org.openide.awt.ActionReferences;
13+
import org.openide.awt.ActionRegistration;
14+
import org.openide.awt.HtmlBrowser;
15+
import org.openide.util.NbBundle;
16+
17+
@ActionID(category = "TMC",
18+
id = "fi.helsinki.cs.tmc.actions.OpenProfileAction")
19+
@ActionRegistration(displayName = "#CTL_OpenProfileAction")
20+
@ActionReferences({
21+
@ActionReference(path = "Menu/TM&C", position = 50, separatorBefore = 49)
22+
})
23+
@NbBundle.Messages("CTL_OpenProfileAction=Open my profile")
24+
public class OpenProfileAction extends AbstractAction {
25+
26+
@Override
27+
public void actionPerformed(ActionEvent e) {
28+
try {
29+
HtmlBrowser.URLDisplayer.getDefault().showURLExternal(new URL("https://tmc.mooc.fi/participants/me"));
30+
} catch (MalformedURLException ex) {
31+
ConvenientDialogDisplayer.getDefault().displayError("Failed to open browser.\n" + ex.getMessage());
32+
}
33+
}
34+
35+
}

tmc-plugin/src/fi/helsinki/cs/tmc/actions/PastebinAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
@ActionID(category = "TMC", id = "fi.helsinki.cs.tmc.actions.PastebinAction")
3737
@ActionRegistration(displayName = "#CTL_PastebinAction", lazy = false)
3838
@ActionReferences({
39-
@ActionReference(path = "Menu/TM&C", position = -17),
39+
@ActionReference(path = "Menu/TM&C", position = 30),
4040
@ActionReference(
4141
path = "Projects/Actions",
4242
position = 1340,

tmc-plugin/src/fi/helsinki/cs/tmc/actions/RequestReviewAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
@ActionID(category = "TMC", id = "fi.helsinki.cs.tmc.actions.RequestReviewAction")
4040
@ActionRegistration(displayName = "#CTL_RequestReviewAction", lazy = false)
4141
@ActionReferences({
42-
@ActionReference(path = "Menu/TM&C", position = -5, separatorAfter = 0),
42+
@ActionReference(path = "Menu/TM&C", position = 40),
4343
@ActionReference(path = "Projects/Actions", position = 1350, separatorBefore = 1330,
4444
separatorAfter = 1360) // Positioning y u no work?
4545
})
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package fi.helsinki.cs.tmc.actions;
2+
3+
import fi.helsinki.cs.tmc.ui.AboutDialog;
4+
5+
import java.awt.event.ActionEvent;
6+
import javax.swing.AbstractAction;
7+
8+
import org.openide.awt.ActionID;
9+
import org.openide.awt.ActionReference;
10+
import org.openide.awt.ActionReferences;
11+
import org.openide.awt.ActionRegistration;
12+
import org.openide.util.NbBundle.Messages;
13+
14+
@ActionID(category = "TMC",
15+
id = "fi.helsinki.cs.tmc.actions.ShowAboutAction")
16+
@ActionRegistration(displayName = "#CTL_ShowAboutAction")
17+
@ActionReferences({
18+
@ActionReference(path = "Menu/TM&C", position = 60)
19+
})
20+
@Messages("CTL_ShowAboutAction=About")
21+
public class ShowAboutAction extends AbstractAction {
22+
23+
@Override
24+
public void actionPerformed(ActionEvent e) {
25+
AboutDialog.display();
26+
}
27+
28+
}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
3+
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
4+
<Properties>
5+
<Property name="defaultCloseOperation" type="int" value="2"/>
6+
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
7+
<Dimension value="[466, 260]"/>
8+
</Property>
9+
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
10+
<Dimension value="[466, 260]"/>
11+
</Property>
12+
<Property name="resizable" type="boolean" value="false"/>
13+
</Properties>
14+
<SyntheticProperties>
15+
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
16+
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
17+
</SyntheticProperties>
18+
<AuxValues>
19+
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
20+
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
21+
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
22+
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
23+
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
24+
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
25+
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
26+
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
27+
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
28+
</AuxValues>
29+
30+
<Layout>
31+
<DimensionLayout dim="0">
32+
<Group type="103" groupAlignment="0" attributes="0">
33+
<Group type="102" alignment="0" attributes="0">
34+
<EmptySpace max="-2" attributes="0"/>
35+
<Group type="103" groupAlignment="0" attributes="0">
36+
<Component id="infoScrollPane" pref="0" max="32767" attributes="0"/>
37+
<Group type="102" alignment="1" attributes="0">
38+
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
39+
<Component id="closeButton" min="-2" max="-2" attributes="0"/>
40+
</Group>
41+
<Group type="102" attributes="0">
42+
<Component id="headerLabel" min="-2" max="-2" attributes="0"/>
43+
<EmptySpace min="0" pref="248" max="32767" attributes="0"/>
44+
</Group>
45+
</Group>
46+
<EmptySpace max="-2" attributes="0"/>
47+
</Group>
48+
</Group>
49+
</DimensionLayout>
50+
<DimensionLayout dim="1">
51+
<Group type="103" groupAlignment="0" attributes="0">
52+
<Group type="102" alignment="0" attributes="0">
53+
<EmptySpace max="-2" attributes="0"/>
54+
<Component id="headerLabel" min="-2" max="-2" attributes="0"/>
55+
<EmptySpace type="unrelated" max="-2" attributes="0"/>
56+
<Component id="infoScrollPane" min="-2" pref="158" max="-2" attributes="0"/>
57+
<EmptySpace type="unrelated" max="-2" attributes="0"/>
58+
<Component id="closeButton" min="-2" max="-2" attributes="0"/>
59+
<EmptySpace max="-2" attributes="0"/>
60+
</Group>
61+
</Group>
62+
</DimensionLayout>
63+
</Layout>
64+
<SubComponents>
65+
<Component class="javax.swing.JLabel" name="headerLabel">
66+
<Properties>
67+
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
68+
<Font name="Ubuntu" size="20" style="1"/>
69+
</Property>
70+
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
71+
<ResourceString bundle="fi/helsinki/cs/tmc/ui/Bundle.properties" key="AboutDialog.headerLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
72+
</Property>
73+
</Properties>
74+
</Component>
75+
<Component class="javax.swing.JButton" name="closeButton">
76+
<Properties>
77+
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
78+
<ResourceString bundle="fi/helsinki/cs/tmc/ui/Bundle.properties" key="AboutDialog.closeButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
79+
</Property>
80+
</Properties>
81+
<Events>
82+
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="closeButtonActionPerformed"/>
83+
</Events>
84+
</Component>
85+
<Container class="javax.swing.JScrollPane" name="infoScrollPane">
86+
<AuxValues>
87+
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
88+
</AuxValues>
89+
90+
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
91+
<SubComponents>
92+
<Component class="javax.swing.JTextPane" name="infoTextPane">
93+
<Properties>
94+
<Property name="editable" type="boolean" value="false"/>
95+
<Property name="contentType" type="java.lang.String" value="text/html" noResource="true"/>
96+
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
97+
<ResourceString bundle="fi/helsinki/cs/tmc/ui/Bundle.properties" key="AboutDialog.infoTextPane.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
98+
</Property>
99+
</Properties>
100+
</Component>
101+
</SubComponents>
102+
</Container>
103+
</SubComponents>
104+
</Form>
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
package fi.helsinki.cs.tmc.ui;
2+
3+
import java.net.MalformedURLException;
4+
import java.net.URL;
5+
import javax.swing.event.HyperlinkEvent;
6+
7+
import org.openide.awt.HtmlBrowser;
8+
import org.openide.windows.WindowManager;
9+
10+
public class AboutDialog extends javax.swing.JDialog {
11+
12+
public static void display() {
13+
AboutDialog dialog = new AboutDialog();
14+
dialog.setTitle("About");
15+
dialog.setLocationRelativeTo(null);
16+
dialog.setVisible(true);
17+
}
18+
19+
public AboutDialog() {
20+
super(WindowManager.getDefault().getMainWindow(), false);
21+
initComponents();
22+
23+
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
24+
25+
this.infoTextPane.addHyperlinkListener((HyperlinkEvent e) -> {
26+
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
27+
try {
28+
HtmlBrowser.URLDisplayer.getDefault().showURLExternal(new URL("https://mooc.fi/tmc"));
29+
} catch (MalformedURLException ex) {
30+
ConvenientDialogDisplayer.getDefault().displayError("Failed to open browser.\n" + ex.getMessage());
31+
}
32+
}
33+
});
34+
}
35+
36+
/**
37+
* This method is called from within the constructor to initialize the form.
38+
* WARNING: Do NOT modify this code. The content of this method is always
39+
* regenerated by the Form Editor.
40+
*/
41+
@SuppressWarnings("unchecked")
42+
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
43+
private void initComponents() {
44+
45+
headerLabel = new javax.swing.JLabel();
46+
closeButton = new javax.swing.JButton();
47+
infoScrollPane = new javax.swing.JScrollPane();
48+
infoTextPane = new javax.swing.JTextPane();
49+
50+
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
51+
setMaximumSize(new java.awt.Dimension(466, 260));
52+
setMinimumSize(new java.awt.Dimension(466, 260));
53+
setResizable(false);
54+
55+
headerLabel.setFont(new java.awt.Font("Ubuntu", 1, 20)); // NOI18N
56+
org.openide.awt.Mnemonics.setLocalizedText(headerLabel, org.openide.util.NbBundle.getMessage(AboutDialog.class, "AboutDialog.headerLabel.text")); // NOI18N
57+
58+
org.openide.awt.Mnemonics.setLocalizedText(closeButton, org.openide.util.NbBundle.getMessage(AboutDialog.class, "AboutDialog.closeButton.text")); // NOI18N
59+
closeButton.addActionListener(new java.awt.event.ActionListener() {
60+
public void actionPerformed(java.awt.event.ActionEvent evt) {
61+
closeButtonActionPerformed(evt);
62+
}
63+
});
64+
65+
infoTextPane.setEditable(false);
66+
infoTextPane.setContentType("text/html"); // NOI18N
67+
infoTextPane.setText(org.openide.util.NbBundle.getMessage(AboutDialog.class, "AboutDialog.infoTextPane.text")); // NOI18N
68+
infoScrollPane.setViewportView(infoTextPane);
69+
70+
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
71+
getContentPane().setLayout(layout);
72+
layout.setHorizontalGroup(
73+
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
74+
.addGroup(layout.createSequentialGroup()
75+
.addContainerGap()
76+
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
77+
.addComponent(infoScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
78+
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
79+
.addGap(0, 0, Short.MAX_VALUE)
80+
.addComponent(closeButton))
81+
.addGroup(layout.createSequentialGroup()
82+
.addComponent(headerLabel)
83+
.addGap(0, 248, Short.MAX_VALUE)))
84+
.addContainerGap())
85+
);
86+
layout.setVerticalGroup(
87+
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
88+
.addGroup(layout.createSequentialGroup()
89+
.addContainerGap()
90+
.addComponent(headerLabel)
91+
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
92+
.addComponent(infoScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
93+
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
94+
.addComponent(closeButton)
95+
.addContainerGap())
96+
);
97+
98+
pack();
99+
}// </editor-fold>//GEN-END:initComponents
100+
101+
private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeButtonActionPerformed
102+
this.setVisible(false);
103+
this.dispose();
104+
}//GEN-LAST:event_closeButtonActionPerformed
105+
106+
// Variables declaration - do not modify//GEN-BEGIN:variables
107+
private javax.swing.JButton closeButton;
108+
private javax.swing.JLabel headerLabel;
109+
private javax.swing.JScrollPane infoScrollPane;
110+
private javax.swing.JTextPane infoTextPane;
111+
// End of variables declaration//GEN-END:variables
112+
}

tmc-plugin/src/fi/helsinki/cs/tmc/ui/Bundle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,6 @@ PreferencesPanel.selectedCourseLabel.text=No course selected
9494
PreferencesPanel.loginLabel.text=Not logged in!
9595
PreferencesPanel.logoutButton.text=Logout
9696
PreferencesPanel.selectedOrganizationLabel.text=No organization selected
97+
AboutDialog.headerLabel.text=About Test My Code
98+
AboutDialog.closeButton.text=Close
99+
AboutDialog.infoTextPane.text=<html> <body> <div> Test My Code is a service designed for learning and teaching programming. It is open source, provides support for automatic assessment of programming assignments, and comes with a server that can be used to maintain course-specific point lists and grading. </div> <br> <div> Find out more at <a href="https://mooc.fi/tmc">https://mooc.fi/tmc</a>. </div> </body> </html>

0 commit comments

Comments
 (0)