001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com) 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * For further information about Alkacon Software GmbH & Co. KG, please see the 018 * company website: http://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: http://www.opencms.org 022 * 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not, write to the Free Software 025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 026 */ 027 028package org.opencms.workplace.explorer; 029 030import org.opencms.file.CmsObject; 031import org.opencms.file.CmsResource; 032import org.opencms.file.types.CmsResourceTypeXmlContent; 033import org.opencms.main.CmsLog; 034import org.opencms.main.OpenCms; 035import org.opencms.security.CmsPermissionSet; 036import org.opencms.security.CmsRole; 037import org.opencms.util.CmsStringUtil; 038import org.opencms.workplace.CmsWorkplaceManager; 039 040import java.io.Serializable; 041import java.util.ArrayList; 042import java.util.Collections; 043import java.util.HashMap; 044import java.util.HashSet; 045import java.util.List; 046import java.util.Map; 047import java.util.Set; 048 049import org.apache.commons.logging.Log; 050 051/** 052 * Holds all information to build the explorer context menu of a resource type 053 * and information for the new resource dialog.<p> 054 * 055 * Objects of this type are sorted by their order value which specifies the order 056 * in the new resource dialog.<p> 057 * 058 * @since 6.0.0 059 */ 060public class CmsExplorerTypeSettings implements Comparable<CmsExplorerTypeSettings>, Serializable { 061 062 /** The default big file type icon style class. */ 063 public static final String ICON_STYLE_DEFAULT_BIG = "oc-icon-24-default"; 064 065 /** The default small file type icon style class. */ 066 public static final String ICON_STYLE_DEFAULT_SMALL = "oc-icon-16-default"; 067 068 /** The model group reuse big file type icon style class. */ 069 public static final String ICON_STYLE_MODEL_GROUP_COPY_BIG = "oc-icon-24-modelgroup_copy"; 070 071 /** The model group reuse small file type icon style class. */ 072 public static final String ICON_STYLE_MODEL_GROUP_COPY_SMALL = "oc-icon-16-modelgroup_copy"; 073 074 /** The nav level big file type icon style class. */ 075 public static final String ICON_STYLE_NAV_LEVEL_BIG = "oc-icon-24-navlevel"; 076 077 /** The nav level small file type icon style class. */ 078 public static final String ICON_STYLE_NAV_LEVEL_SMALL = "oc-icon-16-navlevel"; 079 080 /** The default order start value for context menu entries. */ 081 public static final int ORDER_VALUE_DEFAULT_START = 100000; 082 083 /** The default order value for context menu separator entries without order attribute. */ 084 public static final String ORDER_VALUE_SEPARATOR_DEFAULT = "999999"; 085 086 /** The log object for this class. */ 087 private static final Log LOG = CmsLog.getLog(CmsExplorerTypeSettings.class); 088 089 /** Default view orders. */ 090 private static Map<String, Integer> m_defaultViewOrders = new HashMap<String, Integer>() { 091 092 /** Serial version id. */ 093 private static final long serialVersionUID = 1L; 094 095 { 096 put("folder", new Integer(50)); 097 put("plain", new Integer(200)); 098 put("jsp", new Integer(300)); 099 put("htmlredirect", new Integer(400)); 100 put("containerpage", new Integer(500)); 101 102 put("imagegallery", new Integer(100)); 103 put("downloadgallery", new Integer(200)); 104 put("linkgallery", new Integer(300)); 105 put("subsitemap", new Integer(400)); 106 put("content_folder", new Integer(500)); 107 put("formatter_config", new Integer(100)); 108 109 put("xmlvfsbundle", new Integer(200)); 110 put("propertyvfsbundle", new Integer(300)); 111 put("bundledescriptor", new Integer(350)); 112 put("sitemap_config", new Integer(400)); 113 put("sitemap_master_config", new Integer(500)); 114 put("module_config", new Integer(600)); 115 put("elementview", new Integer(700)); 116 put("seo_file", new Integer(800)); 117 put("containerpage_template", new Integer(900)); 118 put("inheritance_config", new Integer(1000)); 119 120 put(CmsResourceTypeXmlContent.getStaticTypeName(), new Integer(100)); 121 put("pointer", new Integer(200)); 122 123 put("modelgroup", new Integer(100)); 124 } 125 }; 126 127 /** The serial version id. */ 128 private static final long serialVersionUID = 7014251115525259136L; 129 130 /** The explorer type access. */ 131 private CmsExplorerTypeAccess m_access; 132 133 /** Flag for showing that this is an additional resource type which defined in a module. */ 134 private boolean m_addititionalModuleExplorerType; 135 136 /** The auto set navigation flag. */ 137 private boolean m_autoSetNavigation; 138 139 /** The auto set title flag. */ 140 private boolean m_autoSetTitle; 141 142 /** The name of the big icon for this explorer type. */ 143 private String m_bigIcon; 144 145 /** The big icon CSS style class. */ 146 private String m_bigIconStyle; 147 148 /** The element view for this explorer type. */ 149 private String m_elementView; 150 151 /**The edit options flag. */ 152 private boolean m_hasEditOptions; 153 154 /** The icon. */ 155 private String m_icon; 156 157 /** The icon rules for this explorer type. */ 158 private Map<String, CmsIconRule> m_iconRules; 159 160 /** The info. */ 161 private String m_info; 162 163 /** Flag indicating whether this explorer type represents a view. */ 164 private boolean m_isView; 165 166 /** The key. */ 167 private String m_key; 168 169 /** The name. */ 170 private String m_name; 171 172 /** The name pattern. */ 173 private String m_namePattern; 174 175 /** The new resource order value. */ 176 private Integer m_newResourceOrder; 177 178 /** The creatable flag, <code>false</code> for types that can not be created through the workplace UI. */ 179 private boolean m_creatable; 180 181 /** The properties. */ 182 private List<String> m_properties; 183 184 /** The enabled properties. */ 185 private boolean m_propertiesEnabled; 186 187 /** The reference. */ 188 private String m_reference; 189 190 /** The show in navigation flag. */ 191 private boolean m_showNavigation; 192 193 /** The small icon CSS style class. */ 194 private String m_smallIconStyle; 195 196 /** The title key. */ 197 private String m_titleKey; 198 199 /** The configured view order. */ 200 private Integer m_viewOrder; 201 202 /** Properties which are required on upload. */ 203 private Set<String> m_requiredOnUpload = new HashSet<>(); 204 205 /** 206 * Default constructor.<p> 207 */ 208 public CmsExplorerTypeSettings() { 209 210 m_access = new CmsExplorerTypeAccess(); 211 m_properties = new ArrayList<String>(); 212 m_creatable = true; 213 m_hasEditOptions = false; 214 m_propertiesEnabled = false; 215 m_showNavigation = false; 216 m_addititionalModuleExplorerType = false; 217 m_newResourceOrder = new Integer(0); 218 m_iconRules = new HashMap<String, CmsIconRule>(); 219 220 } 221 222 /** 223 * Gets the default view order for the given type name (or null, if there is no default view order).<p> 224 * 225 * @param typeName the type name 226 * 227 * @return the default view order for the type 228 */ 229 public static Integer getDefaultViewOrder(String typeName) { 230 231 return m_defaultViewOrders.get(typeName); 232 } 233 234 /** 235 * Adds a new icon rule to this explorer type.<p> 236 * 237 * @param extension the extension for the icon rule 238 * @param icon the small icon 239 * @param bigIcon the big icon 240 * @param smallIconStyle the small icon CSS style class 241 * @param bigIconStyle the big icon CSS style class 242 */ 243 public void addIconRule(String extension, String icon, String bigIcon, String smallIconStyle, String bigIconStyle) { 244 245 CmsIconRule rule = new CmsIconRule(extension, icon, bigIcon, smallIconStyle, bigIconStyle); 246 m_iconRules.put(extension, rule); 247 } 248 249 /** 250 * Adds a property definition name to the list of editable properties.<p> 251 * 252 * @param propertyName the name of the property definition to add 253 * @param requiredOnUpload if "true", mark the property as required after upload 254 * @return true if the property definition was added properly 255 */ 256 public boolean addProperty(String propertyName, String requiredOnUpload) { 257 258 if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(propertyName)) { 259 if (LOG.isDebugEnabled()) { 260 LOG.debug(Messages.get().getBundle().key(Messages.LOG_ADD_PROP_1, propertyName)); 261 } 262 if (Boolean.valueOf(requiredOnUpload).booleanValue()) { 263 m_requiredOnUpload.add(propertyName); 264 } 265 return m_properties.add(propertyName); 266 } else { 267 return false; 268 } 269 } 270 271 /** 272 * @see java.lang.Object#clone() 273 */ 274 @Override 275 public Object clone() { 276 277 CmsExplorerTypeSettings result = new CmsExplorerTypeSettings(); 278 result.m_access = m_access; 279 result.m_addititionalModuleExplorerType = m_addititionalModuleExplorerType; 280 result.m_autoSetNavigation = m_autoSetNavigation; 281 result.m_autoSetTitle = m_autoSetTitle; 282 result.m_bigIcon = m_bigIcon; 283 result.m_bigIconStyle = m_bigIconStyle; 284 result.m_elementView = m_elementView; 285 result.m_hasEditOptions = m_hasEditOptions; 286 result.m_icon = m_icon; 287 result.m_info = m_info; 288 result.m_isView = m_isView; 289 result.m_key = m_key; 290 result.m_name = m_name; 291 result.m_namePattern = m_namePattern; 292 result.m_newResourceOrder = m_newResourceOrder; 293 result.m_properties = new ArrayList<String>(m_properties); 294 result.m_propertiesEnabled = m_propertiesEnabled; 295 result.m_reference = m_reference; 296 result.m_showNavigation = m_showNavigation; 297 result.m_smallIconStyle = m_smallIconStyle; 298 result.m_titleKey = m_titleKey; 299 result.m_viewOrder = m_viewOrder; 300 result.m_iconRules = new HashMap<String, CmsIconRule>(); 301 for (Map.Entry<String, CmsIconRule> rule : m_iconRules.entrySet()) { 302 result.m_iconRules.put(rule.getKey(), (CmsIconRule)rule.getValue().clone()); 303 } 304 return result; 305 } 306 307 /** 308 * @see java.lang.Comparable#compareTo(java.lang.Object) 309 */ 310 public int compareTo(CmsExplorerTypeSettings other) { 311 312 if (other == this) { 313 return 0; 314 } 315 if (other != null) { 316 return m_newResourceOrder.compareTo(other.m_newResourceOrder); 317 } 318 return 0; 319 } 320 321 /** 322 * @see java.lang.Object#equals(java.lang.Object) 323 */ 324 @Override 325 public boolean equals(Object o) { 326 327 if (!(o instanceof CmsExplorerTypeSettings)) { 328 return false; 329 } 330 CmsExplorerTypeSettings other = (CmsExplorerTypeSettings)o; 331 return getName().equals(other.getName()); 332 } 333 334 /** 335 * Gets the access object of the type settings.<p> 336 * 337 * @return access object of the type settings 338 */ 339 public CmsExplorerTypeAccess getAccess() { 340 341 if (m_access.isEmpty()) { 342 CmsWorkplaceManager workplaceManager = OpenCms.getWorkplaceManager(); 343 if (workplaceManager != null) { 344 m_access = workplaceManager.getDefaultAccess(); 345 } 346 } 347 return m_access; 348 } 349 350 /** 351 * Returns the big icon.<p> 352 * 353 * @return an icon name 354 */ 355 public String getBigIcon() { 356 357 return m_bigIcon; 358 } 359 360 /** 361 * Returns the big icon CSS style class.<p> 362 * 363 * @return the big icon style 364 */ 365 public String getBigIconStyle() { 366 367 return m_bigIconStyle; 368 } 369 370 /** 371 * Gets the element view name.<p> 372 * 373 * @return the element view name 374 */ 375 public String getElementView() { 376 377 return m_elementView; 378 } 379 380 /** 381 * Returns the icon path and file name of the explorer type setting.<p> 382 * 383 * @return the icon path and file name of the explorer type setting 384 */ 385 public String getIcon() { 386 387 return m_icon; 388 } 389 390 /** 391 * Returns a map from file extensions to icon rules for this explorer type.<p> 392 * 393 * @return a map from file extensions to icon rules 394 */ 395 public Map<String, CmsIconRule> getIconRules() { 396 397 return Collections.unmodifiableMap(m_iconRules); 398 } 399 400 /** 401 * Returns the info.<p> 402 * 403 * @return the info 404 */ 405 public String getInfo() { 406 407 return m_info; 408 } 409 410 /** 411 * Returns the key name of the explorer type setting.<p> 412 * 413 * @return the key name of the explorer type setting 414 */ 415 public String getKey() { 416 417 return m_key; 418 } 419 420 /** 421 * Returns the name of the explorer type setting.<p> 422 * 423 * @return the name of the explorer type setting 424 */ 425 public String getName() { 426 427 return m_name; 428 } 429 430 /** 431 * Gets the name pattern.<p> 432 * 433 * @return the name pattern 434 */ 435 public String getNamePattern() { 436 437 return m_namePattern; 438 } 439 440 /** 441 * Returns the order for the new resource dialog of the explorer type setting.<p> 442 * 443 * @return the order for the new resource dialog of the explorer type setting 444 */ 445 public String getNewResourceOrder() { 446 447 return String.valueOf(m_newResourceOrder); 448 } 449 450 /** 451 * Gets the original icon name from the configuration.<p> 452 * 453 * @return an icon name 454 */ 455 public String getOriginalIcon() { 456 457 return m_icon; 458 } 459 460 /** 461 * Returns the list of properties of the explorer type setting.<p> 462 * @return the list of properties of the explorer type setting 463 */ 464 public List<String> getProperties() { 465 466 return m_properties; 467 } 468 469 /** 470 * Returns the reference of the explorer type setting.<p> 471 * 472 * @return the reference of the explorer type setting 473 */ 474 public String getReference() { 475 476 return m_reference; 477 } 478 479 /** 480 * Returns the small icon CSS style class.<p> 481 * 482 * @return the small icon style 483 */ 484 public String getSmallIconStyle() { 485 486 return m_smallIconStyle; 487 } 488 489 /** 490 * Returns the titleKey.<p> 491 * 492 * @return the titleKey 493 */ 494 public String getTitleKey() { 495 496 return m_titleKey; 497 } 498 499 /** 500 * Gets the view order, optionally using a default value if the view order is not configured.<p> 501 * 502 * @param useDefault true if a default should be returned in the case where the view order is not configured 503 * 504 * @return the view order 505 */ 506 public Integer getViewOrder(boolean useDefault) { 507 508 Integer defaultViewOrder = getDefaultViewOrder(m_name); 509 Integer result = null; 510 if (m_viewOrder != null) { 511 result = m_viewOrder; 512 } else if (useDefault) { 513 if (defaultViewOrder != null) { 514 result = defaultViewOrder; 515 } else { 516 result = new Integer(9999); 517 } 518 } 519 return result; 520 } 521 522 /** 523 * Returns true if this explorer type entry has explicit edit options set.<p> 524 * 525 * @return true if this explorer type entry has explicit edit options set 526 */ 527 public boolean hasEditOptions() { 528 529 return m_hasEditOptions; 530 } 531 532 /** 533 * @see java.lang.Object#hashCode() 534 */ 535 @Override 536 public int hashCode() { 537 538 return getName().hashCode(); 539 } 540 541 /** 542 * Indicates that this is an additional explorer type which is defined in a module.<p> 543 * 544 * @return true or false 545 */ 546 public boolean isAddititionalModuleExplorerType() { 547 548 return m_addititionalModuleExplorerType; 549 } 550 551 /** 552 * Returns true if navigation properties should automatically be added on resource creation.<p> 553 * 554 * @return true if navigation properties should automatically be added on resource creation, otherwise false 555 */ 556 public boolean isAutoSetNavigation() { 557 558 return m_autoSetNavigation; 559 } 560 561 /** 562 * Returns true if the title property should automatically be added on resource creation.<p> 563 * 564 * @return true if the title property should automatically be added on resource creation, otherwise false 565 */ 566 public boolean isAutoSetTitle() { 567 568 return m_autoSetTitle; 569 } 570 571 /** 572 * Returns if this type is creatable.<p> 573 * 574 * @return <code>true</code> in case this type is creatable 575 */ 576 public boolean isCreatable() { 577 578 return m_creatable; 579 } 580 581 /** 582 * Checks if the current user has write permissions on the given resource.<p> 583 * 584 * @param cms the current cms context 585 * @param resource the resource to check 586 * 587 * @return <code>true</code> if the current user has write permissions on the given resource 588 */ 589 public boolean isEditable(CmsObject cms, CmsResource resource) { 590 591 if (!cms.getRequestContext().getCurrentProject().isOnlineProject() 592 && OpenCms.getRoleManager().hasRole(cms, CmsRole.ROOT_ADMIN)) { 593 return true; 594 } 595 // determine if this resource type is editable for the current user 596 CmsPermissionSet permissions = getAccess().getPermissions(cms, resource); 597 return permissions.requiresWritePermission(); 598 } 599 600 /** 601 * Returns if this explorer type setting uses a special properties dialog.<p> 602 * 603 * @return true, if this explorer type setting uses a special properties dialog 604 */ 605 public boolean isPropertiesEnabled() { 606 607 return m_propertiesEnabled; 608 } 609 610 /** 611 * Check if property is required on upload. 612 * 613 * @param propName the property name 614 * @return true if the property is required on upload 615 */ 616 public boolean isPropertyRequiredOnUpload(String propName) { 617 618 return m_requiredOnUpload.contains(propName); 619 } 620 621 /** 622 * Returns if this explorer type setting displays the navigation properties in the special properties dialog.<p> 623 * 624 * @return true, if this explorer type setting displays the navigation properties in the special properties dialog 625 */ 626 public boolean isShowNavigation() { 627 628 return m_showNavigation; 629 } 630 631 /** 632 * Returns true if this explorer type represents a view.<p> 633 * 634 * @return true if this explorer type represents a view 635 */ 636 public boolean isView() { 637 638 return m_isView; 639 } 640 641 /** 642 * Sets the access object of the type settings.<p> 643 * 644 * @param access access object 645 */ 646 public void setAccess(CmsExplorerTypeAccess access) { 647 648 m_access = access; 649 } 650 651 /** 652 * Sets the additional explorer type flag.<p> 653 * 654 * @param addititionalModuleExplorerType true or false 655 */ 656 public void setAddititionalModuleExplorerType(boolean addititionalModuleExplorerType) { 657 658 m_addititionalModuleExplorerType = addititionalModuleExplorerType; 659 } 660 661 /** 662 * Sets if navigation properties should automatically be added on resource creation.<p> 663 * 664 * @param autoSetNavigation true if properties should be added, otherwise false 665 */ 666 public void setAutoSetNavigation(String autoSetNavigation) { 667 668 m_autoSetNavigation = Boolean.valueOf(autoSetNavigation).booleanValue(); 669 if (LOG.isDebugEnabled()) { 670 LOG.debug(Messages.get().getBundle().key(Messages.LOG_SET_AUTO_NAV_1, autoSetNavigation)); 671 } 672 } 673 674 /** 675 * Sets if the title property should automatically be added on resource creation.<p> 676 * 677 * @param autoSetTitle true if title should be added, otherwise false 678 */ 679 public void setAutoSetTitle(String autoSetTitle) { 680 681 m_autoSetTitle = Boolean.valueOf(autoSetTitle).booleanValue(); 682 if (LOG.isDebugEnabled()) { 683 LOG.debug(Messages.get().getBundle().key(Messages.LOG_SET_AUTO_TITLE_1, autoSetTitle)); 684 } 685 } 686 687 /** 688 * Sets the file name of the big icon for this explorer type.<p> 689 * 690 * @param bigIcon the file name of the big icon 691 */ 692 public void setBigIcon(String bigIcon) { 693 694 m_bigIcon = bigIcon; 695 } 696 697 /** 698 * Sets the big icon CSS style class.<p> 699 * 700 * @param bigIconStyle the big icon style to set 701 */ 702 public void setBigIconStyle(String bigIconStyle) { 703 704 m_bigIconStyle = bigIconStyle; 705 } 706 707 /** 708 * Sets the creatable flag.<p> 709 * 710 * @param creatable the non creatable flag to set 711 */ 712 public void setCreatable(boolean creatable) { 713 714 m_creatable = creatable; 715 } 716 717 /** 718 * Sets the creatable flag.<p> 719 * 720 * @param creatable the creatable flag to set 721 */ 722 public void setCreatable(String creatable) { 723 724 m_creatable = Boolean.parseBoolean(creatable); 725 } 726 727 /** 728 * Sets the flag if this explorer type entry has explicit edit options set.<p> 729 * 730 * This is determined by the presence of the <editoptions> node in the Cms workplace configuration.<p> 731 */ 732 public void setEditOptions() { 733 734 m_hasEditOptions = true; 735 } 736 737 /** 738 * Sets the reference of the explorer type setting.<p> 739 * 740 * @param elementView the element view 741 */ 742 public void setElementView(String elementView) { 743 744 m_elementView = elementView; 745 if (LOG.isDebugEnabled()) { 746 LOG.debug("Setting element view to " + elementView); 747 748 } 749 } 750 751 /** 752 * Sets the icon path and file name of the explorer type setting.<p> 753 * 754 * @param icon the icon path and file name of the explorer type setting 755 */ 756 public void setIcon(String icon) { 757 758 m_icon = icon; 759 if (LOG.isDebugEnabled()) { 760 LOG.debug(Messages.get().getBundle().key(Messages.LOG_SET_ICON_1, icon)); 761 } 762 } 763 764 /** 765 * Sets the info.<p> 766 * 767 * @param info the info to set 768 */ 769 public void setInfo(String info) { 770 771 m_info = info; 772 if (LOG.isDebugEnabled()) { 773 LOG.debug(Messages.get().getBundle().key(Messages.LOG_SET_INFO_1, info)); 774 } 775 } 776 777 /** 778 * Sets the key name of the explorer type setting.<p> 779 * 780 * @param key the key name of the explorer type setting 781 */ 782 public void setKey(String key) { 783 784 m_key = key; 785 if (LOG.isDebugEnabled()) { 786 LOG.debug(Messages.get().getBundle().key(Messages.LOG_SET_KEY_1, key)); 787 } 788 } 789 790 /** 791 * Sets the name of the explorer type setting.<p> 792 * 793 * @param name the name of the explorer type setting 794 */ 795 public void setName(String name) { 796 797 m_name = name; 798 if (LOG.isDebugEnabled()) { 799 LOG.debug(Messages.get().getBundle().key(Messages.LOG_SET_NAME_1, name)); 800 } 801 } 802 803 /** 804 * Sets the order for the new resource dialog of the explorer type setting.<p> 805 * 806 * @param newResourceOrder the order for the new resource dialog of the explorer type setting 807 */ 808 public void setNewResourceOrder(String newResourceOrder) { 809 810 try { 811 m_newResourceOrder = Integer.valueOf(newResourceOrder); 812 if (LOG.isDebugEnabled()) { 813 LOG.debug(Messages.get().getBundle().key(Messages.LOG_SET_NEW_RESOURCE_ORDER_1, newResourceOrder)); 814 } 815 } catch (Exception e) { 816 // can usually be ignored 817 if (LOG.isInfoEnabled()) { 818 LOG.info(e.getLocalizedMessage(), e); 819 } 820 m_newResourceOrder = new Integer(0); 821 } 822 } 823 824 /** 825 * Sets the list of properties of the explorer type setting.<p> 826 * 827 * @param properties the list of properties of the explorer type setting 828 */ 829 public void setProperties(List<String> properties) { 830 831 m_properties = properties; 832 } 833 834 /** 835 * Sets if this explorer type setting uses a special properties dialog.<p> 836 * 837 * @param enabled true, if this explorer type setting uses a special properties dialog 838 */ 839 public void setPropertiesEnabled(boolean enabled) { 840 841 m_propertiesEnabled = enabled; 842 } 843 844 /** 845 * Sets the default settings for the property display dialog.<p> 846 * 847 * @param enabled true, if this explorer type setting uses a special properties dialog 848 * @param showNavigation true, if this explorer type setting displays the navigation properties in the special properties dialog 849 */ 850 public void setPropertyDefaults(String enabled, String showNavigation) { 851 852 setPropertiesEnabled(Boolean.valueOf(enabled).booleanValue()); 853 setShowNavigation(Boolean.valueOf(showNavigation).booleanValue()); 854 if (LOG.isDebugEnabled()) { 855 LOG.debug(Messages.get().getBundle().key(Messages.LOG_SET_PROP_DEFAULTS_2, enabled, showNavigation)); 856 } 857 } 858 859 /** 860 * Sets the reference of the explorer type setting.<p> 861 * 862 * @param reference the reference of the explorer type setting 863 */ 864 public void setReference(String reference) { 865 866 m_reference = reference; 867 if (LOG.isDebugEnabled()) { 868 LOG.debug(Messages.get().getBundle().key(Messages.LOG_SET_REFERENCE_1, m_reference)); 869 } 870 } 871 872 /** 873 * Sets if this explorer type setting displays the navigation properties in the special properties dialog.<p> 874 * 875 * @param navigation true, if this explorer type setting displays the navigation properties in the special properties dialog 876 */ 877 public void setShowNavigation(boolean navigation) { 878 879 m_showNavigation = navigation; 880 } 881 882 /** 883 * Sets the small icon CSS style class.<p> 884 * 885 * @param smallIconStyle the small icon CSS style class to set 886 */ 887 public void setSmallIconStyle(String smallIconStyle) { 888 889 m_smallIconStyle = smallIconStyle; 890 } 891 892 /** 893 * Sets the titleKey.<p> 894 * 895 * @param titleKey the titleKey to set 896 */ 897 public void setTitleKey(String titleKey) { 898 899 m_titleKey = titleKey; 900 if (LOG.isDebugEnabled()) { 901 LOG.debug(Messages.get().getBundle().key(Messages.LOG_SET_TITLE_KEY_1, titleKey)); 902 } 903 } 904 905 /** 906 * Sets the basic attributes of the type settings.<p> 907 * 908 * @param name the name of the type setting 909 * @param key the key name of the explorer type setting 910 * @param icon the icon path and file name of the explorer type setting 911 */ 912 public void setTypeAttributes(String name, String key, String icon) { 913 914 setName(name); 915 setKey(key); 916 setIcon(icon); 917 } 918 919 /** 920 * Sets the basic attributes of the type settings.<p> 921 * 922 * @param name the name of the type setting 923 * @param key the key name of the explorer type setting 924 * @param icon the icon path and file name of the explorer type setting 925 * @param bigIcon the file name of the big icon 926 * @param smallIconStyle the small icon CSS style class 927 * @param bigIconStyle the big icon CSS style class 928 * @param reference the reference of the explorer type setting 929 * @param elementView the element view 930 * @param isView 'true' if this type represents an element view 931 * @param namePattern the name pattern 932 * @param viewOrder the view order 933 */ 934 public void setTypeAttributes( 935 String name, 936 String key, 937 String icon, 938 String bigIcon, 939 String smallIconStyle, 940 String bigIconStyle, 941 String reference, 942 String elementView, 943 String isView, 944 String namePattern, 945 String viewOrder) { 946 947 setName(name); 948 setKey(key); 949 setIcon(icon); 950 setBigIcon(bigIcon); 951 setSmallIconStyle(smallIconStyle); 952 setBigIconStyle(bigIconStyle); 953 setReference(reference); 954 setElementView(elementView); 955 try { 956 m_viewOrder = Integer.valueOf(viewOrder); 957 } catch (NumberFormatException e) { 958 LOG.debug("Type " + name + " has no or invalid view order:" + viewOrder); 959 } 960 m_isView = Boolean.valueOf(isView).booleanValue(); 961 m_namePattern = namePattern; 962 963 } 964 965}