1616import org .openide .awt .ActionReference ;
1717import org .openide .util .Exceptions ;
1818import org .openide .util .Lookup ;
19+ import org .openide .util .NbBundle ;
1920import org .openide .windows .TopComponent ;
2021
2122/**
2223 *
2324 * @author totetmatt
2425 */
25-
2626@ TopComponent .Description (preferredID = "BlueskyGephiMainPanel" ,
27- iconBase = "fr/totetmatt/gephi/twitter/twitterlogo.png"
28- )
29-
30-
31- @ ActionReference (path = "Menu/Window" , position = 334 )
32- @ TopComponent .OpenActionRegistration (displayName = "Bluesky Gephi" ,
33- preferredID = "MainTwitterStreamerWindow" )
27+ persistenceType = TopComponent .PERSISTENCE_ALWAYS )
28+ @ TopComponent .Registration (mode = "layoutmode" , openAtStartup = true , roles = {"overview" }, position = 2 )
3429@ ActionID (category = "Window" , id = "fr.totetmatt.blueskygephi.BlueskyGephiMainPanel" )
35- @ TopComponent .Registration (mode = "layoutmode" , openAtStartup = true , position =2 )
30+ @ ActionReference (path = "Menu/Window" , position = 334 )
31+ @ TopComponent .OpenActionRegistration (displayName = "#CTL_BlueskyGephiMainPanel" ,
32+ preferredID = "BlueskyGephiMainPanel" )
3633public class BlueskyGephiMainPanel extends TopComponent {
3734 protected static final Logger consoleLogger = Logger .getLogger (BlueskyGephiMainPanel .class .getName ());
38- private final BlueskyGephi blueskyGephi ;
35+ private static final Logger logger = Logger .getLogger (BlueskyGephiMainPanel .class .getName ());
36+ private BlueskyGephi blueskyGephi ;
3937 /**
4038 * Creates new form BlueskyGephiMainPanel
4139 */
4240 public BlueskyGephiMainPanel () {
4341 initComponents ();
44- blueskyGephi = Lookup .getDefault ().lookup (BlueskyGephi .class );
45-
42+ setName (NbBundle .getMessage (BlueskyGephiMainPanel .class , "CTL_BlueskyGephiMainPanel" ));
43+ setToolTipText (NbBundle .getMessage (BlueskyGephiMainPanel .class , "HINT_BlueskyGephiMainPanel" ));
44+ blueskyGephi = Lookup .getDefault ().lookup (BlueskyGephi .class );
45+ if (blueskyGephi == null ) {
46+ logger .warning ("BlueskyGephi service not available" );
47+ return ;
48+ }
49+ credentialsHostField .setText (blueskyGephi .getHost ());
4650 credentialsHandleField .setText (blueskyGephi .getHandle ());
4751 credentialsPasswordField .setText (blueskyGephi .getPassword ());
4852 handleSearchTextArea .setText (blueskyGephi .getQuery ());
@@ -64,6 +68,8 @@ public BlueskyGephiMainPanel() {
6468 private void initComponents () {
6569
6670 credentialsPanel = new javax .swing .JPanel ();
71+ credentialsHostLabel = new javax .swing .JLabel ();
72+ credentialsHostField = new javax .swing .JTextField ();
6773 credentialsHandleLabel = new javax .swing .JLabel ();
6874 credentialsHandleField = new javax .swing .JTextField ();
6975 credentialsPasswordLabel = new javax .swing .JLabel ();
@@ -86,6 +92,15 @@ private void initComponents() {
8692 credentialsPanel .setToolTipText (org .openide .util .NbBundle .getMessage (BlueskyGephiMainPanel .class , "BlueskyGephiMainPanel.Credentials.toolTipText" )); // NOI18N
8793 credentialsPanel .setName ("Credentials" ); // NOI18N
8894
95+ org .openide .awt .Mnemonics .setLocalizedText (credentialsHostLabel , org .openide .util .NbBundle .getMessage (BlueskyGephiMainPanel .class , "BlueskyGephiMainPanel.credentialsHostLabel.text" )); // NOI18N
96+
97+ credentialsHostField .setText (org .openide .util .NbBundle .getMessage (BlueskyGephiMainPanel .class , "BlueskyGephiMainPanel.credentialsHostField.text" )); // NOI18N
98+ credentialsHostField .addActionListener (new java .awt .event .ActionListener () {
99+ public void actionPerformed (java .awt .event .ActionEvent evt ) {
100+ credentialsHostFieldActionPerformed (evt );
101+ }
102+ });
103+
89104 org .openide .awt .Mnemonics .setLocalizedText (credentialsHandleLabel , org .openide .util .NbBundle .getMessage (BlueskyGephiMainPanel .class , "BlueskyGephiMainPanel.credentialsHandleLabel.text" )); // NOI18N
90105
91106 credentialsHandleField .setText (org .openide .util .NbBundle .getMessage (BlueskyGephiMainPanel .class , "BlueskyGephiMainPanel.credentialsHandleField.text" )); // NOI18N
@@ -122,14 +137,22 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
122137 .addComponent (credentialsHandleLabel ))
123138 .addGap (18 , 18 , 18 )
124139 .addGroup (credentialsPanelLayout .createParallelGroup (javax .swing .GroupLayout .Alignment .LEADING )
125- .addComponent (credentialsHandleField )
126- .addComponent (credentialsPasswordField ))))
140+ .addComponent (credentialsHandleField , javax .swing .GroupLayout .DEFAULT_SIZE , 263 , Short .MAX_VALUE )
141+ .addComponent (credentialsPasswordField )))
142+ .addGroup (credentialsPanelLayout .createSequentialGroup ()
143+ .addComponent (credentialsHostLabel )
144+ .addGap (43 , 43 , 43 )
145+ .addComponent (credentialsHostField , javax .swing .GroupLayout .DEFAULT_SIZE , 263 , Short .MAX_VALUE )))
127146 .addContainerGap ())
128147 );
129148 credentialsPanelLayout .setVerticalGroup (
130149 credentialsPanelLayout .createParallelGroup (javax .swing .GroupLayout .Alignment .LEADING )
131- .addGroup (credentialsPanelLayout .createSequentialGroup ()
132- .addContainerGap ()
150+ .addGroup (javax .swing .GroupLayout .Alignment .TRAILING , credentialsPanelLayout .createSequentialGroup ()
151+ .addGap (0 , 9 , Short .MAX_VALUE )
152+ .addGroup (credentialsPanelLayout .createParallelGroup (javax .swing .GroupLayout .Alignment .BASELINE )
153+ .addComponent (credentialsHostLabel )
154+ .addComponent (credentialsHostField , javax .swing .GroupLayout .PREFERRED_SIZE , javax .swing .GroupLayout .DEFAULT_SIZE , javax .swing .GroupLayout .PREFERRED_SIZE ))
155+ .addPreferredGap (javax .swing .LayoutStyle .ComponentPlacement .UNRELATED )
133156 .addGroup (credentialsPanelLayout .createParallelGroup (javax .swing .GroupLayout .Alignment .BASELINE )
134157 .addComponent (credentialsHandleLabel )
135158 .addComponent (credentialsHandleField , javax .swing .GroupLayout .PREFERRED_SIZE , javax .swing .GroupLayout .DEFAULT_SIZE , javax .swing .GroupLayout .PREFERRED_SIZE ))
@@ -138,8 +161,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
138161 .addComponent (credentialsPasswordLabel )
139162 .addComponent (credentialsPasswordField , javax .swing .GroupLayout .PREFERRED_SIZE , javax .swing .GroupLayout .DEFAULT_SIZE , javax .swing .GroupLayout .PREFERRED_SIZE ))
140163 .addPreferredGap (javax .swing .LayoutStyle .ComponentPlacement .UNRELATED )
141- .addComponent (credentialsConnectButton )
142- .addContainerGap (15 , Short .MAX_VALUE ))
164+ .addComponent (credentialsConnectButton ))
143165 );
144166
145167 handleSearchTextArea .setColumns (20 );
@@ -236,7 +258,7 @@ public void propertyChange(java.beans.PropertyChangeEvent evt) {
236258 .addComponent (jScrollPane1 , javax .swing .GroupLayout .PREFERRED_SIZE , javax .swing .GroupLayout .DEFAULT_SIZE , javax .swing .GroupLayout .PREFERRED_SIZE )
237259 .addPreferredGap (javax .swing .LayoutStyle .ComponentPlacement .RELATED )
238260 .addComponent (runFetchButton )
239- .addContainerGap (51 , Short .MAX_VALUE ))
261+ .addContainerGap (29 , Short .MAX_VALUE ))
240262 );
241263
242264 limitCrawlSpinner .getAccessibleContext ().setAccessibleDescription (org .openide .util .NbBundle .getMessage (BlueskyGephiMainPanel .class , "BlueskyGephiMainPanel.limitCrawlSpinner.AccessibleContext.accessibleDescription" )); // NOI18N
@@ -247,7 +269,7 @@ private void isFollowersActivatedActionPerformed(java.awt.event.ActionEvent evt)
247269 }//GEN-LAST:event_isFollowersActivatedActionPerformed
248270
249271 private void credentialsConnectButtonActionPerformed (java .awt .event .ActionEvent evt ) {//GEN-FIRST:event_credentialsConnectButtonActionPerformed
250- if (blueskyGephi .connect (credentialsHandleField .getText (), String .valueOf (credentialsPasswordField .getPassword ()))){
272+ if (blueskyGephi .connect (credentialsHostField . getText (), credentialsHandleField .getText (), String .valueOf (credentialsPasswordField .getPassword ()))){
251273 credentialsConnectButton .setBackground (Color .GREEN );
252274 } else {
253275 credentialsConnectButton .setBackground (Color .RED );
@@ -290,11 +312,17 @@ private void limitCrawlSpinnerPropertyChange(java.beans.PropertyChangeEvent evt)
290312 blueskyGephi .setLimitCrawl (Math .max (1 ,((int )limitCrawlSpinner .getValue ())/100 ));
291313 }//GEN-LAST:event_limitCrawlSpinnerPropertyChange
292314
315+ private void credentialsHostFieldActionPerformed (java .awt .event .ActionEvent evt ) {//GEN-FIRST:event_credentialsHostFieldActionPerformed
316+ // TODO add your handling code here:
317+ }//GEN-LAST:event_credentialsHostFieldActionPerformed
318+
293319
294320 // Variables declaration - do not modify//GEN-BEGIN:variables
295321 private javax .swing .JButton credentialsConnectButton ;
296322 private javax .swing .JTextField credentialsHandleField ;
297323 private javax .swing .JLabel credentialsHandleLabel ;
324+ private javax .swing .JTextField credentialsHostField ;
325+ private javax .swing .JLabel credentialsHostLabel ;
298326 private javax .swing .JPanel credentialsPanel ;
299327 private javax .swing .JPasswordField credentialsPasswordField ;
300328 private javax .swing .JLabel credentialsPasswordLabel ;
0 commit comments