Inspector extends View { private void refreshInspector(ViewInfo viewInfo) { Inspector.this.remove(content); AbstractComponent ac = PlatformAccess.getPlatform().getPersistenceProvider().getComponent(view.getManifestedComponent().getComponentId()); view.removePropertyChangeListener(VIEW_STALE_PROPERTY, objectStaleListener); content = view = viewInfo.createView(ac); view.addPropertyChangeListener(VIEW_STALE_PROPERTY, objectStaleListener); Dimension preferredSize = content.getPreferredSize(); JScrollPane jp = new JScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); preferredSize.height += jp.getHorizontalScrollBar().getPreferredSize().height; JScrollPane inspectorScrollPane = new JScrollPane(content, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); Inspector.this.add(inspectorScrollPane, BorderLayout.CENTER); Inspector.this.revalidate(); content = inspectorScrollPane; viewTitle.setText(view.getManifestedComponent().getDisplayName()); viewControls = view.getControlManifestation(); if (controlAreaToggle.isSelected()) { controlAreaToggle.doClick(); } controlAreaToggle.setEnabled(viewControls != null); STALE_LABEL.setVisible(false); populateStatusBar(); refreshButton.setContext(context); view.requestFocusInWindow(); } Inspector(AbstractComponent ac, ViewInfo vi); AbstractComponent getCurrentlyShowingComponent(); void refreshCurrentlyShowingView(); @Override View getHousedViewManifestation(); @Override void enterLockedState(); @Override void exitLockedState(); @Override boolean setHousedViewManifestation(ViewInfo viewInfo); static final String DEFAULT_INSPECTOR_VIEW_PROP_KEY; }
@Test public void testRefreshInspector() { inspectorPropertyChangeListener.propertyChange(mockPropertyEvent); Mockito.reset(mockViewInfo, mockPersistence); Mockito.when(mockViewInfo.createView(mockComponent)).thenReturn(view); Mockito.when(mockPersistence.getComponent(TEST_COMPONENT_ID)).thenReturn(mockComponent); inspector.refreshCurrentlyShowingView(); Mockito.verify(mockPersistence).getComponent(TEST_COMPONENT_ID); Mockito.verify(mockViewInfo).createView(mockComponent); }