proj_name
stringclasses 131
values | relative_path
stringlengths 30
228
| class_name
stringlengths 1
68
| func_name
stringlengths 1
48
| masked_class
stringlengths 78
9.82k
| func_body
stringlengths 46
9.61k
| len_input
int64 29
2.01k
| len_output
int64 14
1.94k
| total
int64 55
2.05k
| relevant_context
stringlengths 0
38.4k
|
|---|---|---|---|---|---|---|---|---|---|
gephi_gephi
|
gephi/modules/DesktopDataLaboratory/src/main/java/org/gephi/desktop/datalab/tables/popup/EdgesPopupAdapter.java
|
EdgesPopupAdapter
|
createPopup
|
class EdgesPopupAdapter extends AbstractPopupAdapter<Edge> {
public EdgesPopupAdapter(AbstractElementsDataTable<Edge> elementsDataTable) {
super(elementsDataTable);
}
@Override
protected JPopupMenu createPopup(Point p) {<FILL_FUNCTION_BODY>}
}
|
final List<Edge> selectedElements = elementsDataTable.getElementsFromSelectedRows();
final Edge clickedElement = elementsDataTable.getElementFromRow(table.rowAtPoint(p));
JPopupMenu contextMenu = new JPopupMenu();
//First add edges manipulators items:
DataLaboratoryHelper dlh = DataLaboratoryHelper.getDefault();
Integer lastManipulatorType = null;
for (EdgesManipulator em : dlh.getEdgesManipulators()) {
em.setup(selectedElements.toArray(new Edge[0]), clickedElement);
if (lastManipulatorType == null) {
lastManipulatorType = em.getType();
}
if (lastManipulatorType != em.getType()) {
contextMenu.addSeparator();
}
lastManipulatorType = em.getType();
if (em.isAvailable()) {
contextMenu.add(PopupMenuUtils
.createMenuItemFromEdgesManipulator(em, clickedElement, selectedElements.toArray(new Edge[0])));
}
}
//Add AttributeValues manipulators submenu:
Column column = elementsDataTable.getColumnAtIndex(table.columnAtPoint(p));
if (column != null) {
contextMenu.add(PopupMenuUtils.createSubMenuFromRowColumn(clickedElement, column));
}
return contextMenu;
| 91
| 386
| 477
|
<methods>public void <init>(AbstractElementsDataTable<Edge>) <variables>protected final non-sealed AbstractElementsDataTable<Edge> elementsDataTable,protected final non-sealed JXTable table
|
gephi_gephi
|
gephi/modules/DesktopDataLaboratory/src/main/java/org/gephi/desktop/datalab/tables/popup/NodesPopupAdapter.java
|
NodesPopupAdapter
|
createPopup
|
class NodesPopupAdapter extends AbstractPopupAdapter<Node> {
public NodesPopupAdapter(AbstractElementsDataTable<Node> elementsDataTable) {
super(elementsDataTable);
}
@Override
protected JPopupMenu createPopup(Point p) {<FILL_FUNCTION_BODY>}
}
|
final List<Node> selectedElements = elementsDataTable.getElementsFromSelectedRows();
final Node clickedElement = elementsDataTable.getElementFromRow(table.rowAtPoint(p));
JPopupMenu contextMenu = new JPopupMenu();
//First add edges manipulators items:
DataLaboratoryHelper dlh = DataLaboratoryHelper.getDefault();
Integer lastManipulatorType = null;
for (NodesManipulator em : dlh.getNodesManipulators()) {
em.setup(selectedElements.toArray(new Node[0]), clickedElement);
if (lastManipulatorType == null) {
lastManipulatorType = em.getType();
}
if (lastManipulatorType != em.getType()) {
contextMenu.addSeparator();
}
lastManipulatorType = em.getType();
if (em.isAvailable()) {
contextMenu.add(PopupMenuUtils
.createMenuItemFromNodesManipulator(em, clickedElement, selectedElements.toArray(new Node[0])));
}
}
//Add AttributeValues manipulators submenu:
Column column = elementsDataTable.getColumnAtIndex(table.columnAtPoint(p));
if (column != null) {
contextMenu.add(PopupMenuUtils.createSubMenuFromRowColumn(clickedElement, column));
}
return contextMenu;
| 91
| 383
| 474
|
<methods>public void <init>(AbstractElementsDataTable<Node>) <variables>protected final non-sealed AbstractElementsDataTable<Node> elementsDataTable,protected final non-sealed JXTable table
|
gephi_gephi
|
gephi/modules/DesktopDataLaboratory/src/main/java/org/gephi/desktop/datalab/utils/GraphFileExporterBuilderDecorator.java
|
GraphFileExporterBuilderDecorator
|
buildExporter
|
class GraphFileExporterBuilderDecorator implements GraphFileExporterBuilder {
private final GraphFileExporterBuilder instance;
private final ExporterSpreadsheet.ExportTable initialSelectedTable;
public GraphFileExporterBuilderDecorator(GraphFileExporterBuilder instance,
ExporterSpreadsheet.ExportTable initialSelectedTable) {
this.instance = instance;
this.initialSelectedTable = initialSelectedTable;
}
@Override
public GraphExporter buildExporter() {<FILL_FUNCTION_BODY>}
@Override
public FileType[] getFileTypes() {
return instance.getFileTypes();
}
@Override
public String getName() {
return instance.getName();
}
}
|
GraphExporter exporter = instance.buildExporter();
if (exporter instanceof ExporterSpreadsheet) {
((ExporterSpreadsheet) exporter).setTableToExport(initialSelectedTable);
}
return exporter;
| 184
| 63
| 247
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopDataLaboratory/src/main/java/org/gephi/desktop/datalab/utils/PopupMenuUtils.java
|
PopupMenuUtils
|
createMenuItemFromEdgesManipulator
|
class PopupMenuUtils {
public static JMenuItem createMenuItemFromNodesManipulator(final NodesManipulator item, final Node clickedNode,
final Node[] nodes) {
ContextMenuItemManipulator[] subItems = item.getSubItems();
if (subItems != null && item.canExecute()) {
JMenu subMenu = new JMenu();
subMenu.setText(item.getName());
if (item.getDescription() != null && !item.getDescription().isEmpty()) {
subMenu.setToolTipText(item.getDescription());
}
subMenu.setIcon(item.getIcon());
Integer lastItemType = null;
for (ContextMenuItemManipulator subItem : subItems) {
((NodesManipulator) subItem).setup(nodes, clickedNode);
if (lastItemType == null) {
lastItemType = subItem.getType();
}
if (lastItemType != subItem.getType()) {
subMenu.addSeparator();
}
lastItemType = subItem.getType();
if (subItem.isAvailable()) {
subMenu.add(createMenuItemFromNodesManipulator((NodesManipulator) subItem, clickedNode, nodes));
}
}
if (item.getMnemonicKey() != null) {
subMenu.setMnemonic(item.getMnemonicKey());//Mnemonic for opening a sub menu
}
return subMenu;
} else {
JMenuItem menuItem = new JMenuItem();
menuItem.setText(item.getName());
if (item.getDescription() != null && !item.getDescription().isEmpty()) {
menuItem.setToolTipText(item.getDescription());
}
menuItem.setIcon(item.getIcon());
if (item.canExecute()) {
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new Thread() {
@Override
public void run() {
DataLaboratoryHelper.getDefault().executeManipulator(item);
}
}.start();
}
});
} else {
menuItem.setEnabled(false);
}
if (item.getMnemonicKey() != null) {
menuItem.setMnemonic(item.getMnemonicKey());//Mnemonic for executing the action
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!).
}
return menuItem;
}
}
public static JMenuItem createMenuItemFromEdgesManipulator(final EdgesManipulator item, final Edge clickedEdge,
final Edge[] edges) {<FILL_FUNCTION_BODY>}
public static JMenuItem createMenuItemFromManipulator(final Manipulator nm) {
JMenuItem menuItem = new JMenuItem();
menuItem.setText(nm.getName());
if (nm.getDescription() != null && !nm.getDescription().isEmpty()) {
menuItem.setToolTipText(nm.getDescription());
}
menuItem.setIcon(nm.getIcon());
if (nm.canExecute()) {
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
DataLaboratoryHelper dlh = DataLaboratoryHelper.getDefault();
dlh.executeManipulator(nm);
}
});
} else {
menuItem.setEnabled(false);
}
return menuItem;
}
public static JMenu createSubMenuFromRowColumn(Element row, Column column) {
DataLaboratoryHelper dlh = DataLaboratoryHelper.getDefault();
JMenu subMenu = new JMenu(NbBundle.getMessage(PopupMenuUtils.class, "Cell.Popup.subMenu.text"));
subMenu.setIcon(ImageUtilities.loadImageIcon("DesktopDataLaboratory/table-select.png", true));
Integer lastManipulatorType = null;
for (AttributeValueManipulator am : dlh.getAttributeValueManipulators()) {
am.setup(row, column);
if (lastManipulatorType == null) {
lastManipulatorType = am.getType();
}
if (lastManipulatorType != am.getType()) {
subMenu.addSeparator();
}
lastManipulatorType = am.getType();
subMenu.add(PopupMenuUtils.createMenuItemFromManipulator(am));
}
if (subMenu.getMenuComponentCount() == 0) {
subMenu.setEnabled(false);
}
return subMenu;
}
}
|
ContextMenuItemManipulator[] subItems = item.getSubItems();
if (subItems != null && item.canExecute()) {
JMenu subMenu = new JMenu();
subMenu.setText(item.getName());
if (item.getDescription() != null && !item.getDescription().isEmpty()) {
subMenu.setToolTipText(item.getDescription());
}
subMenu.setIcon(item.getIcon());
Integer lastItemType = null;
for (ContextMenuItemManipulator subItem : subItems) {
((EdgesManipulator) subItem).setup(edges, clickedEdge);
if (lastItemType == null) {
lastItemType = subItem.getType();
}
if (lastItemType != subItem.getType()) {
subMenu.addSeparator();
}
lastItemType = subItem.getType();
if (subItem.isAvailable()) {
subMenu.add(createMenuItemFromEdgesManipulator((EdgesManipulator) subItem, clickedEdge, edges));
}
}
if (item.getMnemonicKey() != null) {
subMenu.setMnemonic(item.getMnemonicKey());//Mnemonic for opening a sub menu
}
return subMenu;
} else {
JMenuItem menuItem = new JMenuItem();
menuItem.setText(item.getName());
if (item.getDescription() != null && !item.getDescription().isEmpty()) {
menuItem.setToolTipText(item.getDescription());
}
menuItem.setIcon(item.getIcon());
if (item.canExecute()) {
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new Thread() {
@Override
public void run() {
DataLaboratoryHelper.getDefault().executeManipulator(item);
}
}.start();
}
});
} else {
menuItem.setEnabled(false);
}
if (item.getMnemonicKey() != null) {
menuItem.setMnemonic(item.getMnemonicKey());//Mnemonic for executing the action
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!).
}
return menuItem;
}
| 1,239
| 649
| 1,888
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopDataLaboratory/src/main/java/org/gephi/desktop/datalab/utils/componentproviders/AbstractSparklinesGraphicsComponentProvider.java
|
AbstractSparklinesGraphicsComponentProvider
|
format
|
class AbstractSparklinesGraphicsComponentProvider extends ComponentProvider<JLabel> {
protected static final Color SELECTED_BACKGROUND = UIManager.getColor("Table.selectionBackground");
protected static final Color UNSELECTED_BACKGROUND = UIManager.getColor("Table.background");
protected final Color lineColor;
protected final GraphModelProvider graphModelProvider;
protected final JXTable table;
protected JRendererLabel rendererLabel;
public AbstractSparklinesGraphicsComponentProvider(GraphModelProvider graphModelProvider, JXTable table) {
super(null, JLabel.LEADING);
this.graphModelProvider = graphModelProvider;
this.table = table;
if (UIUtils.isDarkLookAndFeel()) {
lineColor = Color.LIGHT_GRAY;
} else {
lineColor = Color.BLUE;
}
}
public abstract String getTextFromValue(Object value);
@Override
protected void format(CellContext context) {<FILL_FUNCTION_BODY>}
@Override
protected void configureState(CellContext context) {
}
@Override
protected JLabel createRendererComponent() {
return rendererLabel = new JRendererLabel();
}
public void setImagePainter(Object value, boolean isSelected) {
if (value == null) {
rendererLabel.setPainter(null);
return;
}
Number[][] values = getSparklinesXAndYNumbers(value);
Number[] xValues = values[0];
Number[] yValues = values[1];
//If there is less than 1 element, don't show anything.
if (yValues.length < 1) {
rendererLabel.setPainter(null);
return;
}
if (yValues.length == 1) {
//SparklineGraph needs at least 2 values, duplicate the only one we have to get a sparkline with a single line showing that the value does not change over time
xValues = null;
yValues = new Number[] {yValues[0], yValues[0]};
}
Color background;
if (isSelected) {
background = SELECTED_BACKGROUND;
} else {
background = UNSELECTED_BACKGROUND;
}
//Note: Can't use interactive SparklineComponent because TableCellEditors don't receive mouse events.
final SparklineParameters sparklineParameters = new SparklineParameters(
rendererLabel.getWidth() - 1,
rendererLabel.getHeight() - 1,
lineColor,
background,
Color.RED,
Color.GREEN,
null
);
final BufferedImage image = SparklineGraph.draw(xValues, yValues, sparklineParameters);
rendererLabel.setPainter(new ImagePainter(image));
}
public abstract Number[][] getSparklinesXAndYNumbers(Object value);
}
|
//Set image or text
int witdth = table.getColumnModel().getColumn(context.getColumn()).getWidth();
int height = table.getRowHeight(context.getRow());
String text = getTextFromValue(context.getValue());
rendererLabel.setSize(witdth, height);
rendererLabel.setToolTipText(text);
rendererLabel.setBorder(null);
setImagePainter(context.getValue(), context.isSelected());
| 832
| 136
| 968
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopDataLaboratory/src/main/java/org/gephi/desktop/datalab/utils/componentproviders/AbstractTimeSetGraphicsComponentProvider.java
|
AbstractTimeSetGraphicsComponentProvider
|
format
|
class AbstractTimeSetGraphicsComponentProvider extends ComponentProvider<JLabel> {
protected static final Color SELECTED_BACKGROUND = UIManager.getColor("Table.selectionBackground");
protected static final Color UNSELECTED_BACKGROUND = UIManager.getColor("Table.background");
protected final Color lineColor;
protected final Color fillColor;
protected final Color borderColor;
protected final TimeIntervalGraphics timeIntervalGraphics;
protected final JXTable table;
protected final GraphModelProvider graphModelProvider;
protected JRendererLabel rendererLabel;
public AbstractTimeSetGraphicsComponentProvider(GraphModelProvider graphModelProvider, JXTable table) {
super(null, JLabel.LEADING);
this.graphModelProvider = graphModelProvider;
this.table = table;
this.timeIntervalGraphics = new TimeIntervalGraphics(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
if (UIUtils.isDarkLookAndFeel()) {
lineColor = Color.LIGHT_GRAY;
fillColor = new Color(94, 98, 100);
borderColor = Color.LIGHT_GRAY;;
} else {
lineColor = Color.BLUE;
fillColor = new Color(153, 255, 255);
borderColor = new Color(2, 104, 255);
}
}
private String getTextFromValue(Object value) {
TimeSet timeSet = (TimeSet) value;
String text = null;
if (timeSet != null) {
text = timeSet.toString(graphModelProvider.getGraphModel().getTimeFormat(),
graphModelProvider.getGraphModel().getTimeZone());
}
return text;
}
@Override
protected void format(CellContext context) {<FILL_FUNCTION_BODY>}
@Override
protected void configureState(CellContext context) {
}
@Override
protected JLabel createRendererComponent() {
return rendererLabel = new JRendererLabel();
}
public abstract TimeIntervalGraphicsParameters getTimeIntervalGraphicsParameters(TimeSet value);
public void setImagePainter(TimeSet value, boolean isSelected) {
if (value == null) {
rendererLabel.setPainter(null);
return;
}
Color background;
if (isSelected) {
background = SELECTED_BACKGROUND;
} else {
background = UNSELECTED_BACKGROUND;
}
TimeIntervalGraphicsParameters params = getTimeIntervalGraphicsParameters(value);
final BufferedImage image = timeIntervalGraphics.createTimeIntervalImage(
params.starts,
params.ends,
rendererLabel.getWidth() - 1,
rendererLabel.getHeight() - 1,
fillColor,
borderColor,
background
);
rendererLabel.setPainter(new ImagePainter(image));
}
public double getMax() {
return timeIntervalGraphics.getMax();
}
public double getMin() {
return timeIntervalGraphics.getMin();
}
public void setMinMax(double min, double max) {
timeIntervalGraphics.setMinMax(min, max);
}
protected class TimeIntervalGraphicsParameters {
private final double[] starts;
private final double[] ends;
public TimeIntervalGraphicsParameters(double[] starts, double[] ends) {
this.starts = starts;
this.ends = ends;
}
}
}
|
//Set image or text
int witdth = table.getColumnModel().getColumn(context.getColumn()).getWidth();
int height = table.getRowHeight(context.getRow());
String text = getTextFromValue(context.getValue());
rendererLabel.setSize(witdth, height);
rendererLabel.setToolTipText(text);
rendererLabel.setBorder(null);
setImagePainter((TimeSet) context.getValue(), context.isSelected());
| 1,009
| 139
| 1,148
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopDataLaboratory/src/main/java/org/gephi/desktop/datalab/utils/componentproviders/ArraySparklinesGraphicsComponentProvider.java
|
ArraySparklinesGraphicsComponentProvider
|
getTextFromValue
|
class ArraySparklinesGraphicsComponentProvider extends AbstractSparklinesGraphicsComponentProvider {
public ArraySparklinesGraphicsComponentProvider(GraphModelProvider graphModelProvider, JXTable table) {
super(graphModelProvider, table);
}
@Override
public String getTextFromValue(Object value) {<FILL_FUNCTION_BODY>}
@Override
public Number[][] getSparklinesXAndYNumbers(Object arr) {
int size = Array.getLength(arr);
Number[] result = new Number[size];
for (int i = 0; i < size; i++) {
result[i] = (Number) Array.get(arr, i);//This will do the auto-boxing of primitives
}
return new Number[][] {null, result};
}
}
|
if (value == null) {
return null;
}
return AttributeUtils.printArray(value);
| 223
| 39
| 262
|
<methods>public void <init>(org.gephi.desktop.datalab.utils.GraphModelProvider, JXTable) ,public abstract java.lang.Number[][] getSparklinesXAndYNumbers(java.lang.Object) ,public abstract java.lang.String getTextFromValue(java.lang.Object) ,public void setImagePainter(java.lang.Object, boolean) <variables>protected static final java.awt.Color SELECTED_BACKGROUND,protected static final java.awt.Color UNSELECTED_BACKGROUND,protected final non-sealed org.gephi.desktop.datalab.utils.GraphModelProvider graphModelProvider,protected final non-sealed java.awt.Color lineColor,protected JRendererLabel rendererLabel,protected final non-sealed JXTable table
|
gephi_gephi
|
gephi/modules/DesktopDataLaboratory/src/main/java/org/gephi/desktop/datalab/utils/componentproviders/IntervalMapSparklinesGraphicsComponentProvider.java
|
IntervalMapSparklinesGraphicsComponentProvider
|
getSparklinesXAndYNumbers
|
class IntervalMapSparklinesGraphicsComponentProvider extends AbstractSparklinesGraphicsComponentProvider {
public IntervalMapSparklinesGraphicsComponentProvider(GraphModelProvider graphModelProvider, JXTable table) {
super(graphModelProvider, table);
}
@Override
public String getTextFromValue(Object value) {
if (value == null) {
return null;
}
TimeFormat timeFormat = graphModelProvider.getGraphModel().getTimeFormat();
DateTimeZone timeZone = graphModelProvider.getGraphModel().getTimeZone();
return ((IntervalMap) value).toString(timeFormat, timeZone);
}
@Override
public Number[][] getSparklinesXAndYNumbers(Object value) {<FILL_FUNCTION_BODY>}
}
|
IntervalMap intervalMap = (IntervalMap) value;
ArrayList<Number> xValues = new ArrayList<>();
ArrayList<Number> yValues = new ArrayList<>();
if (intervalMap == null) {
return new Number[2][0];
}
Interval[] intervals = intervalMap.toKeysArray();
Object[] values = intervalMap.toValuesArray();
Number n;
for (int i = 0; i < intervals.length; i++) {
n = (Number) values[i];
if (n != null) {
xValues.add(intervals[i].getLow());
yValues.add(n);
}
}
return new Number[][] {xValues.toArray(new Number[0]), yValues.toArray(new Number[0])};
| 214
| 225
| 439
|
<methods>public void <init>(org.gephi.desktop.datalab.utils.GraphModelProvider, JXTable) ,public abstract java.lang.Number[][] getSparklinesXAndYNumbers(java.lang.Object) ,public abstract java.lang.String getTextFromValue(java.lang.Object) ,public void setImagePainter(java.lang.Object, boolean) <variables>protected static final java.awt.Color SELECTED_BACKGROUND,protected static final java.awt.Color UNSELECTED_BACKGROUND,protected final non-sealed org.gephi.desktop.datalab.utils.GraphModelProvider graphModelProvider,protected final non-sealed java.awt.Color lineColor,protected JRendererLabel rendererLabel,protected final non-sealed JXTable table
|
gephi_gephi
|
gephi/modules/DesktopDataLaboratory/src/main/java/org/gephi/desktop/datalab/utils/componentproviders/IntervalSetGraphicsComponentProvider.java
|
IntervalSetGraphicsComponentProvider
|
getTimeIntervalGraphicsParameters
|
class IntervalSetGraphicsComponentProvider extends AbstractTimeSetGraphicsComponentProvider {
public IntervalSetGraphicsComponentProvider(GraphModelProvider graphModelProvider, JXTable table) {
super(graphModelProvider, table);
}
@Override
public TimeIntervalGraphicsParameters getTimeIntervalGraphicsParameters(TimeSet value) {<FILL_FUNCTION_BODY>}
}
|
IntervalSet intervalSet = (IntervalSet) value;
double[] intervals = intervalSet.getIntervals();
double[] starts = new double[intervals.length / 2];
double[] ends = new double[intervals.length / 2];
for (int i = 0, startIndex = 0; startIndex < intervals.length; i++, startIndex += 2) {
starts[i] = intervals[startIndex];
ends[i] = intervals[startIndex + 1];
}
return new TimeIntervalGraphicsParameters(starts, ends);
| 98
| 151
| 249
|
<methods>public void <init>(org.gephi.desktop.datalab.utils.GraphModelProvider, JXTable) ,public double getMax() ,public double getMin() ,public abstract org.gephi.desktop.datalab.utils.componentproviders.AbstractTimeSetGraphicsComponentProvider.TimeIntervalGraphicsParameters getTimeIntervalGraphicsParameters(TimeSet) ,public void setImagePainter(TimeSet, boolean) ,public void setMinMax(double, double) <variables>protected static final java.awt.Color SELECTED_BACKGROUND,protected static final java.awt.Color UNSELECTED_BACKGROUND,protected final non-sealed java.awt.Color borderColor,protected final non-sealed java.awt.Color fillColor,protected final non-sealed org.gephi.desktop.datalab.utils.GraphModelProvider graphModelProvider,protected final non-sealed java.awt.Color lineColor,protected JRendererLabel rendererLabel,protected final non-sealed JXTable table,protected final non-sealed org.gephi.utils.TimeIntervalGraphics timeIntervalGraphics
|
gephi_gephi
|
gephi/modules/DesktopDataLaboratory/src/main/java/org/gephi/desktop/datalab/utils/componentproviders/TimestampMapSparklinesGraphicsComponentProvider.java
|
TimestampMapSparklinesGraphicsComponentProvider
|
getSparklinesXAndYNumbers
|
class TimestampMapSparklinesGraphicsComponentProvider extends AbstractSparklinesGraphicsComponentProvider {
public TimestampMapSparklinesGraphicsComponentProvider(GraphModelProvider graphModelProvider, JXTable table) {
super(graphModelProvider, table);
}
@Override
public String getTextFromValue(Object value) {
if (value == null) {
return null;
}
TimeFormat timeFormat = graphModelProvider.getGraphModel().getTimeFormat();
DateTimeZone timeZone = graphModelProvider.getGraphModel().getTimeZone();
return ((TimestampMap) value).toString(timeFormat, timeZone);
}
@Override
public Number[][] getSparklinesXAndYNumbers(Object value) {<FILL_FUNCTION_BODY>}
}
|
TimestampMap timestampMap = (TimestampMap) value;
Double[] timestamps = timestampMap.toKeysArray();
Number[] values = (Number[]) timestampMap.toValuesArray();
return new Number[][] {timestamps, values};
| 214
| 72
| 286
|
<methods>public void <init>(org.gephi.desktop.datalab.utils.GraphModelProvider, JXTable) ,public abstract java.lang.Number[][] getSparklinesXAndYNumbers(java.lang.Object) ,public abstract java.lang.String getTextFromValue(java.lang.Object) ,public void setImagePainter(java.lang.Object, boolean) <variables>protected static final java.awt.Color SELECTED_BACKGROUND,protected static final java.awt.Color UNSELECTED_BACKGROUND,protected final non-sealed org.gephi.desktop.datalab.utils.GraphModelProvider graphModelProvider,protected final non-sealed java.awt.Color lineColor,protected JRendererLabel rendererLabel,protected final non-sealed JXTable table
|
gephi_gephi
|
gephi/modules/DesktopDataLaboratory/src/main/java/org/gephi/desktop/datalab/utils/componentproviders/TimestampSetGraphicsComponentProvider.java
|
TimestampSetGraphicsComponentProvider
|
getTimeIntervalGraphicsParameters
|
class TimestampSetGraphicsComponentProvider extends AbstractTimeSetGraphicsComponentProvider {
public TimestampSetGraphicsComponentProvider(GraphModelProvider graphModelProvider, JXTable table) {
super(graphModelProvider, table);
}
@Override
public TimeIntervalGraphicsParameters getTimeIntervalGraphicsParameters(TimeSet value) {<FILL_FUNCTION_BODY>}
}
|
TimestampSet timestampSet = (TimestampSet) value;
double[] timestamps = timestampSet.toPrimitiveArray();
double[] starts = new double[timestamps.length];
double[] ends = new double[timestamps.length];
for (int i = 0; i < timestamps.length; i++) {
starts[i] = timestamps[i];
ends[i] = timestamps[i];
}
return new TimeIntervalGraphicsParameters(starts, ends);
| 98
| 143
| 241
|
<methods>public void <init>(org.gephi.desktop.datalab.utils.GraphModelProvider, JXTable) ,public double getMax() ,public double getMin() ,public abstract org.gephi.desktop.datalab.utils.componentproviders.AbstractTimeSetGraphicsComponentProvider.TimeIntervalGraphicsParameters getTimeIntervalGraphicsParameters(TimeSet) ,public void setImagePainter(TimeSet, boolean) ,public void setMinMax(double, double) <variables>protected static final java.awt.Color SELECTED_BACKGROUND,protected static final java.awt.Color UNSELECTED_BACKGROUND,protected final non-sealed java.awt.Color borderColor,protected final non-sealed java.awt.Color fillColor,protected final non-sealed org.gephi.desktop.datalab.utils.GraphModelProvider graphModelProvider,protected final non-sealed java.awt.Color lineColor,protected JRendererLabel rendererLabel,protected final non-sealed JXTable table,protected final non-sealed org.gephi.utils.TimeIntervalGraphics timeIntervalGraphics
|
gephi_gephi
|
gephi/modules/DesktopDataLaboratory/src/main/java/org/gephi/desktop/datalab/utils/stringconverters/ArrayStringConverter.java
|
ArrayStringConverter
|
getString
|
class ArrayStringConverter implements StringValue {
@Override
public String getString(Object value) {<FILL_FUNCTION_BODY>}
}
|
String str = null;
if (value != null) {
str = AttributeUtils.printArray(value);
}
return str;
| 39
| 42
| 81
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopDataLaboratory/src/main/java/org/gephi/desktop/datalab/utils/stringconverters/DefaultStringRepresentationConverter.java
|
DefaultStringRepresentationConverter
|
getString
|
class DefaultStringRepresentationConverter implements StringValue {
@Override
public String getString(Object value) {<FILL_FUNCTION_BODY>}
}
|
String str = null;
if (value != null) {
str = value.toString();
}
return str;
| 42
| 37
| 79
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopDataLaboratory/src/main/java/org/gephi/desktop/datalab/utils/stringconverters/DoubleStringConverter.java
|
DoubleStringConverter
|
getString
|
class DoubleStringConverter implements StringValue {
/**
* Formatter for limiting precision to 6 decimals, avoiding precision errors (epsilon).
*/
public static final DecimalFormat FORMAT = new DecimalFormat("0.0#####");
static {
DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance(Locale.ENGLISH);
symbols.setInfinity("Infinity");
FORMAT.setDecimalFormatSymbols(symbols);
}
@Override
public String getString(Object value) {<FILL_FUNCTION_BODY>}
}
|
String str = null;
if (value != null) {
str = FORMAT.format(value);
}
return str;
| 151
| 41
| 192
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopDataLaboratory/src/main/java/org/gephi/desktop/datalab/utils/stringconverters/TimeMapStringConverter.java
|
TimeMapStringConverter
|
getString
|
class TimeMapStringConverter implements StringValue {
private final GraphModelProvider graphModelProvider;
public TimeMapStringConverter(GraphModelProvider graphModelProvider) {
this.graphModelProvider = graphModelProvider;
}
@Override
public String getString(Object value) {<FILL_FUNCTION_BODY>}
}
|
String str = null;
if (value != null) {
TimeMap timeMap = (TimeMap) value;
str = timeMap.toString(graphModelProvider.getGraphModel().getTimeFormat(),
graphModelProvider.getGraphModel().getTimeZone());
}
return str;
| 84
| 77
| 161
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopDataLaboratory/src/main/java/org/gephi/desktop/datalab/utils/stringconverters/TimeSetStringConverter.java
|
TimeSetStringConverter
|
getString
|
class TimeSetStringConverter implements StringValue {
private final GraphModelProvider graphModelProvider;
public TimeSetStringConverter(GraphModelProvider graphModelProvider) {
this.graphModelProvider = graphModelProvider;
}
@Override
public String getString(Object value) {<FILL_FUNCTION_BODY>}
}
|
String str = null;
if (value != null) {
TimeSet timeSet = (TimeSet) value;
str = timeSet.toString(graphModelProvider.getGraphModel().getTimeFormat(),
graphModelProvider.getGraphModel().getTimeZone());
}
return str;
| 84
| 77
| 161
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopExport/src/main/java/org/gephi/desktop/io/export/DesktopExportController.java
|
MultipleWorkspacesExporter
|
run
|
class MultipleWorkspacesExporter implements Runnable, LongTask {
private final Exporter exporter;
private final FileObject folder;
private final String extension;
private boolean cancel = false;
private ProgressTicket progressTicket;
public MultipleWorkspacesExporter(Exporter exporter, FileObject folder, String extension) {
this.exporter = exporter;
this.folder = folder;
this.extension = extension.replace(".", "");
}
@Override
public void run() {<FILL_FUNCTION_BODY>}
@Override
public boolean cancel() {
cancel = true;
return true;
}
@Override
public void setProgressTicket(ProgressTicket progressTicket) {
this.progressTicket = progressTicket;
}
}
|
Project project = Lookup.getDefault().lookup(ProjectController.class).getCurrentProject();
if (project != null) {
Collection<Workspace> workspaceCollection = project.getWorkspaces();
Progress.start(progressTicket, workspaceCollection.size());
for(Workspace workspace :workspaceCollection) {
if (cancel) {
break;
}
try {
FileObject file;
String workspaceName = workspace.getName().replaceAll("[\\\\/:*?\"<>|]", "_");
if (folder.getFileObject(workspaceName, extension) == null) {
file = folder.createData(workspaceName, extension);
} else {
// Overwrite
file = folder.getFileObject(workspaceName, extension);
}
String taskmsg = NbBundle.getMessage(DesktopExportController.class, "DesktopExportController.exportTaskName",
file.getNameExt());
Progress.setDisplayName(progressTicket, taskmsg);
exporter.setWorkspace(workspace);
controller.exportFile(FileUtil.toFile(file), exporter);
Progress.progress(progressTicket);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
Progress.finish(progressTicket);
if(!cancel) {
StatusDisplayer.getDefault().setStatusText(NbBundle
.getMessage(DesktopExportController.class, "DesktopExportController.status.exportAllSuccess",
workspaceCollection.size(), folder.getPath()));
}
}
| 207
| 391
| 598
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopExport/src/main/java/org/gephi/desktop/io/export/Export.java
|
Export
|
createMenu
|
class Export extends AbstractAction implements DynamicMenuContent {
public Export() {
super(NbBundle.getMessage(Export.class, "CTL_Export"));
}
@Override
public void actionPerformed(ActionEvent e) {
// does nothing, this is a popup menu
}
@Override
public JComponent[] getMenuPresenters() {
return createMenu();
}
@Override
public JComponent[] synchMenuPresenters(JComponent[] items) {
return createMenu();
}
private JComponent[] createMenu() {<FILL_FUNCTION_BODY>}
}
|
JMenu menu = new JMenu(NbBundle.getMessage(Export.class, "CTL_Export"));
menu.setEnabled(Lookup.getDefault().lookup(ProjectController.class).hasCurrentProject());
// Graph and image
menu.add(new JMenuItem(
Actions.forID("File", "org.gephi.desktop.io.export.ExportGraph")));
menu.add(new JMenuItem(
Actions.forID("File", "org.gephi.desktop.io.export.ExportImage")));
// Others
for (final ExporterClassUI ui : Lookup.getDefault().lookupAll(ExporterClassUI.class)) {
String menuName = ui.getName();
JMenuItem menuItem = new JMenuItem(new AbstractAction(menuName) {
@Override
public void actionPerformed(ActionEvent e) {
ui.action();
}
});
menu.add(menuItem);
menuItem.setEnabled(ui.isEnable());
}
return new JComponent[] {menu};
| 161
| 265
| 426
|
<methods>public void <init>() ,public void <init>(java.lang.String) ,public void <init>(java.lang.String, javax.swing.Icon) ,public synchronized void addPropertyChangeListener(java.beans.PropertyChangeListener) ,public java.lang.Object[] getKeys() ,public synchronized java.beans.PropertyChangeListener[] getPropertyChangeListeners() ,public java.lang.Object getValue(java.lang.String) ,public boolean isEnabled() ,public void putValue(java.lang.String, java.lang.Object) ,public synchronized void removePropertyChangeListener(java.beans.PropertyChangeListener) ,public void setEnabled(boolean) <variables>private static java.lang.Boolean RECONFIGURE_ON_NULL,private transient javax.swing.ArrayTable arrayTable,protected javax.swing.event.SwingPropertyChangeSupport changeSupport,protected boolean enabled
|
gephi_gephi
|
gephi/modules/DesktopExport/src/main/java/org/gephi/desktop/io/export/GraphFileAction.java
|
GraphFileAction
|
actionPerformed
|
class GraphFileAction extends AbstractAction {
private final AbstractExporterUI<GraphFileExporterBuilder> exporterUI;
public GraphFileAction() {
super(NbBundle.getMessage(GraphFileAction.class, "CTL_ExportGraphAction"));
exporterUI = new AbstractExporterUI<>("GraphFileExporterUI", GraphFileExporterBuilder.class);
}
@Override
public void actionPerformed(ActionEvent e) {<FILL_FUNCTION_BODY>}
}
|
if(e.getSource() instanceof GraphFileExporterBuilder[]) {
exporterUI.action(Arrays.asList((GraphFileExporterBuilder[]) e.getSource()));
} else {
exporterUI.action();
}
| 125
| 63
| 188
|
<methods>public void <init>() ,public void <init>(java.lang.String) ,public void <init>(java.lang.String, javax.swing.Icon) ,public synchronized void addPropertyChangeListener(java.beans.PropertyChangeListener) ,public java.lang.Object[] getKeys() ,public synchronized java.beans.PropertyChangeListener[] getPropertyChangeListeners() ,public java.lang.Object getValue(java.lang.String) ,public boolean isEnabled() ,public void putValue(java.lang.String, java.lang.Object) ,public synchronized void removePropertyChangeListener(java.beans.PropertyChangeListener) ,public void setEnabled(boolean) <variables>private static java.lang.Boolean RECONFIGURE_ON_NULL,private transient javax.swing.ArrayTable arrayTable,protected javax.swing.event.SwingPropertyChangeSupport changeSupport,protected boolean enabled
|
gephi_gephi
|
gephi/modules/DesktopExport/src/main/java/org/gephi/desktop/io/export/GraphFileExporterUIPanel.java
|
GraphFileExporterUIPanel
|
initComponents
|
class GraphFileExporterUIPanel extends javax.swing.JPanel {
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JRadioButton fullGraphRadio;
private javax.swing.ButtonGroup graphButtonGroup;
private javax.swing.JLabel labelFullgraph;
private javax.swing.JLabel labelGraph;
private javax.swing.JLabel labelVisibleOnly;
private javax.swing.JRadioButton visibleOnlyRadio;
// End of variables declaration//GEN-END:variables
/**
* Creates new form GraphFileExporterUIPanel
*/
public GraphFileExporterUIPanel() {
initComponents();
}
public boolean isVisibleOnlyGraph() {
return graphButtonGroup.isSelected(visibleOnlyRadio.getModel());
}
public void setVisibleOnlyGraph(boolean value) {
graphButtonGroup.setSelected((value ? visibleOnlyRadio.getModel() : fullGraphRadio.getModel()), true);
}
/**
* This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {<FILL_FUNCTION_BODY>}// </editor-fold>//GEN-END:initComponents
}
|
graphButtonGroup = new javax.swing.ButtonGroup();
labelGraph = new javax.swing.JLabel();
fullGraphRadio = new javax.swing.JRadioButton();
visibleOnlyRadio = new javax.swing.JRadioButton();
labelFullgraph = new javax.swing.JLabel();
labelVisibleOnly = new javax.swing.JLabel();
setBorder(javax.swing.BorderFactory.createEtchedBorder());
labelGraph.setText(org.openide.util.NbBundle
.getMessage(GraphFileExporterUIPanel.class, "GraphFileExporterUIPanel.labelGraph.text")); // NOI18N
graphButtonGroup.add(fullGraphRadio);
fullGraphRadio.setSelected(true);
fullGraphRadio.setText(org.openide.util.NbBundle
.getMessage(GraphFileExporterUIPanel.class, "GraphFileExporterUIPanel.fullGraphRadio.text")); // NOI18N
graphButtonGroup.add(visibleOnlyRadio);
visibleOnlyRadio.setText(org.openide.util.NbBundle
.getMessage(GraphFileExporterUIPanel.class, "GraphFileExporterUIPanel.visibleOnlyRadio.text")); // NOI18N
labelFullgraph.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
labelFullgraph.setForeground(new java.awt.Color(102, 102, 102));
labelFullgraph.setText(org.openide.util.NbBundle
.getMessage(GraphFileExporterUIPanel.class, "GraphFileExporterUIPanel.labelFullgraph.text")); // NOI18N
labelVisibleOnly.setFont(new java.awt.Font("Tahoma", 0, 10));
labelVisibleOnly.setForeground(new java.awt.Color(102, 102, 102));
labelVisibleOnly.setText(org.openide.util.NbBundle
.getMessage(GraphFileExporterUIPanel.class, "GraphFileExporterUIPanel.labelVisibleOnly.text")); // NOI18N
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(labelGraph)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(visibleOnlyRadio)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(labelVisibleOnly))
.addGroup(layout.createSequentialGroup()
.addComponent(fullGraphRadio)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(labelFullgraph)))
.addContainerGap(21, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(labelGraph)
.addComponent(fullGraphRadio)
.addComponent(labelFullgraph))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(visibleOnlyRadio)
.addComponent(labelVisibleOnly))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
| 391
| 1,056
| 1,447
|
<methods>public void <init>() ,public void <init>(java.awt.LayoutManager) ,public void <init>(boolean) ,public void <init>(java.awt.LayoutManager, boolean) ,public javax.accessibility.AccessibleContext getAccessibleContext() ,public javax.swing.plaf.PanelUI getUI() ,public java.lang.String getUIClassID() ,public void setUI(javax.swing.plaf.PanelUI) ,public void updateUI() <variables>private static final java.lang.String uiClassID
|
gephi_gephi
|
gephi/modules/DesktopFilters/src/main/java/org/gephi/desktop/filters/FilterPanelPanel.java
|
FilterPanelPanel
|
setQuery
|
class FilterPanelPanel extends JPanel implements ChangeListener {
private final String settingsString;
private Query selectedQuery;
private FilterUIModel uiModel;
public FilterPanelPanel() {
super(new BorderLayout());
settingsString = NbBundle.getMessage(FilterPanelPanel.class, "FilterPanelPanel.settings");
if (UIUtils.isAquaLookAndFeel()) {
setBackground(UIManager.getColor("NbExplorerView.background"));
}
}
@Override
public void stateChanged(ChangeEvent e) {
refreshModel();
}
private void refreshModel() {
if (uiModel != null) {
if (uiModel.getSelectedQuery() != selectedQuery) {
selectedQuery = uiModel.getSelectedQuery();
setQuery(selectedQuery);
}
} else {
setQuery(null);
}
}
public void setup(FilterUIModel model) {
uiModel = model;
if (model != null) {
model.addChangeListener(this);
}
refreshModel();
}
public void unsetup() {
if (uiModel != null) {
uiModel.removeChangeListener(this);
uiModel = null;
refreshModel();
}
}
private void setQuery(final Query query) {<FILL_FUNCTION_BODY>}
}
|
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
//UI update
removeAll();
setBorder(null);
if (query != null) {
FilterController filterController = Lookup.getDefault().lookup(FilterController.class);
FilterBuilder builder = filterController.getModel().getLibrary().getBuilder(query.getFilter());
try {
JPanel panel = builder.getPanel(query.getFilter());
if (panel != null) {
add(panel, BorderLayout.CENTER);
panel.setOpaque(false);
setBorder(javax.swing.BorderFactory
.createTitledBorder(query.getFilter().getName() + " " + settingsString));
}
} catch (Exception e) {
Logger.getLogger("").log(Level.SEVERE, "Error while setting query", e);
}
}
revalidate();
repaint();
}
});
| 354
| 253
| 607
|
<methods>public void <init>() ,public void <init>(java.awt.LayoutManager) ,public void <init>(boolean) ,public void <init>(java.awt.LayoutManager, boolean) ,public javax.accessibility.AccessibleContext getAccessibleContext() ,public javax.swing.plaf.PanelUI getUI() ,public java.lang.String getUIClassID() ,public void setUI(javax.swing.plaf.PanelUI) ,public void updateUI() <variables>private static final java.lang.String uiClassID
|
gephi_gephi
|
gephi/modules/DesktopFilters/src/main/java/org/gephi/desktop/filters/FilterUIModel.java
|
FilterUIModel
|
getSelectedRoot
|
class FilterUIModel {
private final Workspace workspace;
private final List<Query> expandedQueryNodes;
private final List<Query> expandedParametersNodes;
private final List<Category> expandedCategoryNodes;
private final List<ChangeListener> listeners;
private Query selectedQuery;
public FilterUIModel(Workspace workspace) {
this.workspace = workspace;
listeners = new ArrayList<>();
expandedQueryNodes = new ArrayList<>();
expandedCategoryNodes = new ArrayList<>();
expandedParametersNodes = new ArrayList<>();
}
public Workspace getWorkspace() {
return workspace;
}
public Query getSelectedQuery() {
return selectedQuery;
}
public void setSelectedQuery(Query query) {
selectedQuery = query;
fireChangeEvent();
}
public Query getSelectedRoot() {<FILL_FUNCTION_BODY>}
public void setExpand(Query query, boolean expanded, boolean parametersExpanded) {
if (expanded && !expandedQueryNodes.contains(query)) {
expandedQueryNodes.add(query);
} else if (!expanded) {
expandedQueryNodes.remove(query);
}
if (parametersExpanded && !expandedParametersNodes.contains(query)) {
expandedParametersNodes.add(query);
} else if (!parametersExpanded) {
expandedParametersNodes.remove(query);
}
}
public void setExpand(Category category, boolean expanded) {
if (expanded && !expandedCategoryNodes.contains(category)) {
expandedCategoryNodes.add(category);
} else if (!expanded) {
expandedCategoryNodes.remove(category);
}
}
public boolean isExpanded(Query query) {
return expandedQueryNodes.contains(query);
}
public boolean isParametersExpanded(Query query) {
return expandedParametersNodes.contains(query);
}
public boolean isExpanded(Category category) {
return expandedCategoryNodes.contains(category);
}
public void addChangeListener(ChangeListener listener) {
if (!listeners.contains(listener)) {
listeners.add(listener);
}
}
public void removeChangeListener(ChangeListener listener) {
listeners.remove(listener);
}
private void fireChangeEvent() {
ChangeEvent evt = new ChangeEvent(this);
for (ChangeListener listener : listeners) {
listener.stateChanged(evt);
}
}
}
|
if (selectedQuery != null) {
Query root = selectedQuery;
while (root.getParent() != null) {
root = root.getParent();
}
return root;
}
return null;
| 628
| 61
| 689
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopFilters/src/main/java/org/gephi/desktop/filters/FiltersTopComponent.java
|
FiltersTopComponent
|
run
|
class FiltersTopComponent extends TopComponent {
private static final long AUTO_REFRESH_RATE_MILLISECONDS = 3000;
//Panel
private final FiltersPanel panel;
//Models
private FilterModel filterModel;
private WorkspaceColumnsObservers observers;
private FilterUIModel uiModel;
private java.util.Timer observersTimer;
public FiltersTopComponent() {
initComponents();
setName(NbBundle.getMessage(FiltersTopComponent.class, "CTL_FiltersTopComponent"));
putClientProperty(TopComponent.PROP_MAXIMIZATION_DISABLED, Boolean.TRUE);
panel = new FiltersPanel();
add(panel, BorderLayout.CENTER);
//Model management
ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);
pc.addWorkspaceListener(new WorkspaceListener() {
@Override
public void initialize(Workspace workspace) {
workspace.add(new FilterUIModel(workspace));
}
@Override
public void select(Workspace workspace) {
activateWorkspace(workspace);
refreshModel();
}
@Override
public void unselect(Workspace workspace) {
observers.destroy();
}
@Override
public void close(Workspace workspace) {
}
@Override
public void disable() {
filterModel = null;
uiModel = null;
observers = null;
refreshModel();
}
});
if (pc.getCurrentWorkspace() != null) {
Workspace workspace = pc.getCurrentWorkspace();
activateWorkspace(workspace);
}
refreshModel();
initEvents();
}
private void activateWorkspace(Workspace workspace) {
filterModel = workspace.getLookup().lookup(FilterModel.class);
uiModel = workspace.getLookup().lookup(FilterUIModel.class);
if (uiModel == null) {
uiModel = new FilterUIModel(workspace);
workspace.add(uiModel);
}
observers = workspace.getLookup().lookup(WorkspaceColumnsObservers.class);
if (observers == null) {
workspace.add(observers = new WorkspaceColumnsObservers(workspace));
}
observers.initialize();
}
private void refreshModel() {
panel.refreshModel(filterModel, uiModel);
}
public FilterUIModel getUiModel() {
return uiModel;
}
private void initEvents() {
observersTimer = new java.util.Timer("DataLaboratoryGraphObservers");
observersTimer.schedule(new TimerTask() {
@Override
public void run() {<FILL_FUNCTION_BODY>}
}
, 0, AUTO_REFRESH_RATE_MILLISECONDS);//Check graph and tables for changes every 100 ms
}
/**
* This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The content of this method is always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
setLayout(new java.awt.BorderLayout());
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
// End of variables declaration//GEN-END:variables
void writeProperties(java.util.Properties p) {
// better to version settings since initial version as advocated at
// http://wiki.apidesign.org/wiki/PropertyFiles
p.setProperty("version", "1.0");
// TODO store your settings
}
void readProperties(java.util.Properties p) {
String version = p.getProperty("version");
// TODO read your settings according to their version
}
}
|
if (observers != null) {
if (observers.hasChanges()) {
refreshModel();
}
}
| 1,028
| 37
| 1,065
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopFilters/src/main/java/org/gephi/desktop/filters/WorkspaceColumnsObservers.java
|
WorkspaceColumnsObservers
|
initialize
|
class WorkspaceColumnsObservers {
private final GraphModel graphModel;
private TableObserver nodesTableObserver;
private TableObserver edgesTableObserver;
public WorkspaceColumnsObservers(Workspace workspace) {
this.graphModel = Lookup.getDefault().lookup(GraphController.class).getGraphModel(workspace);
}
public synchronized void initialize() {<FILL_FUNCTION_BODY>}
public synchronized void destroy() {
if (nodesTableObserver != null) {
nodesTableObserver.destroy();
nodesTableObserver = null;
}
if (edgesTableObserver != null) {
edgesTableObserver.destroy();
edgesTableObserver = null;
}
}
public boolean hasChanges() {
if (nodesTableObserver == null) {
return false;//Not initialized
}
boolean hasChanges = false;
hasChanges = processTableObseverChanges(nodesTableObserver) || hasChanges;
hasChanges = processTableObseverChanges(edgesTableObserver) || hasChanges;
return hasChanges;
}
private boolean processTableObseverChanges(TableObserver observer) {
return observer.hasTableChanged();
}
}
|
if (nodesTableObserver != null) {
return;
}
nodesTableObserver = graphModel.getNodeTable().createTableObserver(true);
edgesTableObserver = graphModel.getEdgeTable().createTableObserver(true);
| 350
| 68
| 418
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopFilters/src/main/java/org/gephi/desktop/filters/library/CategoryChildFactory.java
|
CategoryChildFactory
|
compare
|
class CategoryChildFactory extends ChildFactory<Object> {
private final Category category;
private final FiltersExplorer.Utils utils;
public CategoryChildFactory(FiltersExplorer.Utils utils, Category category) {
this.utils = utils;
this.category = category;
}
@Override
protected boolean createKeys(List<Object> toPopulate) {
Object[] children = utils.getChildren(category);
Arrays.sort(children, new Comparator() {
@Override
public int compare(Object o1, Object o2) {<FILL_FUNCTION_BODY>}
});
toPopulate.addAll(Arrays.asList(children));
return true;
}
@Override
protected Node[] createNodesForKey(Object key) {
if (key instanceof Category) {
return new Node[] {new CategoryNode(utils, (Category) key)};
} else if (key instanceof FilterBuilder) {
return new Node[] {new FilterBuilderNode((FilterBuilder) key)};
} else {
return new Node[] {new SavedQueryNode((Query) key)};
}
}
}
|
String s1;
String s2;
if (o1 == FiltersExplorer.QUERIES || o2 == FiltersExplorer.QUERIES) {
return o1 == FiltersExplorer.QUERIES ? 1 : -1;
} else if (o1 instanceof Category && o2 instanceof Category) {
s1 = ((Category) o1).getName();
s2 = ((Category) o2).getName();
return s1.compareTo(s2);
} else if (o1 instanceof FilterBuilder && o2 instanceof FilterBuilder) {
s1 = ((FilterBuilder) o1).getName();
s2 = ((FilterBuilder) o2).getName();
return s1.compareTo(s2);
} else if (o1 instanceof Query && o2 instanceof Query) {
s1 = ((Query) o1).getName();
s2 = ((Query) o2).getName();
return s1.compareTo(s2);
} else if (o1 instanceof Category) {
return -1;
}
return 1;
| 292
| 261
| 553
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopFilters/src/main/java/org/gephi/desktop/filters/library/CategoryNode.java
|
CategoryNode
|
getIcon
|
class CategoryNode extends AbstractNode {
private final Category category;
public CategoryNode(FiltersExplorer.Utils utils, Category category) {
super(
utils.isLeaf(category) ? Children.LEAF : Children.create(new CategoryChildFactory(utils, category), true));
this.category = category;
if (category != null) {
setName(category.getName());
} else {
setName(NbBundle.getMessage(CategoryNode.class, "RootNode.name"));
}
}
@Override
public Image getIcon(int type) {<FILL_FUNCTION_BODY>}
@Override
public Image getOpenedIcon(int type) {
return getIcon(type);
}
@Override
public PasteType getDropType(final Transferable t, int action, int index) {
if (category == null || !category.equals(FiltersExplorer.QUERIES)) {
return null;
}
final Node dropNode = NodeTransfer.node(t, DnDConstants.ACTION_COPY_OR_MOVE);
if (dropNode != null && dropNode instanceof QueryNode) {
return new PasteType() {
@Override
public Transferable paste() throws IOException {
QueryNode queryNode = (QueryNode) dropNode;
FilterController filterController = Lookup.getDefault().lookup(FilterController.class);
FilterLibrary library = filterController.getModel().getLibrary();
library.saveQuery(queryNode.getQuery());
return null;
}
};
}
return null;
}
public Category getCategory() {
return category;
}
@Override
public Action[] getActions(boolean context) {
return new Action[0];
}
}
|
try {
if (category.getIcon() != null) {
return ImageUtilities.icon2Image(category.getIcon());
}
} catch (Exception e) {
}
if (category == null) {
return ImageUtilities.loadImage("DesktopFilters/library.png", false);
} else {
return ImageUtilities.loadImage("DesktopFilters/folder.png", false);
}
| 452
| 109
| 561
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopFilters/src/main/java/org/gephi/desktop/filters/library/FilterBuilderNode.java
|
FilterBuilderNode
|
getIcon
|
class FilterBuilderNode extends AbstractNode {
public static final DataFlavor DATA_FLAVOR = new DataFlavor(FilterBuilder.class, "filterbuilder");
private final FilterBuilder filterBuilder;
private final FilterTransferable transferable;
public FilterBuilderNode(FilterBuilder filterBuilder) {
super(Children.LEAF);
this.filterBuilder = filterBuilder;
setName(filterBuilder.getName());
transferable = new FilterTransferable();
if (filterBuilder.getDescription() != null) {
setShortDescription(filterBuilder.getDescription());
}
}
@Override
public String getHtmlDisplayName() {
return super.getName();
}
@Override
public Image getIcon(int type) {<FILL_FUNCTION_BODY>}
@Override
public Image getOpenedIcon(int type) {
return getIcon(type);
}
@Override
public Action getPreferredAction() {
return FilterBuilderNodeDefaultAction.instance;
}
public FilterBuilder getBuilder() {
return filterBuilder;
}
@Override
public Transferable drag() throws IOException {
return transferable;
}
@Override
public Action[] getActions(boolean context) {
return new Action[0];
}
private class FilterTransferable implements Transferable {
@Override
public DataFlavor[] getTransferDataFlavors() {
return new DataFlavor[] {DATA_FLAVOR};
}
@Override
public boolean isDataFlavorSupported(DataFlavor flavor) {
return flavor == DATA_FLAVOR;
}
@Override
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
if (flavor == DATA_FLAVOR) {
return filterBuilder;
} else {
throw new UnsupportedFlavorException(flavor);
}
}
}
}
|
try {
if (filterBuilder.getIcon() != null) {
return ImageUtilities.icon2Image(filterBuilder.getIcon());
}
} catch (Exception e) {
}
return ImageUtilities.loadImage("DesktopFilters/funnel.png", false);
| 495
| 75
| 570
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopFilters/src/main/java/org/gephi/desktop/filters/library/FilterBuilderNodeDefaultAction.java
|
FilterBuilderNodeDefaultAction
|
actionPerformed
|
class FilterBuilderNodeDefaultAction extends SystemAction {
public static FilterBuilderNodeDefaultAction instance = new FilterBuilderNodeDefaultAction();
@Override
public String getName() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public HelpCtx getHelpCtx() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void actionPerformed(ActionEvent ev) {<FILL_FUNCTION_BODY>}
}
|
FilterBuilderNode node = (FilterBuilderNode) ev.getSource();
FilterBuilder builder = node.getBuilder();
FilterController filterController = Lookup.getDefault().lookup(FilterController.class);
Query function = filterController.createQuery(builder);
filterController.add(function);
| 124
| 74
| 198
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopFilters/src/main/java/org/gephi/desktop/filters/library/FiltersExplorer.java
|
FiltersExplorer
|
setup
|
class FiltersExplorer extends BeanTreeView {
public static final Category QUERIES = new Category(
NbBundle.getMessage(FiltersExplorer.class, "FiltersExplorer.Queries"),
null,
null);
private final Category UNSORTED = new Category(
NbBundle.getMessage(FiltersExplorer.class, "FiltersExplorer.UnsortedCategory"),
null,
null);
private ExplorerManager manager;
private FilterLibrary filterLibrary;
private FilterUIModel uiModel;
public FiltersExplorer() {
}
public void setup(final ExplorerManager manager, FilterModel model, FilterUIModel uiModel) {<FILL_FUNCTION_BODY>}
private void updateEnabled(final boolean enabled) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
setRootVisible(enabled);
setEnabled(enabled);
}
});
}
private void loadExpandStatus(CategoryNode node) {
if (uiModel == null) {
return;
}
if (uiModel.isExpanded(node.getCategory())) {
expandNode(node);
}
for (Node n : node.getChildren().getNodes()) {
if (n instanceof CategoryNode) {
loadExpandStatus((CategoryNode) n);
}
}
}
private void saveExpandStatus(CategoryNode node) {
if (uiModel == null) {
return;
}
uiModel.setExpand(node.getCategory(), isExpanded(node));
for (Node n : node.getChildren().getNodes()) {
if (n instanceof CategoryNode) {
saveExpandStatus((CategoryNode) n);
}
}
}
protected class Utils implements LookupListener {
private final Lookup.Result<FilterBuilder> lookupResult;
private final Lookup.Result<Query> lookupResult2;
public Utils() {
lookupResult = filterLibrary.getLookup().lookupResult(FilterBuilder.class);
lookupResult.addLookupListener(this);
lookupResult2 = filterLibrary.getLookup().lookupResult(Query.class);
lookupResult2.addLookupListener(this);
}
@Override
public void resultChanged(LookupEvent ev) {
saveExpandStatus((CategoryNode) manager.getRootContext());
manager.setRootContext(new CategoryNode(this, null));
loadExpandStatus((CategoryNode) manager.getRootContext());
}
public boolean isLeaf(Category category) {
if (category == null) {
return false;
}
if (category.equals(QUERIES)) {
return filterLibrary.getLookup().lookupAll(Query.class).isEmpty();
}
for (FilterBuilder fb : filterLibrary.getLookup().lookupAll(FilterBuilder.class)) {
if (fb.getCategory() == null && category.equals(UNSORTED)) {
return false;
}
if (fb.getCategory() != null && fb.getCategory().getParent() != null &&
fb.getCategory().getParent().equals(category)) {
return false;
}
if (fb.getCategory() != null && fb.getCategory().equals(category)) {
return false;
}
}
for (CategoryBuilder cb : filterLibrary.getLookup().lookupAll(CategoryBuilder.class)) {
if (cb.getCategory().equals(category)) {
return false;
}
if (cb.getCategory().getParent() != null && cb.getCategory().getParent().equals(category)) {
return false;
}
}
return true;
}
public Object[] getChildren(Category category) {
Set<Object> cats = new HashSet<>();
if (category != null && category.equals(QUERIES)) {
for (Query q : filterLibrary.getLookup().lookupAll(Query.class)) {
cats.add(q);
}
} else {
if (category == null) {
cats.add(QUERIES);
}
//get categories from filter builders
for (FilterBuilder fb : filterLibrary.getLookup().lookupAll(FilterBuilder.class)) {
if (fb.getCategory() == null) {
if (category == null) {
cats.add(UNSORTED);
} else if (category.equals(UNSORTED)) {
cats.add(fb);
}
} else if (fb.getCategory().getParent() == category) {
if (isValid(fb.getCategory())) {
cats.add(fb.getCategory());
}
} else if (fb.getCategory().getParent() != null && fb.getCategory().getParent().equals(category)) {
if (isValid(fb.getCategory())) {
cats.add(fb.getCategory());
}
} else if (fb.getCategory().equals(category)) {
cats.add(fb);
}
}
//get categories from cat builders
for (CategoryBuilder cb : filterLibrary.getLookup().lookupAll(CategoryBuilder.class)) {
if (cb.getCategory().getParent() == category) {
cats.add(cb.getCategory());
} else if (cb.getCategory().getParent() != null &&
cb.getCategory().getParent().getParent() == category) {
cats.add(cb.getCategory().getParent());
} else if (cb.getCategory() == category) {
for (FilterBuilder fb : cb.getBuilders(uiModel.getWorkspace())) {
cats.add(fb);
}
}
}
}
return cats.toArray();
}
public boolean isValid(Category category) {
for (FilterLibraryMask mask : filterLibrary.getLookup().lookupAll(FilterLibraryMask.class)) {
if (mask.getCategory().equals(category)) {
return mask.isValid();
}
}
return true;
}
}
}
|
this.manager = manager;
this.uiModel = uiModel;
if (model != null) {
this.filterLibrary = model.getLibrary();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
manager.setRootContext(new CategoryNode(new Utils(), null));
}
});
} else {
this.filterLibrary = null;
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
manager.setRootContext(new AbstractNode(Children.LEAF) {
@Override
public Action[] getActions(boolean context) {
return new Action[0];
}
});
}
});
}
updateEnabled(model != null);
| 1,538
| 208
| 1,746
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopFilters/src/main/java/org/gephi/desktop/filters/library/SavedQueryNode.java
|
RemoveAction
|
actionPerformed
|
class RemoveAction extends AbstractAction {
public RemoveAction() {
super(NbBundle.getMessage(SavedQueryNode.class, "SavedQueryNode.actions.remove"));
}
@Override
public void actionPerformed(ActionEvent e) {<FILL_FUNCTION_BODY>}
}
|
FilterController filterController = Lookup.getDefault().lookup(FilterController.class);
FilterLibrary filterLibrary = filterController.getModel().getLibrary();
filterLibrary.deleteQuery(query);
| 79
| 50
| 129
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopFilters/src/main/java/org/gephi/desktop/filters/library/SavedQueryNodeDefaultAction.java
|
SavedQueryNodeDefaultAction
|
actionPerformed
|
class SavedQueryNodeDefaultAction extends SystemAction {
public static SavedQueryNodeDefaultAction instance = new SavedQueryNodeDefaultAction();
@Override
public String getName() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public HelpCtx getHelpCtx() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void actionPerformed(ActionEvent ev) {<FILL_FUNCTION_BODY>}
}
|
SavedQueryNode node = (SavedQueryNode) ev.getSource();
FilterController filterController = Lookup.getDefault().lookup(FilterController.class);
filterController.add(node.getQuery());
| 127
| 55
| 182
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopFilters/src/main/java/org/gephi/desktop/filters/query/QueryChildren.java
|
QueryChildren
|
initCollection
|
class QueryChildren extends Children.Array {
private Query query;
private Query[] topQuery;
public QueryChildren(Query query) {
this.query = query;
}
public QueryChildren(Query[] topQuery) { //Only for root node
if (topQuery.length > 0) {
this.topQuery = topQuery;
}
}
@Override
protected Collection<Node> initCollection() {<FILL_FUNCTION_BODY>}
private static class HelpNode extends AbstractNode {
public HelpNode() {
super(Children.LEAF);
setIconBaseWithExtension("DesktopFilters/drop.png");
}
@Override
public String getHtmlDisplayName() {
return NbBundle.getMessage(QueryChildren.class, "HelpNode.name");
}
@Override
public PasteType getDropType(Transferable t, int action, int index) {
if (t.isDataFlavorSupported(FilterBuilderNode.DATA_FLAVOR)) {
try {
final FilterBuilder fb = (FilterBuilder) t.getTransferData(FilterBuilderNode.DATA_FLAVOR);
return new PasteType() {
@Override
public Transferable paste() throws IOException {
FilterController filterController = Lookup.getDefault().lookup(FilterController.class);
Query f = filterController.createQuery(fb);
filterController.add(f);
return null;
}
};
} catch (Exception ex) {
Exceptions.printStackTrace(ex);
}
}
return null;
}
@Override
public Action[] getActions(boolean context) {
return new Action[0];
}
}
}
|
Collection<Node> nodesChildren = new ArrayList<>();
if (query == null && topQuery == null) {
nodesChildren.add(new HelpNode());
} else {
Query[] children = topQuery != null ? topQuery : query.getChildren();
boolean hasParameters = query != null && query.getPropertiesCount() > 0;
int slots = topQuery != null ? topQuery.length : query.getChildrenSlotsCount();
if (slots == Integer.MAX_VALUE) {
slots = children != null ? children.length + 1 : 1;
}
if (hasParameters) {
nodesChildren.add(new ParameterNode(query));
}
for (int i = 0; i < slots; i++) {
if (children != null && i < children.length) {
nodesChildren.add(new QueryNode(children[i]));
} else {
nodesChildren.add(new SlotNode(query));
}
}
}
return nodesChildren;
| 436
| 255
| 691
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopFilters/src/main/java/org/gephi/desktop/filters/query/QueryExplorer.java
|
QueryExplorer
|
propertyChange
|
class QueryExplorer extends BeanTreeView implements PropertyChangeListener, ChangeListener {
private ExplorerManager manager;
private FilterModel model;
private FilterUIModel uiModel;
private FilterController filterController;
//state
private boolean listenSelectedNodes = false;
public QueryExplorer() {
setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
}
public void unsetup() {
if (model != null) {
model.removeChangeListener(this);
model = null;
}
}
public void setup(final ExplorerManager manager, final FilterModel model, FilterUIModel uiModel) {
this.manager = manager;
this.model = model;
this.uiModel = uiModel;
this.filterController = Lookup.getDefault().lookup(FilterController.class);
if (model != null) {
model.addChangeListener(this);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
manager.setRootContext(new RootNode(new QueryChildren(model.getQueries())));
}
});
} else {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
manager.setRootContext(new AbstractNode(Children.LEAF) {
@Override
public Action[] getActions(boolean context) {
return new Action[0];
}
});
}
});
}
updateEnabled(model != null);
if (!listenSelectedNodes) {
manager.addPropertyChangeListener(this);
listenSelectedNodes = true;
}
}
@Override
public void propertyChange(PropertyChangeEvent evt) {<FILL_FUNCTION_BODY>}
@Override
public void stateChanged(ChangeEvent e) {
//System.out.println("model updated");
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
//uiModel.setSelectedQuery(model.getCurrentQuery());
saveExpandStatus(QueryExplorer.this.manager.getRootContext());
QueryExplorer.this.manager
.setRootContext(new RootNode(new QueryChildren(QueryExplorer.this.model.getQueries())));
loadExpandStatus(QueryExplorer.this.manager.getRootContext());
}
});
}
private void updateEnabled(final boolean enabled) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
setRootVisible(enabled);
setEnabled(enabled);
}
});
}
private void loadExpandStatus(Node node) {
if (node instanceof RootNode) {
RootNode rootNode = (RootNode) node;
for (Node n : rootNode.getChildren().getNodes()) {
loadExpandStatus(n);
}
} else if (node instanceof QueryNode) {
QueryNode queryNode = (QueryNode) node;
if (uiModel.isExpanded(queryNode.getQuery())) {
expandNode(queryNode);
}
Node firstChild = queryNode.getChildren().getNodeAt(0);
if (firstChild != null && firstChild instanceof ParameterNode) {
if (uiModel.isParametersExpanded(queryNode.getQuery())) {
expandNode(firstChild);
}
}
for (Node n : queryNode.getChildren().getNodes()) {
loadExpandStatus(n);
}
}
}
private void saveExpandStatus(Node node) {
if (node instanceof RootNode) {
RootNode rootNode = (RootNode) node;
for (Node n : rootNode.getChildren().getNodes()) {
saveExpandStatus(n);
}
} else if (node instanceof QueryNode) {
QueryNode queryNode = (QueryNode) node;
Node firstChild = queryNode.getChildren().getNodeAt(0);
boolean parameterExpanded = false;
if (firstChild != null && firstChild instanceof ParameterNode) {
parameterExpanded = isExpanded(firstChild);
}
uiModel.setExpand(queryNode.getQuery(), isExpanded(queryNode), parameterExpanded);
for (Node n : queryNode.getChildren().getNodes()) {
saveExpandStatus(n);
}
}
}
}
|
if (evt.getPropertyName().equals(ExplorerManager.PROP_SELECTED_NODES)) {
if (uiModel == null) {
return;
}
Node[] nodeArray = (Node[]) evt.getNewValue();
if (nodeArray.length > 0) {
Node node = ((Node[]) evt.getNewValue())[0];
if (node instanceof RootNode) {
uiModel.setSelectedQuery(null);
filterController.setCurrentQuery(null);
return;
}
while (!(node instanceof QueryNode)) {
node = node.getParentNode();
if (node.getParentNode() == null) {
uiModel.setSelectedQuery(null);
filterController.setCurrentQuery(null);
return;
}
}
QueryNode queryNode = (QueryNode) node;
final Query query = queryNode.getQuery();
new Thread(new Runnable() {
@Override
public void run() {
uiModel.setSelectedQuery(query);
model.removeChangeListener(QueryExplorer.this);
filterController.setCurrentQuery(uiModel.getSelectedRoot());
model.addChangeListener(QueryExplorer.this);
}
}).start();
}
}
| 1,122
| 319
| 1,441
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopFilters/src/main/java/org/gephi/desktop/filters/query/QueryNode.java
|
DuplicateAction
|
duplicateQuery
|
class DuplicateAction extends AbstractAction {
public DuplicateAction() {
super(NbBundle.getMessage(QueryNode.class, "QueryNode.actions.duplicate"));
}
@Override
public void actionPerformed(ActionEvent e) {
FilterController filterController = Lookup.getDefault().lookup(FilterController.class);
Query ancestor = query;
while (ancestor.getParent() != null) {
ancestor = ancestor.getParent();
}
duplicateQuery(filterController, null, ancestor);
}
private void duplicateQuery(FilterController filterController, Query parent, Query child) {<FILL_FUNCTION_BODY>}
}
|
Filter filter = child.getFilter();
FilterBuilder builder = filterController.getModel().getLibrary().getBuilder(filter);
Query childQuery = filterController.createQuery(builder);
childQuery.setName(child.getName());
Filter filterCopy = childQuery.getFilter();
FilterProperty[] filterProperties = filter.getProperties();
FilterProperty[] filterCopyProperties = filterCopy.getProperties();
if (filterProperties != null && filterCopyProperties != null) {
for (int i = 0; i < filterProperties.length; i++) {
filterCopyProperties[i].setValue(filterProperties[i].getValue());
}
}
if (parent == null) {
filterController.add(childQuery);
} else {
filterController.setSubQuery(parent, childQuery);
}
if (child.getChildrenSlotsCount() > 0) {
for (Query grandChild : child.getChildren()) {
duplicateQuery(filterController, childQuery, grandChild);
}
}
| 173
| 255
| 428
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopFilters/src/main/java/org/gephi/desktop/filters/query/RootNode.java
|
RootNode
|
getDropType
|
class RootNode extends AbstractNode {
public RootNode(Children children) {
super(children);
setName(NbBundle.getMessage(RootNode.class, "RootNode.name"));
setIconBaseWithExtension("DesktopFilters/queries.png");
}
@Override
public PasteType getDropType(Transferable t, int action, int index) {<FILL_FUNCTION_BODY>}
@Override
public Action[] getActions(boolean context) {
return new Action[0];
}
}
|
final Node dropNode = NodeTransfer.node(t, DnDConstants.ACTION_COPY_OR_MOVE);
if (t.isDataFlavorSupported(FilterBuilderNode.DATA_FLAVOR)) {
try {
final FilterBuilder fb = (FilterBuilder) t.getTransferData(FilterBuilderNode.DATA_FLAVOR);
return new PasteType() {
@Override
public Transferable paste() throws IOException {
FilterController filterController = Lookup.getDefault().lookup(FilterController.class);
Query f = filterController.createQuery(fb);
filterController.add(f);
return null;
}
};
} catch (Exception ex) {
Exceptions.printStackTrace(ex);
}
} else if (dropNode != null && dropNode instanceof SavedQueryNode) {
return new PasteType() {
@Override
public Transferable paste() throws IOException {
SavedQueryNode node = (SavedQueryNode) dropNode;
FilterController filterController = Lookup.getDefault().lookup(FilterController.class);
filterController.add(node.getQuery());
return null;
}
};
} else if (dropNode != null && dropNode instanceof QueryNode &&
((QueryNode) dropNode).getQuery().getParent() != null) {
return new PasteType() {
@Override
public Transferable paste() throws IOException {
QueryNode queryNode = (QueryNode) dropNode;
FilterController filterController = Lookup.getDefault().lookup(FilterController.class);
filterController.removeSubQuery(queryNode.getQuery(), queryNode.getQuery().getParent());
filterController.add(queryNode.getQuery());
return null;
}
};
}
return null;
| 136
| 452
| 588
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopFilters/src/main/java/org/gephi/desktop/filters/query/SlotNode.java
|
SlotNode
|
getDropType
|
class SlotNode extends AbstractNode {
private final Query parent;
public SlotNode(Query parent) {
super(Children.LEAF);
this.parent = parent;
setIconBaseWithExtension("DesktopFilters/drop.png");
setShortDescription(NbBundle.getMessage(SlotNode.class, "SlotNode.description"));
}
@Override
public String getHtmlDisplayName() {
return NbBundle.getMessage(SlotNode.class, "SlotNode.name");
}
@Override
public Action[] getActions(boolean context) {
return new Action[0];
}
@Override
public PasteType getDropType(final Transferable t, int action, int index) {<FILL_FUNCTION_BODY>}
}
|
final Node dropNode = NodeTransfer.node(t, DnDConstants.ACTION_COPY_OR_MOVE);
if (dropNode != null && dropNode instanceof QueryNode) {
Query q = ((QueryNode) dropNode).getQuery();
if (!Arrays.asList(q.getDescendantsAndSelf()).contains(parent)) { //Check if not parent
return new PasteType() {
@Override
public Transferable paste() throws IOException {
QueryNode queryNode = (QueryNode) dropNode;
FilterController filterController = Lookup.getDefault().lookup(FilterController.class);
filterController.setSubQuery(parent, queryNode.getQuery());
return null;
}
};
}
} else if (t.isDataFlavorSupported(FilterBuilderNode.DATA_FLAVOR)) {
return new PasteType() {
@Override
public Transferable paste() throws IOException {
try {
FilterBuilder builder = (FilterBuilder) t.getTransferData(FilterBuilderNode.DATA_FLAVOR);
FilterController filterController = Lookup.getDefault().lookup(FilterController.class);
Query query = filterController.createQuery(builder);
filterController.setSubQuery(parent, query);
} catch (UnsupportedFlavorException ex) {
Exceptions.printStackTrace(ex);
}
return null;
}
};
}
return null;
| 199
| 360
| 559
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopGenerate/src/main/java/org/gephi/desktop/generate/DesktopGeneratorController.java
|
DesktopGeneratorController
|
generate
|
class DesktopGeneratorController implements GeneratorController {
private final LongTaskExecutor executor;
public DesktopGeneratorController() {
executor = new LongTaskExecutor(true, "Generator");
}
@Override
public Generator[] getGenerators() {
return Lookup.getDefault().lookupAll(Generator.class).toArray(new Generator[0]);
}
@Override
public void generate(final Generator generator) {<FILL_FUNCTION_BODY>}
private void finishGenerate(Container container) {
container.closeLoader();
DefaultProcessor defaultProcessor = new DefaultProcessor();
defaultProcessor.setContainers(new ContainerUnloader[] {container.getUnloader()});
defaultProcessor.process();
}
}
|
String title = generator.getName();
GeneratorUI ui = generator.getUI();
if (ui != null) {
ui.setup(generator);
JPanel panel = ui.getPanel();
final DialogDescriptor dd = DialogDescriptorWithValidation.dialog(panel, title);
Object result = DialogDisplayer.getDefault().notify(dd);
if (result != NotifyDescriptor.OK_OPTION) {
return;
}
ui.unsetup();
}
final Container container = Lookup.getDefault().lookup(Container.Factory.class).newContainer();
container.setSource(generator.getName());
container.setReport(new Report());
String taskname = NbBundle
.getMessage(DesktopGeneratorController.class, "DesktopGeneratorController.taskname", generator.getName());
//Error handler
LongTaskErrorHandler errorHandler = new LongTaskErrorHandler() {
@Override
public void fatalError(Throwable t) {
Exceptions.printStackTrace(t);
}
};
//Execute
executor.execute(generator, new Runnable() {
@Override
public void run() {
generator.generate(container.getLoader());
finishGenerate(container);
}
}, taskname, errorHandler);
| 190
| 324
| 514
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopGenerate/src/main/java/org/gephi/desktop/generate/Generate.java
|
Generate
|
getMenuPresenter
|
class Generate extends CallableSystemAction {
@Override
public void performAction() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getName() {
return "generate";
}
@Override
public HelpCtx getHelpCtx() {
return null;
}
@Override
public JMenuItem getMenuPresenter() {<FILL_FUNCTION_BODY>}
}
|
JMenu menu = new JMenu(NbBundle.getMessage(Generate.class, "CTL_Generate"));
final GeneratorController generatorController = Lookup.getDefault().lookup(GeneratorController.class);
if (generatorController != null) {
for (final Generator gen : generatorController.getGenerators()) {
String menuName = gen.getName() + "...";
JMenuItem menuItem = new JMenuItem(new AbstractAction(menuName) {
@Override
public void actionPerformed(ActionEvent e) {
generatorController.generate(gen);
}
});
menu.add(menuItem);
}
}
return menu;
| 117
| 171
| 288
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopImport/src/main/java/org/gephi/desktop/importer/DesktopImportControllerUI.java
|
FinishImport
|
run
|
class FinishImport implements LongTask, Runnable {
private final List<Container> containers;
private final ImportErrorHandler errorHandler;
private ProgressTicket progressTicket;
public FinishImport(List<Container> containers, ImportErrorHandler errorHandler) {
this.containers = containers;
this.errorHandler = errorHandler;
}
@Override
public void run() {<FILL_FUNCTION_BODY>}
@Override
public boolean cancel() {
return false;
}
@Override
public void setProgressTicket(ProgressTicket progressTicket) {
this.progressTicket = progressTicket;
}
}
|
// If exceptions were thrown we show them in the processor panel
if (errorHandler != null) {
Report errorReport = errorHandler.closeAndGetReport();
if (errorHandler.countErrors() > 0) {
showProcessorIssues(errorReport);
return;
}
}
Report finalReport = new Report();
for (Container container : containers) {
if (container.verify()) {
Report report = container.getReport();
report.close();
finalReport.append(report);
} else {
//TODO
}
}
finalReport.close();
//Report panel
if (!containers.isEmpty()) {
ReportPanel reportPanel = new ReportPanel();
reportPanel.setData(finalReport, containers.toArray(new Container[0]));
DialogDescriptor dd = new DialogDescriptor(reportPanel,
NbBundle.getMessage(DesktopImportControllerUI.class, "ReportPanel.title"));
Object response = DialogDisplayer.getDefault().notify(dd);
reportPanel.destroy();
finalReport.clean();
for (Container c : containers) {
c.getReport().clean();
}
if (!response.equals(NotifyDescriptor.OK_OPTION)) {
return;
}
final Processor processor = reportPanel.getProcessor();
processor.setProgressTicket(progressTicket);
//Project
Workspace workspace = null;
ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);
if (pc.getCurrentProject() == null) {
Project project = pc.newProject();
workspace = project.getCurrentWorkspace();
}
//Process
final ProcessorUI pui = getProcessorUI(processor);
final ValidResult validResult = new ValidResult();
if (pui != null) {
try {
final JPanel panel = pui.getPanel();
if (panel != null) {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
String title = NbBundle.getMessage(DesktopImportControllerUI.class,
"DesktopImportControllerUI.processor.ui.dialog.title");
pui.setup(processor);
final DialogDescriptor dd2 = DialogDescriptorWithValidation.dialog(panel, title);
Object result = DialogDisplayer.getDefault().notify(dd2);
if (result.equals(NotifyDescriptor.CANCEL_OPTION) ||
result.equals(NotifyDescriptor.CLOSED_OPTION)) {
validResult.setResult(false);
} else {
pui.unsetup(); //true
validResult.setResult(true);
}
}
});
}
} catch (InterruptedException | InvocationTargetException ex) {
Exceptions.printStackTrace(ex);
}
}
if (validResult.isResult()) {
controller.process(containers.toArray(new Container[0]), processor, workspace);
Report report = processor.getReport();
if (report != null && !report.isEmpty()) {
showProcessorIssues(report);
}
//StatusLine notify
StatusDisplayer.getDefault().setStatusText(NbBundle
.getMessage(DesktopImportControllerUI.class,
"DesktopImportControllerUI.status.multiImportSuccess",
containers.size()));
}
}
| 171
| 853
| 1,024
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopImport/src/main/java/org/gephi/desktop/importer/EdgesMergeStrategyWrapper.java
|
EdgesMergeStrategyWrapper
|
equals
|
class EdgesMergeStrategyWrapper {
private final EdgeMergeStrategy instance;
public EdgesMergeStrategyWrapper(EdgeMergeStrategy instance) {
this.instance = instance;
}
public EdgeMergeStrategy getInstance() {
return instance;
}
@Override
public int hashCode() {
int hash = 7;
hash = 31 * hash + Objects.hashCode(this.instance);
return hash;
}
@Override
public boolean equals(Object obj) {<FILL_FUNCTION_BODY>}
@Override
public String toString() {
return NbBundle.getMessage(ReportPanel.class, "ReportPanel.mergeStrategy." + instance.name().toLowerCase(
Locale.US));
}
}
|
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final EdgesMergeStrategyWrapper other = (EdgesMergeStrategyWrapper) obj;
return this.instance == other.instance;
| 197
| 92
| 289
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopImport/src/main/java/org/gephi/desktop/importer/ImportDB.java
|
ImportDB
|
getMenuPresenter
|
class ImportDB extends CallableSystemAction {
@Override
public void performAction() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getName() {
return "importDB";
}
@Override
public HelpCtx getHelpCtx() {
return null;
}
@Override
public JMenuItem getMenuPresenter() {<FILL_FUNCTION_BODY>}
}
|
JMenu menu = new JMenu(NbBundle.getMessage(ImportDB.class, "CTL_ImportDB"));
final ImportControllerUI importController = Lookup.getDefault().lookup(ImportControllerUI.class);
if (importController != null) {
for (final DatabaseImporterBuilder dbb : Lookup.getDefault().lookupAll(DatabaseImporterBuilder.class)) {
ImporterUI ui = importController.getImportController().getUI(dbb.buildImporter());
String menuName = dbb.getName();
if (ui != null) {
menuName = ui.getDisplayName();
}
JMenuItem menuItem = new JMenuItem(new AbstractAction(menuName) {
@Override
public void actionPerformed(ActionEvent e) {
importController.importDatabase(dbb.buildImporter());
}
});
menu.add(menuItem);
}
}
return menu;
| 118
| 236
| 354
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopImport/src/main/java/org/gephi/desktop/importer/ImportWizard.java
|
ImportWizard
|
actionPerformed
|
class ImportWizard implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {<FILL_FUNCTION_BODY>}
}
|
WizardIterator wizardIterator = new WizardIterator();
WizardDescriptor wizardDescriptor = new WizardDescriptor(wizardIterator);
wizardDescriptor.setTitleFormat(new MessageFormat("{0} ({1})"));
wizardDescriptor.setTitle(NbBundle.getMessage(getClass(), "ImportWizard.wizard.title"));
Dialog dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor);
dialog.setVisible(true);
dialog.toFront();
boolean cancelled = wizardDescriptor.getValue() != WizardDescriptor.FINISH_OPTION;
if (!cancelled) {
ImporterWizardUI wizardUI = wizardIterator.getCurrentWizardUI();
//Get Importer
WizardImporter importer = null;
for (WizardImporterBuilder wizardBuilder : Lookup.getDefault().lookupAll(WizardImporterBuilder.class)) {
WizardImporter im = wizardBuilder.buildImporter();
if (wizardUI.isUIForImporter(im)) {
importer = im;
}
}
if (importer == null) {
NotifyDescriptor.Message msg = new NotifyDescriptor.Message(
NbBundle.getMessage(getClass(), "ImportWizard.error_no_matching_importer"),
NotifyDescriptor.WARNING_MESSAGE);
DialogDisplayer.getDefault().notify(msg);
return;
}
//Unsetup
wizardIterator.unsetupPanels(importer);
ImportControllerUI importControllerUI = Lookup.getDefault().lookup(ImportControllerUI.class);
importControllerUI.importWizard(importer);
}
| 41
| 422
| 463
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopImport/src/main/java/org/gephi/desktop/importer/WizardIterator.java
|
WizardIterator
|
previousPanel
|
class WizardIterator implements WizardDescriptor.Iterator {
private int index;
private WizardDescriptor.Panel[] originalPanels;
private WizardDescriptor.Panel[] panels;
private ImporterWizardUI currentWizardUI;
/**
* Initialize panels representing individual wizard's steps and sets various
* properties for them influencing wizard appearance.
*/
private WizardDescriptor.Panel[] getPanels() {
if (panels == null) {
panels = new WizardDescriptor.Panel[] {
new WizardPanel1(),
new WizardPanel2()
};
String[] steps = new String[panels.length];
for (int i = 0; i < panels.length; i++) {
Component c = panels[i].getComponent();
// Default step name to component name of panel.
steps[i] = c.getName();
if (c instanceof JComponent) { // assume Swing components
JComponent jc = (JComponent) c;
// Sets step number of a component
// TODO if using org.openide.dialogs >= 7.8, can use WizardDescriptor.PROP_*:
jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, i);
// Sets steps names for a panel
jc.putClientProperty("WizardPanel_contentData", steps);
// Turn on subtitle creation on each step
jc.putClientProperty("WizardPanel_autoWizardStyle", Boolean.TRUE);
// Show steps on the left side with the image on the background
jc.putClientProperty("WizardPanel_contentDisplayed", Boolean.TRUE);
// Turn on numbering of all steps
jc.putClientProperty("WizardPanel_contentNumbered", Boolean.TRUE);
}
}
originalPanels = panels;
}
return panels;
}
@Override
public WizardDescriptor.Panel current() {
WizardDescriptor.Panel p = getPanels()[index];
// if(p.getComponent() instanceof SetupablePanel){
// ((SetupablePanel)(p.getComponent())).setup
// (currentSpigotSupport.generateImporter());
// }
return p;
}
@Override
public String name() {
return index + 1 + ". from " + getPanels().length;
}
@Override
public boolean hasNext() {
return index < getPanels().length - 1;
}
@Override
public boolean hasPrevious() {
return index > 0;
}
@Override
public void nextPanel() {
if (!hasNext()) {
throw new NoSuchElementException();
}
//change panel if the current is the first panel
if (index == 0) {
for (ImporterWizardUI wizardUi : Lookup.getDefault().lookupAll(ImporterWizardUI.class)) {
WizardVisualPanel1 visual1 = ((WizardVisualPanel1) current().getComponent());
if (visual1.getCurrentCategory().equals(wizardUi.getCategory())
&& visual1.getCurrentWizard().equals(wizardUi.getDisplayName())) {
WizardDescriptor.Panel[] wizardPanels = wizardUi.getPanels();
WizardDescriptor.Panel tempFirstPanel = panels[0];
panels = new WizardDescriptor.Panel[wizardPanels.length + 1];
panels[0] = tempFirstPanel;
for (int i = 0; i < wizardPanels.length; i++) {
panels[i + 1] = wizardPanels[i];
wizardUi.setup(wizardPanels[i]);
}
currentWizardUI = wizardUi;
}
}
//
repaintLeftComponent();
}
index++;
}
/**
* ? might used for repainting
*/
private void repaintLeftComponent() {
String[] steps = new String[panels.length];
for (int i = 0; i < panels.length; i++) {
Component c = panels[i].getComponent();
// Default step name to component name of panel.
steps[i] = c.getName();
if (c instanceof JComponent) { // assume Swing components
JComponent jc = (JComponent) c;
// Sets step number of a component
// TODO if using org.openide.dialogs >= 7.8, can use WizardDescriptor.PROP_*:
jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, i);
// Sets steps names for a panel
jc.putClientProperty("WizardPanel_contentData", steps);
// Turn on subtitle creation on each step
jc.putClientProperty("WizardPanel_autoWizardStyle", Boolean.TRUE);
// Show steps on the left side with the image on the background
jc.putClientProperty("WizardPanel_contentDisplayed", Boolean.TRUE);
// Turn on numbering of all steps
jc.putClientProperty("WizardPanel_contentNumbered", Boolean.TRUE);
}
}
}
@Override
public void previousPanel() {<FILL_FUNCTION_BODY>}
// If nothing unusual changes in the middle of the wizard, simply:
@Override
public void addChangeListener(ChangeListener l) {
}
@Override
public void removeChangeListener(ChangeListener l) {
}
public ImporterWizardUI getCurrentWizardUI() {
return currentWizardUI;
}
void unsetupPanels(WizardImporter importer) {
for (int i = 1; i < panels.length; i++) {
currentWizardUI.unsetup(importer, panels[i]);
}
}
}
|
//change panel if the previous panel is the first
if (!hasPrevious()) {
throw new NoSuchElementException();
}
if (index == 1) {
panels = originalPanels;
repaintLeftComponent();
}
index--;
| 1,440
| 67
| 1,507
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopImport/src/main/java/org/gephi/desktop/importer/WizardPanel1.java
|
WizardPanel1
|
isValid
|
class WizardPanel1 implements WizardDescriptor.ValidatingPanel {
// public final void addChangeListener(ChangeListener l) {
// }
//
// public final void removeChangeListener(ChangeListener l) {
// }
private final Set<ChangeListener> listeners = new HashSet<>(1); // or can use ChangeSupport in NB 6.0
/**
* The visual component that displays this panel. If you need to access the
* component from this class, just use getComponent().
*/
private Component component;
// Get the visual component for the panel. In this template, the component
// is kept separate. This can be more efficient: if the wizard is created
// but never displayed, or not all panels are displayed, it is better to
// create only those which really need to be visible.
@Override
public Component getComponent() {
if (component == null) {
component = new WizardVisualPanel1();
this.addChangeListener((ChangeListener) component);
}
return component;
}
@Override
public HelpCtx getHelp() {
// Show no Help button for this panel:
return HelpCtx.DEFAULT_HELP;
// If you have context help:
// return new HelpCtx(SampleWizardPanel1.class);
}
@Override
public boolean isValid() {<FILL_FUNCTION_BODY>}
@Override
public final void addChangeListener(ChangeListener l) {
synchronized (listeners) {
listeners.add(l);
}
}
@Override
public final void removeChangeListener(ChangeListener l) {
synchronized (listeners) {
listeners.remove(l);
}
}
protected final void fireChangeEvent() {
Iterator<ChangeListener> it;
synchronized (listeners) {
it = new HashSet<>(listeners).iterator();
}
ChangeEvent ev = new ChangeEvent(this);
while (it.hasNext()) {
it.next().stateChanged(ev);
}
}
// You can use a settings object to keep track of state. Normally the
// settings object will be the WizardDescriptor, so you can use
// WizardDescriptor.getProperty & putProperty to store information entered
// by the user.
@Override
public void readSettings(Object settings) {
}
@Override
public void storeSettings(Object settings) {
}
@Override
public void validate() throws WizardValidationException {
if (!isValid()) {
throw new WizardValidationException(null, "Can't be empty.", null);
}
}
}
|
WizardVisualPanel1 panel = (WizardVisualPanel1) getComponent();
return !panel.emptyList();
// If it is always OK to press Next or Finish, then:
// If it depends on some condition (form filled out...), then:
// return someCondition();
// and when this condition changes (last form field filled in...) then:
// fireChangeEvent();
// and uncomment the complicated stuff below.
| 664
| 106
| 770
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopImport/src/main/java/org/gephi/desktop/importer/WizardPanel2.java
|
WizardPanel2
|
isValid
|
class WizardPanel2 implements WizardDescriptor.Panel {
/**
* The visual component that displays this panel. If you need to access the
* component from this class, just use getComponent().
*/
private Component component;
public WizardPanel2() {
super();
}
// Get the visual component for the panel. In this template, the component
// is kept separate. This can be more efficient: if the wizard is created
// but never displayed, or not all panels are displayed, it is better to
// create only those which really need to be visible.
@Override
public Component getComponent() {
if (component == null) {
component = new WizardVisualPanel2();
}
return component;
}
@Override
public HelpCtx getHelp() {
// Show no Help button for this panel:
return HelpCtx.DEFAULT_HELP;
// If you have context help:
// return new HelpCtx(SampleWizardPanel1.class);
}
@Override
public boolean isValid() {<FILL_FUNCTION_BODY>}
@Override
public final void addChangeListener(ChangeListener l) {
}
@Override
public final void removeChangeListener(ChangeListener l) {
}
/*
private final Set<ChangeListener> listeners = new HashSet<ChangeListener>(1); // or can use ChangeSupport in NB 6.0
public final void addChangeListener(ChangeListener l) {
synchronized (listeners) {
listeners.add(l);
}
}
public final void removeChangeListener(ChangeListener l) {
synchronized (listeners) {
listeners.remove(l);
}
}
protected final void fireChangeEvent() {
Iterator<ChangeListener> it;
synchronized (listeners) {
it = new HashSet<ChangeListener>(listeners).iterator();
}
ChangeEvent ev = new ChangeEvent(this);
while (it.hasNext()) {
it.next().stateChanged(ev);
}
}
*/
// You can use a settings object to keep track of state. Normally the
// settings object will be the WizardDescriptor, so you can use
// WizardDescriptor.getProperty & putProperty to store information entered
// by the user.
@Override
public void readSettings(Object settings) {
}
@Override
public void storeSettings(Object settings) {
}
}
|
// If it is always OK to press Next or Finish, then:
return true;
// If it depends on some condition (form filled out...), then:
// return someCondition();
// and when this condition changes (last form field filled in...) then:
// fireChangeEvent();
// and uncomment the complicated stuff below.
| 620
| 84
| 704
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopImport/src/main/java/org/gephi/desktop/importer/WizardVisualPanel2.java
|
WizardVisualPanel2
|
initComponents
|
class WizardVisualPanel2 extends JPanel {
public WizardVisualPanel2() {
initComponents();
}
@Override
public String getName() {
return "...";
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {<FILL_FUNCTION_BODY>}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
// End of variables declaration//GEN-END:variables
}
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 500, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 360, Short.MAX_VALUE)
);
| 204
| 145
| 349
|
<methods>public void <init>() ,public void <init>(java.awt.LayoutManager) ,public void <init>(boolean) ,public void <init>(java.awt.LayoutManager, boolean) ,public javax.accessibility.AccessibleContext getAccessibleContext() ,public javax.swing.plaf.PanelUI getUI() ,public java.lang.String getUIClassID() ,public void setUI(javax.swing.plaf.PanelUI) ,public void updateUI() <variables>private static final java.lang.String uiClassID
|
gephi_gephi
|
gephi/modules/DesktopLayout/src/main/java/org/gephi/desktop/layout/LayoutNode.java
|
LayoutNode
|
getPropertySets
|
class LayoutNode extends AbstractNode {
private final Layout layout;
private PropertySet[] propertySets;
public LayoutNode(Layout layout) {
super(Children.LEAF);
this.layout = layout;
setName(layout.getBuilder().getName());
}
@Override
public PropertySet[] getPropertySets() {<FILL_FUNCTION_BODY>}
public Layout getLayout() {
return layout;
}
}
|
if (propertySets == null) {
try {
Map<String, Sheet.Set> sheetMap = new HashMap<>();
for (LayoutProperty layoutProperty : layout.getProperties()) {
Sheet.Set set = sheetMap.get(layoutProperty.getCategory());
if (set == null) {
set = Sheet.createPropertiesSet();
set.setDisplayName(layoutProperty.getCategory());
sheetMap.put(layoutProperty.getCategory(), set);
}
set.put(layoutProperty.getProperty());
}
propertySets = sheetMap.values().toArray(new PropertySet[0]);
} catch (Exception ex) {
Exceptions.printStackTrace(ex);
return null;
}
}
return propertySets;
| 121
| 196
| 317
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopLayout/src/main/java/org/gephi/desktop/layout/LayoutTopComponent.java
|
LayoutTopComponent
|
writeProperties
|
class LayoutTopComponent extends TopComponent {
private final LayoutPanel layoutPanel;
private LayoutModel model;
public LayoutTopComponent() {
initComponents();
setName(NbBundle.getMessage(LayoutTopComponent.class, "CTL_LayoutTopComponent"));
putClientProperty(TopComponent.PROP_MAXIMIZATION_DISABLED, Boolean.TRUE);
layoutPanel = new LayoutPanel();
if (UIUtils.isAquaLookAndFeel()) {
layoutPanel.setBackground(UIManager.getColor("NbExplorerView.background"));
}
add(layoutPanel, BorderLayout.CENTER);
Lookup.getDefault().lookup(ProjectController.class).addWorkspaceListener(new WorkspaceListener() {
@Override
public void initialize(Workspace workspace) {
}
@Override
public void select(Workspace workspace) {
model = workspace.getLookup().lookup(LayoutModel.class);
refreshModel();
}
@Override
public void unselect(Workspace workspace) {
if (model != null) {
model.removePropertyChangeListener(layoutPanel);
}
}
@Override
public void close(Workspace workspace) {
}
@Override
public void disable() {
model = null;
refreshModel();
}
});
ProjectController projectController = Lookup.getDefault().lookup(ProjectController.class);
if (projectController.getCurrentWorkspace() != null) {
model = projectController.getCurrentWorkspace().getLookup().lookup(LayoutModel.class);
}
refreshModel();
}
private void refreshModel() {
layoutPanel.refreshModel(model);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
setLayout(new java.awt.BorderLayout());
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
// End of variables declaration//GEN-END:variables
void writeProperties(java.util.Properties p) {<FILL_FUNCTION_BODY>}
void readProperties(java.util.Properties p) {
String version = p.getProperty("version");
// TODO read your settings according to their version
}
}
|
// better to version settings since initial version as advocated at
// http://wiki.apidesign.org/wiki/PropertyFiles
p.setProperty("version", "1.0");
// TODO store your settings
| 670
| 55
| 725
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopPreview/src/main/java/org/gephi/desktop/preview/PresetUtils.java
|
PresetUtils
|
savePreset
|
class PresetUtils {
private List<PreviewPreset> presets;
public void savePreset(PreviewPreset preset) {<FILL_FUNCTION_BODY>}
public PreviewPreset[] getPresets() {
if (presets == null) {
presets = new ArrayList<>();
loadPresets();
}
return presets.toArray(new PreviewPreset[0]);
}
private void loadPresets() {
FileObject folder = FileUtil.getConfigFile("previewpresets");
if (folder != null) {
for (FileObject child : folder.getChildren()) {
if (child.isValid() && child.hasExt("xml")) {
try (InputStream stream = child.getInputStream()) {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(stream);
PreviewPreset preset = readXML(document);
addPreset(preset);
} catch (Exception ex) {
Exceptions.printStackTrace(ex);
}
}
}
}
}
private void writeXML(Document doc, PreviewPreset preset) {
Element presetE = doc.createElement("previewpreset");
presetE.setAttribute("name", preset.getName());
presetE.setAttribute("version", "0.8.1");
for (Entry<String, Object> entry : preset.getProperties().entrySet()) {
String propertyName = entry.getKey();
try {
Object propertyValue = entry.getValue();
if (propertyValue != null) {
String serialized = PreviewProperties.getValueAsText(propertyValue);
if (serialized != null) {
Element propertyE = doc.createElement("previewproperty");
propertyE.setAttribute("name", propertyName);
propertyE.setAttribute("class", propertyValue.getClass().getName());
propertyE.setTextContent(serialized);
presetE.appendChild(propertyE);
}
}
} catch (Exception ex) {
Exceptions.printStackTrace(ex);
}
}
doc.appendChild(presetE);
}
private PreviewPreset readXML(Document document) {
DefaultPreset defaultPreset =
new DefaultPreset();//For retrieving property class if it is not in the xml (old serialization)
Element presetE = document.getDocumentElement();
Map<String, Object> propertiesMap = new HashMap<>();
String presetName = presetE.getAttribute("name");
NodeList propertyList = presetE.getElementsByTagName("previewproperty");
for (int i = 0; i < propertyList.getLength(); i++) {
Node n = propertyList.item(i);
if (n.getNodeType() == Node.ELEMENT_NODE) {
Element propertyE = (Element) n;
String name = propertyE.getAttribute("name");
String valueClassName = propertyE.hasAttribute(name) ? propertyE.getAttribute("class") : null;
String stringValue = propertyE.getTextContent();
Class valueClass = null;
if (valueClassName != null) {
try {
valueClass = Class.forName(valueClassName);
} catch (ClassNotFoundException ex) {
Exceptions.printStackTrace(ex);
}
} else {
Object defaultValue = defaultPreset.getProperties().get(name);
if (defaultValue != null) {
valueClass = defaultValue.getClass();
}
}
if (valueClass != null) {
Object value = PreviewProperties.readValueFromText(stringValue, valueClass);
if (value != null) {
propertiesMap.put(name, value);
}
}
}
}
return new PreviewPreset(presetName, propertiesMap);
}
protected void addPreset(PreviewPreset preset) {
presets.add(preset);
}
}
|
int exist = -1;
for (int i = 0; i < presets.size(); i++) {
PreviewPreset p = presets.get(i);
if (p.getName().equals(preset.getName())) {
exist = i;
break;
}
}
if (exist == -1) {
addPreset(preset);
} else {
presets.set(exist, preset);
}
try {
//Create file if dont exist
FileObject folder = FileUtil.getConfigFile("previewpresets");
if (folder == null) {
folder = FileUtil.getConfigRoot().createFolder("previewpresets");
}
String filename = DigestUtils.sha1Hex(preset.getName());//Safe filename
FileObject presetFile = folder.getFileObject(filename, "xml");
if (presetFile == null) {
presetFile = folder.createData(filename, "xml");
}
//Create doc
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = factory.newDocumentBuilder();
final Document document = documentBuilder.newDocument();
document.setXmlVersion("1.0");
document.setXmlStandalone(true);
//Write doc
writeXML(document, preset);
//Write XML file
try (OutputStream outputStream = presetFile.getOutputStream()) {
Source source = new DOMSource(document);
Result result = new StreamResult(outputStream);
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
transformer.transform(source, result);
}
} catch (Exception ex) {
Exceptions.printStackTrace(ex);
}
| 1,019
| 473
| 1,492
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopPreview/src/main/java/org/gephi/desktop/preview/PreviewNode.java
|
PreviewNode
|
createSheet
|
class PreviewNode extends AbstractNode implements PropertyChangeListener {
private final PropertySheet propertySheet;
public PreviewNode(PropertySheet propertySheet) {
super(Children.LEAF);
this.propertySheet = propertySheet;
setDisplayName(NbBundle.getMessage(PreviewNode.class, "PreviewNode.displayName"));
}
@Override
protected Sheet createSheet() {<FILL_FUNCTION_BODY>}
/**
* default method for PropertyChangeListener, it is necessary to fire property change to update propertyEditor, which will refresh at runtime if a property value has been passively updated.
*
* @param pce a PropertyChangeEvent from a PreviewProperty object.
*/
@Override
public void propertyChange(PropertyChangeEvent pce) {
firePropertyChange(pce.getPropertyName(), pce.getOldValue(), pce.getNewValue());
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
propertySheet.updateUI();
}
});
}
private static class PreviewPropertyWrapper extends PropertySupport.ReadWrite {
private final PreviewProperty property;
public PreviewPropertyWrapper(PreviewProperty previewProperty) {
super(previewProperty.getName(), previewProperty.getType(), previewProperty.getDisplayName(),
previewProperty.getDescription());
this.property = previewProperty;
}
@Override
public Object getValue() throws IllegalAccessException, InvocationTargetException {
return property.getValue();
}
@Override
public void setValue(Object t)
throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
property.setValue(t);
}
}
private static class ChildPreviewPropertyWrapper extends PropertySupport.ReadWrite {
private final PreviewProperty property;
private final PreviewProperty[] parents;
public ChildPreviewPropertyWrapper(PreviewProperty previewProperty, PreviewProperty[] parents) {
super(previewProperty.getName(), previewProperty.getType(), previewProperty.getDisplayName(),
previewProperty.getDescription());
this.property = previewProperty;
this.parents = parents;
}
@Override
public Object getValue() throws IllegalAccessException, InvocationTargetException {
return property.getValue();
}
@Override
public void setValue(Object t)
throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
property.setValue(t);
}
@Override
public boolean canWrite() {
for (PreviewProperty parent : parents) {
if (parent.getType().equals(Boolean.class) && parent.getValue().equals(Boolean.FALSE)) {
return false;
}
}
return true;
}
}
private class ParentPreviewPropertyWrapper extends PropertySupport.ReadWrite {
private final PreviewProperty property;
private final PreviewProperty[] children;
public ParentPreviewPropertyWrapper(PreviewProperty previewProperty, PreviewProperty[] children) {
super(previewProperty.getName(), previewProperty.getType(), previewProperty.getDisplayName(),
previewProperty.getDescription());
this.property = previewProperty;
this.children = children;
}
@Override
public Object getValue() throws IllegalAccessException, InvocationTargetException {
return property.getValue();
}
@Override
public void setValue(Object t)
throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
property.setValue(t);
for (PreviewProperty p : children) {
propertyChange(new PropertyChangeEvent(this, p.getName(), p.getValue(), p.getValue()));
}
}
}
}
|
Sheet sheet = Sheet.createDefault();
PreviewController controller = Lookup.getDefault().lookup(PreviewController.class);
Set<Renderer> enabledRenderers = null;
if (controller.getModel() != null && controller.getModel().getManagedRenderers() != null) {
enabledRenderers = new HashSet<>();
for (ManagedRenderer mr : controller.getModel().getManagedRenderers()) {
if (mr.isEnabled()) {
enabledRenderers.add(mr.getRenderer());
}
}
}
PreviewModel model = controller.getModel();
if (model != null) {
PreviewProperties properties = model.getProperties();
Map<String, Sheet.Set> sheetSets = new HashMap<>();
for (PreviewProperty property : properties.getProperties()) {
Object source = property.getSource();
boolean propertyEnabled = true;
if (source instanceof Renderer) {
propertyEnabled = enabledRenderers == null || enabledRenderers.contains((Renderer) source);
}
if (propertyEnabled) {
String category = property.getCategory();
Sheet.Set sheetSet = sheetSets.get(category);
if (sheetSet == null) {
sheetSet = Sheet.createPropertiesSet();
sheetSet.setDisplayName(category);
sheetSet.setName(category);
}
Node.Property nodeProperty = null;
PreviewProperty[] parents = properties.getParentProperties(property);
PreviewProperty[] children = properties.getChildProperties(property);
if (parents.length > 0) {
nodeProperty = new ChildPreviewPropertyWrapper(property, parents);
} else if (children.length > 0) {
nodeProperty = new ParentPreviewPropertyWrapper(property, children);
} else {
nodeProperty = new PreviewPropertyWrapper(property);
}
sheetSet.put(nodeProperty);
sheetSets.put(category, sheetSet);
}
}
//Ordered
Sheet.Set nodeSet = sheetSets.remove(PreviewProperty.CATEGORY_NODES);
Sheet.Set nodeLabelSet = sheetSets.remove(PreviewProperty.CATEGORY_NODE_LABELS);
Sheet.Set edgeSet = sheetSets.remove(PreviewProperty.CATEGORY_EDGES);
Sheet.Set arrowsSet = sheetSets.remove(PreviewProperty.CATEGORY_EDGE_ARROWS);
Sheet.Set edgeLabelSet = sheetSets.remove(PreviewProperty.CATEGORY_EDGE_LABELS);
if (nodeSet != null) {
sheet.put(nodeSet);
}
if (nodeLabelSet != null) {
sheet.put(nodeLabelSet);
}
if (edgeSet != null) {
sheet.put(edgeSet);
}
if (arrowsSet != null) {
sheet.put(arrowsSet);
}
if (edgeLabelSet != null) {
sheet.put(edgeLabelSet);
}
for (Sheet.Set sheetSet : sheetSets.values()) {
sheet.put(sheetSet);
}
}
return sheet;
| 927
| 822
| 1,749
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopPreview/src/main/java/org/gephi/desktop/preview/PreviewSketch.java
|
RefreshLoop
|
run
|
class RefreshLoop {
private final long DELAY = 100;
private final AtomicBoolean running = new AtomicBoolean();
private final AtomicBoolean refresh = new AtomicBoolean();
//Timer
private long timeout = DELAY * 10;
private Timer timer;
public RefreshLoop() {
super();
}
public void refreshSketch() {
refresh.set(true);
if (!running.getAndSet(true)) {
startTimer();
}
}
private void startTimer() {
timer = new Timer("PreviewRefreshLoop", true);
timer.schedule(new TimerTask() {
@Override
public void run() {<FILL_FUNCTION_BODY>}
}, 0, DELAY);
}
private void stopTimer() {
timer.cancel();
running.set(false);
}
}
|
if (refresh.getAndSet(false)) {
target.refresh();
repaint();
} else if (timeout == 0) {
timeout = DELAY * 10;
stopTimer();
} else {
timeout -= DELAY;
}
| 231
| 72
| 303
|
<methods>public void <init>() ,public void <init>(java.awt.LayoutManager) ,public void <init>(boolean) ,public void <init>(java.awt.LayoutManager, boolean) ,public javax.accessibility.AccessibleContext getAccessibleContext() ,public javax.swing.plaf.PanelUI getUI() ,public java.lang.String getUIClassID() ,public void setUI(javax.swing.plaf.PanelUI) ,public void updateUI() <variables>private static final java.lang.String uiClassID
|
gephi_gephi
|
gephi/modules/DesktopPreview/src/main/java/org/gephi/desktop/preview/PreviewUIControllerImpl.java
|
PreviewUIControllerImpl
|
refreshPreview
|
class PreviewUIControllerImpl implements PreviewUIController {
private final List<PropertyChangeListener> listeners;
private final PreviewController previewController;
private final GraphController graphController;
private final PresetUtils presetUtils = new PresetUtils();
private PreviewUIModelImpl model = null;
private GraphModel graphModel = null;
public PreviewUIControllerImpl() {
previewController = Lookup.getDefault().lookup(PreviewController.class);
listeners = new ArrayList<>();
ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);
graphController = Lookup.getDefault().lookup(GraphController.class);
pc.addWorkspaceListener(new WorkspaceListener() {
@Override
public void initialize(Workspace workspace) {
PreviewModel previewModel = previewController.getModel(workspace);
if (workspace.getLookup().lookup(PreviewUIModelImpl.class) == null) {
workspace.add(new PreviewUIModelImpl(previewModel));
}
enableRefresh();
}
@Override
public void select(Workspace workspace) {
graphModel = graphController.getGraphModel(workspace);
PreviewModel previewModel = previewController.getModel(workspace);
model = workspace.getLookup().lookup(PreviewUIModelImpl.class);
if (model == null) {
model = new PreviewUIModelImpl(previewModel);
workspace.add(model);
}
Float visibilityRatio = previewModel.getProperties().getFloatValue(PreviewProperty.VISIBILITY_RATIO);
model.setVisibilityRatio(visibilityRatio);
fireEvent(SELECT, model);
}
@Override
public void unselect(Workspace workspace) {
if (graphModel != null) {
graphModel = null;
}
fireEvent(UNSELECT, model);
}
@Override
public void close(Workspace workspace) {
}
@Override
public void disable() {
if (graphModel != null) {
graphModel = null;
}
fireEvent(SELECT, null);
model = null;
}
});
if (pc.getCurrentWorkspace() != null) {
model = pc.getCurrentWorkspace().getLookup().lookup(PreviewUIModelImpl.class);
if (model == null) {
PreviewModel previewModel = previewController.getModel(pc.getCurrentWorkspace());
model = new PreviewUIModelImpl(previewModel);
pc.getCurrentWorkspace().add(model);
}
Float visibilityRatio =
previewController.getModel().getProperties().getFloatValue(PreviewProperty.VISIBILITY_RATIO);
if (visibilityRatio != null) {
model.setVisibilityRatio(visibilityRatio);
}
graphModel = graphController.getGraphModel(pc.getCurrentWorkspace());
}
//Register editors
//Overriding default Preview API basic editors that don't support CustomEditor
PropertyEditorManager.registerEditor(EdgeColor.class, EdgeColorPropertyEditor.class);
PropertyEditorManager.registerEditor(DependantOriginalColor.class, DependantOriginalColorPropertyEditor.class);
PropertyEditorManager.registerEditor(DependantColor.class, DependantColorPropertyEditor.class);
}
/**
* Refreshes the preview applet.
*/
@Override
public void refreshPreview() {<FILL_FUNCTION_BODY>}
/**
* Enables the preview refresh action.
*/
private void enableRefresh() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
PreviewSettingsTopComponent pstc = (PreviewSettingsTopComponent) WindowManager.getDefault()
.findTopComponent("PreviewSettingsTopComponent");
if (pstc != null) {
pstc.enableRefreshButton();
}
}
});
}
@Override
public void setVisibilityRatio(float visibilityRatio) {
if (model != null) {
model.setVisibilityRatio(visibilityRatio);
}
}
@Override
public PreviewUIModel getModel() {
return model;
}
@Override
public PreviewPreset[] getDefaultPresets() {
return new PreviewPreset[] {new DefaultPreset(), new DefaultCurved(), new DefaultStraight(), new TextOutline(),
new BlackBackground(), new EdgesCustomColor(), new TagCloud()};
}
@Override
public PreviewPreset[] getUserPresets() {
PreviewPreset[] presetsArray = presetUtils.getPresets();
Arrays.sort(presetsArray);
return presetsArray;
}
@Override
public void setCurrentPreset(PreviewPreset preset) {
if (model != null) {
model.setCurrentPreset(preset);
PreviewModel previewModel = previewController.getModel();
previewModel.getProperties().applyPreset(preset);
}
}
@Override
public void addPreset(PreviewPreset preset) {
presetUtils.savePreset(preset);
}
@Override
public void savePreset(String name) {
if (model != null) {
PreviewModel previewModel = previewController.getModel();
Map<String, Object> map = new HashMap<>();
for (PreviewProperty p : previewModel.getProperties().getProperties()) {
map.put(p.getName(), p.getValue());
}
for (Entry<String, Object> p : previewModel.getProperties().getSimpleValues()) {
map.put(p.getKey(), p.getValue());
}
PreviewPreset preset = new PreviewPreset(name, map);
presetUtils.savePreset(preset);
model.setCurrentPreset(preset);
}
}
@Override
public void addPropertyChangeListener(PropertyChangeListener listener) {
if (!listeners.contains(listener)) {
listeners.add(listener);
}
}
@Override
public void removePropertyChangeListener(PropertyChangeListener listener) {
listeners.remove(listener);
}
private void fireEvent(String eventName, Object data) {
PropertyChangeEvent event = new PropertyChangeEvent(this, eventName, null, data);
for (PropertyChangeListener l : listeners) {
l.propertyChange(event);
}
}
}
|
if (model != null) {
Thread refreshThread = new Thread(new Runnable() {
@Override
public void run() {
model.setRefreshing(true);
fireEvent(REFRESHING, true);
previewController.getModel().getProperties()
.putValue(PreviewProperty.VISIBILITY_RATIO, model.getVisibilityRatio());
previewController.refreshPreview();
fireEvent(REFRESHED, model);
model.setRefreshing(false);
fireEvent(REFRESHING, false);
}
}, "Refresh Preview");
refreshThread.start();
}
| 1,673
| 170
| 1,843
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopPreview/src/main/java/org/gephi/desktop/preview/PreviewUIModelImpl.java
|
PreviewUIModelImpl
|
readXML
|
class PreviewUIModelImpl implements PreviewUIModel {
private final PreviewModel previewModel;
//Data
private float visibilityRatio = 1f;
private PreviewPreset currentPreset;
private boolean refreshing;
public PreviewUIModelImpl(PreviewModel model) {
previewModel = model;
if (UIUtils.isDarkLookAndFeel()) {
currentPreset = new BlackBackground();
} else {
currentPreset = new DefaultPreset();
}
model.getProperties().applyPreset(currentPreset);
}
@Override
public PreviewModel getPreviewModel() {
return previewModel;
}
@Override
public Workspace getWorkspace() {
return previewModel.getWorkspace();
}
@Override
public PreviewPreset getCurrentPreset() {
return currentPreset;
}
public void setCurrentPreset(PreviewPreset preset) {
currentPreset = preset;
}
@Override
public float getVisibilityRatio() {
return visibilityRatio;
}
public void setVisibilityRatio(float visibilityRatio) {
this.visibilityRatio = visibilityRatio;
}
@Override
public boolean isRefreshing() {
return refreshing;
}
public void setRefreshing(boolean refreshing) {
this.refreshing = refreshing;
}
private void setCurrentPresetBasedOnString(String className, String displayName) {
// Retrieve preset, either default (by class) or user (by name)
PreviewUIController controller = Lookup.getDefault().lookup(PreviewUIController.class);
PreviewPreset[] defaultPresets = controller.getDefaultPresets();
Optional<PreviewPreset> preset =
Arrays.stream(defaultPresets).filter(p -> p.getClass().getName().equals(className)).findFirst();
if (preset.isPresent()) {
setCurrentPreset(preset.get());
} else {
PreviewPreset[] userPresets = controller.getUserPresets();
preset = Arrays.stream(userPresets).filter(p -> p.getName().equals(displayName)).findFirst();
preset.ifPresent(this::setCurrentPreset);
}
}
protected void writeXML(XMLStreamWriter writer) throws XMLStreamException {
if (currentPreset != null) {
writer.writeStartElement("currentpreset");
writer.writeAttribute("class", currentPreset.getClass().getName());
writer.writeAttribute("name", currentPreset.getName());
writer.writeEndElement();
}
writer.writeStartElement("visibilityratio");
writer.writeAttribute("value", visibilityRatio + "");
writer.writeEndElement();
}
protected void readXML(XMLStreamReader reader) throws XMLStreamException {<FILL_FUNCTION_BODY>}
}
|
boolean end = false;
while (reader.hasNext() && !end) {
int type = reader.next();
switch (type) {
case XMLStreamReader.START_ELEMENT:
String name = reader.getLocalName();
if ("currentpreset".equalsIgnoreCase(name)) {
String presetClass = reader.getAttributeValue(null, "class");
String presetName = reader.getAttributeValue(null, "name");
setCurrentPresetBasedOnString(presetClass, presetName);
} else if ("visibilityratio".equalsIgnoreCase(name)) {
String value = reader.getAttributeValue(null, "value");
visibilityRatio = Float.parseFloat(value);
}
break;
case XMLStreamReader.CHARACTERS:
break;
case XMLStreamReader.END_ELEMENT:
if ("previewuimodel".equalsIgnoreCase(reader.getLocalName())) {
end = true;
}
break;
}
}
| 746
| 255
| 1,001
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopPreview/src/main/java/org/gephi/desktop/preview/PreviewUIPersistenceProvider.java
|
PreviewUIPersistenceProvider
|
readXML
|
class PreviewUIPersistenceProvider implements WorkspaceXMLPersistenceProvider {
@Override
public void writeXML(XMLStreamWriter writer, Workspace workspace) {
PreviewUIModelImpl model = workspace.getLookup().lookup(PreviewUIModelImpl.class);
if (model != null) {
try {
model.writeXML(writer);
} catch (XMLStreamException ex) {
throw new RuntimeException(ex);
}
}
}
@Override
public void readXML(XMLStreamReader reader, Workspace workspace) {<FILL_FUNCTION_BODY>}
@Override
public String getIdentifier() {
return "previewuimodel";
}
}
|
PreviewUIModelImpl model = workspace.getLookup().lookup(PreviewUIModelImpl.class);
PreviewModel previewModel = workspace.getLookup().lookup(PreviewModel.class);
if (previewModel == null) {
PreviewController previewController = Lookup.getDefault().lookup(PreviewController.class);
previewModel = previewController.getModel(workspace);
}
if (model == null) {
model = new PreviewUIModelImpl(previewModel);
workspace.add(model);
}
try {
model.readXML(reader);
} catch (XMLStreamException ex) {
throw new RuntimeException(ex);
}
| 184
| 180
| 364
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopPreview/src/main/java/org/gephi/desktop/preview/propertyeditors/DependantColorPanel.java
|
DependantColorPanel
|
initComponents
|
class DependantColorPanel extends javax.swing.JPanel implements ItemListener {
private DependantColorPropertyEditor propertyEditor;
// Variables declaration - do not modify
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.JButton colorButton;
private javax.swing.JRadioButton customRadio;
private javax.swing.JRadioButton darkerButton;
private org.jdesktop.swingx.JXHeader jXHeader1;
private javax.swing.JRadioButton parentRadio;
// End of variables declaration
/**
* Creates new form DependantColorPanel
*/
public DependantColorPanel() {
initComponents();
colorButton.addPropertyChangeListener(JColorButton.EVENT_COLOR, new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
Color newColor = (Color) evt.getNewValue();
propertyEditor.setValue(new DependantColor(newColor));
}
});
parentRadio.addItemListener(this);
customRadio.addItemListener(this);
darkerButton.addItemListener(this);
}
@Override
public void itemStateChanged(ItemEvent e) {
if(e.getStateChange() == ItemEvent.SELECTED) {
colorButton.setEnabled(customRadio.isSelected());
DependantColor.Mode selectedMode = null;
if (parentRadio.isSelected()) {
selectedMode = DependantColor.Mode.PARENT;
} else if (customRadio.isSelected()) {
selectedMode = DependantColor.Mode.CUSTOM;
} else if (darkerButton.isSelected()) {
selectedMode = DependantColor.Mode.DARKER;
}
propertyEditor.setValue(new DependantColor(selectedMode));
}
}
public void setup(DependantColorPropertyEditor propertyEditor) {
this.propertyEditor = propertyEditor;
DependantColor dependantColor = (DependantColor) propertyEditor.getValue();
switch (dependantColor.getMode()) {
case CUSTOM:
customRadio.setSelected(true);
((JColorButton) colorButton).setColor(dependantColor.getCustomColor());
break;
case PARENT:
parentRadio.setSelected(true);
break;
case DARKER:
darkerButton.setSelected(true);
break;
default:
break;
}
}
/**
* This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {<FILL_FUNCTION_BODY>}// </editor-fold>
}
|
buttonGroup1 = new javax.swing.ButtonGroup();
colorButton = new JColorButton(Color.BLACK);
customRadio = new javax.swing.JRadioButton();
parentRadio = new javax.swing.JRadioButton();
jXHeader1 = new org.jdesktop.swingx.JXHeader();
darkerButton = new javax.swing.JRadioButton();
buttonGroup1.add(customRadio);
customRadio.setText(org.openide.util.NbBundle.getMessage(DependantColorPanel.class, "DependantColorPanel.customRadio.text")); // NOI18N
buttonGroup1.add(parentRadio);
parentRadio.setText(org.openide.util.NbBundle.getMessage(DependantColorPanel.class, "DependantColorPanel.parentRadio.text")); // NOI18N
jXHeader1.setDescription(org.openide.util.NbBundle.getMessage(DependantColorPanel.class, "DependantColorPanel.jXHeader1.description")); // NOI18N
jXHeader1.setTitle(org.openide.util.NbBundle.getMessage(DependantColorPanel.class, "DependantColorPanel.jXHeader1.title")); // NOI18N
buttonGroup1.add(darkerButton);
darkerButton.setText(org.openide.util.NbBundle.getMessage(DependantColorPanel.class, "DependantColorPanel.darkerButton.text")); // NOI18N
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jXHeader1, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(customRadio)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(colorButton))
.addComponent(parentRadio)
.addComponent(darkerButton))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jXHeader1, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(parentRadio)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(darkerButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(customRadio)
.addComponent(colorButton))
.addContainerGap(22, Short.MAX_VALUE))
);
| 742
| 877
| 1,619
|
<methods>public void <init>() ,public void <init>(java.awt.LayoutManager) ,public void <init>(boolean) ,public void <init>(java.awt.LayoutManager, boolean) ,public javax.accessibility.AccessibleContext getAccessibleContext() ,public javax.swing.plaf.PanelUI getUI() ,public java.lang.String getUIClassID() ,public void setUI(javax.swing.plaf.PanelUI) ,public void updateUI() <variables>private static final java.lang.String uiClassID
|
gephi_gephi
|
gephi/modules/DesktopPreview/src/main/java/org/gephi/desktop/preview/propertyeditors/DependantOriginalColorPanel.java
|
DependantOriginalColorPanel
|
initComponents
|
class DependantOriginalColorPanel extends javax.swing.JPanel implements ItemListener {
private DependantOriginalColorPropertyEditor propertyEditor;
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.JButton colorButton;
private javax.swing.JRadioButton customRadio;
private org.jdesktop.swingx.JXHeader jXHeader1;
private javax.swing.JRadioButton originalRadio;
private javax.swing.JRadioButton parentRadio;
// End of variables declaration//GEN-END:variables
/**
* Creates new form DependantOriginalColorPanel
*/
public DependantOriginalColorPanel() {
initComponents();
colorButton.addPropertyChangeListener(JColorButton.EVENT_COLOR, new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
Color newColor = (Color) evt.getNewValue();
propertyEditor.setValue(new DependantOriginalColor(newColor));
}
});
originalRadio.addItemListener(this);
parentRadio.addItemListener(this);
customRadio.addItemListener(this);
}
@Override
public void itemStateChanged(ItemEvent e) {
if(e.getStateChange() == ItemEvent.SELECTED) {
colorButton.setEnabled(customRadio.isSelected());
DependantOriginalColor.Mode selectedMode = null;
if (originalRadio.isSelected()) {
selectedMode = DependantOriginalColor.Mode.ORIGINAL;
} else if (parentRadio.isSelected()) {
selectedMode = DependantOriginalColor.Mode.PARENT;
} else if (customRadio.isSelected()) {
selectedMode = DependantOriginalColor.Mode.CUSTOM;
}
propertyEditor.setValue(new DependantOriginalColor(selectedMode));
}
}
public void setup(DependantOriginalColorPropertyEditor propertyEditor) {
this.propertyEditor = propertyEditor;
DependantOriginalColor dependantOriginalColor = (DependantOriginalColor) propertyEditor.getValue();
if (dependantOriginalColor.getMode().equals(DependantOriginalColor.Mode.CUSTOM)) {
customRadio.setSelected(true);
((JColorButton) colorButton).setColor(dependantOriginalColor.getCustomColor());
} else if (dependantOriginalColor.getMode().equals(DependantOriginalColor.Mode.ORIGINAL)) {
originalRadio.setSelected(true);
} else if (dependantOriginalColor.getMode().equals(DependantOriginalColor.Mode.PARENT)) {
parentRadio.setSelected(true);
}
}
/**
* This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {<FILL_FUNCTION_BODY>}// </editor-fold>//GEN-END:initComponents
}
|
buttonGroup1 = new javax.swing.ButtonGroup();
jXHeader1 = new org.jdesktop.swingx.JXHeader();
colorButton = new JColorButton(Color.BLACK, false, true);
customRadio = new javax.swing.JRadioButton();
originalRadio = new javax.swing.JRadioButton();
parentRadio = new javax.swing.JRadioButton();
jXHeader1.setDescription(org.openide.util.NbBundle.getMessage(DependantOriginalColorPanel.class,
"DependantOriginalColorPanel.jXHeader1.description")); // NOI18N
jXHeader1.setTitle(org.openide.util.NbBundle
.getMessage(DependantOriginalColorPanel.class, "DependantOriginalColorPanel.jXHeader1.title")); // NOI18N
buttonGroup1.add(customRadio);
customRadio.setText(org.openide.util.NbBundle
.getMessage(DependantOriginalColorPanel.class, "DependantOriginalColorPanel.customRadio.text")); // NOI18N
buttonGroup1.add(originalRadio);
originalRadio.setText(org.openide.util.NbBundle
.getMessage(DependantOriginalColorPanel.class, "DependantOriginalColorPanel.originalRadio.text")); // NOI18N
buttonGroup1.add(parentRadio);
parentRadio.setText(org.openide.util.NbBundle
.getMessage(DependantOriginalColorPanel.class, "DependantOriginalColorPanel.parentRadio.text")); // NOI18N
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(originalRadio)
.addContainerGap(360, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(parentRadio)
.addContainerGap(365, Short.MAX_VALUE))
.addComponent(jXHeader1, javax.swing.GroupLayout.DEFAULT_SIZE, 435, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(customRadio)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(colorButton)
.addContainerGap(326, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jXHeader1, javax.swing.GroupLayout.PREFERRED_SIZE, 77,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(originalRadio)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(parentRadio)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(customRadio)
.addComponent(colorButton))
.addGap(47, 47, 47))
);
| 812
| 934
| 1,746
|
<methods>public void <init>() ,public void <init>(java.awt.LayoutManager) ,public void <init>(boolean) ,public void <init>(java.awt.LayoutManager, boolean) ,public javax.accessibility.AccessibleContext getAccessibleContext() ,public javax.swing.plaf.PanelUI getUI() ,public java.lang.String getUIClassID() ,public void setUI(javax.swing.plaf.PanelUI) ,public void updateUI() <variables>private static final java.lang.String uiClassID
|
gephi_gephi
|
gephi/modules/DesktopProject/src/main/java/org/gephi/desktop/project/Installer.java
|
Installer
|
closing
|
class Installer extends ModuleInstall {
@Override
public void restored() {
ProjectControllerUIImpl projectControllerUI = Lookup.getDefault().lookup(ProjectControllerUIImpl.class);
projectControllerUI.loadProjects();
}
@Override
public boolean closing() {<FILL_FUNCTION_BODY>}
}
|
ProjectControllerUIImpl projectControllerUI = Lookup.getDefault().lookup(ProjectControllerUIImpl.class);
if (Lookup.getDefault().lookup(ProjectController.class).getCurrentProject() == null) {
//Close directly if no project open
projectControllerUI.saveProjects();
return true;
}
boolean res = projectControllerUI.closeCurrentProject();
if (res) {
projectControllerUI.saveProjects();
}
return res;
| 87
| 123
| 210
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopProject/src/main/java/org/gephi/desktop/project/actions/DeleteOtherWorkspaces.java
|
DeleteOtherWorkspaces
|
actionPerformed
|
class DeleteOtherWorkspaces extends AbstractAction {
DeleteOtherWorkspaces() {
super(NbBundle.getMessage(DeleteOtherWorkspaces.class, "CTL_DeleteOtherWorkspaces"));
}
@Override
public void actionPerformed(ActionEvent ev) {<FILL_FUNCTION_BODY>}
@Override
public boolean isEnabled() {
return Lookup.getDefault().lookup(ProjectControllerUIImpl.class).canDeleteWorkspace();
}
}
|
if (isEnabled()) {
ProjectControllerUIImpl cui = Lookup.getDefault().lookup(ProjectControllerUIImpl.class);
Workspace workspace;
if (ev.getSource() != null && ev.getSource() instanceof Workspace) {
workspace = (Workspace) ev.getSource();
} else {
workspace = cui.getCurrentProject().getCurrentWorkspace();
}
if (workspace != null) {
List<Workspace> workspaces = new ArrayList<>(cui.getCurrentProject().getWorkspaces());
workspaces.remove(workspace);
if (!workspaces.isEmpty()) {
cui.deleteWorkspaces(workspaces);
}
}
}
| 121
| 184
| 305
|
<methods>public void <init>() ,public void <init>(java.lang.String) ,public void <init>(java.lang.String, javax.swing.Icon) ,public synchronized void addPropertyChangeListener(java.beans.PropertyChangeListener) ,public java.lang.Object[] getKeys() ,public synchronized java.beans.PropertyChangeListener[] getPropertyChangeListeners() ,public java.lang.Object getValue(java.lang.String) ,public boolean isEnabled() ,public void putValue(java.lang.String, java.lang.Object) ,public synchronized void removePropertyChangeListener(java.beans.PropertyChangeListener) ,public void setEnabled(boolean) <variables>private static java.lang.Boolean RECONFIGURE_ON_NULL,private transient javax.swing.ArrayTable arrayTable,protected javax.swing.event.SwingPropertyChangeSupport changeSupport,protected boolean enabled
|
gephi_gephi
|
gephi/modules/DesktopProject/src/main/java/org/gephi/desktop/project/actions/DeleteWorkspace.java
|
DeleteWorkspace
|
actionPerformed
|
class DeleteWorkspace extends AbstractAction {
DeleteWorkspace() {
super(NbBundle.getMessage(DeleteWorkspace.class, "CTL_DeleteWorkspace"),
ImageUtilities.loadImageIcon("DesktopProject/deleteWorkspace.png", false));
}
@Override
public void actionPerformed(ActionEvent ev) {<FILL_FUNCTION_BODY>}
@Override
public boolean isEnabled() {
return Lookup.getDefault().lookup(ProjectControllerUIImpl.class).canDeleteWorkspace();
}
}
|
if (isEnabled()) {
ProjectControllerUIImpl cui = Lookup.getDefault().lookup(ProjectControllerUIImpl.class);
if (ev.getSource() != null && ev.getSource() instanceof Workspace) {
Workspace workspace = (Workspace) ev.getSource();
cui.deleteWorkspace(workspace);
} else {
cui.deleteWorkspace();
}
}
| 138
| 109
| 247
|
<methods>public void <init>() ,public void <init>(java.lang.String) ,public void <init>(java.lang.String, javax.swing.Icon) ,public synchronized void addPropertyChangeListener(java.beans.PropertyChangeListener) ,public java.lang.Object[] getKeys() ,public synchronized java.beans.PropertyChangeListener[] getPropertyChangeListeners() ,public java.lang.Object getValue(java.lang.String) ,public boolean isEnabled() ,public void putValue(java.lang.String, java.lang.Object) ,public synchronized void removePropertyChangeListener(java.beans.PropertyChangeListener) ,public void setEnabled(boolean) <variables>private static java.lang.Boolean RECONFIGURE_ON_NULL,private transient javax.swing.ArrayTable arrayTable,protected javax.swing.event.SwingPropertyChangeSupport changeSupport,protected boolean enabled
|
gephi_gephi
|
gephi/modules/DesktopProject/src/main/java/org/gephi/desktop/project/actions/OpenFile.java
|
OpenFile
|
actionPerformed
|
class OpenFile extends AbstractAction {
private static final String GEPHI_EXTENSION = "gephi";
OpenFile() {
super(NbBundle.getMessage(OpenFile.class, "CTL_OpenFile"));
}
@Override
public boolean isEnabled() {
return Lookup.getDefault().lookup(ProjectControllerUIImpl.class).canOpenFile();
}
@Override
public void actionPerformed(ActionEvent ev) {<FILL_FUNCTION_BODY>}
}
|
if (isEnabled()) {
if (ev != null && ev.getSource() != null && ev.getSource() instanceof File) {
FileObject fileObject = FileUtil.toFileObject((File) ev.getSource());
if (fileObject.hasExt(GEPHI_EXTENSION)) {
Lookup.getDefault().lookup(ProjectControllerUIImpl.class).openProject(FileUtil.toFile(fileObject));
} else {
ImportControllerUI importController = Lookup.getDefault().lookup(ImportControllerUI.class);
if (importController.getImportController().isFileSupported(FileUtil.toFile(fileObject))) {
importController.importFile(fileObject);
} else {
NotifyDescriptor.Message msg = new NotifyDescriptor.Message(
NbBundle.getMessage(OpenFile.class, "OpenFile.fileNotSupported"),
NotifyDescriptor.WARNING_MESSAGE);
DialogDisplayer.getDefault().notify(msg);
}
}
} else if (ev != null && ev.getSource() != null && ev.getSource() instanceof FileImporterBuilder[]) {
Lookup.getDefault().lookup(ProjectControllerUIImpl.class)
.openFile((FileImporterBuilder[]) ev.getSource());
} else if (ev != null && ev.getSource() != null && ev.getSource() instanceof Project) {
Lookup.getDefault().lookup(ProjectControllerUIImpl.class).openProject((Project) ev.getSource());
} else {
Lookup.getDefault().lookup(ProjectControllerUIImpl.class).openFile();
}
}
| 131
| 409
| 540
|
<methods>public void <init>() ,public void <init>(java.lang.String) ,public void <init>(java.lang.String, javax.swing.Icon) ,public synchronized void addPropertyChangeListener(java.beans.PropertyChangeListener) ,public java.lang.Object[] getKeys() ,public synchronized java.beans.PropertyChangeListener[] getPropertyChangeListeners() ,public java.lang.Object getValue(java.lang.String) ,public boolean isEnabled() ,public void putValue(java.lang.String, java.lang.Object) ,public synchronized void removePropertyChangeListener(java.beans.PropertyChangeListener) ,public void setEnabled(boolean) <variables>private static java.lang.Boolean RECONFIGURE_ON_NULL,private transient javax.swing.ArrayTable arrayTable,protected javax.swing.event.SwingPropertyChangeSupport changeSupport,protected boolean enabled
|
gephi_gephi
|
gephi/modules/DesktopProject/src/main/java/org/gephi/desktop/project/actions/RecentFiles.java
|
RecentFiles
|
createMenu
|
class RecentFiles extends AbstractAction implements DynamicMenuContent {
RecentFiles() {
super(NbBundle.getMessage(RecentFiles.class, "CTL_OpenRecentFiles"));
}
@Override
public void actionPerformed(ActionEvent e) {
// does nothing, this is a popup menu
}
@Override
public JComponent[] getMenuPresenters() {
return createMenu();
}
@Override
public JComponent[] synchMenuPresenters(JComponent[] items) {
return createMenu();
}
private JComponent[] createMenu() {<FILL_FUNCTION_BODY>}
private JComponent[] createSubMenus() {
// Projects
List<JMenuItem> projectsItems = new ArrayList<>();
ProjectController projectController = Lookup.getDefault().lookup(ProjectController.class);
for (Project project : projectController.getAllProjects()) {
if (project.hasFile()) {
JMenuItem menuItem = new JMenuItem(new OpenProjectAction(project));
projectsItems.add(menuItem);
}
}
// Files
MostRecentFiles mru = Lookup.getDefault().lookup(MostRecentFiles.class);
List<JMenuItem> filesItems = mru.getMRUFileList().stream().map(File::new).filter(File::exists)
.map(f -> new JMenuItem(new OpenFileAction(f))).collect(
Collectors.toList());
// Add to menu, with separator if needed
List<JComponent> items = new ArrayList<>(projectsItems);
if (!projectsItems.isEmpty() && !filesItems.isEmpty()) {
items.add(new JSeparator());
}
items.addAll(filesItems);
// Manage projects
items.add(new JSeparator());
items.add(new JMenuItem(Actions.forID("File", "org.gephi.desktop.project.actions.ManageProjects")));
return items.toArray(new JComponent[0]);
}
private static class OpenFileAction extends AbstractAction {
private final File file;
public OpenFileAction(File file) {
super(file.getName());
this.file = file;
}
@Override
public void actionPerformed(ActionEvent e) {
FileObject fileObject = FileUtil.toFileObject(file);
ImportControllerUI importController = Lookup.getDefault().lookup(ImportControllerUI.class);
if (importController.getImportController().isFileSupported(file)) {
importController.importFile(fileObject);
}
}
}
private static class OpenProjectAction extends AbstractAction {
private final Project project;
public OpenProjectAction(Project project) {
super(getActionName(project));
this.project = project;
}
private static String getActionName(Project project) {
return project.getName() + " (" + project.getFileName() + ")";
}
@Override
public void actionPerformed(ActionEvent e) {
File file = project.getFile();
Actions.forID("File", "org.gephi.desktop.project.actions.OpenFile").actionPerformed(
new ActionEvent(file, 0, null));
}
}
}
|
JMenu menu = new JMenu(NbBundle.getMessage(RecentFiles.class, "CTL_OpenRecentFiles"));
JComponent[] menuItems = createSubMenus();
for (JComponent item : menuItems) {
menu.add(item);
}
return new JComponent[] {menu};
| 831
| 78
| 909
|
<methods>public void <init>() ,public void <init>(java.lang.String) ,public void <init>(java.lang.String, javax.swing.Icon) ,public synchronized void addPropertyChangeListener(java.beans.PropertyChangeListener) ,public java.lang.Object[] getKeys() ,public synchronized java.beans.PropertyChangeListener[] getPropertyChangeListeners() ,public java.lang.Object getValue(java.lang.String) ,public boolean isEnabled() ,public void putValue(java.lang.String, java.lang.Object) ,public synchronized void removePropertyChangeListener(java.beans.PropertyChangeListener) ,public void setEnabled(boolean) <variables>private static java.lang.Boolean RECONFIGURE_ON_NULL,private transient javax.swing.ArrayTable arrayTable,protected javax.swing.event.SwingPropertyChangeSupport changeSupport,protected boolean enabled
|
gephi_gephi
|
gephi/modules/DesktopProject/src/main/java/org/gephi/desktop/project/actions/RenameWorkspace.java
|
RenameWorkspace
|
actionPerformed
|
class RenameWorkspace extends AbstractAction {
RenameWorkspace() {
super(NbBundle.getMessage(DeleteWorkspace.class, "CTL_RenameWorkspace"),
ImageUtilities.loadImageIcon("DesktopProject/renameWorkspace.png", false));
}
@Override
public void actionPerformed(ActionEvent e) {<FILL_FUNCTION_BODY>}
@Override
public boolean isEnabled() {
return Lookup.getDefault().lookup(ProjectControllerUIImpl.class).canRenameWorkspace();
}
}
|
if (isEnabled()) {
String name = "";
ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);
name = pc.getCurrentWorkspace().getLookup().lookup(WorkspaceInformation.class).getName();
DialogDescriptor.InputLine dd = new DialogDescriptor.InputLine("",
NbBundle.getMessage(RenameWorkspace.class, "RenameWorkspace.dialog.title"));
dd.setInputText(name);
if (DialogDisplayer.getDefault().notify(dd).equals(DialogDescriptor.OK_OPTION) &&
!dd.getInputText().isEmpty()) {
Lookup.getDefault().lookup(ProjectControllerUIImpl.class).renameWorkspace(dd.getInputText());
}
}
| 143
| 193
| 336
|
<methods>public void <init>() ,public void <init>(java.lang.String) ,public void <init>(java.lang.String, javax.swing.Icon) ,public synchronized void addPropertyChangeListener(java.beans.PropertyChangeListener) ,public java.lang.Object[] getKeys() ,public synchronized java.beans.PropertyChangeListener[] getPropertyChangeListeners() ,public java.lang.Object getValue(java.lang.String) ,public boolean isEnabled() ,public void putValue(java.lang.String, java.lang.Object) ,public synchronized void removePropertyChangeListener(java.beans.PropertyChangeListener) ,public void setEnabled(boolean) <variables>private static java.lang.Boolean RECONFIGURE_ON_NULL,private transient javax.swing.ArrayTable arrayTable,protected javax.swing.event.SwingPropertyChangeSupport changeSupport,protected boolean enabled
|
gephi_gephi
|
gephi/modules/DesktopProject/src/main/java/org/gephi/ui/project/ProjectList.java
|
ProjectCellRenderer
|
initComponents
|
class ProjectCellRenderer extends DefaultListCellRenderer {
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
boolean cellHasFocus) {
JLabel c = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
Project p = (Project) value;
if (p.isOpen()) {
c.setFont(c.getFont().deriveFont(Font.BOLD));
} else {
c.setFont(c.getFont().deriveFont(Font.PLAIN));
}
String name = p.getName();
if (p.getFileName() != null) {
name += " (" + p.getFileName() + ")";
}
c.setText(name);
return c;
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {<FILL_FUNCTION_BODY>
|
jScrollPane2 = new javax.swing.JScrollPane();
projectList = new javax.swing.JList<>();
openProjectButton = new javax.swing.JButton();
removeProjectButton = new javax.swing.JButton();
projectList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
jScrollPane2.setViewportView(projectList);
org.openide.awt.Mnemonics.setLocalizedText(openProjectButton,
org.openide.util.NbBundle.getMessage(ProjectList.class, "ProjectList.openProjectButton.text")); // NOI18N
openProjectButton.setToolTipText(org.openide.util.NbBundle.getMessage(ProjectList.class,
"ProjectList.openProjectButton.toolTipText")); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(removeProjectButton,
org.openide.util.NbBundle.getMessage(ProjectList.class, "ProjectList.removeProjectButton.text")); // NOI18N
removeProjectButton.setToolTipText(org.openide.util.NbBundle.getMessage(ProjectList.class,
"ProjectList.removeProjectButton.toolTipText")); // NOI18N
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 243,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(openProjectButton, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(removeProjectButton, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(openProjectButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(removeProjectButton))
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
| 321
| 802
| 1,123
|
<methods>public void <init>() ,public void <init>(java.awt.LayoutManager) ,public void <init>(boolean) ,public void <init>(java.awt.LayoutManager, boolean) ,public javax.accessibility.AccessibleContext getAccessibleContext() ,public javax.swing.plaf.PanelUI getUI() ,public java.lang.String getUIClassID() ,public void setUI(javax.swing.plaf.PanelUI) ,public void updateUI() <variables>private static final java.lang.String uiClassID
|
gephi_gephi
|
gephi/modules/DesktopSearch/src/main/java/org/gephi/desktop/search/SearchAction.java
|
SearchAction
|
actionPerformed
|
class SearchAction extends AbstractAction {
// Singleton so it persists when the dialog is closed
private final SearchUIModel uiModel;
SearchAction() {
super(NbBundle.getMessage(SearchAction.class, "CTL_Search"),
ImageUtilities.loadImageIcon("DesktopSearch/search.png", false));
uiModel = new SearchUIModel();
}
@Override
public void actionPerformed(ActionEvent ae) {<FILL_FUNCTION_BODY>}
private void closeDialog(SearchDialog panel, JDialog dialog) {
SwingUtilities.invokeLater(() -> {
panel.unsetup();
dialog.dispose();
});
}
@Override
public boolean isEnabled() {
return Lookup.getDefault().lookup(ProjectController.class).hasCurrentProject();
}
}
|
if (isEnabled()) {
SearchDialog panel = new SearchDialog(uiModel);
JDialog dialog = new JDialog(WindowManager.getDefault().getMainWindow(),
NbBundle.getMessage(SearchAction.class, "SearchDialog.title"), false);
// Close behavior
dialog.getRootPane().registerKeyboardAction(e -> {
closeDialog(panel, dialog);
}, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
dialog.addWindowFocusListener(new WindowAdapter() {
@Override
public void windowLostFocus(WindowEvent e) {
closeDialog(panel, dialog);
}
});
// Drag behavior
panel.instrumentDragListener(dialog);
// Show dialog
dialog.setUndecorated(true);
dialog.getContentPane().add(panel);
dialog.setBounds(212, 237, 679, 378);
dialog.setVisible(true);
}
| 217
| 274
| 491
|
<methods>public void <init>() ,public void <init>(java.lang.String) ,public void <init>(java.lang.String, javax.swing.Icon) ,public synchronized void addPropertyChangeListener(java.beans.PropertyChangeListener) ,public java.lang.Object[] getKeys() ,public synchronized java.beans.PropertyChangeListener[] getPropertyChangeListeners() ,public java.lang.Object getValue(java.lang.String) ,public boolean isEnabled() ,public void putValue(java.lang.String, java.lang.Object) ,public synchronized void removePropertyChangeListener(java.beans.PropertyChangeListener) ,public void setEnabled(boolean) <variables>private static java.lang.Boolean RECONFIGURE_ON_NULL,private transient javax.swing.ArrayTable arrayTable,protected javax.swing.event.SwingPropertyChangeSupport changeSupport,protected boolean enabled
|
gephi_gephi
|
gephi/modules/DesktopSearch/src/main/java/org/gephi/desktop/search/filter/SearchFilterBuilder.java
|
SearchFilter
|
filter
|
class SearchFilter implements ComplexFilter {
private String query;
private String type;
public SearchFilter() {
type = SearchCategoryImpl.NODES().getId();
}
@Override
public Graph filter(Graph graph) {<FILL_FUNCTION_BODY>}
public String getName() {
return NbBundle.getMessage(SearchFilterBuilder.class, "SearchFilter.name");
}
public FilterProperty[] getProperties() {
try {
return new FilterProperty[] {
FilterProperty.createProperty(this, String.class, "query"),
FilterProperty.createProperty(this, String.class, "type")};
} catch (NoSuchMethodException ex) {
Exceptions.printStackTrace(ex);
}
return new FilterProperty[0];
}
public String getQuery() {
return query;
}
public void setQuery(String query) {
this.query = query;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
|
if (query == null || query.isEmpty()) {
return graph;
}
SearchRequest request =
SearchRequest.builder().query(query).graph(graph).parallel(false).limitResults(false).build();
SearchController searchController = Lookup.getDefault().lookup(SearchController.class);
Subgraph subgraph = graph.getModel().getGraph(graph.getView());
if (type.equalsIgnoreCase(SearchCategoryImpl.NODES().getId())) {
List<Node> nodes = searchController.search(request, Node.class).stream()
.map(SearchResult::getResult).collect(Collectors.toList());
subgraph.retainNodes(nodes);
} else if (type.equalsIgnoreCase(SearchCategoryImpl.EDGES().getId())) {
List<Edge> edges = searchController.search(request, Edge.class).stream()
.map(SearchResult::getResult).collect(Collectors.toList());
subgraph.retainEdges(edges);
}
return subgraph;
| 286
| 253
| 539
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopSearch/src/main/java/org/gephi/desktop/search/filter/SearchPanel.java
|
SearchPanel
|
initComponents
|
class SearchPanel extends javax.swing.JPanel {
public SearchPanel() {
initComponents();
// Combo
DefaultComboBoxModel<SearchCategory> comboBoxModel = new DefaultComboBoxModel<>();
comboBoxModel.addElement(SearchCategoryImpl.NODES());
comboBoxModel.addElement(SearchCategoryImpl.EDGES());
;
typeCombo.setModel(comboBoxModel);
typeCombo.setSelectedIndex(0);
}
public void setup(SearchFilterBuilder.SearchFilter filter) {
searchField.setText(filter.getQuery());
typeCombo.setSelectedItem(SearchCategory.findById(filter.getType()));
searchButton.addActionListener(evt -> {
filter.getProperties()[0].setValue(searchField.getText());
filter.getProperties()[1].setValue(((SearchCategory) typeCombo.getSelectedItem()).getId());
});
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {<FILL_FUNCTION_BODY>}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton searchButton;
private javax.swing.JTextField searchField;
private javax.swing.JLabel searchInLabel;
private javax.swing.JComboBox<SearchCategory> typeCombo;
// End of variables declaration//GEN-END:variables
}
|
searchField = new javax.swing.JTextField();
typeCombo = new javax.swing.JComboBox<>();
searchButton = new javax.swing.JButton();
searchInLabel = new javax.swing.JLabel();
org.openide.awt.Mnemonics.setLocalizedText(searchButton,
org.openide.util.NbBundle.getMessage(SearchPanel.class, "SearchPanel.searchButton.text")); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(searchInLabel,
org.openide.util.NbBundle.getMessage(SearchPanel.class, "SearchPanel.searchInLabel.text")); // NOI18N
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(searchInLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(typeCombo, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addComponent(searchField, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(searchButton)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(searchInLabel)
.addComponent(typeCombo, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(searchField, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(searchButton))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
| 455
| 746
| 1,201
|
<methods>public void <init>() ,public void <init>(java.awt.LayoutManager) ,public void <init>(boolean) ,public void <init>(java.awt.LayoutManager, boolean) ,public javax.accessibility.AccessibleContext getAccessibleContext() ,public javax.swing.plaf.PanelUI getUI() ,public java.lang.String getUIClassID() ,public void setUI(javax.swing.plaf.PanelUI) ,public void updateUI() <variables>private static final java.lang.String uiClassID
|
gephi_gephi
|
gephi/modules/DesktopSearch/src/main/java/org/gephi/desktop/search/impl/SearchCategoryImpl.java
|
EdgeSearchCategoryImpl
|
equals
|
class EdgeSearchCategoryImpl extends SearchCategoryImpl {
@Override
public String getId() {
return EDGE_ID;
}
}
public static SearchCategory NODES() {
return Lookup.getDefault().lookupAll(SearchCategory.class).stream()
.filter(c -> c.getId().equals(NODE_ID)).findFirst().orElse(null);
}
public static SearchCategory EDGES() {
return Lookup.getDefault().lookupAll(SearchCategory.class).stream()
.filter(c -> c.getId().equals(EDGE_ID)).findFirst().orElse(null);
}
@Override
public abstract String getId();
@Override
public String getDisplayName() {
return NbBundle.getMessage(SearchCategoryImpl.class, "Category." + getId() + ".displayName");
}
@Override
public String toString() {
return getDisplayName();
}
@Override
public boolean equals(Object o) {<FILL_FUNCTION_BODY>
|
if (this == o) {
return true;
}
if (!(o instanceof SearchCategoryImpl)) {
return false;
}
SearchCategory that = (SearchCategory) o;
return getId().equals(that.getId());
| 269
| 66
| 335
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopSearch/src/main/java/org/gephi/desktop/search/impl/SearchControllerImpl.java
|
SearchControllerImpl
|
search
|
class SearchControllerImpl implements SearchController {
private final ExecutorService pool;
private final List<Future<Void>> currentSearch = new ArrayList<>();
private SearchSession currentSession;
private SearchListener currentListener;
private final static int MAX_RESULTS = 10;
public SearchControllerImpl() {
pool = Executors.newCachedThreadPool();
}
protected void shutdown() {
pool.shutdown();
}
@Override
public <T> List<SearchResult<T>> search(SearchRequest request, Class<T> typeFilter) {<FILL_FUNCTION_BODY>}
@Override
public void search(SearchRequest request, SearchListener listener) {
synchronized (currentSearch) {
// Cancel current search if exists
currentSearch.forEach(f -> f.cancel(false));
currentSearch.clear();
if (currentSession != null) {
if (currentSession.markObsolete()) {
currentListener.cancelled();
}
}
// Create new search
currentSession = new SearchSession<>(request);
currentListener = listener;
currentListener.started(request);
// Submit provider tasks
getProviderTasks(request, currentSession).stream()
.map(r -> pool.submit((Runnable) r)).forEach(f -> currentSearch.add((Future<Void>) f));
// Join task
final List<Future<Void>> providerTasks = currentSearch;
final SearchSession session = currentSession;
pool.submit(() -> {
for (Future<Void> f : providerTasks) {
try {
f.get();
} catch (CancellationException | InterruptedException ex) {
// ignore
} catch (ExecutionException ex) {
throw new RuntimeException(ex);
}
}
if (!session.isObsolete()) {
listener.finished(session.request, session.getResults());
}
});
}
}
protected <T> List<Runnable> getProviderTasks(SearchRequest request, SearchSession<T> session) {
List<Runnable> tasks = new ArrayList<>();
int position = 0;
for (SearchProvider<T> provider : Lookup.getDefault().lookupAll(SearchProvider.class)) {
final int providerPosition = position++;
tasks.add(() -> {
SearchResultsBuilderImpl<T> resultsBuilder =
new SearchResultsBuilderImpl<>(provider, providerPosition,
request.isLimitResults() ? MAX_RESULTS : Integer.MAX_VALUE);
session.addBuilder(resultsBuilder);
provider.search(request, resultsBuilder);
session.addResult(resultsBuilder.getResults());
});
}
return tasks;
}
private static class SearchSession<T> {
final SearchRequest request;
final Set<Class<T>> classFilters;
final Map<T, SearchResultImpl<T>> resultSet;
final Queue<SearchResultsBuilderImpl<T>> builders;
volatile boolean obsolete;
volatile boolean finished;
public SearchSession(SearchRequest request) {
this(request, Collections.emptySet());
}
public SearchSession(SearchRequest request, Set<Class<T>> classFilters) {
this.request = request;
this.classFilters = classFilters;
this.resultSet = new ConcurrentHashMap<>();
this.builders = new ConcurrentLinkedQueue<>();
}
protected void addBuilder(SearchResultsBuilderImpl<T> builder) {
builders.add(builder);
}
protected boolean markObsolete() {
this.obsolete = true;
SearchResultsBuilderImpl<T> builder;
while ((builder = builders.poll()) != null) {
builder.markObsolete();
}
return !finished;
}
public boolean isObsolete() {
return obsolete;
}
protected void addResult(List<SearchResultImpl<T>> results) {
results.stream().filter(r -> passClassFilters(r.getResult()))
.forEach(key -> resultSet.merge(key.getResult(), key, (oldValue, newValue) -> {
if (newValue.getPosition() < oldValue.getPosition()) {
return newValue;
} else {
return oldValue;
}
}));
}
protected List<SearchResult<T>> getResults() {
this.finished = true;
return resultSet.values().stream().sorted().collect(Collectors.toList());
}
protected boolean passClassFilters(T result) {
if (classFilters.isEmpty()) {
return true;
}
for (Class<T> cls : classFilters) {
if (cls.isAssignableFrom(result.getClass())) {
return true;
}
}
return false;
}
}
}
|
SearchSession<T> session = new SearchSession<>(request, Collections.singleton(typeFilter));
if (request.inParallel()) {
ForkJoinPool commonPool = ForkJoinPool.commonPool();
getProviderTasks(request, session).stream().map(commonPool::submit).forEach(ForkJoinTask::join);
} else {
getProviderTasks(request, session).forEach(Runnable::run);
}
return session.getResults();
| 1,244
| 120
| 1,364
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopSearch/src/main/java/org/gephi/desktop/search/impl/SearchResultImpl.java
|
SearchResultImpl
|
equals
|
class SearchResultImpl<T> implements SearchResult<T>, Comparable<SearchResultImpl<T>> {
private final T result;
private final SearchProvider<T> provider;
private final int position;
private final String htmlDisplay;
private final String matchLocation;
public SearchResultImpl(SearchProvider<T> provider, int position, T result, String htmlDisplay,
String matchLocation) {
this.provider = provider;
this.position = position;
this.result = result;
this.htmlDisplay = htmlDisplay;
this.matchLocation = matchLocation;
}
@Override
public T getResult() {
return result;
}
protected SearchProvider<T> getProvider() {
return provider;
}
@Override
public String getHtmlDisplay() {
return htmlDisplay;
}
@Override
public String getMatchLocation() {
return matchLocation;
}
public int getPosition() {
return position;
}
@Override
public String toString() {
return "<html>" + getHtmlDisplay() + " <font color='#aaaaaa'>" + getMatchLocation() + "</font></html>";
}
@Override
public boolean equals(Object o) {<FILL_FUNCTION_BODY>}
@Override
public int hashCode() {
return result.hashCode();
}
@Override
public int compareTo(SearchResultImpl<T> o) {
return Integer.compare(position, o.position);
}
}
|
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
SearchResultImpl<?> that = (SearchResultImpl<?>) o;
return result.equals(that.result);
| 400
| 80
| 480
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopSearch/src/main/java/org/gephi/desktop/search/impl/SearchResultsBuilderImpl.java
|
SearchResultsBuilderImpl
|
addResult
|
class SearchResultsBuilderImpl<T> implements SearchResultsBuilder<T> {
private boolean obsolete = false;
private final int maxResults;
private final List<SearchResultImpl<T>> resultsList;
private final SearchProvider<T> provider;
private int position;
public SearchResultsBuilderImpl(SearchProvider<T> provider, int position, int maxResults) {
this.provider = provider;
this.position = position;
this.maxResults = maxResults;
this.resultsList = new ArrayList<>();
}
@Override
public synchronized boolean addResult(T result, String htmlDisplayText, String matchLocation) {<FILL_FUNCTION_BODY>}
@Override
public boolean isObsolete() {
return obsolete;
}
protected List<SearchResultImpl<T>> getResults() {
return resultsList;
}
protected void markObsolete() {
this.obsolete = true;
}
}
|
if (result == null) {
throw new NullPointerException("Result cannot be null");
}
resultsList.add(new SearchResultImpl<>(provider, position, result, htmlDisplayText, matchLocation));
return !obsolete && resultsList.size() < maxResults;
| 247
| 71
| 318
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopSearch/src/main/java/org/gephi/desktop/search/plugin/EdgeIdSearchProvider.java
|
EdgeIdSearchProvider
|
search
|
class EdgeIdSearchProvider implements SearchProvider<Edge> {
@Override
public void search(SearchRequest request, SearchResultsBuilder<Edge> resultsBuilder) {<FILL_FUNCTION_BODY>}
private String toHtmlDisplay(Edge edge) {
return NbBundle.getMessage(EdgeIdSearchProvider.class,
"EdgeIdSearchProvider.result", edge.getId());
}
}
|
if (request.isCategoryIncluded(SearchCategoryImpl.EDGES())) {
Edge edge = request.getGraph().getEdge(request.getQuery());
if (edge != null) {
resultsBuilder.addResult(edge, toHtmlDisplay(edge), NbBundle.getMessage(EdgeIdSearchProvider.class,
"EdgeIdSearchProvider.match"));
}
}
| 98
| 97
| 195
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopSearch/src/main/java/org/gephi/desktop/search/plugin/ElementLabelSearchProvider.java
|
ElementLabelSearchProvider
|
search
|
class ElementLabelSearchProvider implements SearchProvider<Element> {
@Override
public void search(SearchRequest request, SearchResultsBuilder<Element> resultsBuilder) {<FILL_FUNCTION_BODY>}
protected void matchElementLabel(ElementIterable<? extends Element> iterable, String query,
SearchResultsBuilder<Element> resultsBuilder) {
final String matchLocation = toMatchLocation();
// Exact Node label
for (Element element : iterable) {
if (match(element, query)) {
if (!resultsBuilder.addResult(element, toHtmlDisplay(element, query), matchLocation)) {
iterable.doBreak();
break;
}
}
if (resultsBuilder.isObsolete()) {
iterable.doBreak();
break;
}
}
}
protected boolean match(Element element, String query) {
return element.getLabel() != null && element.getLabel().equalsIgnoreCase(query);
}
protected String toMatchLocation() {
return NbBundle.getMessage(ElementLabelSearchProvider.class, "ElementLabelSearchProvider.match");
}
protected String toHtmlDisplay(Element element, String query) {
return NbBundle.getMessage(ElementLabelSearchProvider.class,
"ElementLabelSearchProvider.result", element.getLabel());
}
}
|
String query = request.getQuery();
// Exact node label
if (request.isCategoryIncluded(SearchCategoryImpl.NODES())) {
matchElementLabel(request.getGraph().getNodes(), query, resultsBuilder);
}
// Exact edge label
if (request.isCategoryIncluded(SearchCategoryImpl.EDGES())) {
matchElementLabel(request.getGraph().getEdges(), query, resultsBuilder);
}
| 331
| 115
| 446
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopSearch/src/main/java/org/gephi/desktop/search/plugin/FuzzyElementLabelSearchProvider.java
|
FuzzyElementLabelSearchProvider
|
toHtmlDisplay
|
class FuzzyElementLabelSearchProvider extends ElementLabelSearchProvider {
@Override
protected boolean match(Element element, String query) {
return element.getLabel() != null && element.getLabel().toLowerCase().contains(query.toLowerCase()) &&
!super.match(element, query);
}
@Override
protected String toMatchLocation() {
return NbBundle.getMessage(FuzzyElementLabelSearchProvider.class, "FuzzyElementLabelSearchProvider.match");
}
@Override
protected String toHtmlDisplay(Element element, String query) {<FILL_FUNCTION_BODY>}
}
|
String label = element.getLabel();
int index = label.toLowerCase().indexOf(query.toLowerCase());
String before = label.substring(0, index);
String match = label.substring(index, index + query.length());
String after = label.substring(index + query.length());
return NbBundle.getMessage(FuzzyElementLabelSearchProvider.class,
"FuzzyElementLabelSearchProvider.result",
before, match, after);
| 158
| 121
| 279
|
<methods>public non-sealed void <init>() ,public void search(org.gephi.desktop.search.api.SearchRequest, SearchResultsBuilder<Element>) <variables>
|
gephi_gephi
|
gephi/modules/DesktopSearch/src/main/java/org/gephi/desktop/search/plugin/NodeIdSearchProvider.java
|
NodeIdSearchProvider
|
search
|
class NodeIdSearchProvider implements SearchProvider<Node> {
@Override
public void search(SearchRequest request, SearchResultsBuilder<Node> resultsBuilder) {<FILL_FUNCTION_BODY>}
public static String toHtmlDisplay(Node node) {
return NbBundle.getMessage(NodeIdSearchProvider.class,
"NodeIdSearchProvider.result", node.getId());
}
}
|
if (request.isCategoryIncluded(SearchCategoryImpl.NODES())) {
Node node = request.getGraph().getNode(request.getQuery());
if (node != null) {
resultsBuilder.addResult(node, toHtmlDisplay(node), NbBundle.getMessage(NodeIdSearchProvider.class,
"NodeIdSearchProvider.match"));
}
}
| 99
| 96
| 195
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopSearch/src/main/java/org/gephi/desktop/search/plugin/StartWithElementLabelSearchProvider.java
|
StartWithElementLabelSearchProvider
|
toHtmlDisplay
|
class StartWithElementLabelSearchProvider extends ElementLabelSearchProvider {
@Override
protected boolean match(Element element, String query) {
return element.getLabel() != null && element.getLabel().toLowerCase().startsWith(query.toLowerCase()) &&
!super.match(element, query);
}
@Override
protected String toMatchLocation() {
return NbBundle.getMessage(StartWithElementLabelSearchProvider.class,
"StartWithElementLabelSearchProvider.match");
}
@Override
protected String toHtmlDisplay(Element element, String query) {<FILL_FUNCTION_BODY>}
}
|
String label = element.getLabel();
String match = label.substring(0, query.length());
String after = label.substring(query.length());
return NbBundle.getMessage(StartWithElementLabelSearchProvider.class,
"StartWithElementLabelSearchProvider.result",
match, after);
| 159
| 80
| 239
|
<methods>public non-sealed void <init>() ,public void search(org.gephi.desktop.search.api.SearchRequest, SearchResultsBuilder<Element>) <variables>
|
gephi_gephi
|
gephi/modules/DesktopSearch/src/main/java/org/gephi/desktop/search/popup/ActionPopup.java
|
ActionPopup
|
maybePopup
|
class ActionPopup extends MouseAdapter {
private final JList<SearchResult> list;
public ActionPopup(JList<SearchResult> list) {
super();
this.list = list;
}
@Override
public void mousePressed(MouseEvent e) {
maybePopup(e);
}
@Override
public void mouseReleased(MouseEvent e) {
maybePopup(e);
}
private void maybePopup(MouseEvent e) {<FILL_FUNCTION_BODY>}
protected JPopupMenu createPopup(Point p) {
SearchResult result = list.getSelectedValue();
if (result != null) {
if (result.getResult() instanceof Node) {
return NodePopup.createPopup((Node) result.getResult());
} else if (result.getResult() instanceof Edge) {
return EdgePopup.createPopup((Edge) result.getResult());
}
}
return null;
}
private void showPopup(int xpos, int ypos, final JPopupMenu popup) {
if ((popup != null) && (popup.getSubElements().length > 0)) {
popup.show(list, xpos, ypos);
}
}
}
|
if (e.isPopupTrigger()) {
SwingUtilities.invokeLater(() -> {
final Point p = e.getPoint();
int row = list.locationToIndex(e.getPoint());
list.setSelectedIndex(row);
final JPopupMenu pop = createPopup(p);
if (pop != null) {
showPopup(p.x, p.y, pop);
}
});
}
| 328
| 117
| 445
|
<methods>public void mouseClicked(java.awt.event.MouseEvent) ,public void mouseDragged(java.awt.event.MouseEvent) ,public void mouseEntered(java.awt.event.MouseEvent) ,public void mouseExited(java.awt.event.MouseEvent) ,public void mouseMoved(java.awt.event.MouseEvent) ,public void mousePressed(java.awt.event.MouseEvent) ,public void mouseReleased(java.awt.event.MouseEvent) ,public void mouseWheelMoved(java.awt.event.MouseWheelEvent) <variables>
|
gephi_gephi
|
gephi/modules/DesktopSearch/src/main/java/org/gephi/desktop/search/popup/EdgePopup.java
|
EdgePopup
|
createPopup
|
class EdgePopup {
protected static final Set<Class<? extends Manipulator>> excludedManipulators = Set.copyOf(List.of(
CopyEdgeDataToOtherEdges.class));
protected static final Set<Class<? extends Manipulator>> graphManipulators = Set.copyOf(List.of(
SelectOnGraph.class,
SelectSourceOnGraph.class,
SelectTargetOnGraph.class));
protected static final Set<Class<? extends Manipulator>> datalabManipulators = Set.copyOf(List.of(
SelectNodesOnTable.class));
protected static JPopupMenu createPopup(Edge selectedElement) {<FILL_FUNCTION_BODY>}
}
|
boolean graphOpened = SearchDialog.isGraphOpened();
boolean datalabOpened = SearchDialog.isDataLabOpened();
JPopupMenu contextMenu = new JPopupMenu();
DataLaboratoryHelper dlh = DataLaboratoryHelper.getDefault();
Integer lastManipulatorType = null;
for (EdgesManipulator em : dlh.getEdgesManipulators()) {
if (!excludedManipulators.contains(em.getClass())) {
if (!graphOpened && graphManipulators.contains(em.getClass())) {
continue;
}
if (!datalabOpened && datalabManipulators.contains(em.getClass())) {
continue;
}
em.setup(new Edge[] {selectedElement}, selectedElement);
if (lastManipulatorType == null) {
lastManipulatorType = em.getType();
}
if (lastManipulatorType != em.getType()) {
contextMenu.addSeparator();
}
lastManipulatorType = em.getType();
if (em.isAvailable()) {
contextMenu.add(PopupMenuUtils
.createMenuItemFromEdgesManipulator(em, selectedElement, new Edge[] {selectedElement}));
}
}
}
return contextMenu;
| 180
| 339
| 519
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopSearch/src/main/java/org/gephi/desktop/search/popup/NodePopup.java
|
NodePopup
|
createPopup
|
class NodePopup {
protected static final Set<Class<? extends Manipulator>> excludedManipulators = Set.copyOf(List.of(
MergeNodes.class,
LinkNodes.class,
CopyNodeDataToOtherNodes.class));
protected static final Set<Class<? extends Manipulator>> graphManipulators = Set.copyOf(List.of(
SelectOnGraph.class));
protected static final Set<Class<? extends Manipulator>> datalabManipulators = Set.copyOf(List.of(
SelectNeighboursOnTable.class,
SelectEdgesOnTable.class));
protected static JPopupMenu createPopup(Node selectedElement) {<FILL_FUNCTION_BODY>}
}
|
boolean graphOpened = SearchDialog.isGraphOpened();
boolean datalabOpened = SearchDialog.isDataLabOpened();
JPopupMenu contextMenu = new JPopupMenu();
DataLaboratoryHelper dlh = DataLaboratoryHelper.getDefault();
Integer lastManipulatorType = null;
for (NodesManipulator em : dlh.getNodesManipulators()) {
if (!excludedManipulators.contains(em.getClass())) {
if (!graphOpened && graphManipulators.contains(em.getClass())) {
continue;
}
if (!datalabOpened && datalabManipulators.contains(em.getClass())) {
continue;
}
em.setup(new Node[] {selectedElement}, selectedElement);
if (lastManipulatorType == null) {
lastManipulatorType = em.getType();
}
if (lastManipulatorType != em.getType()) {
contextMenu.addSeparator();
}
lastManipulatorType = em.getType();
if (em.isAvailable()) {
contextMenu.add(PopupMenuUtils
.createMenuItemFromNodesManipulator(em, selectedElement, new Node[] {selectedElement}));
}
}
}
return contextMenu;
| 189
| 336
| 525
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopStatistics/src/main/java/org/gephi/desktop/statistics/AvailableStatisticsChooser.java
|
AvailableStatisticsChooser
|
unsetup
|
class AvailableStatisticsChooser extends javax.swing.JPanel {
private final JSqueezeBoxPanel squeezeBoxPanel = new JSqueezeBoxPanel();
private final Map<JCheckBox, StatisticsUI> uiMap = new HashMap<>();
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel metricsPanel;
// End of variables declaration//GEN-END:variables
public AvailableStatisticsChooser() {
initComponents();
metricsPanel.add(squeezeBoxPanel, BorderLayout.CENTER);
}
public void setup(StatisticsModelUI model, StatisticsCategory[] categories) {
//Sort categories by position
Arrays.sort(categories, new Comparator() {
@Override
public int compare(Object o1, Object o2) {
Integer p1 = ((StatisticsCategory) o1).getPosition();
Integer p2 = ((StatisticsCategory) o2).getPosition();
return p1.compareTo(p2);
}
});
//Get UI
StatisticsUI[] statisticsUIs = Lookup.getDefault().lookupAll(StatisticsUI.class).toArray(new StatisticsUI[0]);
for (StatisticsCategory category : categories) {
MigLayout migLayout = new MigLayout("insets 0 0 0 0");
migLayout.setColumnConstraints("[grow,fill]");
migLayout.setRowConstraints("[min!]");
JPanel innerPanel = new JPanel(migLayout);
//Find uis in this category
List<StatisticsUI> uis = new ArrayList<>();
for (StatisticsUI sui : statisticsUIs) {
if (sui.getCategory().equals(category.getName())) {
uis.add(sui);
}
}
//Sort it by position
Collections.sort(uis, new Comparator() {
@Override
public int compare(Object o1, Object o2) {
Integer p1 = ((StatisticsUI) o1).getPosition();
Integer p2 = ((StatisticsUI) o2).getPosition();
return p1.compareTo(p2);
}
});
for (StatisticsUI sui : uis) {
JCheckBox checkBox = new JCheckBox(sui.getDisplayName());
checkBox.setOpaque(false);
checkBox.setSelected(model.isStatisticsUIVisible(sui));
uiMap.put(checkBox, sui);
innerPanel.add(checkBox, "wrap");
}
if (uis.size() > 0) {
squeezeBoxPanel.addPanel(innerPanel, category.getName());
}
}
}
public void unsetup() {<FILL_FUNCTION_BODY>}
/**
* This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
metricsPanel = new javax.swing.JPanel();
metricsPanel.setLayout(new java.awt.BorderLayout());
metricsPanel.setLayout(new java.awt.BorderLayout());
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(metricsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(metricsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 433, Short.MAX_VALUE)
.addContainerGap())
);
add(metricsPanel, java.awt.BorderLayout.CENTER);
}// </editor-fold>//GEN-END:initComponents
}
|
//Only called when OK
StatisticsControllerUI controller = Lookup.getDefault().lookup(StatisticsControllerUI.class);
for (Map.Entry<JCheckBox, StatisticsUI> entry : uiMap.entrySet()) {
controller.setStatisticsUIVisible(entry.getValue(), entry.getKey().isSelected());
}
| 1,148
| 86
| 1,234
|
<methods>public void <init>() ,public void <init>(java.awt.LayoutManager) ,public void <init>(boolean) ,public void <init>(java.awt.LayoutManager, boolean) ,public javax.accessibility.AccessibleContext getAccessibleContext() ,public javax.swing.plaf.PanelUI getUI() ,public java.lang.String getUIClassID() ,public void setUI(javax.swing.plaf.PanelUI) ,public void updateUI() <variables>private static final java.lang.String uiClassID
|
gephi_gephi
|
gephi/modules/DesktopStatistics/src/main/java/org/gephi/desktop/statistics/DynamicSettingsPanel.java
|
DateRangeValidator
|
validate
|
class DateRangeValidator implements Validator<String> {
private final ComboBoxModel combo;
public DateRangeValidator(ComboBoxModel comboBoxModel) {
this.combo = comboBoxModel;
}
@Override
public void validate(Problems prblms, String string, String t) {<FILL_FUNCTION_BODY>}
public Class<String> modelType() {
return String.class;
}
}
|
Integer i = 0;
try {
i = Integer.parseInt(t);
} catch (NumberFormatException e) {
prblms.add("Number can't be parsed");
}
TimeUnit tu = getSelectedTimeUnit(combo);
long timeInMilli = (long) getTimeInMilliseconds(t, tu);
long limit = (long) (bounds.getHigh() - bounds.getLow());
if (i < 1 || timeInMilli > limit) {
String message = NbBundle.getMessage(DynamicSettingsPanel.class,
"DateRangeValidator.NotInRange", i, 1, tu.convert(limit, TimeUnit.MILLISECONDS));
prblms.add(message);
}
| 115
| 188
| 303
|
<methods>public void <init>() ,public void <init>(java.awt.LayoutManager) ,public void <init>(boolean) ,public void <init>(java.awt.LayoutManager, boolean) ,public javax.accessibility.AccessibleContext getAccessibleContext() ,public javax.swing.plaf.PanelUI getUI() ,public java.lang.String getUIClassID() ,public void setUI(javax.swing.plaf.PanelUI) ,public void updateUI() <variables>private static final java.lang.String uiClassID
|
gephi_gephi
|
gephi/modules/DesktopStatistics/src/main/java/org/gephi/desktop/statistics/StatisticsControllerUIImpl.java
|
StatisticsControllerUIImpl
|
execute
|
class StatisticsControllerUIImpl implements StatisticsControllerUI {
// private final DynamicModelListener dynamicModelListener;
private StatisticsModelUIImpl model;
public StatisticsControllerUIImpl() {
// dynamicModelListener = new DynamicModelListener() {
//
// public void dynamicModelChanged(DynamicModelEvent event) {
// if (event.getEventType().equals(DynamicModelEvent.EventType.IS_DYNAMIC_GRAPH)) {
// boolean isDynamic = (Boolean) event.getData();
// for (StatisticsUI ui : Lookup.getDefault().lookupAll(StatisticsUI.class)) {
// if (ui.getCategory().equals(StatisticsUI.CATEGORY_DYNAMIC)) {
// setStatisticsUIVisible(ui, isDynamic);
// }
// }
// }
// }
// };
}
public void setup(StatisticsModelUIImpl model) {
if (this.model == model) {
return;
}
this.model = model;
unsetup();
if (model != null) {
// DynamicController dynamicController = Lookup.getDefault().lookup(DynamicController.class);
// boolean isDynamic = dynamicController.getModel(model.getWorkspace()).isDynamicGraph();
// if (!isDynamic) {
// for (StatisticsUI ui : Lookup.getDefault().lookupAll(StatisticsUI.class)) {
// if (ui.getCategory().equals(StatisticsUI.CATEGORY_DYNAMIC)) {
// setStatisticsUIVisible(ui, false);
// }
// }
// }
// //Add listener
//
// dynamicController.addModelListener(dynamicModelListener);
}
}
public void unsetup() {
if (model != null) {
// DynamicController dynamicController = Lookup.getDefault().lookup(DynamicController.class);
// dynamicController.removeModelListener(dynamicModelListener);
}
}
@Override
public void execute(final Statistics statistics) {
StatisticsController controller = Lookup.getDefault().lookup(StatisticsController.class);
final StatisticsUI[] uis = getUI(statistics);
for (StatisticsUI s : uis) {
s.setup(statistics);
}
model.setRunning(statistics, true);
controller.execute(statistics, new LongTaskListener() {
@Override
public void taskFinished(LongTask task) {
model.setRunning(statistics, false);
for (StatisticsUI s : uis) {
model.addResult(s);
s.unsetup();
}
}
});
}
@Override
public void execute(final Statistics statistics, final LongTaskListener listener) {<FILL_FUNCTION_BODY>}
public StatisticsUI[] getUI(Statistics statistics) {
boolean dynamic = false;
ArrayList<StatisticsUI> list = new ArrayList<>();
for (StatisticsUI sui : Lookup.getDefault().lookupAll(StatisticsUI.class)) {
if (sui.getStatisticsClass().equals(statistics.getClass())) {
list.add(sui);
}
}
return list.toArray(new StatisticsUI[0]);
}
@Override
public void setStatisticsUIVisible(StatisticsUI ui, boolean visible) {
if (model != null) {
model.setVisible(ui, visible);
}
}
}
|
StatisticsController controller = Lookup.getDefault().lookup(StatisticsController.class);
final StatisticsUI[] uis = getUI(statistics);
for (StatisticsUI s : uis) {
s.setup(statistics);
}
model.setRunning(statistics, true);
controller.execute(statistics, new LongTaskListener() {
@Override
public void taskFinished(LongTask task) {
model.setRunning(statistics, false);
for (StatisticsUI s : uis) {
model.addResult(s);
s.unsetup();
}
if (listener != null) {
listener.taskFinished(statistics instanceof LongTask ? (LongTask) statistics : null);
}
}
});
| 895
| 199
| 1,094
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopStatistics/src/main/java/org/gephi/desktop/statistics/StatisticsModelUIImpl.java
|
StatisticsModelUIImpl
|
readXML
|
class StatisticsModelUIImpl implements StatisticsModelUI {
private final Workspace workspace;
private final List<StatisticsUI> invisibleList;
private final Map<StatisticsUI, String> resultMap;
private final List<Statistics> runningList;
//Listeners
private final List<ChangeListener> listeners;
public StatisticsModelUIImpl(Workspace workspace) {
this.workspace = workspace;
runningList = Collections.synchronizedList(new ArrayList<Statistics>());
invisibleList = new ArrayList<>();
resultMap = new HashMap<>();
listeners = new ArrayList<>();
}
public void addResult(StatisticsUI ui) {
if (resultMap.containsKey(ui) && ui.getValue() == null) {
resultMap.remove(ui);
} else {
resultMap.put(ui, ui.getValue());
}
fireChangeEvent();
}
@Override
public String getResult(StatisticsUI statisticsUI) {
return resultMap.get(statisticsUI);
}
@Override
public String getReport(Class<? extends Statistics> statistics) {
StatisticsController controller = Lookup.getDefault().lookup(StatisticsController.class);
return controller.getModel(workspace).getReport(statistics);
}
@Override
public boolean isStatisticsUIVisible(StatisticsUI statisticsUI) {
return !invisibleList.contains(statisticsUI);
}
@Override
public boolean isRunning(StatisticsUI statisticsUI) {
for (Statistics s : runningList.toArray(new Statistics[0])) {
if (statisticsUI.getStatisticsClass().equals(s.getClass())) {
return true;
}
}
return false;
}
public void setRunning(Statistics statistics, boolean running) {
if (!running) {
if (runningList.remove(statistics)) {
fireChangeEvent();
}
} else if (!runningList.contains(statistics)) {
runningList.add(statistics);
fireChangeEvent();
}
}
@Override
public Statistics getRunning(StatisticsUI statisticsUI) {
for (Statistics s : runningList.toArray(new Statistics[0])) {
if (statisticsUI.getStatisticsClass().equals(s)) {
return s;
}
}
return null;
}
public void setVisible(StatisticsUI statisticsUI, boolean visible) {
if (visible) {
if (invisibleList.remove(statisticsUI)) {
fireChangeEvent();
}
} else if (!invisibleList.contains(statisticsUI)) {
invisibleList.add(statisticsUI);
fireChangeEvent();
}
}
@Override
public void addChangeListener(ChangeListener changeListener) {
if (!listeners.contains(changeListener)) {
listeners.add(changeListener);
}
}
@Override
public void removeChangeListener(ChangeListener changeListener) {
listeners.remove(changeListener);
}
public void fireChangeEvent() {
ChangeEvent evt = new ChangeEvent(this);
for (ChangeListener listener : listeners) {
listener.stateChanged(evt);
}
}
public Workspace getWorkspace() {
return workspace;
}
//PERSISTENCE
public void writeXML(XMLStreamWriter writer) throws XMLStreamException {
writer.writeStartElement("results");
for (Map.Entry<StatisticsUI, String> entry : resultMap.entrySet()) {
if (entry.getValue() != null && !entry.getValue().isEmpty()) {
writer.writeStartElement("result");
writer.writeAttribute("class", entry.getKey().getClass().getName());
writer.writeAttribute("value", entry.getValue());
writer.writeEndElement();
}
}
writer.writeEndElement();
}
public void readXML(XMLStreamReader reader) throws XMLStreamException {<FILL_FUNCTION_BODY>}
}
|
Collection<? extends StatisticsUI> uis = Lookup.getDefault().lookupAll(StatisticsUI.class);
boolean end = false;
while (reader.hasNext() && !end) {
int type = reader.next();
switch (type) {
case XMLStreamReader.START_ELEMENT:
String name = reader.getLocalName();
if ("result".equalsIgnoreCase(name)) {
String classStr = reader.getAttributeValue(null, "class");
StatisticsUI resultUI = null;
for (StatisticsUI ui : uis) {
if (ui.getClass().getName().equals(classStr)) {
resultUI = ui;
}
}
if (resultUI != null) {
String value = reader.getAttributeValue(null, "value");
resultMap.put(resultUI, value);
}
}
break;
case XMLStreamReader.END_ELEMENT:
if ("statisticsmodelui".equalsIgnoreCase(reader.getLocalName())) {
end = true;
}
break;
}
}
| 1,024
| 277
| 1,301
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopStatistics/src/main/java/org/gephi/desktop/statistics/StatisticsPanel.java
|
StatisticsPanel
|
initCategories
|
class StatisticsPanel extends JPanel {
//Data
private StatisticsCategory[] categories;
private List<UIFrontEnd> frontEnds;
//UI
private JSqueezeBoxPanel squeezeBoxPanel;
public StatisticsPanel() {
initComponents();
initCategories();
initFrontEnds();
}
public void refreshModel(StatisticsModelUI model) {
boolean needRefreshVisible = false;
for (UIFrontEnd entry : frontEnds) {
entry.getFrontEnd().refreshModel(model);
if (model != null) {
boolean visible = model.isStatisticsUIVisible(entry.getStatisticsUI());
if (visible != entry.visible) {
needRefreshVisible = true;
entry.setVisible(visible);
}
}
}
if (needRefreshVisible) {
refreshFrontEnd();
}
}
private void refreshFrontEnd() {
squeezeBoxPanel.cleanPanels();
for (StatisticsCategory category : categories) {
//Find uis in this category
List<UIFrontEnd> uis = new ArrayList<>();
for (UIFrontEnd uife : frontEnds) {
if (uife.getCategory().equals(category) && uife.isVisible()) {
uis.add(uife);
}
}
if (uis.size() > 0) {
//Sort it by position
Collections.sort(uis, new Comparator() {
@Override
public int compare(Object o1, Object o2) {
Integer p1 = ((UIFrontEnd) o1).getStatisticsUI().getPosition();
Integer p2 = ((UIFrontEnd) o2).getStatisticsUI().getPosition();
return p1.compareTo(p2);
}
});
MigLayout migLayout = new MigLayout("insets 0");
migLayout.setColumnConstraints("[grow,fill]");
migLayout.setRowConstraints("[pref!]");
JPanel innerPanel = new JPanel(migLayout);
for (UIFrontEnd sui : uis) {
innerPanel.add(sui.frontEnd, "wrap");
}
squeezeBoxPanel.addPanel(innerPanel, category.getName());
}
}
}
private void initFrontEnds() {
StatisticsUI[] statisticsUIs = Lookup.getDefault().lookupAll(StatisticsUI.class).toArray(new StatisticsUI[0]);
frontEnds = new ArrayList<>();
for (StatisticsCategory category : categories) {
//Find uis in this category
List<StatisticsUI> uis = new ArrayList<>();
for (StatisticsUI sui : statisticsUIs) {
if (sui.getCategory().equals(category.getName())) {
uis.add(sui);
}
}
if (uis.size() > 0) {
//Sort it by position
Collections.sort(uis, new Comparator() {
@Override
public int compare(Object o1, Object o2) {
Integer p1 = ((StatisticsUI) o1).getPosition();
Integer p2 = ((StatisticsUI) o2).getPosition();
return p1.compareTo(p2);
}
});
MigLayout migLayout = new MigLayout("insets 0");
migLayout.setColumnConstraints("[grow,fill]");
migLayout.setRowConstraints("[pref!]");
JPanel innerPanel = new JPanel(migLayout);
for (StatisticsUI sui : uis) {
StatisticsFrontEnd frontEnd = new StatisticsFrontEnd(sui);
UIFrontEnd uife = new UIFrontEnd(sui, frontEnd, category);
frontEnds.add(uife);
innerPanel.add(frontEnd, "wrap");
}
squeezeBoxPanel.addPanel(innerPanel, category.getName());
}
}
}
private void initCategories() {<FILL_FUNCTION_BODY>}
private void initComponents() {
setLayout(new BorderLayout());
squeezeBoxPanel = new JSqueezeBoxPanel();
add(squeezeBoxPanel, BorderLayout.CENTER);
}
public StatisticsCategory[] getCategories() {
return categories;
}
private static class UIFrontEnd {
private final StatisticsUI statisticsUI;
private final StatisticsFrontEnd frontEnd;
private final StatisticsCategory category;
private boolean visible;
public UIFrontEnd(StatisticsUI statisticsUI, StatisticsFrontEnd frontEnd, StatisticsCategory category) {
this.statisticsUI = statisticsUI;
this.frontEnd = frontEnd;
this.category = category;
this.visible = true;
}
public boolean isVisible() {
return visible;
}
public void setVisible(boolean visible) {
this.visible = visible;
}
public StatisticsFrontEnd getFrontEnd() {
return frontEnd;
}
public StatisticsUI getStatisticsUI() {
return statisticsUI;
}
public StatisticsCategory getCategory() {
return category;
}
}
}
|
Map<String, StatisticsCategory> cats = new LinkedHashMap<>();
cats.put(StatisticsUI.CATEGORY_NETWORK_OVERVIEW,
new StatisticsCategory(StatisticsUI.CATEGORY_NETWORK_OVERVIEW, 100));
cats.put(StatisticsUI.CATEGORY_COMMUNITY_DETECTION,
new StatisticsCategory(StatisticsUI.CATEGORY_COMMUNITY_DETECTION, 150));
cats.put(StatisticsUI.CATEGORY_NODE_OVERVIEW, new StatisticsCategory(StatisticsUI.CATEGORY_NODE_OVERVIEW, 200));
cats.put(StatisticsUI.CATEGORY_EDGE_OVERVIEW, new StatisticsCategory(StatisticsUI.CATEGORY_EDGE_OVERVIEW, 300));
cats.put(StatisticsUI.CATEGORY_DYNAMIC, new StatisticsCategory(StatisticsUI.CATEGORY_DYNAMIC, 400));
int position = 500;
for (StatisticsUI uis : Lookup.getDefault().lookupAll(StatisticsUI.class)) {
String category = uis.getCategory();
if (!cats.containsKey(category)) {
cats.put(category, new StatisticsCategory(category, position));
position += 100;
}
}
categories = cats.values().toArray(new StatisticsCategory[0]);
| 1,351
| 384
| 1,735
|
<methods>public void <init>() ,public void <init>(java.awt.LayoutManager) ,public void <init>(boolean) ,public void <init>(java.awt.LayoutManager, boolean) ,public javax.accessibility.AccessibleContext getAccessibleContext() ,public javax.swing.plaf.PanelUI getUI() ,public java.lang.String getUIClassID() ,public void setUI(javax.swing.plaf.PanelUI) ,public void updateUI() <variables>private static final java.lang.String uiClassID
|
gephi_gephi
|
gephi/modules/DesktopStatistics/src/main/java/org/gephi/desktop/statistics/StatisticsTopComponent.java
|
StatisticsTopComponent
|
select
|
class StatisticsTopComponent extends TopComponent implements ChangeListener {
//Model
private transient StatisticsModelUIImpl model;
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton settingsButton;
private javax.swing.JPanel statisticsPanel;
private javax.swing.JToolBar toolbar;
// End of variables declaration//GEN-END:variables
public StatisticsTopComponent() {
initComponents();
initDesign();
setName(NbBundle.getMessage(StatisticsTopComponent.class, "CTL_StatisticsTopComponent"));
putClientProperty(TopComponent.PROP_MAXIMIZATION_DISABLED, Boolean.TRUE);
//Workspace events
final StatisticsControllerUI sc = Lookup.getDefault().lookup(StatisticsControllerUI.class);
ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);
pc.addWorkspaceListener(new WorkspaceListener() {
@Override
public void initialize(Workspace workspace) {
}
@Override
public void select(Workspace workspace) {<FILL_FUNCTION_BODY>}
@Override
public void unselect(Workspace workspace) {
}
@Override
public void close(Workspace workspace) {
}
@Override
public void disable() {
refreshModel(null);
}
});
if (pc.getCurrentWorkspace() != null) {
StatisticsModelUIImpl model = pc.getCurrentWorkspace().getLookup().lookup(StatisticsModelUIImpl.class);
if (model == null) {
model = new StatisticsModelUIImpl(pc.getCurrentWorkspace());
pc.getCurrentWorkspace().add(model);
}
refreshModel(model);
} else {
refreshModel(null);
}
//Settings
settingsButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
AvailableStatisticsChooser chooser = new AvailableStatisticsChooser();
chooser.setup(model, ((StatisticsPanel) statisticsPanel).getCategories());
DialogDescriptor dd = new DialogDescriptor(chooser,
NbBundle.getMessage(StatisticsTopComponent.class, "AvailableStatisticsChooser.title"));
if (DialogDisplayer.getDefault().notify(dd).equals(NotifyDescriptor.OK_OPTION)) {
chooser.unsetup();
}
}
});
}
private void refreshModel(StatisticsModelUIImpl model) {
if (model != null && model != this.model) {
if (this.model != null) {
this.model.removeChangeListener(this);
}
model.addChangeListener(this);
}
this.model = model;
Lookup.getDefault().lookup(StatisticsControllerUIImpl.class).setup(model);
refreshEnable(model != null);
((StatisticsPanel) statisticsPanel).refreshModel(model);
}
@Override
public void stateChanged(ChangeEvent e) {
refreshModel(model);
}
private void refreshEnable(boolean enable) {
statisticsPanel.setEnabled(enable);
toolbar.setEnabled(enable);
settingsButton.setEnabled(enable);
}
private void initDesign() {
Border b = (Border) UIManager.get("Nb.Editor.Toolbar.border"); //NOI18N
toolbar.setBorder(b);
if (UIUtils.isAquaLookAndFeel()) {
toolbar.setBackground(UIManager.getColor("NbExplorerView.background"));
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
toolbar = new javax.swing.JToolBar();
settingsButton = new javax.swing.JButton();
statisticsPanel = new StatisticsPanel();
setLayout(new java.awt.GridBagLayout());
toolbar.setFloatable(false);
toolbar.setRollover(true);
org.openide.awt.Mnemonics.setLocalizedText(settingsButton, org.openide.util.NbBundle
.getMessage(StatisticsTopComponent.class, "StatisticsTopComponent.settingsButton.text")); // NOI18N
settingsButton.setFocusable(false);
settingsButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
settingsButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
toolbar.add(settingsButton);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints.weightx = 1.0;
add(toolbar, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
add(statisticsPanel, gridBagConstraints);
}// </editor-fold>//GEN-END:initComponents
void writeProperties(java.util.Properties p) {
// better to version settings since initial version as advocated at
// http://wiki.apidesign.org/wiki/PropertyFiles
p.setProperty("version", "1.0");
// TODO store your settings
}
void readProperties(java.util.Properties p) {
String version = p.getProperty("version");
// TODO read your settings according to their version
}
}
|
StatisticsModelUIImpl model = workspace.getLookup().lookup(StatisticsModelUIImpl.class);
if (model == null) {
model = new StatisticsModelUIImpl(workspace);
workspace.add(model);
}
refreshModel(model);
| 1,626
| 75
| 1,701
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopStatistics/src/main/java/org/gephi/desktop/statistics/StatisticsUIPersistenceProvider.java
|
StatisticsUIPersistenceProvider
|
writeXML
|
class StatisticsUIPersistenceProvider implements WorkspaceXMLPersistenceProvider {
@Override
public void writeXML(XMLStreamWriter writer, Workspace workspace) {<FILL_FUNCTION_BODY>}
@Override
public void readXML(XMLStreamReader reader, Workspace workspace) {
StatisticsModelUIImpl statModel = workspace.getLookup().lookup(StatisticsModelUIImpl.class);
if (statModel == null) {
statModel = new StatisticsModelUIImpl(workspace);
workspace.add(statModel);
}
try {
statModel.readXML(reader);
} catch (XMLStreamException ex) {
throw new RuntimeException(ex);
}
}
@Override
public String getIdentifier() {
return "statisticsmodelui";
}
}
|
StatisticsModelUIImpl statModel = workspace.getLookup().lookup(StatisticsModelUIImpl.class);
if (statModel != null) {
try {
statModel.writeXML(writer);
} catch (XMLStreamException ex) {
throw new RuntimeException(ex);
}
}
| 211
| 84
| 295
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopTimeline/src/main/java/org/gephi/desktop/timeline/DateTick.java
|
DateTick
|
create
|
class DateTick {
//Consts
protected final static int MIN_PIXELS = 10;
//Fields
private final DateTime min;
private final DateTime max;
private final TickPeriod[] tickPeriods;
public DateTick(DateTime min, DateTime max, DateTimeFieldType[] types) {
this.min = min;
this.max = max;
this.tickPeriods = new TickPeriod[types.length];
for (int i = 0; i < types.length; i++) {
this.tickPeriods[i] = new TickPeriod(min, max, types[i]);
}
}
public static DateTick create(double min, double max, int width) {<FILL_FUNCTION_BODY>}
public int getTypeCount() {
return tickPeriods.length;
}
public Interval[] getIntervals(int type) {
return tickPeriods[type].getIntervals();
}
public String getTickValue(int type, DateTime dateTime) {
return tickPeriods[type].getTickValue(dateTime);
}
public DurationFieldType getDurationType(int type) {
return tickPeriods[type].getDurationType();
}
public int getTickPixelPosition(long ms, int width) {
long minMs = min.getMillis();
long maxMs = max.getMillis();
long duration = maxMs - minMs;
return (int) ((ms - minMs) * width / duration);
}
private static class TickPeriod {
protected final DateTime min;
protected final DateTime max;
protected final Period period;
protected final Interval interval;
protected final DateTimeFieldType type;
public TickPeriod(DateTime min, DateTime max, DateTimeFieldType type) {
this.min = min;
this.max = max;
this.period = new Period(min, max, PeriodType.forFields(new DurationFieldType[] {type.getDurationType()}));
this.interval = new Interval(min, max);
this.type = type;
}
public Interval[] getIntervals() {
int totalIntervals = period.get(type.getDurationType()) + 2;
Interval[] intervals = new Interval[totalIntervals];
for (int i = 0; i < totalIntervals; i++) {
Interval currentInterval;
if (i == 0) {
currentInterval = min.property(type).toInterval();
} else {
currentInterval = min.property(type).addToCopy(i).property(type).toInterval();
}
intervals[i] = currentInterval;
}
return intervals;
}
public int getIntervalCount() {
return period.get(type.getDurationType());
}
public String getTickValue(DateTime dateTime) {
return dateTime.property(type).getAsShortText();
}
public DurationFieldType getDurationType() {
return type.getDurationType();
}
}
}
|
DateTime minDate = new DateTime((long) min);
DateTime maxDate = new DateTime((long) max);
Period period = new Period(minDate, maxDate, PeriodType.yearMonthDayTime());
int years = period.getYears();
int months = period.getMonths();
int days = period.getDays();
int hours = period.getHours();
int minutes = period.getMinutes();
int seconds = period.getSeconds();
//Top type
DateTimeFieldType topType;
if (years > 0) {
topType = DateTimeFieldType.year();
} else if (months > 0) {
topType = DateTimeFieldType.monthOfYear();
} else if (days > 0) {
topType = DateTimeFieldType.dayOfMonth();
} else if (hours > 0) {
topType = DateTimeFieldType.hourOfDay();
} else if (minutes > 0) {
topType = DateTimeFieldType.minuteOfHour();
} else if (seconds > 0) {
topType = DateTimeFieldType.secondOfMinute();
} else {
topType = DateTimeFieldType.millisOfSecond();
}
//Bottom type
if (topType != DateTimeFieldType.millisOfSecond()) {
DateTimeFieldType bottomType;
if (topType.equals(DateTimeFieldType.year())) {
bottomType = DateTimeFieldType.monthOfYear();
} else if (topType.equals(DateTimeFieldType.monthOfYear())) {
bottomType = DateTimeFieldType.dayOfMonth();
} else if (topType.equals(DateTimeFieldType.dayOfMonth())) {
bottomType = DateTimeFieldType.hourOfDay();
} else if (topType.equals(DateTimeFieldType.hourOfDay())) {
bottomType = DateTimeFieldType.minuteOfHour();
} else if (topType.equals(DateTimeFieldType.minuteOfHour())) {
bottomType = DateTimeFieldType.secondOfMinute();
} else {
bottomType = DateTimeFieldType.millisOfSecond();
}
//Number of ticks
Period p = new Period(minDate, maxDate,
PeriodType.forFields(new DurationFieldType[] {bottomType.getDurationType()}));
int intervals = p.get(bottomType.getDurationType());
if (intervals > 0) {
int intervalSize = width / intervals;
if (intervalSize >= MIN_PIXELS) {
return new DateTick(minDate, maxDate, new DateTimeFieldType[] {topType, bottomType});
}
}
}
return new DateTick(minDate, maxDate, new DateTimeFieldType[] {topType});
| 774
| 673
| 1,447
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopTimeline/src/main/java/org/gephi/desktop/timeline/DrawerSettings.java
|
DrawerSettings
|
update
|
class DrawerSettings {
public Background background = new Background();
public SelectionBox selection = new SelectionBox();
public Stroke defaultStroke;
public Color defaultStrokeColor;
public Color shadowColor;
public int hookLength;
public RenderingHints renderingHints;
public Kernel convolutionKernel;
public ConvolveOp blurOperator;
public int tmMarginTop;
public int tmMarginBottom;
public int topChartMargin;
private int lastWidth = 0;
private int lastHeight = 0;
public DrawerSettings() {
/* DEFINE THEME HERE */
//background.top = new Color(101, 101, 101, 255);
//background.bottom = new Color(47, 45, 43, 255);
//background.top = new Color(131, 131, 131, 255);
//background.bottom = new Color(77, 75, 73, 255);
// background.top = new Color(151, 151, 151, 0);
background.top = UIManager.getColor("NbExplorerView.background");
background.bottom = new Color(97, 95, 93, 0);
// background.paint = new GradientPaint(0, 0, background.top, 0, 20, background.bottom, true);
//selection.top = new Color(89, 161, 235, 153);
//selection.bottom = new Color(37, 104, 161, 153);
selection.top = new Color(108, 151, 194, 50);
selection.bottom = new Color(57, 97, 131, 50);
selection.paint = new GradientPaint(0, 0, selection.top, 0, 20, selection.bottom, true);
selection.visibleHookWidth = 6; // the "visible hook" (mouse hook, to move the selection box)
selection.invisibleHookMargin = 1; // let the "invisible hook" be a bit larger on the left..
selection.minimalWidth = 16;
selection.mouseOverTopColor = new Color(102, 195, 145, 50);
selection.activatedTopColor = new Color(188, 118, 114, 50);
selection.mouseOverBottomColor = new Color(60, 143, 96, 50);
selection.activatedBottomColor = new Color(151, 79, 79, 50);
selection.mouseOverPaint =
new GradientPaint(0, 0, selection.mouseOverTopColor, 0, 20, selection.mouseOverBottomColor, true);
selection.activatedPaint =
new GradientPaint(0, 0, selection.activatedTopColor, 0, 20, selection.activatedBottomColor, true);
shadowColor = new Color(35, 35, 35, 105);
defaultStroke = new BasicStroke(1.0f);
defaultStrokeColor = Color.black;
hookLength = 8;
tmMarginTop = 0;
tmMarginBottom = 0;
topChartMargin = 16;
//System.out.println("Generating filters for " + this);
// filters
Map<Key, Object> map = new HashMap<>();
// bilinear
map.put(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BILINEAR);
map.put(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
// Antialiasing (text and image)
map.put(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
map.put(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
renderingHints = new RenderingHints(map);
// float ninth = 1.0f / 9.0f;
// float[] blurKernel = {ninth, ninth, ninth, ninth, ninth, ninth, ninth,
// ninth, ninth};
// convolutionKernel = new Kernel(3, 3, blurKernel);
// blurOperator = new ConvolveOp(convolutionKernel, ConvolveOp.EDGE_NO_OP,
// renderingHints);
}
void update(int width, int height) {<FILL_FUNCTION_BODY>}
public class Background {
public Color top;
public Color bottom;
public Paint paint;
}
public class SelectionBox {
public Color top;
public Color bottom;
public Paint paint;
public int visibleHookWidth; // the "visible hook" (mouse hook, to move the selection box)
public int invisibleHookMargin; // let the "invisible hook" be a bit larger on the left..
public int minimalWidth;
public Color mouseOverTopColor;
public Color activatedTopColor;
public Color mouseOverBottomColor;
public Color activatedBottomColor;
public Paint mouseOverPaint;
public Paint activatedPaint;
}
}
|
if (lastWidth == width && lastHeight == height) {
return;
}
lastWidth = width;
lastHeight = height;
// background.paint = new GradientPaint(0, 0, background.top, 0, height, background.bottom, true);
selection.paint = new GradientPaint(0, 0, selection.top, 0, height, selection.bottom, true);
selection.mouseOverPaint =
new GradientPaint(0, 0, selection.mouseOverTopColor, 0, height, selection.mouseOverBottomColor, true);
selection.activatedPaint =
new GradientPaint(0, 0, selection.activatedTopColor, 0, height, selection.activatedBottomColor, true);
| 1,419
| 193
| 1,612
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopTimeline/src/main/java/org/gephi/desktop/timeline/Sparkline.java
|
Sparkline
|
draw
|
class Sparkline {
private double min;
private double max;
private SparklineParameters parameters;
private TimelineChart chart;
private BufferedImage image;
public BufferedImage getImage(TimelineModel model, int width, int height) {
double newMin = model.getCustomMin();
double newMax = model.getCustomMax();
TimelineChart newChart = model.getChart();
if (chart == null || newMax != max || newMin != min || image.getWidth() != width || image.getHeight() != height
|| newChart != chart) {
min = newMin;
max = newMax;
chart = newChart;
if (chart != null) {
double minX = chart.getMinX().doubleValue();
double maxX = chart.getMaxX().doubleValue();
int sparklineWidth = (int) (((maxX - minX) / (max - min)) * width);
parameters = new SparklineParameters(sparklineWidth, height);
parameters.setTransparentBackground(true);
parameters.setDrawArea(true);
image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
int sparklineX = (int) ((minX - min) / (max - min) * width);
BufferedImage sparklineImage = draw();
Graphics g = image.getGraphics();
g.drawImage(sparklineImage, sparklineX, 0, null);
g.dispose();
} else {
return null;
}
}
return image;
}
private BufferedImage draw() {<FILL_FUNCTION_BODY>}
}
|
BufferedImage img =
SparklineGraph.draw(chart.getX(), chart.getY(), chart.getMinY(), chart.getMaxY(), parameters);
return img;
| 425
| 48
| 473
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopTimeline/src/main/java/org/gephi/desktop/timeline/StartEndTick.java
|
StartEndTick
|
getEndValue
|
class StartEndTick {
private final DecimalFormat decimalFormat;
private final int exponentMin;
private final int exponentMax;
private final double min;
private final double max;
public StartEndTick(double min, double max, int exponentMin, int exponentMax) {
decimalFormat = new DecimalFormat();
decimalFormat.setRoundingMode(RoundingMode.HALF_EVEN);
this.min = min;
this.max = max;
this.exponentMin = exponentMin;
this.exponentMax = exponentMax;
}
public static StartEndTick create(double min, double max) {
int exponentMin = (int) Math.round(Math.log10(min));
int exponentMax = (int) Math.round(Math.log10(max));
return new StartEndTick(min, max, exponentMin, exponentMax);
}
public int getExponentMax() {
return exponentMax;
}
public int getExponentMin() {
return exponentMin;
}
public double getMax() {
return max;
}
public double getMin() {
return min;
}
public String getStartValue() {
if (exponentMin > 0) {
return String.valueOf((long) min);
}
decimalFormat.setMaximumFractionDigits(Math.abs(exponentMin) + 2);
return decimalFormat.format(min);
}
public String getEndValue() {<FILL_FUNCTION_BODY>}
}
|
if (exponentMax > 0) {
return String.valueOf((long) max);
}
decimalFormat.setMaximumFractionDigits(Math.abs(exponentMax) + 2);
return decimalFormat.format(max);
| 399
| 63
| 462
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopTimeline/src/main/java/org/gephi/desktop/timeline/TimeFormatDialog.java
|
TimeFormatDialog
|
setup
|
class TimeFormatDialog extends javax.swing.JPanel {
private TimelineController timelineController;
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.ButtonGroup buttonGroup;
private javax.swing.JRadioButton dateRadio;
private javax.swing.JRadioButton dateTimeRadio;
private org.jdesktop.swingx.JXHeader headerTitle;
private javax.swing.JRadioButton numericRadio;
// End of variables declaration//GEN-END:variables
/**
* Creates new form DateFormatDialog
*/
public TimeFormatDialog() {
initComponents();
}
public void setup(TimelineModel model) {<FILL_FUNCTION_BODY>}
public void unsetup() {
if (dateRadio.isSelected()) {
timelineController.setTimeFormat(TimeFormat.DATE);
} else if (dateTimeRadio.isSelected()) {
timelineController.setTimeFormat(TimeFormat.DATETIME);
} else {
timelineController.setTimeFormat(TimeFormat.DOUBLE);
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
buttonGroup = new javax.swing.ButtonGroup();
headerTitle = new org.jdesktop.swingx.JXHeader();
dateRadio = new javax.swing.JRadioButton();
numericRadio = new javax.swing.JRadioButton();
dateTimeRadio = new javax.swing.JRadioButton();
headerTitle.setDescription(
NbBundle.getMessage(TimelineTopComponent.class, "TimeFormatDialog.headerTitle.description")); // NOI18N
headerTitle.setIcon(ImageUtilities.loadImageIcon("DesktopTimeline/time_format.png", false)); // NOI18N
headerTitle
.setTitle(NbBundle.getMessage(TimelineTopComponent.class, "TimeFormatDialog.headerTitle.title")); // NOI18N
buttonGroup.add(dateRadio);
dateRadio.setText(NbBundle.getMessage(TimelineTopComponent.class, "TimeFormatDialog.dateRadio.text")); // NOI18N
buttonGroup.add(numericRadio);
numericRadio
.setText(NbBundle.getMessage(TimelineTopComponent.class, "TimeFormatDialog.numericRadio.text")); // NOI18N
buttonGroup.add(dateTimeRadio);
dateTimeRadio.setText(org.openide.util.NbBundle
.getMessage(TimeFormatDialog.class, "TimeFormatDialog.dateTimeRadio.text")); // NOI18N
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(headerTitle, javax.swing.GroupLayout.DEFAULT_SIZE, 422, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addGap(23, 23, 23)
.addComponent(numericRadio)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(dateTimeRadio)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(dateRadio)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(headerTitle, javax.swing.GroupLayout.PREFERRED_SIZE, 69,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(numericRadio)
.addComponent(dateRadio)
.addComponent(dateTimeRadio))
.addGap(0, 22, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
}
|
this.timelineController = Lookup.getDefault().lookup(TimelineController.class);
TimeFormat timeFormat = model.getTimeFormat();
switch (timeFormat) {
case DATE:
dateRadio.setSelected(true);
break;
case DATETIME:
dateTimeRadio.setSelected(true);
break;
case DOUBLE:
numericRadio.setSelected(true);
break;
}
| 1,196
| 119
| 1,315
|
<methods>public void <init>() ,public void <init>(java.awt.LayoutManager) ,public void <init>(boolean) ,public void <init>(java.awt.LayoutManager, boolean) ,public javax.accessibility.AccessibleContext getAccessibleContext() ,public javax.swing.plaf.PanelUI getUI() ,public java.lang.String getUIClassID() ,public void setUI(javax.swing.plaf.PanelUI) ,public void updateUI() <variables>private static final java.lang.String uiClassID
|
gephi_gephi
|
gephi/modules/DesktopTimeline/src/main/java/org/gephi/desktop/timeline/TimelineTooltip.java
|
TimelineTooltip
|
buildData
|
class TimelineTooltip {
private static final int DELAY = 500;
private TimelineModel model;
private String position;
private String min;
private String max;
private String y;
private Timer timer;
private RichTooltip tooltip;
private final Lock lock = new ReentrantLock();
public void setModel(TimelineModel model) {
this.model = model;
}
public void start(final double currentPosition, final Point mousePosition, final JComponent component) {
stop();
if (model == null) {
return;
}
timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
lock.lock();
try {
if (tooltip != null) {
tooltip.hideTooltip();
}
buildData(currentPosition);
tooltip = buildTooltip();
tooltip.showTooltip(component, mousePosition);
} finally {
lock.unlock();
}
}
}, TimelineTooltip.DELAY);
}
public void stop() {
if (timer != null) {
timer.cancel();
}
lock.lock();
try {
if (tooltip != null) {
tooltip.hideTooltip();
}
} finally {
lock.unlock();
}
timer = null;
tooltip = null;
}
private void buildData(double currentPosition) {<FILL_FUNCTION_BODY>}
private RichTooltip buildTooltip() {
RichTooltip richTooltip = new RichTooltip();
//Min
richTooltip
.addDescriptionSection(NbBundle.getMessage(TimelineTooltip.class, "TimelineTooltip.min") + ": " + getMin());
//Max
richTooltip
.addDescriptionSection(NbBundle.getMessage(TimelineTooltip.class, "TimelineTooltip.max") + ": " + getMax());
//Title
richTooltip.setTitle(getPosition());
//Img
richTooltip.setMainImage(ImageUtilities.loadImage("DesktopTimeline/info.png", false));
//Chart
if (getY() != null) {
richTooltip.addFooterSection(model.getChart().getColumn());
richTooltip
.addFooterSection(NbBundle.getMessage(TimelineTooltip.class, "TimelineTooltip.chart") + ": " + getY());
//Img
richTooltip.setFooterImage(ImageUtilities.loadImage("DesktopTimeline/chart.png", false));
}
return richTooltip;
}
public String getY() {
return y;
}
public String getPosition() {
return position;
}
public String getMin() {
return min;
}
public String getMax() {
return max;
}
}
|
switch (model.getTimeFormat()) {
case DOUBLE:
int exponentMin = (int) Math.round(Math.log10(model.getCustomMin()));
DecimalFormat decimalFormat = new DecimalFormat();
decimalFormat.setRoundingMode(RoundingMode.HALF_EVEN);
if (exponentMin > 0) {
min = String.valueOf(model.getCustomMin());
max = String.valueOf(model.getCustomMax());
position = String.valueOf(currentPosition);
} else {
decimalFormat.setMaximumFractionDigits(Math.abs(exponentMin) + 2);
min = decimalFormat.format(model.getCustomMin());
max = decimalFormat.format(model.getCustomMax());
position = decimalFormat.format(currentPosition);
}
break;
case DATE: {
DateTime minDate = new DateTime((long) model.getCustomMin());
DateTime maxDate = new DateTime((long) model.getCustomMax());
DateTime posDate = new DateTime((long) currentPosition);
DateTimeFormatter formatter = ISODateTimeFormat.date();
min = formatter.print(minDate);
max = formatter.print(maxDate);
position = formatter.print(posDate);
break;
}
default: {
DateTime minDate = new DateTime((long) model.getCustomMin());
DateTime maxDate = new DateTime((long) model.getCustomMax());
DateTime posDate = new DateTime((long) currentPosition);
DateTimeFormatter formatter = ISODateTimeFormat.dateTime();
min = formatter.print(minDate);
max = formatter.print(maxDate);
position = formatter.print(posDate);
break;
}
}
if (model.getChart() != null) {
TimelineChart chart = model.getChart();
Number yNumber = chart.getY(currentPosition);
y = yNumber != null ? yNumber.toString() : null;
} else {
y = null;
}
| 757
| 515
| 1,272
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopTimeline/src/main/java/org/gephi/desktop/timeline/TimelineWindowAction.java
|
TimelineWindowAction
|
actionPerformed
|
class TimelineWindowAction implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {<FILL_FUNCTION_BODY>}
}
|
BottomComponentImpl bottomComponent = Lookup.getDefault().lookup(BottomComponentImpl.class);
if (bottomComponent != null) {
bottomComponent.setVisible(!bottomComponent.isVisible());
}
| 46
| 60
| 106
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopTools/src/main/java/org/gephi/desktop/tools/MouseSelectionPopupPanel.java
|
MouseSelectionPopupPanel
|
initComponents
|
class MouseSelectionPopupPanel extends javax.swing.JPanel {
private ChangeListener changeListener;
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JSlider diameterSlider;
private javax.swing.JLabel labelDiameter;
private javax.swing.JLabel labelValue;
private javax.swing.JCheckBox proportionnalZoomCheckbox;
private org.jdesktop.beansbinding.BindingGroup bindingGroup;
// End of variables declaration//GEN-END:variables
/**
* Creates new form MouseSelectionPopupPanel
*/
public MouseSelectionPopupPanel() {
initComponents();
diameterSlider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
JSlider source = (JSlider) e.getSource();
if (!source.getValueIsAdjusting()) {
fireChangeEvent(source);
}
}
});
proportionnalZoomCheckbox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
fireChangeEvent(proportionnalZoomCheckbox);
}
});
}
public boolean isProportionnalToZoom() {
return proportionnalZoomCheckbox.isSelected();
}
public void setProportionnalToZoom(boolean proportionnalToZoom) {
proportionnalZoomCheckbox.setSelected(proportionnalToZoom);
}
public int getDiameter() {
return diameterSlider.getValue();
}
public void setDiameter(int diameter) {
diameterSlider.setValue(diameter);
}
public void setChangeListener(ChangeListener changeListener) {
this.changeListener = changeListener;
}
private void fireChangeEvent(Object source) {
if (changeListener != null) {
ChangeEvent changeEvent = new ChangeEvent(source);
changeListener.stateChanged(changeEvent);
}
}
/**
* This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {<FILL_FUNCTION_BODY>}// </editor-fold>//GEN-END:initComponents
}
|
java.awt.GridBagConstraints gridBagConstraints;
bindingGroup = new org.jdesktop.beansbinding.BindingGroup();
labelDiameter = new javax.swing.JLabel();
diameterSlider = new javax.swing.JSlider();
labelValue = new javax.swing.JLabel();
proportionnalZoomCheckbox = new javax.swing.JCheckBox();
setLayout(new java.awt.GridBagLayout());
setOpaque(true);
diameterSlider.setOpaque(true);
labelDiameter.setText(org.openide.util.NbBundle
.getMessage(MouseSelectionPopupPanel.class, "MouseSelectionPopupPanel.labelDiameter.text")); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.FIRST_LINE_START;
gridBagConstraints.insets = new java.awt.Insets(6, 5, 8, 0);
add(labelDiameter, gridBagConstraints);
diameterSlider.setMaximum(1000);
diameterSlider.setMinimum(1);
diameterSlider.setValue(1);
diameterSlider.setFocusable(false);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.weightx = 1.0;
add(diameterSlider, gridBagConstraints);
org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings
.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, diameterSlider,
org.jdesktop.beansbinding.ELProperty.create("${value}"), labelValue,
org.jdesktop.beansbinding.BeanProperty.create("text"));
bindingGroup.addBinding(binding);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.FIRST_LINE_END;
gridBagConstraints.insets = new java.awt.Insets(6, 0, 8, 5);
add(labelValue, gridBagConstraints);
proportionnalZoomCheckbox.setText(org.openide.util.NbBundle.getMessage(MouseSelectionPopupPanel.class,
"MouseSelectionPopupPanel.proportionnalZoomCheckbox.text")); // NOI18N
proportionnalZoomCheckbox.setFocusable(false);
proportionnalZoomCheckbox.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(10, 5, 5, 0);
add(proportionnalZoomCheckbox, gridBagConstraints);
bindingGroup.bind();
| 650
| 984
| 1,634
|
<methods>public void <init>() ,public void <init>(java.awt.LayoutManager) ,public void <init>(boolean) ,public void <init>(java.awt.LayoutManager, boolean) ,public javax.accessibility.AccessibleContext getAccessibleContext() ,public javax.swing.plaf.PanelUI getUI() ,public java.lang.String getUIClassID() ,public void setUI(javax.swing.plaf.PanelUI) ,public void updateUI() <variables>private static final java.lang.String uiClassID
|
gephi_gephi
|
gephi/modules/DesktopTools/src/main/java/org/gephi/desktop/tools/PropertiesBar.java
|
PropertiesBar
|
getFullScreenIcon
|
class PropertiesBar extends JPanel {
private final SelectionBar selectionBar;
private JPanel propertiesBar;
public PropertiesBar() {
super(new BorderLayout());
JPanel leftPanel = new JPanel(new BorderLayout());
leftPanel.setOpaque(true);
leftPanel.add(getFullScreenIcon(), BorderLayout.WEST);
leftPanel.add(selectionBar = new SelectionBar(), BorderLayout.CENTER);
add(leftPanel, BorderLayout.WEST);
setOpaque(true);
}
public void select(JPanel propertiesBar) {
this.propertiesBar = propertiesBar;
propertiesBar.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2));
add(propertiesBar, BorderLayout.CENTER);
propertiesBar.setOpaque(true);
for (Component c : propertiesBar.getComponents()) {
if (c instanceof JPanel || c instanceof JToolBar) {
((JComponent) c).setOpaque(true);
}
}
revalidate();
}
public void unselect() {
if (propertiesBar != null) {
remove(propertiesBar);
revalidate();
repaint();
propertiesBar = null;
}
}
private JComponent getFullScreenIcon() {<FILL_FUNCTION_BODY>}
@Override
public void setEnabled(final boolean enabled) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
for (Component c : getComponents()) {
c.setEnabled(enabled);
}
selectionBar.setEnabled(enabled);
}
});
}
}
|
int logoWidth = 27;
int logoHeight = 28;
//fullscreen icon size
if (UIUtils.isAquaLookAndFeel()) {
logoWidth = 34;
}
JPanel c = new JPanel(new BorderLayout());
c.setBackground(Color.WHITE);
if (!UIUtils.isAquaLookAndFeel()) {
JButton fullScreenButton = new JButton();
fullScreenButton
.setIcon(ImageUtilities.loadImageIcon("DesktopTools/gephilogo_std.png", false));
fullScreenButton.setRolloverEnabled(true);
fullScreenButton
.setRolloverIcon(ImageUtilities.loadImageIcon("DesktopTools/gephilogo_glow.png", false));
fullScreenButton
.setToolTipText(NbBundle.getMessage(PropertiesBar.class, "PropertiesBar.fullScreenButton.tooltip"));
fullScreenButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Lookup lookup = Lookups.forPath("org-gephi-desktop-tools/Actions/ToggleFullScreenAction");
for (Action a : lookup.lookupAll(Action.class)) {
a.actionPerformed(null);
}
}
});
fullScreenButton.setBorderPainted(false);
fullScreenButton.setContentAreaFilled(false);
fullScreenButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
fullScreenButton.setBorder(BorderFactory.createEmptyBorder());
fullScreenButton.setPreferredSize(new Dimension(logoWidth, logoHeight));
c.add(fullScreenButton, BorderLayout.CENTER);
}
return c;
| 442
| 447
| 889
|
<methods>public void <init>() ,public void <init>(java.awt.LayoutManager) ,public void <init>(boolean) ,public void <init>(java.awt.LayoutManager, boolean) ,public javax.accessibility.AccessibleContext getAccessibleContext() ,public javax.swing.plaf.PanelUI getUI() ,public java.lang.String getUIClassID() ,public void setUI(javax.swing.plaf.PanelUI) ,public void updateUI() <variables>private static final java.lang.String uiClassID
|
gephi_gephi
|
gephi/modules/DesktopTools/src/main/java/org/gephi/desktop/tools/SelectionBar.java
|
SelectionBar
|
refresh
|
class SelectionBar extends javax.swing.JPanel {
// Variables declaration - do not modify//GEN-BEGIN:variables
private org.jdesktop.swingx.JXHyperlink configureLink;
private javax.swing.JSeparator endSeparator;
private javax.swing.JLabel statusLabel;
// End of variables declaration//GEN-END:variables
/**
* Creates new form SelectionBar
*/
public SelectionBar() {
initComponents();
VizController.getInstance().getSelectionManager().addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
refresh();
}
});
refresh();
configureLink.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (statusLabel.isEnabled()) {
JPopupMenu menu = createPopup();
menu.show(statusLabel, 0, statusLabel.getHeight());
}
}
});
}
public JPopupMenu createPopup() {
SelectionManager manager = VizController.getInstance().getSelectionManager();
final MouseSelectionPopupPanel popupPanel = new MouseSelectionPopupPanel();
popupPanel.setDiameter(manager.getMouseSelectionDiameter());
popupPanel.setProportionnalToZoom(manager.isMouseSelectionZoomProportionnal());
popupPanel.setChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
SelectionManager manager = VizController.getInstance().getSelectionManager();
manager.setMouseSelectionDiameter(popupPanel.getDiameter());
manager.setMouseSelectionZoomProportionnal(popupPanel.isProportionnalToZoom());
}
});
JPopupMenu menu = new JPopupMenu();
menu.add(popupPanel);
return menu;
}
public void refresh() {<FILL_FUNCTION_BODY>}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
statusLabel = new javax.swing.JLabel();
configureLink = new org.jdesktop.swingx.JXHyperlink();
endSeparator = new javax.swing.JSeparator();
setPreferredSize(new java.awt.Dimension(180, 28));
setLayout(new java.awt.GridBagLayout());
setOpaque(true);
statusLabel.setFont(statusLabel.getFont().deriveFont((float) 10));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(0, 4, 1, 0);
add(statusLabel, gridBagConstraints);
configureLink.setText(
org.openide.util.NbBundle.getMessage(SelectionBar.class, "SelectionBar.configureLink.text")); // NOI18N
configureLink.setDefaultCapable(false);
configureLink.setFocusable(false);
configureLink.setFont(new java.awt.Font("Lucida Grande", 0, 10)); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0);
add(configureLink, gridBagConstraints);
endSeparator.setOrientation(javax.swing.SwingConstants.VERTICAL);
endSeparator.setPreferredSize(new java.awt.Dimension(3, 22));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 0;
gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.FIRST_LINE_END;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.insets = new java.awt.Insets(3, 0, 3, 0);
add(endSeparator, gridBagConstraints);
}// </editor-fold>//GEN-END:initComponents
@Override
public void setEnabled(final boolean enabled) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
for (Component c : getComponents()) {
c.setEnabled(enabled);
}
}
});
}
}
|
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
SelectionManager manager = VizController.getInstance().getSelectionManager();
if (manager.isSelectionEnabled()) {
if (manager.isRectangleSelection()) {
configureLink.setVisible(false);
statusLabel.setText(
NbBundle.getMessage(SelectionBar.class, "SelectionBar.statusLabel.rectangleSelection"));
} else if (manager.isDirectMouseSelection()) {
configureLink.setVisible(true);
statusLabel.setText(
NbBundle.getMessage(SelectionBar.class, "SelectionBar.statusLabel.mouseSelection"));
} else if (manager.isDraggingEnabled()) {
configureLink.setVisible(true);
statusLabel
.setText(NbBundle.getMessage(SelectionBar.class, "SelectionBar.statusLabel.dragging"));
}
} else {
configureLink.setVisible(false);
statusLabel
.setText(NbBundle.getMessage(SelectionBar.class, "SelectionBar.statusLabel.noSelection"));
}
}
});
| 1,387
| 280
| 1,667
|
<methods>public void <init>() ,public void <init>(java.awt.LayoutManager) ,public void <init>(boolean) ,public void <init>(java.awt.LayoutManager, boolean) ,public javax.accessibility.AccessibleContext getAccessibleContext() ,public javax.swing.plaf.PanelUI getUI() ,public java.lang.String getUIClassID() ,public void setUI(javax.swing.plaf.PanelUI) ,public void updateUI() <variables>private static final java.lang.String uiClassID
|
gephi_gephi
|
gephi/modules/DesktopTools/src/main/java/org/gephi/desktop/tools/Toolbar.java
|
Toolbar
|
setEnabled
|
class Toolbar extends JToolBar {
private final ButtonGroup buttonGroup;
public Toolbar() {
initDesign();
buttonGroup = new ButtonGroup();
}
private void initDesign() {
setFloatable(false);
setOrientation(JToolBar.VERTICAL);
putClientProperty("JToolBar.isRollover", Boolean.TRUE); //NOI18N
setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2));
setOpaque(true);
}
@Override
public void setEnabled(final boolean enabled) {<FILL_FUNCTION_BODY>}
public void clearSelection() {
buttonGroup.clearSelection();
}
@Override
public Component add(Component comp) {
if (comp instanceof JButton) {
UIUtils.fixButtonUI((JButton) comp);
}
if (comp instanceof AbstractButton) {
buttonGroup.add((AbstractButton) comp);
}
return super.add(comp);
}
}
|
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
for (Component c : getComponents()) {
c.setEnabled(enabled);
}
}
});
| 266
| 62
| 328
|
<methods>public void <init>() ,public void <init>(int) ,public void <init>(java.lang.String) ,public void <init>(java.lang.String, int) ,public javax.swing.JButton add(javax.swing.Action) ,public void addSeparator() ,public void addSeparator(java.awt.Dimension) ,public javax.accessibility.AccessibleContext getAccessibleContext() ,public java.awt.Component getComponentAtIndex(int) ,public int getComponentIndex(java.awt.Component) ,public java.awt.Insets getMargin() ,public int getOrientation() ,public javax.swing.plaf.ToolBarUI getUI() ,public java.lang.String getUIClassID() ,public boolean isBorderPainted() ,public boolean isFloatable() ,public boolean isRollover() ,public void setBorderPainted(boolean) ,public void setFloatable(boolean) ,public void setLayout(java.awt.LayoutManager) ,public void setMargin(java.awt.Insets) ,public void setOrientation(int) ,public void setRollover(boolean) ,public void setUI(javax.swing.plaf.ToolBarUI) ,public void updateUI() <variables>private boolean floatable,private java.awt.Insets margin,private int orientation,private boolean paintBorder,private static final java.lang.String uiClassID
|
gephi_gephi
|
gephi/modules/DesktopWindow/src/main/java/org/gephi/desktop/banner/BannerComponent.java
|
BannerComponent
|
initComponents
|
class BannerComponent extends javax.swing.JPanel {
private final transient PerspectiveController perspectiveController;
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel buttonsPanel;
private javax.swing.JPanel mainPanel;
private javax.swing.ButtonGroup perspectivesButtonGroup;
private javax.swing.JPanel workspacePanel;
// End of variables declaration//GEN-END:variables
public BannerComponent() {
initComponents();
// Make the workspace tab stand out well
if (UIUtils.isFlatLafLightLookAndFeel()) {
mainPanel.setBackground(Color.WHITE);
workspacePanel.setBackground(Color.WHITE);
} else if (UIUtils.isFlatLafDarkLookAndFeel()) {
Color cl = UIManager.getColor("EditorTab.background");
mainPanel.setBackground(cl);
workspacePanel.setBackground(cl);
}
// Button panel border so it matches with the workspace panel
buttonsPanel.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createMatteBorder(0, 0, 1, 0, UIManager.getColor("Component.borderColor")),
BorderFactory.createEmptyBorder(6, 0, 6, 5)));
workspacePanel.setBorder(BorderFactory.createEmptyBorder(12, 0, 0, 0));
//Init perspective controller
perspectiveController = Lookup.getDefault().lookup(PerspectiveController.class);
addGroupTabs();
}
private void addGroupTabs() {
JToggleButton[] buttons = new JToggleButton[perspectiveController.getPerspectives().length];
int i = 0;
//Add tabs
for (final Perspective perspective : perspectiveController.getPerspectives()) {
JToggleButton toggleButton =
new JToggleButton(perspective.getDisplayName(), perspective.getIcon());
toggleButton.setFocusPainted(false);
toggleButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
toggleButton.addActionListener(e -> perspectiveController.selectPerspective(perspective));
perspectivesButtonGroup.add(toggleButton);
buttonsPanel.add(toggleButton);
buttons[i++] = toggleButton;
}
//Set currently selected button
perspectivesButtonGroup.setSelected(buttons[getSelectedPerspectiveIndex()].getModel(), true);
}
public int getSelectedPerspectiveIndex() {
int i = 0;
for (Perspective p : perspectiveController.getPerspectives()) {
if (p.equals(perspectiveController.getSelectedPerspective())) {
return i;
}
i++;
}
return -1;
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {<FILL_FUNCTION_BODY>}// </editor-fold>//GEN-END:initComponents
}
|
perspectivesButtonGroup = new javax.swing.ButtonGroup();
mainPanel = new javax.swing.JPanel();
workspacePanel = new org.gephi.desktop.banner.workspace.WorkspacePanel();
buttonsPanel = new javax.swing.JPanel();
setBackground(new java.awt.Color(255, 255, 255));
setLayout(new java.awt.BorderLayout());
mainPanel.setLayout(new java.awt.BorderLayout());
workspacePanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(6, 0, 0, 0));
mainPanel.add(workspacePanel, java.awt.BorderLayout.CENTER);
buttonsPanel.setOpaque(false);
buttonsPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 6, 0));
mainPanel.add(buttonsPanel, java.awt.BorderLayout.WEST);
add(mainPanel, java.awt.BorderLayout.CENTER);
| 837
| 267
| 1,104
|
<methods>public void <init>() ,public void <init>(java.awt.LayoutManager) ,public void <init>(boolean) ,public void <init>(java.awt.LayoutManager, boolean) ,public javax.accessibility.AccessibleContext getAccessibleContext() ,public javax.swing.plaf.PanelUI getUI() ,public java.lang.String getUIClassID() ,public void setUI(javax.swing.plaf.PanelUI) ,public void updateUI() <variables>private static final java.lang.String uiClassID
|
gephi_gephi
|
gephi/modules/DesktopWindow/src/main/java/org/gephi/desktop/banner/Installer.java
|
Installer
|
run
|
class Installer extends ModuleInstall {
@Override
public void restored() {
//Initialize the perspective controller
Lookup.getDefault().lookup(PerspectiveController.class);
// Init Banner
initBanner();
}
private void initBanner() {
WindowManager.getDefault().invokeWhenUIReady(new Runnable() {
@Override
public void run() {<FILL_FUNCTION_BODY>}
});
}
}
|
final JFrame frame = (JFrame) WindowManager.getDefault().getMainWindow();
Container contentPane = ((JRootPane) frame.getComponents()[0]).getContentPane();
//Add Banner
JComponent toolbar = new BannerComponent();
frame.getContentPane().add(toolbar, BorderLayout.NORTH);
//Get the bottom component
BottomComponent bottomComponentImpl = Lookup.getDefault().lookup(BottomComponent.class);
JComponent bottomComponent = bottomComponentImpl != null ? bottomComponentImpl.getComponent() : null;
JComponent statusLinePanel = null;
JPanel childPanel = (JPanel) contentPane.getComponents()[1];
JLayeredPane layeredPane = (JLayeredPane) childPanel.getComponents()[0];
Container desktopPanel = (Container) layeredPane.getComponent(0);
for (Component c : desktopPanel.getComponents()) {
if (c instanceof JPanel) {
JPanel cp = (JPanel) c;
for (Component cpnt : cp.getComponents()) {
if (cpnt.getName() != null && cpnt.getName().equals("statusLine")) {
statusLinePanel = (JComponent) cpnt;
break;
}
}
if (statusLinePanel != null && bottomComponent != null) {
statusLinePanel.add(bottomComponent, BorderLayout.NORTH);
break;
}
}
}
| 123
| 372
| 495
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/DesktopWindow/src/main/java/org/gephi/desktop/progress/ProgressTicketImpl.java
|
ProgressTicketImpl
|
finish
|
class ProgressTicketImpl implements ProgressTicket {
private final ProgressHandle handle;
private String displayName;
private int progress100 = 0;
private int progressTotal;
private int currentUnit = 0;
private boolean started = false;
private boolean finished = false;
public ProgressTicketImpl(String displayName, Cancellable cancellable) {
handle = ProgressHandleFactory.createHandle(displayName, cancellable);
this.displayName = displayName;
}
/**
* Finish the task.
*/
@Override
public void finish() {
if (handle != null && started && !finished) {
try {
handle.finish();
finished = true;
} catch (Exception e) {
}
}
}
/**
* Finish the task and display a statusbar message
*
* @param finishMessage Finish message
*/
@Override
public void finish(String finishMessage) {<FILL_FUNCTION_BODY>}
/**
* Notify the user about a new completed unit. Equivalent to incrementing workunits by one.
*/
@Override
public void progress() {
progress(currentUnit + 1);
}
/**
* Notify the user about completed workunits.
*
* @param workunit cumulative number of workunits completed so far
*/
@Override
public void progress(int workunit) {
this.currentUnit = workunit;
if (handle != null) {
int ratioProgress = (int) (100.0 * workunit / progressTotal);
if (ratioProgress != progress100) {
progress100 = ratioProgress;
handle.progress(progress100 <= 100 ? progress100 : 100);
}
}
}
/**
* Notify the user about progress by showing message with details.
*
* @param message details about the status of the task
*/
@Override
public void progress(String message) {
if (handle != null) {
handle.progress(message);
}
}
/**
* Notify the user about completed workunits and show additional detailed message.
*
* @param message details about the status of the task
* @param workunit a cumulative number of workunits completed so far
*/
@Override
public void progress(String message, int workunit) {
currentUnit = workunit;
if (handle != null) {
int ratioProgress = (int) (100.0 * workunit / progressTotal);
if (ratioProgress != progress100) {
progress100 = ratioProgress;
handle.progress(message, progress100 <= 100 ? progress100 : 100);
}
}
}
/**
* Returns the current display name.
*
* @return the current task's display name
*/
@Override
public String getDisplayName() {
return displayName;
}
/**
* Change the display name of the progress task. Use with care, please make sure the changed name is not completely different, or otherwise it might appear to the user as a different task.
*
* @param newDisplayName the new display name
*/
@Override
public void setDisplayName(String newDisplayName) {
if (handle != null) {
handle.setDisplayName(newDisplayName);
this.displayName = newDisplayName;
}
}
/**
* Start the progress indication for indeterminate task.
*/
@Override
public void start() {
if (handle != null && !started) {
started = true;
handle.start();
}
}
/**
* Start the progress indication for a task with known number of steps.
*
* @param workunits total number of workunits that will be processed
*/
@Override
public void start(int workunits) {
if (handle != null && !started) {
started = true;
this.progressTotal = workunits;
handle.start(100);
} else if (started && progressTotal == 0){
switchToDeterminate(workunits);
}
}
/**
* Currently indeterminate task can be switched to show percentage completed.
*
* @param workunits workunits total number of workunits that will be processed
*/
@Override
public void switchToDeterminate(int workunits) {
if (handle != null) {
if (started) {
this.progressTotal = workunits;
handle.switchToDeterminate(100);
} else {
start(workunits);
}
}
}
/**
* Currently determinate task can be switched to indeterminate mode.
*/
@Override
public void switchToIndeterminate() {
if (handle != null) {
handle.switchToIndeterminate();
}
}
}
|
if (handle != null && started && !finished) {
try {
handle.finish();
finished = true;
} catch (Exception e) {
}
StatusDisplayer.getDefault().setStatusText(finishMessage);
}
| 1,285
| 67
| 1,352
|
<no_super_class>
|
gephi_gephi
|
gephi/modules/ExportAPI/src/main/java/org/gephi/io/exporter/impl/ExportControllerImpl.java
|
ExportControllerImpl
|
exportFile
|
class ExportControllerImpl implements ExportController {
private final FileExporterBuilder[] fileExporterBuilders;
private final ExporterUI[] uis;
public ExportControllerImpl() {
Lookup.getDefault().lookupAll(GraphFileExporterBuilder.class);
Lookup.getDefault().lookupAll(VectorFileExporterBuilder.class);
fileExporterBuilders =
Lookup.getDefault().lookupAll(FileExporterBuilder.class).toArray(new FileExporterBuilder[0]);
uis = Lookup.getDefault().lookupAll(ExporterUI.class).toArray(new ExporterUI[0]);
}
@Override
public void exportFile(File file) throws IOException {
Exporter fileExporter = getFileExporter(file);
if (fileExporter == null) {
throw new RuntimeException(
NbBundle.getMessage(ExportControllerImpl.class, "ExportControllerImpl.error.nomatchingexporter"));
}
exportFile(file, fileExporter);
}
@Override
public void exportFile(File file, Workspace workspace) throws IOException {
Exporter fileExporter = getFileExporter(file);
if (fileExporter == null) {
throw new RuntimeException(
NbBundle.getMessage(ExportControllerImpl.class, "ExportControllerImpl.error.nomatchingexporter"));
}
fileExporter.setWorkspace(workspace);
exportFile(file, fileExporter);
}
@Override
public void exportFile(File file, Exporter fileExporter) throws IOException {<FILL_FUNCTION_BODY>}
@Override
public void exportStream(OutputStream stream, ByteExporter byteExporter) {
if (byteExporter.getWorkspace() == null) {
ProjectController projectController = Lookup.getDefault().lookup(ProjectController.class);
Workspace workspace = projectController.getCurrentWorkspace();
byteExporter.setWorkspace(workspace);
}
byteExporter.setOutputStream(stream);
try {
byteExporter.execute();
} catch (Exception ex) {
try {
stream.flush();
stream.close();
} catch (IOException exe) {
}
if (ex instanceof RuntimeException) {
throw (RuntimeException) ex;
}
throw new RuntimeException(ex);
}
try {
stream.flush();
stream.close();
} catch (IOException ex) {
}
}
@Override
public void exportWriter(Writer writer, CharacterExporter characterExporter) {
if (characterExporter.getWorkspace() == null) {
ProjectController projectController = Lookup.getDefault().lookup(ProjectController.class);
Workspace workspace = projectController.getCurrentWorkspace();
characterExporter.setWorkspace(workspace);
}
characterExporter.setWriter(writer);
try {
characterExporter.execute();
} catch (Exception ex) {
try {
writer.flush();
writer.close();
} catch (IOException exe) {
}
if (ex instanceof RuntimeException) {
throw (RuntimeException) ex;
}
throw new RuntimeException(ex);
}
try {
writer.flush();
writer.close();
} catch (IOException ex) {
}
}
@Override
public Exporter getFileExporter(File file) {
for (FileExporterBuilder im : fileExporterBuilders) {
for (FileType ft : im.getFileTypes()) {
for (String ex : ft.getExtensions()) {
if (hasExt(file, ex)) {
return im.buildExporter();
}
}
}
}
return null;
}
@Override
public Exporter getExporter(String exporterName) {
for (FileExporterBuilder im : fileExporterBuilders) {
if (im.getName().equalsIgnoreCase(exporterName)) {
return im.buildExporter();
}
}
for (FileExporterBuilder im : fileExporterBuilders) {
for (FileType ft : im.getFileTypes()) {
for (String ex : ft.getExtensions()) {
if (ex.equalsIgnoreCase(exporterName)) {
return im.buildExporter();
}
}
}
}
return null;
}
@Override
public ExporterUI getUI(Exporter exporter) {
for (ExporterUI ui : uis) {
if (ui.isUIForExporter(exporter)) {
return ui;
}
}
return null;
}
private boolean hasExt(File file, String ext) {
if (ext == null || ext.isEmpty()) {
return false;
}
/** period at first position is not considered as extension-separator */
if ((file.getName().length() - ext.length()) <= 1) {
return false;
}
boolean ret = file.getName().endsWith(ext);
return ret;
}
}
|
if (fileExporter.getWorkspace() == null) {
ProjectController projectController = Lookup.getDefault().lookup(ProjectController.class);
Workspace workspace = projectController.getCurrentWorkspace();
fileExporter.setWorkspace(workspace);
}
if (fileExporter instanceof ByteExporter) {
OutputStream stream = new BufferedOutputStream(new FileOutputStream(file));
((ByteExporter) fileExporter).setOutputStream(stream);
try {
fileExporter.execute();
} catch (Exception ex) {
try {
stream.flush();
stream.close();
} catch (IOException exe) {
}
if (ex instanceof RuntimeException) {
throw (RuntimeException) ex;
}
throw new RuntimeException(ex);
}
try {
stream.flush();
stream.close();
} catch (IOException ex) {
}
} else if (fileExporter instanceof CharacterExporter) {
Writer writer = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8);
((CharacterExporter) fileExporter).setWriter(writer);
try {
fileExporter.execute();
} catch (Exception ex) {
try {
writer.flush();
writer.close();
} catch (IOException exe) {
}
if (ex instanceof RuntimeException) {
throw (RuntimeException) ex;
}
throw new RuntimeException(ex);
}
try {
writer.flush();
writer.close();
} catch (IOException ex) {
}
}
| 1,277
| 400
| 1,677
|
<no_super_class>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.