Permalink
Browse files

[Icons] Implement getAsset in component providers

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...
vicfx committed Sep 11, 2013
1 parent ec0fd3a commit 3b17a86157e98c5001fd891b42ff616e5f93476c
Showing with 357 additions and 210 deletions.
  1. +1 −5 ImportExportProvider/src/main/java/gov/nasa/arc/mct/importExport/provider/ImportExportProvider.java
  2. +61 −49 canvas/src/main/java/gov/nasa/arc/mct/canvas/provider/CanvasComponentProvider.java
  3. +24 −12 collectionComponent/src/main/java/gov/nasa/arc/mct/collection/CollectionComponentProvider.java
  4. +41 −25 dynamicGraphics/src/main/java/gov/nasa/arc/mct/graphics/GraphicalComponentProvider.java
  5. +24 −7 ...uatorComponent/src/main/java/gov/nasa/arc/mct/evaluator/component/EvaluatorComponentProvider.java
  6. +14 −4 evaluatorComponent/src/main/java/gov/nasa/arc/mct/evaluator/component/MultiComponentProvider.java
  7. +52 −27 exampleplugin/src/main/java/org/acme/example/component/ExampleComponentProvider.java
  8. +26 −10 ...eButtons/src/main/java/gov/nasa/jsc/mct/executable/buttons/ExecutableButtonComponentProvider.java
  9. +29 −18 fastPlotViews/src/main/java/gov/nasa/arc/mct/fastplot/PlotViewProvider.java
  10. +24 −16 limits/src/main/java/gov/nasa/arc/mct/limits/LimitLineComponentProvider.java
  11. +21 −6 mctCoreTaxonomyProvider/src/main/java/gov/nasa/arc/mct/core/provider/CoreComponentProvider.java
  12. +1 −1 mctcore/src/main/java/gov/nasa/arc/mct/registry/ExternalComponentRegistryImpl.java
  13. +2 −8 nonTimePlots/src/main/java/gov/nasa/arc/mct/nontimeplot/NonTimePlotComponentProvider.java
  14. +10 −4 platform/src/main/java/gov/nasa/arc/mct/defaults/view/DefaultViewProvider.java
  15. +27 −18 tableViews/src/main/java/gov/nasa/arc/mct/table/TableViewProvider.java
@@ -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.
@@ -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;
}
@@ -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() {
@@ -201,5 +204,14 @@
@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);
}
}
@@ -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.
@@ -40,6 +41,8 @@
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.
@@ -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
@@ -60,5 +63,14 @@ public CollectionComponentProvider() {
@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);
+ }
}
@@ -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)
);
@@ -74,10 +77,23 @@ public GraphicalComponentProvider(){
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);
+ }
}
@@ -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;
@@ -48,14 +50,14 @@
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));
}
@@ -71,10 +73,9 @@ public EvaluatorComponentProvider() {
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));
@@ -95,5 +96,21 @@ public EvaluatorComponentProvider() {
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);
+ }
+
}
Oops, something went wrong.

0 comments on commit 3b17a86

Please sign in to comment.