001package systems.dmx.webclient.migrations; 002 003import systems.dmx.core.service.Migration; 004 005 006 007/** 008 * Add view configs to Core types. 009 * Runs ALWAYS. 010 * <p> 011 * Part of DM 4.0 012 */ 013public class Migration2 extends Migration { 014 015 // -------------------------------------------------------------------------------------------------- Public Methods 016 017 @Override 018 public void run() { 019 addIconToTopicType("dmx.core.meta_type", "\uf111"); 020 addIconToTopicType("dmx.core.topic_type", "\uf111"); 021 addIconToTopicType("dmx.core.assoc_type", "\uf111"); 022 addIconToTopicType("dmx.core.data_type", "\uf111"); 023 addIconToTopicType("dmx.core.cardinality", "\uf111"); 024 addIconToTopicType("dmx.core.index_mode", "\uf111"); 025 addIconToTopicType("dmx.core.plugin", "\uf12e"); 026 // 027 // Note: on the canvas HSL-specified colors are rendered pale (Safari and Firefox). 028 // Update: this is because HSB is not the same as HSL. The values here are actually HSB, but CSS expects HSL. 029 addColorToAssociationType("dmx.core.association", "rgb(178, 178, 178)" /*"hsl( 0, 0%, 75%)"*/); 030 addColorToAssociationType("dmx.core.aggregation", "rgb(53, 223, 59)" /*"hsl(120, 65%, 90%)"*/); 031 addColorToAssociationType("dmx.core.composition", "rgb(231, 62, 60)" /*"hsl( 0, 65%, 90%)"*/); 032 addColorToAssociationType("dmx.core.aggregation_def", "rgb(44, 178, 48)" /*"hsl(120, 65%, 75%)"*/); 033 addColorToAssociationType("dmx.core.composition_def", "rgb(184, 51, 49)" /*"hsl( 0, 65%, 75%)"*/); 034 addColorToAssociationType("dmx.core.instantiation", "rgb(41, 194, 225)" /*"hsl(190, 65%, 90%)"*/); 035 addColorToAssociationType("dmx.core.sequence", "rgb(228, 223, 55)" /*"hsl( 60, 65%, 90%)"*/); 036 // 037 setSelectWidget("dmx.core.composition_def"); 038 setSelectWidget("dmx.core.aggregation_def"); 039 } 040 041 // ------------------------------------------------------------------------------------------------- Private Methods 042 043 private void addIconToTopicType(String topicTypeUri, String icon) { 044 setTopicTypeViewConfigValue(topicTypeUri, "icon", icon); 045 } 046 047 private void addColorToAssociationType(String assocTypeUri, String color) { 048 setAssocTypeViewConfigValue(assocTypeUri, "color", color); 049 } 050 051 // --- 052 053 private void setSelectWidget(String assocTypeUri) { 054 dmx.getAssociationType(assocTypeUri).getAssocDef("dmx.core.assoc_type#dmx.core.custom_assoc_type") 055 .getViewConfig() 056 .setConfigValueRef("dmx.webclient.view_config", "dmx.webclient.widget", "dmx.webclient.select") 057 .setConfigValue("dmx.webclient.view_config", "dmx.webclient.clearable", true); 058 } 059}