Skip to content

Commit

Permalink
[Icons] Implement getAsset in component providers
Browse files Browse the repository at this point in the history
This removes usages of constructor calls for
ComponentTypeInfo and ViewInfo which involve
elements that have been moved to
ComponentProvider.getAsset. (Specifically,
these are icons and creation wizards.)

Where appropriate, these have been replaced
with appropriate getAsset implementations in
those component providers. In some cases
the icons present do not match up with
current icon implementations and have been
removed entirely.
  • Loading branch information
VWoeltjen committed Sep 11, 2013
1 parent ec0fd3a commit 3b17a86
Show file tree
Hide file tree
Showing 15 changed files with 357 additions and 210 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
import java.util.List;
import java.util.ResourceBundle;

import javax.swing.ImageIcon;

/**
* The <code>ImportExportProvider</code> provides menu items to import data into a
* taxonomy node to the MCT directory and export data from a node.
Expand All @@ -54,9 +52,7 @@ public ImportExportProvider() {
* EventsCollection.class, false),
*/
new ComponentTypeInfo(bundle.getString("display_name"), bundle
.getString("description"), ImportExportComponent.class, false,
new ImageIcon(ImportExportComponent.class
.getResource("/icons/legacyCollection.png"))));
.getString("description"), ImportExportComponent.class, false));

assert componentTypes != null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,65 +21,68 @@
*******************************************************************************/
package gov.nasa.arc.mct.canvas.provider;

import gov.nasa.arc.mct.canvas.policy.CanvasFilterViewPolicy;
import gov.nasa.arc.mct.canvas.policy.EmbeddedCanvasViewsAreNotWriteable;
import gov.nasa.arc.mct.canvas.view.CanvasManifestation;
import gov.nasa.arc.mct.canvas.view.ChangeGridSizeAction;
import gov.nasa.arc.mct.canvas.view.ChangeSnapAction;
import gov.nasa.arc.mct.canvas.view.PanelInspector;
import gov.nasa.arc.mct.canvas.view.ReTileAction;
import gov.nasa.arc.mct.canvas.view.WindowChangeGridSizeAction;
import gov.nasa.arc.mct.canvas.view.WindowChangeSnapAction;
import gov.nasa.arc.mct.canvas.view.WindowReTileAction;
import gov.nasa.arc.mct.gui.MenuItemInfo;
import gov.nasa.arc.mct.canvas.policy.CanvasFilterViewPolicy;
import gov.nasa.arc.mct.canvas.policy.EmbeddedCanvasViewsAreNotWriteable;
import gov.nasa.arc.mct.canvas.view.CanvasManifestation;
import gov.nasa.arc.mct.canvas.view.ChangeGridSizeAction;
import gov.nasa.arc.mct.canvas.view.ChangeSnapAction;
import gov.nasa.arc.mct.canvas.view.PanelInspector;
import gov.nasa.arc.mct.canvas.view.ReTileAction;
import gov.nasa.arc.mct.canvas.view.WindowChangeGridSizeAction;
import gov.nasa.arc.mct.canvas.view.WindowChangeSnapAction;
import gov.nasa.arc.mct.canvas.view.WindowReTileAction;
import gov.nasa.arc.mct.gui.MenuItemInfo;
import gov.nasa.arc.mct.gui.MenuItemInfo.MenuItemType;
import gov.nasa.arc.mct.menu.AlignBottomAction;
import gov.nasa.arc.mct.menu.AlignHorizontalCenterAction;
import gov.nasa.arc.mct.menu.AlignLeftAction;
import gov.nasa.arc.mct.menu.AlignRightAction;
import gov.nasa.arc.mct.menu.AlignTopAction;
import gov.nasa.arc.mct.menu.AlignVerticalCenterAction;
import gov.nasa.arc.mct.menu.AlignmentMenu;
import gov.nasa.arc.mct.menu.BorderStylesAction;
import gov.nasa.arc.mct.menu.BorderStylesMenu;
import gov.nasa.arc.mct.menu.BordersAllOrNoneAction;
import gov.nasa.arc.mct.menu.BordersBottomAction;
import gov.nasa.arc.mct.menu.BordersLeftAction;
import gov.nasa.arc.mct.menu.BordersMenu;
import gov.nasa.arc.mct.menu.BordersRightAction;
import gov.nasa.arc.mct.menu.BordersTopAction;
import gov.nasa.arc.mct.menu.BringToFrontAction;
import gov.nasa.arc.mct.menu.AlignBottomAction;
import gov.nasa.arc.mct.menu.AlignHorizontalCenterAction;
import gov.nasa.arc.mct.menu.AlignLeftAction;
import gov.nasa.arc.mct.menu.AlignRightAction;
import gov.nasa.arc.mct.menu.AlignTopAction;
import gov.nasa.arc.mct.menu.AlignVerticalCenterAction;
import gov.nasa.arc.mct.menu.AlignmentMenu;
import gov.nasa.arc.mct.menu.BorderStylesAction;
import gov.nasa.arc.mct.menu.BorderStylesMenu;
import gov.nasa.arc.mct.menu.BordersAllOrNoneAction;
import gov.nasa.arc.mct.menu.BordersBottomAction;
import gov.nasa.arc.mct.menu.BordersLeftAction;
import gov.nasa.arc.mct.menu.BordersMenu;
import gov.nasa.arc.mct.menu.BordersRightAction;
import gov.nasa.arc.mct.menu.BordersTopAction;
import gov.nasa.arc.mct.menu.BringToFrontAction;
import gov.nasa.arc.mct.menu.ChangeViewAction;
import gov.nasa.arc.mct.menu.ExportPanelAsImageAction;
import gov.nasa.arc.mct.menu.GridMenu;
import gov.nasa.arc.mct.menu.PanelTitleBarAction;
import gov.nasa.arc.mct.menu.RemovePanelAction;
import gov.nasa.arc.mct.menu.SelectAllAction;
import gov.nasa.arc.mct.menu.SendToBackAction;
import gov.nasa.arc.mct.menu.WindowGridMenu;
import gov.nasa.arc.mct.policy.PolicyInfo;
import gov.nasa.arc.mct.services.component.AbstractComponentProvider;
import gov.nasa.arc.mct.services.component.ViewInfo;
import gov.nasa.arc.mct.services.component.ViewType;

import java.util.Arrays;
import java.util.Collection;
import java.util.ResourceBundle;

import javax.swing.ImageIcon;
import gov.nasa.arc.mct.menu.ExportPanelAsImageAction;
import gov.nasa.arc.mct.menu.GridMenu;
import gov.nasa.arc.mct.menu.PanelTitleBarAction;
import gov.nasa.arc.mct.menu.RemovePanelAction;
import gov.nasa.arc.mct.menu.SelectAllAction;
import gov.nasa.arc.mct.menu.SendToBackAction;
import gov.nasa.arc.mct.menu.WindowGridMenu;
import gov.nasa.arc.mct.policy.PolicyInfo;
import gov.nasa.arc.mct.services.component.AbstractComponentProvider;
import gov.nasa.arc.mct.services.component.TypeInfo;
import gov.nasa.arc.mct.services.component.ViewInfo;
import gov.nasa.arc.mct.services.component.ViewType;

import java.util.Arrays;
import java.util.Collection;
import java.util.ResourceBundle;

import javax.swing.ImageIcon;

public class CanvasComponentProvider extends AbstractComponentProvider {
private static ResourceBundle bundle = ResourceBundle.getBundle("CanvasResourceBundle");
private static ResourceBundle bundle = ResourceBundle.getBundle("CanvasResourceBundle");

private static final ImageIcon ICON =
new ImageIcon(CanvasComponentProvider.class.getResource("/icons/mct_icon_menu_canvas.png"));

private static final Collection<ViewInfo> VIEW_INFOS =
Arrays.asList(
new ViewInfo(CanvasManifestation.class, bundle.getString("Canvas"), "gov.nasa.arc.mct.canvas.view.CanvasView",
ViewType.OBJECT,
new ImageIcon(CanvasComponentProvider.class.getResource("/icons/mct_icon_menu_canvas.png"))),
ViewType.OBJECT),
new ViewInfo(CanvasManifestation.class, bundle.getString("Canvas"), "gov.nasa.arc.mct.canvas.view.CanvasView",
ViewType.CENTER),
new ViewInfo(CanvasManifestation.class, bundle.getString("Canvas"), "gov.nasa.arc.mct.canvas.view.CanvasView",
ViewType.EMBEDDED,
new ImageIcon(CanvasComponentProvider.class.getResource("/icons/mct_icon_menu_canvas.png"))),
ViewType.EMBEDDED),
new ViewInfo(PanelInspector.class, "Panel Inspector", ViewType.CENTER_OWNED_INSPECTOR));
@Override
public Collection<MenuItemInfo> getMenuItemInfos() {
Expand Down Expand Up @@ -201,5 +204,14 @@ public Collection<PolicyInfo> getPolicyInfos() {
@Override
public Collection<ViewInfo> getViews(String componentTypeId) {
return VIEW_INFOS;
}

@Override
public <T> T getAsset(TypeInfo<?> typeInfo, Class<T> assetClass) {
if (assetClass.isAssignableFrom(ImageIcon.class) &&
typeInfo.getTypeClass().equals(CanvasManifestation.class)) {
return assetClass.cast(ICON);
}
return super.getAsset(typeInfo, assetClass);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,17 @@
*******************************************************************************/
package gov.nasa.arc.mct.collection;

import gov.nasa.arc.mct.components.collection.CollectionComponent;
import gov.nasa.arc.mct.services.component.AbstractComponentProvider;
import gov.nasa.arc.mct.services.component.ComponentTypeInfo;
import gov.nasa.arc.mct.services.component.ViewInfo;

import java.util.Collection;
import java.util.Collections;
import java.util.ResourceBundle;

import javax.swing.ImageIcon;
import gov.nasa.arc.mct.components.collection.CollectionComponent;
import gov.nasa.arc.mct.services.component.AbstractComponentProvider;
import gov.nasa.arc.mct.services.component.ComponentTypeInfo;
import gov.nasa.arc.mct.services.component.TypeInfo;
import gov.nasa.arc.mct.services.component.ViewInfo;

import java.util.Collection;
import java.util.Collections;
import java.util.ResourceBundle;

import javax.swing.ImageIcon;

/**
* Provides the MCT Collection Component.
Expand All @@ -40,6 +41,8 @@ public class CollectionComponentProvider extends AbstractComponentProvider {
private static ResourceBundle bundle = ResourceBundle.getBundle("CollectionComponent");

private final ComponentTypeInfo componentTypeInfo;

private static final ImageIcon ICON = new ImageIcon(CollectionComponent.class.getResource("/icons/Collection.png"));

/**
* Default constructor for a collection component object.
Expand All @@ -49,7 +52,7 @@ public CollectionComponentProvider() {
componentTypeInfo = new ComponentTypeInfo(
bundle.getString("display_name"),
bundle.getString("description"),
CollectionComponent.class, true, new ImageIcon(CollectionComponent.class.getResource("/icons/Collection.png")));
CollectionComponent.class, true);
}

@Override
Expand All @@ -60,5 +63,14 @@ public Collection<ComponentTypeInfo> getComponentTypes() {
@Override
public Collection<ViewInfo> getViews(String componentTypeId) {
return Collections.<ViewInfo>emptyList();
}
}

@Override
public <T> T getAsset(TypeInfo<?> typeInfo, Class<T> assetClass) {
if (assetClass.isAssignableFrom(ImageIcon.class) &&
typeInfo.getTypeClass().equals(CollectionComponent.class)) {
return assetClass.cast(ICON);
}
return super.getAsset(typeInfo, assetClass);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,38 @@
*******************************************************************************/
package gov.nasa.arc.mct.graphics;

import gov.nasa.arc.mct.graphics.component.GraphicalComponent;
import gov.nasa.arc.mct.graphics.component.GraphicalComponentWizardUI;
import gov.nasa.arc.mct.graphics.view.GraphicalManifestation;
import gov.nasa.arc.mct.graphics.view.StaticGraphicalView;
import gov.nasa.arc.mct.policy.PolicyInfo;
import gov.nasa.arc.mct.services.component.AbstractComponentProvider;
import gov.nasa.arc.mct.services.component.ComponentTypeInfo;
import gov.nasa.arc.mct.services.component.ViewInfo;
import gov.nasa.arc.mct.services.component.ViewType;

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.ResourceBundle;

import javax.swing.ImageIcon;
import gov.nasa.arc.mct.graphics.component.GraphicalComponent;
import gov.nasa.arc.mct.graphics.component.GraphicalComponentWizardUI;
import gov.nasa.arc.mct.graphics.view.GraphicalManifestation;
import gov.nasa.arc.mct.graphics.view.StaticGraphicalView;
import gov.nasa.arc.mct.policy.PolicyInfo;
import gov.nasa.arc.mct.services.component.AbstractComponentProvider;
import gov.nasa.arc.mct.services.component.ComponentTypeInfo;
import gov.nasa.arc.mct.services.component.CreateWizardUI;
import gov.nasa.arc.mct.services.component.TypeInfo;
import gov.nasa.arc.mct.services.component.ViewInfo;
import gov.nasa.arc.mct.services.component.ViewType;

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.ResourceBundle;

import javax.swing.ImageIcon;



public class GraphicalComponentProvider extends AbstractComponentProvider {
private static ResourceBundle bundle = ResourceBundle.getBundle("GraphicsResourceBundle");
final Collection<PolicyInfo> policyInfos;

private static final ImageIcon VIEW_ICON =
new ImageIcon(GraphicalManifestation.class.getResource("/icons/mct_icon_menu_graphical.png"));

private static final List<ViewInfo> VIEW_INFOS = Arrays.asList(
new ViewInfo(GraphicalManifestation.class, GraphicalManifestation.VIEW_ROLE_NAME, GraphicalManifestation.class.getName(), ViewType.OBJECT,
new ImageIcon(GraphicalManifestation.class.getResource("/icons/mct_icon_menu_graphical.png"))),
new ViewInfo(GraphicalManifestation.class, GraphicalManifestation.VIEW_ROLE_NAME, GraphicalManifestation.class.getName(), ViewType.EMBEDDED,
new ImageIcon(GraphicalManifestation.class.getResource("/icons/mct_icon_menu_graphical.png"))),
new ViewInfo(GraphicalManifestation.class, GraphicalManifestation.VIEW_ROLE_NAME, GraphicalManifestation.class.getName(), ViewType.OBJECT),
new ViewInfo(GraphicalManifestation.class, GraphicalManifestation.VIEW_ROLE_NAME, GraphicalManifestation.class.getName(), ViewType.EMBEDDED),
new ViewInfo(StaticGraphicalView.class, GraphicalManifestation.VIEW_ROLE_NAME, ViewType.OBJECT),
new ViewInfo(StaticGraphicalView.class, GraphicalManifestation.VIEW_ROLE_NAME, ViewType.EMBEDDED)
);
Expand All @@ -74,10 +77,23 @@ public Collection<ComponentTypeInfo> getComponentTypes() {
return Collections.singleton(
new ComponentTypeInfo(bundle.getString("Component_Name"),
bundle.getString("Component_Description"),
GraphicalComponent.class,
new GraphicalComponentWizardUI(),
null));//new ImageIcon(GraphicalComponentProvider.class.getResource("/icons/importSVG.png"))));
GraphicalComponent.class));
}



@Override
public <T> T getAsset(TypeInfo<?> typeInfo, Class<T> assetClass) {
if (assetClass.isAssignableFrom(ImageIcon.class)) {
if (typeInfo.getTypeClass().equals(GraphicalManifestation.class) ||
typeInfo.getTypeClass().equals(StaticGraphicalView.class)) {
return assetClass.cast(VIEW_ICON);
}
}
if (assetClass.isAssignableFrom(CreateWizardUI.class)) {
if (typeInfo.getTypeClass().equals(GraphicalComponent.class)) {
return assetClass.cast(new GraphicalComponentWizardUI());
}
}
return super.getAsset(typeInfo, assetClass);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import gov.nasa.arc.mct.policy.PolicyInfo;
import gov.nasa.arc.mct.services.component.AbstractComponentProvider;
import gov.nasa.arc.mct.services.component.ComponentTypeInfo;
import gov.nasa.arc.mct.services.component.CreateWizardUI;
import gov.nasa.arc.mct.services.component.TypeInfo;
import gov.nasa.arc.mct.services.component.ViewInfo;
import gov.nasa.arc.mct.services.component.ViewType;

Expand All @@ -48,14 +50,14 @@ public class EvaluatorComponentProvider extends AbstractComponentProvider {

private final Collection<ComponentTypeInfo> infos;
private final Collection<PolicyInfo> policies = new ArrayList<PolicyInfo>();


private static final ImageIcon VIEW_ICON = new ImageIcon(ExpressionsViewManifestation.class.getResource("/icons/mct_icon_menu_settings.png"));

public EvaluatorComponentProvider() {
infos = Arrays.asList(new ComponentTypeInfo(
bundle.getString("display_name"),
bundle.getString("description"),
EvaluatorComponent.class,
new EvaluatorWizardUI()));
EvaluatorComponent.class));
policies.add(new PolicyInfo(PolicyInfo.CategoryType.FILTER_VIEW_ROLE.getKey(), EvaluatorViewPolicy.class));
policies.add(new PolicyInfo(PolicyInfo.CategoryType.FILTER_VIEW_ROLE.getKey(), EnumeratorViewPolicy.class));
}
Expand All @@ -71,10 +73,9 @@ public Collection<ViewInfo> getViews(String componentTypeId) {
if (EvaluatorComponent.class.getName().equals(componentTypeId)) {
List<ViewInfo> views = new ArrayList<ViewInfo>();
views.add(new ViewInfo(InfoViewManifestation.class, InfoViewManifestation.VIEW_NAME, ViewType.OBJECT));
views.add(new ViewInfo(ExpressionsViewManifestation.class, ExpressionsViewManifestation.VIEW_NAME, ExpressionsViewManifestation.class.getName(),
ViewType.OBJECT,
new ImageIcon(ExpressionsViewManifestation.class.getResource("/icons/mct_icon_menu_settings.png"))));
views.add(new ViewInfo(ExpressionsViewManifestation.class, ExpressionsViewManifestation.VIEW_NAME, ExpressionsViewManifestation.class.getName(), ViewType.CENTER, null, null, true, EvaluatorComponent.class));
views.add(new ViewInfo(ExpressionsViewManifestation.class, ExpressionsViewManifestation.VIEW_NAME,
ExpressionsViewManifestation.class.getName(), ViewType.OBJECT));
views.add(new ViewInfo(ExpressionsViewManifestation.class, ExpressionsViewManifestation.VIEW_NAME, ExpressionsViewManifestation.class.getName(), ViewType.CENTER, true, EvaluatorComponent.class));
return views;
}
return Collections.singleton(new ViewInfo(InfoViewManifestation.class, InfoViewManifestation.VIEW_NAME, ViewType.OBJECT));
Expand All @@ -95,5 +96,21 @@ public Collection<MenuItemInfo> getMenuItemInfos() {
MenuItemType.NORMAL, PlaceObjectsInEnumAction.class));

}

@Override
public <T> T getAsset(TypeInfo<?> typeInfo, Class<T> assetClass) {
if (assetClass.isAssignableFrom(ImageIcon.class)) {
if (typeInfo.getTypeClass().equals(ExpressionsViewManifestation.class)) {
return assetClass.cast(VIEW_ICON);
}
}
if (assetClass.isAssignableFrom(CreateWizardUI.class)) {
if (typeInfo.getTypeClass().equals(EvaluatorComponent.class)) {
return assetClass.cast(new EvaluatorWizardUI());
}
}
return super.getAsset(typeInfo, assetClass);
}


}
Loading

0 comments on commit 3b17a86

Please sign in to comment.