List of usage examples for org.apache.commons.lang BooleanUtils isTrue
public static boolean isTrue(Boolean bool)
Checks if a Boolean
value is true
, handling null
by returning false
.
BooleanUtils.isTrue(Boolean.TRUE) = true BooleanUtils.isTrue(Boolean.FALSE) = false BooleanUtils.isTrue(null) = false
From source file:org.pentaho.di.ui.repository.dialog.SelectDirectoryDialog.java
@SuppressWarnings("deprecation") public RepositoryDirectoryInterface open() { dircolor = GUIResource.getInstance().getColorDirectory(); Shell parent = getParent();/* w w w . jav a 2 s . co m*/ shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN); props.setLook(shell); shell.setImage(GUIResource.getInstance().getImageSpoon()); shell.setText(BaseMessages.getString(PKG, "SelectDirectoryDialog.Dialog.Main.Title")); FormLayout formLayout = new FormLayout(); formLayout.marginWidth = Const.FORM_MARGIN; formLayout.marginHeight = Const.FORM_MARGIN; shell.setLayout(formLayout); // Tree wTree = new Tree(shell, SWT.SINGLE | SWT.BORDER); props.setLook(wTree); try { if (rep instanceof RepositoryExtended) { RepositoryExtended repositoryExtended = (RepositoryExtended) this.rep; repositoryTree = repositoryExtended.loadRepositoryDirectoryTree("/", null, -1, BooleanUtils.isTrue(repositoryExtended.getUserInfo().isAdmin()), true, false); } else { repositoryTree = this.rep.loadRepositoryDirectoryTree(); } } catch (KettleException e) { new ErrorDialog(shell, BaseMessages.getString(PKG, "SelectDirectoryDialog.Dialog.ErrorRefreshingDirectoryTree.Title"), BaseMessages.getString(PKG, "SelectDirectoryDialog.Dialog.ErrorRefreshingDirectoryTree.Message"), e); return null; } if (!getData()) { return null; } // Buttons wOK = new Button(shell, SWT.PUSH); wOK.setText(BaseMessages.getString(PKG, "System.Button.OK")); wRefresh = new Button(shell, SWT.PUSH); wRefresh.setText(BaseMessages.getString(PKG, "System.Button.Refresh")); wCancel = new Button(shell, SWT.PUSH); wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel")); FormData fdTree = new FormData(); FormData fdOK = new FormData(); FormData fdRefresh = new FormData(); FormData fdCancel = new FormData(); int margin = 10; fdTree.left = new FormAttachment(0, 0); // To the right of the label fdTree.top = new FormAttachment(0, 0); fdTree.right = new FormAttachment(100, 0); fdTree.bottom = new FormAttachment(100, -50); wTree.setLayoutData(fdTree); fdOK.left = new FormAttachment(wTree, 0, SWT.CENTER); fdOK.bottom = new FormAttachment(100, -margin); wOK.setLayoutData(fdOK); fdRefresh.left = new FormAttachment(wOK, 10); fdRefresh.bottom = new FormAttachment(100, -margin); wRefresh.setLayoutData(fdRefresh); fdCancel.left = new FormAttachment(wRefresh, 10); fdCancel.bottom = new FormAttachment(100, -margin); wCancel.setLayoutData(fdCancel); // Add listeners wCancel.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { dispose(); } }); // Add listeners wOK.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { handleOK(); } }); wTree.addSelectionListener(new SelectionAdapter() { private String getSelectedPath(SelectionEvent selectionEvent) { TreeItem treeItem = (TreeItem) selectionEvent.item; String path; if (treeItem.getParentItem() == null) { path = treeItem.getText(); } else { path = ConstUI.getTreePath(treeItem, 0); } return path; } private boolean isSelectedPathRestricted(SelectionEvent selectionEvent) { String path = getSelectedPath(selectionEvent); boolean isRestricted = isRestrictedPath(path); return isRestricted; } public void widgetDefaultSelected(SelectionEvent selectionEvent) { if (isSelectedPathRestricted(selectionEvent)) { return; } handleOK(); } public void widgetSelected(SelectionEvent selectionEvent) { boolean restricted = isSelectedPathRestricted(selectionEvent); wOK.setEnabled(!restricted); } }); wRefresh.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { getData(); } }); wTree.addMenuDetectListener(new MenuDetectListener() { public void menuDetected(MenuDetectEvent e) { setTreeMenu(); } }); BaseStepDialog.setSize(shell); shell.open(); Display display = parent.getDisplay(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return selection; }
From source file:org.pentaho.di.ui.repository.dialog.SelectObjectDialog.java
@SuppressWarnings("deprecation") public String open() { Shell parent = getParent();/*from w w w. j a v a 2 s .c om*/ dircolor = GUIResource.getInstance().getColorDirectory(); shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.SHEET | SWT.RESIZE | SWT.MIN | SWT.MAX); props.setLook(shell); shell.setImage(GUIResource.getInstance().getImageSpoon()); FormLayout formLayout = new FormLayout(); formLayout.marginWidth = Const.FORM_MARGIN; formLayout.marginHeight = Const.FORM_MARGIN; shell.setLayout(formLayout); shell.setText(shellText); int margin = Const.MARGIN; ToolBar treeTb = new ToolBar(shell, SWT.HORIZONTAL | SWT.FLAT); props.setLook(treeTb); wfilter = new ToolItem(treeTb, SWT.SEPARATOR); searchText = new Text(treeTb, SWT.SEARCH | SWT.CANCEL); searchText.setToolTipText( BaseMessages.getString(PKG, "RepositoryExplorerDialog.Search.FilterString.ToolTip")); wfilter.setControl(searchText); wfilter.setWidth(100); wbRegex = new ToolItem(treeTb, SWT.CHECK); wbRegex.setImage(GUIResource.getInstance().getImageRegexSmall()); wbRegex.setToolTipText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Search.UseRegex")); goSearch = new ToolItem(treeTb, SWT.PUSH); goSearch.setImage(GUIResource.getInstance().getImageSearchSmall()); goSearch.setToolTipText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Search.Run")); expandAll = new ToolItem(treeTb, SWT.PUSH); expandAll.setImage(GUIResource.getInstance().getImageExpandAll()); collapseAll = new ToolItem(treeTb, SWT.PUSH); collapseAll.setImage(GUIResource.getInstance().getImageCollapseAll()); fdexpandAll = new FormData(); fdexpandAll.right = new FormAttachment(100, -margin); fdexpandAll.top = new FormAttachment(0, margin); treeTb.setLayoutData(fdexpandAll); // From step line wlTree = new Label(shell, SWT.NONE); wlTree.setText(lineText); props.setLook(wlTree); fdlTree = new FormData(); fdlTree.left = new FormAttachment(0, 0); fdlTree.top = new FormAttachment(0, margin); wlTree.setLayoutData(fdlTree); wTree = new Tree(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); wTree.setHeaderVisible(true); props.setLook(wTree); // Add some columns to it as well... nameColumn = new TreeColumn(wTree, SWT.LEFT); nameColumn.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Column.Name")); nameColumn.setWidth(350); nameColumn.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { setSort(0); } }); // No sorting on the type column just yet. typeColumn = new TreeColumn(wTree, SWT.LEFT); typeColumn.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Column.Type")); typeColumn.setWidth(100); typeColumn.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { setSort(1); } }); userColumn = new TreeColumn(wTree, SWT.LEFT); userColumn.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Column.User")); userColumn.setWidth(100); userColumn.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { setSort(2); } }); changedColumn = new TreeColumn(wTree, SWT.LEFT); changedColumn.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Column.Changed")); changedColumn.setWidth(120); changedColumn.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { setSort(3); } }); descriptionColumn = new TreeColumn(wTree, SWT.LEFT); descriptionColumn.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Column.Description")); descriptionColumn.setWidth(120); descriptionColumn.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { setSort(4); } }); props.setLook(wTree); fdTree = new FormData(); fdTree.left = new FormAttachment(0, 0); fdTree.right = new FormAttachment(100, 0); fdTree.top = new FormAttachment(treeTb, margin); fdTree.bottom = new FormAttachment(100, -30); wTree.setLayoutData(fdTree); // Some buttons wOK = new Button(shell, SWT.PUSH); wOK.setText(BaseMessages.getString(PKG, "System.Button.OK")); lsOK = new Listener() { public void handleEvent(Event e) { ok(); } }; wOK.addListener(SWT.Selection, lsOK); wOK.setEnabled(false); wCancel = new Button(shell, SWT.PUSH); wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel")); lsCancel = new Listener() { public void handleEvent(Event e) { cancel(); } }; wCancel.addListener(SWT.Selection, lsCancel); BaseStepDialog.positionBottomButtons(shell, new Button[] { wOK, wCancel }, margin, null); // Add listeners lsDef = new SelectionAdapter() { public void widgetDefaultSelected(SelectionEvent e) { ok(); } }; wTree.addSelectionListener(lsDef); wTree.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.character == SWT.CR) { ok(); } } }); wTree.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (wTree.getSelection().length > 0) { wOK.setEnabled(!Boolean.TRUE.equals(wTree.getSelection()[0].getData("isFolder"))); } } }); expandAll.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { expandAllItems(wTree.getItems(), true); } }); collapseAll.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { expandAllItems(wTree.getItems(), false); } }); goSearch.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { updateFilter(); } }); searchText.addSelectionListener(new SelectionAdapter() { public void widgetDefaultSelected(SelectionEvent e) { updateFilter(); } }); // Detect [X] or ALT-F4 or something that kills this window... shell.addShellListener(new ShellAdapter() { public void shellClosed(ShellEvent e) { cancel(); } }); try { if (rep instanceof RepositoryExtended) { RepositoryExtended repositoryExtended = (RepositoryExtended) this.rep; directoryTree = repositoryExtended.loadRepositoryDirectoryTree("/", "*.kjb|*.ktr", -1, BooleanUtils.isTrue(repositoryExtended.getUserInfo().isAdmin()), true, false); } else { directoryTree = this.rep.loadRepositoryDirectoryTree(); } } catch (KettleException e) { new ErrorDialog(shell, BaseMessages.getString(PKG, "SelectObjectDialog.Dialog.ErrorRefreshingDirectoryTree.Title"), BaseMessages.getString(PKG, "SelectObjectDialog.Dialog.ErrorRefreshingDirectoryTree.Message"), e); } // catch() getData(); wTree.setFocus(); BaseStepDialog.setSize(shell); shell.open(); while (!shell.isDisposed()) { if (!shell.getDisplay().readAndDispatch()) { shell.getDisplay().sleep(); } } return objectName; }
From source file:org.pentaho.di.ui.repository.repositoryexplorer.controllers.BrowseController.java
@SuppressWarnings("deprecation") public void init(Repository repository) throws ControllerInitializationException { try {//from w w w .j ava2s. c om this.repository = repository; mainController = (MainController) this.getXulDomContainer().getEventHandler("mainController"); RepositoryDirectoryInterface root; try { if (repository instanceof RepositoryExtended) { root = ((RepositoryExtended) repository).loadRepositoryDirectoryTree("/", "*.ktr|*.kjb", -1, BooleanUtils.isTrue(repository.getUserInfo().isAdmin()), true, true); } else { root = repository.loadRepositoryDirectoryTree(); } this.repositoryDirectory = UIObjectRegistry.getInstance().constructUIRepositoryDirectory(root, null, repository); } catch (UIObjectCreationException uoe) { this.repositoryDirectory = new UIRepositoryDirectory(repository.loadRepositoryDirectoryTree(), null, repository); } dirMap = new HashMap<ObjectId, UIRepositoryDirectory>(); populateDirMap(repositoryDirectory); bf = new SwtBindingFactory(); bf.setDocument(this.getXulDomContainer().getDocumentRoot()); messageBox = (XulMessageBox) document.createElement("messagebox"); createBindings(); } catch (Exception e) { throw new ControllerInitializationException(e); } }
From source file:org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory.java
/** * Synchronize this folder with the back-end * //from w w w . ja v a 2 s . c om * */ public void refresh() { try { kidElementCache = null; kidDirectoryCache = null; if (this == getRootDirectory()) { RepositoryDirectoryInterface localRoot; if (rep instanceof RepositoryExtended) { localRoot = ((RepositoryExtended) rep) .loadRepositoryDirectoryTree("/", "*.ktr|*.kjb", -1, BooleanUtils.isTrue(rep.getUserInfo().isAdmin()), true, true) .findDirectory(rd.getObjectId()); } else { localRoot = rep.findDirectory(rd.getObjectId()); } rd = localRoot; // Rebuild caches fireCollectionChanged(); } else { getRootDirectory().refresh(); } } catch (Exception e) { // TODO: Better error handling e.printStackTrace(); } }
From source file:org.pentaho.repo.controller.RepositoryBrowserController.java
public List<RepositoryDirectory> loadDirectoryTree(String filter) { if (getRepository() != null) { RepositoryDirectoryInterface repositoryDirectoryInterface; try {/*from w w w .j a v a 2s .c o m*/ if (getRepository() instanceof RepositoryExtended) { repositoryDirectoryInterface = ((RepositoryExtended) getRepository()) .loadRepositoryDirectoryTree("/", filter, -1, BooleanUtils.isTrue(getRepository().getUserInfo().isAdmin()), true, true); } else { repositoryDirectoryInterface = getRepository().loadRepositoryDirectoryTree(); } List<RepositoryDirectory> repositoryDirectories = new LinkedList<>(); boolean isPentahoRepository = getRepository().getRepositoryMeta().getId() .equals("PentahoEnterpriseRepository"); int depth = isPentahoRepository ? -1 : 0; createRepositoryDirectory(repositoryDirectoryInterface, repositoryDirectories, depth, null, filter); return repositoryDirectories; } catch (Exception e) { return null; } } return null; }
From source file:org.projectforge.address.AddressDaoRest.java
/** * Rest-Call for {@link AddressDao#getFavoriteVCards()}. <br/> * If modifiedSince is given then only those addresses will be returned: * <ol>// ww w . java 2 s . c om * <li>The address was changed after the given modifiedSince date, or</li> * <li>the address was added to the user's personal address book after the given modifiedSince date, or</li> * <li>the address was removed from the user's personal address book after the given modifiedSince date.</li> * </ol> * @param searchTerm * @param modifiedSince milliseconds since 1970 (UTC) * @param all If true and the user is member of the ProjectForge's group {@link ProjectForgeGroup#FINANCE_GROUP} or * {@link ProjectForgeGroup#MARKETING_GROUP} the export contains all addresses instead of only favorite addresses. * @see AddressDaoClientMain */ @GET @Path(RestPaths.LIST) @Produces(MediaType.APPLICATION_JSON) public Response getList(@QueryParam("search") final String searchTerm, @QueryParam("modifiedSince") final Long modifiedSince, @QueryParam("all") final Boolean all) { final AddressFilter filter = new AddressFilter(new BaseSearchFilter()); Date modifiedSinceDate = null; if (modifiedSince != null) { modifiedSinceDate = new Date(modifiedSince); filter.setModifiedSince(modifiedSinceDate); } filter.setSearchString(searchTerm); final List<AddressDO> list = addressDao.getList(filter); boolean exportAll = false; if (BooleanUtils.isTrue(all) == true && accessChecker.isLoggedInUserMemberOfGroup(ProjectForgeGroup.FINANCE_GROUP, ProjectForgeGroup.MARKETING_GROUP) == true) { exportAll = true; } List<PersonalAddressDO> favorites = null; Set<Integer> favoritesSet = null; if (exportAll == false) { favorites = personalAddressDao.getList(); favoritesSet = new HashSet<Integer>(); if (favorites != null) { for (final PersonalAddressDO personalAddress : favorites) { if (personalAddress.isFavoriteCard() == true && personalAddress.isDeleted() == false) { favoritesSet.add(personalAddress.getAddressId()); } } } } final List<AddressObject> result = new LinkedList<AddressObject>(); final Set<Integer> alreadyExported = new HashSet<Integer>(); if (list != null) { for (final AddressDO addressDO : list) { if (exportAll == false && favoritesSet.contains(addressDO.getId()) == false) { // Export only personal favorites due to data-protection. continue; } final AddressObject address = AddressDOConverter.getAddressObject(addressDO); result.add(address); alreadyExported.add(address.getId()); } } if (exportAll == false && modifiedSinceDate != null) { // Add now personal address entries which were modified since the given date (deleted or added): for (final PersonalAddressDO personalAddress : favorites) { if (alreadyExported.contains(personalAddress.getAddressId()) == true) { // Already exported: } if (personalAddress.getLastUpdate() != null && personalAddress.getLastUpdate().before(modifiedSinceDate) == false) { final AddressDO addressDO = addressDao.getById(personalAddress.getAddressId()); final AddressObject address = AddressDOConverter.getAddressObject(addressDO); if (personalAddress.isFavorite() == false) { // This address was may-be removed by the user from the personal address book, so add this address as deleted to the result // list. address.setDeleted(true); } result.add(address); } } } @SuppressWarnings("unchecked") final List<AddressObject> uniqResult = (List<AddressObject>) CollectionUtils.select(result, PredicateUtils.uniquePredicate()); final String json = JsonUtils.toJson(uniqResult); log.info("Rest call finished (" + result.size() + " addresses)..."); return Response.ok(json).build(); }
From source file:org.projectforge.export.MyXlsContentProvider.java
/** * @see org.projectforge.excel.XlsContentProvider#getCellFormat(org.projectforge.excel.ExportCell, java.lang.Object, java.lang.String, * java.util.Map)/*from w w w . j av a2s . c o m*/ */ @Override protected CellFormat getCustomizedCellFormat(final CellFormat format, final Object value) { if (value == null || DateHolder.class.isAssignableFrom(value.getClass()) == false) { return null; } if (format != null && BooleanUtils.isTrue(format.getAutoDatePrecision()) == false) { return null; } // Find a format dependent on the precision: final DatePrecision precision = ((DateHolder) value).getPrecision(); if (precision == DatePrecision.DAY) { return new CellFormat(DateFormats.getExcelFormatString(DateFormatType.DATE)); } else if (precision == DatePrecision.SECOND) { return new CellFormat(DateFormats.getExcelFormatString(DateFormatType.DATE_TIME_SECONDS)); } else if (precision == DatePrecision.MILLISECOND) { return new CellFormat(DateFormats.getExcelFormatString(DateFormatType.DATE_TIME_MILLIS)); } else { // HOUR_OF_DAY, MINUTE, MINUTE_15 or null return new CellFormat(DateFormats.getExcelFormatString(DateFormatType.DATE_TIME_MINUTES)); } }
From source file:org.projectforge.export.XlsContentProvider.java
/** * @param cell//from w w w . j av a 2 s . c o m * @param value * @param property * @param map * @return A clone of a pre-defined cell format if found, otherwise null. */ private CellFormat getCellFormat(final ExportCell cell, final Object value, final String property, final Map<Object, CellFormat> map) { CellFormat format = null; if (property != null) { format = map.get(property); } if (format == null) { Class<?> clazz = value == null ? null : value.getClass(); while (format == null && clazz != null) { format = map.get(clazz); clazz = clazz.getSuperclass(); } } if (format == null) { return null; } if (value != null && DateHolder.class.isAssignableFrom(value.getClass()) == true && BooleanUtils.isTrue(format.getAutoDatePrecision()) == true) { // Find a format dependent on the precision: final DatePrecision precision = ((DateHolder) value).getPrecision(); if (precision == DatePrecision.DAY) { return new CellFormat(DateFormats.getExcelFormatString(DateFormatType.DATE)); } else if (precision == DatePrecision.SECOND) { return new CellFormat(DateFormats.getExcelFormatString(DateFormatType.TIMESTAMP_SECONDS)); } else if (precision == DatePrecision.MILLISECOND) { return new CellFormat(DateFormats.getExcelFormatString(DateFormatType.TIMESTAMP_MILLIS)); } else { // HOUR_OF_DAY, MINUTE, MINUTE_15 or null return new CellFormat(DateFormats.getExcelFormatString(DateFormatType.TIMESTAMP_MINUTES)); } } return format.clone(); }
From source file:org.projectforge.mail.SendMail.java
/** * @param composedMessage// w ww. j av a2s. c o m * @return true for successful sending, otherwise an exception will be thrown. * @throws UserException if to address is not given. * @throws InternalErrorException due to technical failures. */ public boolean send(final Mail composedMessage) { final String to = composedMessage.getTo(); if (to == null || to.trim().length() == 0) { log.error("No to address given. Sending of mail cancelled: " + composedMessage.toString()); throw new UserException("mail.error.missingToAddress"); } if (StringUtils.isBlank(sendMailConfig.getHost()) == true) { log.error("No e-mail host configured. E-Mail not sent: " + composedMessage.toString()); return false; } log.info("Try to send email to " + to); // Get a Session object if (properties == null) { properties = new Properties(); String protocol = sendMailConfig.getProtocol(); properties.put("mail.from", sendMailConfig.getFrom()); properties.put("mail.mime.charset", "UTF-8"); properties.put("mail.transport.protocol", sendMailConfig.getProtocol()); properties.put("mail." + protocol + ".host", sendMailConfig.getHost()); properties.put("mail." + protocol + ".port", sendMailConfig.getPort()); if (BooleanUtils.isTrue(sendMailConfig.getDebug()) == true) { properties.put("mail.debug", "true"); } } new Thread() { @Override public void run() { sendIt(composedMessage); } }.start(); return true; }
From source file:org.projectforge.plugins.todo.ToDoEditPage.java
@Override public AbstractSecuredBasePage afterSaveOrUpdate() { // Save to-do as recent to-do final ToDoDO pref = getToDoPrefData(true); copyPrefValues(getData(), pref);//from w ww . j a v a 2 s .c o m // Does the user want to store this to-do as template? boolean sendNotification = false; if (form.sendNotification == true) { sendNotification = true; } else if (oldToDo == null) { // Send notification on new to-do's. sendNotification = true; } else { if (ObjectUtils.equals(oldToDo.getAssigneeId(), getData().getAssigneeId()) == false) { // Assignee was changed. sendNotification = true; } else if (oldToDo.getStatus() != getData().getStatus()) { // Status was changed. sendNotification = true; } else if (oldToDo.isDeleted() != getData().isDeleted()) { // Deletion status was changed. sendNotification = true; } } if (sendNotification == true) { sendNotification(); } // if (form.sendShortMessage == true) { // final PFUserDO assignee = getData().getAssignee(); // final String mobileNumber = assignee != null ? assignee.getPersonalMebMobileNumbers() : null; // } if (BooleanUtils.isTrue(form.saveAsTemplate) == true) { final UserPrefEditPage userPrefEditPage = new UserPrefEditPage(ToDoPlugin.USER_PREF_AREA, getData()); userPrefEditPage.setReturnToPage(this.returnToPage); return userPrefEditPage; } return null; }