Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/BlueskyGephi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<groupId>fr.totetmatt</groupId>
<artifactId>bluesky-gephi</artifactId>
<version>0.1.0</version>
<version>0.2.1</version>
<packaging>nbm</packaging>

<name>Bluesky Gephi</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class BlueskyGephi {
protected static final Logger logger = Logger.getLogger(BlueskyGephi.class.getName());
private final static String NBPREF_BSKY_HANDLE = "bsky.handle";
private final static String NBPREF_BSKY_PASSWORD = "bsky.password";
private final static String NBPREF_ATPROTO_HOST ="bsky.social";
private final static String NBPREF_QUERY = "query";
private final static String NBPREF_QUERY_ISFOLLOWERSACTIVE = "query.isFollowersActive";
private final static String NBPREF_QUERY_ISFOLLOWSACTIVE = "query.isFollowsActive";
Expand All @@ -46,31 +47,33 @@ public class BlueskyGephi {
private final static String NBPREF_QUERY_LIMITCRAWL = "query.limitCrawl";

private final Preferences nbPref = NbPreferences.forModule(BlueskyGephi.class);
// If ATProto get released and decentralized, this will change to adapt to other instances
final private AtClient client = new AtClient("bsky.social");

private AtClient client;
private GraphModel graphModel;

public BlueskyGephi() {
initProjectAndWorkspace();

}

private void initProjectAndWorkspace() {
private void ensureProject() {
ProjectController projectController = Lookup.getDefault().lookup(ProjectController.class);
Project currentProject = projectController.getCurrentProject();
if (currentProject == null) {
projectController.newProject();
}
}

public boolean connect(String handle, String password) {
public boolean connect(String host,String handle, String password) {
nbPref.put(NBPREF_BSKY_HANDLE, handle);
nbPref.put(NBPREF_BSKY_PASSWORD, password);
nbPref.put(NBPREF_ATPROTO_HOST,host);

client = new AtClient(host);
return client.comAtprotoServerCreateSession(handle, password);

}

public String getHost(){
return nbPref.get(NBPREF_ATPROTO_HOST,"bsky.social");
}
public String getHandle() {
return nbPref.get(NBPREF_BSKY_HANDLE, "");
}
Expand Down Expand Up @@ -270,12 +273,14 @@ private void initGraphTable() {
}

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

public void fetchFollowerFollowsFromActors(List<String> actors) {
ensureProject();
graphModel = Lookup.getDefault().lookup(GraphController.class).getGraphModel();
initGraphTable();
actors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<Component id="jScrollPane1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="runFetchButton" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="51" max="32767" attributes="0"/>
<EmptySpace pref="29" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
Expand All @@ -95,7 +95,7 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="credentialsConnectButton" max="32767" attributes="0"/>
Expand All @@ -106,19 +106,29 @@
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="credentialsHandleField" max="32767" attributes="0"/>
<Component id="credentialsHandleField" pref="263" max="32767" attributes="0"/>
<Component id="credentialsPasswordField" max="32767" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="credentialsHostLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="43" max="-2" attributes="0"/>
<Component id="credentialsHostField" pref="263" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="9" max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="credentialsHostLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="credentialsHostField" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="credentialsHandleLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="credentialsHandleField" alignment="3" min="-2" max="-2" attributes="0"/>
Expand All @@ -130,12 +140,28 @@
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="credentialsConnectButton" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="15" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="credentialsHostLabel">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="fr/totetmatt/blueskygephi/Bundle.properties" key="BlueskyGephiMainPanel.credentialsHostLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="credentialsHostField">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="fr/totetmatt/blueskygephi/Bundle.properties" key="BlueskyGephiMainPanel.credentialsHostField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="credentialsHostFieldActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="credentialsHandleLabel">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,37 @@
import org.openide.awt.ActionReference;
import org.openide.util.Exceptions;
import org.openide.util.Lookup;
import org.openide.util.NbBundle;
import org.openide.windows.TopComponent;

/**
*
* @author totetmatt
*/

@TopComponent.Description(preferredID = "BlueskyGephiMainPanel",
iconBase = "fr/totetmatt/gephi/twitter/twitterlogo.png"
)


@ActionReference(path = "Menu/Window", position = 334)
@TopComponent.OpenActionRegistration(displayName = "Bluesky Gephi",
preferredID = "MainTwitterStreamerWindow")
persistenceType = TopComponent.PERSISTENCE_ALWAYS)
@TopComponent.Registration(mode = "layoutmode", openAtStartup = true, roles = {"overview"}, position = 2)
@ActionID(category = "Window", id = "fr.totetmatt.blueskygephi.BlueskyGephiMainPanel")
@TopComponent.Registration(mode = "layoutmode", openAtStartup = true, position=2)
@ActionReference(path = "Menu/Window", position = 334)
@TopComponent.OpenActionRegistration(displayName = "#CTL_BlueskyGephiMainPanel",
preferredID = "BlueskyGephiMainPanel")
public class BlueskyGephiMainPanel extends TopComponent {
protected static final Logger consoleLogger = Logger.getLogger(BlueskyGephiMainPanel.class.getName());
private final BlueskyGephi blueskyGephi;
private static final Logger logger = Logger.getLogger(BlueskyGephiMainPanel.class.getName());
private BlueskyGephi blueskyGephi;
/**
* Creates new form BlueskyGephiMainPanel
*/
public BlueskyGephiMainPanel() {
initComponents();
blueskyGephi = Lookup.getDefault().lookup(BlueskyGephi.class);

setName(NbBundle.getMessage(BlueskyGephiMainPanel.class, "CTL_BlueskyGephiMainPanel"));
setToolTipText(NbBundle.getMessage(BlueskyGephiMainPanel.class, "HINT_BlueskyGephiMainPanel"));
blueskyGephi = Lookup.getDefault().lookup(BlueskyGephi.class);
if (blueskyGephi == null) {
logger.warning("BlueskyGephi service not available");
return;
}
credentialsHostField.setText(blueskyGephi.getHost());
credentialsHandleField.setText(blueskyGephi.getHandle());
credentialsPasswordField.setText(blueskyGephi.getPassword());
handleSearchTextArea.setText(blueskyGephi.getQuery());
Expand All @@ -64,6 +68,8 @@ public BlueskyGephiMainPanel() {
private void initComponents() {

credentialsPanel = new javax.swing.JPanel();
credentialsHostLabel = new javax.swing.JLabel();
credentialsHostField = new javax.swing.JTextField();
credentialsHandleLabel = new javax.swing.JLabel();
credentialsHandleField = new javax.swing.JTextField();
credentialsPasswordLabel = new javax.swing.JLabel();
Expand All @@ -86,6 +92,15 @@ private void initComponents() {
credentialsPanel.setToolTipText(org.openide.util.NbBundle.getMessage(BlueskyGephiMainPanel.class, "BlueskyGephiMainPanel.Credentials.toolTipText")); // NOI18N
credentialsPanel.setName("Credentials"); // NOI18N

org.openide.awt.Mnemonics.setLocalizedText(credentialsHostLabel, org.openide.util.NbBundle.getMessage(BlueskyGephiMainPanel.class, "BlueskyGephiMainPanel.credentialsHostLabel.text")); // NOI18N

credentialsHostField.setText(org.openide.util.NbBundle.getMessage(BlueskyGephiMainPanel.class, "BlueskyGephiMainPanel.credentialsHostField.text")); // NOI18N
credentialsHostField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
credentialsHostFieldActionPerformed(evt);
}
});

org.openide.awt.Mnemonics.setLocalizedText(credentialsHandleLabel, org.openide.util.NbBundle.getMessage(BlueskyGephiMainPanel.class, "BlueskyGephiMainPanel.credentialsHandleLabel.text")); // NOI18N

credentialsHandleField.setText(org.openide.util.NbBundle.getMessage(BlueskyGephiMainPanel.class, "BlueskyGephiMainPanel.credentialsHandleField.text")); // NOI18N
Expand Down Expand Up @@ -122,14 +137,22 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
.addComponent(credentialsHandleLabel))
.addGap(18, 18, 18)
.addGroup(credentialsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(credentialsHandleField)
.addComponent(credentialsPasswordField))))
.addComponent(credentialsHandleField, javax.swing.GroupLayout.DEFAULT_SIZE, 263, Short.MAX_VALUE)
.addComponent(credentialsPasswordField)))
.addGroup(credentialsPanelLayout.createSequentialGroup()
.addComponent(credentialsHostLabel)
.addGap(43, 43, 43)
.addComponent(credentialsHostField, javax.swing.GroupLayout.DEFAULT_SIZE, 263, Short.MAX_VALUE)))
.addContainerGap())
);
credentialsPanelLayout.setVerticalGroup(
credentialsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(credentialsPanelLayout.createSequentialGroup()
.addContainerGap()
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, credentialsPanelLayout.createSequentialGroup()
.addGap(0, 9, Short.MAX_VALUE)
.addGroup(credentialsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(credentialsHostLabel)
.addComponent(credentialsHostField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(credentialsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(credentialsHandleLabel)
.addComponent(credentialsHandleField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
Expand All @@ -138,8 +161,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
.addComponent(credentialsPasswordLabel)
.addComponent(credentialsPasswordField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(credentialsConnectButton)
.addContainerGap(15, Short.MAX_VALUE))
.addComponent(credentialsConnectButton))
);

handleSearchTextArea.setColumns(20);
Expand Down Expand Up @@ -236,7 +258,7 @@ public void propertyChange(java.beans.PropertyChangeEvent evt) {
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(runFetchButton)
.addContainerGap(51, Short.MAX_VALUE))
.addContainerGap(29, Short.MAX_VALUE))
);

limitCrawlSpinner.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BlueskyGephiMainPanel.class, "BlueskyGephiMainPanel.limitCrawlSpinner.AccessibleContext.accessibleDescription")); // NOI18N
Expand All @@ -247,7 +269,7 @@ private void isFollowersActivatedActionPerformed(java.awt.event.ActionEvent evt)
}//GEN-LAST:event_isFollowersActivatedActionPerformed

private void credentialsConnectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_credentialsConnectButtonActionPerformed
if(blueskyGephi.connect(credentialsHandleField.getText(), String.valueOf(credentialsPasswordField.getPassword()))){
if(blueskyGephi.connect(credentialsHostField.getText(), credentialsHandleField.getText(), String.valueOf(credentialsPasswordField.getPassword()))){
credentialsConnectButton.setBackground(Color.GREEN);
} else {
credentialsConnectButton.setBackground(Color.RED);
Expand Down Expand Up @@ -290,11 +312,17 @@ private void limitCrawlSpinnerPropertyChange(java.beans.PropertyChangeEvent evt)
blueskyGephi.setLimitCrawl(Math.max(1,((int)limitCrawlSpinner.getValue())/100));
}//GEN-LAST:event_limitCrawlSpinnerPropertyChange

private void credentialsHostFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_credentialsHostFieldActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_credentialsHostFieldActionPerformed


// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton credentialsConnectButton;
private javax.swing.JTextField credentialsHandleField;
private javax.swing.JLabel credentialsHandleLabel;
private javax.swing.JTextField credentialsHostField;
private javax.swing.JLabel credentialsHostLabel;
private javax.swing.JPanel credentialsPanel;
private javax.swing.JPasswordField credentialsPasswordField;
private javax.swing.JLabel credentialsPasswordLabel;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
CTL_BlueskyGephiMainPanel=Bluesky Gephi
HINT_BlueskyGephiMainPanel=Import network from Bluesky / AtProtocol
BlueskyGephiMainPanel.toolTipText=Bluesky Gephi
BlueskyGephiMainPanel.Credentials.toolTipText=Credentials
BlueskyGephiMainPanel.credentialsPanel.border.title=Credentials
Expand All @@ -14,3 +16,5 @@ BlueskyGephiMainPanel.isDeepSearch.text=Fetch also n+1
BlueskyGephiMainPanel.limitCrawlCheckbox.text=Crawl Limit
BlueskyGephiMainPanel.limitCrawlSpinner.AccessibleContext.accessibleDescription=
BlueskyGephiMainPanel.limitCrawlSpinner.toolTipText=Nb Follower / Following to fetch max on a n+1 crawl
BlueskyGephiMainPanel.credentialsHostLabel.text=Host
BlueskyGephiMainPanel.credentialsHostField.text=
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
<!-- Needs to migrate to new Visualization API -->
<!-- <module>modules/WordCloudPlugin</module>-->
<!-- Needs to not create a project at start-->
<!-- <module>modules/BlueskyGephi</module>-->
<module>modules/BlueskyGephi</module>
</modules>

<!-- Properties -->
Expand Down
Loading