Skip to content

Commit

Permalink
Fix Issue #605
Browse files Browse the repository at this point in the history
  • Loading branch information
eduramiba committed May 1, 2012
1 parent 8af3d3e commit f9c4a62
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 20 deletions.
2 changes: 1 addition & 1 deletion DesktopPreview/manifest.mf
Expand Up @@ -2,5 +2,5 @@ Manifest-Version: 1.0
AutoUpdate-Essential-Module: true
OpenIDE-Module: org.gephi.desktop.preview
OpenIDE-Module-Localizing-Bundle: org/gephi/desktop/preview/Bundle.properties
OpenIDE-Module-Specification-Version: 0.8.1.7
OpenIDE-Module-Specification-Version: 0.8.1.8

Expand Up @@ -47,6 +47,8 @@ Development and Distribution License("CDDL") (collectively, the
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.BorderFactory;
Expand Down Expand Up @@ -142,6 +144,14 @@ public void actionPerformed(ActionEvent e) {
this.model = m;
initTarget(model);
}

sketchPanel.addComponentListener(new ComponentAdapter() {

@Override
public void componentResized(ComponentEvent e) {
Lookup.getDefault().lookup(PreviewUIController.class).refreshPreview();
}
});
}

public void propertyChange(PropertyChangeEvent evt) {
Expand Down Expand Up @@ -257,10 +267,13 @@ public void run() {
});
}

@Override
protected void componentActivated() {
Lookup.getDefault().lookup(PreviewUIController.class).refreshPreview();
}

/**
* 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.
* 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.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
Expand Down
Expand Up @@ -170,8 +170,7 @@ public void disable() {
}

/**
* Shows the refresh notification when the structure of the workspace graph
* has changed.
* Shows the refresh notification when the structure of the workspace graph has changed.
*
* @param event
* @see GraphListener#graphChanged(org.gephi.graph.api.GraphEvent)
Expand All @@ -188,23 +187,25 @@ public void graphChanged(GraphEvent event) {
* Refreshes the preview applet.
*/
public void refreshPreview() {
Thread refreshThread = new Thread(new Runnable() {
if (model != null) {
Thread refreshThread = new Thread(new Runnable() {

public void run() {
model.setRefreshing(true);
fireEvent(REFRESHING, true);
public void run() {
model.setRefreshing(true);
fireEvent(REFRESHING, true);

previewController.getModel().getProperties().putValue(PreviewProperty.VISIBILITY_RATIO, model.getVisibilityRatio());
previewController.refreshPreview();
previewController.getModel().getProperties().putValue(PreviewProperty.VISIBILITY_RATIO, model.getVisibilityRatio());
previewController.refreshPreview();

fireEvent(REFRESHED, model);
fireEvent(REFRESHED, model);

model.setRefreshing(false);
fireEvent(REFRESHING, false);
fireEvent(GRAPH_CHANGED, false);
}
}, "Refresh Preview");
refreshThread.start();
model.setRefreshing(false);
fireEvent(REFRESHING, false);
fireEvent(GRAPH_CHANGED, false);
}
}, "Refresh Preview");
refreshThread.start();
}
}

/**
Expand Down Expand Up @@ -259,7 +260,7 @@ public void savePreset(String name) {
for (PreviewProperty p : previewModel.getProperties().getProperties()) {
map.put(p.getName(), p.getValue());
}
for(Entry<String,Object> p:previewModel.getProperties().getSimpleValues()){
for (Entry<String, Object> p : previewModel.getProperties().getSimpleValues()) {
map.put(p.getKey(), p.getValue());
}
PreviewPreset preset = new PreviewPreset(name, map);
Expand Down

0 comments on commit f9c4a62

Please sign in to comment.