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.list; 029 030import org.opencms.db.CmsUserSettings; 031import org.opencms.file.CmsProject; 032import org.opencms.file.CmsResource; 033import org.opencms.i18n.CmsMessageContainer; 034import org.opencms.jsp.CmsJspActionElement; 035import org.opencms.main.CmsException; 036import org.opencms.main.CmsLog; 037import org.opencms.main.OpenCms; 038import org.opencms.util.CmsUUID; 039import org.opencms.workplace.CmsDialog; 040import org.opencms.workplace.CmsWorkplaceSettings; 041import org.opencms.workplace.commons.CmsTouch; 042import org.opencms.workplace.explorer.CmsExplorer; 043import org.opencms.workplace.explorer.CmsResourceUtil; 044 045import java.util.Collections; 046import java.util.HashMap; 047import java.util.List; 048import java.util.Map; 049 050import javax.servlet.http.HttpServletRequest; 051 052import org.apache.commons.logging.Log; 053 054/** 055 * Provides a list dialog for resources.<p> 056 * 057 * @since 6.0.0 058 */ 059public abstract class A_CmsListExplorerDialog extends A_CmsListDialog { 060 061 /** List action id constant. */ 062 public static final String LIST_ACTION_EDIT = "eae"; 063 064 /** List action id constant. */ 065 public static final String LIST_ACTION_LOCKICON = "eal"; 066 067 /** List action id constant. */ 068 public static final String LIST_ACTION_PROJSTATEICON = "eaps"; 069 070 /** List action id constant. */ 071 public static final String LIST_ACTION_TYPEICON = "eai"; 072 073 /** List column id constant. */ 074 public static final String LIST_COLUMN_DATECREATE = "ecdc"; 075 076 /** List column id constant. */ 077 public static final String LIST_COLUMN_DATEEXP = "ecde"; 078 079 /** List column id constant. */ 080 public static final String LIST_COLUMN_DATELASTMOD = "ecdl"; 081 082 /** List column id constant. */ 083 public static final String LIST_COLUMN_DATEREL = "ecdr"; 084 085 /** List column id constant. */ 086 public static final String LIST_COLUMN_EDIT = "ece"; 087 088 /** List column id constant. */ 089 public static final String LIST_COLUMN_LOCKEDBY = "eclb"; 090 091 /** List column id constant. */ 092 public static final String LIST_COLUMN_LOCKICON = "ecli"; 093 094 /** List column id constant. */ 095 public static final String LIST_COLUMN_NAME = "ecn"; 096 097 /** List column id constant. */ 098 public static final String LIST_COLUMN_PERMISSIONS = "ecp"; 099 100 /** List column id constant. */ 101 public static final String LIST_COLUMN_PROJSTATEICON = "ecpi"; 102 103 /** List column id constant. */ 104 public static final String LIST_COLUMN_ROOT_PATH = "crp"; 105 106 /** List column id constant. */ 107 public static final String LIST_COLUMN_SITE = "ecsi"; 108 109 /** List column id constant. */ 110 public static final String LIST_COLUMN_SIZE = "ecz"; 111 112 /** List column id constant. */ 113 public static final String LIST_COLUMN_STATE = "ecs"; 114 115 /** List column id constant. */ 116 public static final String LIST_COLUMN_TITLE = "ect"; 117 118 /** List column id constant. */ 119 public static final String LIST_COLUMN_TYPE = "ecy"; 120 121 /** List column id constant. */ 122 public static final String LIST_COLUMN_TYPEICON = "ecti"; 123 124 /** List column id constant. */ 125 public static final String LIST_COLUMN_USERCREATE = "ecuc"; 126 127 /** List column id constant. */ 128 public static final String LIST_COLUMN_USERLASTMOD = "ecul"; 129 130 /** List default action id constant. */ 131 public static final String LIST_DEFACTION_OPEN = "edo"; 132 133 /** Request parameter name for the show explorer flag. */ 134 public static final String PARAM_SHOW_EXPLORER = "showexplorer"; 135 136 /** Explorer list JSP path. */ 137 public static final String PATH_EXPLORER_LIST = PATH_DIALOGS + "list-explorer.jsp"; 138 139 /** The log object for this class. */ 140 private static final Log LOG = CmsLog.getLog(A_CmsListExplorerDialog.class); 141 142 /** Column visibility flags container. */ 143 private Map<Integer, Boolean> m_colVisibilities; 144 145 /** Stores the value of the request parameter for the show explorer flag. */ 146 private String m_paramShowexplorer; 147 148 /** Instance resource util. */ 149 private CmsResourceUtil m_resourceUtil; 150 151 /** 152 * Creates a new explorer list ordered and searchable by name.<p> 153 * 154 * @param jsp an initialized JSP action element 155 * @param listId the id of the displayed list 156 * @param listName the name of the list 157 */ 158 protected A_CmsListExplorerDialog(CmsJspActionElement jsp, String listId, CmsMessageContainer listName) { 159 160 this(jsp, listId, listName, LIST_COLUMN_NAME, CmsListOrderEnum.ORDER_ASCENDING, LIST_COLUMN_NAME); 161 } 162 163 /** 164 * Default constructor.<p> 165 * 166 * @param jsp an initialized JSP action element 167 * @param listId the id of the displayed list 168 * @param listName the name of the list 169 * @param sortedColId the a priory sorted column 170 * @param sortOrder the order of the sorted column 171 * @param searchableColId the column to search into 172 */ 173 protected A_CmsListExplorerDialog( 174 CmsJspActionElement jsp, 175 String listId, 176 CmsMessageContainer listName, 177 String sortedColId, 178 CmsListOrderEnum sortOrder, 179 String searchableColId) { 180 181 super(jsp, listId, listName, sortedColId, sortOrder, searchableColId); 182 } 183 184 /** 185 * @see org.opencms.workplace.list.A_CmsListDialog#executeListIndepActions() 186 */ 187 @Override 188 public void executeListIndepActions() { 189 190 if (getParamListAction().equals(CmsListIndependentAction.ACTION_EXPLORER_SWITCH_ID)) { 191 Map<String, String[]> params = new HashMap<String, String[]>(); 192 // set action parameter to initial dialog call 193 params.put(CmsDialog.PARAM_ACTION, new String[] {CmsDialog.DIALOG_INITIAL}); 194 params.putAll(getToolManager().getCurrentTool(this).getHandler().getParameters(this)); 195 196 getSettings().setCollector(getCollector()); 197 getSettings().setExplorerMode(CmsExplorer.VIEW_LIST); 198 getSettings().setExplorerProjectId(getProject().getUuid()); 199 setShowExplorer(true); 200 try { 201 getToolManager().jspForwardPage(this, PATH_EXPLORER_LIST, params); 202 } catch (Exception e) { 203 throw new RuntimeException(e); 204 } 205 } else { 206 super.executeListIndepActions(); 207 } 208 } 209 210 /** 211 * Returns the collector to use to display the resources.<p> 212 * 213 * @return the collector to use to display the resources 214 */ 215 public abstract I_CmsListResourceCollector getCollector(); 216 217 /** 218 * Returns the Show explorer parameter value.<p> 219 * 220 * @return the Show explorer parameter value 221 */ 222 public String getParamShowexplorer() { 223 224 return m_paramShowexplorer; 225 } 226 227 /** 228 * Returns an appropiate initialized resource util object.<p> 229 * 230 * @return a resource util object 231 */ 232 public CmsResourceUtil getResourceUtil() { 233 234 if (m_resourceUtil == null) { 235 try { 236 m_resourceUtil = new CmsResourceUtil(OpenCms.initCmsObject(getCms())); 237 m_resourceUtil.setReferenceProject(getProject()); 238 } catch (CmsException ex) { 239 if (LOG.isErrorEnabled()) { 240 LOG.error(ex.getLocalizedMessage(), ex); 241 } 242 } 243 } 244 return m_resourceUtil; 245 } 246 247 /** 248 * Returns an appropiate initialized resource util object for the given item.<p> 249 * 250 * @param item the item representing the resource 251 * 252 * @return a resource util object 253 */ 254 public CmsResourceUtil getResourceUtil(CmsListItem item) { 255 256 CmsResourceUtil resUtil = getResourceUtil(); 257 resUtil.setResource(getCollector().getResource(getCms(), item)); 258 return resUtil; 259 } 260 261 /** 262 * Sets the Show explorer parameter value.<p> 263 * 264 * @param showExplorer the Show explorer parameter value to set 265 */ 266 public void setParamShowexplorer(String showExplorer) { 267 268 m_paramShowexplorer = showExplorer; 269 } 270 271 /** 272 * Applies the column visibilities.<p> 273 */ 274 protected void applyColumnVisibilities() { 275 276 setColumnVisibilities(); 277 CmsListMetadata metadata = getList().getMetadata(); 278 metadata.getColumnDefinition(LIST_COLUMN_SITE).setVisible(isColumnVisible(LIST_COLUMN_SITE.hashCode())); 279 metadata.getColumnDefinition(LIST_COLUMN_EDIT).setVisible(isColumnVisible(LIST_COLUMN_EDIT.hashCode())); 280 metadata.getColumnDefinition(LIST_COLUMN_TYPEICON).setVisible(isColumnVisible(LIST_COLUMN_TYPEICON.hashCode())); 281 metadata.getColumnDefinition(LIST_COLUMN_LOCKICON).setVisible(isColumnVisible(LIST_COLUMN_LOCKICON.hashCode())); 282 metadata.getColumnDefinition(LIST_COLUMN_PROJSTATEICON).setVisible( 283 isColumnVisible(LIST_COLUMN_PROJSTATEICON.hashCode())); 284 metadata.getColumnDefinition(LIST_COLUMN_NAME).setVisible(isColumnVisible(LIST_COLUMN_NAME.hashCode())); 285 metadata.getColumnDefinition(LIST_COLUMN_TITLE).setVisible(isColumnVisible(CmsUserSettings.FILELIST_TITLE)); 286 metadata.getColumnDefinition(LIST_COLUMN_TYPE).setVisible(isColumnVisible(CmsUserSettings.FILELIST_TYPE)); 287 metadata.getColumnDefinition(LIST_COLUMN_SIZE).setVisible(isColumnVisible(CmsUserSettings.FILELIST_SIZE)); 288 metadata.getColumnDefinition(LIST_COLUMN_PERMISSIONS).setVisible( 289 isColumnVisible(CmsUserSettings.FILELIST_PERMISSIONS)); 290 metadata.getColumnDefinition(LIST_COLUMN_DATELASTMOD).setVisible( 291 isColumnVisible(CmsUserSettings.FILELIST_DATE_LASTMODIFIED)); 292 metadata.getColumnDefinition(LIST_COLUMN_USERLASTMOD).setVisible( 293 isColumnVisible(CmsUserSettings.FILELIST_USER_LASTMODIFIED)); 294 metadata.getColumnDefinition(LIST_COLUMN_DATECREATE).setVisible( 295 isColumnVisible(CmsUserSettings.FILELIST_DATE_CREATED)); 296 metadata.getColumnDefinition(LIST_COLUMN_USERCREATE).setVisible( 297 isColumnVisible(CmsUserSettings.FILELIST_USER_CREATED)); 298 metadata.getColumnDefinition(LIST_COLUMN_DATEREL).setVisible( 299 isColumnVisible(CmsUserSettings.FILELIST_DATE_RELEASED)); 300 metadata.getColumnDefinition(LIST_COLUMN_DATEEXP).setVisible( 301 isColumnVisible(CmsUserSettings.FILELIST_DATE_EXPIRED)); 302 metadata.getColumnDefinition(LIST_COLUMN_STATE).setVisible(isColumnVisible(CmsUserSettings.FILELIST_STATE)); 303 metadata.getColumnDefinition(LIST_COLUMN_LOCKEDBY).setVisible( 304 isColumnVisible(CmsUserSettings.FILELIST_LOCKEDBY)); 305 } 306 307 /** 308 * @see org.opencms.workplace.list.A_CmsListDialog#defaultActionHtmlStart() 309 */ 310 @Override 311 protected String defaultActionHtmlStart() { 312 313 StringBuffer result = new StringBuffer(2048); 314 result.append(htmlStart(null)); 315 result.append(getList().listJs()); 316 result.append(CmsListExplorerColumn.getExplorerStyleDef()); 317 result.append(bodyStart("dialog", null)); 318 result.append(dialogStart()); 319 result.append(dialogContentStart(getParamTitle())); 320 return result.toString(); 321 } 322 323 /** 324 * @see org.opencms.workplace.list.A_CmsListDialog#executeSelectPage() 325 */ 326 @Override 327 protected void executeSelectPage() { 328 329 super.executeSelectPage(); 330 getSettings().setExplorerPage(getList().getCurrentPage()); 331 } 332 333 /** 334 * @see org.opencms.workplace.list.A_CmsListDialog#fillList() 335 */ 336 @Override 337 protected void fillList() { 338 339 getListState().setPage(getSettings().getExplorerPage()); 340 super.fillList(); 341 } 342 343 /** 344 * Gets a map of additional request parameters which should be passed to the explorer.<p> 345 * 346 * @return the map of additional parameters to pass to the explorer 347 */ 348 protected Map<String, String[]> getAdditionalParametersForExplorerForward() { 349 350 return Collections.emptyMap(); 351 } 352 353 /** 354 * Returns the colVisibilities map.<p> 355 * 356 * @return the colVisibilities map 357 */ 358 protected Map<Integer, Boolean> getColVisibilities() { 359 360 return m_colVisibilities; 361 } 362 363 /** 364 * @see org.opencms.workplace.list.A_CmsListDialog#getListItems() 365 */ 366 @Override 367 protected List<CmsListItem> getListItems() throws CmsException { 368 369 if (getSettings().getExplorerMode() != null) { 370 CmsListColumnDefinition nameCol = getList().getMetadata().getColumnDefinition(LIST_COLUMN_NAME); 371 if (!(getSettings().getExplorerMode().equals(CmsExplorer.VIEW_GALLERY) 372 || getSettings().getExplorerMode().equals(CmsExplorer.VIEW_LIST))) { 373 nameCol.setName( 374 org.opencms.workplace.explorer.Messages.get().container( 375 org.opencms.workplace.explorer.Messages.GUI_INPUT_NAME_0)); 376 } else { 377 nameCol.setName( 378 org.opencms.workplace.explorer.Messages.get().container( 379 org.opencms.workplace.explorer.Messages.GUI_INPUT_PATH_0)); 380 } 381 } 382 return getCollector().getListItems(null); 383 } 384 385 /** 386 * Returns the list state for initializing the collector.<p> 387 * 388 * @return the list state 389 */ 390 protected CmsListState getListStateForCollector() { 391 392 CmsListState lstate = new CmsListState(); 393 if (getList() != null) { 394 lstate = getListState(); 395 } 396 switch (getAction()) { 397 //////////////////// ACTION: default actions 398 case ACTION_LIST_SEARCH: 399 if (getParamSearchFilter() == null) { 400 setParamSearchFilter(""); 401 } 402 if (getParamSearchFilter().equals(lstate.getFilter())) { 403 lstate.setOrder(CmsListOrderEnum.ORDER_DESCENDING); 404 } else { 405 lstate.setOrder(CmsListOrderEnum.ORDER_ASCENDING); 406 } 407 lstate.setFilter(getParamSearchFilter()); 408 break; 409 case ACTION_LIST_SORT: 410 lstate.setColumn(getParamSortCol()); 411 break; 412 case ACTION_LIST_SELECT_PAGE: 413 int page = Integer.valueOf(getParamPage()).intValue(); 414 lstate.setPage(page); 415 break; 416 default: 417 // no op 418 } 419 return lstate; 420 } 421 422 /** 423 * Returns the project to use as reference.<p> 424 * 425 * @return the project to use as reference 426 */ 427 protected CmsProject getProject() { 428 429 return getCms().getRequestContext().getCurrentProject(); 430 } 431 432 /** 433 * @see org.opencms.workplace.CmsWorkplace#initWorkplaceRequestValues(org.opencms.workplace.CmsWorkplaceSettings, javax.servlet.http.HttpServletRequest) 434 */ 435 @Override 436 protected void initWorkplaceRequestValues(CmsWorkplaceSettings settings, HttpServletRequest request) { 437 438 super.initWorkplaceRequestValues(settings, request); 439 // this to show first the explorer view 440 if (getShowExplorer()) { 441 CmsUUID projectId = getProject().getUuid(); 442 Map<String, String[]> params = new HashMap<String, String[]>(); 443 // set action parameter to initial dialog call 444 params.put(CmsDialog.PARAM_ACTION, new String[] {CmsDialog.DIALOG_INITIAL}); 445 params.putAll(getToolManager().getCurrentTool(this).getHandler().getParameters(this)); 446 params.putAll(getAdditionalParametersForExplorerForward()); 447 getSettings().setExplorerProjectId(projectId); 448 getSettings().setCollector(getCollector()); 449 getSettings().setExplorerMode(CmsExplorer.VIEW_LIST); 450 try { 451 setShowExplorer(true); 452 getToolManager().jspForwardPage(this, PATH_DIALOGS + "list-explorer.jsp", params); 453 } catch (Exception e) { 454 throw new RuntimeException(e); 455 } 456 } else { 457 setShowExplorer(false); 458 } 459 } 460 461 /** 462 * Returns the visibility flag for a given column.<p> 463 * 464 * The default behavior is to show the same columns as the explorer view, 465 * but this can be overwritten.<p> 466 * 467 * @param colFlag some {@link CmsUserSettings#FILELIST_TITLE} like value 468 * identifying the column to get the visibility flag for 469 * 470 * @return the visibility flag for the given column 471 */ 472 protected boolean isColumnVisible(int colFlag) { 473 474 Integer key = Integer.valueOf(colFlag); 475 if (m_colVisibilities.containsKey(key)) { 476 return m_colVisibilities.get(key).booleanValue(); 477 } 478 return false; 479 } 480 481 /** 482 * Adds the standard explorer view columns to the list.<p> 483 * 484 * @see org.opencms.workplace.list.A_CmsListDialog#setColumns(org.opencms.workplace.list.CmsListMetadata) 485 */ 486 @Override 487 protected void setColumns(CmsListMetadata metadata) { 488 489 setColumnVisibilities(); 490 491 // position 0: icon 492 CmsListColumnDefinition typeIconCol = new CmsListColumnDefinition(LIST_COLUMN_TYPEICON); 493 typeIconCol.setName(Messages.get().container(Messages.GUI_EXPLORER_LIST_COLS_ICON_0)); 494 typeIconCol.setHelpText(Messages.get().container(Messages.GUI_EXPLORER_LIST_COLS_ICON_HELP_0)); 495 typeIconCol.setWidth("20"); 496 typeIconCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER); 497 typeIconCol.setListItemComparator(new CmsListItemActionIconComparator()); 498 499 // add resource icon action 500 CmsListDirectAction resourceTypeIconAction = new CmsListResourceTypeIconAction(LIST_ACTION_TYPEICON); 501 resourceTypeIconAction.setEnabled(false); 502 typeIconCol.addDirectAction(resourceTypeIconAction); 503 metadata.addColumn(typeIconCol); 504 505 // position 1: edit button 506 CmsListColumnDefinition editIconCol = new CmsListColumnDefinition(LIST_COLUMN_EDIT); 507 editIconCol.setName(Messages.get().container(Messages.GUI_EXPLORER_LIST_COLS_EDIT_0)); 508 editIconCol.setHelpText(Messages.get().container(Messages.GUI_EXPLORER_LIST_COLS_EDIT_HELP_0)); 509 editIconCol.setWidth("20"); 510 editIconCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER); 511 512 // add enabled edit action 513 CmsListDirectAction editAction = new CmsListEditResourceAction(LIST_ACTION_EDIT, LIST_COLUMN_NAME); 514 editAction.setEnabled(true); 515 editIconCol.addDirectAction(editAction); 516 // add disabled edit action 517 CmsListDirectAction noEditAction = new CmsListEditResourceAction(LIST_ACTION_EDIT + "d", LIST_COLUMN_NAME); 518 noEditAction.setEnabled(false); 519 editIconCol.addDirectAction(noEditAction); 520 metadata.addColumn(editIconCol); 521 522 // position 2: lock icon 523 CmsListColumnDefinition lockIconCol = new CmsListColumnDefinition(LIST_COLUMN_LOCKICON); 524 lockIconCol.setName(Messages.get().container(Messages.GUI_EXPLORER_LIST_COLS_LOCK_0)); 525 lockIconCol.setWidth("20"); 526 lockIconCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER); 527 lockIconCol.setListItemComparator(new CmsListItemActionIconComparator()); 528 529 // add lock icon action 530 CmsListDirectAction resourceLockIconAction = new CmsListResourceLockAction(LIST_ACTION_LOCKICON); 531 resourceLockIconAction.setEnabled(false); 532 lockIconCol.addDirectAction(resourceLockIconAction); 533 metadata.addColumn(lockIconCol); 534 535 // position 3: project state icon, resource is inside or outside current project 536 CmsListColumnDefinition projStateIconCol = new CmsListColumnDefinition(LIST_COLUMN_PROJSTATEICON); 537 projStateIconCol.setName(Messages.get().container(Messages.GUI_EXPLORER_LIST_COLS_PROJSTATE_0)); 538 projStateIconCol.setWidth("20"); 539 540 // add resource icon action 541 CmsListDirectAction resourceProjStateAction = new CmsListResourceProjStateAction(LIST_ACTION_PROJSTATEICON); 542 resourceProjStateAction.setEnabled(false); 543 projStateIconCol.addDirectAction(resourceProjStateAction); 544 metadata.addColumn(projStateIconCol); 545 546 // position 4: name 547 CmsListColumnDefinition nameCol = new CmsListExplorerColumn(LIST_COLUMN_NAME); 548 nameCol.setName( 549 org.opencms.workplace.explorer.Messages.get().container( 550 org.opencms.workplace.explorer.Messages.GUI_INPUT_PATH_0)); 551 552 // add resource open action 553 CmsListDefaultAction resourceOpenDefAction = new CmsListOpenResourceAction( 554 LIST_DEFACTION_OPEN, 555 LIST_COLUMN_ROOT_PATH); 556 resourceOpenDefAction.setEnabled(true); 557 nameCol.addDefaultAction(resourceOpenDefAction); 558 metadata.addColumn(nameCol); 559 nameCol.setPrintable(false); 560 561 // position 4: root path for printing 562 CmsListColumnDefinition rootPathCol = new CmsListExplorerColumn(LIST_COLUMN_ROOT_PATH); 563 rootPathCol.setName( 564 org.opencms.workplace.explorer.Messages.get().container( 565 org.opencms.workplace.explorer.Messages.GUI_INPUT_NAME_0)); 566 rootPathCol.setVisible(false); 567 rootPathCol.setPrintable(true); 568 metadata.addColumn(rootPathCol); 569 570 // position 5: title 571 CmsListColumnDefinition titleCol = new CmsListExplorerColumn(LIST_COLUMN_TITLE); 572 titleCol.setName( 573 org.opencms.workplace.explorer.Messages.get().container( 574 org.opencms.workplace.explorer.Messages.GUI_INPUT_TITLE_0)); 575 metadata.addColumn(titleCol); 576 577 // position 6: resource type 578 CmsListColumnDefinition typeCol = new CmsListExplorerColumn(LIST_COLUMN_TYPE); 579 typeCol.setName( 580 org.opencms.workplace.explorer.Messages.get().container( 581 org.opencms.workplace.explorer.Messages.GUI_INPUT_TYPE_0)); 582 metadata.addColumn(typeCol); 583 584 // position 7: size 585 CmsListColumnDefinition sizeCol = new CmsListExplorerColumn(LIST_COLUMN_SIZE); 586 sizeCol.setName( 587 org.opencms.workplace.explorer.Messages.get().container( 588 org.opencms.workplace.explorer.Messages.GUI_INPUT_SIZE_0)); 589 metadata.addColumn(sizeCol); 590 591 // position 8: permissions 592 CmsListColumnDefinition permissionsCol = new CmsListExplorerColumn(LIST_COLUMN_PERMISSIONS); 593 permissionsCol.setName( 594 org.opencms.workplace.explorer.Messages.get().container( 595 org.opencms.workplace.explorer.Messages.GUI_INPUT_PERMISSIONS_0)); 596 metadata.addColumn(permissionsCol); 597 598 // position 9: date of last modification 599 CmsListColumnDefinition dateLastModCol = new CmsListExplorerColumn(LIST_COLUMN_DATELASTMOD); 600 dateLastModCol.setName( 601 org.opencms.workplace.explorer.Messages.get().container( 602 org.opencms.workplace.explorer.Messages.GUI_INPUT_DATELASTMODIFIED_0)); 603 dateLastModCol.setFormatter(CmsListDateMacroFormatter.getDefaultDateFormatter()); 604 metadata.addColumn(dateLastModCol); 605 606 // position 10: user who last modified the resource 607 CmsListColumnDefinition userLastModCol = new CmsListExplorerColumn(LIST_COLUMN_USERLASTMOD); 608 userLastModCol.setName( 609 org.opencms.workplace.explorer.Messages.get().container( 610 org.opencms.workplace.explorer.Messages.GUI_INPUT_USERLASTMODIFIED_0)); 611 metadata.addColumn(userLastModCol); 612 613 // position 11: date of creation 614 CmsListColumnDefinition dateCreateCol = new CmsListExplorerColumn(LIST_COLUMN_DATECREATE); 615 dateCreateCol.setName( 616 org.opencms.workplace.explorer.Messages.get().container( 617 org.opencms.workplace.explorer.Messages.GUI_INPUT_DATECREATED_0)); 618 dateCreateCol.setFormatter(CmsListDateMacroFormatter.getDefaultDateFormatter()); 619 metadata.addColumn(dateCreateCol); 620 621 // position 12: user who created the resource 622 CmsListColumnDefinition userCreateCol = new CmsListExplorerColumn(LIST_COLUMN_USERCREATE); 623 userCreateCol.setName( 624 org.opencms.workplace.explorer.Messages.get().container( 625 org.opencms.workplace.explorer.Messages.GUI_INPUT_USERCREATED_0)); 626 metadata.addColumn(userCreateCol); 627 628 // position 13: date of release 629 CmsListColumnDefinition dateReleaseCol = new CmsListExplorerColumn(LIST_COLUMN_DATEREL); 630 dateReleaseCol.setName( 631 org.opencms.workplace.explorer.Messages.get().container( 632 org.opencms.workplace.explorer.Messages.GUI_INPUT_DATERELEASED_0)); 633 dateReleaseCol.setFormatter( 634 new CmsListDateMacroFormatter( 635 Messages.get().container(Messages.GUI_LIST_DATE_FORMAT_1), 636 new CmsMessageContainer(null, CmsTouch.DEFAULT_DATE_STRING), 637 CmsResource.DATE_RELEASED_DEFAULT)); 638 metadata.addColumn(dateReleaseCol); 639 640 // position 14: date of expiration 641 CmsListColumnDefinition dateExpirationCol = new CmsListExplorerColumn(LIST_COLUMN_DATEEXP); 642 dateExpirationCol.setName( 643 org.opencms.workplace.explorer.Messages.get().container( 644 org.opencms.workplace.explorer.Messages.GUI_INPUT_DATEEXPIRED_0)); 645 dateExpirationCol.setFormatter( 646 new CmsListDateMacroFormatter( 647 Messages.get().container(Messages.GUI_LIST_DATE_FORMAT_1), 648 new CmsMessageContainer(null, CmsTouch.DEFAULT_DATE_STRING), 649 CmsResource.DATE_EXPIRED_DEFAULT)); 650 metadata.addColumn(dateExpirationCol); 651 652 // position 15: state (changed, unchanged, new, deleted) 653 CmsListColumnDefinition stateCol = new CmsListExplorerColumn(LIST_COLUMN_STATE); 654 stateCol.setName( 655 org.opencms.workplace.explorer.Messages.get().container( 656 org.opencms.workplace.explorer.Messages.GUI_INPUT_STATE_0)); 657 metadata.addColumn(stateCol); 658 659 // position 16: locked by 660 CmsListColumnDefinition lockedByCol = new CmsListExplorerColumn(LIST_COLUMN_LOCKEDBY); 661 lockedByCol.setName( 662 org.opencms.workplace.explorer.Messages.get().container( 663 org.opencms.workplace.explorer.Messages.GUI_INPUT_LOCKEDBY_0)); 664 metadata.addColumn(lockedByCol); 665 666 // position 17: site 667 CmsListColumnDefinition siteCol = new CmsListExplorerColumn(LIST_COLUMN_SITE); 668 siteCol.setName( 669 org.opencms.workplace.explorer.Messages.get().container( 670 org.opencms.workplace.explorer.Messages.GUI_LABEL_SITE_0)); 671 metadata.addColumn(siteCol); 672 } 673 674 /** 675 * Sets the default column visibility flags from the user preferences.<p> 676 */ 677 protected void setColumnVisibilities() { 678 679 m_colVisibilities = new HashMap<Integer, Boolean>(16); 680 // set explorer configurable column visibilities 681 int preferences = new CmsUserSettings(getCms()).getExplorerSettings(); 682 setColumnVisibility(CmsUserSettings.FILELIST_TITLE, preferences); 683 setColumnVisibility(CmsUserSettings.FILELIST_TYPE, preferences); 684 setColumnVisibility(CmsUserSettings.FILELIST_SIZE, preferences); 685 setColumnVisibility(CmsUserSettings.FILELIST_PERMISSIONS, preferences); 686 setColumnVisibility(CmsUserSettings.FILELIST_DATE_LASTMODIFIED, preferences); 687 setColumnVisibility(CmsUserSettings.FILELIST_USER_LASTMODIFIED, preferences); 688 setColumnVisibility(CmsUserSettings.FILELIST_DATE_CREATED, preferences); 689 setColumnVisibility(CmsUserSettings.FILELIST_USER_CREATED, preferences); 690 setColumnVisibility(CmsUserSettings.FILELIST_DATE_RELEASED, preferences); 691 setColumnVisibility(CmsUserSettings.FILELIST_DATE_EXPIRED, preferences); 692 setColumnVisibility(CmsUserSettings.FILELIST_STATE, preferences); 693 setColumnVisibility(CmsUserSettings.FILELIST_LOCKEDBY, preferences); 694 // set explorer no configurable column visibilities 695 m_colVisibilities.put(Integer.valueOf(LIST_COLUMN_TYPEICON.hashCode()), Boolean.TRUE); 696 m_colVisibilities.put(Integer.valueOf(LIST_COLUMN_LOCKICON.hashCode()), Boolean.TRUE); 697 m_colVisibilities.put(Integer.valueOf(LIST_COLUMN_PROJSTATEICON.hashCode()), Boolean.TRUE); 698 m_colVisibilities.put(Integer.valueOf(LIST_COLUMN_NAME.hashCode()), Boolean.TRUE); 699 m_colVisibilities.put(Integer.valueOf(LIST_COLUMN_EDIT.hashCode()), Boolean.FALSE); 700 m_colVisibilities.put( 701 Integer.valueOf(LIST_COLUMN_SITE.hashCode()), 702 Boolean.valueOf(OpenCms.getSiteManager().getSites().size() > 1)); 703 } 704 705 /** 706 * Sets the given column visibility flag from the given preferences.<p> 707 * 708 * @param colFlag the flag that identifies the column to set the flag for 709 * @param prefs the user preferences 710 */ 711 protected void setColumnVisibility(int colFlag, int prefs) { 712 713 Integer key = Integer.valueOf(colFlag); 714 Boolean value = Boolean.valueOf((prefs & colFlag) > 0); 715 m_colVisibilities.put(key, value); 716 } 717 718 /** 719 * Sets the colVisibilities map.<p> 720 * 721 * @param colVisibilities the colVisibilities map to set 722 */ 723 protected void setColVisibilities(Map<Integer, Boolean> colVisibilities) { 724 725 m_colVisibilities = colVisibilities; 726 } 727 728 /** 729 * @see org.opencms.workplace.list.A_CmsListDialog#setIndependentActions(org.opencms.workplace.list.CmsListMetadata) 730 */ 731 @Override 732 protected void setIndependentActions(CmsListMetadata metadata) { 733 734 metadata.addIndependentAction(CmsListIndependentAction.getDefaultExplorerSwitchAction()); 735 } 736 737 /** 738 * Returns the show explorer flag.<p> 739 * 740 * @return the show explorer flag 741 */ 742 private boolean getShowExplorer() { 743 744 if (getParamShowexplorer() != null) { 745 return Boolean.valueOf(getParamShowexplorer()).booleanValue(); 746 } 747 Map<?, ?> dialogObject = (Map<?, ?>)getSettings().getDialogObject(); 748 if (dialogObject == null) { 749 return false; 750 } 751 Boolean storedParam = (Boolean)dialogObject.get(getClass().getName()); 752 if (storedParam == null) { 753 return false; 754 } 755 return storedParam.booleanValue(); 756 } 757 758 /** 759 * Sets the show explorer flag.<p> 760 * 761 * @param showExplorer the show explorer flag 762 */ 763 @SuppressWarnings({"rawtypes", "unchecked"}) 764 private void setShowExplorer(boolean showExplorer) { 765 766 Map dialogMap = (Map)getSettings().getDialogObject(); 767 if (dialogMap == null) { 768 dialogMap = new HashMap(); 769 getSettings().setDialogObject(dialogMap); 770 } 771 dialogMap.put(getClass().getName(), Boolean.valueOf(showExplorer)); 772 } 773}