1 31 32 package org.opencms.configuration; 33 34 import org.opencms.db.CmsUserSettings; 35 import org.opencms.file.CmsResource; 36 import org.opencms.i18n.CmsLocaleManager; 37 38 import java.util.Arrays ; 39 import java.util.Collections ; 40 import java.util.List ; 41 42 53 public class CmsDefaultUserSettings extends CmsUserSettings { 54 55 56 public static final String [] BUTTON_STYLES = {"image", "textimage", "text"}; 57 58 59 public static final List BUTTON_STYLES_LIST = Collections.unmodifiableList(Arrays.asList(BUTTON_STYLES)); 60 61 private static final int BUTTONSTYLE_TEXTIMAGE = 1; 62 63 64 private static final String COPYMODE_PRESERVE = "preservesiblings"; 65 66 67 private static final String COPYMODE_RESOURCE = "createresource"; 68 69 70 private static final String COPYMODE_SIBLING = "createsibling"; 71 72 73 private static final String DELETEMODE_DELETE = "deletesiblings"; 74 75 76 private static final String DELETEMODE_PRESERVE = "preservesiblings"; 77 78 79 public static final String [] FILTER_NAMES = { 80 "mynewtasks", 81 "mytasksformyroles", 82 "alltasks", 83 "myactivetasks", 84 "myactivetasksformyroles", 85 "allactivetasks", 86 "mycompletedtasks", 87 "mycompletedtasksformyroles", 88 "allcompletedtasks", 89 "newtaskscreatedbyme", 90 "activetaskscreatedbyme", 91 "completedtaskscreatedbyme"}; 92 93 94 public static final List FILTER_NAMES_LIST = Collections.unmodifiableList(Arrays.asList(FILTER_NAMES)); 95 96 97 public static final String [] FILTER_VALUES = { 98 "a1", 99 "b1", 100 "c1", 101 "a2", 102 "b2", 103 "c2", 104 "a3", 105 "b3", 106 "c3", 107 "d1", 108 "d2", 109 "d3"}; 110 111 112 public static final List FILTER_VALUES_LIST = Collections.unmodifiableList(Arrays.asList(FILTER_VALUES)); 113 114 115 private static final String PUBLISHMODE_ONLYRESOURCE = "onlyresource"; 116 117 118 private static final String PUBLISHMODE_SIBLINGS = "allsiblings"; 119 120 125 public String getDialogCopyFileModeString() { 126 127 if (getDialogCopyFileMode() == CmsResource.COPY_AS_NEW) { 128 return COPYMODE_RESOURCE; 129 } else { 130 return COPYMODE_SIBLING; 131 } 132 133 } 134 135 140 public String getDialogCopyFolderModeString() { 141 142 if (getDialogCopyFolderMode() == CmsResource.COPY_AS_NEW) { 143 return COPYMODE_RESOURCE; 144 } else if (getDialogCopyFolderMode() == CmsResource.COPY_AS_SIBLING) { 145 return COPYMODE_SIBLING; 146 } else { 147 return COPYMODE_PRESERVE; 148 } 149 } 150 151 156 public String getDialogDeleteFileModeString() { 157 158 if (getDialogDeleteFileMode() == CmsResource.DELETE_REMOVE_SIBLINGS) { 159 return DELETEMODE_DELETE; 160 } else { 161 return DELETEMODE_PRESERVE; 162 } 163 } 164 165 170 public String getDialogExpandInheritedPermissionsString() { 171 172 return String.valueOf(getDialogExpandInheritedPermissions()); 173 } 174 175 180 public String getDialogExpandUserPermissionsString() { 181 182 return String.valueOf(getDialogExpandUserPermissions()); 183 } 184 185 190 public String getDialogPermissionsInheritOnFolderString() { 191 192 return String.valueOf(getDialogPermissionsInheritOnFolder()); 193 } 194 195 200 public String getDialogPublishSiblingsString() { 201 202 if (getDialogPublishSiblings()) { 203 return PUBLISHMODE_SIBLINGS; 204 } else { 205 return PUBLISHMODE_ONLYRESOURCE; 206 } 207 } 208 209 214 public String getDialogShowExportSettingsString() { 215 216 return String.valueOf(getDialogShowExportSettings()); 217 } 218 219 224 public String getDialogShowLockString() { 225 226 return String.valueOf(getDialogShowLock()); 227 } 228 229 234 public String getDirectEditButtonStyleString() { 235 236 return BUTTON_STYLES[getDirectEditButtonStyle()]; 237 } 238 239 244 public String getEditorButtonStyleString() { 245 246 return BUTTON_STYLES[getEditorButtonStyle()]; 247 } 248 249 254 public String getExplorerButtonStyleString() { 255 256 return BUTTON_STYLES[getExplorerButtonStyle()]; 257 } 258 259 265 private String getExplorerSetting(int setting) { 266 267 return String.valueOf((getExplorerSettings() & setting) > 0); 268 } 269 270 275 public String getRestrictExplorerViewString() { 276 277 return String.valueOf(getRestrictExplorerView()); 278 } 279 280 285 public String getShowExplorerFileDateCreated() { 286 287 return getExplorerSetting(CmsUserSettings.FILELIST_DATE_CREATED); 288 } 289 290 295 public String getShowExplorerFileDateExpired() { 296 297 return getExplorerSetting(CmsUserSettings.FILELIST_DATE_EXPIRED); 298 } 299 300 305 public String getShowExplorerFileDateLastModified() { 306 307 return getExplorerSetting(CmsUserSettings.FILELIST_DATE_LASTMODIFIED); 308 } 309 310 315 public String getShowExplorerFileDateReleased() { 316 317 return getExplorerSetting(CmsUserSettings.FILELIST_DATE_RELEASED); 318 } 319 320 325 public String getShowExplorerFileLockedBy() { 326 327 return getExplorerSetting(CmsUserSettings.FILELIST_LOCKEDBY); 328 } 329 330 335 public String getShowExplorerFilePermissions() { 336 337 return getExplorerSetting(CmsUserSettings.FILELIST_PERMISSIONS); 338 } 339 340 345 public String getShowExplorerFileSize() { 346 347 return getExplorerSetting(CmsUserSettings.FILELIST_SIZE); 348 } 349 350 355 public String getShowExplorerFileState() { 356 357 return getExplorerSetting(CmsUserSettings.FILELIST_STATE); 358 } 359 360 365 public String getShowExplorerFileTitle() { 366 367 return getExplorerSetting(CmsUserSettings.FILELIST_TITLE); 368 } 369 370 375 public String getShowExplorerFileType() { 376 377 return getExplorerSetting(CmsUserSettings.FILELIST_TYPE); 378 } 379 380 385 public String getShowExplorerFileUserCreated() { 386 387 return getExplorerSetting(CmsUserSettings.FILELIST_USER_CREATED); 388 } 389 390 395 public String getShowExplorerFileUserLastModified() { 396 397 return getExplorerSetting(CmsUserSettings.FILELIST_USER_LASTMODIFIED); 398 } 399 400 405 public String getTaskMessageAcceptedString() { 406 407 return String.valueOf(getTaskMessageAccepted()); 408 } 409 410 415 public String getTaskMessageCompletedString() { 416 417 return String.valueOf(getTaskMessageCompleted()); 418 } 419 420 425 public String getTaskMessageForwardedString() { 426 427 return String.valueOf(getTaskMessageForwarded()); 428 } 429 430 435 public String getTaskMessageMembersString() { 436 437 return String.valueOf(getTaskMessageMembers()); 438 } 439 440 445 public String getTaskShowAllProjectsString() { 446 447 return String.valueOf(getTaskShowAllProjects()); 448 } 449 450 455 public String getTaskStartupFilterDefault() { 456 457 int defaultFilter = FILTER_VALUES_LIST.indexOf(getTaskStartupFilter()); 458 return FILTER_NAMES[defaultFilter]; 459 } 460 461 466 public String getUploadAppletString() { 467 468 return String.valueOf(useUploadApplet()); 469 } 470 471 476 public String getWorkplaceButtonStyleString() { 477 478 return BUTTON_STYLES[getWorkplaceButtonStyle()]; 479 } 480 481 486 public void setDialogCopyFileMode(String mode) { 487 488 int copyMode = CmsResource.COPY_AS_NEW; 489 if (mode.equalsIgnoreCase(COPYMODE_SIBLING)) { 490 copyMode = CmsResource.COPY_AS_SIBLING; 491 } 492 setDialogCopyFileMode(copyMode); 493 } 494 495 500 public void setDialogCopyFolderMode(String mode) { 501 502 int copyMode = CmsResource.COPY_AS_NEW; 503 if (mode.equalsIgnoreCase(COPYMODE_SIBLING)) { 504 copyMode = CmsResource.COPY_AS_SIBLING; 505 } else if (mode.equalsIgnoreCase(COPYMODE_PRESERVE)) { 506 copyMode = CmsResource.COPY_PRESERVE_SIBLING; 507 } 508 setDialogCopyFolderMode(copyMode); 509 } 510 511 516 public void setDialogDeleteFileMode(String mode) { 517 518 int deleteMode = CmsResource.DELETE_PRESERVE_SIBLINGS; 519 if (mode.equalsIgnoreCase(DELETEMODE_DELETE)) { 520 deleteMode = CmsResource.DELETE_REMOVE_SIBLINGS; 521 } 522 setDialogDeleteFileMode(deleteMode); 523 } 524 525 530 public void setDialogExpandInheritedPermissions(String dialogExpandInheritedPermissions) { 531 532 setDialogExpandInheritedPermissions(Boolean.valueOf(dialogExpandInheritedPermissions).booleanValue()); 533 } 534 535 540 public void setDialogExpandUserPermissions(String dialogExpandUserPermissions) { 541 542 setDialogExpandUserPermissions(Boolean.valueOf(dialogExpandUserPermissions).booleanValue()); 543 } 544 545 550 public void setDialogPermissionsInheritOnFolder(String dialogPermissionsInheritOnFolder) { 551 552 setDialogPermissionsInheritOnFolder(Boolean.valueOf(dialogPermissionsInheritOnFolder).booleanValue()); 553 } 554 555 560 public void setDialogPublishSiblings(String mode) { 561 562 boolean publishSiblings = false; 563 if (mode.equalsIgnoreCase(PUBLISHMODE_SIBLINGS)) { 564 publishSiblings = true; 565 } 566 setDialogPublishSiblings(publishSiblings); 567 } 568 569 574 public void setDirectEditButtonStyle(String buttonstyle) { 575 576 int buttonstyleValue = BUTTONSTYLE_TEXTIMAGE; 577 try { 578 if (buttonstyle != null) { 579 buttonstyleValue = BUTTON_STYLES_LIST.indexOf(buttonstyle); 580 } 581 } catch (Exception e) { 582 } 584 setDirectEditButtonStyle(buttonstyleValue); 585 } 586 587 592 public void setEditorButtonStyle(String buttonstyle) { 593 594 int buttonstyleValue = BUTTONSTYLE_TEXTIMAGE; 595 try { 596 if (buttonstyle != null) { 597 buttonstyleValue = BUTTON_STYLES_LIST.indexOf(buttonstyle); 598 } 599 } catch (Exception e) { 600 } 602 setEditorButtonStyle(buttonstyleValue); 603 } 604 605 610 public void setExplorerButtonStyle(String buttonstyle) { 611 612 int buttonstyleValue = BUTTONSTYLE_TEXTIMAGE; 613 try { 614 if (buttonstyle != null) { 615 buttonstyleValue = BUTTON_STYLES_LIST.indexOf(buttonstyle); 616 } 617 } catch (Exception e) { 618 } 620 setExplorerButtonStyle(buttonstyleValue); 621 } 622 623 628 public void setExplorerFileEntries(String entries) { 629 630 try { 631 setExplorerFileEntries(Integer.parseInt(entries)); 632 } catch (Throwable t) { 633 } 635 } 636 637 642 public void setLocale(String locale) { 643 644 setLocale(CmsLocaleManager.getLocale(locale)); 646 } 647 648 658 public void setNewFolderCreateIndexPage(String booleanValue) { 659 660 setNewFolderCreateIndexPage(Boolean.valueOf(booleanValue)); 661 } 662 663 673 public void setNewFolderEditProperties(String booleanValue) { 674 675 setNewFolderEditPropertes(Boolean.valueOf(booleanValue)); 676 } 677 678 683 public void setRestrictExplorerView(String restrict) { 684 685 setRestrictExplorerView(Boolean.valueOf(restrict).booleanValue()); 686 } 687 688 693 public void setShowExplorerFileDateCreated(String show) { 694 695 setShowExplorerFileDateCreated(Boolean.valueOf(show).booleanValue()); 696 } 697 698 703 public void setShowExplorerFileDateExpired(String show) { 704 705 setShowExplorerFileDateExpired(Boolean.valueOf(show).booleanValue()); 706 } 707 708 713 public void setShowExplorerFileDateLastModified(String show) { 714 715 setShowExplorerFileDateLastModified(Boolean.valueOf(show).booleanValue()); 716 } 717 718 723 public void setShowExplorerFileDateReleased(String show) { 724 725 setShowExplorerFileDateReleased(Boolean.valueOf(show).booleanValue()); 726 } 727 728 733 public void setShowExplorerFileLockedBy(String show) { 734 735 setShowExplorerFileLockedBy(Boolean.valueOf(show).booleanValue()); 736 } 737 738 743 public void setShowExplorerFilePermissions(String show) { 744 745 setShowExplorerFilePermissions(Boolean.valueOf(show).booleanValue()); 746 } 747 748 753 public void setShowExplorerFileSize(String show) { 754 755 setShowExplorerFileSize(Boolean.valueOf(show).booleanValue()); 756 } 757 758 763 public void setShowExplorerFileState(String show) { 764 765 setShowExplorerFileState(Boolean.valueOf(show).booleanValue()); 766 } 767 768 773 public void setShowExplorerFileTitle(String show) { 774 775 setShowExplorerFileTitle(Boolean.valueOf(show).booleanValue()); 776 } 777 778 783 public void setShowExplorerFileType(String show) { 784 785 setShowExplorerFileType(Boolean.valueOf(show).booleanValue()); 786 } 787 788 793 public void setShowExplorerFileUserCreated(String show) { 794 795 setShowExplorerFileUserCreated(Boolean.valueOf(show).booleanValue()); 796 } 797 798 803 public void setShowExplorerFileUserLastModified(String show) { 804 805 setShowExplorerFileUserLastModified(Boolean.valueOf(show).booleanValue()); 806 } 807 808 813 public void setShowExportSettingsDialog(String mode) { 814 815 setDialogShowExportSettings(Boolean.valueOf(mode).booleanValue()); 816 } 817 818 823 public void setShowLockDialog(String mode) { 824 825 setDialogShowLock(Boolean.valueOf(mode).booleanValue()); 826 } 827 828 833 public void setTaskMessageAccepted(String mode) { 834 835 setTaskMessageAccepted(Boolean.valueOf(mode).booleanValue()); 836 } 837 838 843 public void setTaskMessageCompleted(String mode) { 844 845 setTaskMessageCompleted(Boolean.valueOf(mode).booleanValue()); 846 } 847 848 853 public void setTaskMessageForwarded(String mode) { 854 855 setTaskMessageForwarded(Boolean.valueOf(mode).booleanValue()); 856 } 857 858 863 public void setTaskMessageMembers(String mode) { 864 865 setTaskMessageMembers(Boolean.valueOf(mode).booleanValue()); 866 } 867 868 873 public void setTaskShowAllProjects(String mode) { 874 875 setTaskShowAllProjects(Boolean.valueOf(mode).booleanValue()); 876 877 } 878 879 884 public void setTaskStartupFilterDefault(String filter) { 885 886 int defaultFilter = 0; 887 try { 888 if (filter != null) { 889 defaultFilter = FILTER_NAMES_LIST.indexOf(filter); 890 } 891 } catch (Exception e) { 892 } 894 setTaskStartupFilter(FILTER_VALUES[defaultFilter]); 895 } 896 897 902 public void setUploadApplet(String applet) { 903 904 setUseUploadApplet(Boolean.valueOf(applet).booleanValue()); 906 } 907 908 913 public void setWorkplaceButtonStyle(String buttonstyle) { 914 915 int buttonstyleValue = BUTTONSTYLE_TEXTIMAGE; 916 917 try { 918 if (buttonstyle != null) { 919 buttonstyleValue = BUTTON_STYLES_LIST.indexOf(buttonstyle); 920 } 921 } catch (Exception e) { 922 } 924 925 setWorkplaceButtonStyle(buttonstyleValue); 926 } 927 } | Popular Tags |