Skip to content

Commit 61700da

Browse files
authored
Merge pull request #332 from totetmatt/blueskyGephi
New Version of BlueskyGephi
2 parents 8b2b659 + 98491fc commit 61700da

10 files changed

Lines changed: 102 additions & 39 deletions

File tree

modules/BlueskyGephi/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
<groupId>fr.totetmatt</groupId>
1111
<artifactId>bluesky-gephi</artifactId>
12-
<version>0.1.0</version>
12+
<version>0.2.1</version>
1313
<packaging>nbm</packaging>
1414

1515
<name>Bluesky Gephi</name>

modules/BlueskyGephi/src/main/java/fr/totetmatt/blueskygephi/BlueskyGephi.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public class BlueskyGephi {
3838
protected static final Logger logger = Logger.getLogger(BlueskyGephi.class.getName());
3939
private final static String NBPREF_BSKY_HANDLE = "bsky.handle";
4040
private final static String NBPREF_BSKY_PASSWORD = "bsky.password";
41+
private final static String NBPREF_ATPROTO_HOST ="bsky.social";
4142
private final static String NBPREF_QUERY = "query";
4243
private final static String NBPREF_QUERY_ISFOLLOWERSACTIVE = "query.isFollowersActive";
4344
private final static String NBPREF_QUERY_ISFOLLOWSACTIVE = "query.isFollowsActive";
@@ -46,31 +47,33 @@ public class BlueskyGephi {
4647
private final static String NBPREF_QUERY_LIMITCRAWL = "query.limitCrawl";
4748

4849
private final Preferences nbPref = NbPreferences.forModule(BlueskyGephi.class);
49-
// If ATProto get released and decentralized, this will change to adapt to other instances
50-
final private AtClient client = new AtClient("bsky.social");
50+
51+
private AtClient client;
5152
private GraphModel graphModel;
5253

5354
public BlueskyGephi() {
54-
initProjectAndWorkspace();
55-
5655
}
5756

58-
private void initProjectAndWorkspace() {
57+
private void ensureProject() {
5958
ProjectController projectController = Lookup.getDefault().lookup(ProjectController.class);
6059
Project currentProject = projectController.getCurrentProject();
6160
if (currentProject == null) {
6261
projectController.newProject();
6362
}
6463
}
6564

66-
public boolean connect(String handle, String password) {
65+
public boolean connect(String host,String handle, String password) {
6766
nbPref.put(NBPREF_BSKY_HANDLE, handle);
6867
nbPref.put(NBPREF_BSKY_PASSWORD, password);
68+
nbPref.put(NBPREF_ATPROTO_HOST,host);
6969

70+
client = new AtClient(host);
7071
return client.comAtprotoServerCreateSession(handle, password);
7172

7273
}
73-
74+
public String getHost(){
75+
return nbPref.get(NBPREF_ATPROTO_HOST,"bsky.social");
76+
}
7477
public String getHandle() {
7578
return nbPref.get(NBPREF_BSKY_HANDLE, "");
7679
}
@@ -270,12 +273,14 @@ private void initGraphTable() {
270273
}
271274

272275
public void fetchFollowerFollowsFromActors(List<String> actors, boolean isFollowsActive, boolean isFollowersActive, boolean isBlocksActive) {
276+
ensureProject();
273277
graphModel = Lookup.getDefault().lookup(GraphController.class).getGraphModel();
274278
initGraphTable();
275279
actors.stream().forEach(actor -> fetchFollowerFollowsFromActor(actor, null, isFollowsActive, isFollowersActive, getIsDeepSearch()));
276280
}
277281

278282
public void fetchFollowerFollowsFromActors(List<String> actors) {
283+
ensureProject();
279284
graphModel = Lookup.getDefault().lookup(GraphController.class).getGraphModel();
280285
initGraphTable();
281286
actors

modules/BlueskyGephi/src/main/java/fr/totetmatt/blueskygephi/BlueskyGephiMainPanel.form

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
<Component id="jScrollPane1" min="-2" max="-2" attributes="0"/>
7272
<EmptySpace max="-2" attributes="0"/>
7373
<Component id="runFetchButton" min="-2" max="-2" attributes="0"/>
74-
<EmptySpace pref="51" max="32767" attributes="0"/>
74+
<EmptySpace pref="29" max="32767" attributes="0"/>
7575
</Group>
7676
</Group>
7777
</DimensionLayout>
@@ -95,7 +95,7 @@
9595
<Layout>
9696
<DimensionLayout dim="0">
9797
<Group type="103" groupAlignment="0" attributes="0">
98-
<Group type="102" alignment="0" attributes="0">
98+
<Group type="102" attributes="0">
9999
<EmptySpace max="-2" attributes="0"/>
100100
<Group type="103" groupAlignment="0" attributes="0">
101101
<Component id="credentialsConnectButton" max="32767" attributes="0"/>
@@ -106,19 +106,29 @@
106106
</Group>
107107
<EmptySpace type="separate" max="-2" attributes="0"/>
108108
<Group type="103" groupAlignment="0" attributes="0">
109-
<Component id="credentialsHandleField" max="32767" attributes="0"/>
109+
<Component id="credentialsHandleField" pref="263" max="32767" attributes="0"/>
110110
<Component id="credentialsPasswordField" max="32767" attributes="0"/>
111111
</Group>
112112
</Group>
113+
<Group type="102" alignment="0" attributes="0">
114+
<Component id="credentialsHostLabel" min="-2" max="-2" attributes="0"/>
115+
<EmptySpace min="-2" pref="43" max="-2" attributes="0"/>
116+
<Component id="credentialsHostField" pref="263" max="32767" attributes="0"/>
117+
</Group>
113118
</Group>
114119
<EmptySpace max="-2" attributes="0"/>
115120
</Group>
116121
</Group>
117122
</DimensionLayout>
118123
<DimensionLayout dim="1">
119124
<Group type="103" groupAlignment="0" attributes="0">
120-
<Group type="102" alignment="0" attributes="0">
121-
<EmptySpace max="-2" attributes="0"/>
125+
<Group type="102" alignment="1" attributes="0">
126+
<EmptySpace min="0" pref="9" max="32767" attributes="0"/>
127+
<Group type="103" groupAlignment="3" attributes="0">
128+
<Component id="credentialsHostLabel" alignment="3" min="-2" max="-2" attributes="0"/>
129+
<Component id="credentialsHostField" alignment="3" min="-2" max="-2" attributes="0"/>
130+
</Group>
131+
<EmptySpace type="unrelated" max="-2" attributes="0"/>
122132
<Group type="103" groupAlignment="3" attributes="0">
123133
<Component id="credentialsHandleLabel" alignment="3" min="-2" max="-2" attributes="0"/>
124134
<Component id="credentialsHandleField" alignment="3" min="-2" max="-2" attributes="0"/>
@@ -130,12 +140,28 @@
130140
</Group>
131141
<EmptySpace type="unrelated" max="-2" attributes="0"/>
132142
<Component id="credentialsConnectButton" min="-2" max="-2" attributes="0"/>
133-
<EmptySpace pref="15" max="32767" attributes="0"/>
134143
</Group>
135144
</Group>
136145
</DimensionLayout>
137146
</Layout>
138147
<SubComponents>
148+
<Component class="javax.swing.JLabel" name="credentialsHostLabel">
149+
<Properties>
150+
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
151+
<ResourceString bundle="fr/totetmatt/blueskygephi/Bundle.properties" key="BlueskyGephiMainPanel.credentialsHostLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
152+
</Property>
153+
</Properties>
154+
</Component>
155+
<Component class="javax.swing.JTextField" name="credentialsHostField">
156+
<Properties>
157+
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
158+
<ResourceString bundle="fr/totetmatt/blueskygephi/Bundle.properties" key="BlueskyGephiMainPanel.credentialsHostField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
159+
</Property>
160+
</Properties>
161+
<Events>
162+
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="credentialsHostFieldActionPerformed"/>
163+
</Events>
164+
</Component>
139165
<Component class="javax.swing.JLabel" name="credentialsHandleLabel">
140166
<Properties>
141167
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">

modules/BlueskyGephi/src/main/java/fr/totetmatt/blueskygephi/BlueskyGephiMainPanel.java

Lines changed: 48 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,37 @@
1616
import org.openide.awt.ActionReference;
1717
import org.openide.util.Exceptions;
1818
import org.openide.util.Lookup;
19+
import org.openide.util.NbBundle;
1920
import 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")
3633
public 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;

modules/BlueskyGephi/src/main/resources/fr/totetmatt/blueskygephi/Bundle.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
CTL_BlueskyGephiMainPanel=Bluesky Gephi
2+
HINT_BlueskyGephiMainPanel=Import network from Bluesky / AtProtocol
13
BlueskyGephiMainPanel.toolTipText=Bluesky Gephi
24
BlueskyGephiMainPanel.Credentials.toolTipText=Credentials
35
BlueskyGephiMainPanel.credentialsPanel.border.title=Credentials
@@ -14,3 +16,5 @@ BlueskyGephiMainPanel.isDeepSearch.text=Fetch also n+1
1416
BlueskyGephiMainPanel.limitCrawlCheckbox.text=Crawl Limit
1517
BlueskyGephiMainPanel.limitCrawlSpinner.AccessibleContext.accessibleDescription=
1618
BlueskyGephiMainPanel.limitCrawlSpinner.toolTipText=Nb Follower / Following to fetch max on a n+1 crawl
19+
BlueskyGephiMainPanel.credentialsHostLabel.text=Host
20+
BlueskyGephiMainPanel.credentialsHostField.text=

modules/Export-To-Earth/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
<dependency>
4848
<groupId>junit</groupId>
4949
<artifactId>junit</artifactId>
50-
<version>4.11</version>
50+
<version>4.13.2</version>
5151
<scope>test</scope>
5252
</dependency>
5353
</dependencies>

modules/MinimumSpanningTree/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<dependency>
5252
<groupId>junit</groupId>
5353
<artifactId>junit</artifactId>
54-
<version>4.10</version>
54+
<version>4.13.2</version>
5555
<scope>test</scope>
5656
</dependency>
5757
<dependency>

modules/StreamingImpl/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<dependency>
4545
<groupId>junit</groupId>
4646
<artifactId>junit</artifactId>
47-
<version>4.10</version>
47+
<version>4.13.2</version>
4848
<scope>test</scope>
4949
</dependency>
5050
</dependencies>

modules/StreamingServer/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<dependency>
5151
<groupId>junit</groupId>
5252
<artifactId>junit</artifactId>
53-
<version>4.10</version>
53+
<version>4.13.2</version>
5454
<scope>test</scope>
5555
</dependency>
5656
</dependencies>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
<!-- Needs to migrate to new Visualization API -->
8686
<!-- <module>modules/WordCloudPlugin</module>-->
8787
<!-- Needs to not create a project at start-->
88-
<!-- <module>modules/BlueskyGephi</module>-->
88+
<module>modules/BlueskyGephi</module>
8989
</modules>
9090

9191
<!-- Properties -->

0 commit comments

Comments
 (0)