use of org.cytoscape.filter.internal.widgets.autocomplete.view.TextIndexComboBox in project cytoscape-impl by cytoscape.
the class FilterSettingPanel method getTextIndexComboBox.
private JComboBox getTextIndexComboBox(StringFilter pFilter) {
TextIndexComboBox comboBox = null;
try {
// If index doesnot exist, check if there is such attribute or
if (!FilterUtil.hasSuchAttribute(pFilter.getNetwork(), pFilter.getControllingAttribute(), pFilter.getIndexType())) {
// no such attribute
JComboBox tmpCombo;
if (pFilter.getSearchStr() != null) {
Object[] objList = { pFilter.getSearchStr() };
tmpCombo = new JComboBox(objList);
} else {
tmpCombo = new JComboBox();
}
tmpCombo.setEnabled(false);
return tmpCombo;
}
// The attribute exists, create an index
// final QuickFind quickFind = QuickFindFactory.getGlobalQuickFindInstance();
// quickFind.reindexNetwork(Cytoscape.getCurrentNetwork(), pFilter.getIndexType(),
// pFilter.getControllingAttribute(), new TaskMonitorBase());
// TextIndex index_by_thisAttr = (TextIndex) quickFind.getIndex(Cytoscape.getCurrentNetwork());
pFilter.setIndex(createTextIndex(pFilter));
comboBox = ComboBoxFactory.createTextIndexComboBox((TextIndex) pFilter.getIndex(), 2.0);
// Set Size of ComboBox Display, based on # of specific chars
comboBox.setPrototypeDisplayValue("01234567");
// Set Max Size of ComboBox to match preferred size
comboBox.setMaximumSize(comboBox.getPreferredSize());
comboBox.setName(pFilter.getControllingAttribute());
if (pFilter.getSearchStr() != null) {
comboBox.setSelectedItem(pFilter.getSearchStr());
}
ActionListener listener = new UserSelectionListener(comboBox);
comboBox.addFinalSelectionListener(listener);
final JTextComponent editor = (JTextComponent) comboBox.getEditor().getEditorComponent();
ComboBoxFocusListener focuslistener = new ComboBoxFocusListener(comboBox);
editor.addFocusListener(focuslistener);
} catch (Exception e) {
logger.error("Exception in FilterSettingpanel.getTextIndexComboBox()", e);
}
return comboBox;
}
use of org.cytoscape.filter.internal.widgets.autocomplete.view.TextIndexComboBox in project cytoscape-impl by cytoscape.
the class FilterSettingPanel method refreshIndicesForWidgets.
// Refresh indices for widget after network switch or Cytoscape.ATTRIBUTES_CHANGED event is received
// The method may be triggered by event of NETWORK_VIEW_FOCUSED
public void refreshIndicesForWidgets() {
// Check if each widget has associatd index, if not, try to create one
// System.out.println("FilterSettingpanel:refreshIndicesForWidgets()...\n");
List<CyFilter> children = theFilter.getChildren();
if ((children == null) || (children.size() == 0)) {
return;
}
CyNetwork network = applicationManager.getCurrentNetwork();
for (int i = 0; i < children.size(); i++) {
CyFilter child = children.get(i);
if (child instanceof StringFilter) {
if (pnlCustomSettings.getComponent(i * 5 + 3) instanceof TextIndexComboBox) {
TextIndexComboBox theBox = (TextIndexComboBox) pnlCustomSettings.getComponent(i * 5 + 3);
if (network != null) {
CyNetworkView networkView = applicationManager.getCurrentNetworkView();
if (networkView != null) {
TextIndex textIndex = createTextIndex((StringFilter) child);
;
if (textIndex != null) {
theBox.setTextIndex(textIndex);
StringFilter aFilter = (StringFilter) child;
aFilter.setIndex(textIndex);
}
}
}
}
}
if (child instanceof NumericFilter) {
if (pnlCustomSettings.getComponent(i * 5 + 3) instanceof JRangeSliderExtended) {
JRangeSliderExtended theSlider = (JRangeSliderExtended) pnlCustomSettings.getComponent(i * 5 + 3);
if (network != null) {
CyNetworkView networkView = applicationManager.getCurrentNetworkView();
if (networkView != null) {
NumberIndex numIndex = createNumberIndex((NumericFilter) child);
;
if (numIndex != null) {
NumberRangeModel rangeModel = (NumberRangeModel) theSlider.getModel();
rangeModel.setMinValue(numIndex.getMinimumValue());
rangeModel.setMaxValue(numIndex.getMaximumValue());
NumericFilter aFilter = (NumericFilter) child;
aFilter.setIndex(numIndex);
}
}
}
}
}
}
}
Aggregations