Java Code Examples for javax.swing.event.ListDataEvent

The following examples show how to use javax.swing.event.ListDataEvent. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Override
public void intervalAdded(final ListDataEvent pE)
{
	SwingUtilities.invokeLater(new Runnable()
	{

		@Override
		public void run()
		{
			final TIntArrayList lSelectedIndices = new TIntArrayList(mActiveChannelJList.getSelectedIndices());
			for (int i = pE.getIndex0(); i < pE.getIndex1(); i++)
				lSelectedIndices.add(i);
			mActiveChannelJList.setSelectedIndices(lSelectedIndices.toArray());

		}
	});
}
 
Example 2
Source Project: CXTouch   Source File: RowHeaderList.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void mainModelChanged(ListDataEvent e) {
    RowNumberListModel listModel = (RowNumberListModel) getModel();
    int listRowCount = listModel.getSize();
    int mainRowCount = RowHeaderList.this.getModel().getSize();
    if (mainRowCount == listRowCount) {
        if ( e.getType() == ListDataEvent.CONTENTS_CHANGED ) {
            listModel.fireContentsChanged(e.getIndex0(), e.getIndex1());
        }
        return;
    }

    listModel.setSize(mainRowCount);
    if (mainRowCount == 0) {
        return;
    }

    Insets insets = getInsets();
    ListCellRenderer cellRender = getCellRenderer();
    int with = (int) cellRender.getListCellRendererComponent(this, null, mainRowCount - 1, false, false)
            .getPreferredSize().getWidth() + insets.left + insets.right;
    setFixedCellWidth(with);
}
 
Example 3
public void contentsChanged( final ListDataEvent e ) {
  final ParameterType type = (ParameterType) parameterTypeModel.getSelectedItem();
  final boolean visible = ( type != null ) && type.isHasVisibleItems();

  visibleItemsTextField.setVisible( visible );
  visibleItemsLabel.setVisible( visible );

  final boolean displayFormulaVisible = ( type != null ) && !type.isQueryOptional();
  displayFormulaField.setVisible( displayFormulaVisible );
  displayFormulaLabel.setVisible( displayFormulaVisible );
  displayValueLabel.setVisible( displayFormulaVisible );
  displayValueComboBox.setVisible( displayFormulaVisible );

  final String selectedQuery = (String) queryComboBoxModel.getSelectedItem();
  final boolean querySelected = !StringUtils.isEmpty( selectedQuery, false );
  strictValuesCheckBox.setVisible( querySelected );
  reevaluateOnInvalidStrictParamCheckBox.setVisible( querySelected );
  autofillSelectionCheckBox.setVisible( querySelected );
}
 
Example 4
Source Project: NBANDROID-V2   Source File: LogDevicesComboBoxSupport.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Add a new device serial to this data model, if it doesn't already exist.
 */
private void add(String device) {
    int insertIndex = devices.size();

    // check, if this serial already exists.
    for (int i = devices.size(); --i >= 0;) {
        if (devices.get(i).equals(device)) {

            // refresh this item (the label may changed)
            fireListDataEvent(ListDataEvent.INTERVAL_REMOVED, i);
            fireListDataEvent(ListDataEvent.INTERVAL_ADDED, i);

            return;
        }
    }

    if (insertIndex != -1) {
        devices.add(insertIndex, device);

        // send notification
        fireListDataEvent(ListDataEvent.INTERVAL_ADDED, insertIndex);
    }
}
 
Example 5
Source Project: pdfxtk   Source File: MultiColumnListUI.java    License: Apache License 2.0 6 votes vote down vote up
public void intervalAdded(ListDataEvent e) {
     updateLayoutStateNeeded = modelChanged;

     int minIndex = Math.min(e.getIndex0(), e.getIndex1());
     int maxIndex = Math.max(e.getIndex0(), e.getIndex1());

     /* Sync the SelectionModel with the DataModel.
      */

     ListSelectionModel sm = list.getSelectionModel();
     if (sm != null) {
sm.insertIndexInterval(minIndex, maxIndex - minIndex, true);
     }

     /* Repaint the entire list, from the origin of
      * the first added cell, to the bottom of the
      * component.
      */

     Rectangle r = getCellBounds(list, minIndex, list.getModel().getSize());
     list.revalidate();
     list.repaint(r);
   }
 
Example 6
public void contentsChanged( final ListDataEvent e ) {
  final ExpressionMetaData o = (ExpressionMetaData) getPrimaryDataSourcesModel().getSelectedItem();
  if ( o == null ) {
    setPrimaryDataSource( null );
    return;
  }
  final Expression primaryDataSourceExpression = getPrimaryDataSource();
  if ( primaryDataSourceExpression != null && primaryDataSourceExpression.getClass()
    .equals( o.getExpressionType() ) ) {
    // no need to change anything ..
    return;
  }

  try {
    final Expression expression = (Expression) o.getExpressionType().newInstance();
    if ( primaryDataSourceExpression != null ) {
      propagateExpressionSettings( primaryDataSourceExpression, expression );
    }

    setPrimaryDataSource( expression.getInstance() );
  } catch ( final Exception e1 ) {
    // ignore the exception ..
    UncaughtExceptionsModel.getInstance().addException( e1 );
    setPrimaryDataSource( null );
  }
}
 
Example 7
public void contentsChanged( final ListDataEvent e ) {
  if ( inUpdate ) {
    return;
  }
  if ( e.getIndex0() != -1 ) {
    return;
  }

  final NamedDataSourceDialogModel dialogModel = getDialogModel();
  try {
    inUpdate = true;

    final DataSetQuery<String> selectedQuery = dialogModel.getQueries().getSelectedQuery();
    if ( selectedQuery == null ) {
      setQueryName( null );
      queryTextArea.setText( null );
      queryScriptTextArea.setText( null );
      queryLanguageField.setSelectedItem( null );
      return;
    }

    setQueryName( selectedQuery.getQueryName() );
    queryTextArea.setText( selectedQuery.getQuery() );
    queryScriptTextArea.setText( selectedQuery.getScript() );
    setScriptingLanguage( selectedQuery.getScriptLanguage(), queryLanguageField );
  } finally {
    inUpdate = false;
  }
}
 
Example 8
/**
 * Notifies all registered list data listener of the given event.
 *
 * @param evt the event.
 */
protected synchronized void fireListDataEvent( final ListDataEvent evt ) {
  if ( tempListeners == null ) {
    tempListeners = listdatalistener.toArray
      ( new ListDataListener[ listdatalistener.size() ] );
  }

  final ListDataListener[] listeners = tempListeners;
  for ( int i = 0; i < listeners.length; i++ ) {
    final ListDataListener l = listeners[ i ];
    l.contentsChanged( evt );
  }
}
 
Example 9
/**
 * Removes all entries from the model.
 */
public void clear()
{
  final int size = getSize();
  this.data.clear();
  final ListDataEvent evt = new ListDataEvent(this, ListDataEvent.INTERVAL_REMOVED, 0, size - 1);
  fireListDataEvent(evt);
}
 
Example 10
Source Project: netbeans   Source File: FilteredListModel.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void intervalAdded (ListDataEvent listDataEvent) {
    if (external == null) {
        return;
    }

    updateYourAssumeptions ();

    int first = listDataEvent.getIndex0 ();
    int end = listDataEvent.getIndex1 () + 1;
    int len = end - first;

    int newOriginalSize = originalSize + len;
    int newSize = size + len;

    int insert = findExternalIndex (first);
    int[] newExternal = new int[newSize];
    System.arraycopy (external, 0, newExternal, 0, insert);
    for (int i = 0; i < len; i++) {
        newExternal[insert + i] = NOT_TESTED;
    }
    for (int i = insert + len; i < newExternal.length; i++) {
        int v = external[i - len];
        newExternal[i] = v < 0 ? v : v + len;
    }
    external = newExternal;
    size = newSize;
    originalSize = newOriginalSize;

    regenerateCheckedBitSet ();

    fireChange (new ListDataEvent (this, ListDataEvent.INTERVAL_ADDED, insert, insert + len - 1));
    assert externalContraints () : "Constraints failed"; // NOI18N
}
 
Example 11
Source Project: netbeans   Source File: ListComboBoxModel.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void addListDataListener(ListDataListener l) {
    if (listeners == null) {
        listeners = new ArrayList<ListDataListener>(3);
        event = new ListDataEvent(this, CONTENTS_CHANGED, -1, -1);
    }
    listeners.add(l);
}
 
Example 12
public void contentsChanged( final ListDataEvent e ) {
  if ( inUpdate ) {
    return;
  }
  if ( e.getIndex0() != -1 ) {
    return;
  }

  final NamedDataSourceDialogModel dialogModel = getDialogModel();
  try {
    inUpdate = true;

    final DataSetQuery<String> selectedQuery = dialogModel.getQueries().getSelectedQuery();
    if ( selectedQuery == null ) {
      setQueryName( null );
      queryTextArea.setText( null );
      queryScriptTextArea.setText( null );
      queryLanguageField.setSelectedItem( null );
      return;
    }

    setQueryName( selectedQuery.getQueryName() );
    queryTextArea.setText( selectedQuery.getQuery() );
    queryScriptTextArea.setText( selectedQuery.getScript() );
    setScriptingLanguage( selectedQuery.getScriptLanguage(), queryLanguageField );
  } finally {
    inUpdate = false;
  }
}
 
Example 13
@Override
public void intervalAdded(final ListDataEvent e) {
	int index0 = e.getIndex0();
	int index1 = e.getIndex1();
	if (index0 == index1) {
		updateList(index0, 1);
	}
}
 
Example 14
Source Project: netbeans   Source File: FilteredListModel.java    License: Apache License 2.0 5 votes vote down vote up
/** Notifies removal of inteval from (inclusive) to (exclusive) and
 * updates its structures.
 *
 * !!! as a side effect updates size !!!
 *
 * @return s - number of removals
 */
private void notifyRemoval (int from, int to) {
    ListDataEvent ev = new ListDataEvent (
        this, ListDataEvent.INTERVAL_REMOVED, from, to - 1
    );
    removeInterval (external, from, to);
    int cnt = to - from;
    size -= cnt;

    regenerateCheckedBitSet ();
    fireChange (ev);
}
 
Example 15
Source Project: netbeans   Source File: DefaultTabDataModel.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Remove a range of tabs from <code>start</code> up to <i>and including</i> 
 * <code>finish</code>.
 */
@Override
public void removeTabs(int start, int end) {
    java.util.List affected = new ArrayList(list.subList(start, end));
    if (start == end) {
        list.remove(start);
    } else {
        list.removeRange(start, end);
    }
    ComplexListDataEvent lde = new ComplexListDataEvent(this,
                                                        ListDataEvent.INTERVAL_REMOVED,
                                                        start, end);
    lde.setAffectedItems((TabData[]) affected.toArray(new TabData[0]));
    fireIntervalRemoved(lde);
}
 
Example 16
/**
 * Called when data in a replacement changed
 *
 * @param index Index of which SWF changed
 */
public void dataChanged(int index) {
    if (index == -1) {
        return;
    }
    for (ListDataListener l : listeners) {
        l.contentsChanged(new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, index, index));
    }
}
 
Example 17
Source Project: NBANDROID-V2   Source File: LogDevicesComboBoxSupport.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Remove a device from the data model, except it has messages in the log
 * cache.
 */
private void remove(String device) {
    // do we have log events for this device?
    if (reader.getLogEventsForDevice(device) != null) {
        // if true, we want to keep it
        return;
    }

    for (int i = devices.size(); --i >= 0;) {
        if (devices.get(i).equals(device)) {
            devices.remove(i);
            fireListDataEvent(ListDataEvent.INTERVAL_REMOVED, i);
        }
    }
}
 
Example 18
Source Project: netbeans   Source File: DefaultTabbedContainerUI.java    License: Apache License 2.0 5 votes vote down vote up
public void intervalAdded(ListDataEvent e) {
    if (container.getContentPolicy() == TabbedContainer.CONTENT_POLICY_ADD_ALL) {
        Component curC = null;
        for (int i = e.getIndex0(); i <= e.getIndex1(); i++) {
            curC = toComp(container.getModel().getTab(i));
            contentDisplayer.add(curC, "");
        }
    }
}
 
Example 19
Source Project: binnavi   Source File: CDebuggerComboModel.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void addedDebugger(
    final IDebuggerContainer container, final DebuggerTemplate debugger) {
  updateElements();

  for (final ListDataListener listener : modelListeners) {
    listener.contentsChanged(new ListDataEvent(
        CDebuggerComboModel.this, ListDataEvent.CONTENTS_CHANGED, 0, getSize()));
  }
}
 
Example 20
Source Project: constellation   Source File: DragDropList.java    License: Apache License 2.0 4 votes vote down vote up
public void addMyElement(final MyElement element) {
    elements.add(element);
    for (ListDataListener l : listeners) {
        l.contentsChanged(new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, getSize() - 1));
    }
}
 
Example 21
Source Project: netbeans   Source File: TabState.java    License: Apache License 2.0 4 votes vote down vote up
void contentsChanged(ListDataEvent evt) {
    if (!hasAlarmTabs()) return;
    //Do nothing, just means some text or icons changed
}
 
Example 22
public void intervalAdded(final ListDataEvent e) {
}
 
Example 23
Source Project: openAGV   Source File: EditableComboBoxEditor.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void contentsChanged(ListDataEvent e) {
  loadContent();
}
 
Example 24
public void intervalRemoved(final ListDataEvent e) {
}
 
Example 25
Source Project: pdfxtk   Source File: ChartPanel.java    License: Apache License 2.0 4 votes vote down vote up
public void intervalRemoved(ListDataEvent e) {
  update();
}
 
Example 26
public void intervalRemoved(final ListDataEvent e) {
}
 
Example 27
Source Project: netbeans   Source File: Install.java    License: Apache License 2.0 4 votes vote down vote up
public void contentsChanged(ListDataEvent e) {
    setKeys(getPendingTasks());
}
 
Example 28
@Override
public void intervalAdded(ListDataEvent e) {
    _syncModelContents();
}
 
Example 29
public void contentsChanged( final ListDataEvent e ) {
  updateEnabled();
}
 
Example 30
public void intervalAdded( final ListDataEvent e ) {
  // ignore
}