Merge lp:~eduramiba/gephi/linkfluence-features into lp:~gephi.team/gephi/0.8

Proposed by Eduardo Ramos
Status: Merged
Merged at revision: 2087
Proposed branch: lp:~eduramiba/gephi/linkfluence-features
Merge into: lp:~gephi.team/gephi/0.8
Diff against target: 5353 lines (+3283/-1259)
73 files modified
DataLaboratoryAPI/nbproject/genfiles.properties (+2/-2)
DataLaboratoryAPI/nbproject/project.xml (+8/-0)
DataLaboratoryAPI/src/org/gephi/datalab/api/AttributeColumnsController.java (+21/-0)
DataLaboratoryAPI/src/org/gephi/datalab/api/Bundle.properties (+2/-0)
DataLaboratoryAPI/src/org/gephi/datalab/api/Bundle_es.properties (+3/-0)
DataLaboratoryAPI/src/org/gephi/datalab/api/Bundle_fr.properties (+3/-0)
DataLaboratoryAPI/src/org/gephi/datalab/api/Bundle_ru.properties (+1/-0)
DataLaboratoryAPI/src/org/gephi/datalab/api/DataLaboratoryHelper.java (+409/-0)
DataLaboratoryAPI/src/org/gephi/datalab/impl/AttributeColumnsControllerImpl.java (+16/-0)
DataLaboratoryAPI/src/org/gephi/datalab/impl/GraphElementsControllerImpl.java (+38/-6)
DataLaboratoryAPI/src/org/gephi/datalab/spi/Manipulator.java (+3/-3)
DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/GeneralColumnAndValueChooser.java (+65/-0)
DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/GeneralColumnsChooser.java (+1/-1)
DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/edges/Bundle.properties (+2/-0)
DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/edges/ClearEdgesData.java (+1/-1)
DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/edges/CopyEdgeDataToOtherEdges.java (+1/-1)
DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/edges/TagEdges.java (+119/-0)
DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/edges/TagEdgesBuilder.java (+37/-0)
DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/nodes/Bundle.properties (+2/-0)
DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/nodes/ClearNodesData.java (+1/-1)
DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/nodes/CopyNodeDataToOtherNodes.java (+1/-1)
DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/nodes/TagNodes.java (+119/-0)
DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/nodes/TagNodesBuilder.java (+38/-0)
DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/ui/Bundle.properties (+3/-0)
DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/ui/GeneralColumnAndValueChooserUI.form (+102/-0)
DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/ui/GeneralColumnAndValueChooserUI.java (+218/-0)
DesktopBranding/src/org/gephi/branding/desktop/multilingual/LanguageAction.java (+3/-3)
DesktopDataLaboratory/nbproject/genfiles.properties (+2/-2)
DesktopDataLaboratory/nbproject/project.xml (+0/-8)
DesktopDataLaboratory/src/org/gephi/desktop/datalab/DataTableTopComponent.java (+11/-8)
DesktopDataLaboratory/src/org/gephi/desktop/datalab/EdgeDataTable.java (+4/-4)
DesktopDataLaboratory/src/org/gephi/desktop/datalab/NodeDataTable.java (+4/-4)
DesktopDataLaboratory/src/org/gephi/desktop/datalab/general/actions/MergeColumnsUI.java (+3/-3)
DesktopDataLaboratory/src/org/gephi/desktop/datalab/utils/Bundle.properties (+0/-2)
DesktopDataLaboratory/src/org/gephi/desktop/datalab/utils/Bundle_es.properties (+0/-4)
DesktopDataLaboratory/src/org/gephi/desktop/datalab/utils/Bundle_fr.properties (+0/-4)
DesktopDataLaboratory/src/org/gephi/desktop/datalab/utils/DataLaboratoryHelper.java (+0/-350)
DesktopDataLaboratory/src/org/gephi/desktop/datalab/utils/PopupMenuUtils.java (+3/-2)
VisualizationAPI/nbproject/genfiles.properties (+2/-2)
VisualizationAPI/nbproject/project.xml (+1/-0)
VisualizationAPI/src/org/gephi/visualization/spi/GraphContextMenuItem.java (+125/-0)
VisualizationModule/nbproject/genfiles.properties (+2/-2)
VisualizationModule/nbproject/project.xml (+8/-0)
VisualizationModule/src/org/gephi/visualization/apiimpl/Bundle.properties (+0/-14)
VisualizationModule/src/org/gephi/visualization/apiimpl/Bundle_es.properties (+0/-32)
VisualizationModule/src/org/gephi/visualization/apiimpl/Bundle_fr.properties (+0/-32)
VisualizationModule/src/org/gephi/visualization/apiimpl/GraphContextMenu.java (+114/-178)
VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Bundle.properties (+21/-0)
VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Bundle_es.properties (+32/-0)
VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Bundle_fr.properties (+32/-0)
VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Contract.java (+126/-0)
VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/CopyOrMoveToWorkspace.java (+93/-0)
VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/CopyOrMoveToWorkspaceSubItem.java (+149/-0)
VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/CopyToWorkspace.java (+31/-0)
VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Delete.java (+93/-0)
VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Expand.java (+124/-0)
VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Free.java (+91/-0)
VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Group.java (+85/-0)
VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/LastColumnOpenedURL.java (+33/-0)
VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/MoveToWorkspace.java (+31/-0)
VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/OpenURL.java (+93/-0)
VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/OpenURLLastItem.java (+119/-0)
VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/OpenURLSubItem.java (+152/-0)
VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/SelectInDataLaboratory.java (+86/-0)
VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Settle.java (+91/-0)
VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/TagNodes.java (+86/-0)
VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Ungroup.java (+91/-0)
VisualizationModule/src/org/gephi/visualization/apiimpl/es.po (+0/-57)
VisualizationModule/src/org/gephi/visualization/apiimpl/fr.po (+0/-57)
VisualizationModule/src/org/gephi/visualization/apiimpl/org-gephi-visualization-api.pot (+0/-37)
VisualizationModule/src/org/gephi/visualization/apiimpl/org-gephi-visualization-apiimpl.pot (+0/-55)
VisualizationModule/src/org/gephi/visualization/bridge/DHNSEventBridge.java (+59/-381)
VisualizationModule/src/org/gephi/visualization/component/GraphTopComponent.java (+67/-2)
To merge this branch: bzr merge lp:~eduramiba/gephi/linkfluence-features
Reviewer Review Type Date Requested Status
Mathieu Bastian Approve
Review via email: mp+48162@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Mathieu Bastian (mathieu.bastian) wrote :

Great Job Eduardo, that are great useful features and nice API improvements.

Some comments:
- As we plan to do a last 0.7 update very soon, to include the bugfixes, I reverted the LanguageAction change, as new languages will be in 0.8 only
- The OpenURL contect menu item should rather be in a plugin. Please remove it from the trunk and create a plugin branch.

review: Approve
Revision history for this message
Mathieu Bastian (mathieu.bastian) wrote :

The Tag menu item should also be part of a plugin I guess

Revision history for this message
Eduardo Ramos (eduramiba) wrote :

Hi,
Right, I enabled language selection to try it and forgot to disable it.
Then, it will be necessary to delete translated bundles for an 0.7 update
before 0.8 (which will have languages), since they were merged to trunk
recently.
Also I still have to update some translations before 0.8.

When I finish my exams next tuesday I will do that, add/change other
linkfluence plugin features like "copy column of selected nodes to
clipboard" and review the API documentation.

Open URL, tagging, and the clipboard thing could be an extra utils plugin I
guess, yes.

Also, the SPI for context menu actions is very similar to nodes/edges
manipulators of data laboratory (I added support for declaring shortcut keys
and submenues, which could be useful for data lab nodes/edges manipulators).
So, with small changes if necessary, some node actions can appear in graph
view and data lab, and I thought I will add the move/copy to workspace
feature to data laboratory once it has support for the submenues.

Thanks,
Eduardo

2011/2/4 Mathieu Bastian <email address hidden>

> Review: Approve
> Great Job Eduardo, that are great useful features and nice API
> improvements.
>
> Some comments:
> - As we plan to do a last 0.7 update very soon, to include the bugfixes, I
> reverted the LanguageAction change, as new languages will be in 0.8 only
> - The OpenURL contect menu item should rather be in a plugin. Please remove
> it from the trunk and create a plugin branch.
> --
>
> https://code.launchpad.net/~eduramiba/gephi/linkfluence-features/+merge/48162<https://code.launchpad.net/%7Eeduramiba/gephi/linkfluence-features/+merge/48162>
> You are the owner of lp:~eduramiba/gephi/linkfluence-features.
>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'DataLaboratoryAPI/nbproject/genfiles.properties'
--- DataLaboratoryAPI/nbproject/genfiles.properties 2010-09-16 21:39:28 +0000
+++ DataLaboratoryAPI/nbproject/genfiles.properties 2011-02-01 14:23:14 +0000
@@ -1,8 +1,8 @@
1build.xml.data.CRC32=08e66a2b1build.xml.data.CRC32=cde22f7d
2build.xml.script.CRC32=f4b00cc32build.xml.script.CRC32=f4b00cc3
3build.xml.stylesheet.CRC32=a56c6a5b@1.42.23build.xml.stylesheet.CRC32=a56c6a5b@1.42.2
4# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.4# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
5# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.5# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6nbproject/build-impl.xml.data.CRC32=08e66a2b6nbproject/build-impl.xml.data.CRC32=cde22f7d
7nbproject/build-impl.xml.script.CRC32=eea9549d7nbproject/build-impl.xml.script.CRC32=eea9549d
8nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.42.28nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.42.2
99
=== modified file 'DataLaboratoryAPI/nbproject/project.xml'
--- DataLaboratoryAPI/nbproject/project.xml 2010-09-16 21:39:28 +0000
+++ DataLaboratoryAPI/nbproject/project.xml 2011-02-01 14:23:14 +0000
@@ -47,6 +47,14 @@
47 </run-dependency>47 </run-dependency>
48 </dependency>48 </dependency>
49 <dependency>49 <dependency>
50 <code-name-base>org.openide.dialogs</code-name-base>
51 <build-prerequisite/>
52 <compile-dependency/>
53 <run-dependency>
54 <specification-version>7.15.1</specification-version>
55 </run-dependency>
56 </dependency>
57 <dependency>
50 <code-name-base>org.openide.util</code-name-base>58 <code-name-base>org.openide.util</code-name-base>
51 <build-prerequisite/>59 <build-prerequisite/>
52 <compile-dependency/>60 <compile-dependency/>
5361
=== modified file 'DataLaboratoryAPI/src/org/gephi/datalab/api/AttributeColumnsController.java'
--- DataLaboratoryAPI/src/org/gephi/datalab/api/AttributeColumnsController.java 2010-10-12 12:56:30 +0000
+++ DataLaboratoryAPI/src/org/gephi/datalab/api/AttributeColumnsController.java 2011-02-01 14:23:14 +0000
@@ -31,6 +31,7 @@
31import org.gephi.graph.api.Attributes;31import org.gephi.graph.api.Attributes;
32import org.gephi.graph.api.Edge;32import org.gephi.graph.api.Edge;
33import org.gephi.graph.api.Node;33import org.gephi.graph.api.Node;
34import org.openide.util.Lookup;
3435
35/**36/**
36 * <p>This interface defines part of the Data Laboratory API basic actions.</p>37 * <p>This interface defines part of the Data Laboratory API basic actions.</p>
@@ -109,6 +110,26 @@
109 void fillColumnWithValue(AttributeTable table, AttributeColumn column, String value);110 void fillColumnWithValue(AttributeTable table, AttributeColumn column, String value);
110111
111 /**112 /**
113 * <p>Fills the data values of a given column of the indicated nodes with a value as a String,
114 * parsing it for the <code>AttributeType</code> of the column. If it is not possible to parse,
115 * the value will be set to null.</p>
116 * @param nodes Nodes to fill
117 * @param column Column to fill
118 * @param value String representation of the value for the column for each node
119 */
120 void fillNodesColumnWithValue(Node[] nodes, AttributeColumn column, String value);
121
122 /**
123 * <p>Fills the data values of a given column of the indicated edges with a value as a String,
124 * parsing it for the <code>AttributeType</code> of the column. If it is not possible to parse,
125 * the value will be set to null.</p>
126 * @param edges Edges to fill
127 * @param column Column to fill
128 * @param value String representation of the value for the column for each edge
129 */
130 void fillEdgesColumnWithValue(Edge[] edges, AttributeColumn column, String value);
131
132 /**
112 * <p>Clears all rows data for a given column of a table (nodes table or edges table)</p>133 * <p>Clears all rows data for a given column of a table (nodes table or edges table)</p>
113 * @param table Table to clear column data134 * @param table Table to clear column data
114 * @param column Column to clear data135 * @param column Column to clear data
115136
=== modified file 'DataLaboratoryAPI/src/org/gephi/datalab/api/Bundle.properties'
--- DataLaboratoryAPI/src/org/gephi/datalab/api/Bundle.properties 2010-09-07 09:00:13 +0000
+++ DataLaboratoryAPI/src/org/gephi/datalab/api/Bundle.properties 2011-02-01 14:23:14 +0000
@@ -3,3 +3,5 @@
3 API/SPI for interacting with the Data Laboratory and extending it.3 API/SPI for interacting with the Data Laboratory and extending it.
4OpenIDE-Module-Name=Data Laboratory API4OpenIDE-Module-Name=Data Laboratory API
5OpenIDE-Module-Short-Description=API/SPI for interacting with the Data Laboratory and extending it5OpenIDE-Module-Short-Description=API/SPI for interacting with the Data Laboratory and extending it
6DataLaboratoryHelper.ui.okButton.text=Ok
7SettingsPanel.title={0}
68
=== modified file 'DataLaboratoryAPI/src/org/gephi/datalab/api/Bundle_es.properties'
--- DataLaboratoryAPI/src/org/gephi/datalab/api/Bundle_es.properties 2010-12-30 12:17:31 +0000
+++ DataLaboratoryAPI/src/org/gephi/datalab/api/Bundle_es.properties 2011-02-01 14:23:14 +0000
@@ -8,3 +8,6 @@
8OpenIDE-Module-Long-Description=API/SPI para interactuar con el Laboratorio de Datos y extenderlo.8OpenIDE-Module-Long-Description=API/SPI para interactuar con el Laboratorio de Datos y extenderlo.
99
10OpenIDE-Module-Short-Description=API/SPI para interactuar con el Laboratorio de Datos y extenderlo.10OpenIDE-Module-Short-Description=API/SPI para interactuar con el Laboratorio de Datos y extenderlo.
11
12DataLaboratoryHelper.ui.okButton.text=Ok
13SettingsPanel.title={0}
11\ No newline at end of file14\ No newline at end of file
1215
=== modified file 'DataLaboratoryAPI/src/org/gephi/datalab/api/Bundle_fr.properties'
--- DataLaboratoryAPI/src/org/gephi/datalab/api/Bundle_fr.properties 2010-12-30 12:17:31 +0000
+++ DataLaboratoryAPI/src/org/gephi/datalab/api/Bundle_fr.properties 2011-02-01 14:23:14 +0000
@@ -8,3 +8,6 @@
8OpenIDE-Module-Long-Description=API/SPI pour interagir avec le Data Laboratory et l'\u00e9tendre8OpenIDE-Module-Long-Description=API/SPI pour interagir avec le Data Laboratory et l'\u00e9tendre
99
10OpenIDE-Module-Short-Description=API/SPI pour interagir avec le Data Laboratory et l'\u00e9tendre10OpenIDE-Module-Short-Description=API/SPI pour interagir avec le Data Laboratory et l'\u00e9tendre
11
12DataLaboratoryHelper.ui.okButton.text=Ok
13SettingsPanel.title={0}
11\ No newline at end of file14\ No newline at end of file
1215
=== modified file 'DataLaboratoryAPI/src/org/gephi/datalab/api/Bundle_ru.properties'
--- DataLaboratoryAPI/src/org/gephi/datalab/api/Bundle_ru.properties 2010-12-30 12:17:31 +0000
+++ DataLaboratoryAPI/src/org/gephi/datalab/api/Bundle_ru.properties 2011-02-01 14:23:14 +0000
@@ -8,3 +8,4 @@
8OpenIDE-Module-Long-Description=API/SPI \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u041b\u0430\u0431\u043e\u0440\u0430\u0442\u043e\u0440\u0438\u0435\u0439 \u0414\u0430\u043d\u043d\u044b\u04458OpenIDE-Module-Long-Description=API/SPI \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u041b\u0430\u0431\u043e\u0440\u0430\u0442\u043e\u0440\u0438\u0435\u0439 \u0414\u0430\u043d\u043d\u044b\u0445
99
10OpenIDE-Module-Short-Description=API/SPI \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u041b\u0430\u0431\u043e\u0440\u0430\u0442\u043e\u0440\u0438\u0435\u0439 \u0414\u0430\u043d\u043d\u044b\u044510OpenIDE-Module-Short-Description=API/SPI \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u041b\u0430\u0431\u043e\u0440\u0430\u0442\u043e\u0440\u0438\u0435\u0439 \u0414\u0430\u043d\u043d\u044b\u0445
11SettingsPanel.title={0}
11\ No newline at end of file12\ No newline at end of file
1213
=== added file 'DataLaboratoryAPI/src/org/gephi/datalab/api/DataLaboratoryHelper.java'
--- DataLaboratoryAPI/src/org/gephi/datalab/api/DataLaboratoryHelper.java 1970-01-01 00:00:00 +0000
+++ DataLaboratoryAPI/src/org/gephi/datalab/api/DataLaboratoryHelper.java 2011-02-01 14:23:14 +0000
@@ -0,0 +1,409 @@
1/*
2Copyright 2008-2010 Gephi
3Authors : Eduardo Ramos <eduramiba@gmail.com>
4Website : http://www.gephi.org
5
6This file is part of Gephi.
7
8Gephi is free software: you can redistribute it and/or modify
9it under the terms of the GNU Affero General Public License as
10published by the Free Software Foundation, either version 3 of the
11License, or (at your option) any later version.
12
13Gephi is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU Affero General Public License for more details.
17
18You should have received a copy of the GNU Affero General Public License
19along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.datalab.api;
22
23import java.awt.Dialog;
24import java.awt.event.ActionEvent;
25import java.awt.event.ActionListener;
26import java.awt.event.WindowAdapter;
27import java.awt.event.WindowEvent;
28import java.util.ArrayList;
29import java.util.Collections;
30import java.util.Comparator;
31import javax.swing.JButton;
32import javax.swing.JComponent;
33import javax.swing.JPanel;
34import javax.swing.SwingUtilities;
35import org.gephi.data.attributes.api.AttributeColumn;
36import org.gephi.data.attributes.api.AttributeTable;
37import org.gephi.datalab.spi.DialogControls;
38import org.gephi.datalab.spi.Manipulator;
39import org.gephi.datalab.spi.ManipulatorUI;
40import org.gephi.datalab.spi.columns.AttributeColumnsManipulator;
41import org.gephi.datalab.spi.columns.AttributeColumnsManipulatorUI;
42import org.gephi.datalab.spi.columns.merge.AttributeColumnsMergeStrategy;
43import org.gephi.datalab.spi.columns.merge.AttributeColumnsMergeStrategyBuilder;
44import org.gephi.datalab.spi.values.AttributeValueManipulator;
45import org.gephi.datalab.spi.values.AttributeValueManipulatorBuilder;
46import org.gephi.datalab.spi.edges.EdgesManipulator;
47import org.gephi.datalab.spi.edges.EdgesManipulatorBuilder;
48import org.gephi.datalab.spi.general.GeneralActionsManipulator;
49import org.gephi.datalab.spi.general.PluginGeneralActionsManipulator;
50import org.gephi.datalab.spi.nodes.NodesManipulator;
51import org.gephi.datalab.spi.nodes.NodesManipulatorBuilder;
52import org.openide.DialogDescriptor;
53import org.openide.DialogDisplayer;
54import org.openide.util.Lookup;
55import org.openide.util.NbBundle;
56import org.openide.util.lookup.ServiceProvider;
57
58/**
59 * Helper class for simplifying the use of Data Laboratory API and SPI.
60 */
61@ServiceProvider(service=DataLaboratoryHelper.class)
62public class DataLaboratoryHelper{
63
64 /**
65 * <p>Prepares an array with one new instance of every NodesManipulator
66 * that has a builder registered and returns it.</p>
67 * <p>It also returns the manipulators ordered first by type and then by position.</p>
68 * @return Array of all NodesManipulator implementations
69 */
70 public NodesManipulator[] getNodesManipulators() {
71 ArrayList<NodesManipulator> nodesManipulators = new ArrayList<NodesManipulator>();
72 for (NodesManipulatorBuilder nm : Lookup.getDefault().lookupAll(NodesManipulatorBuilder.class)) {
73 nodesManipulators.add(nm.getNodesManipulator());
74 }
75 sortManipulators(nodesManipulators);
76 return nodesManipulators.toArray(new NodesManipulator[0]);
77 }
78
79 /**
80 * <p>Prepares an array with one new instance of every EdgesManipulator
81 * that has a builder registered and returns it.</p>
82 * <p>It also returns the manipulators ordered first by type and then by position.</p>
83 * @return Array of all EdgesManipulator implementations
84 */
85 public EdgesManipulator[] getEdgesManipulators() {
86 ArrayList<EdgesManipulator> edgesManipulators = new ArrayList<EdgesManipulator>();
87 for (EdgesManipulatorBuilder em : Lookup.getDefault().lookupAll(EdgesManipulatorBuilder.class)) {
88 edgesManipulators.add(em.getEdgesManipulator());
89 }
90 sortManipulators(edgesManipulators);
91 return edgesManipulators.toArray(new EdgesManipulator[0]);
92 }
93
94 /**
95 * <p>Prepares an array with one instance of every GeneralActionsManipulator that is registered.</p>
96 * <p>It also returns the manipulators ordered first by type and then by position.</p>
97 * @return Array of all GeneralActionsManipulator implementations
98 */
99 public GeneralActionsManipulator[] getGeneralActionsManipulators() {
100 ArrayList<GeneralActionsManipulator> generalActionsManipulators = new ArrayList<GeneralActionsManipulator>();
101 generalActionsManipulators.addAll(Lookup.getDefault().lookupAll(GeneralActionsManipulator.class));
102 sortManipulators(generalActionsManipulators);
103 return generalActionsManipulators.toArray(new GeneralActionsManipulator[0]);
104 }
105
106 /**
107 * <p>Prepares an array with one instance of every PluginGeneralActionsManipulator that is registered.</p>
108 * <p>It also returns the manipulators ordered first by type and then by position.</p>
109 * @return Array of all PluginGeneralActionsManipulator implementations
110 */
111 public PluginGeneralActionsManipulator[] getPluginGeneralActionsManipulators() {
112 ArrayList<PluginGeneralActionsManipulator> pluginGeneralActionsManipulators = new ArrayList<PluginGeneralActionsManipulator>();
113 pluginGeneralActionsManipulators.addAll(Lookup.getDefault().lookupAll(PluginGeneralActionsManipulator.class));
114 sortManipulators(pluginGeneralActionsManipulators);
115 return pluginGeneralActionsManipulators.toArray(new PluginGeneralActionsManipulator[0]);
116 }
117
118 /**
119 * <p>Prepares an array that has one instance of every AttributeColumnsManipulator implementation
120 * that has a builder registered and returns it.</p>
121 * <p>It also returns the manipulators ordered first by type and then by position.</p>
122 * @return Array of all AttributeColumnsManipulator implementations
123 */
124 public AttributeColumnsManipulator[] getAttributeColumnsManipulators() {
125 ArrayList<AttributeColumnsManipulator> attributeColumnsManipulators = new ArrayList<AttributeColumnsManipulator>();
126 attributeColumnsManipulators.addAll(Lookup.getDefault().lookupAll(AttributeColumnsManipulator.class));
127 sortAttributeColumnsManipulators(attributeColumnsManipulators);
128 return attributeColumnsManipulators.toArray(new AttributeColumnsManipulator[0]);
129 }
130
131 /**
132 * <p>Prepares an array with one new instance of every AttributeValueManipulator
133 * that has a builder registered and returns it.</p>
134 * <p>It also returns the manipulators ordered first by type and then by position.</p>
135 * @return Array of all AttributeValueManipulator implementations
136 */
137 public AttributeValueManipulator[] getAttributeValueManipulators() {
138 ArrayList<AttributeValueManipulator> attributeValueManipulators = new ArrayList<AttributeValueManipulator>();
139 for (AttributeValueManipulatorBuilder am : Lookup.getDefault().lookupAll(AttributeValueManipulatorBuilder.class)) {
140 attributeValueManipulators.add(am.getAttributeValueManipulator());
141 }
142 sortManipulators(attributeValueManipulators);
143 return attributeValueManipulators.toArray(new AttributeValueManipulator[0]);
144 }
145
146 /**
147 * <p>Prepares an array that has one new instance of every AttributeColumnsMergeStrategy implementation that is registered.</p>
148 * <p>It also returns the manipulators ordered first by type and then by position.</p>
149 * @return Array of all AttributeColumnsMergeStrategy implementations
150 */
151 public AttributeColumnsMergeStrategy[] getAttributeColumnsMergeStrategies() {
152 ArrayList<AttributeColumnsMergeStrategy> strategies = new ArrayList<AttributeColumnsMergeStrategy>();
153 for (AttributeColumnsMergeStrategyBuilder cs : Lookup.getDefault().lookupAll(AttributeColumnsMergeStrategyBuilder.class)) {
154 strategies.add(cs.getAttributeColumnsMergeStrategy());
155 }
156 sortManipulators(strategies);
157 return strategies.toArray(new AttributeColumnsMergeStrategy[0]);
158 }
159
160 private void sortManipulators(ArrayList<? extends Manipulator> m) {
161 Collections.sort(m, new Comparator<Manipulator>() {
162
163 public int compare(Manipulator o1, Manipulator o2) {
164 //Order by type, position.
165 if (o1.getType() == o2.getType()) {
166 return o1.getPosition() - o2.getPosition();
167 } else {
168 return o1.getType() - o2.getType();
169 }
170 }
171 });
172 }
173
174 private void sortAttributeColumnsManipulators(ArrayList<? extends AttributeColumnsManipulator> m) {
175 Collections.sort(m, new Comparator<AttributeColumnsManipulator>() {
176
177 public int compare(AttributeColumnsManipulator o1, AttributeColumnsManipulator o2) {
178 //Order by type, position.
179 if (o1.getType() == o2.getType()) {
180 return o1.getPosition() - o2.getPosition();
181 } else {
182 return o1.getType() - o2.getType();
183 }
184 }
185 });
186 }
187
188 /**
189 * Prepares the dialog UI of a manipulator if it has one and executes the manipulator in a separate
190 * Thread when the dialog is accepted or directly if there is no UI.
191 * @param m Manipulator to execute
192 */
193 public void executeManipulator(final Manipulator m) {
194 if (m.canExecute()) {
195 SwingUtilities.invokeLater(new Runnable() {
196
197 public void run() {
198
199 final ManipulatorUI ui = m.getUI();
200 //Show a dialog for the manipulator UI if it provides one. If not, execute the manipulator directly:
201 if (ui != null) {
202 final JButton okButton = new JButton(NbBundle.getMessage(DataLaboratoryHelper.class, "DataLaboratoryHelper.ui.okButton.text"));
203 DialogControls dialogControls = new DialogControlsImpl(okButton);
204 ui.setup(m, dialogControls);
205 JPanel settingsPanel = ui.getSettingsPanel();
206 DialogDescriptor dd = new DialogDescriptor(settingsPanel, NbBundle.getMessage(DataLaboratoryHelper.class, "SettingsPanel.title", ui.getDisplayName()), ui.isModal(), new ActionListener() {
207
208 public void actionPerformed(ActionEvent e) {
209 if (e.getSource().equals(okButton)) {
210 ui.unSetup();
211 executeManipulatorInOtherThread(m);
212 } else {
213 ui.unSetup();
214 }
215 }
216 });
217 dd.setOptions(new Object[]{okButton, DialogDescriptor.CANCEL_OPTION});
218 dd.setClosingOptions(null);//All options close
219 Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
220 dialog.addWindowListener(new WindowAdapter() {
221
222 @Override
223 public void windowClosing(WindowEvent e) {
224 ui.unSetup();
225 }
226 });
227 dialog.setVisible(true);
228 } else {
229 executeManipulatorInOtherThread(m);
230 }
231 }
232 });
233 }
234 }
235
236 private void executeManipulatorInOtherThread(final Manipulator m) {
237 new Thread() {
238
239 @Override
240 public void run() {
241 m.execute();
242 }
243 }.start();
244 }
245
246 /**
247 * Prepares the dialog UI of a AttributeColumnsManipulator if it has one and executes the manipulator in a separate
248 * Thread when the dialog is accepted or directly if there is no UI.
249 * @param m AttributeColumnsManipulator
250 * @param table Table of the column
251 * @param column Column to manipulate
252 */
253 public void executeAttributeColumnsManipulator(final AttributeColumnsManipulator m, final AttributeTable table, final AttributeColumn column) {
254 if (m.canManipulateColumn(table, column)) {
255 SwingUtilities.invokeLater(new Runnable() {
256
257 public void run() {
258 final AttributeColumnsManipulatorUI ui = m.getUI(table, column);
259 //Show a dialog for the manipulator UI if it provides one. If not, execute the manipulator directly:
260 if (ui != null) {
261 final JButton okButton = new JButton(NbBundle.getMessage(DataLaboratoryHelper.class, "DataLaboratoryHelper.ui.okButton.text"));
262 DialogControls dialogControls = new DialogControlsImpl(okButton);
263 ui.setup(m, table, column, dialogControls);
264 JPanel settingsPanel = ui.getSettingsPanel();
265 DialogDescriptor dd = new DialogDescriptor(settingsPanel, NbBundle.getMessage(DataLaboratoryHelper.class, "SettingsPanel.title", ui.getDisplayName()), ui.isModal(), new ActionListener() {
266
267 public void actionPerformed(ActionEvent e) {
268 if (e.getSource().equals(okButton)) {
269 ui.unSetup();
270 executeAttributeColumnsManipulatorInOtherThread(m, table, column);
271 } else {
272 ui.unSetup();
273 }
274 }
275 });
276 dd.setOptions(new Object[]{okButton, DialogDescriptor.CANCEL_OPTION});
277 dd.setClosingOptions(null);//All options close
278 Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
279 dialog.addWindowListener(new WindowAdapter() {
280
281 @Override
282 public void windowClosing(WindowEvent e) {
283 ui.unSetup();
284 }
285 });
286 dialog.setVisible(true);
287 } else {
288 executeAttributeColumnsManipulatorInOtherThread(m, table, column);
289 }
290 }
291 });
292 }
293 }
294
295 private void executeAttributeColumnsManipulatorInOtherThread(final AttributeColumnsManipulator m, final AttributeTable table, final AttributeColumn column) {
296 new Thread() {
297
298 @Override
299 public void run() {
300 m.execute(table, column);
301 }
302 }.start();
303 }
304
305 /**
306 * Returns the AttributeColumnsMergeStrategy with that class name or null if it does not exist
307 */
308 public NodesManipulator getNodesManipulatorByName(String name){
309 for (NodesManipulatorBuilder nm : Lookup.getDefault().lookupAll(NodesManipulatorBuilder.class)) {
310 if(nm.getNodesManipulator().getClass().getSimpleName().equals(name)){
311 return nm.getNodesManipulator();
312 }
313 }
314 return null;
315 }
316
317 /**
318 * Returns the AttributeColumnsMergeStrategy with that class name or null if it does not exist
319 */
320 public EdgesManipulator getEdgesManipulatorByName(String name){
321 for (EdgesManipulatorBuilder nm : Lookup.getDefault().lookupAll(EdgesManipulatorBuilder.class)) {
322 if(nm.getEdgesManipulator().getClass().getSimpleName().equals(name)){
323 return nm.getEdgesManipulator();
324 }
325 }
326 return null;
327 }
328
329 /**
330 * Returns the AttributeColumnsMergeStrategy with that class name or null if it does not exist
331 */
332 public GeneralActionsManipulator getGeneralActionsManipulatorByName(String name) {
333 for (GeneralActionsManipulator m : Lookup.getDefault().lookupAll(GeneralActionsManipulator.class)) {
334 if(m.getClass().getSimpleName().equals(name)){
335 return m;
336 }
337 }
338 return null;
339 }
340
341 /**
342 * Returns the AttributeColumnsMergeStrategy with that class name or null if it does not exist
343 */
344 public PluginGeneralActionsManipulator getPluginGeneralActionsManipulatorByName(String name) {
345 for (PluginGeneralActionsManipulator m : Lookup.getDefault().lookupAll(PluginGeneralActionsManipulator.class)) {
346 if(m.getClass().getSimpleName().equals(name)){
347 return m;
348 }
349 }
350 return null;
351 }
352
353 /**
354 * Returns the AttributeColumnsMergeStrategy with that class name or null if it does not exist
355 */
356 public AttributeColumnsManipulator getAttributeColumnsManipulatorByName(String name) {
357 for (AttributeColumnsManipulator m : Lookup.getDefault().lookupAll(AttributeColumnsManipulator.class)) {
358 if(m.getClass().getSimpleName().equals(name)){
359 return m;
360 }
361 }
362 return null;
363 }
364
365 /**
366 * Returns the AttributeColumnsMergeStrategy with that class name or null if it does not exist
367 */
368 public AttributeValueManipulator getAttributeValueManipulatorByName(String name) {
369 for (AttributeValueManipulatorBuilder am : Lookup.getDefault().lookupAll(AttributeValueManipulatorBuilder.class)) {
370 if(am.getAttributeValueManipulator().getClass().getSimpleName().equals(name)){
371 return am.getAttributeValueManipulator();
372 }
373 }
374 return null;
375 }
376
377 /**
378 * Returns the AttributeColumnsMergeStrategy with that class name or null if it does not exist
379 */
380 public AttributeColumnsMergeStrategy getAttributeColumnsMergeStrategieByName(String name) {
381 for (AttributeColumnsMergeStrategyBuilder cs : Lookup.getDefault().lookupAll(AttributeColumnsMergeStrategyBuilder.class)) {
382 if(cs.getAttributeColumnsMergeStrategy().getClass().getSimpleName().equals(name)){
383 return cs.getAttributeColumnsMergeStrategy();
384 }
385 }
386 return null;
387 }
388
389 class DialogControlsImpl implements DialogControls {
390
391 JComponent okButton;
392
393 public DialogControlsImpl(JComponent okButton) {
394 this.okButton = okButton;
395 }
396
397 public void setOkButtonEnabled(boolean enabled) {
398 okButton.setEnabled(enabled);
399 }
400
401 public boolean isOkButtonEnabled(){
402 return okButton.isEnabled();
403 }
404 }
405
406 public static DataLaboratoryHelper getDefault(){
407 return Lookup.getDefault().lookup(DataLaboratoryHelper.class);
408 }
409}
0410
=== modified file 'DataLaboratoryAPI/src/org/gephi/datalab/impl/AttributeColumnsControllerImpl.java'
--- DataLaboratoryAPI/src/org/gephi/datalab/impl/AttributeColumnsControllerImpl.java 2010-10-16 16:36:58 +0000
+++ DataLaboratoryAPI/src/org/gephi/datalab/impl/AttributeColumnsControllerImpl.java 2011-02-01 14:23:14 +0000
@@ -142,6 +142,22 @@
142 }142 }
143 }143 }
144144
145 public void fillNodesColumnWithValue(Node[] nodes, AttributeColumn column, String value){
146 if (canChangeColumnData(column)) {
147 for (Node node: nodes) {
148 setAttributeValue(value, node.getNodeData().getAttributes(), column);
149 }
150 }
151 }
152
153 public void fillEdgesColumnWithValue(Edge[] edges, AttributeColumn column, String value){
154 if (canChangeColumnData(column)) {
155 for (Edge edge: edges) {
156 setAttributeValue(value, edge.getEdgeData().getAttributes(), column);
157 }
158 }
159 }
160
145 public void clearColumnData(AttributeTable table, AttributeColumn column) {161 public void clearColumnData(AttributeTable table, AttributeColumn column) {
146 if (canClearColumnData(column)) {162 if (canClearColumnData(column)) {
147 final int columnIndex = column.getIndex();163 final int columnIndex = column.getIndex();
148164
=== modified file 'DataLaboratoryAPI/src/org/gephi/datalab/impl/GraphElementsControllerImpl.java'
--- DataLaboratoryAPI/src/org/gephi/datalab/impl/GraphElementsControllerImpl.java 2010-10-11 12:12:06 +0000
+++ DataLaboratoryAPI/src/org/gephi/datalab/impl/GraphElementsControllerImpl.java 2011-02-01 14:23:14 +0000
@@ -35,6 +35,8 @@
35import org.gephi.graph.api.Node;35import org.gephi.graph.api.Node;
36import org.gephi.graph.api.NodeData;36import org.gephi.graph.api.NodeData;
37import org.gephi.graph.api.UndirectedGraph;37import org.gephi.graph.api.UndirectedGraph;
38import org.openide.DialogDisplayer;
39import org.openide.NotifyDescriptor;
38import org.openide.util.Lookup;40import org.openide.util.Lookup;
39import org.openide.util.NbBundle;41import org.openide.util.NbBundle;
40import org.openide.util.lookup.ServiceProvider;42import org.openide.util.lookup.ServiceProvider;
@@ -47,8 +49,9 @@
47 */49 */
48@ServiceProvider(service = GraphElementsController.class)50@ServiceProvider(service = GraphElementsController.class)
49public class GraphElementsControllerImpl implements GraphElementsController {51public class GraphElementsControllerImpl implements GraphElementsController {
50 private static final float DEFAULT_NODE_SIZE=10f;52
51 private static final float DEFAULT_EDGE_WEIGHT=1f;53 private static final float DEFAULT_NODE_SIZE = 10f;
54 private static final float DEFAULT_EDGE_WEIGHT = 1f;
5255
53 public Node createNode(String label) {56 public Node createNode(String label) {
54 Node newNode = buildNode(label);57 Node newNode = buildNode(label);
@@ -176,10 +179,39 @@
176179
177 public boolean groupNodes(Node[] nodes) {180 public boolean groupNodes(Node[] nodes) {
178 if (canGroupNodes(nodes)) {181 if (canGroupNodes(nodes)) {
179 HierarchicalGraph hg = getHierarchicalGraph();182 HierarchicalGraph graph = getHierarchicalGraph();
180 Node group = hg.groupNodes(nodes);183 try {
181 //Set the group node label to the same used int visualization module:184 float centroidX = 0;
182 group.getNodeData().setLabel(NbBundle.getMessage(GraphElementsControllerImpl.class, "Group.nodeCount.label", getNodeChildrenCount(hg, group)));185 float centroidY = 0;
186 int len = 0;
187 float sizes = 0;
188 float r = 0;
189 float g = 0;
190 float b = 0;
191 Node group = graph.groupNodes(nodes);
192 group.getNodeData().setLabel(NbBundle.getMessage(GraphElementsControllerImpl.class, "Group.nodeCount.label", nodes.length));
193 group.getNodeData().setSize(10f);
194 for (Node child : nodes) {
195 centroidX += child.getNodeData().x();
196 centroidY += child.getNodeData().y();
197 len++;
198 sizes += child.getNodeData().getSize() / 10f;
199 r += child.getNodeData().r();
200 g += child.getNodeData().g();
201 b += child.getNodeData().b();
202 }
203 centroidX /= len;
204 centroidY /= len;
205 group.getNodeData().setSize(sizes);
206 group.getNodeData().setColor(r / len, g / len, b / len);
207 group.getNodeData().setX(centroidX);
208 group.getNodeData().setY(centroidY);
209 } catch (Exception e) {
210 graph.readUnlockAll();
211 NotifyDescriptor.Message nd = new NotifyDescriptor.Message(e.getMessage());
212 DialogDisplayer.getDefault().notifyLater(nd);
213 return false;
214 }
183 return true;215 return true;
184 } else {216 } else {
185 return false;217 return false;
186218
=== modified file 'DataLaboratoryAPI/src/org/gephi/datalab/spi/Manipulator.java'
--- DataLaboratoryAPI/src/org/gephi/datalab/spi/Manipulator.java 2010-09-07 09:00:13 +0000
+++ DataLaboratoryAPI/src/org/gephi/datalab/spi/Manipulator.java 2011-02-01 14:23:14 +0000
@@ -31,7 +31,7 @@
31 * <ul>31 * <ul>
32 * <li>Execute an action</li>32 * <li>Execute an action</li>
33 * <li>Provide a name, description, type and order of appearance (position in group of its type)</li>33 * <li>Provide a name, description, type and order of appearance (position in group of its type)</li>
34 * <li>Indicate wether they have to be executable or not</li>34 * <li>Indicate wether they have to be executable (enabled in the context menu) or not</li>
35 * <li>Provide and UI or not</li>35 * <li>Provide and UI or not</li>
36 * <li>Provide and icon or not</li>36 * <li>Provide and icon or not</li>
37 * </ul>37 * </ul>
@@ -64,9 +64,9 @@
64 String getDescription();64 String getDescription();
6565
66 /**66 /**
67 * Indicates if this Manipulator has to be shown.67 * Indicates if this Manipulator has to be executable.
68 * Implementations should evaluate the current data and conditions.68 * Implementations should evaluate the current data and conditions.
69 * @return True if it has to be shown, false otherwise69 * @return True if it has to be executable, false otherwise
70 */70 */
71 boolean canExecute();71 boolean canExecute();
7272
7373
=== added file 'DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/GeneralColumnAndValueChooser.java'
--- DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/GeneralColumnAndValueChooser.java 1970-01-01 00:00:00 +0000
+++ DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/GeneralColumnAndValueChooser.java 2011-02-01 14:23:14 +0000
@@ -0,0 +1,65 @@
1/*
2Copyright 2008-2010 Gephi
3Authors : Eduardo Ramos <eduramiba@gmail.com>
4Website : http://www.gephi.org
5
6This file is part of Gephi.
7
8Gephi is free software: you can redistribute it and/or modify
9it under the terms of the GNU Affero General Public License as
10published by the Free Software Foundation, either version 3 of the
11License, or (at your option) any later version.
12
13Gephi is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU Affero General Public License for more details.
17
18You should have received a copy of the GNU Affero General Public License
19along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.datalab.plugin.manipulators;
22
23import org.gephi.data.attributes.api.AttributeColumn;
24import org.gephi.data.attributes.api.AttributeTable;
25import org.gephi.datalab.plugin.manipulators.nodes.TagNodes;
26
27/**
28 * Interface in common for choosing a column to manipulate from a list and a String value.
29 * Used to be able to mass-tag a column of nodes/edges.
30 * @author Eduardo Ramos <eduramiba@gmail.com>
31 * @see FillNodesColumnWithValue
32 */
33public interface GeneralColumnAndValueChooser{
34
35 /**
36 * Provide columns to show in the UI to select one.
37 * Normally provide all table columns that can be manipulated.
38 * @return Columns to show in the GeneralColumnAndValueChooserUI
39 */
40 AttributeColumn[] getColumns();
41
42 /**
43 * Provide table for auto-completion of column values
44 * @return
45 */
46 AttributeTable getTable();
47
48 /**
49 * The GeneralColumnAndValueChooserUI will use this method to set the column to finally manipulate, after the GeneralColumnAndValueChooserUI is closed.
50 * @param columnsToClearData Column to manipulate
51 */
52 void setColumn(AttributeColumn column);
53
54 /**
55 * The GeneralColumnAndValueChooserUI will use this method to set the String value to finally use, after the GeneralColumnAndValueChooserUI is closed.
56 * @param columnsToClearData Column to manipulate
57 */
58 void setValue(String value);
59
60 /**
61 * Provide title for the GeneralColumnAndValueChooserUI.
62 * @return Title name
63 */
64 String getName();
65}
066
=== modified file 'DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/GeneralColumnsChooser.java'
--- DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/GeneralColumnsChooser.java 2010-12-28 14:28:46 +0000
+++ DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/GeneralColumnsChooser.java 2011-02-01 14:23:14 +0000
@@ -40,7 +40,7 @@
4040
41 /**41 /**
42 * The GeneralChooseColumnsUI will use this method to set the columns to finally manipulate, after the GeneralChooseColumnsUI is closed.42 * The GeneralChooseColumnsUI will use this method to set the columns to finally manipulate, after the GeneralChooseColumnsUI is closed.
43 * @param columnsToClearData Columns to clear43 * @param columnsToClearData Columns to manipulate
44 */44 */
45 void setColumns(AttributeColumn[] columnsToClearData);45 void setColumns(AttributeColumn[] columnsToClearData);
4646
4747
=== modified file 'DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/edges/Bundle.properties'
--- DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/edges/Bundle.properties 2010-12-29 15:36:47 +0000
+++ DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/edges/Bundle.properties 2011-02-01 14:23:14 +0000
@@ -12,6 +12,8 @@
12DeleteEdgesWithNodes.name.single=Delete edge with nodes...12DeleteEdgesWithNodes.name.single=Delete edge with nodes...
13DeleteEdgesWithNodes.name.multiple=Delete all edges with nodes...13DeleteEdgesWithNodes.name.multiple=Delete all edges with nodes...
1414
15TagEdges.name.single=Tag edge...
16TagEdges.name.multiple=Tag edges...
15ClearEdgesData.name.single=Clear...17ClearEdgesData.name.single=Clear...
16ClearEdgesData.name.multiple=Clear all...18ClearEdgesData.name.multiple=Clear all...
17ClearEdgesData.description=Clear data of the selected edges19ClearEdgesData.description=Clear data of the selected edges
1820
=== modified file 'DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/edges/ClearEdgesData.java'
--- DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/edges/ClearEdgesData.java 2010-09-07 09:00:13 +0000
+++ DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/edges/ClearEdgesData.java 2011-02-01 14:23:14 +0000
@@ -89,7 +89,7 @@
89 }89 }
9090
91 public int getPosition() {91 public int getPosition() {
92 return 0;92 return 100;
93 }93 }
9494
95 public Icon getIcon() {95 public Icon getIcon() {
9696
=== modified file 'DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/edges/CopyEdgeDataToOtherEdges.java'
--- DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/edges/CopyEdgeDataToOtherEdges.java 2010-12-28 14:28:46 +0000
+++ DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/edges/CopyEdgeDataToOtherEdges.java 2011-02-01 14:23:14 +0000
@@ -87,7 +87,7 @@
87 }87 }
8888
89 public int getPosition() {89 public int getPosition() {
90 return 100;90 return 200;
91 }91 }
9292
93 public Icon getIcon() {93 public Icon getIcon() {
9494
=== added file 'DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/edges/TagEdges.java'
--- DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/edges/TagEdges.java 1970-01-01 00:00:00 +0000
+++ DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/edges/TagEdges.java 2011-02-01 14:23:14 +0000
@@ -0,0 +1,119 @@
1/*
2Copyright 2008-2010 Gephi
3Authors : Eduardo Ramos <eduramiba@gmail.com>
4Website : http://www.gephi.org
5
6This file is part of Gephi.
7
8Gephi is free software: you can redistribute it and/or modify
9it under the terms of the GNU Affero General Public License as
10published by the Free Software Foundation, either version 3 of the
11License, or (at your option) any later version.
12
13Gephi is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU Affero General Public License for more details.
17
18You should have received a copy of the GNU Affero General Public License
19along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.datalab.plugin.manipulators.edges;
22
23import java.util.ArrayList;
24import javax.swing.Icon;
25import org.gephi.data.attributes.api.AttributeColumn;
26import org.gephi.data.attributes.api.AttributeController;
27import org.gephi.data.attributes.api.AttributeTable;
28import org.gephi.datalab.api.AttributeColumnsController;
29import org.gephi.datalab.api.DataTablesController;
30import org.gephi.datalab.plugin.manipulators.GeneralColumnAndValueChooser;
31import org.gephi.datalab.plugin.manipulators.ui.GeneralColumnAndValueChooserUI;
32import org.gephi.datalab.spi.ManipulatorUI;
33import org.gephi.datalab.spi.edges.EdgesManipulator;
34import org.gephi.graph.api.Edge;
35import org.openide.util.ImageUtilities;
36import org.openide.util.Lookup;
37import org.openide.util.NbBundle;
38
39/**
40 * Edges manipulator that fills the given column of multiple edges with a value.
41 * @author Eduardo Ramos <eduramiba@gmail.com>
42 */
43public class TagEdges implements EdgesManipulator, GeneralColumnAndValueChooser {
44
45 private Edge[] edges;
46 private AttributeColumn column;
47 private AttributeTable table;
48 private AttributeColumn[] availableColumns;
49 private String value;
50
51 public void setup(Edge[] edges, Edge clickedEdge) {
52 this.edges = edges;
53 table = Lookup.getDefault().lookup(AttributeController.class).getModel().getEdgeTable();
54 AttributeColumnsController ac = Lookup.getDefault().lookup(AttributeColumnsController.class);
55 ArrayList<AttributeColumn> availableColumnsList = new ArrayList<AttributeColumn>();
56 for (AttributeColumn c : table.getColumns()) {
57 if (ac.canChangeColumnData(c)) {
58 availableColumnsList.add(c);
59 }
60 }
61 availableColumns = availableColumnsList.toArray(new AttributeColumn[0]);
62 }
63
64 public void execute() {
65 if (column != null) {
66 AttributeColumnsController ac = Lookup.getDefault().lookup(AttributeColumnsController.class);
67 ac.fillEdgesColumnWithValue(edges, column, value);
68 Lookup.getDefault().lookup(DataTablesController.class).refreshCurrentTable();
69 }
70 }
71
72 public String getName() {
73 if (edges.length > 1) {
74 return NbBundle.getMessage(TagEdges.class, "TagEdges.name.multiple");
75 } else {
76 return NbBundle.getMessage(TagEdges.class, "TagEdges.name.single");
77 }
78 }
79
80 public String getDescription() {
81 return "";
82 }
83
84 public boolean canExecute() {
85 return edges.length > 0;
86 }
87
88 public ManipulatorUI getUI() {
89 return new GeneralColumnAndValueChooserUI();
90 }
91
92 public int getType() {
93 return 200;
94 }
95
96 public int getPosition() {
97 return 0;
98 }
99
100 public Icon getIcon() {
101 return ImageUtilities.loadImageIcon("org/gephi/datalab/plugin/manipulators/resources/tag-label.png", true);
102 }
103
104 public AttributeColumn[] getColumns() {
105 return availableColumns;
106 }
107
108 public void setColumn(AttributeColumn column) {
109 this.column = column;
110 }
111
112 public void setValue(String value) {
113 this.value = value;
114 }
115
116 public AttributeTable getTable() {
117 return table;
118 }
119}
0120
=== added file 'DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/edges/TagEdgesBuilder.java'
--- DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/edges/TagEdgesBuilder.java 1970-01-01 00:00:00 +0000
+++ DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/edges/TagEdgesBuilder.java 2011-02-01 14:23:14 +0000
@@ -0,0 +1,37 @@
1/*
2Copyright 2008-2010 Gephi
3Authors : Eduardo Ramos <eduramiba@gmail.com>
4Website : http://www.gephi.org
5
6This file is part of Gephi.
7
8Gephi is free software: you can redistribute it and/or modify
9it under the terms of the GNU Affero General Public License as
10published by the Free Software Foundation, either version 3 of the
11License, or (at your option) any later version.
12
13Gephi is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU Affero General Public License for more details.
17
18You should have received a copy of the GNU Affero General Public License
19along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.datalab.plugin.manipulators.edges;
22
23import org.gephi.datalab.spi.edges.EdgesManipulator;
24import org.gephi.datalab.spi.edges.EdgesManipulatorBuilder;
25import org.openide.util.lookup.ServiceProvider;
26
27/**
28 * Builder for TagEdges edges manipulator.
29 * @author Eduardo Ramos <eduramiba@gmail.com>
30 */
31@ServiceProvider(service=EdgesManipulatorBuilder.class)
32public class TagEdgesBuilder implements EdgesManipulatorBuilder{
33
34 public EdgesManipulator getEdgesManipulator() {
35 return new TagEdges();
36 }
37}
038
=== modified file 'DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/nodes/Bundle.properties'
--- DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/nodes/Bundle.properties 2010-12-29 15:36:47 +0000
+++ DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/nodes/Bundle.properties 2011-02-01 14:23:14 +0000
@@ -10,6 +10,8 @@
10DeleteNodes.name.multiple=Delete all10DeleteNodes.name.multiple=Delete all
11DeleteNodes.confirmation.message=Confirm nodes deletion?11DeleteNodes.confirmation.message=Confirm nodes deletion?
1212
13TagNodes.name.multiple=Tag nodes...
14TagNodes.name.single=Tag node...
13ClearNodesData.name.single=Clear...15ClearNodesData.name.single=Clear...
14ClearNodesData.name.multiple=Clear all...16ClearNodesData.name.multiple=Clear all...
15ClearNodesData.description=Clear data of the selected nodes17ClearNodesData.description=Clear data of the selected nodes
1618
=== modified file 'DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/nodes/ClearNodesData.java'
--- DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/nodes/ClearNodesData.java 2010-09-07 09:00:13 +0000
+++ DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/nodes/ClearNodesData.java 2011-02-01 14:23:14 +0000
@@ -89,7 +89,7 @@
89 }89 }
9090
91 public int getPosition() {91 public int getPosition() {
92 return 0;92 return 100;
93 }93 }
9494
95 public Icon getIcon() {95 public Icon getIcon() {
9696
=== modified file 'DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/nodes/CopyNodeDataToOtherNodes.java'
--- DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/nodes/CopyNodeDataToOtherNodes.java 2010-12-28 14:28:46 +0000
+++ DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/nodes/CopyNodeDataToOtherNodes.java 2011-02-01 14:23:14 +0000
@@ -87,7 +87,7 @@
87 }87 }
8888
89 public int getPosition() {89 public int getPosition() {
90 return 100;90 return 200;
91 }91 }
9292
93 public Icon getIcon() {93 public Icon getIcon() {
9494
=== added file 'DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/nodes/TagNodes.java'
--- DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/nodes/TagNodes.java 1970-01-01 00:00:00 +0000
+++ DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/nodes/TagNodes.java 2011-02-01 14:23:14 +0000
@@ -0,0 +1,119 @@
1/*
2Copyright 2008-2010 Gephi
3Authors : Eduardo Ramos <eduramiba@gmail.com>
4Website : http://www.gephi.org
5
6This file is part of Gephi.
7
8Gephi is free software: you can redistribute it and/or modify
9it under the terms of the GNU Affero General Public License as
10published by the Free Software Foundation, either version 3 of the
11License, or (at your option) any later version.
12
13Gephi is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU Affero General Public License for more details.
17
18You should have received a copy of the GNU Affero General Public License
19along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.datalab.plugin.manipulators.nodes;
22
23import java.util.ArrayList;
24import javax.swing.Icon;
25import org.gephi.data.attributes.api.AttributeColumn;
26import org.gephi.data.attributes.api.AttributeController;
27import org.gephi.data.attributes.api.AttributeTable;
28import org.gephi.datalab.api.AttributeColumnsController;
29import org.gephi.datalab.api.DataTablesController;
30import org.gephi.datalab.plugin.manipulators.GeneralColumnAndValueChooser;
31import org.gephi.datalab.plugin.manipulators.ui.GeneralColumnAndValueChooserUI;
32import org.gephi.datalab.spi.ManipulatorUI;
33import org.gephi.datalab.spi.nodes.NodesManipulator;
34import org.gephi.graph.api.Node;
35import org.openide.util.ImageUtilities;
36import org.openide.util.Lookup;
37import org.openide.util.NbBundle;
38
39/**
40 * Nodes manipulator that fills the given column of multiple nodes with a value.
41 * @author Eduardo Ramos <eduramiba@gmail.com>
42 */
43public class TagNodes implements NodesManipulator, GeneralColumnAndValueChooser {
44
45 private Node[] nodes;
46 private AttributeColumn column;
47 private AttributeTable table;
48 private AttributeColumn[] availableColumns;
49 private String value;
50
51 public void setup(Node[] nodes, Node clickedNode) {
52 this.nodes = nodes;
53 table = Lookup.getDefault().lookup(AttributeController.class).getModel().getNodeTable();
54 AttributeColumnsController ac = Lookup.getDefault().lookup(AttributeColumnsController.class);
55 ArrayList<AttributeColumn> availableColumnsList = new ArrayList<AttributeColumn>();
56 for (AttributeColumn c : table.getColumns()) {
57 if (ac.canChangeColumnData(c)) {
58 availableColumnsList.add(c);
59 }
60 }
61 availableColumns = availableColumnsList.toArray(new AttributeColumn[0]);
62 }
63
64 public void execute() {
65 if (column != null) {
66 AttributeColumnsController ac = Lookup.getDefault().lookup(AttributeColumnsController.class);
67 ac.fillNodesColumnWithValue(nodes, column, value);
68 Lookup.getDefault().lookup(DataTablesController.class).refreshCurrentTable();
69 }
70 }
71
72 public String getName() {
73 if (nodes.length > 1) {
74 return NbBundle.getMessage(TagNodes.class, "TagNodes.name.multiple");
75 } else {
76 return NbBundle.getMessage(TagNodes.class, "TagNodes.name.single");
77 }
78 }
79
80 public String getDescription() {
81 return "";
82 }
83
84 public boolean canExecute() {
85 return nodes.length > 0;
86 }
87
88 public ManipulatorUI getUI() {
89 return new GeneralColumnAndValueChooserUI();
90 }
91
92 public int getType() {
93 return 200;
94 }
95
96 public int getPosition() {
97 return 0;
98 }
99
100 public Icon getIcon() {
101 return ImageUtilities.loadImageIcon("org/gephi/datalab/plugin/manipulators/resources/tag-label.png", true);
102 }
103
104 public AttributeColumn[] getColumns() {
105 return availableColumns;
106 }
107
108 public void setColumn(AttributeColumn column) {
109 this.column = column;
110 }
111
112 public void setValue(String value) {
113 this.value = value;
114 }
115
116 public AttributeTable getTable() {
117 return table;
118 }
119}
0120
=== added file 'DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/nodes/TagNodesBuilder.java'
--- DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/nodes/TagNodesBuilder.java 1970-01-01 00:00:00 +0000
+++ DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/nodes/TagNodesBuilder.java 2011-02-01 14:23:14 +0000
@@ -0,0 +1,38 @@
1/*
2Copyright 2008-2010 Gephi
3Authors : Eduardo Ramos <eduramiba@gmail.com>
4Website : http://www.gephi.org
5
6This file is part of Gephi.
7
8Gephi is free software: you can redistribute it and/or modify
9it under the terms of the GNU Affero General Public License as
10published by the Free Software Foundation, either version 3 of the
11License, or (at your option) any later version.
12
13Gephi is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU Affero General Public License for more details.
17
18You should have received a copy of the GNU Affero General Public License
19along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.datalab.plugin.manipulators.nodes;
22
23import org.gephi.datalab.spi.nodes.NodesManipulator;
24import org.gephi.datalab.spi.nodes.NodesManipulatorBuilder;
25import org.openide.util.lookup.ServiceProvider;
26
27/**
28 * Builder for TagNodes nodes manipulator.
29 * @author Eduardo Ramos <eduramiba@gmail.com>
30 */
31@ServiceProvider(service=NodesManipulatorBuilder.class)
32public class TagNodesBuilder implements NodesManipulatorBuilder{
33
34 public NodesManipulator getNodesManipulator() {
35 return new TagNodes();
36 }
37
38}
039
=== added file 'DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/resources/tag-label.png'
1Binary files DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/resources/tag-label.png 1970-01-01 00:00:00 +0000 and DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/resources/tag-label.png 2011-02-01 14:23:14 +0000 differ40Binary files DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/resources/tag-label.png 1970-01-01 00:00:00 +0000 and DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/resources/tag-label.png 2011-02-01 14:23:14 +0000 differ
=== modified file 'DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/ui/Bundle.properties'
--- DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/ui/Bundle.properties 2010-09-07 09:00:13 +0000
+++ DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/ui/Bundle.properties 2011-02-01 14:23:14 +0000
@@ -5,3 +5,6 @@
5GeneralNumberListStatisticsReportUI.useLinearRegression.text=Show linear regression5GeneralNumberListStatisticsReportUI.useLinearRegression.text=Show linear regression
6GeneralNumberListStatisticsReportUI.configureHistogramButton.text=Configure Histogram6GeneralNumberListStatisticsReportUI.configureHistogramButton.text=Configure Histogram
7GeneralNumberListStatisticsReportUI.divisionsLabel.text=Divisions:7GeneralNumberListStatisticsReportUI.divisionsLabel.text=Divisions:
8GeneralColumnAndValueChooserUI.columnLabel.text=Column:
9GeneralColumnAndValueChooserUI.valueLabel.text=Value:
10GeneralColumnAndValueChooserUI.autoComplete.text=Auto- complete
811
=== added file 'DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/ui/GeneralColumnAndValueChooserUI.form'
--- DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/ui/GeneralColumnAndValueChooserUI.form 1970-01-01 00:00:00 +0000
+++ DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/ui/GeneralColumnAndValueChooserUI.form 2011-02-01 14:23:14 +0000
@@ -0,0 +1,102 @@
1<?xml version="1.1" encoding="UTF-8" ?>
2
3<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
4 <AuxValues>
5 <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
6 <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
7 <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
8 <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
9 <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
10 <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
11 <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
12 <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
13 <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
14 </AuxValues>
15
16 <Layout>
17 <DimensionLayout dim="0">
18 <Group type="103" groupAlignment="0" attributes="0">
19 <Group type="102" alignment="0" attributes="0">
20 <EmptySpace min="-2" max="-2" attributes="0"/>
21 <Group type="103" groupAlignment="1" max="-2" attributes="0">
22 <Component id="valueLabel" alignment="0" max="32767" attributes="1"/>
23 <Component id="columnLabel" alignment="0" pref="63" max="32767" attributes="1"/>
24 </Group>
25 <EmptySpace min="-2" max="-2" attributes="0"/>
26 <Group type="103" groupAlignment="0" attributes="0">
27 <Group type="102" attributes="0">
28 <Component id="valueComboBox" pref="145" max="32767" attributes="0"/>
29 <EmptySpace min="-2" max="-2" attributes="0"/>
30 <Component id="autoComplete" min="-2" max="-2" attributes="0"/>
31 </Group>
32 <Component id="columnComboBox" pref="246" max="32767" attributes="0"/>
33 </Group>
34 <EmptySpace min="-2" max="-2" attributes="0"/>
35 </Group>
36 </Group>
37 </DimensionLayout>
38 <DimensionLayout dim="1">
39 <Group type="103" groupAlignment="0" attributes="0">
40 <Group type="102" alignment="0" attributes="0">
41 <EmptySpace max="-2" attributes="0"/>
42 <Group type="103" groupAlignment="3" attributes="0">
43 <Component id="columnLabel" alignment="3" min="-2" max="-2" attributes="0"/>
44 <Component id="columnComboBox" alignment="3" min="-2" max="-2" attributes="0"/>
45 </Group>
46 <EmptySpace type="unrelated" max="-2" attributes="0"/>
47 <Group type="103" groupAlignment="3" attributes="0">
48 <Component id="valueLabel" alignment="3" min="-2" max="-2" attributes="0"/>
49 <Component id="valueComboBox" alignment="3" min="-2" max="-2" attributes="0"/>
50 <Component id="autoComplete" alignment="3" min="-2" max="-2" attributes="0"/>
51 </Group>
52 <EmptySpace max="32767" attributes="0"/>
53 </Group>
54 </Group>
55 </DimensionLayout>
56 </Layout>
57 <SubComponents>
58 <Component class="javax.swing.JComboBox" name="columnComboBox">
59 <Properties>
60 <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
61 <StringArray count="0"/>
62 </Property>
63 </Properties>
64 <Events>
65 <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="columnComboBoxItemStateChanged"/>
66 </Events>
67 </Component>
68 <Component class="javax.swing.JLabel" name="columnLabel">
69 <Properties>
70 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
71 <ResourceString bundle="org/gephi/datalab/plugin/manipulators/ui/Bundle.properties" key="GeneralColumnAndValueChooserUI.columnLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
72 </Property>
73 </Properties>
74 </Component>
75 <Component class="javax.swing.JLabel" name="valueLabel">
76 <Properties>
77 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
78 <ResourceString bundle="org/gephi/datalab/plugin/manipulators/ui/Bundle.properties" key="GeneralColumnAndValueChooserUI.valueLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
79 </Property>
80 </Properties>
81 </Component>
82 <Component class="javax.swing.JComboBox" name="valueComboBox">
83 <Properties>
84 <Property name="editable" type="boolean" value="true"/>
85 <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
86 <StringArray count="0"/>
87 </Property>
88 </Properties>
89 </Component>
90 <Component class="javax.swing.JCheckBox" name="autoComplete">
91 <Properties>
92 <Property name="selected" type="boolean" value="true"/>
93 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
94 <ResourceString bundle="org/gephi/datalab/plugin/manipulators/ui/Bundle.properties" key="GeneralColumnAndValueChooserUI.autoComplete.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
95 </Property>
96 </Properties>
97 <Events>
98 <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="autoCompleteActionPerformed"/>
99 </Events>
100 </Component>
101 </SubComponents>
102</Form>
0103
=== added file 'DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/ui/GeneralColumnAndValueChooserUI.java'
--- DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/ui/GeneralColumnAndValueChooserUI.java 1970-01-01 00:00:00 +0000
+++ DataLaboratoryPlugin/src/org/gephi/datalab/plugin/manipulators/ui/GeneralColumnAndValueChooserUI.java 2011-02-01 14:23:14 +0000
@@ -0,0 +1,218 @@
1/*
2Copyright 2008-2010 Gephi
3Authors : Eduardo Ramos <eduramiba@gmail.com>
4Website : http://www.gephi.org
5
6This file is part of Gephi.
7
8Gephi is free software: you can redistribute it and/or modify
9it under the terms of the GNU Affero General Public License as
10published by the Free Software Foundation, either version 3 of the
11License, or (at your option) any later version.
12
13Gephi is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU Affero General Public License for more details.
17
18You should have received a copy of the GNU Affero General Public License
19along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.datalab.plugin.manipulators.ui;
22
23import java.util.ArrayList;
24import javax.swing.JPanel;
25import org.gephi.data.attributes.api.AttributeColumn;
26import org.gephi.data.attributes.api.AttributeTable;
27import org.gephi.datalab.api.AttributeColumnsController;
28import org.gephi.datalab.plugin.manipulators.GeneralColumnAndValueChooser;
29import org.gephi.datalab.spi.DialogControls;
30import org.gephi.datalab.spi.Manipulator;
31import org.gephi.datalab.spi.ManipulatorUI;
32import org.gephi.graph.api.Attributes;
33import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;
34import org.openide.util.Lookup;
35import org.openide.util.NbPreferences;
36
37/**
38 * UI for GeneralColumnAndValueChooser
39 * @author Eduardo Ramos <eduramiba@gmail.com>
40 */
41public class GeneralColumnAndValueChooserUI extends javax.swing.JPanel implements ManipulatorUI {
42
43 private static final String AUTO_COMPLETE_SAVED_PREFERENCES = "GeneralColumnAndValueChooserUI_autoComplete";
44 private GeneralColumnAndValueChooser manipulator;
45 private AttributeColumn[] columns;
46 private AttributeTable table;
47 private String values[];
48 private static String lastChosenColumn=null;//To try to preserve last chosen column only while this program execution.
49
50 /** Creates new form GeneralColumnAndValueChooserUI */
51 public GeneralColumnAndValueChooserUI() {
52 initComponents();
53 }
54
55 public void setup(Manipulator m, DialogControls dialogControls) {
56 this.manipulator = (GeneralColumnAndValueChooser) m;
57 this.table = manipulator.getTable();
58 refreshColumns();
59 autoComplete.setSelected(NbPreferences.forModule(GeneralChooseColumnsAndRowUI.class).getBoolean(AUTO_COMPLETE_SAVED_PREFERENCES, false));
60 refreshAutoComplete();
61 }
62
63 public void unSetup() {
64 manipulator.setColumn(getChosenColumn());
65 manipulator.setValue(valueComboBox.getSelectedItem() != null ? valueComboBox.getSelectedItem().toString() : null);
66 NbPreferences.forModule(GeneralChooseColumnsAndRowUI.class).putBoolean(AUTO_COMPLETE_SAVED_PREFERENCES, autoComplete.isSelected());
67 lastChosenColumn=getChosenColumn().getTitle();
68 }
69
70 public String getDisplayName() {
71 return manipulator.getName();
72 }
73
74 public JPanel getSettingsPanel() {
75 return this;
76 }
77
78 public boolean isModal() {
79 return true;
80 }
81
82 public AttributeColumn getChosenColumn() {
83 if (columnComboBox.getSelectedIndex() != -1) {
84 return columns[columnComboBox.getSelectedIndex()];
85 } else {
86 return null;
87 }
88 }
89
90 private void refreshColumns() {
91 columns = manipulator.getColumns();
92 for (int i = 0; i < columns.length; i++) {
93 columnComboBox.addItem(columns[i].getTitle());
94 }
95 if(lastChosenColumn!=null&&!lastChosenColumn.isEmpty()){
96 columnComboBox.setSelectedItem(lastChosenColumn);
97 }
98 }
99 private int lastFetchedColumn = -1;
100
101 private void refreshAutoComplete() {
102 Object currentValue = valueComboBox.getSelectedItem();
103 if (autoComplete.isSelected()) {
104 AttributeColumn column = getChosenColumn();
105 if (column != null) {
106 if ((lastFetchedColumn != columnComboBox.getSelectedIndex()) || values == null) {
107 ArrayList<String> valuesList = new ArrayList<String>();
108 Object value;
109 String str;
110 for (Attributes row : Lookup.getDefault().lookup(AttributeColumnsController.class).getTableAttributeRows(table)) {
111 value = row.getValue(column.getId());
112 if (value != null) {
113 str = value.toString();
114 if (!valuesList.contains(str)) {
115 valuesList.add(str);
116 }
117 }
118 }
119
120 values = valuesList.toArray(new String[0]);
121 lastFetchedColumn = columnComboBox.getSelectedIndex();
122 }
123 valueComboBox.removeAllItems();
124 for (String item : values) {
125 valueComboBox.addItem(item);
126 }
127 AutoCompleteDecorator.decorate(valueComboBox);
128 }
129 } else {
130 valueComboBox.removeAllItems();
131 }
132 valueComboBox.setSelectedItem(currentValue);
133 }
134
135 /** This method is called from within the constructor to
136 * initialize the form.
137 * WARNING: Do NOT modify this code. The content of this method is
138 * always regenerated by the Form Editor.
139 */
140 @SuppressWarnings("unchecked")
141 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
142 private void initComponents() {
143
144 columnComboBox = new javax.swing.JComboBox();
145 columnLabel = new javax.swing.JLabel();
146 valueLabel = new javax.swing.JLabel();
147 valueComboBox = new javax.swing.JComboBox();
148 autoComplete = new javax.swing.JCheckBox();
149
150 columnComboBox.addItemListener(new java.awt.event.ItemListener() {
151 public void itemStateChanged(java.awt.event.ItemEvent evt) {
152 columnComboBoxItemStateChanged(evt);
153 }
154 });
155
156 columnLabel.setText(org.openide.util.NbBundle.getMessage(GeneralColumnAndValueChooserUI.class, "GeneralColumnAndValueChooserUI.columnLabel.text")); // NOI18N
157
158 valueLabel.setText(org.openide.util.NbBundle.getMessage(GeneralColumnAndValueChooserUI.class, "GeneralColumnAndValueChooserUI.valueLabel.text")); // NOI18N
159
160 valueComboBox.setEditable(true);
161
162 autoComplete.setSelected(true);
163 autoComplete.setText(org.openide.util.NbBundle.getMessage(GeneralColumnAndValueChooserUI.class, "GeneralColumnAndValueChooserUI.autoComplete.text")); // NOI18N
164 autoComplete.addActionListener(new java.awt.event.ActionListener() {
165 public void actionPerformed(java.awt.event.ActionEvent evt) {
166 autoCompleteActionPerformed(evt);
167 }
168 });
169
170 javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
171 this.setLayout(layout);
172 layout.setHorizontalGroup(
173 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
174 .addGroup(layout.createSequentialGroup()
175 .addContainerGap()
176 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
177 .addComponent(valueLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
178 .addComponent(columnLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 63, Short.MAX_VALUE))
179 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
180 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
181 .addGroup(layout.createSequentialGroup()
182 .addComponent(valueComboBox, 0, 145, Short.MAX_VALUE)
183 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
184 .addComponent(autoComplete))
185 .addComponent(columnComboBox, 0, 246, Short.MAX_VALUE))
186 .addContainerGap())
187 );
188 layout.setVerticalGroup(
189 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
190 .addGroup(layout.createSequentialGroup()
191 .addContainerGap()
192 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
193 .addComponent(columnLabel)
194 .addComponent(columnComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
195 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
196 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
197 .addComponent(valueLabel)
198 .addComponent(valueComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
199 .addComponent(autoComplete))
200 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
201 );
202 }// </editor-fold>//GEN-END:initComponents
203
204 private void autoCompleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_autoCompleteActionPerformed
205 refreshAutoComplete();
206 }//GEN-LAST:event_autoCompleteActionPerformed
207
208 private void columnComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_columnComboBoxItemStateChanged
209 refreshAutoComplete();
210 }//GEN-LAST:event_columnComboBoxItemStateChanged
211 // Variables declaration - do not modify//GEN-BEGIN:variables
212 private javax.swing.JCheckBox autoComplete;
213 private javax.swing.JComboBox columnComboBox;
214 private javax.swing.JLabel columnLabel;
215 private javax.swing.JComboBox valueComboBox;
216 private javax.swing.JLabel valueLabel;
217 // End of variables declaration//GEN-END:variables
218}
0219
=== modified file 'DesktopBranding/src/org/gephi/branding/desktop/multilingual/LanguageAction.java'
--- DesktopBranding/src/org/gephi/branding/desktop/multilingual/LanguageAction.java 2010-12-20 00:55:12 +0000
+++ DesktopBranding/src/org/gephi/branding/desktop/multilingual/LanguageAction.java 2011-02-01 14:23:14 +0000
@@ -45,9 +45,9 @@
4545
46 public enum Language {46 public enum Language {
4747
48 EN_US("en", "English");48 EN_US("en", "English"),
49 //FR_FR("fr", "Français"),49 FR_FR("fr", "Français"),
50 //ES_ES("es", "Español");50 ES_ES("es", "Español");
51 private String locale;51 private String locale;
52 private String name;52 private String name;
5353
5454
=== modified file 'DesktopDataLaboratory/nbproject/genfiles.properties'
--- DesktopDataLaboratory/nbproject/genfiles.properties 2010-09-11 15:09:14 +0000
+++ DesktopDataLaboratory/nbproject/genfiles.properties 2011-02-01 14:23:14 +0000
@@ -1,8 +1,8 @@
1build.xml.data.CRC32=acfd74171build.xml.data.CRC32=93720211
2build.xml.script.CRC32=e39c7ed02build.xml.script.CRC32=e39c7ed0
3build.xml.stylesheet.CRC32=a56c6a5b@1.42.23build.xml.stylesheet.CRC32=a56c6a5b@1.42.2
4# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.4# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
5# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.5# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6nbproject/build-impl.xml.data.CRC32=acfd74176nbproject/build-impl.xml.data.CRC32=93720211
7nbproject/build-impl.xml.script.CRC32=91e63bf07nbproject/build-impl.xml.script.CRC32=91e63bf0
8nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.42.28nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.42.2
99
=== modified file 'DesktopDataLaboratory/nbproject/project.xml'
--- DesktopDataLaboratory/nbproject/project.xml 2010-09-11 15:09:14 +0000
+++ DesktopDataLaboratory/nbproject/project.xml 2011-02-01 14:23:14 +0000
@@ -23,14 +23,6 @@
23 </run-dependency>23 </run-dependency>
24 </dependency>24 </dependency>
25 <dependency>25 <dependency>
26 <code-name-base>org.gephi.datalab.plugin</code-name-base>
27 <build-prerequisite/>
28 <compile-dependency/>
29 <run-dependency>
30 <specification-version>0.7.1</specification-version>
31 </run-dependency>
32 </dependency>
33 <dependency>
34 <code-name-base>org.gephi.dynamic.api</code-name-base>26 <code-name-base>org.gephi.dynamic.api</code-name-base>
35 <build-prerequisite/>27 <build-prerequisite/>
36 <compile-dependency/>28 <compile-dependency/>
3729
=== modified file 'DesktopDataLaboratory/src/org/gephi/desktop/datalab/DataTableTopComponent.java'
--- DesktopDataLaboratory/src/org/gephi/desktop/datalab/DataTableTopComponent.java 2010-12-28 14:28:46 +0000
+++ DesktopDataLaboratory/src/org/gephi/desktop/datalab/DataTableTopComponent.java 2011-02-01 14:23:14 +0000
@@ -54,6 +54,7 @@
54import org.gephi.data.attributes.api.AttributeListener;54import org.gephi.data.attributes.api.AttributeListener;
55import org.gephi.data.attributes.api.AttributeModel;55import org.gephi.data.attributes.api.AttributeModel;
56import org.gephi.data.attributes.api.AttributeTable;56import org.gephi.data.attributes.api.AttributeTable;
57import org.gephi.datalab.api.DataLaboratoryHelper;
57import org.gephi.datalab.api.DataTablesController;58import org.gephi.datalab.api.DataTablesController;
58import org.gephi.datalab.api.DataTablesEventListener;59import org.gephi.datalab.api.DataTablesEventListener;
59import org.gephi.datalab.spi.columns.AttributeColumnsManipulator;60import org.gephi.datalab.spi.columns.AttributeColumnsManipulator;
@@ -74,7 +75,6 @@
74import org.gephi.desktop.datalab.general.actions.AddColumnUI;75import org.gephi.desktop.datalab.general.actions.AddColumnUI;
75import org.gephi.desktop.datalab.general.actions.CSVExportUI;76import org.gephi.desktop.datalab.general.actions.CSVExportUI;
76import org.gephi.desktop.datalab.general.actions.MergeColumnsUI;77import org.gephi.desktop.datalab.general.actions.MergeColumnsUI;
77import org.gephi.desktop.datalab.utils.DataLaboratoryHelper;
78import org.gephi.ui.utils.DialogFileFilter;78import org.gephi.ui.utils.DialogFileFilter;
79import org.gephi.ui.utils.UIUtils;79import org.gephi.ui.utils.UIUtils;
80import org.gephi.utils.TableCSVExporter;80import org.gephi.utils.TableCSVExporter;
@@ -298,7 +298,7 @@
298 }298 }
299299
300 private synchronized void refreshAll() {300 private synchronized void refreshAll() {
301 if (Lookup.getDefault().lookup(ProjectController.class).getCurrentWorkspace()!=null) {//Some workspace is selected301 if (Lookup.getDefault().lookup(ProjectController.class).getCurrentWorkspace() != null) {//Some workspace is selected
302 refreshTable();302 refreshTable();
303 refreshColumnManipulators();303 refreshColumnManipulators();
304 refreshGeneralActionsButtons();304 refreshGeneralActionsButtons();
@@ -741,7 +741,7 @@
741 columns = edgeAvailableColumnsModel.getAvailableColumns();741 columns = edgeAvailableColumnsModel.getAvailableColumns();
742 }742 }
743743
744 DataLaboratoryHelper dlh = new DataLaboratoryHelper();744 DataLaboratoryHelper dlh = DataLaboratoryHelper.getDefault();
745 AttributeColumnsManipulator[] manipulators = dlh.getAttributeColumnsManipulators();745 AttributeColumnsManipulator[] manipulators = dlh.getAttributeColumnsManipulators();
746746
747 JCommandButtonStrip currentButtonGroup = new JCommandButtonStrip(JCommandButtonStrip.StripOrientation.HORIZONTAL);747 JCommandButtonStrip currentButtonGroup = new JCommandButtonStrip(JCommandButtonStrip.StripOrientation.HORIZONTAL);
@@ -802,7 +802,7 @@
802 button.addActionListener(new ActionListener() {802 button.addActionListener(new ActionListener() {
803803
804 public void actionPerformed(ActionEvent e) {804 public void actionPerformed(ActionEvent e) {
805 new DataLaboratoryHelper().executeAttributeColumnsManipulator(acm, table, column);805 DataLaboratoryHelper.getDefault().executeAttributeColumnsManipulator(acm, table, column);
806 }806 }
807 });807 });
808 popup.addMenuButton(button);808 popup.addMenuButton(button);
@@ -924,7 +924,7 @@
924 //Figure out the index to place the buttons, in order to put them between separator 2 and the boxGlue.924 //Figure out the index to place the buttons, in order to put them between separator 2 and the boxGlue.
925 int index = controlToolbar.getComponentIndex(boxGlue);925 int index = controlToolbar.getComponentIndex(boxGlue);
926926
927 final DataLaboratoryHelper dlh = new DataLaboratoryHelper();927 final DataLaboratoryHelper dlh = DataLaboratoryHelper.getDefault();
928 JButton button;928 JButton button;
929 for (final GeneralActionsManipulator m : dlh.getGeneralActionsManipulators()) {929 for (final GeneralActionsManipulator m : dlh.getGeneralActionsManipulators()) {
930 button = new JButton(m.getName(), m.getIcon());930 button = new JButton(m.getName(), m.getIcon());
@@ -996,7 +996,7 @@
996 button.addActionListener(new ActionListener() {996 button.addActionListener(new ActionListener() {
997997
998 public void actionPerformed(ActionEvent e) {998 public void actionPerformed(ActionEvent e) {
999 new DataLaboratoryHelper().executeManipulator(m);999 DataLaboratoryHelper.getDefault().executeManipulator(m);
1000 }1000 }
1001 });1001 });
1002 } else {1002 } else {
@@ -1053,8 +1053,11 @@
1053 KeyEvent evt = (KeyEvent) event;1053 KeyEvent evt = (KeyEvent) event;
10541054
1055 if (evt.getID() == KeyEvent.KEY_RELEASED && (evt.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0 && evt.getKeyCode() == KeyEvent.VK_F) {1055 if (evt.getID() == KeyEvent.KEY_RELEASED && (evt.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0 && evt.getKeyCode() == KeyEvent.VK_F) {
1056 DataLaboratoryHelper dlh = new DataLaboratoryHelper();1056 DataLaboratoryHelper dlh = DataLaboratoryHelper.getDefault();
1057 dlh.executeManipulator(dlh.getSearchReplaceManipulator());1057 GeneralActionsManipulator gam=dlh.getGeneralActionsManipulatorByName("SearchReplace");
1058 if (gam!=null) {
1059 dlh.executeManipulator(gam);
1060 }
1058 evt.consume();1061 evt.consume();
1059 }1062 }
1060 }1063 }
10611064
=== modified file 'DesktopDataLaboratory/src/org/gephi/desktop/datalab/EdgeDataTable.java'
--- DesktopDataLaboratory/src/org/gephi/desktop/datalab/EdgeDataTable.java 2010-10-14 21:06:13 +0000
+++ DesktopDataLaboratory/src/org/gephi/desktop/datalab/EdgeDataTable.java 2011-02-01 14:23:14 +0000
@@ -56,8 +56,8 @@
56import org.gephi.data.attributes.type.NumberList;56import org.gephi.data.attributes.type.NumberList;
57import org.gephi.data.attributes.type.TimeInterval;57import org.gephi.data.attributes.type.TimeInterval;
58import org.gephi.datalab.api.AttributeColumnsController;58import org.gephi.datalab.api.AttributeColumnsController;
59import org.gephi.datalab.api.DataLaboratoryHelper;
59import org.gephi.datalab.spi.edges.EdgesManipulator;60import org.gephi.datalab.spi.edges.EdgesManipulator;
60import org.gephi.desktop.datalab.utils.DataLaboratoryHelper;
61import org.gephi.graph.api.Edge;61import org.gephi.graph.api.Edge;
62import org.gephi.graph.api.HierarchicalGraph;62import org.gephi.graph.api.HierarchicalGraph;
63import org.gephi.tools.api.EditWindowController;63import org.gephi.tools.api.EditWindowController;
@@ -182,10 +182,10 @@
182 @Override182 @Override
183 public void keyReleased(KeyEvent e) {183 public void keyReleased(KeyEvent e) {
184 if (e.getKeyCode() == KeyEvent.VK_DELETE) {184 if (e.getKeyCode() == KeyEvent.VK_DELETE) {
185 DataLaboratoryHelper dlh = DataLaboratoryHelper.getDefault();
185 Edge[] selectedEdges = getEdgesFromSelectedRows();186 Edge[] selectedEdges = getEdgesFromSelectedRows();
186 if (selectedEdges.length > 0) {187 if (selectedEdges.length > 0) {
187 DataLaboratoryHelper dlh = new DataLaboratoryHelper();188 EdgesManipulator del = dlh.getEdgesManipulatorByName("DeleteEdges");
188 EdgesManipulator del = dlh.getDeleEdgesManipulator();
189 if (del != null) {189 if (del != null) {
190 del.setup(selectedEdges, null);190 del.setup(selectedEdges, null);
191 if (del.canExecute()) {191 if (del.canExecute()) {
@@ -576,7 +576,7 @@
576 JPopupMenu contextMenu = new JPopupMenu();576 JPopupMenu contextMenu = new JPopupMenu();
577577
578 //First add edges manipulators items:578 //First add edges manipulators items:
579 DataLaboratoryHelper dlh = new DataLaboratoryHelper();579 DataLaboratoryHelper dlh = DataLaboratoryHelper.getDefault();
580 Integer lastManipulatorType = null;580 Integer lastManipulatorType = null;
581 for (EdgesManipulator em : dlh.getEdgesManipulators()) {581 for (EdgesManipulator em : dlh.getEdgesManipulators()) {
582 em.setup(selectedEdges, clickedEdge);582 em.setup(selectedEdges, clickedEdge);
583583
=== modified file 'DesktopDataLaboratory/src/org/gephi/desktop/datalab/NodeDataTable.java'
--- DesktopDataLaboratory/src/org/gephi/desktop/datalab/NodeDataTable.java 2010-12-28 14:28:46 +0000
+++ DesktopDataLaboratory/src/org/gephi/desktop/datalab/NodeDataTable.java 2011-02-01 14:23:14 +0000
@@ -58,6 +58,7 @@
58import org.gephi.data.attributes.type.NumberList;58import org.gephi.data.attributes.type.NumberList;
59import org.gephi.data.attributes.type.TimeInterval;59import org.gephi.data.attributes.type.TimeInterval;
60import org.gephi.datalab.api.AttributeColumnsController;60import org.gephi.datalab.api.AttributeColumnsController;
61import org.gephi.datalab.api.DataLaboratoryHelper;
61import org.gephi.dynamic.api.DynamicModel.TimeFormat;62import org.gephi.dynamic.api.DynamicModel.TimeFormat;
62import org.gephi.graph.api.HierarchicalGraph;63import org.gephi.graph.api.HierarchicalGraph;
63import org.gephi.graph.api.ImmutableTreeNode;64import org.gephi.graph.api.ImmutableTreeNode;
@@ -71,7 +72,6 @@
71import org.openide.awt.MouseUtils;72import org.openide.awt.MouseUtils;
72import org.openide.util.Lookup;73import org.openide.util.Lookup;
73import org.gephi.datalab.spi.nodes.NodesManipulator;74import org.gephi.datalab.spi.nodes.NodesManipulator;
74import org.gephi.desktop.datalab.utils.DataLaboratoryHelper;
75import org.gephi.graph.api.Attributes;75import org.gephi.graph.api.Attributes;
76import org.gephi.tools.api.EditWindowController;76import org.gephi.tools.api.EditWindowController;
77import org.gephi.desktop.datalab.utils.PopupMenuUtils;77import org.gephi.desktop.datalab.utils.PopupMenuUtils;
@@ -148,10 +148,10 @@
148 @Override148 @Override
149 public void keyReleased(KeyEvent e) {149 public void keyReleased(KeyEvent e) {
150 if (e.getKeyCode() == KeyEvent.VK_DELETE) {150 if (e.getKeyCode() == KeyEvent.VK_DELETE) {
151 DataLaboratoryHelper dlh = DataLaboratoryHelper.getDefault();
151 Node[] selectedNodes = getNodesFromSelectedRows();152 Node[] selectedNodes = getNodesFromSelectedRows();
152 if (selectedNodes.length > 0) {153 if (selectedNodes.length > 0) {
153 DataLaboratoryHelper dlh = new DataLaboratoryHelper();154 NodesManipulator del = dlh.getNodesManipulatorByName("DeleteNodes");
154 NodesManipulator del = dlh.getDeleteNodesManipulator();
155 if (del != null) {155 if (del != null) {
156 del.setup(selectedNodes, null);156 del.setup(selectedNodes, null);
157 if (del.canExecute()) {157 if (del.canExecute()) {
@@ -567,7 +567,7 @@
567 JPopupMenu contextMenu = new JPopupMenu();567 JPopupMenu contextMenu = new JPopupMenu();
568568
569 //First add nodes manipulators items:569 //First add nodes manipulators items:
570 DataLaboratoryHelper dlh = new DataLaboratoryHelper();570 DataLaboratoryHelper dlh = DataLaboratoryHelper.getDefault();
571 Integer lastManipulatorType = null;571 Integer lastManipulatorType = null;
572 for (NodesManipulator nm : dlh.getNodesManipulators()) {572 for (NodesManipulator nm : dlh.getNodesManipulators()) {
573 nm.setup(selectedNodes, clickedNode);573 nm.setup(selectedNodes, clickedNode);
574574
=== modified file 'DesktopDataLaboratory/src/org/gephi/desktop/datalab/general/actions/MergeColumnsUI.java'
--- DesktopDataLaboratory/src/org/gephi/desktop/datalab/general/actions/MergeColumnsUI.java 2010-12-28 14:28:46 +0000
+++ DesktopDataLaboratory/src/org/gephi/desktop/datalab/general/actions/MergeColumnsUI.java 2011-02-01 14:23:14 +0000
@@ -32,8 +32,8 @@
32import org.gephi.data.attributes.api.AttributeColumn;32import org.gephi.data.attributes.api.AttributeColumn;
33import org.gephi.data.attributes.api.AttributeController;33import org.gephi.data.attributes.api.AttributeController;
34import org.gephi.data.attributes.api.AttributeTable;34import org.gephi.data.attributes.api.AttributeTable;
35import org.gephi.datalab.api.DataLaboratoryHelper;
35import org.gephi.datalab.spi.columns.merge.AttributeColumnsMergeStrategy;36import org.gephi.datalab.spi.columns.merge.AttributeColumnsMergeStrategy;
36import org.gephi.desktop.datalab.utils.DataLaboratoryHelper;
37import org.gephi.ui.components.richtooltip.RichTooltip;37import org.gephi.ui.components.richtooltip.RichTooltip;
38import org.netbeans.validation.api.Problems;38import org.netbeans.validation.api.Problems;
39import org.netbeans.validation.api.Validator;39import org.netbeans.validation.api.Validator;
@@ -153,7 +153,7 @@
153 if (columnsToMerge.length < 1) {153 if (columnsToMerge.length < 1) {
154 return;154 return;
155 }155 }
156 AttributeColumnsMergeStrategy[] strategies = new DataLaboratoryHelper().getAttributeColumnsMergeStrategies();156 AttributeColumnsMergeStrategy[] strategies = DataLaboratoryHelper.getDefault().getAttributeColumnsMergeStrategies();
157 ArrayList<AttributeColumnsMergeStrategy> availableStrategiesList = new ArrayList<AttributeColumnsMergeStrategy>();157 ArrayList<AttributeColumnsMergeStrategy> availableStrategiesList = new ArrayList<AttributeColumnsMergeStrategy>();
158 for (AttributeColumnsMergeStrategy strategy : strategies) {158 for (AttributeColumnsMergeStrategy strategy : strategies) {
159 strategy.setup(table, columnsToMerge);159 strategy.setup(table, columnsToMerge);
@@ -205,7 +205,7 @@
205 public void execute() {205 public void execute() {
206 int index = availableStrategiesComboBox.getSelectedIndex();206 int index = availableStrategiesComboBox.getSelectedIndex();
207 if (index != -1) {207 if (index != -1) {
208 new DataLaboratoryHelper().executeManipulator(availableMergeStrategies[index]);208 DataLaboratoryHelper.getDefault().executeManipulator(availableMergeStrategies[index]);
209 }209 }
210 }210 }
211211
212212
=== modified file 'DesktopDataLaboratory/src/org/gephi/desktop/datalab/utils/Bundle.properties'
--- DesktopDataLaboratory/src/org/gephi/desktop/datalab/utils/Bundle.properties 2010-12-28 12:29:32 +0000
+++ DesktopDataLaboratory/src/org/gephi/desktop/datalab/utils/Bundle.properties 2011-02-01 14:23:14 +0000
@@ -1,3 +1,1 @@
1Cell.Popup.subMenu.text=Cell1Cell.Popup.subMenu.text=Cell
2SettingsPanel.title={0}
3DataLaboratoryHelper.ui.okButton.text=OK
4\ No newline at end of file2\ No newline at end of file
53
=== modified file 'DesktopDataLaboratory/src/org/gephi/desktop/datalab/utils/Bundle_es.properties'
--- DesktopDataLaboratory/src/org/gephi/desktop/datalab/utils/Bundle_es.properties 2010-12-30 12:17:31 +0000
+++ DesktopDataLaboratory/src/org/gephi/desktop/datalab/utils/Bundle_es.properties 2011-02-01 14:23:14 +0000
@@ -6,7 +6,3 @@
6!=Project-Id-Version\: gephi\nReport-Msgid-Bugs-To\: FULL NAME <EMAIL@ADDRESS>\nPOT-Creation-Date\: 2010-04-07 13\:16+0200\nPO-Revision-Date\: 2010-12-26 20\:29+0000\nLast-Translator\: Eduardo Ramos <Unknown>\nLanguage-Team\: Spanish <es@li.org>\nMIME-Version\: 1.0\nContent-Type\: text/plain; charset\=UTF-8\nContent-Transfer-Encoding\: 8bit\nX-Launchpad-Export-Date\: 2010-12-27 04\:43+0000\nX-Generator\: Launchpad (build Unknown)\n6!=Project-Id-Version\: gephi\nReport-Msgid-Bugs-To\: FULL NAME <EMAIL@ADDRESS>\nPOT-Creation-Date\: 2010-04-07 13\:16+0200\nPO-Revision-Date\: 2010-12-26 20\:29+0000\nLast-Translator\: Eduardo Ramos <Unknown>\nLanguage-Team\: Spanish <es@li.org>\nMIME-Version\: 1.0\nContent-Type\: text/plain; charset\=UTF-8\nContent-Transfer-Encoding\: 8bit\nX-Launchpad-Export-Date\: 2010-12-27 04\:43+0000\nX-Generator\: Launchpad (build Unknown)\n
77
8Cell.Popup.subMenu.text=Celda8Cell.Popup.subMenu.text=Celda
9
10SettingsPanel.title={0} - Par\u00e1metros
11
12DataLaboratoryHelper.ui.okButton.text=Ok
139
=== modified file 'DesktopDataLaboratory/src/org/gephi/desktop/datalab/utils/Bundle_fr.properties'
--- DesktopDataLaboratory/src/org/gephi/desktop/datalab/utils/Bundle_fr.properties 2010-12-30 12:17:31 +0000
+++ DesktopDataLaboratory/src/org/gephi/desktop/datalab/utils/Bundle_fr.properties 2011-02-01 14:23:14 +0000
@@ -6,7 +6,3 @@
6!=Project-Id-Version\: gephi\nReport-Msgid-Bugs-To\: FULL NAME <EMAIL@ADDRESS>\nPOT-Creation-Date\: 2010-04-07 13\:16+0200\nPO-Revision-Date\: 2010-12-25 20\:14+0000\nLast-Translator\: S\u00e9bastien Heymann <Unknown>\nLanguage-Team\: French <fr@li.org>\nMIME-Version\: 1.0\nContent-Type\: text/plain; charset\=UTF-8\nContent-Transfer-Encoding\: 8bit\nX-Launchpad-Export-Date\: 2010-12-26 04\:54+0000\nX-Generator\: Launchpad (build Unknown)\n6!=Project-Id-Version\: gephi\nReport-Msgid-Bugs-To\: FULL NAME <EMAIL@ADDRESS>\nPOT-Creation-Date\: 2010-04-07 13\:16+0200\nPO-Revision-Date\: 2010-12-25 20\:14+0000\nLast-Translator\: S\u00e9bastien Heymann <Unknown>\nLanguage-Team\: French <fr@li.org>\nMIME-Version\: 1.0\nContent-Type\: text/plain; charset\=UTF-8\nContent-Transfer-Encoding\: 8bit\nX-Launchpad-Export-Date\: 2010-12-26 04\:54+0000\nX-Generator\: Launchpad (build Unknown)\n
77
8Cell.Popup.subMenu.text=Cellule8Cell.Popup.subMenu.text=Cellule
9
10SettingsPanel.title={0} - Param\u00e8tres
11
12DataLaboratoryHelper.ui.okButton.text=Ok
139
=== removed file 'DesktopDataLaboratory/src/org/gephi/desktop/datalab/utils/DataLaboratoryHelper.java'
--- DesktopDataLaboratory/src/org/gephi/desktop/datalab/utils/DataLaboratoryHelper.java 2010-09-16 21:39:28 +0000
+++ DesktopDataLaboratory/src/org/gephi/desktop/datalab/utils/DataLaboratoryHelper.java 1970-01-01 00:00:00 +0000
@@ -1,350 +0,0 @@
1/*
2Copyright 2008-2010 Gephi
3Authors : Eduardo Ramos <eduramiba@gmail.com>
4Website : http://www.gephi.org
5
6This file is part of Gephi.
7
8Gephi is free software: you can redistribute it and/or modify
9it under the terms of the GNU Affero General Public License as
10published by the Free Software Foundation, either version 3 of the
11License, or (at your option) any later version.
12
13Gephi is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU Affero General Public License for more details.
17
18You should have received a copy of the GNU Affero General Public License
19along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.desktop.datalab.utils;
22
23import java.awt.Dialog;
24import java.awt.event.ActionEvent;
25import java.awt.event.ActionListener;
26import java.awt.event.WindowAdapter;
27import java.awt.event.WindowEvent;
28import java.util.ArrayList;
29import java.util.Collections;
30import java.util.Comparator;
31import javax.swing.JButton;
32import javax.swing.JComponent;
33import javax.swing.JPanel;
34import javax.swing.SwingUtilities;
35import org.gephi.data.attributes.api.AttributeColumn;
36import org.gephi.data.attributes.api.AttributeTable;
37import org.gephi.datalab.plugin.manipulators.edges.DeleteEdges;
38import org.gephi.datalab.plugin.manipulators.general.SearchReplace;
39import org.gephi.datalab.plugin.manipulators.nodes.DeleteNodes;
40import org.gephi.datalab.spi.DialogControls;
41import org.gephi.datalab.spi.Manipulator;
42import org.gephi.datalab.spi.ManipulatorUI;
43import org.gephi.datalab.spi.columns.AttributeColumnsManipulator;
44import org.gephi.datalab.spi.columns.AttributeColumnsManipulatorUI;
45import org.gephi.datalab.spi.columns.merge.AttributeColumnsMergeStrategy;
46import org.gephi.datalab.spi.columns.merge.AttributeColumnsMergeStrategyBuilder;
47import org.gephi.datalab.spi.values.AttributeValueManipulator;
48import org.gephi.datalab.spi.values.AttributeValueManipulatorBuilder;
49import org.gephi.datalab.spi.edges.EdgesManipulator;
50import org.gephi.datalab.spi.edges.EdgesManipulatorBuilder;
51import org.gephi.datalab.spi.general.GeneralActionsManipulator;
52import org.gephi.datalab.spi.general.PluginGeneralActionsManipulator;
53import org.gephi.datalab.spi.nodes.NodesManipulator;
54import org.gephi.datalab.spi.nodes.NodesManipulatorBuilder;
55import org.openide.DialogDescriptor;
56import org.openide.DialogDisplayer;
57import org.openide.util.Lookup;
58import org.openide.util.NbBundle;
59
60/**
61 * Helper class for simplifying the implementation of Data Laboratory UI.
62 * @author Eduardo Ramos <eduramiba@gmail.com>
63 */
64public class DataLaboratoryHelper{
65
66 /**
67 * <p>Prepares an array with one new instance of every NodesManipulator
68 * that has a builder registered and returns it.</p>
69 * <p>It also returns the manipulators ordered first by type and then by position.</p>
70 * @return Array of all NodesManipulator implementations
71 */
72 public NodesManipulator[] getNodesManipulators() {
73 ArrayList<NodesManipulator> nodesManipulators = new ArrayList<NodesManipulator>();
74 for (NodesManipulatorBuilder nm : Lookup.getDefault().lookupAll(NodesManipulatorBuilder.class)) {
75 nodesManipulators.add(nm.getNodesManipulator());
76 }
77 sortManipulators(nodesManipulators);
78 return nodesManipulators.toArray(new NodesManipulator[0]);
79 }
80
81 /**
82 * <p>Prepares an array with one new instance of every EdgesManipulator
83 * that has a builder registered and returns it.</p>
84 * <p>It also returns the manipulators ordered first by type and then by position.</p>
85 * @return Array of all EdgesManipulator implementations
86 */
87 public EdgesManipulator[] getEdgesManipulators() {
88 ArrayList<EdgesManipulator> edgesManipulators = new ArrayList<EdgesManipulator>();
89 for (EdgesManipulatorBuilder em : Lookup.getDefault().lookupAll(EdgesManipulatorBuilder.class)) {
90 edgesManipulators.add(em.getEdgesManipulator());
91 }
92 sortManipulators(edgesManipulators);
93 return edgesManipulators.toArray(new EdgesManipulator[0]);
94 }
95
96 /**
97 * <p>Prepares an array with one instance of every GeneralActionsManipulator that is registered.</p>
98 * <p>It also returns the manipulators ordered first by type and then by position.</p>
99 * @return Array of all GeneralActionsManipulator implementations
100 */
101 public GeneralActionsManipulator[] getGeneralActionsManipulators() {
102 ArrayList<GeneralActionsManipulator> generalActionsManipulators = new ArrayList<GeneralActionsManipulator>();
103 generalActionsManipulators.addAll(Lookup.getDefault().lookupAll(GeneralActionsManipulator.class));
104 sortManipulators(generalActionsManipulators);
105 return generalActionsManipulators.toArray(new GeneralActionsManipulator[0]);
106 }
107
108 /**
109 * <p>Prepares an array with one instance of every PluginGeneralActionsManipulator that is registered.</p>
110 * <p>It also returns the manipulators ordered first by type and then by position.</p>
111 * @return Array of all PluginGeneralActionsManipulator implementations
112 */
113 public PluginGeneralActionsManipulator[] getPluginGeneralActionsManipulators() {
114 ArrayList<PluginGeneralActionsManipulator> pluginGeneralActionsManipulators = new ArrayList<PluginGeneralActionsManipulator>();
115 pluginGeneralActionsManipulators.addAll(Lookup.getDefault().lookupAll(PluginGeneralActionsManipulator.class));
116 sortManipulators(pluginGeneralActionsManipulators);
117 return pluginGeneralActionsManipulators.toArray(new PluginGeneralActionsManipulator[0]);
118 }
119
120 /**
121 * <p>Prepares an array that has one instance of every AttributeColumnsManipulator implementation
122 * that has a builder registered and returns it.</p>
123 * <p>It also returns the manipulators ordered first by type and then by position.</p>
124 * @return Array of all AttributeColumnsManipulator implementations
125 */
126 public AttributeColumnsManipulator[] getAttributeColumnsManipulators() {
127 ArrayList<AttributeColumnsManipulator> attributeColumnsManipulators = new ArrayList<AttributeColumnsManipulator>();
128 attributeColumnsManipulators.addAll(Lookup.getDefault().lookupAll(AttributeColumnsManipulator.class));
129 sortAttributeColumnsManipulators(attributeColumnsManipulators);
130 return attributeColumnsManipulators.toArray(new AttributeColumnsManipulator[0]);
131 }
132
133 /**
134 * <p>Prepares an array with one new instance of every AttributeValueManipulator
135 * that has a builder registered and returns it.</p>
136 * <p>It also returns the manipulators ordered first by type and then by position.</p>
137 * @return Array of all AttributeValueManipulator implementations
138 */
139 public AttributeValueManipulator[] getAttributeValueManipulators() {
140 ArrayList<AttributeValueManipulator> attributeValueManipulators = new ArrayList<AttributeValueManipulator>();
141 for (AttributeValueManipulatorBuilder am : Lookup.getDefault().lookupAll(AttributeValueManipulatorBuilder.class)) {
142 attributeValueManipulators.add(am.getAttributeValueManipulator());
143 }
144 sortManipulators(attributeValueManipulators);
145 return attributeValueManipulators.toArray(new AttributeValueManipulator[0]);
146 }
147
148 /**
149 * <p>Prepares an array that has one new instance of every AttributeColumnsMergeStrategy implementation that is registered.</p>
150 * <p>It also returns the manipulators ordered first by type and then by position.</p>
151 * @return Array of all AttributeColumnsMergeStrategy implementations
152 */
153 public AttributeColumnsMergeStrategy[] getAttributeColumnsMergeStrategies() {
154 ArrayList<AttributeColumnsMergeStrategy> strategies = new ArrayList<AttributeColumnsMergeStrategy>();
155 for (AttributeColumnsMergeStrategyBuilder cs : Lookup.getDefault().lookupAll(AttributeColumnsMergeStrategyBuilder.class)) {
156 strategies.add(cs.getAttributeColumnsMergeStrategy());
157 }
158 sortManipulators(strategies);
159 return strategies.toArray(new AttributeColumnsMergeStrategy[0]);
160 }
161
162 private void sortManipulators(ArrayList<? extends Manipulator> m) {
163 Collections.sort(m, new Comparator<Manipulator>() {
164
165 public int compare(Manipulator o1, Manipulator o2) {
166 //Order by type, position.
167 if (o1.getType() == o2.getType()) {
168 return o1.getPosition() - o2.getPosition();
169 } else {
170 return o1.getType() - o2.getType();
171 }
172 }
173 });
174 }
175
176 private void sortAttributeColumnsManipulators(ArrayList<? extends AttributeColumnsManipulator> m) {
177 Collections.sort(m, new Comparator<AttributeColumnsManipulator>() {
178
179 public int compare(AttributeColumnsManipulator o1, AttributeColumnsManipulator o2) {
180 //Order by type, position.
181 if (o1.getType() == o2.getType()) {
182 return o1.getPosition() - o2.getPosition();
183 } else {
184 return o1.getType() - o2.getType();
185 }
186 }
187 });
188 }
189
190 /**
191 * Prepares the dialog UI of a manipulator if it has one and executes the manipulator in a separate
192 * Thread when the dialog is accepted or directly if there is no UI.
193 * @param m Manipulator to execute
194 */
195 public void executeManipulator(final Manipulator m) {
196 if (m.canExecute()) {
197 SwingUtilities.invokeLater(new Runnable() {
198
199 public void run() {
200
201 final ManipulatorUI ui = m.getUI();
202 //Show a dialog for the manipulator UI if it provides one. If not, execute the manipulator directly:
203 if (ui != null) {
204 final JButton okButton = new JButton(NbBundle.getMessage(DataLaboratoryHelper.class, "DataLaboratoryHelper.ui.okButton.text"));
205 DialogControls dialogControls = new DialogControlsImpl(okButton);
206 ui.setup(m, dialogControls);
207 JPanel settingsPanel = ui.getSettingsPanel();
208 DialogDescriptor dd = new DialogDescriptor(settingsPanel, NbBundle.getMessage(DataLaboratoryHelper.class, "SettingsPanel.title", ui.getDisplayName()), ui.isModal(), new ActionListener() {
209
210 public void actionPerformed(ActionEvent e) {
211 if (e.getSource().equals(okButton)) {
212 ui.unSetup();
213 executeManipulatorInOtherThread(m);
214 } else {
215 ui.unSetup();
216 }
217 }
218 });
219 dd.setOptions(new Object[]{okButton, DialogDescriptor.CANCEL_OPTION});
220 dd.setClosingOptions(null);//All options close
221 Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
222 dialog.addWindowListener(new WindowAdapter() {
223
224 @Override
225 public void windowClosing(WindowEvent e) {
226 ui.unSetup();
227 }
228 });
229 dialog.setVisible(true);
230 } else {
231 executeManipulatorInOtherThread(m);
232 }
233 }
234 });
235 }
236 }
237
238 private void executeManipulatorInOtherThread(final Manipulator m) {
239 new Thread() {
240
241 @Override
242 public void run() {
243 m.execute();
244 }
245 }.start();
246 }
247
248 /**
249 * Prepares the dialog UI of a AttributeColumnsManipulator if it has one and executes the manipulator in a separate
250 * Thread when the dialog is accepted or directly if there is no UI.
251 * @param m AttributeColumnsManipulator
252 * @param table Table of the column
253 * @param column Column to manipulate
254 */
255 public void executeAttributeColumnsManipulator(final AttributeColumnsManipulator m, final AttributeTable table, final AttributeColumn column) {
256 if (m.canManipulateColumn(table, column)) {
257 SwingUtilities.invokeLater(new Runnable() {
258
259 public void run() {
260 final AttributeColumnsManipulatorUI ui = m.getUI(table, column);
261 //Show a dialog for the manipulator UI if it provides one. If not, execute the manipulator directly:
262 if (ui != null) {
263 final JButton okButton = new JButton(NbBundle.getMessage(DataLaboratoryHelper.class, "DataLaboratoryHelper.ui.okButton.text"));
264 DialogControls dialogControls = new DialogControlsImpl(okButton);
265 ui.setup(m, table, column, dialogControls);
266 JPanel settingsPanel = ui.getSettingsPanel();
267 DialogDescriptor dd = new DialogDescriptor(settingsPanel, NbBundle.getMessage(DataLaboratoryHelper.class, "SettingsPanel.title", ui.getDisplayName()), ui.isModal(), new ActionListener() {
268
269 public void actionPerformed(ActionEvent e) {
270 if (e.getSource().equals(okButton)) {
271 ui.unSetup();
272 executeAttributeColumnsManipulatorInOtherThread(m, table, column);
273 } else {
274 ui.unSetup();
275 }
276 }
277 });
278 dd.setOptions(new Object[]{okButton, DialogDescriptor.CANCEL_OPTION});
279 dd.setClosingOptions(null);//All options close
280 Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
281 dialog.addWindowListener(new WindowAdapter() {
282
283 @Override
284 public void windowClosing(WindowEvent e) {
285 ui.unSetup();
286 }
287 });
288 dialog.setVisible(true);
289 } else {
290 executeAttributeColumnsManipulatorInOtherThread(m, table, column);
291 }
292 }
293 });
294 }
295 }
296
297 private void executeAttributeColumnsManipulatorInOtherThread(final AttributeColumnsManipulator m, final AttributeTable table, final AttributeColumn column) {
298 new Thread() {
299
300 @Override
301 public void run() {
302 m.execute(table, column);
303 }
304 }.start();
305 }
306
307 /**
308 * Special method for making public DeleteNodes manipulator so it can be specifically retrieved from Data Table UI.
309 * It is used for reacting to delete key.
310 * @return DeleteNodes new instance
311 */
312 public NodesManipulator getDeleteNodesManipulator() {
313 return new DeleteNodes();
314 }
315
316 /**
317 * Special method for making public DeleteEdges manipulator so it can be specifically retrieved from Data Table UI.
318 * It is used for reacting to delete key.
319 * @return DeleteEdges new instance
320 */
321 public EdgesManipulator getDeleEdgesManipulator() {
322 return new DeleteEdges();
323 }
324
325 /**
326 * Special method for making public SearchReplace manipulator so it can be specifically retrieved from Data Table UI.
327 * It is used for reacting to Ctrl+F keys combination.
328 * @return SearchReplace new instance
329 */
330 public GeneralActionsManipulator getSearchReplaceManipulator() {
331 return new SearchReplace();
332 }
333
334 class DialogControlsImpl implements DialogControls {
335
336 JComponent okButton;
337
338 public DialogControlsImpl(JComponent okButton) {
339 this.okButton = okButton;
340 }
341
342 public void setOkButtonEnabled(boolean enabled) {
343 okButton.setEnabled(enabled);
344 }
345
346 public boolean isOkButtonEnabled(){
347 return okButton.isEnabled();
348 }
349 }
350}
3510
=== modified file 'DesktopDataLaboratory/src/org/gephi/desktop/datalab/utils/PopupMenuUtils.java'
--- DesktopDataLaboratory/src/org/gephi/desktop/datalab/utils/PopupMenuUtils.java 2010-09-07 12:43:59 +0000
+++ DesktopDataLaboratory/src/org/gephi/desktop/datalab/utils/PopupMenuUtils.java 2011-02-01 14:23:14 +0000
@@ -26,6 +26,7 @@
26import javax.swing.JMenuItem;26import javax.swing.JMenuItem;
27import org.gephi.data.attributes.api.AttributeColumn;27import org.gephi.data.attributes.api.AttributeColumn;
28import org.gephi.data.attributes.api.AttributeRow;28import org.gephi.data.attributes.api.AttributeRow;
29import org.gephi.datalab.api.DataLaboratoryHelper;
29import org.gephi.datalab.spi.Manipulator;30import org.gephi.datalab.spi.Manipulator;
30import org.gephi.datalab.spi.values.AttributeValueManipulator;31import org.gephi.datalab.spi.values.AttributeValueManipulator;
31import org.openide.util.ImageUtilities;32import org.openide.util.ImageUtilities;
@@ -48,7 +49,7 @@
48 menuItem.addActionListener(new ActionListener() {49 menuItem.addActionListener(new ActionListener() {
4950
50 public void actionPerformed(ActionEvent e) {51 public void actionPerformed(ActionEvent e) {
51 DataLaboratoryHelper dlh = new DataLaboratoryHelper();52 DataLaboratoryHelper dlh = DataLaboratoryHelper.getDefault();
52 dlh.executeManipulator(nm);53 dlh.executeManipulator(nm);
53 }54 }
54 });55 });
@@ -59,7 +60,7 @@
59 }60 }
6061
61 public static JMenu createSubMenuFromRowColumn(AttributeRow row, AttributeColumn column) {62 public static JMenu createSubMenuFromRowColumn(AttributeRow row, AttributeColumn column) {
62 DataLaboratoryHelper dlh = new DataLaboratoryHelper();63 DataLaboratoryHelper dlh = DataLaboratoryHelper.getDefault();
63 JMenu subMenu = new JMenu(NbBundle.getMessage(PopupMenuUtils.class, "Cell.Popup.subMenu.text"));64 JMenu subMenu = new JMenu(NbBundle.getMessage(PopupMenuUtils.class, "Cell.Popup.subMenu.text"));
64 subMenu.setIcon(ImageUtilities.loadImageIcon("org/gephi/desktop/datalab/resources/table-select.png", true));65 subMenu.setIcon(ImageUtilities.loadImageIcon("org/gephi/desktop/datalab/resources/table-select.png", true));
6566
6667
=== modified file 'VisualizationAPI/nbproject/genfiles.properties'
--- VisualizationAPI/nbproject/genfiles.properties 2010-10-07 08:53:53 +0000
+++ VisualizationAPI/nbproject/genfiles.properties 2011-02-01 14:23:14 +0000
@@ -1,8 +1,8 @@
1build.xml.data.CRC32=006815d51build.xml.data.CRC32=aa440a30
2build.xml.script.CRC32=84b64b022build.xml.script.CRC32=84b64b02
3build.xml.stylesheet.CRC32=a56c6a5b@1.42.23build.xml.stylesheet.CRC32=a56c6a5b@1.42.2
4# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.4# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
5# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.5# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6nbproject/build-impl.xml.data.CRC32=006815d56nbproject/build-impl.xml.data.CRC32=aa440a30
7nbproject/build-impl.xml.script.CRC32=1628a5817nbproject/build-impl.xml.script.CRC32=1628a581
8nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.42.28nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.42.2
99
=== modified file 'VisualizationAPI/nbproject/project.xml'
--- VisualizationAPI/nbproject/project.xml 2010-10-07 08:53:53 +0000
+++ VisualizationAPI/nbproject/project.xml 2011-02-01 14:23:14 +0000
@@ -26,6 +26,7 @@
26 <public-packages>26 <public-packages>
27 <package>org.gephi.visualization.api</package>27 <package>org.gephi.visualization.api</package>
28 <package>org.gephi.visualization.impl</package>28 <package>org.gephi.visualization.impl</package>
29 <package>org.gephi.visualization.spi</package>
29 </public-packages>30 </public-packages>
30 </data>31 </data>
31 </configuration>32 </configuration>
3233
=== added directory 'VisualizationAPI/src/org/gephi/visualization/spi'
=== added file 'VisualizationAPI/src/org/gephi/visualization/spi/GraphContextMenuItem.java'
--- VisualizationAPI/src/org/gephi/visualization/spi/GraphContextMenuItem.java 1970-01-01 00:00:00 +0000
+++ VisualizationAPI/src/org/gephi/visualization/spi/GraphContextMenuItem.java 2011-02-01 14:23:14 +0000
@@ -0,0 +1,125 @@
1
2/*
3Copyright 2008-2010 Gephi
4Authors : Eduardo Ramos <eduramiba@gmail.com>
5Website : http://www.gephi.org
6
7This file is part of Gephi.
8
9Gephi is free software: you can redistribute it and/or modify
10it under the terms of the GNU Affero General Public License as
11published by the Free Software Foundation, either version 3 of the
12License, or (at your option) any later version.
13
14Gephi is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17GNU Affero General Public License for more details.
18
19You should have received a copy of the GNU Affero General Public License
20along with Gephi. If not, see <http://www.gnu.org/licenses/>.
21 */
22package org.gephi.visualization.spi;
23
24import javax.swing.Icon;
25import org.gephi.graph.api.HierarchicalGraph;
26import org.gephi.graph.api.Node;
27
28/**
29 * <p>Interface from providing graph context menu items as services.</p>
30 * <p>All context menu items are able to:</p>
31 * <ul>
32 * <li>Execute an action</li>
33 * <li>Provide a name, type and order of appearance (position in group of its type)</li>
34 * <li>Indicate wether they have to be available (appear in the context menu) or not</li>
35 * <li>Indicate wether they have to be executable (enabled in the context menu) or not</li>
36 * <li>Provide and icon or not</li>
37 * </ul>
38 * <p>Used for different manipulators such as NodesManipulator, EdgesManipulator and GeneralActionsManipulator.</p>
39 * <p>The only methods that are called before setting up an item with the data are <b>getSubItems, getType and getPosition.</b>
40 * This way, the other methods behaviour can depend on the data that has been setup before</p>
41 * <p><b>getSubItems will be called before and after setup. Take care when the nodes are null!</b></p>
42 *
43 * To provide a context menu item, a class has to implement this interface and have a <code>@ServiceProvider</code> annotation
44 * @author Eduardo Ramos <eduramiba@gmail.com>
45 */
46public interface GraphContextMenuItem {
47
48 /**
49 * Prepare nodes for this item. Note that nodes could contain 0 nodes.
50 * @param graph Hierarchical graph
51 * @param nodes All selected nodes
52 */
53 void setup(HierarchicalGraph graph, Node[] nodes);
54
55 /**
56 * Execute this item.
57 * It will operate with data like nodes and edges previously setup for the type of manipulator.
58 */
59 void execute();
60
61 /**
62 * <p>This is optional. Return sub items for this menu item if desired.</p>
63 * <p>If this item should contain more items, return a new instance of each sub item.
64 * If not return null and implement execute for this item.</p>
65 * <p>In order to declare mnemonic keys for subitem(s), the implementation of this item
66 * must return the subitem(s) with the mnemonic even when it has not been setup with any node.
67 * If you don't need a mnemonic, return null if the item is not setup.</p>
68 * @return
69 */
70 GraphContextMenuItem[] getSubItems();
71
72 /**
73 * <p>Return name to show for this item in the context menu.</p>
74 * <p>Implementations can provide different names depending on the data this
75 * item has (for example depending on the number of nodes).</p>
76 * @return Name to show at current time and conditions
77 */
78 String getName();
79
80 /**
81 * Description of the context menu item, to show as tooltip.
82 * @return Description or null
83 */
84 String getDescription();
85
86 /**
87 * Indicates if this item has to appear in the context menu at all
88 * @return True to show, false otherwise
89 */
90 boolean isAvailable();
91
92 /**
93 * Indicates if this item can be executed when it is available.
94 * Implementations should evaluate the current data and conditions.
95 * @return True if it has to be executable, false otherwise
96 */
97 boolean canExecute();
98
99 /**
100 * Type of item. This is used for separating the items
101 * in groups when shown, using popup separators. First types to show will be the lesser.
102 * @return Type of this manipulator
103 */
104 int getType();
105
106 /**
107 * Returns a position value that indicates the position
108 * of this Manipulator in its type group. Less means upper.
109 * @return This Manipulator position
110 */
111 int getPosition();
112
113 /**
114 * Optional. Allows to declare a mnemonic key for this item in the menu.
115 * There should not be 2 items with the same mnemonic at the same time.
116 * @return Integer from <code>KeyEvent</code> values or null
117 */
118 Integer getMnemonicKey();
119
120 /**
121 * Returns an icon for this item if necessary.
122 * @return Icon or null
123 */
124 Icon getIcon();
125}
0126
=== modified file 'VisualizationModule/nbproject/genfiles.properties'
--- VisualizationModule/nbproject/genfiles.properties 2010-09-16 21:37:51 +0000
+++ VisualizationModule/nbproject/genfiles.properties 2011-02-01 14:23:14 +0000
@@ -1,8 +1,8 @@
1build.xml.data.CRC32=4d1f53aa1build.xml.data.CRC32=4ad970b7
2build.xml.script.CRC32=587055f02build.xml.script.CRC32=587055f0
3build.xml.stylesheet.CRC32=a56c6a5b@1.42.23build.xml.stylesheet.CRC32=a56c6a5b@1.42.2
4# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.4# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
5# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.5# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6nbproject/build-impl.xml.data.CRC32=4d1f53aa6nbproject/build-impl.xml.data.CRC32=4ad970b7
7nbproject/build-impl.xml.script.CRC32=413ca7507nbproject/build-impl.xml.script.CRC32=413ca750
8nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.42.28nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.42.2
99
=== modified file 'VisualizationModule/nbproject/project.xml'
--- VisualizationModule/nbproject/project.xml 2010-09-16 21:37:51 +0000
+++ VisualizationModule/nbproject/project.xml 2011-02-01 14:23:14 +0000
@@ -15,6 +15,14 @@
15 </run-dependency>15 </run-dependency>
16 </dependency>16 </dependency>
17 <dependency>17 <dependency>
18 <code-name-base>org.gephi.datalab.api</code-name-base>
19 <build-prerequisite/>
20 <compile-dependency/>
21 <run-dependency>
22 <specification-version>0.7.1.4</specification-version>
23 </run-dependency>
24 </dependency>
25 <dependency>
18 <code-name-base>org.gephi.desktop.project</code-name-base>26 <code-name-base>org.gephi.desktop.project</code-name-base>
19 <build-prerequisite/>27 <build-prerequisite/>
20 <compile-dependency/>28 <compile-dependency/>
2129
=== added file 'VisualizationModule/src/org/gephi/visualization/api/resources/delete.png'
22Binary files VisualizationModule/src/org/gephi/visualization/api/resources/delete.png 1970-01-01 00:00:00 +0000 and VisualizationModule/src/org/gephi/visualization/api/resources/delete.png 2011-02-01 14:23:14 +0000 differ30Binary files VisualizationModule/src/org/gephi/visualization/api/resources/delete.png 1970-01-01 00:00:00 +0000 and VisualizationModule/src/org/gephi/visualization/api/resources/delete.png 2011-02-01 14:23:14 +0000 differ
=== added file 'VisualizationModule/src/org/gephi/visualization/api/resources/free.png'
23Binary files VisualizationModule/src/org/gephi/visualization/api/resources/free.png 1970-01-01 00:00:00 +0000 and VisualizationModule/src/org/gephi/visualization/api/resources/free.png 2011-02-01 14:23:14 +0000 differ31Binary files VisualizationModule/src/org/gephi/visualization/api/resources/free.png 1970-01-01 00:00:00 +0000 and VisualizationModule/src/org/gephi/visualization/api/resources/free.png 2011-02-01 14:23:14 +0000 differ
=== added file 'VisualizationModule/src/org/gephi/visualization/api/resources/globe-network.png'
24Binary files VisualizationModule/src/org/gephi/visualization/api/resources/globe-network.png 1970-01-01 00:00:00 +0000 and VisualizationModule/src/org/gephi/visualization/api/resources/globe-network.png 2011-02-01 14:23:14 +0000 differ32Binary files VisualizationModule/src/org/gephi/visualization/api/resources/globe-network.png 1970-01-01 00:00:00 +0000 and VisualizationModule/src/org/gephi/visualization/api/resources/globe-network.png 2011-02-01 14:23:14 +0000 differ
=== added file 'VisualizationModule/src/org/gephi/visualization/api/resources/table-select.png'
25Binary files VisualizationModule/src/org/gephi/visualization/api/resources/table-select.png 1970-01-01 00:00:00 +0000 and VisualizationModule/src/org/gephi/visualization/api/resources/table-select.png 2011-02-01 14:23:14 +0000 differ33Binary files VisualizationModule/src/org/gephi/visualization/api/resources/table-select.png 1970-01-01 00:00:00 +0000 and VisualizationModule/src/org/gephi/visualization/api/resources/table-select.png 2011-02-01 14:23:14 +0000 differ
=== removed file 'VisualizationModule/src/org/gephi/visualization/apiimpl/Bundle.properties'
--- VisualizationModule/src/org/gephi/visualization/apiimpl/Bundle.properties 2010-09-16 21:37:51 +0000
+++ VisualizationModule/src/org/gephi/visualization/apiimpl/Bundle.properties 1970-01-01 00:00:00 +0000
@@ -1,14 +0,0 @@
1GraphContextMenu_Group = Group
2GraphContextMenu_Ungroup = Ungroup
3GraphContextMenu_Expand = Expand
4GraphContextMenu_Contract = Contract
5GraphContextMenu_Settle = Settle
6GraphContextMenu_Free = Free
7GraphContextMenu_Delete = Delete
8GraphContextMenu_MoveToWorkspace = Move to...
9GraphContextMenu_MoveToWorkspace_NewWorkspace = New workspace
10GraphContextMenu_CopyToWorkspace = Copy to...
11GraphContextMenu_CopyToWorkspace_NewWorkspace = New workspace
12
13GraphContextMenu.Delete.message = Nodes will be deleted, do you want to proceed?
14GraphContextMenu.Delete.message.title = Delete nodes
15\ No newline at end of file0\ No newline at end of file
161
=== removed file 'VisualizationModule/src/org/gephi/visualization/apiimpl/Bundle_es.properties'
--- VisualizationModule/src/org/gephi/visualization/apiimpl/Bundle_es.properties 2010-12-30 12:17:31 +0000
+++ VisualizationModule/src/org/gephi/visualization/apiimpl/Bundle_es.properties 1970-01-01 00:00:00 +0000
@@ -1,32 +0,0 @@
1# Spanish translation for gephi
2# Copyright (c) 2010 Rosetta Contributors and Canonical Ltd 2010
3# This file is distributed under the same license as the gephi package.
4# FIRST AUTHOR <EMAIL@ADDRESS>, 2010.
5#
6!=Project-Id-Version\: gephi\nReport-Msgid-Bugs-To\: FULL NAME <EMAIL@ADDRESS>\nPOT-Creation-Date\: 2010-04-07 13\:16+0200\nPO-Revision-Date\: 2010-12-26 00\:11+0000\nLast-Translator\: Eduardo Ramos <Unknown>\nLanguage-Team\: Spanish <es@li.org>\nMIME-Version\: 1.0\nContent-Type\: text/plain; charset\=UTF-8\nContent-Transfer-Encoding\: 8bit\nX-Launchpad-Export-Date\: 2010-12-27 04\:43+0000\nX-Generator\: Launchpad (build Unknown)\n
7
8GraphContextMenu_Group=Agrupar
9
10GraphContextMenu_Ungroup=Desagrupar
11
12GraphContextMenu_Expand=Expandir
13
14GraphContextMenu_Contract=Contraer
15
16GraphContextMenu_Settle=Bloquear
17
18GraphContextMenu_Free=Desbloquear
19
20GraphContextMenu_Delete=Eliminar
21
22GraphContextMenu_MoveToWorkspace=Mover a...
23
24GraphContextMenu_MoveToWorkspace_NewWorkspace=Nuevo espacio de trabajo
25
26GraphContextMenu_CopyToWorkspace=Copiar a...
27
28GraphContextMenu_CopyToWorkspace_NewWorkspace=Nuevo espacio de trabajo
29
30GraphContextMenu.Delete.message=Los nodos ser\u00e1n eliminados, \u00bfContinuar?
31
32GraphContextMenu.Delete.message.title=Eliminar nodos
330
=== removed file 'VisualizationModule/src/org/gephi/visualization/apiimpl/Bundle_fr.properties'
--- VisualizationModule/src/org/gephi/visualization/apiimpl/Bundle_fr.properties 2010-12-30 12:17:31 +0000
+++ VisualizationModule/src/org/gephi/visualization/apiimpl/Bundle_fr.properties 1970-01-01 00:00:00 +0000
@@ -1,32 +0,0 @@
1# French translation for gephi
2# Copyright (c) 2010 Rosetta Contributors and Canonical Ltd 2010
3# This file is distributed under the same license as the gephi package.
4# FIRST AUTHOR <EMAIL@ADDRESS>, 2010.
5#
6!=Project-Id-Version\: gephi\nReport-Msgid-Bugs-To\: FULL NAME <EMAIL@ADDRESS>\nPOT-Creation-Date\: 2010-04-07 13\:16+0200\nPO-Revision-Date\: 2010-12-25 19\:49+0000\nLast-Translator\: S\u00e9bastien Heymann <Unknown>\nLanguage-Team\: French <fr@li.org>\nMIME-Version\: 1.0\nContent-Type\: text/plain; charset\=UTF-8\nContent-Transfer-Encoding\: 8bit\nX-Launchpad-Export-Date\: 2010-12-26 04\:53+0000\nX-Generator\: Launchpad (build Unknown)\n
7
8GraphContextMenu_Group=Grouper
9
10GraphContextMenu_Ungroup=D\u00e9grouper
11
12GraphContextMenu_Expand=\u00c9tendre
13
14GraphContextMenu_Contract=Contracter
15
16GraphContextMenu_Settle=Fixer
17
18GraphContextMenu_Free=Lib\u00e9rer
19
20GraphContextMenu_Delete=Supprimer
21
22GraphContextMenu_MoveToWorkspace=D\u00e9placer vers...
23
24GraphContextMenu_MoveToWorkspace_NewWorkspace=Nouvel espace de travail
25
26GraphContextMenu_CopyToWorkspace=Copier vers...
27
28GraphContextMenu_CopyToWorkspace_NewWorkspace=Nouvel espace de travail
29
30GraphContextMenu.Delete.message=Les noeuds seront supprim\u00e9s. Voulez-vous continuer ?
31
32GraphContextMenu.Delete.message.title=Suppression des noeuds
330
=== modified file 'VisualizationModule/src/org/gephi/visualization/apiimpl/GraphContextMenu.java'
--- VisualizationModule/src/org/gephi/visualization/apiimpl/GraphContextMenu.java 2010-09-16 21:37:51 +0000
+++ VisualizationModule/src/org/gephi/visualization/apiimpl/GraphContextMenu.java 2011-02-01 14:23:14 +0000
@@ -22,22 +22,20 @@
2222
23import java.awt.event.ActionEvent;23import java.awt.event.ActionEvent;
24import java.awt.event.ActionListener;24import java.awt.event.ActionListener;
25import javax.swing.AbstractAction;25import java.awt.event.KeyEvent;
26import javax.swing.Action;26import java.util.ArrayList;
27import java.util.Collections;
28import java.util.Comparator;
27import javax.swing.JMenu;29import javax.swing.JMenu;
28import javax.swing.JMenuItem;30import javax.swing.JMenuItem;
29import javax.swing.JPopupMenu;31import javax.swing.JPopupMenu;
30import org.gephi.project.api.ProjectController;32import javax.swing.KeyStroke;
31import org.gephi.project.api.Workspace;33import org.gephi.graph.api.HierarchicalGraph;
32import org.gephi.project.api.WorkspaceInformation;34import org.gephi.graph.api.Node;
33import org.gephi.project.api.WorkspaceProvider;
34import org.gephi.visualization.VizController;35import org.gephi.visualization.VizController;
35import org.gephi.visualization.bridge.DHNSEventBridge;36import org.gephi.visualization.bridge.DHNSEventBridge;
36import org.openide.DialogDisplayer;37import org.gephi.visualization.spi.GraphContextMenuItem;
37import org.openide.NotifyDescriptor;
38import org.openide.util.ImageUtilities;
39import org.openide.util.Lookup;38import org.openide.util.Lookup;
40import org.openide.util.NbBundle;
4139
42/**40/**
43 *41 *
@@ -54,173 +52,111 @@
54 }52 }
5553
56 public JPopupMenu getMenu() {54 public JPopupMenu getMenu() {
57 //Group55 GraphContextMenuItem[] items = getGraphContextMenuItems();
58 GraphContextMenuAction groupAction = new GraphContextMenuImpl("GraphContextMenu_Group", "org/gephi/visualization/api/resources/group.png") {56 final Node[] selectedNodes = eventBridge.getSelectedNodes();
5957 final HierarchicalGraph graph = eventBridge.getGraph();
60 @Override58 JPopupMenu contextMenu = new JPopupMenu();
61 public void actionPerformed(ActionEvent e) {59
62 eventBridge.group();60 //Add items ordered:
63 }61 Integer lastItemType = null;
64 };62 for (GraphContextMenuItem item : items) {
65 groupAction.setEnabled(eventBridge.canGroup());63 item.setup(graph, selectedNodes);
6664 if (lastItemType == null) {
67 //Ungroup65 lastItemType = item.getType();
68 GraphContextMenuAction ungroupAction = new GraphContextMenuImpl("GraphContextMenu_Ungroup", "org/gephi/visualization/api/resources/ungroup.png") {66 }
6967 if (lastItemType != item.getType()) {
70 @Override68 contextMenu.addSeparator();
71 public void actionPerformed(ActionEvent e) {69 }
72 eventBridge.ungroup();70 lastItemType = item.getType();
73 }71 if (item.isAvailable()) {
74 };72 contextMenu.add(createMenuItemFromGraphContextMenuItem(item, graph, selectedNodes));
75 ungroupAction.setEnabled(eventBridge.canUngroup());73 }
7674 }
77 //Expand75
78 GraphContextMenuAction expandAction = new GraphContextMenuImpl("GraphContextMenu_Expand", "org/gephi/visualization/api/resources/expand.png") {76 return contextMenu;
7977 }
80 @Override78
81 public void actionPerformed(ActionEvent e) {79 /**
82 eventBridge.expand();80 * <p>Prepares an array with one new instance of every GraphContextMenuItem and returns it.</p>
83 }81 * <p>It also returns the items ordered first by type and then by position.</p>
84 };82 * @return Array of all GraphContextMenuItem implementations
85 expandAction.setEnabled(eventBridge.canExpand());83 */
8684 public GraphContextMenuItem[] getGraphContextMenuItems() {
87 //Contract85 ArrayList<GraphContextMenuItem> items = new ArrayList<GraphContextMenuItem>();
88 GraphContextMenuAction contractAction = new GraphContextMenuImpl("GraphContextMenu_Contract", "org/gephi/visualization/api/resources/contract.png") {86 items.addAll(Lookup.getDefault().lookupAll(GraphContextMenuItem.class));
8987 sortItems(items);
90 @Override88 return items.toArray(new GraphContextMenuItem[0]);
91 public void actionPerformed(ActionEvent e) {89 }
92 eventBridge.contract();90
93 }91 public JMenuItem createMenuItemFromGraphContextMenuItem(final GraphContextMenuItem item, final HierarchicalGraph graph, final Node[] nodes) {
94 };92 GraphContextMenuItem[] subItems = item.getSubItems();
95 contractAction.setEnabled(eventBridge.canContract());93 if (subItems != null && item.canExecute()) {
9694 JMenu subMenu = new JMenu();
97 //Settle95 subMenu.setText(item.getName());
98 GraphContextMenuAction settleAction = new GraphContextMenuImpl("GraphContextMenu_Settle", "org/gephi/visualization/api/resources/settle.png") {96 if (item.getDescription() != null && !item.getDescription().isEmpty()) {
9997 subMenu.setToolTipText(item.getDescription());
100 @Override98 }
101 public void actionPerformed(ActionEvent e) {99 subMenu.setIcon(item.getIcon());
102 eventBridge.settle();100 Integer lastItemType = null;
103 }101 for (GraphContextMenuItem subItem : subItems) {
104 };102 subItem.setup(graph, nodes);
105 settleAction.setEnabled(eventBridge.canSettle());103 if (lastItemType == null) {
106104 lastItemType = subItem.getType();
107 //Free105 }
108 GraphContextMenuAction freeAction = new GraphContextMenuImpl("GraphContextMenu_Free") {106 if (lastItemType != subItem.getType()) {
109107 subMenu.addSeparator();
110 @Override108 }
111 public void actionPerformed(ActionEvent e) {109 lastItemType = subItem.getType();
112 eventBridge.free();110 if (subItem.isAvailable()) {
113 }111 subMenu.add(createMenuItemFromGraphContextMenuItem(subItem, graph, nodes));
114 };112 }
115 freeAction.setEnabled(eventBridge.canFree());113 }
116114 if(item.getMnemonicKey()!=null){
117 //Free115 subMenu.setMnemonic(item.getMnemonicKey());//Mnemonic for opening a sub menu
118 GraphContextMenuAction deleteAction = new GraphContextMenuImpl("GraphContextMenu_Delete") {116 }
119117 return subMenu;
120 @Override118 } else {
121 public void actionPerformed(ActionEvent e) {119 JMenuItem menuItem = new JMenuItem();
122 NotifyDescriptor.Confirmation notifyDescriptor = new NotifyDescriptor.Confirmation(120 menuItem.setText(item.getName());
123 NbBundle.getMessage(GraphContextMenu.class, "GraphContextMenu.Delete.message"),121 if (item.getDescription() != null && !item.getDescription().isEmpty()) {
124 NbBundle.getMessage(GraphContextMenu.class, "GraphContextMenu.Delete.message.title"), NotifyDescriptor.YES_NO_OPTION);122 menuItem.setToolTipText(item.getDescription());
125 if (DialogDisplayer.getDefault().notify(notifyDescriptor).equals(NotifyDescriptor.YES_OPTION)) {123 }
126 eventBridge.delete();124 menuItem.setIcon(item.getIcon());
127 }125 if (item.canExecute()) {
128 }126 menuItem.addActionListener(new ActionListener() {
129 };127
130 deleteAction.setEnabled(eventBridge.canDelete());128 public void actionPerformed(ActionEvent e) {
131129 new Thread() {
132 //Move workspace130
133 JMenu moveToWorkspaceMenu = new JMenu(NbBundle.getMessage(GraphContextMenu.class, "GraphContextMenu_MoveToWorkspace"));131 @Override
134 boolean moveOrCopyEnabled = eventBridge.canMoveOrCopyWorkspace();132 public void run() {
135 if (moveOrCopyEnabled) {133 item.execute();
136 moveToWorkspaceMenu.add(new GraphContextMenuImpl("GraphContextMenu_MoveToWorkspace_NewWorkspace", "org/gephi/visualization/api/resources/new-wokspace.png") {134 }
137135 }.start();
138 @Override136 }
139 public void actionPerformed(ActionEvent e) {137 });
140 eventBridge.moveToNewWorkspace();138 } else {
141 }139 menuItem.setEnabled(false);
142 });140 }
143 moveToWorkspaceMenu.addSeparator();141 if(item.getMnemonicKey()!=null){
144 ProjectController projectController = Lookup.getDefault().lookup(ProjectController.class);142 menuItem.setMnemonic(item.getMnemonicKey());//Mnemonic for executing the action
145 for (final Workspace w : projectController.getCurrentProject().getLookup().lookup(WorkspaceProvider.class).getWorkspaces()) {143 menuItem.setAccelerator(KeyStroke.getKeyStroke(item.getMnemonicKey(),KeyEvent.CTRL_DOWN_MASK));//And the same key mnemonic + ctrl for executing the action (and as a help display for the user!).
146 JMenuItem item = new JMenuItem(w.getLookup().lookup(WorkspaceInformation.class).getName());144 }
147 item.addActionListener(new ActionListener() {145 return menuItem;
148146 }
149 public void actionPerformed(ActionEvent e) {147 }
150 eventBridge.moveToWorkspace(w);148
151 }149 private void sortItems(ArrayList<? extends GraphContextMenuItem> m) {
152 });150 Collections.sort(m, new Comparator<GraphContextMenuItem>() {
153 moveToWorkspaceMenu.add(item);151
154 item.setEnabled(w != projectController.getCurrentWorkspace());152 public int compare(GraphContextMenuItem o1, GraphContextMenuItem o2) {
155 }153 //Order by type, position.
156 }154 if (o1.getType() == o2.getType()) {
157 moveToWorkspaceMenu.setEnabled(moveOrCopyEnabled);155 return o1.getPosition() - o2.getPosition();
158156 } else {
159 //Copy workspace157 return o1.getType() - o2.getType();
160 JMenu copyToWorkspaceMenu = new JMenu(NbBundle.getMessage(GraphContextMenu.class, "GraphContextMenu_CopyToWorkspace"));158 }
161 if (moveOrCopyEnabled) {159 }
162 copyToWorkspaceMenu.add(new GraphContextMenuImpl("GraphContextMenu_CopyToWorkspace_NewWorkspace", "org/gephi/visualization/api/resources/new-wokspace.png") {160 });
163
164 @Override
165 public void actionPerformed(ActionEvent e) {
166 eventBridge.copyToNewWorkspace();
167 }
168 });
169 copyToWorkspaceMenu.addSeparator();
170 ProjectController projectController = Lookup.getDefault().lookup(ProjectController.class);
171 for (final Workspace w : projectController.getCurrentProject().getLookup().lookup(WorkspaceProvider.class).getWorkspaces()) {
172 JMenuItem item = new JMenuItem(w.getLookup().lookup(WorkspaceInformation.class).getName());
173 item.addActionListener(new ActionListener() {
174
175 public void actionPerformed(ActionEvent e) {
176 eventBridge.copyToWorkspace(w);
177 }
178 });
179 copyToWorkspaceMenu.add(item);
180 item.setEnabled(w != projectController.getCurrentWorkspace());
181 }
182 }
183 copyToWorkspaceMenu.setEnabled(moveOrCopyEnabled);
184
185 //Popup
186 JPopupMenu popupMenu = new JPopupMenu();
187 popupMenu.add(groupAction);
188 popupMenu.add(ungroupAction);
189 popupMenu.addSeparator();
190 popupMenu.add(expandAction);
191 popupMenu.add(contractAction);
192 popupMenu.addSeparator();
193 popupMenu.add(deleteAction);
194 popupMenu.add(moveToWorkspaceMenu);
195 popupMenu.add(copyToWorkspaceMenu);
196 popupMenu.addSeparator();
197 popupMenu.add(settleAction);
198 popupMenu.add(freeAction);
199 return popupMenu;
200 }
201
202 public static interface GraphContextMenuAction extends Action {
203
204 public boolean isVisible();
205 }
206
207 private static class GraphContextMenuImpl extends AbstractAction implements GraphContextMenuAction {
208
209 public GraphContextMenuImpl(String key) {
210 putValue(Action.NAME, NbBundle.getMessage(GraphContextMenu.class, key));
211 }
212
213 public GraphContextMenuImpl(String key, String icon) {
214 putValue(Action.NAME, NbBundle.getMessage(GraphContextMenu.class, key));
215 putValue(Action.SMALL_ICON, ImageUtilities.loadImageIcon(icon, false));
216 }
217
218 public void actionPerformed(ActionEvent e) {
219 throw new UnsupportedOperationException("Not supported yet.");
220 }
221
222 public boolean isVisible() {
223 return true;
224 }
225 }161 }
226}162}
227163
=== added directory 'VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems'
=== added file 'VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Bundle.properties'
--- VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Bundle.properties 1970-01-01 00:00:00 +0000
+++ VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Bundle.properties 2011-02-01 14:23:14 +0000
@@ -0,0 +1,21 @@
1GraphContextMenu_Group = Group
2GraphContextMenu_Ungroup = Ungroup
3GraphContextMenu_Expand = Expand
4GraphContextMenu_Contract = Contract
5GraphContextMenu_Settle = Settle
6GraphContextMenu_Free = Free
7GraphContextMenu_TagNodes = Tag nodes...
8GraphContextMenu_Delete = Delete
9GraphContextMenu_MoveToWorkspace = Move to...
10GraphContextMenu_MoveToWorkspace_NewWorkspace = New workspace
11GraphContextMenu_CopyToWorkspace = Copy to...
12GraphContextMenu_CopyToWorkspace_NewWorkspace = New workspace
13
14GraphContextMenu.Delete.message = Nodes will be deleted, do you want to proceed?
15GraphContextMenu.Delete.message.title = Delete nodes
16GraphContextMenu_SelectInDataLaboratory = Select in data laboratory
17GraphContextMenu_OpenURL = Open in web browser
18GraphContextMenu_OpenURL.description = Open URL in an attribute of the node
19GraphContextMenu_OpenURLSubItem = Choose column...
20GraphContextMenu_OpenURLSubItem.message = Column:
21GraphContextMenu_OpenURLLastItem = Last column opened ({0})
0\ No newline at end of file22\ No newline at end of file
123
=== added file 'VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Bundle_es.properties'
--- VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Bundle_es.properties 1970-01-01 00:00:00 +0000
+++ VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Bundle_es.properties 2011-02-01 14:23:14 +0000
@@ -0,0 +1,32 @@
1# Spanish translation for gephi
2# Copyright (c) 2010 Rosetta Contributors and Canonical Ltd 2010
3# This file is distributed under the same license as the gephi package.
4# FIRST AUTHOR <EMAIL@ADDRESS>, 2010.
5#
6!=Project-Id-Version\: gephi\nReport-Msgid-Bugs-To\: FULL NAME <EMAIL@ADDRESS>\nPOT-Creation-Date\: 2010-04-07 13\:16+0200\nPO-Revision-Date\: 2010-12-26 00\:11+0000\nLast-Translator\: Eduardo Ramos <Unknown>\nLanguage-Team\: Spanish <es@li.org>\nMIME-Version\: 1.0\nContent-Type\: text/plain; charset\=UTF-8\nContent-Transfer-Encoding\: 8bit\nX-Launchpad-Export-Date\: 2010-12-27 04\:43+0000\nX-Generator\: Launchpad (build Unknown)\n
7
8GraphContextMenu_Group=Agrupar
9
10GraphContextMenu_Ungroup=Desagrupar
11
12GraphContextMenu_Expand=Expandir
13
14GraphContextMenu_Contract=Contraer
15
16GraphContextMenu_Settle=Bloquear
17
18GraphContextMenu_Free=Desbloquear
19
20GraphContextMenu_Delete=Eliminar
21
22GraphContextMenu_MoveToWorkspace=Mover a...
23
24GraphContextMenu_MoveToWorkspace_NewWorkspace=Nuevo espacio de trabajo
25
26GraphContextMenu_CopyToWorkspace=Copiar a...
27
28GraphContextMenu_CopyToWorkspace_NewWorkspace=Nuevo espacio de trabajo
29
30GraphContextMenu.Delete.message=Los nodos ser\u00e1n eliminados, \u00bfContinuar?
31
32GraphContextMenu.Delete.message.title=Eliminar nodos
033
=== added file 'VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Bundle_fr.properties'
--- VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Bundle_fr.properties 1970-01-01 00:00:00 +0000
+++ VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Bundle_fr.properties 2011-02-01 14:23:14 +0000
@@ -0,0 +1,32 @@
1# French translation for gephi
2# Copyright (c) 2010 Rosetta Contributors and Canonical Ltd 2010
3# This file is distributed under the same license as the gephi package.
4# FIRST AUTHOR <EMAIL@ADDRESS>, 2010.
5#
6!=Project-Id-Version\: gephi\nReport-Msgid-Bugs-To\: FULL NAME <EMAIL@ADDRESS>\nPOT-Creation-Date\: 2010-04-07 13\:16+0200\nPO-Revision-Date\: 2010-12-25 19\:49+0000\nLast-Translator\: S\u00e9bastien Heymann <Unknown>\nLanguage-Team\: French <fr@li.org>\nMIME-Version\: 1.0\nContent-Type\: text/plain; charset\=UTF-8\nContent-Transfer-Encoding\: 8bit\nX-Launchpad-Export-Date\: 2010-12-26 04\:53+0000\nX-Generator\: Launchpad (build Unknown)\n
7
8GraphContextMenu_Group=Grouper
9
10GraphContextMenu_Ungroup=D\u00e9grouper
11
12GraphContextMenu_Expand=\u00c9tendre
13
14GraphContextMenu_Contract=Contracter
15
16GraphContextMenu_Settle=Fixer
17
18GraphContextMenu_Free=Lib\u00e9rer
19
20GraphContextMenu_Delete=Supprimer
21
22GraphContextMenu_MoveToWorkspace=D\u00e9placer vers...
23
24GraphContextMenu_MoveToWorkspace_NewWorkspace=Nouvel espace de travail
25
26GraphContextMenu_CopyToWorkspace=Copier vers...
27
28GraphContextMenu_CopyToWorkspace_NewWorkspace=Nouvel espace de travail
29
30GraphContextMenu.Delete.message=Les noeuds seront supprim\u00e9s. Voulez-vous continuer ?
31
32GraphContextMenu.Delete.message.title=Suppression des noeuds
033
=== added file 'VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Contract.java'
--- VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Contract.java 1970-01-01 00:00:00 +0000
+++ VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Contract.java 2011-02-01 14:23:14 +0000
@@ -0,0 +1,126 @@
1/*
2Copyright 2008-2010 Gephi
3Authors : Mathieu Bastian <mathieu.bastian@gephi.org>, Eduardo Ramos <eduramiba@gmail.com>
4Website : http://www.gephi.org
5
6This file is part of Gephi.
7
8Gephi is free software: you can redistribute it and/or modify
9it under the terms of the GNU Affero General Public License as
10published by the Free Software Foundation, either version 3 of the
11License, or (at your option) any later version.
12
13Gephi is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU Affero General Public License for more details.
17
18You should have received a copy of the GNU Affero General Public License
19along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.visualization.apiimpl.contextmenuitems;
22
23import java.awt.event.KeyEvent;
24import java.util.HashSet;
25import java.util.Set;
26import javax.swing.Icon;
27import org.gephi.graph.api.GroupData;
28import org.gephi.graph.api.HierarchicalGraph;
29import org.gephi.graph.api.Node;
30import org.gephi.graph.api.NodeData;
31import org.gephi.visualization.hull.ConvexHull;
32import org.gephi.visualization.opengl.compatibility.objects.ConvexHullModel;
33import org.gephi.visualization.spi.GraphContextMenuItem;
34import org.openide.util.ImageUtilities;
35import org.openide.util.NbBundle;
36import org.openide.util.lookup.ServiceProvider;
37
38/**
39 *
40 */
41@ServiceProvider(service = GraphContextMenuItem.class)
42public class Contract implements GraphContextMenuItem {
43
44 private Node[] nodes;
45 private HierarchicalGraph graph;
46
47 public void setup(HierarchicalGraph graph, Node[] nodes) {
48 this.nodes = nodes;
49 this.graph = graph;
50 }
51
52 public void execute() {
53 try {
54 Set<Node> parents = new HashSet<Node>();
55 for (Node node : nodes) {
56 Node nodeParent = graph.getParent(node);
57 if (nodeParent != null) {
58 parents.add(nodeParent);
59 }
60 }
61
62 for (Node parent : parents) {
63 GroupData gd = (GroupData) parent.getNodeData();
64 if (gd.getHullModel() != null) {
65 ConvexHull hull = ((ConvexHullModel) gd.getHullModel()).getObj();
66 contractPositioning(hull);
67 }
68 graph.retract(parent);
69 }
70 } catch (Exception e) {
71 e.printStackTrace();
72 graph.readUnlockAll();
73 }
74 }
75
76 private void contractPositioning(ConvexHull hull) {
77 NodeData metaNode = hull.getMetaNode().getNodeData();
78 metaNode.setX(hull.x());
79 metaNode.setY(hull.y());
80
81 ConvexHullModel model = (ConvexHullModel) hull.getModel();
82 model.setScale(0.9f);
83 model.setScaleQuantum(-0.1f);
84 }
85
86 public GraphContextMenuItem[] getSubItems() {
87 return null;
88 }
89
90 public String getName() {
91 return NbBundle.getMessage(Contract.class, "GraphContextMenu_Contract");
92 }
93
94 public String getDescription() {
95 return null;
96 }
97
98 public boolean isAvailable() {
99 return true;
100 }
101
102 public boolean canExecute() {
103 for (Node n : nodes) {
104 if (graph.getParent(n)!=null) {
105 return true;
106 }
107 }
108 return false;
109 }
110
111 public int getType() {
112 return 100;
113 }
114
115 public int getPosition() {
116 return 100;
117 }
118
119 public Icon getIcon() {
120 return ImageUtilities.loadImageIcon("org/gephi/visualization/api/resources/contract.png", false);
121 }
122
123 public Integer getMnemonicKey() {
124 return KeyEvent.VK_C;
125 }
126}
0127
=== added file 'VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/CopyOrMoveToWorkspace.java'
--- VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/CopyOrMoveToWorkspace.java 1970-01-01 00:00:00 +0000
+++ VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/CopyOrMoveToWorkspace.java 2011-02-01 14:23:14 +0000
@@ -0,0 +1,93 @@
1/*
2Copyright 2008-2010 Gephi
3Authors : Mathieu Bastian <mathieu.bastian@gephi.org>, Eduardo Ramos <eduramiba@gmail.com>
4Website : http://www.gephi.org
5
6This file is part of Gephi.
7
8Gephi is free software: you can redistribute it and/or modify
9it under the terms of the GNU Affero General Public License as
10published by the Free Software Foundation, either version 3 of the
11License, or (at your option) any later version.
12
13Gephi is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU Affero General Public License for more details.
17
18You should have received a copy of the GNU Affero General Public License
19along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.visualization.apiimpl.contextmenuitems;
22
23import java.util.ArrayList;
24import javax.swing.Icon;
25import org.gephi.graph.api.HierarchicalGraph;
26import org.gephi.graph.api.Node;
27import org.gephi.project.api.ProjectController;
28import org.gephi.project.api.Workspace;
29import org.gephi.project.api.WorkspaceProvider;
30import org.gephi.visualization.spi.GraphContextMenuItem;
31import org.openide.util.Lookup;
32
33/**
34 *
35 */
36public abstract class CopyOrMoveToWorkspace implements GraphContextMenuItem {
37
38 private Node[] nodes;
39
40 public void setup(HierarchicalGraph graph, Node[] nodes) {
41 this.nodes = nodes;
42 }
43
44 public void execute() {
45 }
46
47 public GraphContextMenuItem[] getSubItems() {
48 if (nodes != null) {
49 int i = 0;
50 ArrayList<GraphContextMenuItem> subItems = new ArrayList<GraphContextMenuItem>();
51 if (canExecute()) {
52 subItems.add(new CopyOrMoveToWorkspaceSubItem(null, true, 0, 0, isCopy()));//New workspace
53 ProjectController projectController = Lookup.getDefault().lookup(ProjectController.class);
54 for (final Workspace w : projectController.getCurrentProject().getLookup().lookup(WorkspaceProvider.class).getWorkspaces()) {
55 GraphContextMenuItem item = new CopyOrMoveToWorkspaceSubItem(w, w != projectController.getCurrentWorkspace(), 1, i, isCopy());
56 subItems.add(item);
57 i++;
58 }
59 return subItems.toArray(new GraphContextMenuItem[0]);
60 } else {
61 return null;
62 }
63 } else {
64 return null;
65 }
66 }
67
68 public String getDescription() {
69 return null;
70 }
71
72 public boolean isAvailable() {
73 return true;
74 }
75
76 public boolean canExecute() {
77 return nodes.length > 0;
78 }
79
80 public int getType() {
81 return 200;
82 }
83
84 public Icon getIcon() {
85 return null;
86 }
87
88 public Integer getMnemonicKey() {
89 return null;
90 }
91
92 protected abstract boolean isCopy();
93}
094
=== added file 'VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/CopyOrMoveToWorkspaceSubItem.java'
--- VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/CopyOrMoveToWorkspaceSubItem.java 1970-01-01 00:00:00 +0000
+++ VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/CopyOrMoveToWorkspaceSubItem.java 2011-02-01 14:23:14 +0000
@@ -0,0 +1,149 @@
1/*
2Copyright 2008-2010 Gephi
3Authors : Mathieu Bastian <mathieu.bastian@gephi.org>, Eduardo Ramos <eduramiba@gmail.com>
4Website : http://www.gephi.org
5
6This file is part of Gephi.
7
8Gephi is free software: you can redistribute it and/or modify
9it under the terms of the GNU Affero General Public License as
10published by the Free Software Foundation, either version 3 of the
11License, or (at your option) any later version.
12
13Gephi is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU Affero General Public License for more details.
17
18You should have received a copy of the GNU Affero General Public License
19along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.visualization.apiimpl.contextmenuitems;
22
23import javax.swing.Icon;
24import org.gephi.data.attributes.api.AttributeController;
25import org.gephi.data.attributes.api.AttributeModel;
26import org.gephi.desktop.project.api.ProjectControllerUI;
27import org.gephi.graph.api.Graph;
28import org.gephi.graph.api.GraphController;
29import org.gephi.graph.api.GraphModel;
30import org.gephi.graph.api.HierarchicalGraph;
31import org.gephi.graph.api.Node;
32import org.gephi.project.api.ProjectController;
33import org.gephi.project.api.Workspace;
34import org.gephi.project.api.WorkspaceInformation;
35import org.gephi.visualization.spi.GraphContextMenuItem;
36import org.openide.util.Lookup;
37import org.openide.util.NbBundle;
38
39public class CopyOrMoveToWorkspaceSubItem implements GraphContextMenuItem {
40
41 private Workspace workspace;
42 private boolean canExecute;
43 private int type;
44 private int position;
45 private HierarchicalGraph graph;
46 private Node[] nodes;
47 private final boolean copy;
48
49 /**
50 * Constructor with copy or move settings
51 * @param workspace Workspace to copy or move, or null to use new workspace
52 * @param canExecute canExecute
53 * @param type type
54 * @param position position
55 * @param copy True to copy, false to move
56 */
57 public CopyOrMoveToWorkspaceSubItem(Workspace workspace, boolean canExecute, int type, int position, boolean copy) {
58 this.workspace = workspace;
59 this.canExecute = canExecute;
60 this.type = type;
61 this.position = position;
62 this.copy = copy;
63 }
64
65 public void setup(HierarchicalGraph graph, Node[] nodes) {
66 this.graph = graph;
67 this.nodes = nodes;
68 }
69
70 public void execute() {
71 if (workspace == null) {
72 workspace = Lookup.getDefault().lookup(ProjectControllerUI.class).newWorkspace();
73 }
74 if (copy) {
75 copyToWorkspace(workspace);
76 } else {
77 moveToWorkspace(workspace);
78 }
79 }
80
81 public GraphContextMenuItem[] getSubItems() {
82 return null;
83 }
84
85 public String getName() {
86 if (workspace != null) {
87 return workspace.getLookup().lookup(WorkspaceInformation.class).getName();
88 } else {
89 return NbBundle.getMessage(CopyOrMoveToWorkspaceSubItem.class, copy ? "GraphContextMenu_CopyToWorkspace_NewWorkspace" : "GraphContextMenu_MoveToWorkspace_NewWorkspace");
90 }
91 }
92
93 public String getDescription() {
94 return null;
95 }
96
97 public boolean isAvailable() {
98 return true;
99 }
100
101 public boolean canExecute() {
102 return canExecute;
103 }
104
105 public int getType() {
106 return type;
107 }
108
109 public int getPosition() {
110 return position;
111 }
112
113 public Icon getIcon() {
114 return null;
115 }
116
117 public void copyToWorkspace(Workspace workspace) {
118 GraphController graphController = Lookup.getDefault().lookup(GraphController.class);
119 AttributeController attributeController = Lookup.getDefault().lookup(AttributeController.class);
120 ProjectController projectController = Lookup.getDefault().lookup(ProjectController.class);
121
122 Workspace currentWorkspace = projectController.getCurrentWorkspace();
123 AttributeModel sourceAttributeModel = attributeController.getModel(currentWorkspace);
124 AttributeModel destAttributeModel = attributeController.getModel(workspace);
125 destAttributeModel.mergeModel(sourceAttributeModel);
126
127 GraphModel sourceModel = graphController.getModel(currentWorkspace);
128 GraphModel destModel = graphController.getModel(workspace);
129 Graph destGraph = destModel.getHierarchicalGraphVisible();
130 Graph sourceGraph = sourceModel.getHierarchicalGraphVisible();
131
132 destModel.pushNodes(sourceGraph, nodes);
133 }
134
135 public void moveToWorkspace(Workspace workspace) {
136 copyToWorkspace(workspace);
137 delete();
138 }
139
140 public void delete() {
141 for (Node n : nodes) {
142 graph.removeNode(n);
143 }
144 }
145
146 public Integer getMnemonicKey() {
147 return null;
148 }
149}
0150
=== added file 'VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/CopyToWorkspace.java'
--- VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/CopyToWorkspace.java 1970-01-01 00:00:00 +0000
+++ VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/CopyToWorkspace.java 2011-02-01 14:23:14 +0000
@@ -0,0 +1,31 @@
1/*
2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
4 */
5
6package org.gephi.visualization.apiimpl.contextmenuitems;
7
8import org.gephi.visualization.spi.GraphContextMenuItem;
9import org.openide.util.NbBundle;
10import org.openide.util.lookup.ServiceProvider;
11
12/**
13 *
14 * @author Eduardo
15 */
16@ServiceProvider(service = GraphContextMenuItem.class)
17public class CopyToWorkspace extends CopyOrMoveToWorkspace{
18
19 @Override
20 protected boolean isCopy() {
21 return true;
22 }
23
24 public String getName() {
25 return NbBundle.getMessage(CopyOrMoveToWorkspace.class, "GraphContextMenu_CopyToWorkspace");
26 }
27
28 public int getPosition() {
29 return 200;
30 }
31}
032
=== added file 'VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Delete.java'
--- VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Delete.java 1970-01-01 00:00:00 +0000
+++ VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Delete.java 2011-02-01 14:23:14 +0000
@@ -0,0 +1,93 @@
1/*
2Copyright 2008-2010 Gephi
3Authors : Mathieu Bastian <mathieu.bastian@gephi.org>, Eduardo Ramos <eduramiba@gmail.com>
4Website : http://www.gephi.org
5
6This file is part of Gephi.
7
8Gephi is free software: you can redistribute it and/or modify
9it under the terms of the GNU Affero General Public License as
10published by the Free Software Foundation, either version 3 of the
11License, or (at your option) any later version.
12
13Gephi is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU Affero General Public License for more details.
17
18You should have received a copy of the GNU Affero General Public License
19along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.visualization.apiimpl.contextmenuitems;
22
23import java.awt.event.KeyEvent;
24import javax.swing.Icon;
25import org.gephi.datalab.api.GraphElementsController;
26import org.gephi.graph.api.HierarchicalGraph;
27import org.gephi.graph.api.Node;
28import org.gephi.visualization.spi.GraphContextMenuItem;
29import org.openide.DialogDisplayer;
30import org.openide.NotifyDescriptor;
31import org.openide.util.ImageUtilities;
32import org.openide.util.Lookup;
33import org.openide.util.NbBundle;
34import org.openide.util.lookup.ServiceProvider;
35
36/**
37 *
38 */
39@ServiceProvider(service = GraphContextMenuItem.class)
40public class Delete implements GraphContextMenuItem {
41
42 private Node[] nodes;
43
44 public void setup(HierarchicalGraph graph, Node[] nodes) {
45 this.nodes = nodes;
46 }
47
48 public void execute() {
49 NotifyDescriptor.Confirmation notifyDescriptor = new NotifyDescriptor.Confirmation(
50 NbBundle.getMessage(Delete.class, "GraphContextMenu.Delete.message"),
51 NbBundle.getMessage(Delete.class, "GraphContextMenu.Delete.message.title"), NotifyDescriptor.YES_NO_OPTION);
52 if (DialogDisplayer.getDefault().notify(notifyDescriptor).equals(NotifyDescriptor.YES_OPTION)) {
53 GraphElementsController gec = Lookup.getDefault().lookup(GraphElementsController.class);
54 gec.deleteNodes(nodes);
55 }
56 }
57
58 public GraphContextMenuItem[] getSubItems() {
59 return null;
60 }
61
62 public String getName() {
63 return NbBundle.getMessage(Delete.class, "GraphContextMenu_Delete");
64 }
65
66 public String getDescription() {
67 return null;
68 }
69
70 public boolean isAvailable() {
71 return true;
72 }
73
74 public boolean canExecute() {
75 return nodes.length > 0;
76 }
77
78 public int getType() {
79 return 200;
80 }
81
82 public int getPosition() {
83 return 0;
84 }
85
86 public Icon getIcon() {
87 return ImageUtilities.loadImageIcon("org/gephi/visualization/api/resources/delete.png", false);
88 }
89
90 public Integer getMnemonicKey() {
91 return KeyEvent.VK_D;
92 }
93}
094
=== added file 'VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Expand.java'
--- VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Expand.java 1970-01-01 00:00:00 +0000
+++ VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Expand.java 2011-02-01 14:23:14 +0000
@@ -0,0 +1,124 @@
1/*
2Copyright 2008-2010 Gephi
3Authors : Mathieu Bastian <mathieu.bastian@gephi.org>, Eduardo Ramos <eduramiba@gmail.com>
4Website : http://www.gephi.org
5
6This file is part of Gephi.
7
8Gephi is free software: you can redistribute it and/or modify
9it under the terms of the GNU Affero General Public License as
10published by the Free Software Foundation, either version 3 of the
11License, or (at your option) any later version.
12
13Gephi is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU Affero General Public License for more details.
17
18You should have received a copy of the GNU Affero General Public License
19along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.visualization.apiimpl.contextmenuitems;
22
23import java.awt.event.KeyEvent;
24import javax.swing.Icon;
25import org.gephi.graph.api.HierarchicalGraph;
26import org.gephi.graph.api.Node;
27import org.gephi.graph.api.NodeData;
28import org.gephi.visualization.spi.GraphContextMenuItem;
29import org.openide.util.ImageUtilities;
30import org.openide.util.NbBundle;
31import org.openide.util.lookup.ServiceProvider;
32
33/**
34 *
35 */
36@ServiceProvider(service = GraphContextMenuItem.class)
37public class Expand implements GraphContextMenuItem {
38
39 private Node[] nodes;
40 private HierarchicalGraph graph;
41
42 public void setup(HierarchicalGraph graph, Node[] nodes) {
43 this.nodes = nodes;
44 this.graph=graph;
45 }
46
47 public void execute() {
48 try {
49 for (Node node : nodes) {
50 if (graph.getDescendantCount(node) > 0) {
51 expandPositioning(node);
52 graph.expand(node);
53 }
54 }
55 } catch (Exception e) {
56 e.printStackTrace();
57 graph.readUnlockAll();
58 }
59 }
60
61 private void expandPositioning(Node node) {
62 NodeData nodeData = node.getNodeData();
63 float centroidX = 0;
64 float centroidY = 0;
65 int len = 0;
66 Node[] children = graph.getChildren(node).toArray();
67 for (Node child : children) {
68 centroidX += child.getNodeData().x();
69 centroidY += child.getNodeData().y();
70 len++;
71 }
72 centroidX /= len;
73 centroidY /= len;
74
75 float diffX = nodeData.x() - centroidX;
76 float diffY = nodeData.y() - centroidY;
77 for (Node child : children) {
78 NodeData nd = child.getNodeData();
79 nd.setX(nd.x() + diffX);
80 nd.setY(nd.y() + diffY);
81 }
82 }
83
84 public GraphContextMenuItem[] getSubItems() {
85 return null;
86 }
87
88 public String getName() {
89 return NbBundle.getMessage(Expand.class, "GraphContextMenu_Expand");
90 }
91
92 public String getDescription() {
93 return null;
94 }
95
96 public boolean isAvailable() {
97 return true;
98 }
99
100 public boolean canExecute() {
101 for (Node n : nodes) {
102 if (graph.getDescendantCount(n)>0) {
103 return true;
104 }
105 }
106 return false;
107 }
108
109 public int getType() {
110 return 100;
111 }
112
113 public int getPosition() {
114 return 0;
115 }
116
117 public Icon getIcon() {
118 return ImageUtilities.loadImageIcon("org/gephi/visualization/api/resources/expand.png", false);
119 }
120
121 public Integer getMnemonicKey() {
122 return KeyEvent.VK_E;
123 }
124}
0125
=== added file 'VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Free.java'
--- VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Free.java 1970-01-01 00:00:00 +0000
+++ VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Free.java 2011-02-01 14:23:14 +0000
@@ -0,0 +1,91 @@
1/*
2Copyright 2008-2010 Gephi
3Authors : Mathieu Bastian <mathieu.bastian@gephi.org>, Eduardo Ramos <eduramiba@gmail.com>
4Website : http://www.gephi.org
5
6This file is part of Gephi.
7
8Gephi is free software: you can redistribute it and/or modify
9it under the terms of the GNU Affero General Public License as
10published by the Free Software Foundation, either version 3 of the
11License, or (at your option) any later version.
12
13Gephi is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU Affero General Public License for more details.
17
18You should have received a copy of the GNU Affero General Public License
19along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.visualization.apiimpl.contextmenuitems;
22
23import java.awt.event.KeyEvent;
24import javax.swing.Icon;
25import org.gephi.datalab.api.GraphElementsController;
26import org.gephi.graph.api.HierarchicalGraph;
27import org.gephi.graph.api.Node;
28import org.gephi.visualization.spi.GraphContextMenuItem;
29import org.openide.util.ImageUtilities;
30import org.openide.util.Lookup;
31import org.openide.util.NbBundle;
32import org.openide.util.lookup.ServiceProvider;
33
34/**
35 *
36 */
37@ServiceProvider(service = GraphContextMenuItem.class)
38public class Free implements GraphContextMenuItem {
39
40 private Node[] nodes;
41
42 public void setup(HierarchicalGraph graph, Node[] nodes) {
43 this.nodes = nodes;
44 }
45
46 public void execute() {
47 GraphElementsController gec = Lookup.getDefault().lookup(GraphElementsController.class);
48 gec.setNodesFixed(nodes, false);
49 }
50
51 public GraphContextMenuItem[] getSubItems() {
52 return null;
53 }
54
55 public String getName() {
56 return NbBundle.getMessage(Free.class, "GraphContextMenu_Free");
57 }
58
59 public String getDescription() {
60 return null;
61 }
62
63 public boolean isAvailable() {
64 return true;
65 }
66
67 public boolean canExecute() {
68 for (Node n : nodes) {
69 if (Lookup.getDefault().lookup(GraphElementsController.class).isNodeFixed(n)) {
70 return true;
71 }
72 }
73 return false;
74 }
75
76 public int getType() {
77 return 300;
78 }
79
80 public int getPosition() {
81 return 100;
82 }
83
84 public Icon getIcon() {
85 return ImageUtilities.loadImageIcon("org/gephi/visualization/api/resources/free.png", false);
86 }
87
88 public Integer getMnemonicKey() {
89 return KeyEvent.VK_F;
90 }
91}
092
=== added file 'VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Group.java'
--- VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Group.java 1970-01-01 00:00:00 +0000
+++ VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Group.java 2011-02-01 14:23:14 +0000
@@ -0,0 +1,85 @@
1/*
2Copyright 2008-2010 Gephi
3Authors : Mathieu Bastian <mathieu.bastian@gephi.org>, Eduardo Ramos <eduramiba@gmail.com>
4Website : http://www.gephi.org
5
6This file is part of Gephi.
7
8Gephi is free software: you can redistribute it and/or modify
9it under the terms of the GNU Affero General Public License as
10published by the Free Software Foundation, either version 3 of the
11License, or (at your option) any later version.
12
13Gephi is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU Affero General Public License for more details.
17
18You should have received a copy of the GNU Affero General Public License
19along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.visualization.apiimpl.contextmenuitems;
22
23import java.awt.event.KeyEvent;
24import javax.swing.Icon;
25import org.gephi.datalab.api.GraphElementsController;
26import org.gephi.graph.api.HierarchicalGraph;
27import org.gephi.graph.api.Node;
28import org.gephi.visualization.spi.GraphContextMenuItem;
29import org.openide.util.ImageUtilities;
30import org.openide.util.Lookup;
31import org.openide.util.NbBundle;
32import org.openide.util.lookup.ServiceProvider;
33
34/**
35 *
36 */
37@ServiceProvider(service=GraphContextMenuItem.class)
38public class Group implements GraphContextMenuItem{
39 private Node[] nodes;
40
41 public void setup(HierarchicalGraph graph,Node[] nodes) {
42 this.nodes=nodes;
43 }
44
45 public void execute() {
46 GraphElementsController gec=Lookup.getDefault().lookup(GraphElementsController.class);
47 gec.groupNodes(nodes);
48 }
49
50 public GraphContextMenuItem[] getSubItems() {
51 return null;
52 }
53
54 public String getName() {
55 return NbBundle.getMessage(Group.class, "GraphContextMenu_Group");
56 }
57
58 public String getDescription() {
59 return null;
60 }
61
62 public boolean isAvailable() {
63 return true;
64 }
65
66 public boolean canExecute() {
67 return nodes.length>0;
68 }
69
70 public int getType() {
71 return 0;
72 }
73
74 public int getPosition() {
75 return 0;
76 }
77
78 public Icon getIcon() {
79 return ImageUtilities.loadImageIcon("org/gephi/visualization/api/resources/group.png", false);
80 }
81
82 public Integer getMnemonicKey() {
83 return KeyEvent.VK_G;
84 }
85}
086
=== added file 'VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/LastColumnOpenedURL.java'
--- VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/LastColumnOpenedURL.java 1970-01-01 00:00:00 +0000
+++ VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/LastColumnOpenedURL.java 2011-02-01 14:23:14 +0000
@@ -0,0 +1,33 @@
1/*
2Copyright 2008-2010 Gephi
3Authors : Mathieu Bastian <mathieu.bastian@gephi.org>, Eduardo Ramos <eduramiba@gmail.com>
4Website : http://www.gephi.org
5
6This file is part of Gephi.
7
8Gephi is free software: you can redistribute it and/or modify
9it under the terms of the GNU Affero General Public License as
10published by the Free Software Foundation, either version 3 of the
11License, or (at your option) any later version.
12
13Gephi is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU Affero General Public License for more details.
17
18You should have received a copy of the GNU Affero General Public License
19along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.visualization.apiimpl.contextmenuitems;
22
23/**
24 *
25 * @author Eduardo
26 */
27public class LastColumnOpenedURL {
28 String column;
29
30 public LastColumnOpenedURL(String column) {
31 this.column = column;
32 }
33}
034
=== added file 'VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/MoveToWorkspace.java'
--- VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/MoveToWorkspace.java 1970-01-01 00:00:00 +0000
+++ VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/MoveToWorkspace.java 2011-02-01 14:23:14 +0000
@@ -0,0 +1,31 @@
1/*
2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
4 */
5
6package org.gephi.visualization.apiimpl.contextmenuitems;
7
8import org.gephi.visualization.spi.GraphContextMenuItem;
9import org.openide.util.NbBundle;
10import org.openide.util.lookup.ServiceProvider;
11
12/**
13 *
14 * @author Eduardo
15 */
16@ServiceProvider(service = GraphContextMenuItem.class)
17public class MoveToWorkspace extends CopyOrMoveToWorkspace{
18
19 @Override
20 protected boolean isCopy() {
21 return false;
22 }
23
24 public String getName() {
25 return NbBundle.getMessage(CopyOrMoveToWorkspace.class, "GraphContextMenu_MoveToWorkspace");
26 }
27
28 public int getPosition() {
29 return 100;
30 }
31}
032
=== added file 'VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/OpenURL.java'
--- VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/OpenURL.java 1970-01-01 00:00:00 +0000
+++ VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/OpenURL.java 2011-02-01 14:23:14 +0000
@@ -0,0 +1,93 @@
1/*
2Copyright 2008-2010 Gephi
3Authors : Mathieu Bastian <mathieu.bastian@gephi.org>, Eduardo Ramos <eduramiba@gmail.com>
4Website : http://www.gephi.org
5
6This file is part of Gephi.
7
8Gephi is free software: you can redistribute it and/or modify
9it under the terms of the GNU Affero General Public License as
10published by the Free Software Foundation, either version 3 of the
11License, or (at your option) any later version.
12
13Gephi is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU Affero General Public License for more details.
17
18You should have received a copy of the GNU Affero General Public License
19along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.visualization.apiimpl.contextmenuitems;
22
23import java.util.ArrayList;
24import javax.swing.Icon;
25import org.gephi.data.attributes.api.AttributeRow;
26import org.gephi.data.attributes.api.AttributeType;
27import org.gephi.graph.api.HierarchicalGraph;
28import org.gephi.graph.api.Node;
29import org.gephi.visualization.spi.GraphContextMenuItem;
30import org.openide.util.ImageUtilities;
31import org.openide.util.NbBundle;
32import org.openide.util.lookup.ServiceProvider;
33
34/**
35 *
36 */
37@ServiceProvider(service = GraphContextMenuItem.class)
38public class OpenURL implements GraphContextMenuItem {
39
40 private Node node;
41
42 public void setup(HierarchicalGraph graph, Node[] nodes) {
43 if (nodes.length == 1) {
44 node = nodes[0];
45 }else{
46 node=null;
47 }
48 }
49
50 public void execute() {
51 }
52
53 public GraphContextMenuItem[] getSubItems() {
54 GraphContextMenuItem[] subItems=new GraphContextMenuItem[2];
55
56 //Always provide subitems so their shortcuts are available:
57 subItems[0]=new OpenURLLastItem();
58 subItems[1]=new OpenURLSubItem();
59 return subItems;
60 }
61
62 public String getName() {
63 return NbBundle.getMessage(OpenURL.class, "GraphContextMenu_OpenURL");
64 }
65
66 public String getDescription() {
67 return NbBundle.getMessage(OpenURL.class, "GraphContextMenu_OpenURL.description");
68 }
69
70 public boolean isAvailable() {
71 return node != null;
72 }
73
74 public boolean canExecute() {
75 return true;
76 }
77
78 public int getType() {
79 return 400;
80 }
81
82 public int getPosition() {
83 return 300;
84 }
85
86 public Icon getIcon() {
87 return ImageUtilities.loadImageIcon("org/gephi/visualization/api/resources/globe-network.png", false);
88 }
89
90 public Integer getMnemonicKey() {
91 return null;
92 }
93}
094
=== added file 'VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/OpenURLLastItem.java'
--- VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/OpenURLLastItem.java 1970-01-01 00:00:00 +0000
+++ VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/OpenURLLastItem.java 2011-02-01 14:23:14 +0000
@@ -0,0 +1,119 @@
1/*
2Copyright 2008-2010 Gephi
3Authors : Mathieu Bastian <mathieu.bastian@gephi.org>, Eduardo Ramos <eduramiba@gmail.com>
4Website : http://www.gephi.org
5
6This file is part of Gephi.
7
8Gephi is free software: you can redistribute it and/or modify
9it under the terms of the GNU Affero General Public License as
10published by the Free Software Foundation, either version 3 of the
11License, or (at your option) any later version.
12
13Gephi is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU Affero General Public License for more details.
17
18You should have received a copy of the GNU Affero General Public License
19along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.visualization.apiimpl.contextmenuitems;
22
23import java.awt.event.KeyEvent;
24import java.net.URL;
25import javax.swing.Icon;
26import org.gephi.data.attributes.api.AttributeController;
27import org.gephi.data.attributes.api.AttributeRow;
28import org.gephi.data.attributes.api.AttributeTable;
29import org.gephi.graph.api.HierarchicalGraph;
30import org.gephi.graph.api.Node;
31import org.gephi.project.api.ProjectController;
32import org.gephi.visualization.spi.GraphContextMenuItem;
33import org.openide.awt.HtmlBrowser.URLDisplayer;
34import org.openide.util.Lookup;
35import org.openide.util.NbBundle;
36
37/**
38 *
39 */
40public class OpenURLLastItem implements GraphContextMenuItem {
41
42 private Node node;
43 private String column, url;
44
45 public void setup(HierarchicalGraph graph, Node[] nodes) {
46 url = null;
47 column = null;
48 if (nodes.length == 1) {
49 node = nodes[0];
50 LastColumnOpenedURL lc = Lookup.getDefault().lookup(ProjectController.class).getCurrentWorkspace().getLookup().lookup(LastColumnOpenedURL.class);
51 if (lc != null) {
52 column = lc.column;
53 AttributeTable table = Lookup.getDefault().lookup(AttributeController.class).getModel().getNodeTable();
54 if (table.hasColumn(column)) {
55 AttributeRow row = (AttributeRow) node.getNodeData().getAttributes();
56 Object value;
57 if ((value = row.getValue(column)) != null) {
58 url = value.toString();
59
60 if (!url.matches("(https?|ftp):(//?|\\\\?)?.*")) {
61 //Does not look like an URL, try http:
62 url = "http://" + url;
63 }
64 }
65 }else{
66 column=null;
67 Lookup.getDefault().lookup(ProjectController.class).getCurrentWorkspace().remove(lc);
68 }
69 }
70 } else {
71 node = null;
72 }
73 }
74
75 public void execute() {
76 if (url != null) {
77 try {
78 URLDisplayer.getDefault().showURLExternal(new URL(url));
79 } catch (Exception ex) {
80 }
81 }
82 }
83
84 public GraphContextMenuItem[] getSubItems() {
85 return null;
86 }
87
88 public String getName() {
89 return NbBundle.getMessage(OpenURLLastItem.class, "GraphContextMenu_OpenURLLastItem", column != null ? column : "--");
90 }
91
92 public String getDescription() {
93 return null;
94 }
95
96 public boolean isAvailable() {
97 return true;
98 }
99
100 public boolean canExecute() {
101 return url != null;
102 }
103
104 public int getType() {
105 return 0;
106 }
107
108 public int getPosition() {
109 return 0;
110 }
111
112 public Icon getIcon() {
113 return null;
114 }
115
116 public Integer getMnemonicKey() {
117 return KeyEvent.VK_P;
118 }
119}
0120
=== added file 'VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/OpenURLSubItem.java'
--- VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/OpenURLSubItem.java 1970-01-01 00:00:00 +0000
+++ VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/OpenURLSubItem.java 2011-02-01 14:23:14 +0000
@@ -0,0 +1,152 @@
1/*
2Copyright 2008-2010 Gephi
3Authors : Mathieu Bastian <mathieu.bastian@gephi.org>, Eduardo Ramos <eduramiba@gmail.com>
4Website : http://www.gephi.org
5
6This file is part of Gephi.
7
8Gephi is free software: you can redistribute it and/or modify
9it under the terms of the GNU Affero General Public License as
10published by the Free Software Foundation, either version 3 of the
11License, or (at your option) any later version.
12
13Gephi is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU Affero General Public License for more details.
17
18You should have received a copy of the GNU Affero General Public License
19along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.visualization.apiimpl.contextmenuitems;
22
23import java.awt.event.KeyEvent;
24import java.net.URL;
25import java.util.ArrayList;
26import javax.swing.Icon;
27import javax.swing.JOptionPane;
28import org.gephi.data.attributes.api.AttributeColumn;
29import org.gephi.data.attributes.api.AttributeRow;
30import org.gephi.data.attributes.api.AttributeType;
31import org.gephi.graph.api.HierarchicalGraph;
32import org.gephi.graph.api.Node;
33import org.gephi.project.api.ProjectController;
34import org.gephi.visualization.spi.GraphContextMenuItem;
35import org.openide.awt.HtmlBrowser.URLDisplayer;
36import org.openide.util.Lookup;
37import org.openide.util.NbBundle;
38
39/**
40 *
41 */
42public class OpenURLSubItem implements GraphContextMenuItem {
43
44 private Node node;
45 private String columnTitle, url;
46
47 public void setup(HierarchicalGraph graph, Node[] nodes) {
48 if (nodes.length == 1) {
49 node = nodes[0];
50 } else {
51 node = null;
52 }
53 }
54
55 public void execute() {
56 if (node != null) {
57 LastColumnOpenedURL lc = Lookup.getDefault().lookup(ProjectController.class).getCurrentWorkspace().getLookup().lookup(LastColumnOpenedURL.class);
58 ArrayList<ColumnURL> columnUrls = new ArrayList<ColumnURL>();
59 ColumnURL initialSelection = null;
60 Object value;
61 String str;
62 AttributeColumn column;
63 AttributeRow row = (AttributeRow) node.getNodeData().getAttributes();
64 for (int i = 0; i < row.countValues(); i++) {
65 column = row.getColumnAt(i);
66 if ((column.getType() == AttributeType.STRING || column.getType() == AttributeType.DYNAMIC_STRING) && (value = row.getValue(i)) != null) {
67 str = value.toString();
68 if (!str.matches("(https?|ftp):(//?|\\\\?)?.*")) {
69 //Does not look like an URL, try http:
70 str = "http://" + str;
71 }
72 if (lc != null && lc.column.equals(column.getTitle())) {
73 columnUrls.add(initialSelection=new ColumnURL(column.getTitle(), str));
74 }else{
75 columnUrls.add(new ColumnURL(column.getTitle(), str));
76 }
77 }
78 }
79
80 ColumnURL selection = (ColumnURL) JOptionPane.showInputDialog(null, NbBundle.getMessage(OpenURLSubItem.class, "GraphContextMenu_OpenURLSubItem.message"), getName(), JOptionPane.QUESTION_MESSAGE, null, columnUrls.toArray(), initialSelection);
81 if (selection != null) {
82 columnTitle = selection.column;
83 url = selection.url;
84 showUrl();
85 }
86 }
87 }
88
89 private void showUrl() {
90 try {
91 URLDisplayer.getDefault().showURLExternal(new URL(url));
92 } catch (Exception ex) {
93 }
94 LastColumnOpenedURL lc = Lookup.getDefault().lookup(ProjectController.class).getCurrentWorkspace().getLookup().lookup(LastColumnOpenedURL.class);
95 if (lc == null) {
96 Lookup.getDefault().lookup(ProjectController.class).getCurrentWorkspace().add(new LastColumnOpenedURL(columnTitle));
97 } else {
98 lc.column = columnTitle;
99 }
100 }
101
102 public GraphContextMenuItem[] getSubItems() {
103 return null;
104 }
105
106 public String getName() {
107 return NbBundle.getMessage(OpenURLSubItem.class, "GraphContextMenu_OpenURLSubItem");
108 }
109
110 public String getDescription() {
111 return null;
112 }
113
114 public boolean isAvailable() {
115 return true;
116 }
117
118 public boolean canExecute() {
119 return true;
120 }
121
122 public int getType() {
123 return 100;
124 }
125
126 public int getPosition() {
127 return 0;
128 }
129
130 public Icon getIcon() {
131 return null;
132 }
133
134 public Integer getMnemonicKey() {
135 return KeyEvent.VK_N;
136 }
137
138 class ColumnURL {
139
140 String column, url;
141
142 public ColumnURL(String column, String url) {
143 this.column = column;
144 this.url = url;
145 }
146
147 @Override
148 public String toString() {
149 return String.format("%s - %s", column, url);
150 }
151 }
152}
0153
=== added file 'VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/SelectInDataLaboratory.java'
--- VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/SelectInDataLaboratory.java 1970-01-01 00:00:00 +0000
+++ VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/SelectInDataLaboratory.java 2011-02-01 14:23:14 +0000
@@ -0,0 +1,86 @@
1/*
2Copyright 2008-2010 Gephi
3Authors : Mathieu Bastian <mathieu.bastian@gephi.org>, Eduardo Ramos <eduramiba@gmail.com>
4Website : http://www.gephi.org
5
6This file is part of Gephi.
7
8Gephi is free software: you can redistribute it and/or modify
9it under the terms of the GNU Affero General Public License as
10published by the Free Software Foundation, either version 3 of the
11License, or (at your option) any later version.
12
13Gephi is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU Affero General Public License for more details.
17
18You should have received a copy of the GNU Affero General Public License
19along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.visualization.apiimpl.contextmenuitems;
22
23import java.awt.event.KeyEvent;
24import javax.swing.Icon;
25import org.gephi.datalab.api.DataTablesController;
26import org.gephi.graph.api.HierarchicalGraph;
27import org.gephi.graph.api.Node;
28import org.gephi.visualization.spi.GraphContextMenuItem;
29import org.openide.util.ImageUtilities;
30import org.openide.util.Lookup;
31import org.openide.util.NbBundle;
32import org.openide.util.lookup.ServiceProvider;
33
34/**
35 *
36 */
37@ServiceProvider(service = GraphContextMenuItem.class)
38public class SelectInDataLaboratory implements GraphContextMenuItem {
39 private Node[] nodes;
40 private DataTablesController dtc;
41 public void setup(HierarchicalGraph graph, Node[] nodes) {
42 this.nodes = nodes;
43 dtc=Lookup.getDefault().lookup(DataTablesController.class);
44 }
45
46 public void execute() {
47 dtc.setNodeTableSelection(nodes);
48 dtc.selectNodesTable();
49 }
50
51 public GraphContextMenuItem[] getSubItems() {
52 return null;
53 }
54
55 public String getName() {
56 return NbBundle.getMessage(SelectInDataLaboratory.class, "GraphContextMenu_SelectInDataLaboratory");
57 }
58
59 public String getDescription() {
60 return null;
61 }
62
63 public boolean isAvailable() {
64 return dtc.isDataTablesReady();
65 }
66
67 public boolean canExecute() {
68 return nodes.length>=1;
69 }
70
71 public int getType() {
72 return 400;
73 }
74
75 public int getPosition() {
76 return 100;
77 }
78
79 public Icon getIcon() {
80 return ImageUtilities.loadImageIcon("org/gephi/visualization/api/resources/table-select.png", false);
81 }
82
83 public Integer getMnemonicKey() {
84 return KeyEvent.VK_L;
85 }
86}
087
=== added file 'VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Settle.java'
--- VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Settle.java 1970-01-01 00:00:00 +0000
+++ VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Settle.java 2011-02-01 14:23:14 +0000
@@ -0,0 +1,91 @@
1/*
2Copyright 2008-2010 Gephi
3Authors : Mathieu Bastian <mathieu.bastian@gephi.org>, Eduardo Ramos <eduramiba@gmail.com>
4Website : http://www.gephi.org
5
6This file is part of Gephi.
7
8Gephi is free software: you can redistribute it and/or modify
9it under the terms of the GNU Affero General Public License as
10published by the Free Software Foundation, either version 3 of the
11License, or (at your option) any later version.
12
13Gephi is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU Affero General Public License for more details.
17
18You should have received a copy of the GNU Affero General Public License
19along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.visualization.apiimpl.contextmenuitems;
22
23import java.awt.event.KeyEvent;
24import javax.swing.Icon;
25import org.gephi.datalab.api.GraphElementsController;
26import org.gephi.graph.api.HierarchicalGraph;
27import org.gephi.graph.api.Node;
28import org.gephi.visualization.spi.GraphContextMenuItem;
29import org.openide.util.ImageUtilities;
30import org.openide.util.Lookup;
31import org.openide.util.NbBundle;
32import org.openide.util.lookup.ServiceProvider;
33
34/**
35 *
36 */
37@ServiceProvider(service = GraphContextMenuItem.class)
38public class Settle implements GraphContextMenuItem {
39
40 private Node[] nodes;
41
42 public void setup(HierarchicalGraph graph, Node[] nodes) {
43 this.nodes = nodes;
44 }
45
46 public void execute() {
47 GraphElementsController gec = Lookup.getDefault().lookup(GraphElementsController.class);
48 gec.setNodesFixed(nodes, true);
49 }
50
51 public GraphContextMenuItem[] getSubItems() {
52 return null;
53 }
54
55 public String getName() {
56 return NbBundle.getMessage(Settle.class, "GraphContextMenu_Settle");
57 }
58
59 public String getDescription() {
60 return null;
61 }
62
63 public boolean isAvailable() {
64 return true;
65 }
66
67 public boolean canExecute() {
68 for (Node n : nodes) {
69 if (!Lookup.getDefault().lookup(GraphElementsController.class).isNodeFixed(n)) {
70 return true;
71 }
72 }
73 return false;
74 }
75
76 public int getType() {
77 return 300;
78 }
79
80 public int getPosition() {
81 return 0;
82 }
83
84 public Icon getIcon() {
85 return ImageUtilities.loadImageIcon("org/gephi/visualization/api/resources/settle.png", false);
86 }
87
88 public Integer getMnemonicKey() {
89 return KeyEvent.VK_B;
90 }
91}
092
=== added file 'VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/TagNodes.java'
--- VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/TagNodes.java 1970-01-01 00:00:00 +0000
+++ VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/TagNodes.java 2011-02-01 14:23:14 +0000
@@ -0,0 +1,86 @@
1/*
2Copyright 2008-2010 Gephi
3Authors : Mathieu Bastian <mathieu.bastian@gephi.org>, Eduardo Ramos <eduramiba@gmail.com>
4Website : http://www.gephi.org
5
6This file is part of Gephi.
7
8Gephi is free software: you can redistribute it and/or modify
9it under the terms of the GNU Affero General Public License as
10published by the Free Software Foundation, either version 3 of the
11License, or (at your option) any later version.
12
13Gephi is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU Affero General Public License for more details.
17
18You should have received a copy of the GNU Affero General Public License
19along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.visualization.apiimpl.contextmenuitems;
22
23import java.awt.event.KeyEvent;
24import javax.swing.Icon;
25import org.gephi.datalab.api.DataLaboratoryHelper;
26import org.gephi.datalab.spi.nodes.NodesManipulator;
27import org.gephi.graph.api.HierarchicalGraph;
28import org.gephi.graph.api.Node;
29import org.gephi.visualization.spi.GraphContextMenuItem;
30import org.openide.util.lookup.ServiceProvider;
31
32/**
33 * Tag Nodes context menu action, uses existing same Data Laboratory manipulator when available.
34 */
35@ServiceProvider(service = GraphContextMenuItem.class)
36public class TagNodes implements GraphContextMenuItem {
37 private NodesManipulator tagNodes;
38
39 public TagNodes() {
40 tagNodes = DataLaboratoryHelper.getDefault().getNodesManipulatorByName("TagNodes");
41 }
42
43 public void setup(HierarchicalGraph graph, Node[] nodes) {
44 tagNodes.setup(nodes, null);
45 }
46
47 public void execute() {
48 DataLaboratoryHelper.getDefault().executeManipulator(tagNodes);
49 }
50
51 public GraphContextMenuItem[] getSubItems() {
52 return null;
53 }
54
55 public String getName() {
56 return tagNodes != null ? tagNodes.getName() : null;
57 }
58
59 public String getDescription() {
60 return null;
61 }
62
63 public boolean isAvailable() {
64 return tagNodes != null;//Do not show tag nodes action if the TagNodes nodes manipulator does not exist
65 }
66
67 public boolean canExecute() {
68 return tagNodes != null ? tagNodes.canExecute() : false;
69 }
70
71 public int getType() {
72 return 400;
73 }
74
75 public int getPosition() {
76 return 0;
77 }
78
79 public Icon getIcon() {
80 return tagNodes != null ? tagNodes.getIcon() : null;
81 }
82
83 public Integer getMnemonicKey() {
84 return KeyEvent.VK_T;
85 }
86}
087
=== added file 'VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Ungroup.java'
--- VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Ungroup.java 1970-01-01 00:00:00 +0000
+++ VisualizationModule/src/org/gephi/visualization/apiimpl/contextmenuitems/Ungroup.java 2011-02-01 14:23:14 +0000
@@ -0,0 +1,91 @@
1/*
2Copyright 2008-2010 Gephi
3Authors : Mathieu Bastian <mathieu.bastian@gephi.org>, Eduardo Ramos <eduramiba@gmail.com>
4Website : http://www.gephi.org
5
6This file is part of Gephi.
7
8Gephi is free software: you can redistribute it and/or modify
9it under the terms of the GNU Affero General Public License as
10published by the Free Software Foundation, either version 3 of the
11License, or (at your option) any later version.
12
13Gephi is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU Affero General Public License for more details.
17
18You should have received a copy of the GNU Affero General Public License
19along with Gephi. If not, see <http://www.gnu.org/licenses/>.
20 */
21package org.gephi.visualization.apiimpl.contextmenuitems;
22
23import java.awt.event.KeyEvent;
24import javax.swing.Icon;
25import org.gephi.datalab.api.GraphElementsController;
26import org.gephi.graph.api.HierarchicalGraph;
27import org.gephi.graph.api.Node;
28import org.gephi.visualization.spi.GraphContextMenuItem;
29import org.openide.util.ImageUtilities;
30import org.openide.util.Lookup;
31import org.openide.util.NbBundle;
32import org.openide.util.lookup.ServiceProvider;
33
34/**
35 *
36 */
37@ServiceProvider(service = GraphContextMenuItem.class)
38public class Ungroup implements GraphContextMenuItem {
39
40 private Node[] nodes;
41
42 public void setup(HierarchicalGraph graph, Node[] nodes) {
43 this.nodes = nodes;
44 }
45
46 public void execute() {
47 GraphElementsController gec = Lookup.getDefault().lookup(GraphElementsController.class);
48 gec.ungroupNodes(nodes);
49 }
50
51 public GraphContextMenuItem[] getSubItems() {
52 return null;
53 }
54
55 public String getName() {
56 return NbBundle.getMessage(Ungroup.class, "GraphContextMenu_Ungroup");
57 }
58
59 public String getDescription() {
60 return null;
61 }
62
63 public boolean isAvailable() {
64 return true;
65 }
66
67 public boolean canExecute() {
68 for (Node n : nodes) {
69 if (Lookup.getDefault().lookup(GraphElementsController.class).canUngroupNode(n)) {
70 return true;
71 }
72 }
73 return false;
74 }
75
76 public int getType() {
77 return 0;
78 }
79
80 public int getPosition() {
81 return 100;
82 }
83
84 public Icon getIcon() {
85 return ImageUtilities.loadImageIcon("org/gephi/visualization/api/resources/ungroup.png", false);
86 }
87
88 public Integer getMnemonicKey() {
89 return KeyEvent.VK_U;
90 }
91}
092
=== removed file 'VisualizationModule/src/org/gephi/visualization/apiimpl/es.po'
--- VisualizationModule/src/org/gephi/visualization/apiimpl/es.po 2010-12-27 04:43:17 +0000
+++ VisualizationModule/src/org/gephi/visualization/apiimpl/es.po 1970-01-01 00:00:00 +0000
@@ -1,57 +0,0 @@
1# Spanish translation for gephi
2# Copyright (c) 2010 Rosetta Contributors and Canonical Ltd 2010
3# This file is distributed under the same license as the gephi package.
4# FIRST AUTHOR <EMAIL@ADDRESS>, 2010.
5#
6msgid ""
7msgstr ""
8"Project-Id-Version: gephi\n"
9"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
10"POT-Creation-Date: 2010-04-07 13:16+0200\n"
11"PO-Revision-Date: 2010-12-26 00:11+0000\n"
12"Last-Translator: Eduardo Ramos <Unknown>\n"
13"Language-Team: Spanish <es@li.org>\n"
14"MIME-Version: 1.0\n"
15"Content-Type: text/plain; charset=UTF-8\n"
16"Content-Transfer-Encoding: 8bit\n"
17"X-Launchpad-Export-Date: 2010-12-27 04:43+0000\n"
18"X-Generator: Launchpad (build Unknown)\n"
19
20msgid "GraphContextMenu_Group"
21msgstr "Agrupar"
22
23msgid "GraphContextMenu_Ungroup"
24msgstr "Desagrupar"
25
26msgid "GraphContextMenu_Expand"
27msgstr "Expandir"
28
29msgid "GraphContextMenu_Contract"
30msgstr "Contraer"
31
32msgid "GraphContextMenu_Settle"
33msgstr "Bloquear"
34
35msgid "GraphContextMenu_Free"
36msgstr "Desbloquear"
37
38msgid "GraphContextMenu_Delete"
39msgstr "Eliminar"
40
41msgid "GraphContextMenu_MoveToWorkspace"
42msgstr "Mover a..."
43
44msgid "GraphContextMenu_MoveToWorkspace_NewWorkspace"
45msgstr "Nuevo espacio de trabajo"
46
47msgid "GraphContextMenu_CopyToWorkspace"
48msgstr "Copiar a..."
49
50msgid "GraphContextMenu_CopyToWorkspace_NewWorkspace"
51msgstr "Nuevo espacio de trabajo"
52
53msgid "GraphContextMenu.Delete.message"
54msgstr "Los nodos serán eliminados, ¿Continuar?"
55
56msgid "GraphContextMenu.Delete.message.title"
57msgstr "Eliminar nodos"
580
=== removed file 'VisualizationModule/src/org/gephi/visualization/apiimpl/fr.po'
--- VisualizationModule/src/org/gephi/visualization/apiimpl/fr.po 2010-12-26 04:54:12 +0000
+++ VisualizationModule/src/org/gephi/visualization/apiimpl/fr.po 1970-01-01 00:00:00 +0000
@@ -1,57 +0,0 @@
1# French translation for gephi
2# Copyright (c) 2010 Rosetta Contributors and Canonical Ltd 2010
3# This file is distributed under the same license as the gephi package.
4# FIRST AUTHOR <EMAIL@ADDRESS>, 2010.
5#
6msgid ""
7msgstr ""
8"Project-Id-Version: gephi\n"
9"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
10"POT-Creation-Date: 2010-04-07 13:16+0200\n"
11"PO-Revision-Date: 2010-12-25 19:49+0000\n"
12"Last-Translator: Sébastien Heymann <Unknown>\n"
13"Language-Team: French <fr@li.org>\n"
14"MIME-Version: 1.0\n"
15"Content-Type: text/plain; charset=UTF-8\n"
16"Content-Transfer-Encoding: 8bit\n"
17"X-Launchpad-Export-Date: 2010-12-26 04:53+0000\n"
18"X-Generator: Launchpad (build Unknown)\n"
19
20msgid "GraphContextMenu_Group"
21msgstr "Grouper"
22
23msgid "GraphContextMenu_Ungroup"
24msgstr "Dégrouper"
25
26msgid "GraphContextMenu_Expand"
27msgstr "Étendre"
28
29msgid "GraphContextMenu_Contract"
30msgstr "Contracter"
31
32msgid "GraphContextMenu_Settle"
33msgstr "Fixer"
34
35msgid "GraphContextMenu_Free"
36msgstr "Libérer"
37
38msgid "GraphContextMenu_Delete"
39msgstr "Supprimer"
40
41msgid "GraphContextMenu_MoveToWorkspace"
42msgstr "Déplacer vers..."
43
44msgid "GraphContextMenu_MoveToWorkspace_NewWorkspace"
45msgstr "Nouvel espace de travail"
46
47msgid "GraphContextMenu_CopyToWorkspace"
48msgstr "Copier vers..."
49
50msgid "GraphContextMenu_CopyToWorkspace_NewWorkspace"
51msgstr "Nouvel espace de travail"
52
53msgid "GraphContextMenu.Delete.message"
54msgstr "Les noeuds seront supprimés. Voulez-vous continuer ?"
55
56msgid "GraphContextMenu.Delete.message.title"
57msgstr "Suppression des noeuds"
580
=== removed file 'VisualizationModule/src/org/gephi/visualization/apiimpl/org-gephi-visualization-api.pot'
--- VisualizationModule/src/org/gephi/visualization/apiimpl/org-gephi-visualization-api.pot 2010-04-29 20:47:13 +0000
+++ VisualizationModule/src/org/gephi/visualization/apiimpl/org-gephi-visualization-api.pot 1970-01-01 00:00:00 +0000
@@ -1,37 +0,0 @@
1# English (en) translation for Gephi.
2# Copyright (C) 2010 Gephi contributors.
3# This file is distributed under the same license as the Gephi package.
4# Gephi Team <gephi.team@lists.launchpad.net>, 2010.
5#
6msgid ""
7msgstr ""
8"Project-Id-Version: Gephi 0.7\n"
9"Report-Msgid-Bugs-To: gephi.team@lists.launchpad.net\n"
10"POT-Creation-Date: 2010-04-07 13:16+0200\n"
11"PO-Revision-Date: 2010-04-07 13:16+0200\n"
12"Last-Translator: Mathieu Bastian <gephi.team@lists.launchpad.net>\n"
13"Language-Team: English <https://launchpad.net/~gephi.team>\n"
14"MIME-Version: 1.0\n"
15"Content-Type: text/plain; charset=UTF-8\n"
16"Content-Transfer-Encoding: 8bit\n"
17
18msgid "GraphContextMenu_Group"
19msgstr "Group"
20
21msgid "GraphContextMenu_Ungroup"
22msgstr "Ungroup"
23
24msgid "GraphContextMenu_Expand"
25msgstr "Expand"
26
27msgid "GraphContextMenu_Contract"
28msgstr "Contract"
29
30msgid "GraphContextMenu_Settle"
31msgstr "Settle"
32
33msgid "GraphContextMenu_Free"
34msgstr "Free"
35
36msgid "GraphContextMenu_Delete"
37msgstr "Delete"
380
=== removed file 'VisualizationModule/src/org/gephi/visualization/apiimpl/org-gephi-visualization-apiimpl.pot'
--- VisualizationModule/src/org/gephi/visualization/apiimpl/org-gephi-visualization-apiimpl.pot 2010-09-17 09:19:14 +0000
+++ VisualizationModule/src/org/gephi/visualization/apiimpl/org-gephi-visualization-apiimpl.pot 1970-01-01 00:00:00 +0000
@@ -1,55 +0,0 @@
1# English (en) translation for Gephi.
2# Copyright (C) 2010 Gephi contributors.
3# This file is distributed under the same license as the Gephi package.
4# Gephi Team <gephi.team@lists.launchpad.net>, 2010.
5#
6msgid ""
7msgstr ""
8"Project-Id-Version: Gephi 0.7\n"
9"Report-Msgid-Bugs-To: gephi.team@lists.launchpad.net\n"
10"POT-Creation-Date: 2010-04-07 13:16+0200\n"
11"PO-Revision-Date: 2010-04-07 13:16+0200\n"
12"Last-Translator: Mathieu Bastian <gephi.team@lists.launchpad.net>\n"
13"Language-Team: English <https://launchpad.net/~gephi.team>\n"
14"MIME-Version: 1.0\n"
15"Content-Type: text/plain; charset=UTF-8\n"
16"Content-Transfer-Encoding: 8bit\n"
17
18msgid "GraphContextMenu_Group"
19msgstr "Group"
20
21msgid "GraphContextMenu_Ungroup"
22msgstr "Ungroup"
23
24msgid "GraphContextMenu_Expand"
25msgstr "Expand"
26
27msgid "GraphContextMenu_Contract"
28msgstr "Contract"
29
30msgid "GraphContextMenu_Settle"
31msgstr "Settle"
32
33msgid "GraphContextMenu_Free"
34msgstr "Free"
35
36msgid "GraphContextMenu_Delete"
37msgstr "Delete"
38
39msgid "GraphContextMenu_MoveToWorkspace"
40msgstr "Move to..."
41
42msgid "GraphContextMenu_MoveToWorkspace_NewWorkspace"
43msgstr "New workspace"
44
45msgid "GraphContextMenu_CopyToWorkspace"
46msgstr "Copy to..."
47
48msgid "GraphContextMenu_CopyToWorkspace_NewWorkspace"
49msgstr "New workspace"
50
51msgid "GraphContextMenu.Delete.message"
52msgstr "Nodes will be deleted, do you want to proceed?"
53
54msgid "GraphContextMenu.Delete.message.title"
55msgstr "Delete nodes"
560
=== modified file 'VisualizationModule/src/org/gephi/visualization/bridge/DHNSEventBridge.java'
--- VisualizationModule/src/org/gephi/visualization/bridge/DHNSEventBridge.java 2010-09-30 08:11:38 +0000
+++ VisualizationModule/src/org/gephi/visualization/bridge/DHNSEventBridge.java 2011-02-01 14:23:14 +0000
@@ -21,33 +21,21 @@
21package org.gephi.visualization.bridge;21package org.gephi.visualization.bridge;
2222
23import java.util.ArrayList;23import java.util.ArrayList;
24import java.util.Arrays;
25import java.util.HashSet;
26import java.util.List;24import java.util.List;
27import java.util.Set;25import org.gephi.datalab.api.DataLaboratoryHelper;
28import org.gephi.data.attributes.api.AttributeController;26import org.gephi.datalab.spi.nodes.NodesManipulator;
29import org.gephi.data.attributes.api.AttributeModel;
30import org.gephi.desktop.project.api.ProjectControllerUI;
31import org.gephi.graph.api.Graph;
32import org.gephi.graph.api.GraphController;27import org.gephi.graph.api.GraphController;
33import org.gephi.graph.api.GraphModel;28import org.gephi.graph.api.GraphModel;
34import org.gephi.graph.api.GroupData;
35import org.gephi.graph.api.HierarchicalGraph;29import org.gephi.graph.api.HierarchicalGraph;
36import org.gephi.graph.api.Model;30import org.gephi.graph.api.Model;
37import org.gephi.graph.api.Node;31import org.gephi.graph.api.Node;
38import org.gephi.graph.api.NodeData;32import org.gephi.graph.api.NodeData;
39import org.gephi.project.api.ProjectController;
40import org.gephi.project.api.Workspace;
41import org.gephi.visualization.VizArchitecture;33import org.gephi.visualization.VizArchitecture;
42import org.gephi.visualization.VizController;34import org.gephi.visualization.VizController;
43import org.gephi.visualization.apiimpl.GraphIO;35import org.gephi.visualization.apiimpl.GraphIO;
44import org.gephi.visualization.apiimpl.ModelImpl;36import org.gephi.visualization.apiimpl.ModelImpl;
45import org.gephi.visualization.api.objects.ModelClass;37import org.gephi.visualization.api.objects.ModelClass;
46import org.gephi.visualization.hull.ConvexHull;
47import org.gephi.visualization.opengl.AbstractEngine;38import org.gephi.visualization.opengl.AbstractEngine;
48import org.gephi.visualization.opengl.compatibility.objects.ConvexHullModel;
49import org.openide.DialogDisplayer;
50import org.openide.NotifyDescriptor;
51import org.openide.util.Lookup;39import org.openide.util.Lookup;
5240
53/**41/**
@@ -74,380 +62,70 @@
74 public void initEvents() {62 public void initEvents() {
75 }63 }
7664
77 //GROUPING65 public HierarchicalGraph getGraph(){
78 public boolean canExpand() {66 return graph;
79 GraphModel graphModel = graphController.getModel();67 }
80 if (graphModel == null) {68
81 return false;69 public Node[] getSelectedNodes(){
82 }70 GraphModel graphModel = graphController.getModel();
83 this.graph = graphController.getModel().getHierarchicalGraphVisible();71 if (graphModel == null) {
84 ModelImpl[] selectedNodeModels = engine.getSelectedObjects(AbstractEngine.CLASS_NODE);72 return new Node[0];
85 for (ModelImpl metaModelImpl : selectedNodeModels) {73 }
86 NodeData nodeData = (NodeData) metaModelImpl.getObj();74 this.graph = graphModel.getHierarchicalGraphVisible();
87 Node node = nodeData.getNode(graph.getView().getViewId());75 ModelImpl[] selectedNodeModels = engine.getSelectedObjects(AbstractEngine.CLASS_NODE);
88 if (node != null && graph.getDescendantCount(node) > 0) {76 ArrayList<Node> nodes=new ArrayList<Node>();
89 return true;
90 }
91 }
92 return false;
93 }
94
95 public boolean canContract() {
96 GraphModel graphModel = graphController.getModel();
97 if (graphModel == null) {
98 return false;
99 }
100 this.graph = graphController.getModel().getHierarchicalGraphVisible();
101 ModelImpl[] selectedNodeModels = engine.getSelectedObjects(AbstractEngine.CLASS_NODE);
102 for (ModelImpl metaModelImpl : selectedNodeModels) {
103 NodeData nodeData = (NodeData) metaModelImpl.getObj();
104 Node node = nodeData.getNode(graph.getView().getViewId());
105 if (node != null && graph.getParent(node) != null) {
106 return true;
107 }
108 }
109 return false;
110 }
111
112 public boolean canGroup() {
113 GraphModel graphModel = graphController.getModel();
114 if (graphModel == null) {
115 return false;
116 }
117 this.graph = graphController.getModel().getHierarchicalGraphVisible();
118 ModelImpl[] selectedNodeModels = engine.getSelectedObjects(AbstractEngine.CLASS_NODE);
119 int nodesReallyPresent = 0;
120 for (ModelImpl metaModelImpl : selectedNodeModels) {77 for (ModelImpl metaModelImpl : selectedNodeModels) {
121 NodeData nodeData = (NodeData) metaModelImpl.getObj();78 NodeData nodeData = (NodeData) metaModelImpl.getObj();
122 Node node = nodeData.getNode(graph.getView().getViewId());79 Node node = nodeData.getNode(graph.getView().getViewId());
123 if (node != null) {80 if (node != null) {
124 nodesReallyPresent++;81 nodes.add(node);
125 }82 }
126 }83 }
127 return nodesReallyPresent >= 1;84 return nodes.toArray(new Node[0]);
128 }85 }
12986
130 public boolean canUngroup() {87 //MASS TAGGING OF NODES
131 GraphModel graphModel = graphController.getModel();88 public boolean isTagNodesAvailable() {
132 if (graphModel == null) {89 return DataLaboratoryHelper.getDefault().getNodesManipulatorByName("TagNodes")!=null;//Do not show tag nodes action if the TagNodes nodes manipulator does not exist
133 return false;90 }
134 }91
135 ModelImpl[] selectedNodeModels = engine.getSelectedObjects(AbstractEngine.CLASS_NODE);92 public boolean canTagNodes() {
136 return selectedNodeModels.length >= 1;93 this.graph = graphController.getModel().getHierarchicalGraphVisible();
137 }94 ModelImpl[] selectedNodeModels = engine.getSelectedObjects(AbstractEngine.CLASS_NODE);
138
139 public void expand() {
140 this.graph = graphController.getModel().getHierarchicalGraphVisible();
141 ModelImpl[] selectedNodeModels = engine.getSelectedObjects(AbstractEngine.CLASS_NODE);
142 final ModelImpl[] models = Arrays.copyOf(selectedNodeModels, selectedNodeModels.length);
143 new Thread(new Runnable() {
144
145 public void run() {
146 try {
147 for (ModelImpl metaModelImpl : models) {
148 Node node = ((NodeData) metaModelImpl.getObj()).getNode(graph.getView().getViewId());
149 if (node != null && graph.getDescendantCount(node) > 0) {
150 expandPositioning(node);
151 graph.expand(node);
152 }
153 }
154 } catch (Exception e) {
155 e.printStackTrace();
156 graph.readUnlockAll();
157 }
158 }
159 }, "Expand nodes").start();
160 }
161
162 public void contract() {
163 this.graph = graphController.getModel().getHierarchicalGraphVisible();
164 ModelImpl[] selectedNodeModels = engine.getSelectedObjects(AbstractEngine.CLASS_NODE);
165 final ModelImpl[] models = Arrays.copyOf(selectedNodeModels, selectedNodeModels.length);
166 new Thread(new Runnable() {
167
168 public void run() {
169 try {
170 Set<Node> parents = new HashSet<Node>();
171 for (ModelImpl metaModelImpl : models) {
172 NodeData nodeData = (NodeData) metaModelImpl.getObj();
173 Node node = nodeData.getNode(graph.getView().getViewId());
174 if (node != null) {
175 Node nodeParent = graph.getParent(node);
176 if (nodeParent != null) {
177 parents.add(nodeParent);
178 }
179 }
180 }
181
182 for (Node parent : parents) {
183 GroupData gd = (GroupData) parent.getNodeData();
184 if (gd.getHullModel() != null) {
185 ConvexHull hull = ((ConvexHullModel) gd.getHullModel()).getObj();
186 contractPositioning(hull);
187 }
188 graph.retract(parent);
189 }
190 } catch (Exception e) {
191 e.printStackTrace();
192 graph.readUnlockAll();
193 }
194 }
195 }, "Contract nodes").start();
196 }
197
198 public void group() {
199 this.graph = graphController.getModel().getHierarchicalGraphVisible();
200 ModelImpl[] selectedNodeModels = engine.getSelectedObjects(AbstractEngine.CLASS_NODE);
201 final List<Node> newGroup = new ArrayList<Node>();
202 for (int i = 0; i < selectedNodeModels.length; i++) {95 for (int i = 0; i < selectedNodeModels.length; i++) {
203 Node node = ((NodeData) selectedNodeModels[i].getObj()).getNode(graph.getView().getViewId());96 Node node = ((NodeData) selectedNodeModels[i].getObj()).getNode(graph.getView().getViewId());
204 if (node != null) {97 if (node != null) {
205 newGroup.add(node);
206 }
207 }
208 new Thread(new Runnable() {
209
210 public void run() {
211 try {
212 float centroidX = 0;
213 float centroidY = 0;
214 int len = 0;
215 float sizes = 0;
216 float r = 0;
217 float g = 0;
218 float b = 0;
219 Node group = graph.groupNodes(newGroup.toArray(new Node[0]));
220 group.getNodeData().setLabel("Group (" + newGroup.size() + " nodes)");
221 group.getNodeData().setSize(10f);
222 for (Node child : newGroup) {
223 centroidX += child.getNodeData().x();
224 centroidY += child.getNodeData().y();
225 len++;
226 sizes += child.getNodeData().getSize() / 10f;
227 r += child.getNodeData().r();
228 g += child.getNodeData().g();
229 b += child.getNodeData().b();
230 }
231 centroidX /= len;
232 centroidY /= len;
233 group.getNodeData().setSize(sizes);
234 group.getNodeData().setColor(r / len, g / len, b / len);
235 group.getNodeData().setX(centroidX);
236 group.getNodeData().setY(centroidY);
237 } catch (Exception e) {
238 graph.readUnlockAll();
239 NotifyDescriptor.Message nd = new NotifyDescriptor.Message(e.getMessage());
240 DialogDisplayer.getDefault().notifyLater(nd);
241 }
242 }
243 }, "Group nodes").start();
244 }
245
246 public void ungroup() {
247 this.graph = graphController.getModel().getHierarchicalGraph();
248 ModelImpl[] selectedNodeModels = engine.getSelectedObjects(AbstractEngine.CLASS_NODE);
249 final ModelImpl[] models = Arrays.copyOf(selectedNodeModels, selectedNodeModels.length);
250 new Thread(new Runnable() {
251
252 public void run() {
253 try {
254 Set<Node> parents = new HashSet<Node>();
255 for (ModelImpl metaModelImpl : models) {
256 NodeData nodeData = (NodeData) metaModelImpl.getObj();
257 Node node = nodeData.getNode(graph.getView().getViewId());
258 if (node != null && graph.getDescendantCount(node) > 0) {
259 parents.add(node);
260 } else if (node != null && graph.getParent(node) != null) {
261 parents.add(graph.getParent(node));
262 }
263 }
264 for (Node parent : parents) {
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes: