Program: 103147
Project: 103147
Buggy source:
/** 
 * Updates   {@link #settingsPanel} from the model of this view. The update isperformed in the AWT event dispatching thread. <p> The center of this view is occupied by  {@link #callPanel}, the bottom of this view is dedicated to <tt>settingsPanel</tt>. The method  {@link #updateViewFromModelInEventDispatchThread()} updates<tt>callPanel</tt> from the model of this view and then invokes the method <tt>updateSettingsPanelInEventDispatchThread()</tt>. Thus this whole view is updated so that it depicts the current state of its model. </p>
 * @param callConferenceIsEnded <tt>true</tt> if the method<tt>updateViewFromModelInEventDispatchThread()</tt> considers the {@link #callConference} ended; otherwise, <tt>false</tt>. When the<tt>callConference</tt> is considered ended, the <tt>callPanel</tt> instance will not be switched to a specific type (one-to-one, audio-only, or audio/video) because, otherwise, the switch will leave it <tt>null</tt> and this view will remain blank. In such a case, <tt>settingsPanel</tt> may wish to do pretty much the same but disable and/or hide the buttons it contains.
 */
private void doUpdateSettingsPanelInEventDispatchThread(boolean callConferenceIsEnded){
  settingsPanel.setFullScreen(isFullScreen());
  boolean isConference=(callPanel instanceof BasicConferenceCallPanel);
  if (isConference) {
    settingsPanel.add(localLevel);
    settingsPanel.add(remoteLevel);
  }
 else {
    settingsPanel.remove(localLevel);
    settingsPanel.remove(remoteLevel);
  }
  chatButton.setVisible(!isConference && (getIMCapableCallPeers(1).size() == 1));
  updateHoldButtonState();
  updateMergeButtonState();
  List<Call> calls=callConference.getCalls();
  boolean advancedTelephony=!calls.isEmpty();
  boolean telephonyConferencing=false;
  boolean videoTelephony=false;
  boolean videoTelephonyIsLocalVideoAllowed=false;
  boolean videoTelephonyIsLocalVideoStreaming=false;
  boolean desktopSharing=false;
  boolean desktopSharingIsStreamed=false;
  for (  Call call : calls) {
    ProtocolProviderService pps=call.getProtocolProvider();
    if (advancedTelephony) {
      OperationSetAdvancedTelephony<?> osat=pps.getOperationSet(OperationSetAdvancedTelephony.class);
      if (osat == null)       advancedTelephony=false;
    }
    if (!telephonyConferencing) {
      OperationSetTelephonyConferencing ostc=pps.getOperationSet(OperationSetTelephonyConferencing.class);
      if (ostc != null)       telephonyConferencing=true;
    }
    if (!videoTelephony || !videoTelephonyIsLocalVideoAllowed || !videoTelephonyIsLocalVideoStreaming) {
      OperationSetVideoTelephony osvt=pps.getOperationSet(OperationSetVideoTelephony.class);
      if (osvt != null) {
        if (!videoTelephony)         videoTelephony=true;
        if (!videoTelephonyIsLocalVideoAllowed && osvt.isLocalVideoAllowed(call))         videoTelephonyIsLocalVideoAllowed=true;
        if (!videoTelephonyIsLocalVideoStreaming && osvt.isLocalVideoStreaming(call))         videoTelephonyIsLocalVideoStreaming=true;
      }
    }
    if (!desktopSharing) {
      OperationSetDesktopStreaming osds=pps.getOperationSet(OperationSetDesktopStreaming.class);
      if (osds != null) {
        desktopSharing=true;
        if (videoTelephonyIsLocalVideoStreaming && call instanceof MediaAwareCall && ((MediaAwareCall<?,?,?>)call).getMediaUseCase() == MediaUseCase.DESKTOP) {
          desktopSharingIsStreamed=true;
        }
      }
    }
  }
  conferenceButton.setEnabled(telephonyConferencing);
  transferCallButton.setEnabled(advancedTelephony);
  transferCallButton.setVisible(!callConference.isConferenceFocus());
  videoButton.setEnabled(videoTelephony);
  videoButton.setSelected(videoTelephonyIsLocalVideoAllowed);
  showHideVideoButton.setEnabled(videoButton.isEnabled() && videoTelephonyIsLocalVideoAllowed);
  showHideVideoButton.setSelected(showHideVideoButton.isEnabled() && uiVideoHandler.isLocalVideoVisible());
  showHideVideoButton.setVisible(showHideVideoButton.isEnabled());
  desktopSharingButton.setEnabled(desktopSharing);
  desktopSharingButton.setSelected(desktopSharingIsStreamed);
  if (callPanel instanceof OneToOneCallPanel) {
    OneToOneCallPanel oneToOneCallPanel=(OneToOneCallPanel)callPanel;
    if (desktopSharingIsStreamed)     oneToOneCallPanel.addDesktopSharingComponents();
 else     oneToOneCallPanel.removeDesktopSharingComponents();
  }
}

Fixed version (ground truth):
/** 
 * Updates   {@link #settingsPanel} from the model of this view. The update isperformed in the AWT event dispatching thread. <p> The center of this view is occupied by  {@link #callPanel}, the bottom of this view is dedicated to <tt>settingsPanel</tt>. The method  {@link #updateViewFromModelInEventDispatchThread()} updates<tt>callPanel</tt> from the model of this view and then invokes the method <tt>updateSettingsPanelInEventDispatchThread()</tt>. Thus this whole view is updated so that it depicts the current state of its model. </p>
 * @param callConferenceIsEnded <tt>true</tt> if the method<tt>updateViewFromModelInEventDispatchThread()</tt> considers the {@link #callConference} ended; otherwise, <tt>false</tt>. When the<tt>callConference</tt> is considered ended, the <tt>callPanel</tt> instance will not be switched to a specific type (one-to-one, audio-only, or audio/video) because, otherwise, the switch will leave it <tt>null</tt> and this view will remain blank. In such a case, <tt>settingsPanel</tt> may wish to do pretty much the same but disable and/or hide the buttons it contains.
 */
private void doUpdateSettingsPanelInEventDispatchThread(boolean callConferenceIsEnded){
  settingsPanel.setFullScreen(isFullScreen());
  boolean isConference=(callPanel instanceof BasicConferenceCallPanel);
  if (isConference) {
    settingsPanel.add(localLevel);
    settingsPanel.add(remoteLevel);
  }
 else {
    settingsPanel.remove(localLevel);
    settingsPanel.remove(remoteLevel);
  }
  chatButton.setVisible(!isConference && (getIMCapableCallPeers(1).size() == 1));
  updateHoldButtonState();
  updateMergeButtonState();
  List<Call> calls=callConference.getCalls();
  boolean advancedTelephony=!calls.isEmpty();
  boolean telephonyConferencing=false;
  boolean videoTelephony=false;
  boolean videoTelephonyIsLocalVideoAllowed=false;
  boolean videoTelephonyIsLocalVideoStreaming=false;
  boolean desktopSharing=false;
  boolean desktopSharingIsStreamed=false;
  boolean allCallsConnected=true;
  for (  Call call : calls) {
    ProtocolProviderService pps=call.getProtocolProvider();
    if (advancedTelephony) {
      OperationSetAdvancedTelephony<?> osat=pps.getOperationSet(OperationSetAdvancedTelephony.class);
      if (osat == null)       advancedTelephony=false;
    }
    if (!telephonyConferencing) {
      OperationSetTelephonyConferencing ostc=pps.getOperationSet(OperationSetTelephonyConferencing.class);
      if (ostc != null)       telephonyConferencing=true;
    }
    if (!videoTelephony || !videoTelephonyIsLocalVideoAllowed || !videoTelephonyIsLocalVideoStreaming) {
      OperationSetVideoTelephony osvt=pps.getOperationSet(OperationSetVideoTelephony.class);
      if (osvt != null) {
        if (!videoTelephony)         videoTelephony=true;
        if (!videoTelephonyIsLocalVideoAllowed && osvt.isLocalVideoAllowed(call))         videoTelephonyIsLocalVideoAllowed=true;
        if (!videoTelephonyIsLocalVideoStreaming && osvt.isLocalVideoStreaming(call))         videoTelephonyIsLocalVideoStreaming=true;
      }
    }
    if (!desktopSharing) {
      OperationSetDesktopStreaming osds=pps.getOperationSet(OperationSetDesktopStreaming.class);
      if (osds != null) {
        desktopSharing=true;
        if (videoTelephonyIsLocalVideoStreaming && call instanceof MediaAwareCall && ((MediaAwareCall<?,?,?>)call).getMediaUseCase() == MediaUseCase.DESKTOP) {
          desktopSharingIsStreamed=true;
        }
      }
    }
    if (CallState.CALL_IN_PROGRESS != call.getCallState()) {
      allCallsConnected=false;
    }
  }
  conferenceButton.setEnabled(telephonyConferencing);
  transferCallButton.setEnabled(advancedTelephony);
  transferCallButton.setVisible(!callConference.isConferenceFocus());
  videoButton.setEnabled(allCallsConnected && videoTelephony);
  videoButton.setSelected(videoTelephonyIsLocalVideoAllowed);
  showHideVideoButton.setEnabled(videoButton.isEnabled() && videoTelephonyIsLocalVideoAllowed);
  showHideVideoButton.setSelected(showHideVideoButton.isEnabled() && uiVideoHandler.isLocalVideoVisible());
  showHideVideoButton.setVisible(showHideVideoButton.isEnabled());
  desktopSharingButton.setEnabled(desktopSharing);
  desktopSharingButton.setSelected(desktopSharingIsStreamed);
  if (callPanel instanceof OneToOneCallPanel) {
    OneToOneCallPanel oneToOneCallPanel=(OneToOneCallPanel)callPanel;
    if (desktopSharingIsStreamed)     oneToOneCallPanel.addDesktopSharingComponents();
 else     oneToOneCallPanel.removeDesktopSharingComponents();
  }
}