Merge branch 'master' into 0.8.1

Esse commit está contido em:
Eduardo Ramos
2012-09-25 21:37:50 +02:00
6 arquivos alterados com 130 adições e 113 exclusões
+1 -1
Ver Arquivo
@@ -2,4 +2,4 @@ Manifest-Version: 1.0
AutoUpdate-Essential-Module: true
OpenIDE-Module: org.gephi.desktop.datalab
OpenIDE-Module-Localizing-Bundle: org/gephi/desktop/datalab/Bundle.properties
OpenIDE-Module-Specification-Version: 0.8.1.2
OpenIDE-Module-Specification-Version: 0.8.1.3
@@ -58,7 +58,6 @@ import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import org.gephi.data.attributes.api.AttributeEvent.EventType;
import org.gephi.data.attributes.api.*;
import org.gephi.datalab.api.DataLaboratoryHelper;
import org.gephi.datalab.api.datatables.DataTablesController;
@@ -107,7 +106,7 @@ persistenceType = TopComponent.PERSISTENCE_ALWAYS)
@ActionReference(path = "Menu/Window", position = 300)
@TopComponent.OpenActionRegistration(displayName = "#CTL_DataTableTopComponent",
preferredID = "DataTableTopComponent")
public class DataTableTopComponent extends TopComponent implements AWTEventListener, DataTablesEventListener, AttributeListener, GraphListener {
public class DataTableTopComponent extends TopComponent implements AWTEventListener, DataTablesEventListener, GraphListener {
private enum ClassDisplayed {
@@ -170,7 +169,6 @@ public class DataTableTopComponent extends TopComponent implements AWTEventListe
controlToolbar.setBackground(UIManager.getColor("NbExplorerView.background"));
}
initEvents();
//Init tables
nodeTable = new NodeDataTable();
@@ -182,23 +180,22 @@ public class DataTableTopComponent extends TopComponent implements AWTEventListe
edgeTable.setTimeIntervalGraphics(timeIntervalGraphics);
edgeTable.setShowEdgesNodesLabels(showEdgesNodesLabels);
//Init
ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);
Workspace workspace = pc.getCurrentWorkspace();
if (workspace == null) {
clearAll();
} else {
AttributeModel attributeModel = Lookup.getDefault().lookup(AttributeController.class).getModel();
dataTablesModel = workspace.getLookup().lookup(DataTablesModel.class);
if (dataTablesModel == null) {
workspace.add(dataTablesModel = new DataTablesModel(attributeModel.getNodeTable(), attributeModel.getEdgeTable()));
workspace.add(dataTablesModel = new DataTablesModel(workspace));
}
nodeAvailableColumnsModel = dataTablesModel.getNodeAvailableColumnsModel();
edgeAvailableColumnsModel = dataTablesModel.getEdgeAvailableColumnsModel();
refreshAllOnce();
}
initEvents();
bannerPanel.setVisible(false);
}
@@ -212,24 +209,21 @@ public class DataTableTopComponent extends TopComponent implements AWTEventListe
public void initialize(Workspace workspace) {
//Prepare DataTablesEvent listener
Lookup.getDefault().lookup(DataTablesController.class).setDataTablesEventListener(DataTableTopComponent.this);
if (workspace.getLookup().lookup(DataTablesModel.class) == null) {
workspace.add(new DataTablesModel(workspace));
}
}
public void select(Workspace workspace) {
//Prepare DataTablesEvent listener
Lookup.getDefault().lookup(DataTablesController.class).setDataTablesEventListener(DataTableTopComponent.this);
AttributeModel attributeModel = Lookup.getDefault().lookup(AttributeController.class).getModel();
dataTablesModel = workspace.getLookup().lookup(DataTablesModel.class);
if (dataTablesModel == null) {
workspace.add(dataTablesModel = new DataTablesModel(attributeModel.getNodeTable(), attributeModel.getEdgeTable()));
}
nodeAvailableColumnsModel = dataTablesModel.getNodeAvailableColumnsModel();
edgeAvailableColumnsModel = dataTablesModel.getEdgeAvailableColumnsModel();
hideTable();
enableTableControls();
attributeModel.addAttributeListener(DataTableTopComponent.this);
graphModel = gc.getModel();
graphModel.addGraphListener(DataTableTopComponent.this);
@@ -238,9 +232,7 @@ public class DataTableTopComponent extends TopComponent implements AWTEventListe
public void unselect(Workspace workspace) {
graphModel.removeGraphListener(DataTableTopComponent.this);
AttributeModel attributeModel = workspace.getLookup().lookup(AttributeModel.class);
attributeModel.removeAttributeListener(DataTableTopComponent.this);
graphModel = null;
dataTablesModel = null;
nodeAvailableColumnsModel = null;
@@ -260,12 +252,8 @@ public class DataTableTopComponent extends TopComponent implements AWTEventListe
if (pc.getCurrentWorkspace() != null) {
//Prepare DataTablesEvent listener
Lookup.getDefault().lookup(DataTablesController.class).setDataTablesEventListener(DataTableTopComponent.this);
dataTablesModel = pc.getCurrentWorkspace().getLookup().lookup(DataTablesModel.class);
graphModel = gc.getModel();
graphModel.addGraphListener(DataTableTopComponent.this);
AttributeModel attributeModel = pc.getCurrentWorkspace().getLookup().lookup(AttributeModel.class);
attributeModel.addAttributeListener(DataTableTopComponent.this);
}
//Filter
@@ -351,42 +339,6 @@ public class DataTableTopComponent extends TopComponent implements AWTEventListe
}
}
public void attributesChanged(final AttributeEvent event) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
AttributeTable table = event.getSource();
AvailableColumnsModel tableAvailableColumnsModel = getTableAvailableColumnsModel(table);
if (tableAvailableColumnsModel != null) {
switch (event.getEventType()) {
case ADD_COLUMN:
for (AttributeColumn c : event.getData().getAddedColumns()) {
if (!tableAvailableColumnsModel.addAvailableColumn(c)) {//Add as available by default. Will only be added if the max number of available columns is not surpassed
availableColumnsButton.setIcon(ImageUtilities.loadImageIcon("org/gephi/desktop/datalab/resources/light-bulb--plus.png", true));
break;
}
}
break;
case REMOVE_COLUMN:
for (AttributeColumn c : event.getData().getAddedColumns()) {
tableAvailableColumnsModel.removeAvailableColumn(c);
}
break;
case REPLACE_COLUMN:
for (AttributeColumn c : event.getData().getRemovedColumns()) {
tableAvailableColumnsModel.removeAvailableColumn(c);
tableAvailableColumnsModel.addAvailableColumn(table.getColumn(c.getId()));
}
break;
}
}
if (isOpened()) {
refreshOnce(event.is(EventType.SET_VALUE));
}
}
});
}
public void graphChanged(GraphEvent event) {
SwingUtilities.invokeLater(new Runnable() {
@@ -442,18 +394,32 @@ public class DataTableTopComponent extends TopComponent implements AWTEventListe
previousEdgeColumnsFilterIndex = index;
}
}
private void refreshAvailableColumnsButton(AvailableColumnsModel availableColumnsModel, AttributeTable table){
if(table.countColumns() > availableColumnsModel.getAvailableColumnsCount()){
availableColumnsButton.setIcon(ImageUtilities.loadImageIcon("org/gephi/desktop/datalab/resources/light-bulb--plus.png", true));
}else{
availableColumnsButton.setIcon(ImageUtilities.loadImageIcon("org/gephi/desktop/datalab/resources/light-bulb.png", true));
}
}
private void initNodesView() {
Runnable initNodesRunnable = new Runnable() {
public void run() {
try {
if(dataTablesModel == null){
return;
}
String busyMsg = NbBundle.getMessage(DataTableTopComponent.class, "DataTableTopComponent.tableScrollPane.busyMessage");
BusyUtils.BusyLabel busylabel = BusyUtils.createCenteredBusyLabel(tableScrollPane, busyMsg, nodeTable.getOutlineTable());
busylabel.setBusy(true);
//Attributes columns
final AttributeColumn[] cols = nodeAvailableColumnsModel.getAvailableColumns();
refreshAvailableColumnsButton(nodeAvailableColumnsModel, Lookup.getDefault().lookup(AttributeController.class).getModel().getNodeTable());
//Nodes from DHNS
HierarchicalGraph graph;
@@ -488,12 +454,18 @@ public class DataTableTopComponent extends TopComponent implements AWTEventListe
public void run() {
try {
if(dataTablesModel == null){
return;
}
String busyMsg = NbBundle.getMessage(DataTableTopComponent.class, "DataTableTopComponent.tableScrollPane.busyMessage");
BusyUtils.BusyLabel busylabel = BusyUtils.createCenteredBusyLabel(tableScrollPane, busyMsg, edgeTable.getTable());
busylabel.setBusy(true);
//Attributes columns
final AttributeColumn[] cols = edgeAvailableColumnsModel.getAvailableColumns();
refreshAvailableColumnsButton(edgeAvailableColumnsModel, Lookup.getDefault().lookup(AttributeController.class).getModel().getEdgeTable());
//Edges from DHNS
HierarchicalGraph graph;
@@ -642,7 +614,7 @@ public class DataTableTopComponent extends TopComponent implements AWTEventListe
SwingUtilities.invokeLater(new Runnable() {
public void run() {
refreshOnce(true);
refreshAllOnce();
}
});
}
@@ -728,7 +700,7 @@ public class DataTableTopComponent extends TopComponent implements AWTEventListe
JTable table;
String fileName = prepareTableExportFileName();
if (classDisplayed == classDisplayed.NODE) {
if (classDisplayed == ClassDisplayed.NODE) {
table = nodeTable.getOutlineTable();
fileName += " [Nodes]";
} else {
@@ -811,7 +783,7 @@ public class DataTableTopComponent extends TopComponent implements AWTEventListe
* Creates the buttons that call the AttributeColumnManipulators.
*/
private void prepareColumnManipulatorsButtons() {
AttributeModel attributeModel = Lookup.getDefault().lookup(ProjectController.class).getCurrentWorkspace().getLookup().lookup(AttributeModel.class);
AttributeModel attributeModel = Lookup.getDefault().lookup(AttributeController.class).getModel();
AttributeTable table;
AttributeColumn[] columns;
if (classDisplayed == ClassDisplayed.NODE) {
@@ -1383,7 +1355,6 @@ public class DataTableTopComponent extends TopComponent implements AWTEventListe
dd.setOptions(new Object[]{DialogDescriptor.OK_OPTION});
DialogDisplayer.getDefault().notify(dd);
refreshAllOnce();
availableColumnsButton.setIcon(ImageUtilities.loadImageIcon("org/gephi/desktop/datalab/resources/light-bulb.png", true));
}//GEN-LAST:event_availableColumnsButtonActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JScrollPane attributeColumnsScrollPane;
@@ -1,75 +1,84 @@
/*
Copyright 2008-2010 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
Copyright 2008-2010 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2011 Gephi Consortium. All rights reserved.
Copyright 2011 Gephi Consortium. All rights reserved.
The contents of this file are subject to the terms of either the GNU
General Public License Version 3 only ("GPL") or the Common
Development and Distribution License("CDDL") (collectively, the
"License"). You may not use this file except in compliance with the
License. You can obtain a copy of the License at
http://gephi.org/about/legal/license-notice/
or /cddl-1.0.txt and /gpl-3.0.txt. See the License for the
specific language governing permissions and limitations under the
License. When distributing the software, include this License Header
Notice in each file and include the License files at
/cddl-1.0.txt and /gpl-3.0.txt. If applicable, add the following below the
License Header, with the fields enclosed by brackets [] replaced by
your own identifying information:
"Portions Copyrighted [year] [name of copyright owner]"
The contents of this file are subject to the terms of either the GNU
General Public License Version 3 only ("GPL") or the Common
Development and Distribution License("CDDL") (collectively, the
"License"). You may not use this file except in compliance with the
License. You can obtain a copy of the License at
http://gephi.org/about/legal/license-notice/
or /cddl-1.0.txt and /gpl-3.0.txt. See the License for the
specific language governing permissions and limitations under the
License. When distributing the software, include this License Header
Notice in each file and include the License files at
/cddl-1.0.txt and /gpl-3.0.txt. If applicable, add the following below the
License Header, with the fields enclosed by brackets [] replaced by
your own identifying information:
"Portions Copyrighted [year] [name of copyright owner]"
If you wish your version of this file to be governed by only the CDDL
or only the GPL Version 3, indicate your decision by adding
"[Contributor] elects to include this software in this distribution
under the [CDDL or GPL Version 3] license." If you do not indicate a
single choice of license, a recipient has the option to distribute
your version of this file under either the CDDL, the GPL Version 3 or
to extend the choice of license to its licensees as provided above.
However, if you add GPL Version 3 code and therefore, elected the GPL
Version 3 license, then the option applies only if the new code is
made subject to such option by the copyright holder.
If you wish your version of this file to be governed by only the CDDL
or only the GPL Version 3, indicate your decision by adding
"[Contributor] elects to include this software in this distribution
under the [CDDL or GPL Version 3] license." If you do not indicate a
single choice of license, a recipient has the option to distribute
your version of this file under either the CDDL, the GPL Version 3 or
to extend the choice of license to its licensees as provided above.
However, if you add GPL Version 3 code and therefore, elected the GPL
Version 3 license, then the option applies only if the new code is
made subject to such option by the copyright holder.
Contributor(s):
Contributor(s):
Portions Copyrighted 2011 Gephi Consortium.
Portions Copyrighted 2011 Gephi Consortium.
*/
package org.gephi.desktop.datalab;
import org.gephi.data.attributes.api.AttributeColumn;
import org.gephi.data.attributes.api.AttributeController;
import org.gephi.data.attributes.api.AttributeEvent;
import org.gephi.data.attributes.api.AttributeListener;
import org.gephi.data.attributes.api.AttributeModel;
import org.gephi.data.attributes.api.AttributeTable;
import org.gephi.datalab.api.datatables.DataTablesController;
import org.gephi.project.api.Workspace;
import org.openide.util.ImageUtilities;
import org.openide.util.Lookup;
/**
*
* @author Mathieu Bastian
*/
public class DataTablesModel {
public class DataTablesModel implements AttributeListener {
private AvailableColumnsModel nodeAvailableColumnsModel;
private AvailableColumnsModel edgeAvailableColumnsModel;
private AttributeModel attributeModel;
public DataTablesModel() {
public DataTablesModel(Workspace workspace) {
nodeAvailableColumnsModel = new AvailableColumnsModel();
edgeAvailableColumnsModel = new AvailableColumnsModel();
}
public DataTablesModel(AttributeTable nodeTable, AttributeTable edgeTable) {
nodeAvailableColumnsModel = new AvailableColumnsModel();
edgeAvailableColumnsModel = new AvailableColumnsModel();
attributeModel = Lookup.getDefault().lookup(AttributeController.class).getModel(workspace);
//Try to make available all columns at start by default:
for(AttributeColumn column:nodeTable.getColumns()){
for (AttributeColumn column : attributeModel.getNodeTable().getColumns()) {
System.out.println("");
nodeAvailableColumnsModel.addAvailableColumn(column);
}
for(AttributeColumn column:edgeTable.getColumns()){
for (AttributeColumn column : attributeModel.getEdgeTable().getColumns()) {
edgeAvailableColumnsModel.addAvailableColumn(column);
}
attributeModel.addAttributeListener(this);
}
public AvailableColumnsModel getEdgeAvailableColumnsModel() {
@@ -79,4 +88,42 @@ public class DataTablesModel {
public AvailableColumnsModel getNodeAvailableColumnsModel() {
return nodeAvailableColumnsModel;
}
private AvailableColumnsModel getTableAvailableColumnsModel(AttributeTable table) {
if (attributeModel.getNodeTable() == table) {
return nodeAvailableColumnsModel;
} else if (attributeModel.getEdgeTable() == table) {
return edgeAvailableColumnsModel;
} else {
return null;//Graph table or other table, not supported in data laboratory for now.
}
}
public void attributesChanged(AttributeEvent event) {
AttributeTable table = event.getSource();
AvailableColumnsModel tableAvailableColumnsModel = getTableAvailableColumnsModel(table);
if (tableAvailableColumnsModel != null) {
switch (event.getEventType()) {
case ADD_COLUMN:
for (AttributeColumn c : event.getData().getAddedColumns()) {
if (!tableAvailableColumnsModel.addAvailableColumn(c)) {//Add as available by default. Will only be added if the max number of available columns is not surpassed
break;
}
}
break;
case REMOVE_COLUMN:
for (AttributeColumn c : event.getData().getRemovedColumns()) {
tableAvailableColumnsModel.removeAvailableColumn(c);
}
break;
case REPLACE_COLUMN:
for (AttributeColumn c : event.getData().getRemovedColumns()) {
tableAvailableColumnsModel.removeAvailableColumn(c);
tableAvailableColumnsModel.addAvailableColumn(table.getColumn(c.getId()));
}
break;
}
}
Lookup.getDefault().lookup(DataTablesController.class).refreshCurrentTable();
}
}
@@ -66,10 +66,9 @@ public class DataLaboratoryPersistenceProvider implements WorkspacePersistencePr
private static final String EDGE_COLUMN = "edgecolumn";
public void writeXML(XMLStreamWriter writer, Workspace workspace) {
AttributeModel attributeModel = workspace.getLookup().lookup(AttributeModel.class);
DataTablesModel dataTablesModel = workspace.getLookup().lookup(DataTablesModel.class);
if (dataTablesModel == null) {
workspace.add(dataTablesModel = new DataTablesModel(attributeModel.getNodeTable(), attributeModel.getEdgeTable()));
workspace.add(dataTablesModel = new DataTablesModel(workspace));
}
try {
writeDataTablesModel(writer, dataTablesModel);
@@ -114,7 +113,7 @@ public class DataLaboratoryPersistenceProvider implements WorkspacePersistencePr
AttributeTable edgesTable = attributeModel.getEdgeTable();
DataTablesModel dataTablesModel = workspace.getLookup().lookup(DataTablesModel.class);
if (dataTablesModel == null) {
workspace.add(dataTablesModel = new DataTablesModel());
workspace.add(dataTablesModel = new DataTablesModel(workspace));
}
AvailableColumnsModel nodeColumns = dataTablesModel.getNodeAvailableColumnsModel();
nodeColumns.removeAllColumns();
+1 -1
Ver Arquivo
@@ -2,5 +2,5 @@ Manifest-Version: 1.0
AutoUpdate-Essential-Module: true
OpenIDE-Module: org.gephi.tools.plugin
OpenIDE-Module-Localizing-Bundle: org/gephi/tools/plugin/Bundle.properties
OpenIDE-Module-Specification-Version: 0.8.0.7
OpenIDE-Module-Specification-Version: 0.8.0.8
@@ -168,7 +168,6 @@ public class EditEdges extends AbstractNode {
private Sheet.Set prepareEdgesProperties() {
try {
if (multipleEdges) {
MultipleEdgesPropertiesWrapper EdgesWrapper = new MultipleEdgesPropertiesWrapper(edges);
Sheet.Set set = new Sheet.Set();
set.setName("properties");
set.setDisplayName(NbBundle.getMessage(EditEdges.class, "EditEdges.properties.text.multiple"));
@@ -176,7 +175,8 @@ public class EditEdges extends AbstractNode {
Property p;
//Color:
p = new PropertySupport.Reflection(EdgesWrapper, Color.class, "getEdgesColor", "setEdgesColor");
MultipleEdgesPropertiesWrapper edgesWrapper = new MultipleEdgesPropertiesWrapper(edges);
p = new PropertySupport.Reflection(edgesWrapper, Color.class, "getEdgesColor", "setEdgesColor");
p.setDisplayName(NbBundle.getMessage(EditEdges.class, "EditEdges.color.text"));
p.setName("color");
set.put(p);
@@ -191,8 +191,8 @@ public class EditEdges extends AbstractNode {
Property p;
//Color:
SingleEdgePropertiesWrapper EdgeWrapper = new SingleEdgePropertiesWrapper(edge);
p = new PropertySupport.Reflection(EdgeWrapper, Color.class, "getEdgeColor", "setEdgeColor");
SingleEdgePropertiesWrapper edgeWrapper = new SingleEdgePropertiesWrapper(edge);
p = new PropertySupport.Reflection(edgeWrapper, Color.class, "getEdgeColor", "setEdgeColor");
p.setDisplayName(NbBundle.getMessage(EditEdges.class, "EditEdges.color.text"));
p.setName("color");
set.put(p);
@@ -233,7 +233,7 @@ public class EditEdges extends AbstractNode {
}
}
class MultipleEdgesPropertiesWrapper {
public class MultipleEdgesPropertiesWrapper {
Edge[] edges;
@@ -241,15 +241,15 @@ public class EditEdges extends AbstractNode {
this.edges = Edges;
}
//Methods and fields for multiple edges editing:
private Color EdgesColor = null;
private Color edgesColor = null;
public Color getEdgesColor() {
return EdgesColor;
return edgesColor;
}
public void setEdgesColor(Color c) {
if (c != null) {
EdgesColor = c;
edgesColor = c;
EdgeData data;
for (Edge edge : edges) {
data = edge.getEdgeData();