com.github.andy2003.ui.startpage.StartPageTopComponent Maven / Gradle / Ivy
package com.github.andy2003.ui.startpage;
import com.github.andy2003.ui.options.Options;
import org.netbeans.api.settings.ConvertAsProperties;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.util.NbBundle;
import org.openide.windows.TopComponent;
@ConvertAsProperties(dtd = "-//com.github.andy2003.ui.startpage//StartPage//EN", autostore = false)
@TopComponent.Description(preferredID = "StartPageTopComponent",
iconBase="org/tango-project/tango-icon-theme/16x16/mimetypes/text-x-generic.png",
persistenceType = TopComponent.PERSISTENCE_ONLY_OPENED)
@TopComponent.Registration(mode = "editor", openAtStartup = true)
@ActionID(category = "Window", id = "StartPageTopComponent")
@ActionReference(path = "Menu/Window" , position = 10 )
@TopComponent.OpenActionRegistration(displayName = "#CTL_StartPageTopComponent",
preferredID = "StartPageTopTopComponent")
public final class StartPageTopComponent extends TopComponent {
public static boolean firstTimeOpen = true;
public StartPageTopComponent() {
initComponents();
setName(NbBundle.getMessage(StartPageTopComponent.class, "CTL_StartPageTopComponent"));
setToolTipText(NbBundle.getMessage(StartPageTopComponent.class, "HINT_StartPageTopComponent"));
putClientProperty(TopComponent.PROP_DRAGGING_DISABLED, Boolean.TRUE);
putClientProperty(TopComponent.PROP_UNDOCKING_DISABLED, Boolean.TRUE);
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// //GEN-BEGIN:initComponents
private void initComponents() {
jScrollPane2 = new javax.swing.JScrollPane();
jTextPane1 = new javax.swing.JTextPane();
jCheckBox1 = new javax.swing.JCheckBox();
setLayout(new java.awt.BorderLayout(20, 20));
jScrollPane2.setBorder(null);
jTextPane1.setBorder(null);
jTextPane1.setContentType(org.openide.util.NbBundle.getMessage(StartPageTopComponent.class, "StartPageTopComponent.jTextPane1.contentType")); // NOI18N
jTextPane1.setEditable(false);
jTextPane1.setFont(jTextPane1.getFont());
jTextPane1.setText(org.openide.util.NbBundle.getMessage(StartPageTopComponent.class, "StartPageTopComponent.jTextPane1.text")); // NOI18N
jTextPane1.setToolTipText(org.openide.util.NbBundle.getMessage(StartPageTopComponent.class, "StartPageTopComponent.jTextPane1.toolTipText")); // NOI18N
jScrollPane2.setViewportView(jTextPane1);
add(jScrollPane2, java.awt.BorderLayout.CENTER);
org.openide.awt.Mnemonics.setLocalizedText(jCheckBox1, org.openide.util.NbBundle.getMessage(StartPageTopComponent.class, "StartPageTopComponent.jCheckBox1.text")); // NOI18N
jCheckBox1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jCheckBox1ActionPerformed(evt);
}
});
add(jCheckBox1, java.awt.BorderLayout.PAGE_END);
}// //GEN-END:initComponents
private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox1ActionPerformed
if(jCheckBox1.isSelected())
Options.setShowStartPage(false);
else
Options.setShowStartPage(true);
}//GEN-LAST:event_jCheckBox1ActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JCheckBox jCheckBox1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JTextPane jTextPane1;
// End of variables declaration//GEN-END:variables
@Override
public void componentOpened() {
if(firstTimeOpen) {
firstTimeOpen = false;
if(!Options.getShowStartPage()) {
close();
}
}
jCheckBox1.setSelected(!Options.getShowStartPage());
}
@Override
public void componentClosed() {
}
void writeProperties(java.util.Properties p) {
// better to version settings since initial version as advocated at
// http://wiki.apidesign.org/wiki/PropertyFiles
p.setProperty("version", "1.0");
}
void readProperties(java.util.Properties p) {
}
}