code stringlengths 73 34.1k | label stringclasses 1 value |
|---|---|
public static String getSolrRangeString(String from, String to) {
// If a parameter is not initialized, use the asterisk '*' operator
if (CmsStringUtil.isEmptyOrWhitespaceOnly(from)) {
from = "*";
}
if (CmsStringUtil.isEmptyOrWhitespaceOnly(to)) {
to = "*";
}
return String.format("[%s TO %s]", from, to);
} | java |
public static Collection<ContentStream> toContentStreams(final String str, final String contentType) {
if (str == null) {
return null;
}
ArrayList<ContentStream> streams = new ArrayList<>(1);
ContentStreamBase ccc = new ContentStreamBase.StringStream(str);
ccc.setContentType(contentType);
streams.add(ccc);
return streams;
} | java |
public static String paramMapToString(final Map<String, String[]> parameters) {
final StringBuffer result = new StringBuffer();
for (final String key : parameters.keySet()) {
String[] values = parameters.get(key);
if (null == values) {
result.append(key).append('&');
} else {
for (final String value : parameters.get(key)) {
result.append(key).append('=').append(CmsEncoder.encode(value)).append('&');
}
}
}
// remove last '&'
if (result.length() > 0) {
result.setLength(result.length() - 1);
}
return result.toString();
} | java |
String getFacetParamKey(String facet) {
I_CmsSearchControllerFacetField fieldFacet = m_result.getController().getFieldFacets().getFieldFacetController().get(
facet);
if (fieldFacet != null) {
return fieldFacet.getConfig().getParamKey();
}
I_CmsSearchControllerFacetRange rangeFacet = m_result.getController().getRangeFacets().getRangeFacetController().get(
facet);
if (rangeFacet != null) {
return rangeFacet.getConfig().getParamKey();
}
I_CmsSearchControllerFacetQuery queryFacet = m_result.getController().getQueryFacet();
if ((queryFacet != null) && queryFacet.getConfig().getName().equals(facet)) {
return queryFacet.getConfig().getParamKey();
}
// Facet did not exist
LOG.warn(Messages.get().getBundle().key(Messages.LOG_FACET_NOT_CONFIGURED_1, facet), new Throwable());
return null;
} | java |
public static void closeWindow(Component component) {
Window window = getWindow(component);
if (window != null) {
window.close();
}
} | java |
@SuppressWarnings("unchecked")
public static <T> void defaultHandleContextMenuForMultiselect(
Table table,
CmsContextMenu menu,
ItemClickEvent event,
List<I_CmsSimpleContextMenuEntry<Collection<T>>> entries) {
if (!event.isCtrlKey() && !event.isShiftKey()) {
if (event.getButton().equals(MouseButton.RIGHT)) {
Collection<T> oldValue = ((Collection<T>)table.getValue());
if (oldValue.isEmpty() || !oldValue.contains(event.getItemId())) {
table.setValue(new HashSet<Object>(Arrays.asList(event.getItemId())));
}
Collection<T> selection = (Collection<T>)table.getValue();
menu.setEntries(entries, selection);
menu.openForTable(event, table);
}
}
} | java |
public static IndexedContainer getGroupsOfUser(
CmsObject cms,
CmsUser user,
String caption,
String iconProp,
String ou,
String propStatus,
Function<CmsGroup, CmsCssIcon> iconProvider) {
IndexedContainer container = new IndexedContainer();
container.addContainerProperty(caption, String.class, "");
container.addContainerProperty(ou, String.class, "");
container.addContainerProperty(propStatus, Boolean.class, new Boolean(true));
if (iconProvider != null) {
container.addContainerProperty(iconProp, CmsCssIcon.class, null);
}
try {
for (CmsGroup group : cms.getGroupsOfUser(user.getName(), true)) {
Item item = container.addItem(group);
item.getItemProperty(caption).setValue(group.getSimpleName());
item.getItemProperty(ou).setValue(group.getOuFqn());
if (iconProvider != null) {
item.getItemProperty(iconProp).setValue(iconProvider.apply(group));
}
}
} catch (CmsException e) {
LOG.error("Unable to read groups from user", e);
}
return container;
} | java |
public static IndexedContainer getPrincipalContainer(
CmsObject cms,
List<? extends I_CmsPrincipal> list,
String captionID,
String descID,
String iconID,
String ouID,
String icon,
List<FontIcon> iconList) {
IndexedContainer res = new IndexedContainer();
res.addContainerProperty(captionID, String.class, "");
res.addContainerProperty(ouID, String.class, "");
res.addContainerProperty(iconID, FontIcon.class, new CmsCssIcon(icon));
if (descID != null) {
res.addContainerProperty(descID, String.class, "");
}
for (I_CmsPrincipal group : list) {
Item item = res.addItem(group);
item.getItemProperty(captionID).setValue(group.getSimpleName());
item.getItemProperty(ouID).setValue(group.getOuFqn());
if (descID != null) {
item.getItemProperty(descID).setValue(group.getDescription(A_CmsUI.get().getLocale()));
}
}
for (int i = 0; i < iconList.size(); i++) {
res.getItem(res.getIdByIndex(i)).getItemProperty(iconID).setValue(iconList.get(i));
}
return res;
} | java |
public static void setFilterBoxStyle(TextField searchBox) {
searchBox.setIcon(FontOpenCms.FILTER);
searchBox.setPlaceholder(
org.opencms.ui.apps.Messages.get().getBundle(UI.getCurrent().getLocale()).key(
org.opencms.ui.apps.Messages.GUI_EXPLORER_FILTER_0));
searchBox.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
} | java |
protected ZipEntry getZipEntry(String filename) throws ZipException {
// yes
ZipEntry entry = getZipFile().getEntry(filename);
// path to file might be relative, too
if ((entry == null) && filename.startsWith("/")) {
entry = m_zipFile.getEntry(filename.substring(1));
}
if (entry == null) {
throw new ZipException(
Messages.get().getBundle().key(Messages.LOG_IMPORTEXPORT_FILE_NOT_FOUND_IN_ZIP_1, filename));
}
return entry;
} | java |
protected void appenHtmlFooter(StringBuffer buffer) {
if (m_configuredFooter != null) {
buffer.append(m_configuredFooter);
} else {
buffer.append(" </body>\r\n" + "</html>");
}
} | java |
public void openReport(String newState, A_CmsReportThread thread, String label) {
setReport(newState, thread);
m_labels.put(thread, label);
openSubView(newState, true);
} | java |
public static CmsUUID readId(JSONObject obj, String key) {
String strValue = obj.optString(key);
if (!CmsUUID.isValidUUID(strValue)) {
return null;
}
return new CmsUUID(strValue);
} | java |
public void setSiteRoot(String siteRoot) {
if (siteRoot != null) {
siteRoot = siteRoot.replaceFirst("/$", "");
}
m_siteRoot = siteRoot;
} | java |
public JSONObject toJson() throws JSONException {
JSONObject result = new JSONObject();
if (m_detailId != null) {
result.put(JSON_DETAIL, "" + m_detailId);
}
if (m_siteRoot != null) {
result.put(JSON_SITEROOT, m_siteRoot);
}
if (m_structureId != null) {
result.put(JSON_STRUCTUREID, "" + m_structureId);
}
if (m_projectId != null) {
result.put(JSON_PROJECT, "" + m_projectId);
}
if (m_type != null) {
result.put(JSON_TYPE, "" + m_type.getJsonId());
}
return result;
} | java |
public String updateContextAndGetFavoriteUrl(CmsObject cms) throws CmsException {
CmsResourceFilter filter = CmsResourceFilter.IGNORE_EXPIRATION;
CmsProject project = null;
switch (getType()) {
case explorerFolder:
CmsResource folder = cms.readResource(getStructureId(), filter);
project = cms.readProject(getProjectId());
cms.getRequestContext().setSiteRoot(getSiteRoot());
cms.getRequestContext().setCurrentProject(project);
String explorerLink = CmsVaadinUtils.getWorkplaceLink()
+ "#!"
+ CmsFileExplorerConfiguration.APP_ID
+ "/"
+ getProjectId()
+ "!!"
+ getSiteRoot()
+ "!!"
+ cms.getSitePath(folder);
return explorerLink;
case page:
project = cms.readProject(getProjectId());
CmsResource target = cms.readResource(getStructureId(), filter);
CmsResource detailContent = null;
String link = null;
cms.getRequestContext().setCurrentProject(project);
cms.getRequestContext().setSiteRoot(getSiteRoot());
if (getDetailId() != null) {
detailContent = cms.readResource(getDetailId());
link = OpenCms.getLinkManager().substituteLinkForUnknownTarget(
cms,
cms.getSitePath(detailContent),
cms.getSitePath(target),
false);
} else {
link = OpenCms.getLinkManager().substituteLink(cms, target);
}
return link;
default:
return null;
}
} | java |
public static void openFavoriteDialog(CmsFileExplorer explorer) {
try {
CmsExplorerFavoriteContext context = new CmsExplorerFavoriteContext(A_CmsUI.getCmsObject(), explorer);
CmsFavoriteDialog dialog = new CmsFavoriteDialog(context, new CmsFavoriteDAO(A_CmsUI.getCmsObject()));
Window window = CmsBasicDialog.prepareWindow(DialogWidth.max);
window.setContent(dialog);
window.setCaption(CmsVaadinUtils.getMessageText(org.opencms.ui.Messages.GUI_FAVORITES_DIALOG_TITLE_0));
A_CmsUI.get().addWindow(window);
window.center();
} catch (CmsException e) {
CmsErrorDialog.showErrorDialog(e);
}
} | java |
public static CmsResource getDescriptor(CmsObject cms, String basename) {
CmsSolrQuery query = new CmsSolrQuery();
query.setResourceTypes(CmsMessageBundleEditorTypes.BundleType.DESCRIPTOR.toString());
query.setFilterQueries("filename:\"" + basename + CmsMessageBundleEditorTypes.Descriptor.POSTFIX + "\"");
query.add("fl", "path");
CmsSolrResultList results;
try {
boolean isOnlineProject = cms.getRequestContext().getCurrentProject().isOnlineProject();
String indexName = isOnlineProject
? CmsSolrIndex.DEFAULT_INDEX_NAME_ONLINE
: CmsSolrIndex.DEFAULT_INDEX_NAME_OFFLINE;
results = OpenCms.getSearchManager().getIndexSolr(indexName).search(cms, query, true, null, true, null);
} catch (CmsSearchException e) {
LOG.error(Messages.get().getBundle().key(Messages.ERR_BUNDLE_DESCRIPTOR_SEARCH_ERROR_0), e);
return null;
}
switch (results.size()) {
case 0:
return null;
case 1:
return results.get(0);
default:
String files = "";
for (CmsResource res : results) {
files += " " + res.getRootPath();
}
LOG.warn(Messages.get().getBundle().key(Messages.ERR_BUNDLE_DESCRIPTOR_NOT_UNIQUE_1, files));
return results.get(0);
}
} | java |
static void showWarning(final String caption, final String description) {
Notification warning = new Notification(caption, description, Type.WARNING_MESSAGE, true);
warning.setDelayMsec(-1);
warning.show(UI.getCurrent().getPage());
} | java |
public void setDateOnly(boolean dateOnly) {
if (m_dateOnly != dateOnly) {
m_dateOnly = dateOnly;
if (m_dateOnly) {
m_time.removeFromParent();
m_am.removeFromParent();
m_pm.removeFromParent();
} else {
m_timeField.add(m_time);
m_timeField.add(m_am);
m_timeField.add(m_pm);
}
}
} | java |
@UiHandler("m_addButton")
void addButtonClick(ClickEvent e) {
if (null != m_newDate.getValue()) {
m_dateList.addDate(m_newDate.getValue());
m_newDate.setValue(null);
if (handleChange()) {
m_controller.setDates(m_dateList.getDates());
}
}
} | java |
@UiHandler("m_dateList")
void dateListValueChange(ValueChangeEvent<SortedSet<Date>> event) {
if (handleChange()) {
m_controller.setDates(event.getValue());
}
} | java |
@Override
public String remove(Object key) {
String result = m_configurationStrings.remove(key);
m_configurationObjects.remove(key);
return result;
} | java |
private boolean loadCustomErrorPage(
CmsObject cms,
HttpServletRequest req,
HttpServletResponse res,
String rootPath) {
try {
// get the site of the error page resource
CmsSite errorSite = OpenCms.getSiteManager().getSiteForRootPath(rootPath);
cms.getRequestContext().setSiteRoot(errorSite.getSiteRoot());
String relPath = cms.getRequestContext().removeSiteRoot(rootPath);
if (cms.existsResource(relPath)) {
cms.getRequestContext().setUri(relPath);
OpenCms.getResourceManager().loadResource(cms, cms.readResource(relPath), req, res);
return true;
} else {
return false;
}
} catch (Throwable e) {
// something went wrong log the exception and return false
LOG.error(e.getMessage(), e);
return false;
}
} | java |
private boolean tryCustomErrorPage(CmsObject cms, HttpServletRequest req, HttpServletResponse res, int errorCode) {
String siteRoot = OpenCms.getSiteManager().matchRequest(req).getSiteRoot();
CmsSite site = OpenCms.getSiteManager().getSiteForSiteRoot(siteRoot);
if (site != null) {
// store current site root and URI
String currentSiteRoot = cms.getRequestContext().getSiteRoot();
String currentUri = cms.getRequestContext().getUri();
try {
if (site.getErrorPage() != null) {
String rootPath = site.getErrorPage();
if (loadCustomErrorPage(cms, req, res, rootPath)) {
return true;
}
}
String rootPath = CmsStringUtil.joinPaths(siteRoot, "/.errorpages/handle" + errorCode + ".html");
if (loadCustomErrorPage(cms, req, res, rootPath)) {
return true;
}
} finally {
cms.getRequestContext().setSiteRoot(currentSiteRoot);
cms.getRequestContext().setUri(currentUri);
}
}
return false;
} | java |
private CmsVfsEntryBean buildVfsEntryBeanForQuickSearch(
CmsResource resource,
Multimap<CmsResource, CmsResource> childMap,
Set<CmsResource> filterMatches,
Set<String> parentPaths,
boolean isRoot)
throws CmsException {
CmsObject cms = getCmsObject();
String title = cms.readPropertyObject(resource, CmsPropertyDefinition.PROPERTY_TITLE, false).getValue();
boolean isMatch = filterMatches.contains(resource);
List<CmsVfsEntryBean> childBeans = Lists.newArrayList();
Collection<CmsResource> children = childMap.get(resource);
if (!children.isEmpty()) {
for (CmsResource child : children) {
CmsVfsEntryBean childBean = buildVfsEntryBeanForQuickSearch(
child,
childMap,
filterMatches,
parentPaths,
false);
childBeans.add(childBean);
}
} else if (filterMatches.contains(resource)) {
if (parentPaths.contains(resource.getRootPath())) {
childBeans = null;
}
// otherwise childBeans remains an empty list
}
String rootPath = resource.getRootPath();
CmsVfsEntryBean result = new CmsVfsEntryBean(
rootPath,
resource.getStructureId(),
title,
CmsIconUtil.getIconClasses(CmsIconUtil.getDisplayType(cms, resource), resource.getName(), true),
isRoot,
isEditable(cms, resource),
childBeans,
isMatch);
String siteRoot = null;
if (OpenCms.getSiteManager().startsWithShared(rootPath)) {
siteRoot = OpenCms.getSiteManager().getSharedFolder();
} else {
String tempSiteRoot = OpenCms.getSiteManager().getSiteRoot(rootPath);
if (tempSiteRoot != null) {
siteRoot = tempSiteRoot;
} else {
siteRoot = "";
}
}
result.setSiteRoot(siteRoot);
return result;
} | java |
protected void doPurge(Runnable afterPurgeAction) {
if (LOG.isInfoEnabled()) {
LOG.info(
org.opencms.flex.Messages.get().getBundle().key(
org.opencms.flex.Messages.LOG_FLEXCACHE_WILL_PURGE_JSP_REPOSITORY_0));
}
File d;
d = new File(getJspRepository() + CmsFlexCache.REPOSITORY_ONLINE + File.separator);
CmsFileUtil.purgeDirectory(d);
d = new File(getJspRepository() + CmsFlexCache.REPOSITORY_OFFLINE + File.separator);
CmsFileUtil.purgeDirectory(d);
if (afterPurgeAction != null) {
afterPurgeAction.run();
}
if (LOG.isInfoEnabled()) {
LOG.info(
org.opencms.flex.Messages.get().getBundle().key(
org.opencms.flex.Messages.LOG_FLEXCACHE_PURGED_JSP_REPOSITORY_0));
}
} | java |
private void wrongUsage() {
String usage = "Usage: java -cp $PATH_TO_OPENCMS_JAR org.opencms.rmi.CmsRemoteShellClient\n"
+ " -script=[path to script] (optional) \n"
+ " -registryPort=[port of RMI registry] (optional, default is "
+ CmsRemoteShellConstants.DEFAULT_PORT
+ ")\n"
+ " -additional=[additional commands class name] (optional)";
System.out.println(usage);
System.exit(1);
} | java |
public void setAddContentInfo(final Boolean doAddInfo) {
if ((null != doAddInfo) && doAddInfo.booleanValue() && (null != m_addContentInfoForEntries)) {
m_addContentInfoForEntries = Integer.valueOf(DEFAULT_CONTENTINFO_ROWS);
}
} | java |
public void setFileFormat(String fileFormat) {
if (fileFormat.toUpperCase().equals(FileFormat.JSON.toString())) {
m_fileFormat = FileFormat.JSON;
}
} | java |
private void addContentInfo() {
if (!m_cms.getRequestContext().getCurrentProject().isOnlineProject()
&& (null == m_searchController.getCommon().getConfig().getSolrIndex())
&& (null != m_addContentInfoForEntries)) {
CmsSolrQuery query = new CmsSolrQuery();
m_searchController.addQueryParts(query, m_cms);
query.setStart(Integer.valueOf(0));
query.setRows(m_addContentInfoForEntries);
CmsContentLoadCollectorInfo info = new CmsContentLoadCollectorInfo();
info.setCollectorClass(this.getClass().getName());
info.setCollectorParams(query.getQuery());
info.setId((new CmsUUID()).getStringValue());
if (CmsJspTagEditable.getDirectEditProvider(pageContext) != null) {
try {
CmsJspTagEditable.getDirectEditProvider(pageContext).insertDirectEditListMetadata(
pageContext,
info);
} catch (JspException e) {
LOG.error("Could not write content info.", e);
}
}
}
} | java |
private I_CmsSearchResultWrapper getSearchResults() {
// The second parameter is just ignored - so it does not matter
m_searchController.updateFromRequestParameters(pageContext.getRequest().getParameterMap(), false);
I_CmsSearchControllerCommon common = m_searchController.getCommon();
// Do not search for empty query, if configured
if (common.getState().getQuery().isEmpty()
&& (!common.getConfig().getIgnoreQueryParam() && !common.getConfig().getSearchForEmptyQueryParam())) {
return new CmsSearchResultWrapper(m_searchController, null, null, m_cms, null);
}
Map<String, String[]> queryParams = null;
boolean isEditMode = CmsJspTagEditable.isEditableRequest(pageContext.getRequest());
if (isEditMode) {
String params = "";
if (common.getConfig().getIgnoreReleaseDate()) {
params += "&fq=released:[* TO *]";
}
if (common.getConfig().getIgnoreExpirationDate()) {
params += "&fq=expired:[* TO *]";
}
if (!params.isEmpty()) {
queryParams = CmsRequestUtil.createParameterMap(params.substring(1));
}
}
CmsSolrQuery query = new CmsSolrQuery(null, queryParams);
m_searchController.addQueryParts(query, m_cms);
try {
// use "complicated" constructor to allow more than 50 results -> set ignoreMaxResults to true
// also set resource filter to allow for returning unreleased/expired resources if necessary.
CmsSolrResultList solrResultList = m_index.search(
m_cms,
query.clone(), // use a clone of the query, since the search function manipulates the query (removes highlighting parts), but we want to keep the original one.
true,
isEditMode ? CmsResourceFilter.IGNORE_EXPIRATION : null);
return new CmsSearchResultWrapper(m_searchController, solrResultList, query, m_cms, null);
} catch (CmsSearchException e) {
LOG.warn(Messages.get().getBundle().key(Messages.LOG_TAG_SEARCH_SEARCH_FAILED_0), e);
return new CmsSearchResultWrapper(m_searchController, null, query, m_cms, e);
}
} | java |
public Date toDate(Object date) {
Date d = null;
if (null != date) {
if (date instanceof Date) {
d = (Date)date;
} else if (date instanceof Long) {
d = new Date(((Long)date).longValue());
} else {
try {
long l = Long.parseLong(date.toString());
d = new Date(l);
} catch (Exception e) {
// do nothing, just let d remain null
}
}
}
return d;
} | java |
public synchronized void stop() {
if (m_thread != null) {
long timeBeforeShutdownWasCalled = System.currentTimeMillis();
JLANServer.shutdownServer(new String[] {});
while (m_thread.isAlive()
&& ((System.currentTimeMillis() - timeBeforeShutdownWasCalled) < MAX_SHUTDOWN_WAIT_MILLIS)) {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
// ignore
}
}
}
} | java |
public boolean needToSetCategoryFolder() {
if (m_adeModuleVersion == null) {
return true;
}
CmsModuleVersion categoryFolderUpdateVersion = new CmsModuleVersion("9.0.0");
return (m_adeModuleVersion.compareTo(categoryFolderUpdateVersion) == -1);
} | java |
public void setWeekDays(SortedSet<WeekDay> weekDays) {
final SortedSet<WeekDay> newWeekDays = null == weekDays ? new TreeSet<WeekDay>() : weekDays;
SortedSet<WeekDay> currentWeekDays = m_model.getWeekDays();
if (!currentWeekDays.equals(newWeekDays)) {
conditionallyRemoveExceptionsOnChange(new Command() {
public void execute() {
m_model.setWeekDays(newWeekDays);
onValueChange();
}
}, !newWeekDays.containsAll(m_model.getWeekDays()));
}
} | java |
protected void switchTab() {
Component tab = m_tab.getSelectedTab();
int pos = m_tab.getTabPosition(m_tab.getTab(tab));
if (m_isWebOU) {
if (pos == 0) {
pos = 1;
}
}
m_tab.setSelectedTab(pos + 1);
} | java |
protected void onEditTitleTextBox(TextBox box) {
if (m_titleEditHandler != null) {
m_titleEditHandler.handleEdit(m_title, box);
return;
}
String text = box.getText();
box.removeFromParent();
m_title.setText(text);
m_title.setVisible(true);
} | java |
public void setPatternScheme(final boolean isByWeekDay, final boolean fireChange) {
if (isByWeekDay ^ (null != m_model.getWeekDay())) {
removeExceptionsOnChange(new Command() {
public void execute() {
if (isByWeekDay) {
m_model.setWeekOfMonth(getPatternDefaultValues().getWeekOfMonth());
m_model.setWeekDay(getPatternDefaultValues().getWeekDay());
} else {
m_model.clearWeekDays();
m_model.clearWeeksOfMonth();
m_model.setDayOfMonth(getPatternDefaultValues().getDayOfMonth());
}
m_model.setInterval(getPatternDefaultValues().getInterval());
if (fireChange) {
onValueChange();
}
}
});
}
} | java |
public void setWeekDay(String dayString) {
final WeekDay day = WeekDay.valueOf(dayString);
if (m_model.getWeekDay() != day) {
removeExceptionsOnChange(new Command() {
public void execute() {
m_model.setWeekDay(day);
onValueChange();
}
});
}
} | java |
public void weeksChange(String week, Boolean value) {
final WeekOfMonth changedWeek = WeekOfMonth.valueOf(week);
boolean newValue = (null != value) && value.booleanValue();
boolean currentValue = m_model.getWeeksOfMonth().contains(changedWeek);
if (newValue != currentValue) {
if (newValue) {
setPatternScheme(true, false);
m_model.addWeekOfMonth(changedWeek);
onValueChange();
} else {
removeExceptionsOnChange(new Command() {
public void execute() {
m_model.removeWeekOfMonth(changedWeek);
onValueChange();
}
});
}
}
} | java |
public void validateAliases(
final CmsUUID uuid,
final Map<String, String> aliasPaths,
final AsyncCallback<Map<String, String>> callback) {
CmsRpcAction<Map<String, String>> action = new CmsRpcAction<Map<String, String>>() {
/**
* @see org.opencms.gwt.client.rpc.CmsRpcAction#execute()
*/
@Override
public void execute() {
start(200, true);
CmsCoreProvider.getVfsService().validateAliases(uuid, aliasPaths, this);
}
/**
* @see org.opencms.gwt.client.rpc.CmsRpcAction#onResponse(java.lang.Object)
*/
@Override
protected void onResponse(Map<String, String> result) {
stop(false);
callback.onSuccess(result);
}
};
action.execute();
} | java |
void setDayOfMonth(String day) {
final int i = CmsSerialDateUtil.toIntWithDefault(day, -1);
if (m_model.getDayOfMonth() != i) {
removeExceptionsOnChange(new Command() {
public void execute() {
m_model.setDayOfMonth(i);
onValueChange();
}
});
}
} | java |
private String convertOutputToHtml(String content) {
if (content.length() == 0) {
return "";
}
StringBuilder buffer = new StringBuilder();
for (String line : content.split("\n")) {
buffer.append(CmsEncoder.escapeXml(line) + "<br>");
}
return buffer.toString();
} | java |
private void writeToDelegate(byte[] data) {
if (m_delegateStream != null) {
try {
m_delegateStream.write(data);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
} | java |
public static String getStatusForItem(Long lastActivity) {
if (lastActivity.longValue() < CmsSessionsTable.INACTIVE_LIMIT) {
return CmsVaadinUtils.getMessageText(Messages.GUI_MESSAGES_BROADCAST_COLS_STATUS_ACTIVE_0);
}
return CmsVaadinUtils.getMessageText(Messages.GUI_MESSAGES_BROADCAST_COLS_STATUS_INACTIVE_0);
} | java |
public static void showUserInfo(CmsSessionInfo session) {
final Window window = CmsBasicDialog.prepareWindow(DialogWidth.wide);
CmsUserInfoDialog dialog = new CmsUserInfoDialog(session, new Runnable() {
public void run() {
window.close();
}
});
window.setCaption(CmsVaadinUtils.getMessageText(Messages.GUI_MESSAGES_SHOW_USER_0));
window.setContent(dialog);
A_CmsUI.get().addWindow(window);
} | java |
@Override
public void onBrowserEvent(Event event) {
super.onBrowserEvent(event);
switch (DOM.eventGetType(event)) {
case Event.ONMOUSEUP:
Event.releaseCapture(m_slider.getElement());
m_capturedMouse = false;
break;
case Event.ONMOUSEDOWN:
Event.setCapture(m_slider.getElement());
m_capturedMouse = true;
//$FALL-THROUGH$
case Event.ONMOUSEMOVE:
if (m_capturedMouse) {
event.preventDefault();
float x = ((event.getClientX() - (m_colorUnderlay.getAbsoluteLeft())) + Window.getScrollLeft());
float y = ((event.getClientY() - (m_colorUnderlay.getAbsoluteTop())) + Window.getScrollTop());
if (m_parent != null) {
m_parent.onMapSelected(x, y);
}
setSliderPosition(x, y);
}
//$FALL-THROUGH$
default:
}
} | java |
private void addChildrenForGroupsNode(I_CmsOuTreeType type, String ouItem) {
try {
// Cut of type-specific prefix from ouItem with substring()
List<CmsGroup> groups = m_app.readGroupsForOu(m_cms, ouItem.substring(1), type, false);
for (CmsGroup group : groups) {
Pair<String, CmsUUID> key = Pair.of(type.getId(), group.getId());
Item groupItem = m_treeContainer.addItem(key);
if (groupItem == null) {
groupItem = getItem(key);
}
groupItem.getItemProperty(PROP_SID).setValue(group.getId());
groupItem.getItemProperty(PROP_NAME).setValue(getIconCaptionHTML(group, CmsOuTreeType.GROUP));
groupItem.getItemProperty(PROP_TYPE).setValue(type);
setChildrenAllowed(key, false);
m_treeContainer.setParent(key, ouItem);
}
} catch (CmsException e) {
LOG.error("Can not read group", e);
}
} | java |
private void addChildrenForRolesNode(String ouItem) {
try {
List<CmsRole> roles = OpenCms.getRoleManager().getRoles(m_cms, ouItem.substring(1), false);
CmsRole.applySystemRoleOrder(roles);
for (CmsRole role : roles) {
String roleId = ouItem + "/" + role.getId();
Item roleItem = m_treeContainer.addItem(roleId);
if (roleItem == null) {
roleItem = getItem(roleId);
}
roleItem.getItemProperty(PROP_NAME).setValue(getIconCaptionHTML(role, CmsOuTreeType.ROLE));
roleItem.getItemProperty(PROP_TYPE).setValue(CmsOuTreeType.ROLE);
setChildrenAllowed(roleId, false);
m_treeContainer.setParent(roleId, ouItem);
}
} catch (CmsException e) {
LOG.error("Can not read group", e);
}
} | java |
public static boolean checkConfiguredInModules() {
Boolean result = m_moduleCheckCache.get();
if (result == null) {
result = Boolean.valueOf(getConfiguredTemplateMapping() != null);
m_moduleCheckCache.set(result);
}
return result.booleanValue();
} | java |
@SuppressWarnings("unused")
public static void addTo(
AbstractSingleComponentContainer componentContainer,
int scrollBarrier,
int barrierMargin,
String styleName) {
new CmsScrollPositionCss(componentContainer, scrollBarrier, barrierMargin, styleName);
} | java |
protected boolean checkvalue(String colorvalue) {
boolean valid = validateColorValue(colorvalue);
if (valid) {
if (colorvalue.length() == 4) {
char[] chr = colorvalue.toCharArray();
for (int i = 1; i < 4; i++) {
String foo = String.valueOf(chr[i]);
colorvalue = colorvalue.replaceFirst(foo, foo + foo);
}
}
m_textboxColorValue.setValue(colorvalue, true);
m_colorField.getElement().getStyle().setBackgroundColor(colorvalue);
m_colorValue = colorvalue;
}
return valid;
} | java |
protected AllowableActions collectAllowableActions(CmsObject cms, CmsResource file) {
try {
if (file == null) {
throw new IllegalArgumentException("File must not be null!");
}
CmsLock lock = cms.getLock(file);
CmsUser user = cms.getRequestContext().getCurrentUser();
boolean canWrite = !cms.getRequestContext().getCurrentProject().isOnlineProject()
&& (lock.isOwnedBy(user) || lock.isLockableBy(user))
&& cms.hasPermissions(file, CmsPermissionSet.ACCESS_WRITE, false, CmsResourceFilter.DEFAULT);
boolean isReadOnly = !canWrite;
boolean isFolder = file.isFolder();
boolean isRoot = file.getRootPath().length() <= 1;
Set<Action> aas = new LinkedHashSet<Action>();
addAction(aas, Action.CAN_GET_OBJECT_PARENTS, !isRoot);
addAction(aas, Action.CAN_GET_PROPERTIES, true);
addAction(aas, Action.CAN_UPDATE_PROPERTIES, !isReadOnly);
addAction(aas, Action.CAN_MOVE_OBJECT, !isReadOnly && !isRoot);
addAction(aas, Action.CAN_DELETE_OBJECT, !isReadOnly && !isRoot);
if (isFolder) {
addAction(aas, Action.CAN_GET_DESCENDANTS, true);
addAction(aas, Action.CAN_GET_CHILDREN, true);
addAction(aas, Action.CAN_GET_FOLDER_PARENT, !isRoot);
addAction(aas, Action.CAN_GET_FOLDER_TREE, true);
addAction(aas, Action.CAN_CREATE_DOCUMENT, !isReadOnly);
addAction(aas, Action.CAN_CREATE_FOLDER, !isReadOnly);
addAction(aas, Action.CAN_DELETE_TREE, !isReadOnly);
} else {
addAction(aas, Action.CAN_GET_CONTENT_STREAM, true);
addAction(aas, Action.CAN_SET_CONTENT_STREAM, !isReadOnly);
addAction(aas, Action.CAN_GET_ALL_VERSIONS, true);
}
AllowableActionsImpl result = new AllowableActionsImpl();
result.setAllowableActions(aas);
return result;
} catch (CmsException e) {
handleCmsException(e);
return null;
}
} | java |
public static String getStatusText(int nHttpStatusCode) {
Integer intKey = new Integer(nHttpStatusCode);
if (!mapStatusCodes.containsKey(intKey)) {
return "";
} else {
return mapStatusCodes.get(intKey);
}
} | java |
private boolean addType(TypeDefinition type) {
if (type == null) {
return false;
}
if (type.getBaseTypeId() == null) {
return false;
}
// find base type
TypeDefinition baseType = null;
if (type.getBaseTypeId() == BaseTypeId.CMIS_DOCUMENT) {
baseType = copyTypeDefintion(m_types.get(DOCUMENT_TYPE_ID).getTypeDefinition());
} else if (type.getBaseTypeId() == BaseTypeId.CMIS_FOLDER) {
baseType = copyTypeDefintion(m_types.get(FOLDER_TYPE_ID).getTypeDefinition());
} else if (type.getBaseTypeId() == BaseTypeId.CMIS_RELATIONSHIP) {
baseType = copyTypeDefintion(m_types.get(RELATIONSHIP_TYPE_ID).getTypeDefinition());
} else if (type.getBaseTypeId() == BaseTypeId.CMIS_POLICY) {
baseType = copyTypeDefintion(m_types.get(POLICY_TYPE_ID).getTypeDefinition());
} else {
return false;
}
AbstractTypeDefinition newType = (AbstractTypeDefinition)copyTypeDefintion(type);
// copy property definition
for (PropertyDefinition<?> propDef : baseType.getPropertyDefinitions().values()) {
((AbstractPropertyDefinition<?>)propDef).setIsInherited(Boolean.TRUE);
newType.addPropertyDefinition(propDef);
}
// add it
addTypeInternal(newType);
return true;
} | java |
public String buildRadio(String propName) throws CmsException {
String propVal = readProperty(propName);
StringBuffer result = new StringBuffer("<table border=\"0\"><tr>");
result.append("<td><input type=\"radio\" value=\"true\" onClick=\"checkNoIntern()\" name=\"").append(
propName).append("\" ").append(Boolean.valueOf(propVal).booleanValue() ? "checked=\"checked\"" : "").append(
"/></td><td id=\"tablelabel\">").append(key(Messages.GUI_LABEL_TRUE_0)).append("</td>");
result.append("<td><input type=\"radio\" value=\"false\" onClick=\"checkNoIntern()\" name=\"").append(
propName).append("\" ").append(Boolean.valueOf(propVal).booleanValue() ? "" : "checked=\"checked\"").append(
"/></td><td id=\"tablelabel\">").append(key(Messages.GUI_LABEL_FALSE_0)).append("</td>");
result.append("<td><input type=\"radio\" value=\"\" onClick=\"checkNoIntern()\" name=\"").append(
propName).append("\" ").append(CmsStringUtil.isEmpty(propVal) ? "checked=\"checked\"" : "").append(
"/></td><td id=\"tablelabel\">").append(getPropertyInheritanceInfo(propName)).append(
"</td></tr></table>");
return result.toString();
} | java |
public void setCategoryDisplayOptions(
String displayCategoriesByRepository,
String displayCategorySelectionCollapsed) {
m_displayCategoriesByRepository = Boolean.parseBoolean(displayCategoriesByRepository);
m_displayCategorySelectionCollapsed = Boolean.parseBoolean(displayCategorySelectionCollapsed);
} | java |
protected boolean showMoreEntries(Calendar nextDate, int previousOccurrences) {
switch (getSerialEndType()) {
case DATE:
boolean moreByDate = nextDate.getTimeInMillis() < m_endMillis;
boolean moreByOccurrences = previousOccurrences < CmsSerialDateUtil.getMaxEvents();
if (moreByDate && !moreByOccurrences) {
m_hasTooManyOccurrences = Boolean.TRUE;
}
return moreByDate && moreByOccurrences;
case TIMES:
case SINGLE:
return previousOccurrences < getOccurrences();
default:
throw new IllegalArgumentException();
}
} | java |
private SortedSet<Date> calculateDates() {
if (null == m_allDates) {
SortedSet<Date> result = new TreeSet<>();
if (isAnyDatePossible()) {
Calendar date = getFirstDate();
int previousOccurrences = 0;
while (showMoreEntries(date, previousOccurrences)) {
result.add(date.getTime());
toNextDate(date);
previousOccurrences++;
}
}
m_allDates = result;
}
return m_allDates;
} | java |
private SortedSet<Date> filterExceptions(SortedSet<Date> dates) {
SortedSet<Date> result = new TreeSet<Date>();
for (Date d : dates) {
if (!m_exceptions.contains(d)) {
result.add(d);
}
}
return result;
} | java |
private void setHeaderList(Map<String, List<String>> headers, String name, String value) {
List<String> values = new ArrayList<String>();
values.add(SET_HEADER + value);
headers.put(name, values);
} | java |
public static String changeFileNameSuffixTo(String filename, String suffix) {
int dotPos = filename.lastIndexOf('.');
if (dotPos != -1) {
return filename.substring(0, dotPos + 1) + suffix;
} else {
// the string has no suffix
return filename;
}
} | java |
public static final long parseDuration(String durationStr, long defaultValue) {
durationStr = durationStr.toLowerCase().trim();
Matcher matcher = DURATION_NUMBER_AND_UNIT_PATTERN.matcher(durationStr);
long millis = 0;
boolean matched = false;
while (matcher.find()) {
long number = Long.valueOf(matcher.group(1)).longValue();
String unit = matcher.group(2);
long multiplier = 0;
for (int j = 0; j < DURATION_UNTIS.length; j++) {
if (unit.equals(DURATION_UNTIS[j])) {
multiplier = DURATION_MULTIPLIERS[j];
break;
}
}
if (multiplier == 0) {
LOG.warn("parseDuration: Unknown unit " + unit);
} else {
matched = true;
}
millis += number * multiplier;
}
if (!matched) {
millis = defaultValue;
}
return millis;
} | java |
public static StringTemplateGroup readStringTemplateGroup(InputStream stream) {
try {
return new StringTemplateGroup(
new InputStreamReader(stream, "UTF-8"),
DefaultTemplateLexer.class,
new StringTemplateErrorListener() {
@SuppressWarnings("synthetic-access")
public void error(String arg0, Throwable arg1) {
LOG.error(arg0 + ": " + arg1.getMessage(), arg1);
}
@SuppressWarnings("synthetic-access")
public void warning(String arg0) {
LOG.warn(arg0);
}
});
} catch (Exception e) {
LOG.error(e.getLocalizedMessage(), e);
return new StringTemplateGroup("dummy");
}
} | java |
public static void fire(I_CmsHasDateBoxEventHandlers source, Date date, boolean isTyping) {
if (TYPE != null) {
CmsDateBoxEvent event = new CmsDateBoxEvent(date, isTyping);
source.fireEvent(event);
}
} | java |
protected CmsProject createAndSetModuleImportProject(CmsObject cms, CmsModule module) throws CmsException {
CmsProject importProject = cms.createProject(
org.opencms.module.Messages.get().getBundle(cms.getRequestContext().getLocale()).key(
org.opencms.module.Messages.GUI_IMPORT_MODULE_PROJECT_NAME_1,
new Object[] {module.getName()}),
org.opencms.module.Messages.get().getBundle(cms.getRequestContext().getLocale()).key(
org.opencms.module.Messages.GUI_IMPORT_MODULE_PROJECT_DESC_1,
new Object[] {module.getName()}),
OpenCms.getDefaultUsers().getGroupAdministrators(),
OpenCms.getDefaultUsers().getGroupAdministrators(),
CmsProject.PROJECT_TYPE_TEMPORARY);
cms.getRequestContext().setCurrentProject(importProject);
cms.copyResourceToProject("/");
return importProject;
} | java |
protected void deleteConflictingResources(CmsObject cms, CmsModule module, Map<CmsUUID, CmsUUID> conflictingIds)
throws CmsException, Exception {
CmsProject conflictProject = cms.createProject(
"Deletion of conflicting resources for " + module.getName(),
"Deletion of conflicting resources for " + module.getName(),
OpenCms.getDefaultUsers().getGroupAdministrators(),
OpenCms.getDefaultUsers().getGroupAdministrators(),
CmsProject.PROJECT_TYPE_TEMPORARY);
CmsObject deleteCms = OpenCms.initCmsObject(cms);
deleteCms.getRequestContext().setCurrentProject(conflictProject);
for (CmsUUID vfsId : conflictingIds.values()) {
CmsResource toDelete = deleteCms.readResource(vfsId, CmsResourceFilter.ALL);
lock(deleteCms, toDelete);
deleteCms.deleteResource(toDelete, CmsResource.DELETE_PRESERVE_SIBLINGS);
}
OpenCms.getPublishManager().publishProject(deleteCms);
OpenCms.getPublishManager().waitWhileRunning();
} | java |
protected void parseLinks(CmsObject cms) throws CmsException {
List<CmsResource> linkParseables = new ArrayList<>();
for (CmsResourceImportData resData : m_moduleData.getResourceData()) {
CmsResource importRes = resData.getImportResource();
if ((importRes != null) && m_importIds.contains(importRes.getStructureId()) && isLinkParsable(importRes)) {
linkParseables.add(importRes);
}
}
m_report.println(Messages.get().container(Messages.RPT_START_PARSE_LINKS_0), I_CmsReport.FORMAT_HEADLINE);
CmsImportVersion10.parseLinks(cms, linkParseables, m_report);
m_report.println(Messages.get().container(Messages.RPT_END_PARSE_LINKS_0), I_CmsReport.FORMAT_HEADLINE);
} | java |
protected void processDeletions(CmsObject cms, List<CmsResource> toDelete) throws CmsException {
Collections.sort(toDelete, (a, b) -> b.getRootPath().compareTo(a.getRootPath()));
for (CmsResource deleteRes : toDelete) {
m_report.print(
org.opencms.importexport.Messages.get().container(org.opencms.importexport.Messages.RPT_DELFOLDER_0),
I_CmsReport.FORMAT_NOTE);
m_report.print(
org.opencms.report.Messages.get().container(
org.opencms.report.Messages.RPT_ARGUMENT_1,
deleteRes.getRootPath()));
CmsLock lock = cms.getLock(deleteRes);
if (lock.isUnlocked()) {
lock(cms, deleteRes);
}
cms.deleteResource(deleteRes, CmsResource.DELETE_PRESERVE_SIBLINGS);
m_report.println(
org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_OK_0),
I_CmsReport.FORMAT_OK);
}
} | java |
protected void runImportScript(CmsObject cms, CmsModule module) {
LOG.info("Executing import script for module " + module.getName());
m_report.println(
org.opencms.module.Messages.get().container(org.opencms.module.Messages.RPT_IMPORT_SCRIPT_HEADER_0),
I_CmsReport.FORMAT_HEADLINE);
String importScript = "echo on\n" + module.getImportScript();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
PrintStream out = new PrintStream(buffer);
CmsShell shell = new CmsShell(cms, "${user}@${project}:${siteroot}|${uri}>", null, out, out);
shell.execute(importScript);
String outputString = buffer.toString();
LOG.info("Shell output for import script was: \n" + outputString);
m_report.println(
org.opencms.module.Messages.get().container(
org.opencms.module.Messages.RPT_IMPORT_SCRIPT_OUTPUT_1,
outputString));
} | java |
public Map<String, List<Locale>> getAvailableLocales() {
if (m_availableLocales == null) {
// create lazy map only on demand
m_availableLocales = CmsCollectionsGenericWrapper.createLazyMap(new CmsAvailableLocaleLoaderTransformer());
}
return m_availableLocales;
} | java |
private static CmsObject adjustSiteRootIfNecessary(final CmsObject cms, final CmsModule module)
throws CmsException {
CmsObject cmsClone;
if ((null == module.getSite()) || cms.getRequestContext().getSiteRoot().equals(module.getSite())) {
cmsClone = cms;
} else {
cmsClone = OpenCms.initCmsObject(cms);
cmsClone.getRequestContext().setSiteRoot(module.getSite());
}
return cmsClone;
} | java |
public boolean shouldIncrementVersionBasedOnResources(CmsObject cms) throws CmsException {
if (m_checkpointTime == 0) {
return true;
}
// adjust the site root, if necessary
CmsObject cmsClone = adjustSiteRootIfNecessary(cms, this);
// calculate the module resources
List<CmsResource> moduleResources = calculateModuleResources(cmsClone, this);
for (CmsResource resource : moduleResources) {
try {
List<CmsResource> resourcesToCheck = Lists.newArrayList();
resourcesToCheck.add(resource);
if (resource.isFolder()) {
resourcesToCheck.addAll(cms.readResources(resource, CmsResourceFilter.IGNORE_EXPIRATION, true));
}
for (CmsResource resourceToCheck : resourcesToCheck) {
if (resourceToCheck.getDateLastModified() > m_checkpointTime) {
return true;
}
}
} catch (CmsException e) {
LOG.warn(e.getLocalizedMessage(), e);
continue;
}
}
return false;
} | java |
public Class<?> getColumnType(int c) {
for (int r = 0; r < m_data.size(); r++) {
Object val = m_data.get(r).get(c);
if (val != null) {
return val.getClass();
}
}
return Object.class;
} | java |
public String getCsv() {
StringWriter writer = new StringWriter();
try (CSVWriter csv = new CSVWriter(writer)) {
List<String> headers = new ArrayList<>();
for (String col : m_columns) {
headers.add(col);
}
csv.writeNext(headers.toArray(new String[] {}));
for (List<Object> row : m_data) {
List<String> colCsv = new ArrayList<>();
for (Object col : row) {
colCsv.add(String.valueOf(col));
}
csv.writeNext(colCsv.toArray(new String[] {}));
}
return writer.toString();
} catch (IOException e) {
return null;
}
} | java |
protected String getBasePath(String rootPath) {
if (rootPath.endsWith(INHERITANCE_CONFIG_FILE_NAME)) {
return rootPath.substring(0, rootPath.length() - INHERITANCE_CONFIG_FILE_NAME.length());
}
return rootPath;
} | java |
public static String getStringOption(Map<String, String> configOptions, String optionKey, String defaultValue) {
String result = configOptions.get(optionKey);
return null != result ? result : defaultValue;
} | java |
private String generateValue() {
String result = "";
for (CmsCheckBox checkbox : m_checkboxes) {
if (checkbox.isChecked()) {
result += checkbox.getInternalValue() + ",";
}
}
if (result.contains(",")) {
result = result.substring(0, result.lastIndexOf(","));
}
return result;
} | java |
protected void runQuery() {
String pool = m_pool.getValue();
String stmt = m_script.getValue();
if (stmt.trim().isEmpty()) {
return;
}
CmsStringBufferReport report = new CmsStringBufferReport(Locale.ENGLISH);
List<Throwable> errors = new ArrayList<>();
CmsSqlConsoleResults result = m_console.execute(stmt, pool, report, errors);
if (errors.size() > 0) {
CmsErrorDialog.showErrorDialog(report.toString() + errors.get(0).getMessage(), errors.get(0));
} else {
Window window = CmsBasicDialog.prepareWindow(DialogWidth.max);
window.setCaption(CmsVaadinUtils.getMessageText(Messages.GUI_SQLCONSOLE_QUERY_RESULTS_0));
window.setContent(new CmsSqlConsoleResultsForm(result, report.toString()));
A_CmsUI.get().addWindow(window);
window.center();
}
} | java |
public static Resource getSetupPage(I_SetupUiContext context, String name) {
String path = CmsStringUtil.joinPaths(context.getSetupBean().getContextPath(), CmsSetupBean.FOLDER_SETUP, name);
Resource resource = new ExternalResource(path);
return resource;
} | java |
protected void showStep(A_CmsSetupStep step) {
Window window = newWindow();
window.setContent(step);
window.setCaption(step.getTitle());
A_CmsUI.get().addWindow(window);
window.center();
} | java |
protected void updateStep(int stepNo) {
if ((0 <= stepNo) && (stepNo < m_steps.size())) {
Class<? extends A_CmsSetupStep> cls = m_steps.get(stepNo);
A_CmsSetupStep step;
try {
step = cls.getConstructor(I_SetupUiContext.class).newInstance(this);
showStep(step);
m_stepNo = stepNo; // Only update step number if no exceptions
} catch (Exception e) {
CmsSetupErrorDialog.showErrorDialog(e);
}
}
} | java |
protected void appendFacetOption(StringBuffer query, final String name, final String value) {
query.append(" facet.").append(name).append("=").append(value);
} | java |
public void setEditedFilePath(final String editedFilePath) {
m_filePathField.setReadOnly(false);
m_filePathField.setValue(editedFilePath);
m_filePathField.setReadOnly(true);
} | java |
public void updateShownOptions(boolean showModeSwitch, boolean showAddKeyOption) {
if (showModeSwitch != m_showModeSwitch) {
m_upperLeftComponent.removeAllComponents();
m_upperLeftComponent.addComponent(m_languageSwitch);
if (showModeSwitch) {
m_upperLeftComponent.addComponent(m_modeSwitch);
}
m_upperLeftComponent.addComponent(m_filePathLabel);
m_showModeSwitch = showModeSwitch;
}
if (showAddKeyOption != m_showAddKeyOption) {
if (showAddKeyOption) {
m_optionsComponent.addComponent(m_lowerLeftComponent, 0, 1);
m_optionsComponent.addComponent(m_lowerRightComponent, 1, 1);
} else {
m_optionsComponent.removeComponent(0, 1);
m_optionsComponent.removeComponent(1, 1);
}
m_showAddKeyOption = showAddKeyOption;
}
} | java |
void handleAddKey() {
String key = m_addKeyInput.getValue();
if (m_listener.handleAddKey(key)) {
Notification.show(
key.isEmpty()
? m_messages.key(Messages.GUI_NOTIFICATION_MESSAGEBUNDLEEDITOR_EMPTY_KEY_SUCCESSFULLY_ADDED_0)
: m_messages.key(Messages.GUI_NOTIFICATION_MESSAGEBUNDLEEDITOR_KEY_SUCCESSFULLY_ADDED_1, key));
} else {
CmsMessageBundleEditorTypes.showWarning(
m_messages.key(Messages.GUI_NOTIFICATION_MESSAGEBUNDLEEDITOR_KEY_ALREADEY_EXISTS_CAPTION_0),
m_messages.key(Messages.GUI_NOTIFICATION_MESSAGEBUNDLEEDITOR_KEY_ALREADEY_EXISTS_DESCRIPTION_1, key));
}
m_addKeyInput.focus();
m_addKeyInput.selectAll();
} | java |
void setLanguage(final Locale locale) {
if (!m_languageSelect.getValue().equals(locale)) {
m_languageSelect.setValue(locale);
}
} | java |
private Component createAddKeyButton() {
// the "+" button
Button addKeyButton = new Button();
addKeyButton.addStyleName("icon-only");
addKeyButton.addStyleName("borderless-colored");
addKeyButton.setDescription(m_messages.key(Messages.GUI_ADD_KEY_0));
addKeyButton.setIcon(FontOpenCms.CIRCLE_PLUS, m_messages.key(Messages.GUI_ADD_KEY_0));
addKeyButton.addClickListener(new ClickListener() {
private static final long serialVersionUID = 1L;
public void buttonClick(ClickEvent event) {
handleAddKey();
}
});
return addKeyButton;
} | java |
private void initModeSwitch(final EditMode current) {
FormLayout modes = new FormLayout();
modes.setHeight("100%");
modes.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
m_modeSelect = new ComboBox();
m_modeSelect.setCaption(m_messages.key(Messages.GUI_VIEW_SWITCHER_LABEL_0));
// add Modes
m_modeSelect.addItem(CmsMessageBundleEditorTypes.EditMode.DEFAULT);
m_modeSelect.setItemCaption(
CmsMessageBundleEditorTypes.EditMode.DEFAULT,
m_messages.key(Messages.GUI_VIEW_SWITCHER_EDITMODE_DEFAULT_0));
m_modeSelect.addItem(CmsMessageBundleEditorTypes.EditMode.MASTER);
m_modeSelect.setItemCaption(
CmsMessageBundleEditorTypes.EditMode.MASTER,
m_messages.key(Messages.GUI_VIEW_SWITCHER_EDITMODE_MASTER_0));
// set current mode as selected
m_modeSelect.setValue(current);
m_modeSelect.setNewItemsAllowed(false);
m_modeSelect.setTextInputAllowed(false);
m_modeSelect.setNullSelectionAllowed(false);
m_modeSelect.addValueChangeListener(new ValueChangeListener() {
private static final long serialVersionUID = 1L;
public void valueChange(ValueChangeEvent event) {
m_listener.handleModeChange((EditMode)event.getProperty().getValue());
}
});
modes.addComponent(m_modeSelect);
m_modeSwitch = modes;
} | java |
private void initUpperLeftComponent() {
m_upperLeftComponent = new HorizontalLayout();
m_upperLeftComponent.setHeight("100%");
m_upperLeftComponent.setSpacing(true);
m_upperLeftComponent.setDefaultComponentAlignment(Alignment.MIDDLE_RIGHT);
m_upperLeftComponent.addComponent(m_languageSwitch);
m_upperLeftComponent.addComponent(m_filePathLabel);
} | java |
public CmsScheduledJobInfo getJob(String id) {
Iterator<CmsScheduledJobInfo> it = m_jobs.iterator();
while (it.hasNext()) {
CmsScheduledJobInfo job = it.next();
if (job.getId().equals(id)) {
return job;
}
}
// not found
return null;
} | java |
@UiHandler({"m_atMonth", "m_everyMonth"})
void onMonthChange(ValueChangeEvent<String> event) {
if (handleChange()) {
m_controller.setMonth(event.getValue());
}
} | java |
@UiHandler("m_atNumber")
void onWeekOfMonthChange(ValueChangeEvent<String> event) {
if (handleChange()) {
m_controller.setWeekOfMonth(event.getValue());
}
} | java |
public CmsResource buildResource() {
return new CmsResource(
m_structureId,
m_resourceId,
m_rootPath,
m_type,
m_flags,
m_projectLastModified,
m_state,
m_dateCreated,
m_userCreated,
m_dateLastModified,
m_userLastModified,
m_dateReleased,
m_dateExpired,
m_length,
m_flags,
m_dateContent,
m_version);
} | java |
public List<CmsProject> getAllAccessibleProjects(CmsObject cms, String ouFqn, boolean includeSubOus)
throws CmsException {
CmsOrganizationalUnit orgUnit = readOrganizationalUnit(cms, ouFqn);
return (m_securityManager.getAllAccessibleProjects(cms.getRequestContext(), orgUnit, includeSubOus));
} | java |
public CmsJspDateSeriesBean getToDateSeries() {
if (m_dateSeries == null) {
m_dateSeries = new CmsJspDateSeriesBean(this, m_cms.getRequestContext().getLocale());
}
return m_dateSeries;
} | java |
public void copyPageOnly(CmsResource originalPage, String targetPageRootPath)
throws CmsException, NoCustomReplacementException {
if ((null == originalPage)
|| !OpenCms.getResourceManager().getResourceType(originalPage).getTypeName().equals(
CmsResourceTypeXmlContainerPage.getStaticTypeName())) {
throw new CmsException(new CmsMessageContainer(Messages.get(), Messages.ERR_PAGECOPY_INVALID_PAGE_0));
}
m_originalPage = originalPage;
CmsObject rootCms = getRootCms();
rootCms.copyResource(originalPage.getRootPath(), targetPageRootPath);
CmsResource copiedPage = rootCms.readResource(targetPageRootPath, CmsResourceFilter.IGNORE_EXPIRATION);
m_targetFolder = rootCms.readResource(CmsResource.getFolderPath(copiedPage.getRootPath()));
replaceElements(copiedPage);
attachLocaleGroups(copiedPage);
tryUnlock(copiedPage);
} | java |
private void attachLocaleGroups(CmsResource copiedPage) throws CmsException {
CmsLocaleGroupService localeGroupService = getRootCms().getLocaleGroupService();
if (Status.linkable == localeGroupService.checkLinkable(m_originalPage, copiedPage)) {
try {
localeGroupService.attachLocaleGroupIndirect(m_originalPage, copiedPage);
} catch (CmsException e) {
LOG.error(e.getLocalizedMessage(), e);
}
}
} | java |
protected List<CmsUUID> undelete() throws CmsException {
List<CmsUUID> modifiedResources = new ArrayList<CmsUUID>();
CmsObject cms = m_context.getCms();
for (CmsResource resource : m_context.getResources()) {
CmsLockActionRecord actionRecord = null;
try {
actionRecord = CmsLockUtil.ensureLock(m_context.getCms(), resource);
cms.undeleteResource(cms.getSitePath(resource), true);
modifiedResources.add(resource.getStructureId());
} finally {
if ((actionRecord != null) && (actionRecord.getChange() == LockChange.locked)) {
try {
cms.unlockResource(resource);
} catch (CmsLockException e) {
LOG.warn(e.getLocalizedMessage(), e);
}
}
}
}
return modifiedResources;
} | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.