2
Copyright 2008-2010 Gephi
3
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
4
Website : http://www.gephi.org
6
This file is part of Gephi.
8
Gephi is free software: you can redistribute it and/or modify
9
it under the terms of the GNU Affero General Public License as
10
published by the Free Software Foundation, either version 3 of the
11
License, or (at your option) any later version.
13
Gephi is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU Affero General Public License for more details.
18
You should have received a copy of the GNU Affero General Public License
19
along with Gephi. If not, see <http://www.gnu.org/licenses/>.
21
package org.gephi.ui.exporter.plugin;
23
import javax.swing.JPanel;
24
import org.gephi.io.exporter.plugin.ExporterCSV;
25
import org.gephi.io.exporter.spi.Exporter;
26
import org.gephi.io.exporter.spi.ExporterUI;
27
import org.openide.util.NbBundle;
28
import org.openide.util.lookup.ServiceProvider;
32
* @author Mathieu Bastian
34
@ServiceProvider(service = ExporterUI.class)
35
public class UIExporterCSV implements ExporterUI {
37
private UIExporterCSVPanel panel;
38
private ExporterCSV exporterCSV;
39
private ExporterCSVSettings settings = new ExporterCSVSettings();
41
public void setup(Exporter exporter) {
42
exporterCSV = (ExporterCSV) exporter;
43
settings.load(exporterCSV);
44
panel.setup(exporterCSV);
47
public void unsetup(boolean update) {
49
panel.unsetup(exporterCSV);
50
settings.save(exporterCSV);
56
public JPanel getPanel() {
57
panel = new UIExporterCSVPanel();
61
public boolean isUIForExporter(Exporter exporter) {
62
return exporter instanceof ExporterCSV;
65
public String getDisplayName() {
66
return NbBundle.getMessage(UIExporterCSV.class, "UIExporterCSV.name");
69
private static class ExporterCSVSettings {
71
private boolean edgeWeight = true;
72
private boolean writeZero = true;
73
private boolean header = true;
74
private boolean list = false;
76
private void save(ExporterCSV exporterCSV) {
77
this.edgeWeight = exporterCSV.isEdgeWeight();
78
this.writeZero = exporterCSV.isWriteZero();
79
this.header = exporterCSV.isHeader();
80
this.list = exporterCSV.isList();
83
private void load(ExporterCSV exporterCSV) {
84
exporterCSV.setEdgeWeight(edgeWeight);
85
exporterCSV.setWriteZero(writeZero);
86
exporterCSV.setHeader(header);
87
exporterCSV.setList(list);