@Test public void testGetAsset() { DefaultViewProvider provider = new DefaultViewProvider(); TypeInfo<?> info; info = new ComponentTypeInfo("","",AbstractComponent.class); Assert.assertNotNull(provider.getAsset(info, Icon.class)); info = new ViewInfo(View.class,"",ViewType.OBJECT); Assert.assertNotNull(provider.getAsset(info, Icon.class)); info = new TypeInfo<TestDefaultViewProvider>(TestDefaultViewProvider.class){}; Assert.assertNotNull(provider.getAsset(info, Icon.class)); Assert.assertNull(provider.getAsset(info, getClass())); }
@Override public <T> T getAsset(TypeInfo<?> type, Class<T> assetClass) { if (assetClass.isAssignableFrom(ImageIcon.class)) { if (InfoView.class.isAssignableFrom(type.getTypeClass())) { return assetClass.cast(ICON); } int sz = 16; if (View.class.isAssignableFrom(type.getTypeClass())) { sz = 9; } else if (AbstractComponent.class.isAssignableFrom(type.getTypeClass())) { sz = 14; } return assetClass.cast(MCTIcons.generateIcon( type.getTypeClass().getName().hashCode(), sz, Color.WHITE)); } return super.getAsset(type, assetClass); }
DefaultViewProvider extends AbstractComponentProvider { @Override public <T> T getAsset(TypeInfo<?> type, Class<T> assetClass) { if (assetClass.isAssignableFrom(ImageIcon.class)) { if (InfoView.class.isAssignableFrom(type.getTypeClass())) { return assetClass.cast(ICON); } int sz = 16; if (View.class.isAssignableFrom(type.getTypeClass())) { sz = 9; } else if (AbstractComponent.class.isAssignableFrom(type.getTypeClass())) { sz = 14; } return assetClass.cast(MCTIcons.generateIcon( type.getTypeClass().getName().hashCode(), sz, Color.WHITE)); } return super.getAsset(type, assetClass); } }
DefaultViewProvider extends AbstractComponentProvider { @Override public <T> T getAsset(TypeInfo<?> type, Class<T> assetClass) { if (assetClass.isAssignableFrom(ImageIcon.class)) { if (InfoView.class.isAssignableFrom(type.getTypeClass())) { return assetClass.cast(ICON); } int sz = 16; if (View.class.isAssignableFrom(type.getTypeClass())) { sz = 9; } else if (AbstractComponent.class.isAssignableFrom(type.getTypeClass())) { sz = 14; } return assetClass.cast(MCTIcons.generateIcon( type.getTypeClass().getName().hashCode(), sz, Color.WHITE)); } return super.getAsset(type, assetClass); } DefaultViewProvider(); }
DefaultViewProvider extends AbstractComponentProvider { @Override public <T> T getAsset(TypeInfo<?> type, Class<T> assetClass) { if (assetClass.isAssignableFrom(ImageIcon.class)) { if (InfoView.class.isAssignableFrom(type.getTypeClass())) { return assetClass.cast(ICON); } int sz = 16; if (View.class.isAssignableFrom(type.getTypeClass())) { sz = 9; } else if (AbstractComponent.class.isAssignableFrom(type.getTypeClass())) { sz = 14; } return assetClass.cast(MCTIcons.generateIcon( type.getTypeClass().getName().hashCode(), sz, Color.WHITE)); } return super.getAsset(type, assetClass); } DefaultViewProvider(); @Override Collection<ViewInfo> getViews(String componentTypeId); @Override T getAsset(TypeInfo<?> type, Class<T> assetClass); }
DefaultViewProvider extends AbstractComponentProvider { @Override public <T> T getAsset(TypeInfo<?> type, Class<T> assetClass) { if (assetClass.isAssignableFrom(ImageIcon.class)) { if (InfoView.class.isAssignableFrom(type.getTypeClass())) { return assetClass.cast(ICON); } int sz = 16; if (View.class.isAssignableFrom(type.getTypeClass())) { sz = 9; } else if (AbstractComponent.class.isAssignableFrom(type.getTypeClass())) { sz = 14; } return assetClass.cast(MCTIcons.generateIcon( type.getTypeClass().getName().hashCode(), sz, Color.WHITE)); } return super.getAsset(type, assetClass); } DefaultViewProvider(); @Override Collection<ViewInfo> getViews(String componentTypeId); @Override T getAsset(TypeInfo<?> type, Class<T> assetClass);  }