diff --git a/.gitattributes b/.gitattributes index 78a592374d5..96e0d2042b3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -51,39 +51,19 @@ announcements/src/org/labkey/announcements/respond.jsp -text announcements/src/org/labkey/announcements/rss.jsp -text announcements/src/org/labkey/announcements/SendMessageAction.java -text announcements/src/org/labkey/announcements/update.jsp -text -api/gwtsrc/org/labkey/api/gwt/client/assay/AssayException.java -text -api/gwtsrc/org/labkey/api/gwt/client/assay/model/GWTPropertyDescriptorMixin.java -text -api/gwtsrc/org/labkey/api/gwt/client/assay/model/GWTProtocol.java -text -api/gwtsrc/org/labkey/api/gwt/client/AuditBehaviorType.java -text -api/gwtsrc/org/labkey/api/gwt/client/DefaultScaleType.java -text -api/gwtsrc/org/labkey/api/gwt/client/DefaultValueType.java -text -api/gwtsrc/org/labkey/api/gwt/client/FacetingBehaviorType.java -text -api/gwtsrc/org/labkey/api/gwt/client/model/GWTConditionalFormat.java -text -api/gwtsrc/org/labkey/api/gwt/client/model/GWTContainer.java -text -api/gwtsrc/org/labkey/api/gwt/client/model/GWTDomain.java -text -api/gwtsrc/org/labkey/api/gwt/client/model/GWTIndex.java -text -api/gwtsrc/org/labkey/api/gwt/client/model/GWTPropertyDescriptor.java -text -api/gwtsrc/org/labkey/api/gwt/client/model/GWTPropertyValidator.java -text -api/gwtsrc/org/labkey/api/gwt/client/model/PropertyValidatorType.java -text -api/gwtsrc/org/labkey/api/gwt/client/ui/BoundTextBox.java -text -api/gwtsrc/org/labkey/api/gwt/client/ui/DirtyCallback.java -text -api/gwtsrc/org/labkey/api/gwt/client/ui/domain/CancellationException.java -text -api/gwtsrc/org/labkey/api/gwt/client/ui/HelpPopup.java -text -api/gwtsrc/org/labkey/api/gwt/client/ui/ImageButton.java -text -api/gwtsrc/org/labkey/api/gwt/client/ui/TextBoxDialogBox.java -text -api/gwtsrc/org/labkey/api/gwt/client/ui/WebPartPanel.java -text -api/gwtsrc/org/labkey/api/gwt/client/ui/WidgetUpdatable.java -text -api/gwtsrc/org/labkey/api/gwt/client/ui/WindowUtil.java -text -api/gwtsrc/org/labkey/api/gwt/client/util/BooleanProperty.java -text -api/gwtsrc/org/labkey/api/gwt/client/util/ColorGenerator.java -text -api/gwtsrc/org/labkey/api/gwt/client/util/ErrorDialogAsyncCallback.java -text -api/gwtsrc/org/labkey/api/gwt/client/util/IntegerProperty.java -text -api/gwtsrc/org/labkey/api/gwt/client/util/IPropertyWrapper.java -text -api/gwtsrc/org/labkey/api/gwt/client/util/PropertyUtil.java -text -api/gwtsrc/org/labkey/api/gwt/client/util/ServiceUtil.java -text -api/gwtsrc/org/labkey/api/gwt/client/util/StringProperty.java -text -api/gwtsrc/org/labkey/api/gwt/client/util/StringUtils.java -text -api/gwtsrc/org/labkey/api/gwt/Internal.gwt.xml -text +api/src/org/labkey/api/gwt/client/assay/model/GWTPropertyDescriptorMixin.java -text +api/src/org/labkey/api/gwt/client/assay/model/GWTProtocol.java -text +api/src/org/labkey/api/gwt/client/AuditBehaviorType.java -text +api/src/org/labkey/api/gwt/client/DefaultScaleType.java -text +api/src/org/labkey/api/gwt/client/DefaultValueType.java -text +api/src/org/labkey/api/gwt/client/FacetingBehaviorType.java -text +api/src/org/labkey/api/gwt/client/model/GWTConditionalFormat.java -text +api/src/org/labkey/api/gwt/client/model/GWTContainer.java -text +api/src/org/labkey/api/gwt/client/model/GWTDomain.java -text +api/src/org/labkey/api/gwt/client/model/GWTIndex.java -text +api/src/org/labkey/api/gwt/client/model/GWTPropertyDescriptor.java -text +api/src/org/labkey/api/gwt/client/model/GWTPropertyValidator.java -text +api/src/org/labkey/api/gwt/client/model/PropertyValidatorType.java -text api/module.properties -text api/schemas/apiTest.xsd -text api/schemas/clientLibrary.xsd -text @@ -1398,8 +1378,6 @@ api/src/org/labkey/api/view/DefaultModelAndView.java -text api/src/org/labkey/api/view/FolderManagement.java -text api/src/org/labkey/api/view/FolderTab.java -text api/src/org/labkey/api/view/ForbiddenProjectException.java -text -api/src/org/labkey/api/view/GWTView.java -text -api/src/org/labkey/api/view/GWTView.jsp -text api/src/org/labkey/api/view/JspTemplate.java -text api/src/org/labkey/api/view/jspTemplateTest.jsp -text api/src/org/labkey/api/view/menu/ContainerMenu.java -text @@ -1592,27 +1570,6 @@ assay/api-src/org/labkey/api/assay/plate/Well.java -text assay/api-src/org/labkey/api/assay/plate/WellData.java -text assay/api-src/org/labkey/api/assay/plate/WellGroup.java -text assay/api-src/org/labkey/api/assay/query/RunListDetailsQueryView.java -text -assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/GroupChangeListener.java -text -assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/GroupChangeListenerAdapter.java -text -assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/GroupTypePanel.java -text -assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/GroupTypePanelRow.java -text -assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/GroupTypesTabPanel.java -text -assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/model/GWTPlate.java -text -assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/model/GWTPosition.java -text -assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/model/GWTWellGroup.java -text -assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/PlateDataService.java -text -assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/PlateDataServiceAsync.java -text -assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/PlatePropertyPanel.java -text -assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/PropertyCreationDialog.java -text -assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/PropertyPanel.java -text -assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/ShiftPanel.java -text -assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/StatusBar.java -text -assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/TemplateDesigner.java -text -assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/TemplateGrid.java -text -assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/TemplateGridCell.java -text -assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/TemplateView.java -text -assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/WarningPanel.java -text -assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/WellGroupPropertyPanel.java -text assay/schemas/assayProvider.xsd -text assay/src/org/labkey/api/assay/nab/view/controlSummary.jsp -text assay/src/org/labkey/api/assay/nab/view/cutoffDilutions.jsp -text diff --git a/api/build.gradle b/api/build.gradle index ec41567f313..b9c8f700499 100644 --- a/api/build.gradle +++ b/api/build.gradle @@ -74,7 +74,7 @@ configurations { sourceSets { main { java { - srcDirs = ["src", "gwtsrc", "${BuildUtils.getBuildDirPath(project)}/xb"] + srcDirs = ["src", "${BuildUtils.getBuildDirPath(project)}/xb"] } // TODO move resources files into resources directory to avoid this overlap resources { @@ -420,19 +420,6 @@ dependencies { ) ) - BuildUtils.addExternalDependency( - project, - new ExternalDependency( - "org.gwtproject:gwt-servlet-jakarta:${gwtServletJakartaVersion}", - "Server Support for Google Web Toolkit", - "Google", - "http://code.google.com/webtoolkit/", - ExternalDependency.APACHE_2_LICENSE_NAME, - ExternalDependency.APACHE_2_LICENSE_URL, - "Support for rich web apps", - ) - ) - BuildUtils.addExternalDependency( project, new ExternalDependency( @@ -1023,19 +1010,6 @@ dependencies { ) ) - BuildUtils.addExternalDependency( - project, - new ExternalDependency( - "jakarta.validation:jakarta.validation-api:${validationJakartaApiVersion}", - "Bean Validation API (JSR 303)", - "JCP", - "http://jcp.org/en/jsr/detail?id=303", - ExternalDependency.APACHE_2_LICENSE_NAME, - ExternalDependency.APACHE_2_LICENSE_URL, - "Validation of objects, requirement of GWT", - ) - ) - BuildUtils.addExternalDependency( project, new ExternalDependency( diff --git a/api/gwtsrc/org/labkey/api/gwt/Internal.gwt.xml b/api/gwtsrc/org/labkey/api/gwt/Internal.gwt.xml deleted file mode 100644 index a67836e894d..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/Internal.gwt.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/api/gwtsrc/org/labkey/api/gwt/client/assay/AssayException.java b/api/gwtsrc/org/labkey/api/gwt/client/assay/AssayException.java deleted file mode 100644 index f7d4f9cc498..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/assay/AssayException.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.api.gwt.client.assay; - -import com.google.gwt.user.client.rpc.SerializableException; - -/** - * User: jeckels - * Date: Jul 17, 2007 - */ -public class AssayException extends SerializableException -{ - public AssayException() - { - super(); - } - - public AssayException(String message) - { - super(message); - } - - public AssayException(Throwable cause) - { - super(cause.toString()); - } -} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/assay/model/GWTPropertyDescriptorMixin.java b/api/gwtsrc/org/labkey/api/gwt/client/assay/model/GWTPropertyDescriptorMixin.java deleted file mode 100644 index 88642a23a37..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/assay/model/GWTPropertyDescriptorMixin.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.api.gwt.client.assay.model; - - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import org.labkey.api.gwt.client.util.StringProperty; - -/** - * Configures the fields that are not returned when serializing a GWTPropertyDescriptor. - * Ideally we would just add the @JsonIgnore annotations to GWTPropertyDescriptor directly, - * but the GWT compiler would need to have jackson on the classpath which isn't - * necessary. - */ -@JsonIgnoreProperties({ - "setMeasure", - "setDimension", - "setExcludeFromShifting", - "lookupDescription", - "fileType", - "updatedField", - "newField", - "renderUpdate" -}) -public abstract class GWTPropertyDescriptorMixin -{ - GWTPropertyDescriptorMixin(@JsonProperty("PHI") StringProperty phi, @JsonProperty("URL") StringProperty url, @JsonProperty("URLTarget") StringProperty URLTarget) - { } - @JsonProperty("PHI") - abstract void setPHI(String phi); // rename property on deserialize - @JsonProperty("URL") - abstract void setURL(String url); // rename property on deserialize - @JsonProperty("URLTarget") - abstract void setURLTarget(String urlTarget); // rename property on deserialize -} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/model/GWTPropertyDescriptor.java b/api/gwtsrc/org/labkey/api/gwt/client/model/GWTPropertyDescriptor.java deleted file mode 100644 index 303fd309ede..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/model/GWTPropertyDescriptor.java +++ /dev/null @@ -1,696 +0,0 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.api.gwt.client.model; - -import com.google.gwt.user.client.rpc.IsSerializable; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.Setter; -import org.apache.commons.lang3.StringUtils; -import org.labkey.api.gwt.client.DefaultScaleType; -import org.labkey.api.gwt.client.DefaultValueType; -import org.labkey.api.gwt.client.LockedPropertyType; -import org.labkey.api.gwt.client.ui.PropertyType; -import org.labkey.api.gwt.client.util.BooleanProperty; -import org.labkey.api.gwt.client.util.IntegerProperty; -import org.labkey.api.gwt.client.util.StringProperty; - -import java.util.ArrayList; -import java.util.List; - -/** - * See {@link org.labkey.api.exp.PropertyDescriptor} - */ -@EqualsAndHashCode -public class GWTPropertyDescriptor implements IsSerializable -{ - private final IntegerProperty propertyId = new IntegerProperty(0); - private final StringProperty propertyURI = new StringProperty(); - private final StringProperty container = new StringProperty(); - private final StringProperty name = new StringProperty(); - private final StringProperty description = new StringProperty(); - private final StringProperty rangeURI = new StringProperty("http://www.w3.org/2001/XMLSchema#string"); - private final StringProperty conceptURI = new StringProperty(); - private final StringProperty label = new StringProperty(); - private final StringProperty format = new StringProperty(); - private final BooleanProperty required = new BooleanProperty(false); - private final BooleanProperty hidden = new BooleanProperty(false); - private final StringProperty lookupContainer = new StringProperty(); - private final StringProperty lookupSchema = new StringProperty(); - private final StringProperty lookupQuery = new StringProperty(); - private final BooleanProperty lookupIsValid = new BooleanProperty(true); - private String defaultValueType = null; - private final StringProperty defaultValue = new StringProperty(); - private final StringProperty defaultDisplayValue = new StringProperty("[none]"); - private final BooleanProperty mvEnabled = new BooleanProperty(false); - private final StringProperty importAliases = new StringProperty(); - private final StringProperty url = new StringProperty(); - private final StringProperty urlTarget = new StringProperty(); - private final BooleanProperty shownInInsertView = new BooleanProperty(true); - private final BooleanProperty shownInUpdateView = new BooleanProperty(true); - private final BooleanProperty shownInDetailsView = new BooleanProperty(true); - private final BooleanProperty measure = new BooleanProperty(); - private final BooleanProperty dimension = new BooleanProperty(); - private final BooleanProperty recommendedVariable = new BooleanProperty(false); - private final StringProperty defaultScale = new StringProperty(DefaultScaleType.LINEAR.name()); - private final StringProperty facetingBehaviorType = new StringProperty(); - private final StringProperty phi = new StringProperty("NotPHI"); // Must match PHI.NotPHI and tableInfo.xsd enum PHIType.NotPHI - private final BooleanProperty isExcludeFromShifting = new BooleanProperty(); - private final BooleanProperty isPreventReordering = new BooleanProperty(); - private final BooleanProperty isDisableEditing = new BooleanProperty(); - private final IntegerProperty scale = new IntegerProperty(4000); - private final StringProperty principalConceptCode = new StringProperty(); - private final StringProperty sourceOntology = new StringProperty(); - private final StringProperty conceptSubtree = new StringProperty(); - private final StringProperty conceptImportColumn = new StringProperty(); - private final StringProperty conceptLabelColumn = new StringProperty(); - private final StringProperty redactedText = new StringProperty(); - private final StringProperty derivationDataScope = new StringProperty(); - private final BooleanProperty isPrimaryKey = new BooleanProperty(false); - private final StringProperty lockType = new StringProperty(LockedPropertyType.NotLocked.name()); - private final BooleanProperty scannable = new BooleanProperty(false); - private final StringProperty valueExpression = new StringProperty(); - - @Getter @Setter private List conditionalFormats = new ArrayList<>(); - @Getter @Setter private List filterCriteria = new ArrayList<>(); - @Getter @Setter private List propertyValidators = new ArrayList<>(); - - public GWTPropertyDescriptor() - { - } - - public GWTPropertyDescriptor(String name, String rangeURI) - { - setName(name); - setRangeURI(rangeURI); - } - - public GWTPropertyDescriptor(GWTPropertyDescriptor s) - { - this(s, false); - } - - public GWTPropertyDescriptor(GWTPropertyDescriptor s, boolean isNew) - { - if (!isNew) - { - setPropertyId(s.getPropertyId()); - setPropertyURI(s.getPropertyURI()); - } - - setContainer(s.getContainer()); - setName(s.getName()); - setDescription(s.getDescription()); - setRangeURI(s.getRangeURI()); - setConceptURI(s.getConceptURI()); - setLabel(s.getLabel()); - setFormat(s.getFormat()); - setRequired(s.isRequired()); - setHidden(s.isHidden()); - setShownInDetailsView(s.isShownInDetailsView()); - setShownInInsertView(s.isShownInInsertView()); - setShownInUpdateView(s.isShownInUpdateView()); - setMvEnabled(s.getMvEnabled()); - setMeasure(s.isMeasure()); - setDimension(s.isDimension()); - setRecommendedVariable(s.isRecommendedVariable()); - setDefaultScale(s.getDefaultScale()); - setLookupContainer(s.getLookupContainer()); - setLookupIsValid(s.getLookupIsValid()); - setLookupSchema(s.getLookupSchema()); - setLookupQuery(s.getLookupQuery()); - setDefaultValueType(s.getDefaultValueType()); - setDefaultValue(s.getDefaultValue()); - setDefaultDisplayValue(s.getDefaultDisplayValue()); - setImportAliases(s.getImportAliases()); - setURL(s.getURL()); - setURLTarget(s.getURLTarget()); - setFacetingBehaviorType(s.getFacetingBehaviorType()); - setPHI(s.getPHI()); - setExcludeFromShifting(s.isExcludeFromShifting()); - setPreventReordering(s.getPreventReordering()); - setDisableEditing(s.getDisableEditing()); - setScale(s.getScale()); - setRedactedText(s.getRedactedText()); - setIsPrimaryKey(s.getIsPrimaryKey()); - setLockType(s.getLockType()); - setPrincipalConceptCode(s.getPrincipalConceptCode()); - setSourceOntology(s.getSourceOntology()); - setConceptSubtree(s.getConceptSubtree()); - setConceptImportColumn(s.getConceptImportColumn()); - setConceptLabelColumn(s.getConceptLabelColumn()); - setDerivationDataScope(s.getDerivationDataScope()); - setScannable(s.isScannable()); - setValueExpression(s.getValueExpression()); - - for (GWTPropertyValidator v : s.getPropertyValidators()) - { - GWTPropertyValidator gpv = new GWTPropertyValidator(v); - if (isNew) - { - gpv.setRowId(0); - gpv.setNew(true); - } - propertyValidators.add(gpv); - } - - for (GWTConditionalFormat f : s.getConditionalFormats()) - { - conditionalFormats.add(new GWTConditionalFormat(f)); - } - - for (GWTFilterCriteria fc : s.getFilterCriteria()) - { - filterCriteria.add(new GWTFilterCriteria(fc)); - } - } - - public GWTPropertyDescriptor copy() - { - return new GWTPropertyDescriptor(this); - } - - public String getContainer() - { - return container.getString(); - } - - public void setContainer(String container) - { - this.container.set(container); - } - - public String getLookupContainer() - { - return lookupContainer.getString(); - } - - public void setLookupContainer(String lookupContainer) - { - this.lookupContainer.set(lookupContainer); - } - - public String getLookupSchema() - { - return lookupSchema.getString(); - } - - public void setLookupSchema(String lookupSchema) - { - this.lookupSchema.set(lookupSchema); - } - - public String getLookupQuery() - { - return lookupQuery.getString(); - } - - public void setLookupQuery(String lookupQuery) - { - this.lookupQuery.set(lookupQuery); - } - - public boolean getLookupIsValid() - { - return lookupIsValid.getBoolean(); - } - - public void setLookupIsValid(boolean lookupIsValid) - { - this.lookupIsValid.set(lookupIsValid); - } - - public int getPropertyId() - { - return propertyId.getInt(); - } - - public void setPropertyId(int rowId) - { - this.propertyId.setInt(rowId); - } - - public String getPropertyURI() - { - return propertyURI.getString(); - } - - public void setPropertyURI(String propertyURI) - { - this.propertyURI.set(propertyURI); - } - - public String getName() - { - return name.getString(); - } - - public void setName(String name) - { - this.name.set(name); - } - - public String getDescription() - { - return description.getString(); - } - - public void setDescription(String description) - { - this.description.set(description); - } - - public String getRangeURI() - { - return rangeURI.getString(); - } - - public void setRangeURI(String dataTypeURI) - { - this.rangeURI.set(dataTypeURI); - } - - public void guessMeasureAndDimension() - { - boolean plottableType = PropertyType.xsdInt.getURI().equals(getRangeURI()) || - PropertyType.xsdDouble.getURI().equals(getRangeURI()); - boolean isMeasure = plottableType && getLookupQuery() == null && !isHidden(); - setMeasure(isMeasure); - - setDimension(getLookupQuery() != null && !isHidden()); - } - - public String getConceptURI() - { - return conceptURI.getString(); - } - - public void setConceptURI(String conceptURI) - { - this.conceptURI.set(conceptURI); - } - - public String getLabel() - { - return label.getString(); - } - - public void setLabel(String label) - { - this.label.set(label); - } - - public String getFormat() - { - return format.getString(); - } - - public void setFormat(String format) - { - this.format.set(format); - } - - public boolean isRequired() - { - return required.getBool(); - } - - public void setRequired(boolean required) - { - this.required.setBool(required); - } - - public boolean isHidden() - { - return hidden.getBool(); - } - - public void setHidden(boolean hidden) - { - this.hidden.setBool(hidden); - } - - public boolean isShownInInsertView() - { - return shownInInsertView.getBool(); - } - - public void setShownInInsertView(boolean shown) - { - shownInInsertView.setBool(shown); - } - - public boolean isShownInUpdateView() - { - return shownInUpdateView.getBool(); - } - - public void setShownInUpdateView(boolean shown) - { - shownInUpdateView.setBool(shown); - } - - public boolean isShownInDetailsView() - { - return shownInDetailsView.getBool(); - } - - public void setShownInDetailsView(boolean shown) - { - shownInDetailsView.setBool(shown); - } - - public boolean isSetMeasure() - { - return measure.getBoolean() != null; - } - - public boolean isMeasure() - { - return measure.booleanValue(); - } - - public void setMeasure(boolean isMeasure) - { - measure.setBool(isMeasure); - } - - public boolean isSetDimension() - { - return dimension.getBoolean() != null; - } - - public boolean isDimension() - { - return dimension.booleanValue(); - } - - public void setDimension(boolean isDimension) - { - dimension.setBool(isDimension); - } - - public boolean isRecommendedVariable() - { - return recommendedVariable.booleanValue(); - } - - public void setRecommendedVariable(boolean isRecommendedVariable) - { - recommendedVariable.setBool(isRecommendedVariable); - } - - public String getDefaultScale() - { - return defaultScale.getString(); - } - - public void setDefaultScale(String defaultScale) - { - this.defaultScale.set(defaultScale); - } - - public boolean getMvEnabled() - { - return mvEnabled.getBool(); - } - - public void setMvEnabled(boolean mvEnabled) - { - this.mvEnabled.setBool(mvEnabled); - } - - public DefaultValueType getDefaultValueType() - { - return null==defaultValueType ? null : DefaultValueType.valueOf(defaultValueType); - } - - public void setDefaultValueType(DefaultValueType defaultValueType) - { - this.defaultValueType = null==defaultValueType ? null : defaultValueType.name(); - } - - public String getDefaultValue() - { - return defaultValue.getString(); - } - - public void setDefaultValue(String defaultValue) - { - this.defaultValue.set(defaultValue); - } - - public String getDefaultDisplayValue() - { - return defaultDisplayValue.toString(); - } - - public void setDefaultDisplayValue(String defaultDisplayValue) - { - this.defaultDisplayValue.set(defaultDisplayValue); - } - - public String getFacetingBehaviorType() - { - return facetingBehaviorType.getString(); - } - - public void setFacetingBehaviorType(String facetingBehavior) - { - this.facetingBehaviorType.set(facetingBehavior); - } - - public String getPHI() - { - return phi.getString(); - } - - public void setPHI(String phi) - { - this.phi.set(phi); - } - - public boolean isSetExcludeFromShifting() - { - return isExcludeFromShifting.getBoolean() != null; - } - - public boolean isExcludeFromShifting() - { - return isExcludeFromShifting.booleanValue(); - } - - public void setExcludeFromShifting(boolean isExcludeFromShifting) - { - this.isExcludeFromShifting.setBool(isExcludeFromShifting); - } - - public boolean getPreventReordering() - { - return isPreventReordering.booleanValue(); - } - - public void setPreventReordering(boolean preventReordering) - { - isPreventReordering.setBool(preventReordering); - } - - public boolean getDisableEditing() - { - return isDisableEditing.booleanValue(); - } - - public void setDisableEditing(boolean disableEditing) - { - isDisableEditing.setBool(disableEditing); - } - - public Integer getScale() - { - return this.scale.getInteger(); - } - - public void setScale(Integer value) - { - this.scale.set(value); - } - - public boolean isScannable() - { - return scannable.getBoolean(); - } - - public void setScannable(boolean scannable) - { - this.scannable.setBool(scannable); - } - - public String getPrincipalConceptCode() { return this.principalConceptCode.getString(); } - - public void setPrincipalConceptCode(String code) { this.principalConceptCode.set(code); } - - public String getSourceOntology() - { - return sourceOntology.getString(); - } - - public void setSourceOntology(String sourceOntology) - { - this.sourceOntology.set(sourceOntology); - } - - public String getConceptSubtree() - { - return this.conceptSubtree.getString(); - } - - public void setConceptSubtree(String path) - { - this.conceptSubtree.set(path); - } - - public String getConceptImportColumn() - { - return conceptImportColumn.getString(); - } - - public void setConceptImportColumn(String conceptImportColumn) - { - this.conceptImportColumn.set(conceptImportColumn); - } - - public String getConceptLabelColumn() - { - return conceptLabelColumn.getString(); - } - - public void setConceptLabelColumn(String conceptLabelColumn) - { - this.conceptLabelColumn.set(conceptLabelColumn); - } - - public String getRedactedText() - { - return redactedText.getString(); - } - - public void setRedactedText(String redactedText) - { - this.redactedText.set(redactedText); - } - - public String getDerivationDataScope() - { - return derivationDataScope.getString(); - } - - public void setDerivationDataScope(String derivationDataScope) - { - this.derivationDataScope.set(derivationDataScope); - } - - public String getValueExpression() - { - return valueExpression.getString(); - } - - public void setValueExpression(String valueExpression) - { - this.valueExpression.set(valueExpression); - } - - public boolean getIsPrimaryKey() - { - return isPrimaryKey.booleanValue(); - } - - /** This method is for informational purpose only so that the client can identify column as a PK column. - * Setting PK on a column via this method will not get preserved in the domain's table. - */ - public void setIsPrimaryKey(boolean isPrimaryKey) - { - this.isPrimaryKey.setBool(isPrimaryKey); - } - - public String getLockType() - { - return lockType.getString(); - } - - /** This method is for informational purpose only so that the client can identify column's locked type. - * Setting lock type on a column via this method will not get preserved in the domain's table. - */ - public void setLockType(String lockType) - { - this.lockType.set(lockType); - } - - public String debugString() - { - return getName() + " " + getLabel() + " " + getRangeURI() + " " + isRequired() + " " + getDescription(); - } - - public String getImportAliases() - { - return importAliases.toString(); - } - - public void setImportAliases(String importAliases) - { - this.importAliases.set(importAliases); - } - - public String getURL() - { - return url.toString(); - } - - public void setURL(String url) - { - this.url.set(url); - } - - public String getURLTarget() - { - return urlTarget.toString(); - } - - public void setURLTarget(String urlTarget) - { - this.urlTarget.set(urlTarget); - } - - public String getLookupDescription() - { - if (StringUtils.isEmpty(getLookupSchema()) || StringUtils.isEmpty(getLookupQuery())) - return "(none)"; - - return getLookupSchema() + "." + getLookupQuery(); - } - - @Override - public String toString() - { - return name.getString() + ": " + rangeURI.getString(); - } - - public boolean isFileType() - { - return "http://cpas.fhcrc.org/exp/xml#fileLink".equals(getRangeURI()) || - "http://www.labkey.org/exp/xml#attachment".equals(getRangeURI()); - } -} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/ui/BoundTextBox.java b/api/gwtsrc/org/labkey/api/gwt/client/ui/BoundTextBox.java deleted file mode 100644 index 54c523a0d3d..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/ui/BoundTextBox.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.api.gwt.client.ui; - -import com.google.gwt.event.dom.client.BlurEvent; -import com.google.gwt.event.dom.client.BlurHandler; -import com.google.gwt.event.dom.client.ChangeEvent; -import com.google.gwt.event.dom.client.ChangeHandler; -import com.google.gwt.event.dom.client.KeyPressEvent; -import com.google.gwt.event.dom.client.KeyPressHandler; -import com.google.gwt.event.dom.client.KeyUpEvent; -import com.google.gwt.event.dom.client.KeyUpHandler; -import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.Window; -import com.google.gwt.user.client.ui.HorizontalPanel; -import com.google.gwt.user.client.ui.TextBox; -import com.google.gwt.user.client.ui.Widget; -import org.labkey.api.gwt.client.util.StringProperty; -import org.labkey.api.gwt.client.util.StringUtils; - -/** - * User: jeckels -* Date: Sep 9, 2008 -*/ -public class BoundTextBox extends HorizontalPanel -{ - protected final String _initialValue; - private final WidgetUpdatable _updateable; - private final DirtyCallback _dirtyCallback; - protected TextBox _box; - protected String _caption; - private boolean _required; - - public BoundTextBox(String caption, String id, String initialValue, final WidgetUpdatable updatable) - { - this(caption, id, initialValue, updatable, null); - } - - public BoundTextBox(String caption, String id, StringProperty prop) - { - this(caption, id, prop, null); - } - - public BoundTextBox(String caption, String id, final StringProperty prop, DirtyCallback dirtyCallback) - { - this(caption, id, prop.getString(), new WidgetUpdatable(){ - @Override - public void update(Widget widget) - { - prop.set(((TextBox)widget).getText()); - } - }, dirtyCallback); - } - - public BoundTextBox(String caption, String id, String initialValue, WidgetUpdatable updatable, final DirtyCallback dirtyCallback) - { - _initialValue = null==initialValue ? "" : initialValue; - _updateable = updatable; - _dirtyCallback = dirtyCallback; - _caption = caption; - _box = new TextBox(); - DOM.setElementAttribute(_box.getElement(), "id", id); - DOM.setElementAttribute(_box.getElement(), "name", id); - _box.setText(StringUtils.trimToEmpty(initialValue)); - _box.addBlurHandler(new BlurHandler() - { - @Override - public void onBlur(BlurEvent event) - { - _update((Widget)event.getSource()); - } - }); - _box.addChangeHandler(new ChangeHandler() - { - @Override - public void onChange(ChangeEvent change) - { - _update((Widget)change.getSource()); - } - }); - _box.addKeyPressHandler(new KeyPressHandler() - { - @Override - public void onKeyPress(KeyPressEvent e) - { - _dirty(); - } - }); - _box.addKeyUpHandler(new KeyUpHandler() - { - @Override - public void onKeyUp(KeyUpEvent e) - { - _dirty(); - } - }); - add(_box); - } - - - public void setRequired(boolean required) - { - _required = required; - } - - - void _update(Widget sender) - { - if (checkValid()) - _updateable.update(sender); - } - - - void _dirty() - { - if (_dirtyCallback != null && !_initialValue.equals(getBox().getText())) - _dirtyCallback.setDirty(true); - } - - - public boolean checkValid() - { - String value = _box.getText(); - String msg = validateValue(value); - if (null == msg) - { - clearErrorFormat(getBox()); - return true; - } - else - { - setErrorFormat(getBox(), msg, false); - return false; - } - } - - public final String validate() - { - return validateValue(getBox().getText()); - } - - - protected String validateValue(String text) - { - text = text.trim(); - if (_required && (text == null || text.isEmpty())) - return "\"" + _caption + "\" is required."; - return null; - } - - - public TextBox getBox() - { - return _box; - } - - - - static void setErrorFormat(Widget w, String message, boolean alert) - { - if (null == message) - message = "illegal value"; - - w.addStyleName("labkey-textbox-error"); - w.setTitle(message); - if (alert) - Window.alert(message); - } - - static void clearErrorFormat(Widget w) - { - w.removeStyleName("labkey-textbox-error"); - w.setTitle(""); - } -} \ No newline at end of file diff --git a/api/gwtsrc/org/labkey/api/gwt/client/ui/DirtyCallback.java b/api/gwtsrc/org/labkey/api/gwt/client/ui/DirtyCallback.java deleted file mode 100644 index 01d1d89c53e..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/ui/DirtyCallback.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.api.gwt.client.ui; - -/** - * Used for UI components to callback to let their container know that their value has changed - * User: jeckels - * Date: Sep 9, 2008 - */ -public interface DirtyCallback -{ - void setDirty(boolean dirty); -} \ No newline at end of file diff --git a/api/gwtsrc/org/labkey/api/gwt/client/ui/HelpPopup.java b/api/gwtsrc/org/labkey/api/gwt/client/ui/HelpPopup.java deleted file mode 100644 index d23c009c174..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/ui/HelpPopup.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.api.gwt.client.ui; - -import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.Element; -import com.google.gwt.user.client.ui.InlineLabel; -import org.labkey.api.gwt.client.util.PropertyUtil; - -/** - * User: Karl Lum - * Date: Aug 22, 2007 - */ -public class HelpPopup extends InlineLabel -{ - private final Element _element; - private final String _title; - private String _body; - - public HelpPopup(String title, String body) - { - _element = getElement(); - _title = title; - _body = body; - - final String headerSize = PropertyUtil.getServerProperty("header1Size"); - String text = "?"; - DOM.setInnerHTML(_element, text); - - addMouseOverHandler(e -> showHelpDiv(_element, _title, _body)); - - addMouseOutHandler(e -> hideHelpDiv()); - } - - public void setBody(String body) - { - _body = body; - } - - /** - * JSNI method to call the underlying javascript function in util.js - */ - public static native void hideHelpDiv() /*-{ - $wnd.hideHelpDivDelay(); - }-*/; - - public static native void showHelpDiv(Element element, String title, String body) /*-{ - $wnd.showHelpDivDelay(element, title, body); - }-*/; -} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/ui/ImageButton.java b/api/gwtsrc/org/labkey/api/gwt/client/ui/ImageButton.java deleted file mode 100644 index 1b160535f3b..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/ui/ImageButton.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.api.gwt.client.ui; - -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; -import com.google.gwt.event.dom.client.KeyPressEvent; -import com.google.gwt.event.dom.client.KeyPressHandler; -import com.google.gwt.event.shared.HandlerRegistration; -import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.ui.ButtonBase; -import com.google.gwt.user.client.ui.ClickListener; -import com.google.gwt.user.client.ui.ClickListenerCollection; -import com.google.gwt.user.client.ui.Widget; - -import java.util.ArrayList; -import java.util.List; - -public class ImageButton extends ButtonBase implements ClickListener -{ - private final ClickListenerCollection _clickListeners = new ClickListenerCollection(); - private final List _clickHandlers = new ArrayList<>(); - private String _text; - - public ImageButton(String text, ClickListener listener) - { - this(text); - addClickListener(listener); - } - - public ImageButton(String text, ClickHandler handler) - { - this(text); - addClickHandler(handler); - } - - public ImageButton(String text) - { - super(DOM.createSpan()); - addClickListener(this); - - _text = text; - DOM.setAttribute(getElement(), "id", "button_" + text); - - refreshState(); - - addKeyPressHandler(new KeyPressHandler() - { - @Override - public void onKeyPress(KeyPressEvent event) - { - if (event.getCharCode() == ' ' && !event.isAnyModifierKeyDown()) - { - fireEvent(new ClickEvent() - { - // Hack - subclass exists to make the constructor public - }); - } - } - }); - - super.addClickListener(new ClickListener() - { - @Override - public void onClick(Widget sender) - { - if (isEnabled()) - _clickListeners.fireClick(sender); - } - }); - super.addClickHandler(new ClickHandler() - { - @Override - public void onClick(ClickEvent event) - { - if (isEnabled()) - { - for (ClickHandler clickHandler : _clickHandlers) - { - clickHandler.onClick(event); - } - } - } - }); - } - - @Override - public HandlerRegistration addClickHandler(final ClickHandler handler) - { - _clickHandlers.add(handler); - return new HandlerRegistration() - { - @Override - public void removeHandler() - { - _clickHandlers.remove(handler); - } - }; - } - - @Override - public void addClickListener(ClickListener listener) - { - _clickListeners.add(listener); - } - - @Override - public void removeClickListener(ClickListener listener) - { - _clickListeners.remove(listener); - } - - @Override - public String getText() - { - return _text; - } - - public void refreshState() - { - // TODO: This should try to use Button.ButtonBuilder - setHTML("" + _text + ""); - } - - @Override - public void setText(String text) - { - if (_text.equals(text)) - return; - - _text = text; - refreshState(); - } - - @Override - public void setEnabled(boolean enabled) - { - super.setEnabled(enabled); - refreshState(); - } - - /** to make life simple, just override onClick instead of registering a listener */ - @Override - public void onClick(Widget sender) - { - } -} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/ui/PropertyType.java b/api/gwtsrc/org/labkey/api/gwt/client/ui/PropertyType.java deleted file mode 100644 index 5cb59516f9d..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/ui/PropertyType.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.api.gwt.client.ui; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** -* User: matthewb -* Date: Apr 22, 2010 - * - * TODO: Merge or replace with exp/PropertyType -*/ -public enum PropertyType -{ - // Treat expMultiLine the same as xsdString for lookup purposes, since it's really just a formatting distinction - expMultiLine("http://www.w3.org/2001/XMLSchema#multiLine", true, "Multi-Line Text", "String", "string"), - xsdString("http://www.w3.org/2001/XMLSchema#string", true, "Text (String)", "String", "string"), - xsdBoolean("http://www.w3.org/2001/XMLSchema#boolean", false, "Boolean", null, "boolean"), - xsdInt("http://www.w3.org/2001/XMLSchema#int", true, "Integer", null, "int"), - xsdDouble("http://www.w3.org/2001/XMLSchema#double", true, "Number (Double)", "Double", "float"), - xsdDateTime("http://www.w3.org/2001/XMLSchema#dateTime", true, "DateTime", null, "date"), - xsdDate("http://www.w3.org/2001/XMLSchema#date", true, "Date", null, "date"), - xsdTime("http://www.w3.org/2001/XMLSchema#time", true, "Time", null, "time"), - expFileLink("http://cpas.fhcrc.org/exp/xml#fileLink", false, "File"), - expAttachment("http://www.labkey.org/exp/xml#attachment", false, "Attachment"), - xsdFloat("http://www.w3.org/2001/XMLSchema#float", true, "Number (Float)", "Float", "float"), - xsdDecimal("http://www.w3.org/2001/XMLSchema#decimal", true, "Number (Decimal)", "Decimal", "float"), - xsdLong("http://www.w3.org/2001/XMLSchema#long", true, "Long Integer", "Long", "int"), - xsdBinary("http://www.w3.org/2001/XMLSchema#binary", false, "Byte Buffer", "Buffer", "string"); - - public static final String PARTICIPANT_CONCEPT_URI = "http://cpas.labkey.com/Study#ParticipantId"; - public static final String VISIT_CONCEPT_URI = "http://cpas.labkey.com/Study#VisitId"; - public static final String SPECIMEN_CONCEPT_URI = "http://cpas.labkey.com/Study#SpecimenId"; - public static final String SAMPLE_CONCEPT_URI = "http://www.labkey.org/exp/xml#sample"; - public static final String CALCULATED_CONCEPT_URI = "http://www.labkey.org/exp/xml#calculated"; - - private final String _uri; - private final String _display; - private final String _jsonType; - private final String _short; - private final boolean _lookup; - - PropertyType(String uri, boolean lookup, String display) - { - this(uri,lookup,display, display, null); - } - - PropertyType(String uri, boolean lookup, String display, String shortName, String jsonType) - { - _uri = uri; - _lookup = lookup; - _display = display; - _jsonType = jsonType; - _short = shortName == null ? display : shortName; - } - - public String getURI() - { - return _uri; - } - - @Override - public String toString() - { - return _uri; - } - - public String getDisplay() - { - return _display; - } - - public String getShortName() - { - return _short; - } - - public String getJsonType() - { - return _jsonType; - } - - public boolean isLookupType() - { - return _lookup; - } - - public static PropertyType fromURI(String uri) - { - for (PropertyType propertyType : values()) - { - if (propertyType.getURI().equals(uri)) - { - return propertyType; - } - } - return null; - } - - public static PropertyType fromName(String type) - { - PropertyType t = synonyms.get(type); - if (null == t) - t = synonyms.get(type.toLowerCase()); - return t; - } - - - private static final Map synonyms = new HashMap<>(); - private static void _put(PropertyType t) - { - synonyms.put(t.toString().toLowerCase(), t); - synonyms.put(t.getDisplay().toLowerCase(), t); - synonyms.put(t.getShortName().toLowerCase(), t); - } - static - { - for (PropertyType t : PropertyType.values()) - _put(t); - - synonyms.put("text", xsdString); - synonyms.put("xsd:string", xsdString); - - synonyms.put("int", xsdInt); - synonyms.put("integer", xsdInt); - synonyms.put("xsd:int", xsdInt); - - synonyms.put("number", xsdDouble); - synonyms.put("real", xsdDouble); - synonyms.put("float", xsdDouble); - synonyms.put("xsd:double", xsdDouble); - - synonyms.put("date", xsdDateTime); - synonyms.put("xsd:datetime", xsdDateTime); - - synonyms.put("bool", xsdBoolean); - synonyms.put("xsd:boolean", xsdBoolean); - } - - public static List getBaseTypes() - { - return Arrays.asList(xsdString, expMultiLine, xsdBoolean, xsdInt, xsdDouble, xsdDateTime); - } -} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/ui/SaveButtonBar.java b/api/gwtsrc/org/labkey/api/gwt/client/ui/SaveButtonBar.java deleted file mode 100644 index abffa7378d4..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/ui/SaveButtonBar.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.api.gwt.client.ui; - -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; -import com.google.gwt.user.client.ui.ButtonBase; -import com.google.gwt.user.client.ui.HorizontalPanel; - -/** - * User: jgarms - * Date: Jun 2, 2008 - * Time: 1:46:00 PM - */ -public class SaveButtonBar extends HorizontalPanel -{ - private final Saveable owner; - - private final ButtonBase finishButton; - private final ButtonBase saveButton; - private final ButtonBase cancelButton; - - public SaveButtonBar(Saveable s) - { - super(); - owner = s; - - getTable().setClassName("gwt-ButtonBar"); - - finishButton = new ImageButton("Save & Close", new ClickHandler() - { - @Override - public void onClick(ClickEvent e) - { - owner.finish(); - } - }); - - add(finishButton); - - saveButton = new ImageButton("Save", new ClickHandler() - { - @Override - public void onClick(ClickEvent e) - { - owner.save(); - } - }); - add(saveButton); - - - cancelButton = new ImageButton("Cancel", new ClickHandler() - { - @Override - public void onClick(ClickEvent e) - { - owner.cancel(); - } - }); - - add(cancelButton); - } - - public void disableAll() - { - saveButton.setEnabled(false); - finishButton.setEnabled(false); - cancelButton.setEnabled(false); - } - - public void setAllowSave(boolean dirty) - { - // For unknown reasons, GWT ignores the button click if an already-enabled button is re-enabled - // during its click handling. Specifically, this happens if the dirty state is set as part of a blur handler - // when a form element is losing focus because a user is clicking on the save or cancel buttons - if (saveButton.isEnabled() != dirty) - saveButton.setEnabled(dirty); - if (!cancelButton.isEnabled()) - cancelButton.setEnabled(true); - if (!finishButton.isEnabled()) - finishButton.setEnabled(true); - } - -} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/ui/Saveable.java b/api/gwtsrc/org/labkey/api/gwt/client/ui/Saveable.java deleted file mode 100644 index 690d1c42c28..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/ui/Saveable.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.api.gwt.client.ui; - -/** - * Interface for widgets that need a Save Finish Cancel button bar - * - * User: jgarms - * Date: Jun 2, 2008 - * Time: 11:01:14 AM - */ -public interface Saveable -{ - /** - * @return the URL that should be considered the current URL. This is useful for apps that both create - * new objects and edit existing objects. The new URL typically doesn't have a RowId or other identifier, - * but the edit does. Thus, to return to the "same" page after saving a new object, you need to add - * the RowId or otherwise change it. - */ - String getCurrentURL(); - - interface SaveListener - { - void saveSuccessful(ObjectType result, String designerUrl); - } - - /** - * Save button clicked - */ - void save(); - - /** - * Save button clicked - */ - void save(SaveListener listener); - - /** - * Cancel button clicked - */ - void cancel(); - - /** - * Finish button clicked - */ - void finish(); - - boolean isDirty(); -} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/ui/TextBoxDialogBox.java b/api/gwtsrc/org/labkey/api/gwt/client/ui/TextBoxDialogBox.java deleted file mode 100644 index b87bf216d06..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/ui/TextBoxDialogBox.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.api.gwt.client.ui; - -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; -import com.google.gwt.event.dom.client.KeyCodes; -import com.google.gwt.user.client.ui.DialogBox; -import com.google.gwt.user.client.ui.HorizontalPanel; -import com.google.gwt.user.client.ui.KeyboardListenerAdapter; -import com.google.gwt.user.client.ui.Label; -import com.google.gwt.user.client.ui.TextBox; -import com.google.gwt.user.client.ui.VerticalPanel; -import com.google.gwt.user.client.ui.Widget; - -/** - * User: jeckels - * Date: Apr 24, 2007 - */ -public abstract class TextBoxDialogBox extends DialogBox -{ - private final TextBox _textBox; - - public TextBoxDialogBox(String title, String label) - { - super(false); - - setText(title); - - _textBox = new TextBox(); - _textBox.addKeyboardListener(new KeyboardListenerAdapter() - { - @Override - public void onKeyDown(Widget sender, char keyCode, int modifiers) - { - if (keyCode == KeyCodes.KEY_ENTER) - { - commit(); - } - else if (keyCode == KeyCodes.KEY_ESCAPE) - { - hide(); - } - } - }); - - VerticalPanel contentPanel = new VerticalPanel(); - contentPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); - - HorizontalPanel inputPanel = new HorizontalPanel(); - inputPanel.setSpacing(5); - - inputPanel.add(new Label(label + ": ")); - inputPanel.add(_textBox); - - HorizontalPanel buttonPanel = new HorizontalPanel(); - buttonPanel.setSpacing(5); - - ImageButton okButton = new ImageButton("OK"); - buttonPanel.add(okButton); - okButton.addClickHandler(new ClickHandler() - { - @Override - public void onClick(ClickEvent e) - { - commit(); - } - }); - - ImageButton cancelButton = new ImageButton("Cancel"); - cancelButton.addClickHandler(new ClickHandler() - { - @Override - public void onClick(ClickEvent e) - { - hide(); - } - }); - buttonPanel.add(cancelButton); - - contentPanel.add(inputPanel); - contentPanel.add(buttonPanel); - - setWidget(contentPanel); - _textBox.setFocus(true); - } - - private void commit() - { - String propName = _textBox.getText().trim(); - - if (commit(propName)) - { - hide(); - } - } - - @Override - public void show() - { - WindowUtil.centerDialog(this); - super.show(); - _textBox.selectAll(); - _textBox.setFocus(true); - WindowUtil.centerDialog(this); - } - - public void show(String defaultValue) - { - _textBox.setText(defaultValue); - show(); - } - - /** Do something useful with the value. If it's not valid, return false and the dialog won't go away. - */ - protected abstract boolean commit(String value); - -} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/ui/WebPartPanel.java b/api/gwtsrc/org/labkey/api/gwt/client/ui/WebPartPanel.java deleted file mode 100644 index 4c156181296..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/ui/WebPartPanel.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.api.gwt.client.ui; - -import com.google.gwt.safehtml.shared.SafeHtmlUtils; -import com.google.gwt.user.client.ui.Composite; -import com.google.gwt.user.client.ui.HTMLPanel; -import com.google.gwt.user.client.ui.Widget; - -/** - * User: jeckels - * Date: Jun 13, 2007 - */ -public class WebPartPanel extends Composite -{ - public WebPartPanel(String title, Widget contents) - { - final HTMLPanel panel; - final String bodyId = HTMLPanel.createUniqueId(); - - panel = new HTMLPanel( - "
" + - "
" + - "

" + SafeHtmlUtils.htmlEscape(title) + "

" + - "
" + - "
" + - "
" + - "
" - ); - panel.getElement().setAttribute("name", "webpart"); - - panel.add(contents, bodyId); - - initWidget(panel); - } -} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/ui/WidgetUpdatable.java b/api/gwtsrc/org/labkey/api/gwt/client/ui/WidgetUpdatable.java deleted file mode 100644 index fe5afd7ea01..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/ui/WidgetUpdatable.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.api.gwt.client.ui; - -import com.google.gwt.user.client.ui.Widget; - -/** - * User: jeckels -* Date: Sep 9, 2008 -*/ -public interface WidgetUpdatable -{ - void update(Widget widget); -} \ No newline at end of file diff --git a/api/gwtsrc/org/labkey/api/gwt/client/ui/WindowUtil.java b/api/gwtsrc/org/labkey/api/gwt/client/ui/WindowUtil.java deleted file mode 100644 index 8b0452a22c1..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/ui/WindowUtil.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.api.gwt.client.ui; - -import com.google.gwt.user.client.Window; -import com.google.gwt.user.client.ui.DialogBox; -import com.google.gwt.user.client.ui.Widget; - -/** - * User: Mark Igra - * Date: Feb 26, 2007 - * Time: 9:56:50 PM - */ -public class WindowUtil -{ - /** - * Gets the left scroll position. - * - * @return The left scroll position. - */ - public static native int getScrollLeft() /*-{ - var scrollLeft; - if ($wnd.innerHeight) - { - scrollLeft = $wnd.pageXOffset; - } - else if ($doc.documentElement && $doc.documentElement.scrollLeft) - { - scrollLeft = $doc.documentElement.scrollLeft; - } - else if ($doc.body) - { - scrollLeft = $doc.body.scrollLeft; - } - return scrollLeft; - }-*/; - - /** - * Gets the top scroll position. - * - * @return The top scroll position. - */ - public static native int getScrollTop() /*-{ - var scrollTop; - if ($wnd.innerHeight) - { - scrollTop = $wnd.pageYOffset; - } - else if ($doc.documentElement && $doc.documentElement.scrollTop) - { - scrollTop = $doc.documentElement.scrollTop; - } - else if ($doc.body) - { - scrollTop = $doc.body.scrollTop; - } - return scrollTop; - }-*/; - - public static native void scrollTo(int x, int y) /*-{ - $wnd.scrollTo(x, y); - }-*/; - - - public static void scrollIntoView(Widget w) - { - int widgetTop = w.getAbsoluteTop(); - int widgetLeft = w.getAbsoluteLeft(); - int widgetWidth = w.getOffsetWidth(); - int widgetHeight = w.getOffsetHeight(); - int widgetRight = widgetLeft + widgetWidth; - int widgetBottom = widgetTop + widgetHeight; - - int visTop = getScrollTop(); - int visLeft = getScrollLeft(); - int visWidth = Window.getClientWidth(); - int visHeight = Window.getClientHeight(); - int visRight = visLeft + visWidth; - int visBottom = visTop + visHeight; - - if (widgetTop >= visTop && widgetBottom <= visBottom && - widgetLeft >= visLeft && widgetRight <= visRight) - return; - - - int newTop = visTop; - int newLeft = visLeft; - if (widgetTop < visTop || widgetHeight > visHeight) - newTop = widgetTop; - else if (widgetBottom > visBottom) - newTop = widgetBottom - visHeight; - - if (widgetLeft < visLeft || widgetWidth > visWidth) - newLeft = widgetLeft; - else if (widgetRight > visRight) - newLeft = widgetRight - visWidth; - - scrollTo(newLeft, newTop); - } - - /** - * Navigates to a different URL (leaving this app) using - * window.location=loc - * @param loc - * - * Does NOT work with simple action names like "begin.view" (this breaks on IE). See PropertyUtil.getRelativeURL() - * and PropertyUtil.getContextPath(). - */ - public static void setLocation(String loc) - { - Window.Location.assign(loc); - } - - /** - * Navigates back one page - */ - public static native void back() /*-{ - $wnd.history.back(); - }-*/; - - public static void centerDialog(DialogBox dialogBox) - { - dialogBox.setPopupPosition((Window.getClientWidth() - dialogBox.getOffsetWidth()) / 2 + WindowUtil.getScrollLeft(), (Window.getClientHeight() - dialogBox.getOffsetHeight()) / 2 + WindowUtil.getScrollTop()); - } - - public static native String prompt(String prompt, String defaultValue) /*-{ - return $wnd.prompt(prompt, null == defaultValue ? "" : defaultValue); - }-*/; - -} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/ui/domain/CancellationException.java b/api/gwtsrc/org/labkey/api/gwt/client/ui/domain/CancellationException.java deleted file mode 100644 index fc4c4c5b43e..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/ui/domain/CancellationException.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.api.gwt.client.ui.domain; -/* - * User: adam - * Date: Dec 31, 2009 - * Time: 12:25:09 PM - */ -public class CancellationException extends RuntimeException -{ -} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/ui/incubator/ResizableWidget.java b/api/gwtsrc/org/labkey/api/gwt/client/ui/incubator/ResizableWidget.java deleted file mode 100644 index 2e00d11051d..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/ui/incubator/ResizableWidget.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2008 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.labkey.api.gwt.client.ui.incubator; - -import com.google.gwt.user.client.Element; - -/** - * An interface that defines the methods required to support automatic resizing - * of the Widget element. - */ -public interface ResizableWidget { - /** - * Get the widget's element. - */ - Element getElement(); - - /** - * Check if this widget is attached to the page. - * - * @return true if the widget is attached to the page - */ - boolean isAttached(); - - /** - * This method is called when the dimensions of the parent element change. - * Subclasses should override this method as needed. - * - * @param width the new client width of the element - * @param height the new client height of the element - */ - void onResize(int width, int height); -} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/ui/incubator/ResizableWidgetCollection.java b/api/gwtsrc/org/labkey/api/gwt/client/ui/incubator/ResizableWidgetCollection.java deleted file mode 100644 index 22d036c221a..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/ui/incubator/ResizableWidgetCollection.java +++ /dev/null @@ -1,329 +0,0 @@ -/* - * Copyright 2008 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.labkey.api.gwt.client.ui.incubator; - -import com.google.gwt.event.logical.shared.ResizeEvent; -import com.google.gwt.event.logical.shared.ResizeHandler; -import com.google.gwt.event.shared.HandlerRegistration; -import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.Timer; -import com.google.gwt.user.client.Window; -import com.google.gwt.user.client.WindowResizeListener; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -/** - * A collection of {@link ResizableWidget} that periodically checks the outer - * dimensions of a widget and redraws it as necessary. Every - * {@link ResizableWidgetCollection} uses a timer, so consider the cost when - * adding one. - * - * Typically, a {@link ResizableWidgetCollection} is only needed if you expect - * your widgets to resize based on window resizing or other events. Fixed sized - * Widgets do not need to be added to a {@link ResizableWidgetCollection} as - * they cannot be resized. - */ -public class ResizableWidgetCollection implements WindowResizeListener, - Iterable { - /** - * Information about a widgets size. - */ - private static class ResizableWidgetInfo { - /** - * The current clientHeight. - */ - private int curHeight; - - /** - * The current clientWidth. - */ - private int curWidth; - - /** - * Constructor. - * - * @param widget the widget that will be monitored - */ - public ResizableWidgetInfo(ResizableWidget widget) { - curWidth = DOM.getElementPropertyInt(widget.getElement(), "clientWidth"); - curHeight = DOM.getElementPropertyInt(widget.getElement(), "clientHeight"); - } - - /** - * Set the new dimensions of the widget if they changed. - * - * @param width the new width - * @param height the new height - * @return true if the dimensions have changed - */ - public boolean setClientSize(int width, int height) { - if (width != curWidth || height != curHeight) { - this.curWidth = width; - this.curHeight = height; - return true; - } else { - return false; - } - } - } - - /** - * The default delay between resize checks in milliseconds. - */ - private static final int DEFAULT_RESIZE_CHECK_DELAY = 400; - - /** - * A static {@link ResizableWidgetCollection} that can be used in most cases. - */ - private static ResizableWidgetCollection staticCollection = null; - - /** - * Get the globally accessible {@link ResizableWidgetCollection}. In most - * cases, the global collection can be used for all {@link ResizableWidget}s. - * - * @return the global {@link ResizableWidgetCollection} - */ - public static ResizableWidgetCollection get() { - if (staticCollection == null) { - staticCollection = new ResizableWidgetCollection(); - } - return staticCollection; - } - - /** - * The timer used to periodically compare the dimensions of elements to their - * old dimensions. - */ - private final Timer resizeCheckTimer = new Timer() { - @Override - public void run() { - // Ignore changes that result from window resize events - if (windowHeight != Window.getClientHeight() - || windowWidth != Window.getClientWidth()) { - windowHeight = Window.getClientHeight(); - windowWidth = Window.getClientWidth(); - schedule(resizeCheckDelay); - return; - } - - // Look for elements that have new dimensions - checkWidgetSize(); - - // Start checking again - if (resizeCheckingEnabled) { - schedule(resizeCheckDelay); - } - } - }; - - /** - * A hash map of the resizable widgets this collection is checking. - */ - private final Map widgets = new HashMap<>(); - - /** - * The current window height. - */ - private int windowHeight = 0; - - /** - * The current window width. - */ - private int windowWidth = 0; - - /** - * The hook used to remove the window handler. - */ - private HandlerRegistration windowHandler; - - /** - * The delay between resize checks. - */ - private int resizeCheckDelay = DEFAULT_RESIZE_CHECK_DELAY; - - /** - * A boolean indicating that resize checking should run. - */ - private boolean resizeCheckingEnabled; - - /** - * Create a ResizableWidget. - */ - public ResizableWidgetCollection() { - this(DEFAULT_RESIZE_CHECK_DELAY); - } - - /** - * Constructor. - * - * @param resizeCheckingEnabled false to disable resize checking - */ - public ResizableWidgetCollection(boolean resizeCheckingEnabled) { - this(DEFAULT_RESIZE_CHECK_DELAY, resizeCheckingEnabled); - } - - /** - * Constructor. - * - * @param resizeCheckDelay the delay between checks in milliseconds - */ - public ResizableWidgetCollection(int resizeCheckDelay) { - this(resizeCheckDelay, true); - } - - /** - * Constructor. - */ - protected ResizableWidgetCollection(int resizeCheckDelay, - boolean resizeCheckingEnabled) { - setResizeCheckDelay(resizeCheckDelay); - setResizeCheckingEnabled(resizeCheckingEnabled); - } - - /** - * Add a resizable widget to the collection. - * - * @param widget the resizable widget to add - */ - public void add(ResizableWidget widget) { - widgets.put(widget, new ResizableWidgetInfo(widget)); - } - - /** - * Check to see if any Widgets have been resized and call their handlers - * appropriately. - */ - public void checkWidgetSize() { - for (Map.Entry entry : widgets.entrySet()) { - ResizableWidget widget = entry.getKey(); - ResizableWidgetInfo info = entry.getValue(); - int curWidth = widget.getElement().getPropertyInt("clientWidth"); - int curHeight = widget.getElement().getPropertyInt("clientHeight"); - - // Call the onResize method only if the widget is attached - if (info.setClientSize(curWidth, curHeight)) { - if (curWidth > 0 && curHeight > 0 && widget.isAttached()) { - widget.onResize(curWidth, curHeight); - } - } - } - } - - /** - * Get the delay between resize checks in milliseconds. - * - * @return the resize check delay - */ - public int getResizeCheckDelay() { - return resizeCheckDelay; - } - - /** - * Check whether or not resize checking is enabled. - * - * @return true is resize checking is enabled - */ - public boolean isResizeCheckingEnabled() { - return resizeCheckingEnabled; - } - - @Override - public Iterator iterator() { - return widgets.keySet().iterator(); - } - - /** - * Called when the browser window is resized. - * - * @param width the width of the window's client area. - * @param height the height of the window's client area. - */ - @Override - @Deprecated - public void onWindowResized(int width, int height) { - checkWidgetSize(); - } - - /** - * Remove a {@link ResizableWidget} from the collection. - * - * @param widget the widget to remove - */ - public void remove(ResizableWidget widget) { - widgets.remove(widget); - } - - /** - * Set the delay between resize checks in milliseconds. - * - * @param resizeCheckDelay the new delay - */ - public void setResizeCheckDelay(int resizeCheckDelay) { - this.resizeCheckDelay = resizeCheckDelay; - } - - /** - * Set whether or not resize checking is enabled. If disabled, elements will - * still be resized on window events, but the timer will not check their - * dimensions periodically. - * - * @param enabled true to enable the resize checking timer - */ - public void setResizeCheckingEnabled(boolean enabled) { - if (enabled && !resizeCheckingEnabled) { - resizeCheckingEnabled = true; - if (windowHandler == null) { - windowHandler = Window.addResizeHandler(new ResizeHandler() { - @Override - public void onResize(ResizeEvent event) { - onWindowResized(event.getWidth(), event.getHeight()); - } - }); - } - resizeCheckTimer.schedule(resizeCheckDelay); - } else if (!enabled && resizeCheckingEnabled) { - resizeCheckingEnabled = false; - if (windowHandler != null) { - windowHandler.removeHandler(); - windowHandler = null; - } - resizeCheckTimer.cancel(); - } - } - - /** - * Inform the {@link ResizableWidgetCollection} that the size of a widget has - * changed and already been redrawn. This will prevent the widget from being - * redrawn on the next loop. - * - * @param widget the widget's size that changed - */ - public void updateWidgetSize(ResizableWidget widget) { - if (!widget.isAttached()) { - return; - } - - ResizableWidgetInfo info = widgets.get(widget); - if (info != null) { - int curWidth = widget.getElement().getPropertyInt("clientWidth"); - int curHeight = widget.getElement().getPropertyInt("clientHeight"); - info.setClientSize(curWidth, curHeight); - } - } - -} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/util/BooleanProperty.java b/api/gwtsrc/org/labkey/api/gwt/client/util/BooleanProperty.java deleted file mode 100644 index 3c68ed489af..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/util/BooleanProperty.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.api.gwt.client.util; - -import com.google.gwt.user.client.rpc.IsSerializable; - -/** - * User: Matthew - * Date: Apr 25, 2007 - * Time: 4:43:06 PM - */ -public class BooleanProperty implements IPropertyWrapper, IsSerializable -{ - Boolean b; - - public BooleanProperty() - { - b = null; - } - - public BooleanProperty(boolean b) - { - setBool(b); - } - - public BooleanProperty(Boolean b) - { - set(b); - } - - @Override - public Object get() - { - return b; - } - - @Override - public void set(Object o) - { - if (o instanceof String) - b = Boolean.valueOf((String)o); - else if (o instanceof Boolean) - b = (Boolean)o; - else - throw new IllegalArgumentException(String.valueOf(o)); - } - - public Boolean getBoolean() - { - return b; - } - - public void setBool(boolean b) - { - this.b = Boolean.valueOf(b); - } - - public boolean booleanValue() - { - return b != null && b.booleanValue(); - } - - @Deprecated - public boolean getBool() - { - return b != null && b.booleanValue(); - } - - public String toString() - { - return String.valueOf(b); - } - - @Override - public int hashCode() - { - return null==b ? 0 : b.hashCode(); - } -} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/util/ColorGenerator.java b/api/gwtsrc/org/labkey/api/gwt/client/util/ColorGenerator.java deleted file mode 100644 index bb159f80d30..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/util/ColorGenerator.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.api.gwt.client.util; - -/** - * User: brittp -* Date: Feb 5, 2007 -* Time: 6:32:56 PM -*/ -public class ColorGenerator -{ - private static final String[] SUBCOLOR_STRINGS = new String[]{"66", "AA", "EE", "88", "CC"}; - private int _r = 0; - private int _g = 1; - private int _b = 2; - - public ColorGenerator() - { - - } - - public ColorGenerator(int startColor) - { - for (int i = 0; i < startColor; i++) - advance(); - } - - public String next() - { - advance(); - return SUBCOLOR_STRINGS[_r % SUBCOLOR_STRINGS.length] + - SUBCOLOR_STRINGS[_g % SUBCOLOR_STRINGS.length] + - SUBCOLOR_STRINGS[_b % SUBCOLOR_STRINGS.length]; - } - - private void advance() - { - do - { - _r = (_r + 1) % SUBCOLOR_STRINGS.length; - if (_r % 2 == 0) - { - _g = (_g + 1) % SUBCOLOR_STRINGS.length; - if (_g % 3 == 0) - _b = (_b + 1) % SUBCOLOR_STRINGS.length; - } - } - while (_r == _g && _g == _b); - } -} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/util/ErrorDialogAsyncCallback.java b/api/gwtsrc/org/labkey/api/gwt/client/util/ErrorDialogAsyncCallback.java deleted file mode 100644 index a5ba4f7b7d8..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/util/ErrorDialogAsyncCallback.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.api.gwt.client.util; - -import com.google.gwt.user.client.Window; -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.gwt.user.client.rpc.StatusCodeException; - -/** - * User: jeckels - * Date: May 28, 2010 - */ -@SuppressWarnings("PatternVariableCanBeUsed") -public abstract class ErrorDialogAsyncCallback implements AsyncCallback -{ - private final String _description; - - public ErrorDialogAsyncCallback() - { - this(null); - } - - protected ErrorDialogAsyncCallback(String description) - { - _description = description; - } - - public static void showDialog(Throwable caught) - { - showDialog(caught, null); - } - - public static void showDialog(Throwable caught, String message) - { - ErrorDialogAsyncCallback dialog = new ErrorDialogAsyncCallback(message) - { - @Override - public void onSuccess(Object result) - { - } - }; - dialog.onFailure(caught); - } - - @Override - public final void onFailure(Throwable caught) - { - String message = null; - if (caught instanceof StatusCodeException) - { - StatusCodeException statusCodeException = (StatusCodeException)caught; - switch (statusCodeException.getStatusCode()) - { - case 0: - // Indicates the request was cancelled because the user navigated to another page - // Don't bother showing any dialog at all - return; - case 401: - message = "You do not have permission to perform this operation. Your session may have expired."; - break; - case 404: - message = "Not found."; - break; - case 500: - message = "The server encountered an error"; - if(statusCodeException.getMessage() != null) - message += ": " + statusCodeException.getMessage(); - break; - default: - message = "There was an error"; - if(statusCodeException.getMessage() != null) - message += ": " + statusCodeException.getMessage(); - message += " (" + statusCodeException.getStatusCode() + ")"; - break; - } - } - else - { - // We really want to be able to check for instances of - // com.google.gwt.core.client.impl.AsyncFragmentLoader.HttpDownloadFailure - // and treat them like StatusCodeExceptions, but it's a private class so just do a string check for the - // abort case - if ("HTTP download failed with status 0".equals(caught.getMessage())) - { - return; - } - } - if (message == null) - { - message = caught.getMessage() == null || caught.getMessage().trim().isEmpty() ? caught.toString() : caught.getMessage(); - } - if (_description != null) - { - message = _description + ": " + message; - } - reportFailure(message, caught); - handleFailure(message, caught); - } - - /** Shows the error message to the user in a dialog */ - protected void reportFailure(String message, Throwable caught) - { - Window.alert(message); - } - - /** Subclasses can override to provide additional error handling */ - protected void handleFailure(String message, Throwable caught) - { - - } -} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/util/IPropertyWrapper.java b/api/gwtsrc/org/labkey/api/gwt/client/util/IPropertyWrapper.java deleted file mode 100644 index 7e75458d846..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/util/IPropertyWrapper.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.api.gwt.client.util; - -/** - * User: Matthew - * Date: Apr 25, 2007 - * Time: 4:42:14 PM - */ -public interface IPropertyWrapper -{ - Object get(); - void set(Object o); - int hashCode(); -} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/util/IntegerProperty.java b/api/gwtsrc/org/labkey/api/gwt/client/util/IntegerProperty.java deleted file mode 100644 index 6c01aea6fbb..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/util/IntegerProperty.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.api.gwt.client.util; - -import com.google.gwt.user.client.rpc.IsSerializable; - -/** - * User: Matthew - * Date: Apr 25, 2007 - * Time: 4:43:06 PM - */ -public class IntegerProperty implements IPropertyWrapper, IsSerializable -{ - Integer i; - - public IntegerProperty() - { - i = null; - } - - public IntegerProperty(int i) - { - setInt(i); - } - - public IntegerProperty(Integer i) - { - set(i); - } - - @Override - public Object get() - { - return i; - } - - @Override - public void set(Object o) - { - i = (Integer)o; - } - - public Integer getInteger() - { - return i; - } - - public void setInt(int i) - { - // this.i = Integer.valueOf(i); - this.i = Integer.valueOf(i); - } - - public int intValue() - { - return null==i ? 0 : i.intValue(); - } - - @Deprecated - public int getInt() - { - return i.intValue(); - } - - public String toString() - { - return String.valueOf(i); - } - - @Override - public int hashCode() - { - return null==i ? 0 : i.hashCode(); - } -} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/util/PropertyUtil.java b/api/gwtsrc/org/labkey/api/gwt/client/util/PropertyUtil.java deleted file mode 100644 index 186080c2fd4..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/util/PropertyUtil.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.api.gwt.client.util; - -import com.google.gwt.http.client.URL; - -/** - * User: brittp - * Date: Feb 2, 2007 - * Time: 9:49:20 AM - */ -public class PropertyUtil -{ - public static native String getServerProperty(String propName) - /*-{ - var value = $wnd.LABKEY.GWTProperties[propName]; - if (!value) - return null; - else - return value; - }-*/; - - public static native String getCurrentURL() - /*-{ - var location = $wnd.location + ''; - // Safari returns current location with spaces, rather than %20. - // The "g" parameter creates a "global" regex, which will replace all instances. - location = location.replace(new RegExp(' ', 'g'), '%20'); - location = location.replace(new RegExp('\\+', 'g'), '%20'); - return location; - }-*/; - - public static String getContainerPath() - { - return getServerProperty("container"); - } - - // Is the current container a project? - public static boolean isProject() - { - String path = getContainerPath(); - // Currently in a project if container path is not the root and has no slashes after the first character - return !"/".equals(path) && (-1 == getContainerPath().indexOf('/', 1)); - } - - public static String getController() - { - return getServerProperty("controller"); - } - - public static String getAction() - { - return getServerProperty("action"); - } - - public static String getQueryString() - { - return getServerProperty("queryString"); - } - - public static String getReturnURL() - { - return getServerProperty("returnUrl"); - } - - public static String getRedirectURL() - { - return getServerProperty("redirectUrl"); - } - - public static String getCancelURL() - { - return getServerProperty("cancelUrl"); - } - - public static String getContextPath() - { - String ret = getServerProperty("contextPath"); - if (ret == null) - return ""; - return ret; - } - - // @Nullable (commented because GWT doesn't recognize) - public static String getMaxAllowedPhi() - { - return getServerProperty("maxAllowedPhi"); - } - - public static String getRelativeURL(String action) - { - return getRelativeURL(action, getController()); - } - - public static String getRelativeURL(String action, String pageFlow) - { - String[] pathParts = PropertyUtil.getContainerPath().split("/"); - StringBuilder encodedPath = new StringBuilder("/"); - for (String pathPart : pathParts) - { - if (!pathPart.isEmpty()) - { - //issue 14006: changed encodeComponent to encodePathSegment, b/c the former will convert spaces to '+' - String part = URL.encodePathSegment(pathPart); - encodedPath.append(part).append("/"); - } - } - if (!action.contains(".")) - action = action + ".view"; - return getContextPath() + encodedPath + pageFlow + "-" + action; - } - - /** @return true if the two arguments are both null, or are .equals() */ - public static boolean nullSafeEquals(Object o1, Object o2) - { - if (o1 == o2) - { - return true; - } - - return o1 != null && o1.equals(o2); - } -} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/util/ServiceUtil.java b/api/gwtsrc/org/labkey/api/gwt/client/util/ServiceUtil.java deleted file mode 100644 index f037245c112..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/util/ServiceUtil.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.api.gwt.client.util; - -import com.google.gwt.http.client.RequestBuilder; -import com.google.gwt.http.client.URL; -import com.google.gwt.user.client.rpc.RpcRequestBuilder; -import com.google.gwt.user.client.rpc.ServiceDefTarget; -import com.google.gwt.user.client.ui.RootPanel; - -import java.util.Collections; -import java.util.Map; - -/** - * User: brittp - * Date: Feb 2, 2007 - * Time: 11:35:54 AM - */ -public class ServiceUtil -{ - public static Object configureEndpoint(Object remoteService, String actionName) - { - return configureEndpoint(remoteService, actionName, null); - } - - public static Object configureEndpoint(Object remoteService, String actionName, String controllerName) - { - return configureEndpoint(remoteService, actionName, controllerName, Collections.emptyMap()); - } - - public static Object configureEndpoint(Object remoteService, String actionName, String controllerName, Map urlParams) - { - ServiceDefTarget endpoint = (ServiceDefTarget) remoteService; - - String url; - if (controllerName == null) - { - url = PropertyUtil.getRelativeURL(actionName); - } - else - { - url = PropertyUtil.getRelativeURL(actionName, controllerName); - } - String separator = "?"; - for (String key : urlParams.keySet()) - { - url += separator; - separator = "&"; - //issue 14006: changed encodeComponent to encodePathSegment, b/c the former will convert spaces to '+' - url += URL.encodePathSegment(key) + "=" + URL.encodePathSegment(urlParams.get(key)); - } - endpoint.setServiceEntryPoint(url); - - RpcRequestBuilder rpc = new RpcRequestBuilder() - { - @Override - protected void doFinish(RequestBuilder rb) - { - rb.setHeader("X-LABKEY-CSRF",getCsrfToken()); - super.doFinish(rb); - } - }; - endpoint.setRpcRequestBuilder(rpc); - - return remoteService; - } - - public static RootPanel findRootPanel(String classname) - { - int index = classname.indexOf(".client."); - if (index != -1) - { - classname = classname.substring(0, index) + classname.substring(index + ".client.".length() - 1); - } - return RootPanel.get(classname + "-Root"); - } - - public static native String getCsrfToken() /*-{ - return $wnd.LABKEY.CSRF; - }-*/; -} \ No newline at end of file diff --git a/api/gwtsrc/org/labkey/api/gwt/client/util/StringProperty.java b/api/gwtsrc/org/labkey/api/gwt/client/util/StringProperty.java deleted file mode 100644 index cbafe7986cb..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/util/StringProperty.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.api.gwt.client.util; - -import com.google.gwt.user.client.rpc.IsSerializable; - -/** - * User: Matthew - * Date: Apr 25, 2007 - * Time: 4:44:09 PM - */ -public class StringProperty implements IPropertyWrapper, IsSerializable -{ - String s; - - public StringProperty() - { - s = null; - } - - public StringProperty(String s) - { - this.s = s; - } - - @Override - public Object get() - { - return s; - } - - @Override - public void set(Object o) - { - s = (String)o; - } - - public String getString() - { - return s; - } - - public String toString() - { - return s; - } - - @Override - public int hashCode() - { - return null==s ? 0 : s.hashCode(); - } -} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/util/StringUtils.java b/api/gwtsrc/org/labkey/api/gwt/client/util/StringUtils.java deleted file mode 100644 index 1af3b035e6e..00000000000 --- a/api/gwtsrc/org/labkey/api/gwt/client/util/StringUtils.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.api.gwt.client.util; - -import java.util.List; - -/** - * GWT client code is the only place we should be using these methods; use org.apache.commons.lang3.StringUtils instead. - * This class will be removed in a future release of LabKey. - * - * User: Mark Igra - * Date: Feb 15, 2007 - * Time: 10:20:35 PM - */ - -@Deprecated -public class StringUtils -{ - public static boolean isEmpty(String str) - { - return null == str || str.isEmpty(); - } - - public static String trimToNull(String str) - { - if (null == str) - return str; - - str = str.trim(); - return str.isEmpty() ? null : str; - } - - public static String trimToEmpty(String str) - { - if (null == str) - return ""; - - return str.trim(); - } - - public static boolean equals(String a, String b) - { - return (null == a && null == b) || (null != a && a.equals(b)); - } - - public static String join(List l, String join) - { - StringBuffer sb = new StringBuffer(); - String sep = ""; - for (int i = 0; i < l.size(); i++) - { - sb.append(sep); - sb.append(l.get(i).toString()); - sep = join; - } - - return sb.toString(); - } - - static public String filter(String s, boolean encodeSpace) - { - if (null == s || s.isEmpty()) - return ""; - - int len = s.length(); - int i = 0; - - StringBuffer sb = new StringBuffer(2 * len); - sb.append(s.substring(0, i)); - boolean newline = false; - - for (; i < len; ++i) - { - char c = s.charAt(i); - - //Character.isWhitespace() not supported in GWT - if (c != '\t' && c != ' ') - newline = false; - if ('\r' == c || '\n' == c) - newline = true; - - switch (c) - { - case '&': - sb.append("&"); - break; - case '"': - sb.append("""); - break; - case '<': - sb.append("<"); - break; - case '>': - sb.append(">"); - break; - case '\n': - if (encodeSpace) - sb.append("
\n"); - else - sb.append(c); - break; - case '\t': - if (!encodeSpace) - sb.append(c); - else if (newline) - sb.append("    "); - else - sb.append("    "); - break; - case ' ': - if (encodeSpace && newline) - sb.append(" "); - else - sb.append(' '); - break; - default: - sb.append(c); - break; - } - } - - return sb.toString(); - } - - - public static String filter(Object o) - { - return filter(o == null ? null : o.toString()); - } - - /** - * HTML encode a string - */ - public static String filter(String s) - { - return filter(s, false); - } -} diff --git a/api/src/org/labkey/api/action/GWTServiceAction.java b/api/src/org/labkey/api/action/GWTServiceAction.java deleted file mode 100644 index 5c94ad4de69..00000000000 --- a/api/src/org/labkey/api/action/GWTServiceAction.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2008-2018 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.api.action; - -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; -import org.jetbrains.annotations.NotNull; -import org.labkey.api.gwt.server.BaseRemoteService; -import org.labkey.api.usageMetrics.SimpleMetricsService; -import org.labkey.api.view.UnauthorizedException; -import org.springframework.validation.Errors; -import org.springframework.web.servlet.ModelAndView; - -public abstract class GWTServiceAction extends BaseViewAction -{ - protected GWTServiceAction() - { - super(Object.class); - setUnauthorizedType(UnauthorizedException.Type.sendUnauthorized); - } - - @Override - public ModelAndView handleRequest(@NotNull HttpServletRequest httpServletRequest, @NotNull HttpServletResponse httpServletResponse) - { - // Use Core as the catch-all to consolidate reporting, even though GWT uses are distributed across modules - SimpleMetricsService.get().increment("Core", "GWTService", getClass().getSimpleName()); - - BaseRemoteService service = createService(); - if (!isPost()) - { - // GWT service requests must be POSTs - httpServletResponse.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED); - httpServletResponse.setHeader("Allow", "POST"); - } - else - { - service.doPost(httpServletRequest, httpServletResponse); - } - return null; - } - - protected abstract BaseRemoteService createService(); - - // methods we ignore, but have to implement since we extend BaseViewAction - @Override - protected String getCommandClassMethodName() - { - throw new UnsupportedOperationException(); - } - - @Override - public void validate(Object o, Errors errors) - { - throw new UnsupportedOperationException(); - } - - @Override - public ModelAndView handleRequest() - { - throw new UnsupportedOperationException(); - } -} diff --git a/api/src/org/labkey/api/assay/AbstractAssayTsvDataHandler.java b/api/src/org/labkey/api/assay/AbstractAssayTsvDataHandler.java index 9fa5dac7d8a..20b4050fe83 100644 --- a/api/src/org/labkey/api/assay/AbstractAssayTsvDataHandler.java +++ b/api/src/org/labkey/api/assay/AbstractAssayTsvDataHandler.java @@ -102,7 +102,6 @@ import org.labkey.api.view.ActionURL; import org.labkey.api.view.ViewBackgroundInfo; import org.labkey.vfs.FileLike; -import org.labkey.vfs.FileSystemLike; import org.springframework.jdbc.BadSqlGrammarException; import java.io.File; @@ -127,7 +126,7 @@ import static java.util.stream.Collectors.toList; import static org.labkey.api.assay.AssayRunUploadContext.ReImportOption.MERGE_DATA; import static org.labkey.api.exp.OntologyManager.NO_OP_ROW_CALLBACK; -import static org.labkey.api.gwt.client.ui.PropertyType.SAMPLE_CONCEPT_URI; +import static org.labkey.api.exp.PropertyType.SAMPLE_CONCEPT_URI; import static org.labkey.api.util.IntegerUtils.asLongElseNull; public abstract class AbstractAssayTsvDataHandler extends AbstractExperimentDataHandler implements ValidationDataHandler diff --git a/api/src/org/labkey/api/assay/AssayQCService.java b/api/src/org/labkey/api/assay/AssayQCService.java index 4509603f535..11cc4834eb2 100644 --- a/api/src/org/labkey/api/assay/AssayQCService.java +++ b/api/src/org/labkey/api/assay/AssayQCService.java @@ -15,6 +15,7 @@ */ package org.labkey.api.assay; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.labkey.api.data.Container; import org.labkey.api.data.SQLFragment; @@ -25,7 +26,6 @@ import org.labkey.api.security.User; import org.labkey.api.view.HttpView; -import jakarta.validation.constraints.NotNull; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -55,7 +55,7 @@ static AssayQCService getProvider() { if (!_providers.isEmpty()) { - return _providers.get(0); + return _providers.getFirst(); } return _defaultProvider; } @@ -114,13 +114,13 @@ static AssayQCService getProvider() void setDefaultDataImportState(Container container, DataState state); /** - * Gets/sets whether or not a blank state should be interpreted as public data or not + * Gets/sets whether a blank state should be interpreted as public data or not */ boolean isBlankQCStatePublic(Container container); void setIsBlankQCStatePublic(Container container, boolean isPublic); /** - * Gets/sets whether or not a comment is required on a QC State change + * Gets/sets whether a comment is required on a QC State change */ boolean isRequireCommentOnQCStateChange(Container container); void setRequireCommentOnQCStateChange(Container container, boolean requireCommentOnQCStateChange); @@ -129,7 +129,7 @@ static AssayQCService getProvider() * Returns the warnings view if the specified run has a current QC state associated with it */ @Nullable - HttpView getAssayReImportWarningView(Container container, ExpRun run) throws ExperimentException; + HttpView getAssayReImportWarningView(Container container, ExpRun run) throws ExperimentException; class DefaultQCService implements AssayQCService { @@ -199,7 +199,7 @@ public void setDefaultDataImportState(Container container, DataState state) } @Override - public @Nullable HttpView getAssayReImportWarningView(Container container, ExpRun run) throws ExperimentException + public @Nullable HttpView getAssayReImportWarningView(Container container, ExpRun run) { return null; } diff --git a/api/src/org/labkey/api/data/RuntimeSQLException.java b/api/src/org/labkey/api/data/RuntimeSQLException.java index 0f38a6b5aba..1473f1dd564 100644 --- a/api/src/org/labkey/api/data/RuntimeSQLException.java +++ b/api/src/org/labkey/api/data/RuntimeSQLException.java @@ -16,7 +16,6 @@ package org.labkey.api.data; -import com.google.gwt.user.client.rpc.IsSerializable; import org.jetbrains.annotations.NotNull; import org.labkey.api.data.dialect.SqlDialect; @@ -31,7 +30,7 @@ * User: mbellew * Date: Mar 23, 2005 */ -public class RuntimeSQLException extends RuntimeException implements Serializable, IsSerializable +public class RuntimeSQLException extends RuntimeException implements Serializable { // don't want to use cause, I want to impersonate the cause SQLException sqlx; diff --git a/api/src/org/labkey/api/dataiterator/CopyConfig.java b/api/src/org/labkey/api/dataiterator/CopyConfig.java index 90db56c9df9..26b1c4c0275 100644 --- a/api/src/org/labkey/api/dataiterator/CopyConfig.java +++ b/api/src/org/labkey/api/dataiterator/CopyConfig.java @@ -17,6 +17,7 @@ import com.fasterxml.jackson.annotation.JsonCreator; +import org.jetbrains.annotations.NotNull; import org.labkey.api.data.CompareType; import org.labkey.api.data.SimpleFilter; import org.labkey.api.query.FieldKey; @@ -24,7 +25,6 @@ import org.labkey.api.util.ConfigurationException; import org.labkey.remoteapi.query.Filter; -import jakarta.validation.constraints.NotNull; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; diff --git a/api/src/org/labkey/api/exp/OntologyManager.java b/api/src/org/labkey/api/exp/OntologyManager.java index 469b025eecc..f509e343236 100644 --- a/api/src/org/labkey/api/exp/OntologyManager.java +++ b/api/src/org/labkey/api/exp/OntologyManager.java @@ -48,7 +48,6 @@ import org.labkey.api.exp.property.PropertyService; import org.labkey.api.exp.property.SystemProperty; import org.labkey.api.exp.property.ValidatorContext; -import org.labkey.api.gwt.client.ui.domain.CancellationException; import org.labkey.api.query.BatchValidationException; import org.labkey.api.query.FieldKey; import org.labkey.api.query.PropertyValidationError; @@ -377,7 +376,7 @@ public static void insertTabDelimited(Container c, Map map = rows.getMap(); // TODO: hack -- should exit and return cancellation status instead of throwing if (Thread.currentThread().isInterrupted()) - throw new CancellationException(); + throw new RuntimeException(); assert before.start(); @@ -597,7 +596,7 @@ private static void saveTabDelimited(TableInfo table, // TODO: hack -- should exit and return cancellation status instead of throwing if (Thread.currentThread().isInterrupted()) - throw new CancellationException(); + throw new RuntimeException(); parameterMap.clearParameters(); diff --git a/api/src/org/labkey/api/exp/PropertyType.java b/api/src/org/labkey/api/exp/PropertyType.java index b3ab3c8017a..333c7b96a6a 100644 --- a/api/src/org/labkey/api/exp/PropertyType.java +++ b/api/src/org/labkey/api/exp/PropertyType.java @@ -43,7 +43,6 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.Objects; import java.util.TimeZone; @@ -96,7 +95,7 @@ protected void setValue(ObjectProperty property, Object value) boolValue = (Boolean)value; else if (null != value) boolValue = (Boolean) ConvertUtils.convert(value.toString(), Boolean.class); - property.floatValue = boolValue == null ? null : boolValue == Boolean.TRUE ? 1.0 : 0.0; + property.floatValue = boolValue == null ? null : boolValue ? 1.0 : 0.0; } @Override @@ -963,6 +962,11 @@ public Object getPreviewValue(@Nullable String prefix) } }; + public static final String PARTICIPANT_CONCEPT_URI = "http://cpas.labkey.com/Study#ParticipantId"; + public static final String VISIT_CONCEPT_URI = "http://cpas.labkey.com/Study#VisitId"; + public static final String SAMPLE_CONCEPT_URI = "http://www.labkey.org/exp/xml#sample"; + public static final String CALCULATED_CONCEPT_URI = "http://www.labkey.org/exp/xml#calculated"; + private final String typeURI; private final String xarName; private final char storageType; @@ -970,8 +974,8 @@ public Object getPreviewValue(@Nullable String prefix) private final @NotNull JdbcType jdbcType; private final int scale; private final String inputType; - private final Class javaType; - private final Class[] additionalTypes; + private final Class javaType; + private final Class[] additionalTypes; private static Map uriToProperty; private static Map xarToProperty = null; @@ -983,8 +987,8 @@ public Object getPreviewValue(@Nullable String prefix) int scale, String inputType, CellType excelCellType, - Class javaType, - Class... additionalTypes) + Class javaType, + Class... additionalTypes) { this.typeURI = typeURI; this.xarName = xarName; @@ -1116,7 +1120,7 @@ public static PropertyType getFromXarName(String xarName, PropertyType def) return null == p ? def : p; } - public static PropertyType getFromClass(Class clazz) + public static PropertyType getFromClass(Class clazz) { if (clazz == BigDecimal.class) clazz = Double.class; @@ -1134,7 +1138,7 @@ public static PropertyType getFromClass(Class clazz) { if (t.additionalTypes == null || t.additionalTypes.length == 0) continue; - for (Class type : t.additionalTypes) + for (Class type : t.additionalTypes) { if (type.isAssignableFrom(clazz)) return t; @@ -1201,16 +1205,12 @@ public static Object getFromExcelCell(Cell cell) throws ConversionException public String getValueTypeColumn() { - switch (this.getStorageType()) + return switch (this.getStorageType()) { - case 's': - return "stringValue"; - case 'd': - return "dateTimeValue"; - case 'f': - return "floatValue"; - default: - throw new IllegalArgumentException("Unknown property type: " + this); - } + case 's' -> "stringValue"; + case 'd' -> "dateTimeValue"; + case 'f' -> "floatValue"; + default -> throw new IllegalArgumentException("Unknown property type: " + this); + }; } } diff --git a/api/src/org/labkey/api/exp/property/DomainUtil.java b/api/src/org/labkey/api/exp/property/DomainUtil.java index c440d32c0ba..0152b74163d 100644 --- a/api/src/org/labkey/api/exp/property/DomainUtil.java +++ b/api/src/org/labkey/api/exp/property/DomainUtil.java @@ -117,7 +117,7 @@ import static org.labkey.api.data.ColumnRenderPropertiesImpl.TEXT_CHOICE_CONCEPT_URI; import static org.labkey.api.dataiterator.DetailedAuditLogDataIterator.AuditConfigs.AuditBehavior; -import static org.labkey.api.gwt.client.ui.PropertyType.CALCULATED_CONCEPT_URI; +import static org.labkey.api.exp.PropertyType.CALCULATED_CONCEPT_URI; import static org.labkey.api.util.StringExpressionFactory.SUBSTITUTION_EXP_PATTERN; public class DomainUtil diff --git a/api/gwtsrc/org/labkey/api/gwt/client/AuditBehaviorType.java b/api/src/org/labkey/api/gwt/client/AuditBehaviorType.java similarity index 96% rename from api/gwtsrc/org/labkey/api/gwt/client/AuditBehaviorType.java rename to api/src/org/labkey/api/gwt/client/AuditBehaviorType.java index e369374e6d1..0c8b2bd758d 100644 --- a/api/gwtsrc/org/labkey/api/gwt/client/AuditBehaviorType.java +++ b/api/src/org/labkey/api/gwt/client/AuditBehaviorType.java @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.api.gwt.client; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * User: klum - * Date: 10/17/12 - */ -public enum AuditBehaviorType -{ - NONE("None", 1), - DETAILED("Detailed", 3), - SUMMARY("Summary", 2); - - private final String _label; - private final int _priority; - - AuditBehaviorType(String label, int priority) - { - _label = label; - _priority = priority; - } - - public String getLabel() - { - return _label; - } - - public int getPriority() - { - return _priority; - } - - public static AuditBehaviorType getEffectiveAuditLevel(@Nullable AuditBehaviorType apiOverride, @NotNull AuditBehaviorType tableAuditBehaviorType) - { - if (apiOverride == null || apiOverride._priority < tableAuditBehaviorType._priority) - return tableAuditBehaviorType; - - return apiOverride; - } -} +/* + * Copyright (c) 2018-2019 LabKey Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.labkey.api.gwt.client; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * User: klum + * Date: 10/17/12 + */ +public enum AuditBehaviorType +{ + NONE("None", 1), + DETAILED("Detailed", 3), + SUMMARY("Summary", 2); + + private final String _label; + private final int _priority; + + AuditBehaviorType(String label, int priority) + { + _label = label; + _priority = priority; + } + + public String getLabel() + { + return _label; + } + + public int getPriority() + { + return _priority; + } + + public static AuditBehaviorType getEffectiveAuditLevel(@Nullable AuditBehaviorType apiOverride, @NotNull AuditBehaviorType tableAuditBehaviorType) + { + if (apiOverride == null || apiOverride._priority < tableAuditBehaviorType._priority) + return tableAuditBehaviorType; + + return apiOverride; + } +} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/DefaultScaleType.java b/api/src/org/labkey/api/gwt/client/DefaultScaleType.java similarity index 96% rename from api/gwtsrc/org/labkey/api/gwt/client/DefaultScaleType.java rename to api/src/org/labkey/api/gwt/client/DefaultScaleType.java index 187ef2755ab..929055e9d2b 100644 --- a/api/gwtsrc/org/labkey/api/gwt/client/DefaultScaleType.java +++ b/api/src/org/labkey/api/gwt/client/DefaultScaleType.java @@ -1,38 +1,38 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.api.gwt.client; - -/** - * User: cnathe - * Date: 3/18/14 - */ -public enum DefaultScaleType -{ - LINEAR("Linear"), - LOG("Log"); - - private final String _label; - - DefaultScaleType(String label) - { - _label = label; - } - - public String getLabel() - { - return _label; - } -} +/* + * Copyright (c) 2018-2019 LabKey Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.labkey.api.gwt.client; + +/** + * User: cnathe + * Date: 3/18/14 + */ +public enum DefaultScaleType +{ + LINEAR("Linear"), + LOG("Log"); + + private final String _label; + + DefaultScaleType(String label) + { + _label = label; + } + + public String getLabel() + { + return _label; + } +} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/DefaultValueType.java b/api/src/org/labkey/api/gwt/client/DefaultValueType.java similarity index 81% rename from api/gwtsrc/org/labkey/api/gwt/client/DefaultValueType.java rename to api/src/org/labkey/api/gwt/client/DefaultValueType.java index 6e033567f14..9f2798e8b10 100644 --- a/api/gwtsrc/org/labkey/api/gwt/client/DefaultValueType.java +++ b/api/src/org/labkey/api/gwt/client/DefaultValueType.java @@ -15,21 +15,16 @@ */ package org.labkey.api.gwt.client; -import com.google.gwt.user.client.rpc.IsSerializable; - import java.io.Serializable; -public enum DefaultValueType implements Serializable, IsSerializable +public enum DefaultValueType implements Serializable { FIXED_EDITABLE("Editable default", "An editable default value will be entered for the user. The default value will be the same for every user for every insert."), FIXED_NON_EDITABLE("Fixed value", "Fixed values cannot be edited by the user. This option is used to save fixed data with each inserted data row."), LAST_ENTERED("Last entered", "An editable default value will be entered for the user's first use of the form. During subsequent inserts, the user will see their last entered value as the default."); - private String _label; - private String _helpText; - - // Needed for GWT serialization to work correctly, at least in dev mode - DefaultValueType() {} + private final String _label; + private final String _helpText; DefaultValueType(String label, String helpText) { diff --git a/api/gwtsrc/org/labkey/api/gwt/client/FacetingBehaviorType.java b/api/src/org/labkey/api/gwt/client/FacetingBehaviorType.java similarity index 67% rename from api/gwtsrc/org/labkey/api/gwt/client/FacetingBehaviorType.java rename to api/src/org/labkey/api/gwt/client/FacetingBehaviorType.java index e8884d38c47..3b08697d4ff 100644 --- a/api/gwtsrc/org/labkey/api/gwt/client/FacetingBehaviorType.java +++ b/api/src/org/labkey/api/gwt/client/FacetingBehaviorType.java @@ -32,8 +32,6 @@ public enum FacetingBehaviorType private final String _label; private final String _helpText; - private static String _helpPopupHtml; - FacetingBehaviorType(String label, String helpText) { _label = label; @@ -49,21 +47,4 @@ public String getHelpText() { return _helpText; } - - public static String getHelpPopupHtml() - { - if (_helpPopupHtml == null) - { - StringBuilder helpString = new StringBuilder(); - for (int i = 0; i < values().length; i++) - { - FacetingBehaviorType type = values()[i]; - helpString.append("").append(type.getLabel()).append(": ").append(type.getHelpText()); - if (i < values().length - 1) - helpString.append("

"); - } - _helpPopupHtml = helpString.toString(); - } - return _helpPopupHtml; - } } diff --git a/api/gwtsrc/org/labkey/api/gwt/client/LockedPropertyType.java b/api/src/org/labkey/api/gwt/client/LockedPropertyType.java similarity index 100% rename from api/gwtsrc/org/labkey/api/gwt/client/LockedPropertyType.java rename to api/src/org/labkey/api/gwt/client/LockedPropertyType.java diff --git a/api/gwtsrc/org/labkey/api/gwt/client/assay/model/GWTProtocol.java b/api/src/org/labkey/api/gwt/client/assay/model/GWTProtocol.java similarity index 95% rename from api/gwtsrc/org/labkey/api/gwt/client/assay/model/GWTProtocol.java rename to api/src/org/labkey/api/gwt/client/assay/model/GWTProtocol.java index 6d79916061a..534a8dad52a 100644 --- a/api/gwtsrc/org/labkey/api/gwt/client/assay/model/GWTProtocol.java +++ b/api/src/org/labkey/api/gwt/client/assay/model/GWTProtocol.java @@ -16,7 +16,6 @@ package org.labkey.api.gwt.client.assay.model; -import com.google.gwt.user.client.rpc.IsSerializable; import org.apache.commons.lang3.StringUtils; import org.labkey.api.gwt.client.model.GWTContainer; import org.labkey.api.gwt.client.model.GWTDomain; @@ -33,7 +32,7 @@ * Date: Jun 20, 2007 * Time: 2:29:22 PM */ -public class GWTProtocol implements IsSerializable +public class GWTProtocol { private Long _protocolId; private String _name; @@ -229,7 +228,7 @@ private void handleStringTransformScripts(List protocolTransformScripts) public void setProtocolTransformScripts(List protocolTransformScripts) { if (!protocolTransformScripts.isEmpty()) { - Object first = protocolTransformScripts.get(0); + Object first = protocolTransformScripts.getFirst(); if (first instanceof Map) { handleMapTransformScripts((List>) protocolTransformScripts); } else if (first instanceof String) { diff --git a/api/gwtsrc/org/labkey/api/gwt/client/model/GWTConditionalFormat.java b/api/src/org/labkey/api/gwt/client/model/GWTConditionalFormat.java similarity index 89% rename from api/gwtsrc/org/labkey/api/gwt/client/model/GWTConditionalFormat.java rename to api/src/org/labkey/api/gwt/client/model/GWTConditionalFormat.java index 8200dd1bcc9..d23647d510f 100644 --- a/api/gwtsrc/org/labkey/api/gwt/client/model/GWTConditionalFormat.java +++ b/api/src/org/labkey/api/gwt/client/model/GWTConditionalFormat.java @@ -1,52 +1,51 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.api.gwt.client.model; - -import com.google.gwt.user.client.rpc.IsSerializable; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.Setter; - -import java.io.Serializable; - -@Getter -@Setter -@EqualsAndHashCode -public class GWTConditionalFormat implements Serializable, IsSerializable -{ - public static final String COLOR_REGEX = "[0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f]"; - public static final String DATA_REGION_NAME = "format"; - public static final String COLUMN_NAME = "column"; - - private boolean bold = false; - private boolean italic = false; - private boolean strikethrough = false; - private String textColor = null; - private String backgroundColor = null; - private String filter; - - public GWTConditionalFormat() {} - - public GWTConditionalFormat(GWTConditionalFormat f) - { - setBold(f.isBold()); - setItalic(f.isItalic()); - setStrikethrough(f.isStrikethrough()); - setTextColor(f.getTextColor()); - setBackgroundColor(f.getBackgroundColor()); - setFilter(f.getFilter()); - } -} +/* + * Copyright (c) 2018-2019 LabKey Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.labkey.api.gwt.client.model; + +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; + +@Getter +@Setter +@EqualsAndHashCode +public class GWTConditionalFormat implements Serializable +{ + public static final String COLOR_REGEX = "[0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f]"; + public static final String DATA_REGION_NAME = "format"; + public static final String COLUMN_NAME = "column"; + + private boolean bold = false; + private boolean italic = false; + private boolean strikethrough = false; + private String textColor = null; + private String backgroundColor = null; + private String filter; + + public GWTConditionalFormat() {} + + public GWTConditionalFormat(GWTConditionalFormat f) + { + setBold(f.isBold()); + setItalic(f.isItalic()); + setStrikethrough(f.isStrikethrough()); + setTextColor(f.getTextColor()); + setBackgroundColor(f.getBackgroundColor()); + setFilter(f.getFilter()); + } +} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/model/GWTContainer.java b/api/src/org/labkey/api/gwt/client/model/GWTContainer.java similarity index 95% rename from api/gwtsrc/org/labkey/api/gwt/client/model/GWTContainer.java rename to api/src/org/labkey/api/gwt/client/model/GWTContainer.java index 69be6fdd666..f78158b3b33 100644 --- a/api/gwtsrc/org/labkey/api/gwt/client/model/GWTContainer.java +++ b/api/src/org/labkey/api/gwt/client/model/GWTContainer.java @@ -1,70 +1,70 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.api.gwt.client.model; - -import java.io.Serializable; - -/** - * User: jeckels - * Date: Jan 28, 2011 - */ -public class GWTContainer implements Serializable -{ - private String _entityId; - private int _rowId; - private String _path; - private String _name; - - /** Required for GWT serialization */ - @SuppressWarnings({"UnusedDeclaration"}) - public GWTContainer() - { - } - - public GWTContainer(String entityId, int rowId, String path, String name) - { - _entityId = entityId; - _rowId = rowId; - _path = path; - _name = name; - } - - public String getEntityId() - { - return _entityId; - } - - public int getRowId() - { - return _rowId; - } - - public String getName() - { - return _name; - } - - public String getPath() - { - return _path; - } - - @Override - public String toString() - { - return getPath(); - } -} +/* + * Copyright (c) 2018-2019 LabKey Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.labkey.api.gwt.client.model; + +import java.io.Serializable; + +/** + * User: jeckels + * Date: Jan 28, 2011 + */ +public class GWTContainer implements Serializable +{ + private String _entityId; + private int _rowId; + private String _path; + private String _name; + + /** Required for GWT serialization */ + @SuppressWarnings({"UnusedDeclaration"}) + public GWTContainer() + { + } + + public GWTContainer(String entityId, int rowId, String path, String name) + { + _entityId = entityId; + _rowId = rowId; + _path = path; + _name = name; + } + + public String getEntityId() + { + return _entityId; + } + + public int getRowId() + { + return _rowId; + } + + public String getName() + { + return _name; + } + + public String getPath() + { + return _path; + } + + @Override + public String toString() + { + return getPath(); + } +} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/model/GWTDomain.java b/api/src/org/labkey/api/gwt/client/model/GWTDomain.java similarity index 87% rename from api/gwtsrc/org/labkey/api/gwt/client/model/GWTDomain.java rename to api/src/org/labkey/api/gwt/client/model/GWTDomain.java index 7fc753de0e5..dff37bf0349 100644 --- a/api/gwtsrc/org/labkey/api/gwt/client/model/GWTDomain.java +++ b/api/src/org/labkey/api/gwt/client/model/GWTDomain.java @@ -17,11 +17,9 @@ package org.labkey.api.gwt.client.model; import com.fasterxml.jackson.annotation.JsonIgnore; -import com.google.gwt.user.client.rpc.IsSerializable; import lombok.Getter; import lombok.Setter; import org.labkey.api.gwt.client.DefaultValueType; -import org.labkey.api.gwt.client.util.PropertyUtil; import java.util.ArrayList; import java.util.Collections; @@ -29,7 +27,7 @@ import java.util.List; import java.util.Set; -public class GWTDomain implements IsSerializable +public class GWTDomain { private String _ts; @Getter @Setter private int domainId; @@ -47,17 +45,25 @@ public class GWTDomain implements IsSer @Getter @Setter private boolean allowUniqueConstraintProperties; @Getter @Setter private boolean allowCalculatedFields; @Getter @Setter private boolean showDefaultValueSettings; + @Getter private DefaultValueType defaultDefaultValueType = null; + @Getter private DefaultValueType[] defaultValueOptions = new DefaultValueType[0]; private List fields = new ArrayList<>(); private List standardFields = null; private List calculatedFields = null; @Getter @Setter private List indices = new ArrayList<>(); + @Setter + @Getter private String defaultValuesURL = null; private Set mandatoryPropertyDescriptorNames = new HashSet<>(); + @Getter private Set reservedFieldNames = new HashSet<>(); + @Getter private Set reservedFieldNamePrefixes = new HashSet<>(); + @Getter private Set phiNotAllowedFieldNames = new HashSet<>(); + @Getter private Set excludeFromExportFieldNames = new HashSet<>(); @Getter @Setter private boolean provisioned = false; @Getter @Setter private List disabledSystemFields; @@ -203,11 +209,6 @@ public boolean isMandatoryField(FieldType field) return mandatoryPropertyDescriptorNames.contains(field.getName().toLowerCase()); } - public boolean isEditable(FieldType field) - { - return true; - } - /** * @return Indicates that the property is not allowed to be set as PHI */ @@ -238,11 +239,6 @@ public Set getMandatoryFieldNames() return Collections.unmodifiableSet(this.mandatoryPropertyDescriptorNames); } - public Set getReservedFieldNames() - { - return reservedFieldNames; - } - /** * @param reservedFieldNames can't create new fields with these names */ @@ -255,11 +251,6 @@ public void setReservedFieldNames(Set reservedFieldNames) } } - public Set getReservedFieldNamePrefixes() - { - return this.reservedFieldNamePrefixes; - } - public void setReservedFieldNamePrefixes(Set prefixes) { this.reservedFieldNamePrefixes = new HashSet<>(prefixes); @@ -277,11 +268,6 @@ public void setExcludeFromExportFieldNames(Set excludeFromExportFieldNam } } - public Set getExcludeFromExportFieldNames() - { - return excludeFromExportFieldNames; - } - public boolean isExcludeFromExportField(FieldType field) { if (excludeFromExportFieldNames == null || field.getName() == null) @@ -291,11 +277,6 @@ public boolean isExcludeFromExportField(FieldType field) return excludeFromExportFieldNames.contains(field.getName().toLowerCase()); } - public Set getPhiNotAllowedFieldNames() - { - return phiNotAllowedFieldNames; - } - public void setPhiNotAllowedFieldNames(Set phiNotAllowedFieldNames) { this.phiNotAllowedFieldNames = new HashSet<>(); @@ -305,31 +286,9 @@ public void setPhiNotAllowedFieldNames(Set phiNotAllowedFieldNames) } } - public DefaultValueType getDefaultDefaultValueType() - { - return defaultDefaultValueType; - } - - public DefaultValueType[] getDefaultValueOptions() - { - return defaultValueOptions; - } - public void setDefaultValueOptions(DefaultValueType[] defaultOptions, DefaultValueType defaultDefault) { this.defaultDefaultValueType = defaultDefault; this.defaultValueOptions = defaultOptions; } - - public String getDefaultValuesURL() - { - if (defaultValuesURL == null) - return PropertyUtil.getRelativeURL("setDefaultValuesList", "list"); - return defaultValuesURL; - } - - public void setDefaultValuesURL(String defaultValuesURL) - { - this.defaultValuesURL = defaultValuesURL; - } } diff --git a/api/gwtsrc/org/labkey/api/gwt/client/model/GWTFilterCriteria.java b/api/src/org/labkey/api/gwt/client/model/GWTFilterCriteria.java similarity index 83% rename from api/gwtsrc/org/labkey/api/gwt/client/model/GWTFilterCriteria.java rename to api/src/org/labkey/api/gwt/client/model/GWTFilterCriteria.java index 0dc50ead244..50723f69de0 100644 --- a/api/gwtsrc/org/labkey/api/gwt/client/model/GWTFilterCriteria.java +++ b/api/src/org/labkey/api/gwt/client/model/GWTFilterCriteria.java @@ -1,6 +1,5 @@ package org.labkey.api.gwt.client.model; -import com.google.gwt.user.client.rpc.IsSerializable; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; @@ -10,7 +9,7 @@ @Setter @Getter @EqualsAndHashCode -public class GWTFilterCriteria implements Serializable, IsSerializable +public class GWTFilterCriteria implements Serializable { private String name; private String op; diff --git a/api/gwtsrc/org/labkey/api/gwt/client/model/GWTIndex.java b/api/src/org/labkey/api/gwt/client/model/GWTIndex.java similarity index 95% rename from api/gwtsrc/org/labkey/api/gwt/client/model/GWTIndex.java rename to api/src/org/labkey/api/gwt/client/model/GWTIndex.java index 75e8030492d..60290fc4abf 100644 --- a/api/gwtsrc/org/labkey/api/gwt/client/model/GWTIndex.java +++ b/api/src/org/labkey/api/gwt/client/model/GWTIndex.java @@ -15,7 +15,6 @@ */ package org.labkey.api.gwt.client.model; -import com.google.gwt.user.client.rpc.IsSerializable; import org.apache.commons.lang3.StringUtils; import org.labkey.api.data.PropertyStorageSpec; @@ -30,7 +29,7 @@ * User: kevink * Date: 11/9/15 */ -public class GWTIndex implements IsSerializable, Serializable +public class GWTIndex implements Serializable { private List _columnNames; private boolean _unique; diff --git a/api/src/org/labkey/api/gwt/client/model/GWTPropertyDescriptor.java b/api/src/org/labkey/api/gwt/client/model/GWTPropertyDescriptor.java new file mode 100644 index 00000000000..d0feeeb6ccd --- /dev/null +++ b/api/src/org/labkey/api/gwt/client/model/GWTPropertyDescriptor.java @@ -0,0 +1,409 @@ +/* + * Copyright (c) 2018-2019 LabKey Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.labkey.api.gwt.client.model; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import org.apache.commons.lang3.StringUtils; +import org.labkey.api.gwt.client.DefaultScaleType; +import org.labkey.api.gwt.client.DefaultValueType; +import org.labkey.api.gwt.client.LockedPropertyType; + +import java.util.ArrayList; +import java.util.List; + +/** + * See {@link org.labkey.api.exp.PropertyDescriptor} + */ +@EqualsAndHashCode +public class GWTPropertyDescriptor +{ + @Setter + @Getter + private int propertyId = 0; + @Setter + @Getter + private String propertyURI; + @Setter + @Getter + private String container; + @Setter + @Getter + private String name; + @Setter + @Getter + private String description; + @Setter + @Getter + private String rangeURI = "http://www.w3.org/2001/XMLSchema#string"; + @Setter + @Getter + private String conceptURI; + @Setter + @Getter + private String label; + @Setter + @Getter + private String format; + @Setter + @Getter + private boolean required = false; + @Setter + @Getter + private boolean hidden = false; + @Getter + @Setter + private String lookupContainer; + @Setter + @Getter + private String lookupSchema; + @Setter + @Getter + private String lookupQuery; + @Setter + private boolean lookupIsValid = true; + private String defaultValueType = null; + @Setter + @Getter + private String defaultValue; + @Setter + @Getter + private String defaultDisplayValue = "[none]"; + @Setter + private boolean mvEnabled = false; + @Setter + @Getter + private String importAliases; + private String url; + private String urlTarget; + @Setter + @Getter + private boolean shownInInsertView = true; + @Setter + @Getter + private boolean shownInUpdateView = true; + @Setter + @Getter + private boolean shownInDetailsView = true; + private Boolean measure; + private Boolean dimension; + @Setter + @Getter + private boolean recommendedVariable = false; + @Setter + @Getter + private String defaultScale = DefaultScaleType.LINEAR.name(); + @Setter + @Getter + private String facetingBehaviorType; + private String phi = "NotPHI"; // Must match PHI.NotPHI and tableInfo.xsd enum PHIType.NotPHI + private Boolean isExcludeFromShifting; + @Setter + private boolean isPreventReordering = false; + @Setter + private boolean isDisableEditing = false; + @Setter + @Getter + private Integer scale = 4000; + @Setter + @Getter + private String principalConceptCode; + @Setter + @Getter + private String sourceOntology; + @Setter + @Getter + private String conceptSubtree; + @Setter + @Getter + private String conceptImportColumn; + @Setter + @Getter + private String conceptLabelColumn; + @Setter + @Getter + private String redactedText; + @Setter + @Getter + private String derivationDataScope; + private boolean isPrimaryKey = false; + /** + * -- SETTER -- + * This method is for informational purpose only so that the client can identify column's locked type. + * Setting lock type on a column via this method will not get preserved in the domain's table. + */ + @Setter + @Getter + private String lockType = LockedPropertyType.NotLocked.name(); + @Setter + @Getter + private boolean scannable = false; + @Setter + @Getter + private String valueExpression; + + @Getter @Setter private List conditionalFormats = new ArrayList<>(); + @Getter @Setter private List filterCriteria = new ArrayList<>(); + @Getter @Setter private List propertyValidators = new ArrayList<>(); + + public GWTPropertyDescriptor() + { + } + + public GWTPropertyDescriptor(String name, String rangeURI) + { + setName(name); + setRangeURI(rangeURI); + } + + public GWTPropertyDescriptor(GWTPropertyDescriptor s) + { + this(s, false); + } + + public GWTPropertyDescriptor(GWTPropertyDescriptor s, boolean isNew) + { + if (!isNew) + { + setPropertyId(s.getPropertyId()); + setPropertyURI(s.getPropertyURI()); + } + + setContainer(s.getContainer()); + setName(s.getName()); + setDescription(s.getDescription()); + setRangeURI(s.getRangeURI()); + setConceptURI(s.getConceptURI()); + setLabel(s.getLabel()); + setFormat(s.getFormat()); + setRequired(s.isRequired()); + setHidden(s.isHidden()); + setShownInDetailsView(s.isShownInDetailsView()); + setShownInInsertView(s.isShownInInsertView()); + setShownInUpdateView(s.isShownInUpdateView()); + setMvEnabled(s.getMvEnabled()); + setMeasure(s.isMeasure()); + setDimension(s.isDimension()); + setRecommendedVariable(s.isRecommendedVariable()); + setDefaultScale(s.getDefaultScale()); + setLookupContainer(s.getLookupContainer()); + setLookupIsValid(s.getLookupIsValid()); + setLookupSchema(s.getLookupSchema()); + setLookupQuery(s.getLookupQuery()); + setDefaultValueType(s.getDefaultValueType()); + setDefaultValue(s.getDefaultValue()); + setDefaultDisplayValue(s.getDefaultDisplayValue()); + setImportAliases(s.getImportAliases()); + setURL(s.getURL()); + setURLTarget(s.getURLTarget()); + setFacetingBehaviorType(s.getFacetingBehaviorType()); + setPHI(s.getPHI()); + setExcludeFromShifting(s.isExcludeFromShifting()); + setPreventReordering(s.getPreventReordering()); + setDisableEditing(s.getDisableEditing()); + setScale(s.getScale()); + setRedactedText(s.getRedactedText()); + setIsPrimaryKey(s.getIsPrimaryKey()); + setLockType(s.getLockType()); + setPrincipalConceptCode(s.getPrincipalConceptCode()); + setSourceOntology(s.getSourceOntology()); + setConceptSubtree(s.getConceptSubtree()); + setConceptImportColumn(s.getConceptImportColumn()); + setConceptLabelColumn(s.getConceptLabelColumn()); + setDerivationDataScope(s.getDerivationDataScope()); + setScannable(s.isScannable()); + setValueExpression(s.getValueExpression()); + + for (GWTPropertyValidator v : s.getPropertyValidators()) + { + GWTPropertyValidator gpv = new GWTPropertyValidator(v); + if (isNew) + { + gpv.setRowId(0); + gpv.setNew(true); + } + propertyValidators.add(gpv); + } + + for (GWTConditionalFormat f : s.getConditionalFormats()) + { + conditionalFormats.add(new GWTConditionalFormat(f)); + } + + for (GWTFilterCriteria fc : s.getFilterCriteria()) + { + filterCriteria.add(new GWTFilterCriteria(fc)); + } + } + + public GWTPropertyDescriptor copy() + { + return new GWTPropertyDescriptor(this); + } + + public boolean getLookupIsValid() + { + return lookupIsValid; + } + + @JsonIgnore + public boolean isSetMeasure() + { + return measure != null; + } + + public boolean isMeasure() + { + return measure != null && measure; + } + + public void setMeasure(boolean isMeasure) + { + this.measure = isMeasure; + } + + @JsonIgnore + public boolean isSetDimension() + { + return dimension != null; + } + + public boolean isDimension() + { + return dimension != null && dimension; + } + + public void setDimension(boolean isDimension) + { + this.dimension = isDimension; + } + + public boolean getMvEnabled() + { + return mvEnabled; + } + + public DefaultValueType getDefaultValueType() + { + return null==defaultValueType ? null : DefaultValueType.valueOf(defaultValueType); + } + + public void setDefaultValueType(DefaultValueType defaultValueType) + { + this.defaultValueType = null==defaultValueType ? null : defaultValueType.name(); + } + + @JsonProperty("PHI") + public String getPHI() + { + return phi; + } + + @JsonProperty("PHI") + public void setPHI(String phi) + { + this.phi = phi; + } + + @JsonIgnore + public boolean isSetExcludeFromShifting() + { + return isExcludeFromShifting != null; + } + + public boolean isExcludeFromShifting() + { + return isExcludeFromShifting != null && isExcludeFromShifting; + } + + public void setExcludeFromShifting(boolean isExcludeFromShifting) + { + this.isExcludeFromShifting = isExcludeFromShifting; + } + + public boolean getPreventReordering() + { + return isPreventReordering; + } + + public boolean getDisableEditing() + { + return isDisableEditing; + } + + public boolean getIsPrimaryKey() + { + return isPrimaryKey; + } + + /** This method is for informational purpose only so that the client can identify column as a PK column. + * Setting PK on a column via this method will not get preserved in the domain's table. + */ + public void setIsPrimaryKey(boolean isPrimaryKey) + { + this.isPrimaryKey = isPrimaryKey; + } + + @JsonProperty("URL") + public String getURL() + { + return url; + } + + @JsonProperty("URL") + public void setURL(String url) + { + this.url = url; + } + + @JsonProperty("URLTarget") + public String getURLTarget() + { + return urlTarget; + } + + @JsonProperty("URLTarget") + public void setURLTarget(String urlTarget) + { + this.urlTarget = urlTarget; + } + + @JsonIgnore + public String getLookupDescription() + { + if (StringUtils.isEmpty(getLookupSchema()) || StringUtils.isEmpty(getLookupQuery())) + return "(none)"; + + return getLookupSchema() + "." + getLookupQuery(); + } + + @Override + public String toString() + { + return name + ": " + rangeURI; + } + + @JsonIgnore + public boolean isFileType() + { + return "http://cpas.fhcrc.org/exp/xml#fileLink".equals(getRangeURI()) || + "http://www.labkey.org/exp/xml#attachment".equals(getRangeURI()); + } +} diff --git a/api/gwtsrc/org/labkey/api/gwt/client/model/GWTPropertyValidator.java b/api/src/org/labkey/api/gwt/client/model/GWTPropertyValidator.java similarity index 84% rename from api/gwtsrc/org/labkey/api/gwt/client/model/GWTPropertyValidator.java rename to api/src/org/labkey/api/gwt/client/model/GWTPropertyValidator.java index 2c0d9a24729..148a02dc191 100644 --- a/api/gwtsrc/org/labkey/api/gwt/client/model/GWTPropertyValidator.java +++ b/api/src/org/labkey/api/gwt/client/model/GWTPropertyValidator.java @@ -1,200 +1,201 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.api.gwt.client.model; - -import com.google.gwt.user.client.rpc.IsSerializable; -import org.labkey.api.gwt.client.util.PropertyUtil; -import org.labkey.api.gwt.client.util.StringUtils; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/* -* User: Karl Lum -* Date: Aug 8, 2008 -* Time: 3:49:42 PM -*/ -public class GWTPropertyValidator implements Serializable, IsSerializable -{ - private long _rowId; - private String _name; - private PropertyValidatorType _type; - private String _description; - private String _expression; - private String _errorMessage; - private boolean _isNew; - - private Map _properties = new HashMap<>(); - private Map> _extraProperties = new HashMap<>(); - - public GWTPropertyValidator() - { - _isNew = true; - } - - public GWTPropertyValidator(GWTPropertyValidator s) - { - _copyProperties(s, this); - } - - public void copy(GWTPropertyValidator s) - { - _copyProperties(s, this); - } - - private static void _copyProperties(GWTPropertyValidator s, GWTPropertyValidator d) - { - d.setRowId(s.getRowId()); - d.setName(s.getName()); - d.setType(s.getType()); - d.setDescription(s.getDescription()); - d.setExpression(s.getExpression()); - d.setErrorMessage(s.getErrorMessage()); - d.getProperties().putAll(s.getProperties()); - d.setNew(s.isNew()); - } - - public long getRowId() - { - return _rowId; - } - - public void setRowId(long rowId) - { - _rowId = rowId; - } - - public String getName() - { - return _name; - } - - public void setName(String name) - { - _name = name; - } - - public PropertyValidatorType getType() - { - return _type; - } - - public void setType(PropertyValidatorType type) - { - _type = type; - } - - public String getDescription() - { - return _description; - } - - public void setDescription(String description) - { - _description = description; - } - - public String getExpression() - { - return _expression; - } - - public void setExpression(String expression) - { - _expression = expression; - } - - public String getErrorMessage() - { - return _errorMessage; - } - - public void setErrorMessage(String errorMessage) - { - _errorMessage = errorMessage; - } - - public Map getProperties() - { - return _properties; - } - - public void setProperties(Map properties) - { - _properties = properties; - } - - public Map> getExtraProperties() - { - return _extraProperties; - } - - public void setExtraProperties(Map> extraProperties) - { - _extraProperties = extraProperties; - } - - public boolean isNew() - { - return _isNew; - } - - public void setNew(boolean aNew) - { - _isNew = aNew; - } - - public void validate(List errors) - { - if (StringUtils.trimToNull(getName()) == null) - errors.add("Validator Name cannot be blank"); - if (StringUtils.trimToNull(getExpression()) == null) - errors.add("Validator Expression cannot be blank"); - } - - public boolean equals(Object o) - { - if (this == o) return true; - if (o == null) return false; - if (!(o instanceof GWTPropertyValidator that)) - return false; - - if (getRowId() != that.getRowId()) return false; - if (!StringUtils.equals(getName(), that.getName())) return false; - if (!PropertyUtil.nullSafeEquals(getType(), that.getType())) return false; - if (!StringUtils.equals(getDescription(), that.getDescription())) return false; - if (!StringUtils.equals(getExpression(), that.getExpression())) return false; - if (!StringUtils.equals(getErrorMessage(), that.getErrorMessage())) return false; - if (!getProperties().equals(that.getProperties())) return false; - - return true; - } - - public int hashCode() - { - int result = (int)getRowId(); - result = 31 * result + (getName() != null ? getName().hashCode() : 0); - result = 31 * result + (getType() != null ? getType().hashCode() : 0); - result = 31 * result + (getDescription() != null ? getDescription().hashCode() : 0); - result = 31 * result + (getExpression() != null ? getExpression().hashCode() : 0); - result = 31 * result + (getErrorMessage() != null ? getErrorMessage().hashCode() : 0); - result = 31 * result + (getProperties() != null ? getProperties().hashCode() : 0); - - return result; - } +/* + * Copyright (c) 2018-2019 LabKey Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.labkey.api.gwt.client.model; + +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Strings; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/* +* User: Karl Lum +* Date: Aug 8, 2008 +* Time: 3:49:42 PM +*/ +public class GWTPropertyValidator implements Serializable +{ + private long _rowId; + private String _name; + private PropertyValidatorType _type; + private String _description; + private String _expression; + private String _errorMessage; + private boolean _isNew; + + private Map _properties = new HashMap<>(); + private Map> _extraProperties = new HashMap<>(); + + public GWTPropertyValidator() + { + _isNew = true; + } + + public GWTPropertyValidator(GWTPropertyValidator s) + { + _copyProperties(s, this); + } + + public void copy(GWTPropertyValidator s) + { + _copyProperties(s, this); + } + + private static void _copyProperties(GWTPropertyValidator s, GWTPropertyValidator d) + { + d.setRowId(s.getRowId()); + d.setName(s.getName()); + d.setType(s.getType()); + d.setDescription(s.getDescription()); + d.setExpression(s.getExpression()); + d.setErrorMessage(s.getErrorMessage()); + d.getProperties().putAll(s.getProperties()); + d.setNew(s.isNew()); + } + + public long getRowId() + { + return _rowId; + } + + public void setRowId(long rowId) + { + _rowId = rowId; + } + + public String getName() + { + return _name; + } + + public void setName(String name) + { + _name = name; + } + + public PropertyValidatorType getType() + { + return _type; + } + + public void setType(PropertyValidatorType type) + { + _type = type; + } + + public String getDescription() + { + return _description; + } + + public void setDescription(String description) + { + _description = description; + } + + public String getExpression() + { + return _expression; + } + + public void setExpression(String expression) + { + _expression = expression; + } + + public String getErrorMessage() + { + return _errorMessage; + } + + public void setErrorMessage(String errorMessage) + { + _errorMessage = errorMessage; + } + + public Map getProperties() + { + return _properties; + } + + public void setProperties(Map properties) + { + _properties = properties; + } + + public Map> getExtraProperties() + { + return _extraProperties; + } + + public void setExtraProperties(Map> extraProperties) + { + _extraProperties = extraProperties; + } + + public boolean isNew() + { + return _isNew; + } + + public void setNew(boolean aNew) + { + _isNew = aNew; + } + + public void validate(List errors) + { + if (StringUtils.trimToNull(getName()) == null) + errors.add("Validator Name cannot be blank"); + if (StringUtils.trimToNull(getExpression()) == null) + errors.add("Validator Expression cannot be blank"); + } + + public boolean equals(Object o) + { + if (this == o) return true; + if (o == null) return false; + if (!(o instanceof GWTPropertyValidator that)) + return false; + + if (getRowId() != that.getRowId()) return false; + if (!Strings.CS.equals(getName(), that.getName())) return false; + Object o1 = getType(); + if (!Objects.equals(o1, that.getType())) return false; + if (!Strings.CS.equals(getDescription(), that.getDescription())) return false; + if (!Strings.CS.equals(getExpression(), that.getExpression())) return false; + if (!Strings.CS.equals(getErrorMessage(), that.getErrorMessage())) return false; + if (!getProperties().equals(that.getProperties())) return false; + + return true; + } + + public int hashCode() + { + int result = (int)getRowId(); + result = 31 * result + (getName() != null ? getName().hashCode() : 0); + result = 31 * result + (getType() != null ? getType().hashCode() : 0); + result = 31 * result + (getDescription() != null ? getDescription().hashCode() : 0); + result = 31 * result + (getExpression() != null ? getExpression().hashCode() : 0); + result = 31 * result + (getErrorMessage() != null ? getErrorMessage().hashCode() : 0); + result = 31 * result + (getProperties() != null ? getProperties().hashCode() : 0); + + return result; + } } \ No newline at end of file diff --git a/api/gwtsrc/org/labkey/api/gwt/client/model/PropertyValidatorType.java b/api/src/org/labkey/api/gwt/client/model/PropertyValidatorType.java similarity index 60% rename from api/gwtsrc/org/labkey/api/gwt/client/model/PropertyValidatorType.java rename to api/src/org/labkey/api/gwt/client/model/PropertyValidatorType.java index 845826d6466..70b1803782c 100644 --- a/api/gwtsrc/org/labkey/api/gwt/client/model/PropertyValidatorType.java +++ b/api/src/org/labkey/api/gwt/client/model/PropertyValidatorType.java @@ -1,143 +1,109 @@ -/* - * Copyright (c) 2018-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.api.gwt.client.model; - -import org.labkey.api.gwt.client.ui.HelpPopup; - -/** - * User: jeckels - * Date: Oct 10, 2010 - */ -public enum PropertyValidatorType -{ - RegEx - { - @Override - public String getLabel() - { - return "RegEx Validator"; - } - - @Override - public HelpPopup createHelpPopup() - { - return new HelpPopup(getLabel(), "RegEx validators allow you to specify a regular expression that defines what string values are valid"); - } - }, - Range - { - @Override - public String getLabel() - { - return "Range Validator"; - } - - @Override - public HelpPopup createHelpPopup() - { - return new HelpPopup(getLabel(), "Range validators allow you to specify numeric comparisons that must be satisfied, such as the value must be greater than or less than some constant"); - } - }, - Lookup - { - @Override - public String getLabel() - { - return "Lookup Validator"; - } - - @Override - public HelpPopup createHelpPopup() - { - return new HelpPopup(getLabel(), "Lookup validators allow you to require that any value is present in the lookup's target table or query"); - } - - @Override - public boolean isConfigurable() - { - return false; - } - }, - TextLength - { - @Override - public String getLabel() - { - return "Length Validator"; - } - - @Override - public HelpPopup createHelpPopup() - { - return new HelpPopup(getLabel(), "Length validators allow you to validate the length of a text field"); - } - @Override - public boolean isConfigurable() - { - return false; - } - @Override - public boolean isHidden() - { - return true; - } - }, - TextChoice - { - @Override - public String getLabel() - { - return "Text Choice Validator"; - } - - @Override - public HelpPopup createHelpPopup() - { - return new HelpPopup(getLabel(), "Text Choice validators allow you to specify a set of text values that are used to constrain values for a given domain field, like a light-weight lookup."); - } - }; - - public abstract HelpPopup createHelpPopup(); - - public abstract String getLabel(); - - public String getTypeName() - { - return toString().toLowerCase(); - } - - public boolean isConfigurable() - { - return true; - } - - public boolean isHidden() - { - return false; - } - - public static PropertyValidatorType getType(String typeName) - { - for (PropertyValidatorType type : values()) - { - if (type.getTypeName().equals(typeName)) - { - return type; - } - } - return null; - } -} +/* + * Copyright (c) 2018-2019 LabKey Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.labkey.api.gwt.client.model; + +/** + * User: jeckels + * Date: Oct 10, 2010 + */ +public enum PropertyValidatorType +{ + RegEx + { + @Override + public String getLabel() + { + return "RegEx Validator"; + } + }, + Range + { + @Override + public String getLabel() + { + return "Range Validator"; + } + }, + Lookup + { + @Override + public String getLabel() + { + return "Lookup Validator"; + } + + @Override + public boolean isConfigurable() + { + return false; + } + }, + TextLength + { + @Override + public String getLabel() + { + return "Length Validator"; + } + @Override + public boolean isConfigurable() + { + return false; + } + @Override + public boolean isHidden() + { + return true; + } + }, + TextChoice + { + @Override + public String getLabel() + { + return "Text Choice Validator"; + } + }; + + public abstract String getLabel(); + + public String getTypeName() + { + return toString().toLowerCase(); + } + + public boolean isConfigurable() + { + return true; + } + + public boolean isHidden() + { + return false; + } + + public static PropertyValidatorType getType(String typeName) + { + for (PropertyValidatorType type : values()) + { + if (type.getTypeName().equals(typeName)) + { + return type; + } + } + return null; + } +} diff --git a/api/src/org/labkey/api/gwt/server/BaseRemoteService.java b/api/src/org/labkey/api/gwt/server/BaseRemoteService.java deleted file mode 100644 index 16ef58e9145..00000000000 --- a/api/src/org/labkey/api/gwt/server/BaseRemoteService.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2008-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.api.gwt.server; - -import com.google.gwt.user.server.rpc.jakarta.RemoteServiceServlet; -import org.labkey.api.data.Container; -import org.labkey.api.data.ContainerManager; -import org.labkey.api.module.ModuleLoader; -import org.labkey.api.security.User; -import org.labkey.api.settings.LookAndFeelProperties; -import org.labkey.api.util.ExceptionUtil; -import org.labkey.api.view.ActionURL; -import org.labkey.api.view.UnauthorizedException; -import org.labkey.api.view.ViewContext; - -import jakarta.servlet.ServletConfig; -import jakarta.servlet.ServletContext; -import jakarta.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.Enumeration; -import java.util.Vector; - -/** - * User: brittp - * Date: Feb 2, 2007 - * Time: 2:30:51 PM - */ -public abstract class BaseRemoteService extends RemoteServiceServlet -{ - protected ViewContext _context; - public BaseRemoteService(ViewContext context) - { - _context = context; - } - - public Container getContainer() - { - return _context.getContainer(); - } - - public User getUser() - { - return _context.getUser(); - } - - public ActionURL getActionURL() - { - return _context.getActionURL(); - } - - @Override - public String getServletName() - { - return getServletConfig().getServletName(); - } - - @Override - public ServletConfig getServletConfig() - { - return new ServletConfig() - { - @Override - public String getInitParameter(String string) - { - return null; - } - - @Override - public Enumeration getInitParameterNames() - { - return new Vector().elements(); - } - - @Override - public ServletContext getServletContext() - { - return ModuleLoader.getServletContext(); - } - - @Override - public String getServletName() - { - return "BaseRemoteService"; - } - }; - } - - @Override - protected void doUnexpectedFailure(Throwable failure) - { - failure = ExceptionUtil.unwrapException(failure); - ExceptionUtil.logExceptionToMothership(getThreadLocalRequest(), failure); - - HttpServletResponse response = getThreadLocalResponse(); - try - { - int status = HttpServletResponse.SC_INTERNAL_SERVER_ERROR; - if (failure instanceof UnauthorizedException) - { - response.setHeader("WWW-Authenticate", "Basic realm=\"" + LookAndFeelProperties.getInstance(ContainerManager.getRoot()).getDescription() + "\""); - status = HttpServletResponse.SC_UNAUTHORIZED; - } - response.setContentType("text/plain"); - response.setStatus(status); - response.getWriter().write("There was an error processing the request."); - if (failure.getMessage() != null) - { - response.getWriter().write("\n" + failure.getMessage()); - } - response.getWriter().write("\n(Error type: " + failure.getClass().getName() + ")"); - } - catch (IOException e) - { - // Give up - } - catch (IllegalStateException e) - { - // Give up, response is already committed - } - - } - - public ViewContext getViewContext() - { - return _context; - } -} diff --git a/api/src/org/labkey/api/ontology/Ontology.java b/api/src/org/labkey/api/ontology/Ontology.java index 90afb47df33..9f2275148fb 100644 --- a/api/src/org/labkey/api/ontology/Ontology.java +++ b/api/src/org/labkey/api/ontology/Ontology.java @@ -1,9 +1,9 @@ package org.labkey.api.ontology; +import org.jetbrains.annotations.NotNull; import org.labkey.api.data.Container; import org.labkey.api.data.ContainerManager; -import jakarta.validation.constraints.NotNull; import java.util.Date; public interface Ontology // extends Entity diff --git a/api/src/org/labkey/api/pipeline/PipelineJob.java b/api/src/org/labkey/api/pipeline/PipelineJob.java index 534d5ad3c57..9f8678cc278 100644 --- a/api/src/org/labkey/api/pipeline/PipelineJob.java +++ b/api/src/org/labkey/api/pipeline/PipelineJob.java @@ -40,7 +40,6 @@ import org.labkey.api.assay.AssayFileWriter; import org.labkey.api.data.Container; import org.labkey.api.exp.api.ExpRun; -import org.labkey.api.gwt.client.util.PropertyUtil; import org.labkey.api.pipeline.file.FileAnalysisJobSupport; import org.labkey.api.query.FieldKey; import org.labkey.api.query.QueryKey; @@ -1977,28 +1976,28 @@ public List compareJobs(PipelineJob job2) { PipelineJob job1 = this; List errors = new ArrayList<>(); - if (!PropertyUtil.nullSafeEquals(job1._activeTaskId, job2._activeTaskId)) + if (!com.google.api.client.util.Objects.equal(job1._activeTaskId, job2._activeTaskId)) errors.add("_activeTaskId"); if (job1._activeTaskRetries != job2._activeTaskRetries) errors.add("_activeTaskRetries"); - if (!PropertyUtil.nullSafeEquals(job1._activeTaskStatus, job2._activeTaskStatus)) + if (!com.google.api.client.util.Objects.equal(job1._activeTaskStatus, job2._activeTaskStatus)) errors.add("_activeTaskStatus"); if (job1._errors != job2._errors) errors.add("_errors"); if (job1._interrupted != job2._interrupted) errors.add("_interrupted"); - if (!PropertyUtil.nullSafeEquals(job1._jobGUID, job2._jobGUID)) + if (!com.google.api.client.util.Objects.equal(job1._jobGUID, job2._jobGUID)) errors.add("_jobGUID"); - if (!PropertyUtil.nullSafeEquals(job1._logFile, job2._logFile)) + if (!com.google.api.client.util.Objects.equal(job1._logFile, job2._logFile)) { if (null == job1._logFile || null == job2._logFile) errors.add("_logFile"); else if (!FileUtil.getAbsoluteCaseSensitiveFile(job1._logFile.toFile()).getAbsolutePath().equalsIgnoreCase(FileUtil.getAbsoluteCaseSensitiveFile(job2._logFile.toFile()).getAbsolutePath())) errors.add("_logFile"); } - if (!PropertyUtil.nullSafeEquals(job1._parentGUID, job2._parentGUID)) + if (!com.google.api.client.util.Objects.equal(job1._parentGUID, job2._parentGUID)) errors.add("_parentGUID"); - if (!PropertyUtil.nullSafeEquals(job1._provider, job2._provider)) + if (!com.google.api.client.util.Objects.equal(job1._provider, job2._provider)) errors.add("_provider"); if (job1._submitted != job2._submitted) errors.add("_submitted"); diff --git a/api/src/org/labkey/api/query/CrosstabExcelWriter.java b/api/src/org/labkey/api/query/CrosstabExcelWriter.java index 64c57ca45cd..d842c99a2ce 100644 --- a/api/src/org/labkey/api/query/CrosstabExcelWriter.java +++ b/api/src/org/labkey/api/query/CrosstabExcelWriter.java @@ -19,6 +19,7 @@ import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Row.MissingCellPolicy; import org.apache.poi.ss.usermodel.Sheet; +import org.jetbrains.annotations.NotNull; import org.labkey.api.data.CrosstabMember; import org.labkey.api.data.CrosstabTableInfo; import org.labkey.api.data.DisplayColumn; @@ -27,7 +28,6 @@ import org.labkey.api.data.ResultsFactory; import org.labkey.api.util.Pair; -import jakarta.validation.constraints.NotNull; import java.util.List; /** diff --git a/api/src/org/labkey/api/query/FilteredTable.java b/api/src/org/labkey/api/query/FilteredTable.java index 3219fcdab59..88c81138e08 100644 --- a/api/src/org/labkey/api/query/FilteredTable.java +++ b/api/src/org/labkey/api/query/FilteredTable.java @@ -62,7 +62,7 @@ import java.util.Set; import java.util.stream.Collectors; -import static org.labkey.api.gwt.client.ui.PropertyType.PARTICIPANT_CONCEPT_URI; +import static org.labkey.api.exp.PropertyType.PARTICIPANT_CONCEPT_URI; /** * A table that filters down to a particular set of rows from an underlying, wrapped table/subquery. A typical example diff --git a/api/src/org/labkey/api/study/query/PublishResultsQueryView.java b/api/src/org/labkey/api/study/query/PublishResultsQueryView.java index 1c2c6db2ceb..634db325c71 100644 --- a/api/src/org/labkey/api/study/query/PublishResultsQueryView.java +++ b/api/src/org/labkey/api/study/query/PublishResultsQueryView.java @@ -40,9 +40,9 @@ import org.labkey.api.data.Table; import org.labkey.api.data.UpdateColumn; import org.labkey.api.exp.ExperimentException; +import org.labkey.api.exp.PropertyType; import org.labkey.api.exp.api.ExpRun; import org.labkey.api.exp.api.ExperimentService; -import org.labkey.api.gwt.client.ui.PropertyType; import org.labkey.api.query.FieldKey; import org.labkey.api.query.QueryService; import org.labkey.api.query.QuerySettings; @@ -1041,7 +1041,7 @@ protected List getExtraColumns(Collection selectColum { //NOTE: the name of the assay PTID field might not always match ParticipantId. this allows us to also //support PARTICIPANT_CONCEPT_URI - ColumnInfo ptidCol = selectColumns.stream().filter(c -> PropertyType.PARTICIPANT_CONCEPT_URI.equals(c.getConceptURI())).findFirst().orElse(null); + ColumnInfo ptidCol = selectColumns.stream().filter(c -> org.labkey.api.exp.PropertyType.PARTICIPANT_CONCEPT_URI.equals(c.getConceptURI())).findFirst().orElse(null); if (ptidCol != null) linkedColumnMap.put(LinkToStudyKeys.ParticipantId, ptidCol); } diff --git a/api/src/org/labkey/api/util/ExceptionUtil.java b/api/src/org/labkey/api/util/ExceptionUtil.java index 402eddb58b7..0a28c89becf 100644 --- a/api/src/org/labkey/api/util/ExceptionUtil.java +++ b/api/src/org/labkey/api/util/ExceptionUtil.java @@ -163,7 +163,7 @@ public static Throwable unwrapException(@NotNull Throwable ex) ex = cause; cause = null; - if (ex.getClass() == RuntimeException.class || ex.getClass() == UnexpectedException.class || ex.getClass() == RuntimeSQLException.class || ex instanceof InvocationTargetException || ex instanceof com.google.gwt.user.server.rpc.UnexpectedException) + if (ex.getClass() == RuntimeException.class || ex.getClass() == UnexpectedException.class || ex.getClass() == RuntimeSQLException.class || ex instanceof InvocationTargetException) { cause = ex.getCause(); } @@ -1611,7 +1611,7 @@ public void sendRedirect(String s) } @Override - public void sendRedirect(String s, int i, boolean b) throws IOException + public void sendRedirect(String s, int i, boolean b) { redirect = s; } diff --git a/api/src/org/labkey/api/util/OptionBuilder.java b/api/src/org/labkey/api/util/OptionBuilder.java index 8c2f3733ff9..58c4ab0efa9 100644 --- a/api/src/org/labkey/api/util/OptionBuilder.java +++ b/api/src/org/labkey/api/util/OptionBuilder.java @@ -1,6 +1,6 @@ package org.labkey.api.util; -import jakarta.validation.constraints.NotNull; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public class OptionBuilder implements HasHtmlString, SafeToRender diff --git a/api/src/org/labkey/api/view/GWTView.java b/api/src/org/labkey/api/view/GWTView.java deleted file mode 100644 index 2d1da04ae7f..00000000000 --- a/api/src/org/labkey/api/view/GWTView.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2008-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.api.view; - -import com.google.gwt.core.client.EntryPoint; -import org.labkey.api.compliance.ComplianceService; -import org.labkey.api.usageMetrics.SimpleMetricsService; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -/** - * Wrapper around a GWT (Google Web Toolkit) module that knows how to render into the overall HTML of the page. - */ -public class GWTView extends JspView -{ - public static final String PROPERTIES_OBJECT_NAME = "LABKEY.GWTProperties"; - - public static class GWTViewBean - { - private final String _moduleName; - private final Map _properties; - - public GWTViewBean(String moduleName, Map properties) - { - _moduleName = moduleName; - _properties = new HashMap<>(properties); - } - - public void init(ViewContext context) - { - // Use Core as the catch-all to consolidate reporting, even though GWT uses are distributed across modules - SimpleMetricsService.get().increment("Core", "GWTView", context.getActionURL().getController() + "-" + context.getActionURL().getAction()); - - _properties.put("container", context.getContainer().getPath()); - _properties.put("controller", context.getActionURL().getController()); - _properties.put("action", context.getActionURL().getAction()); - _properties.put("queryString", context.getActionURL().getQueryString()); - _properties.put("contextPath", context.getContextPath()); - _properties.put("header1Size", "16px"); - _properties.put("loadingStyle", ""); - - _properties.put("maxAllowedPhi", ComplianceService.get().getMaxAllowedPhi(context.getContainer(), context.getUser()).name()); - } - - public String getModuleName() - { - return _moduleName; - } - - public Map getProperties() - { - return _properties; - } - - public String getLoadingStyleName() - { - return _properties.get("loadingStyle"); - } - - public void setLoadingStyleName(String name) - { - _properties.put("loadingStyle", name); - } - } - - private static String convertClassToModuleName(Class c) - { - String name = c.getName(); - int index = name.indexOf(".client."); - if (index != -1) - { - name = name.substring(0, index) + name.substring(index + ".client.".length() - 1); - } - return name; - } - - public GWTView(Class moduleClass, Map properties) - { - this(convertClassToModuleName(moduleClass), properties); - } - - public GWTView(String moduleName, Map properties) - { - super("/org/labkey/api/view/GWTView.jsp", new GWTViewBean(moduleName, properties)); - getModelBean().init(getViewContext()); - getModulesForRootContext().add(moduleName); - } - - public static Set getModulesForRootContext() - { - //Not synchronized since view rendering is single threaded - Set gwtModules = (Set) HttpView.getRootContext().get("gwtModules"); - if (null == gwtModules) - { - gwtModules = new HashSet<>(); - HttpView.getRootContext().put("gwtModules", gwtModules); - } - - return gwtModules; - } -} diff --git a/api/src/org/labkey/api/view/GWTView.jsp b/api/src/org/labkey/api/view/GWTView.jsp deleted file mode 100644 index fc3da72a77f..00000000000 --- a/api/src/org/labkey/api/view/GWTView.jsp +++ /dev/null @@ -1,35 +0,0 @@ -<% -/* - * Copyright (c) 2008-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -%> -<%@ page import="org.json.JSONObject" %> -<%@ page import="org.labkey.api.view.GWTView" %> -<%@ page import="org.labkey.api.view.HttpView" %> -<%@ page extends="org.labkey.api.jsp.JspBase"%> -<% - HttpView me = HttpView.currentView(); - GWTView.GWTViewBean bean = me.getModelBean(); -%> -
-<% -String jsPath = bean.getModuleName() + "/" + bean.getModuleName() + ".nocache.js"; -%> - -<%=getScriptTag(jsPath)%> - diff --git a/assay/gwtsrc/gwt/AssayApplication.gwt.xml b/assay/gwtsrc/gwt/AssayApplication.gwt.xml deleted file mode 100644 index 0e66d7c545b..00000000000 --- a/assay/gwtsrc/gwt/AssayApplication.gwt.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/assay/gwtsrc/gwt/client/org/labkey/assay/AssayApplication.java b/assay/gwtsrc/gwt/client/org/labkey/assay/AssayApplication.java deleted file mode 100644 index fcda0059d86..00000000000 --- a/assay/gwtsrc/gwt/client/org/labkey/assay/AssayApplication.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2010-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package gwt.client.org.labkey.assay; - -import com.google.gwt.core.client.EntryPoint; -import com.google.gwt.core.client.GWT; -import com.google.gwt.core.client.RunAsyncCallback; -import com.google.gwt.user.client.ui.RootPanel; -import org.labkey.api.gwt.client.util.ErrorDialogAsyncCallback; -import org.labkey.api.gwt.client.util.PropertyUtil; - -import java.util.HashSet; -import java.util.Set; - -/** - * User: matthewb - * Date: Mar 31, 2010 - * Time: 1:59:56 PM - */ -public class AssayApplication implements EntryPoint -{ - /** - * As of 2.4.0, the GWT compiler NPEs if you pass an enum value in to GWT.runAsync(). Therefore, this is enum-like - * but not an actual enum anymore. - */ - public abstract static class GWTModule implements RunAsyncCallback - { - public final String className; - - private static final Set MODULES = new HashSet<>(); - - static - { - MODULES.add(new TemplateDesigner()); - } - - GWTModule(String clss) - { - this.className = clss; - } - - abstract EntryPoint getEntryPoint(); - - // - // RunAsyncCallback - // - @Override - public void onFailure(Throwable caught) - { - ErrorDialogAsyncCallback.showDialog(caught, "Failed to load code for module: " + getClass()); - } - - public static Set values() - { - return MODULES; - } - } - - public static class TemplateDesigner extends GWTModule - { - public TemplateDesigner() - { - super("gwt.client.org.labkey.plate.designer.client.TemplateDesigner"); - } - - @Override - public void onSuccess() - { - new gwt.client.org.labkey.plate.designer.client.TemplateDesigner().onModuleLoad(); - } - - @Override - EntryPoint getEntryPoint() - { - return new gwt.client.org.labkey.plate.designer.client.TemplateDesigner(); - } - } - - - public static RootPanel getRootPanel() - { - String name = PropertyUtil.getServerProperty("RootPanel"); - if (null == name) - name = "gwt.AssayApplication-Root"; - return RootPanel.get(name); - } - - - @Override - public void onModuleLoad() - { - RootPanel panel = getRootPanel(); - if (null != panel) - { - panel.getElement().setInnerHTML(""); - } - - final String moduleName = PropertyUtil.getServerProperty("GWTModule"); - - if ("TemplateDesigner".equalsIgnoreCase(moduleName)) - { - GWT.runAsync(new TemplateDesigner()); - } - else - { - throw new IllegalArgumentException("Unknown module: " + moduleName); - } - } -} diff --git a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/GroupChangeListener.java b/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/GroupChangeListener.java deleted file mode 100644 index 04ac813d65f..00000000000 --- a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/GroupChangeListener.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2010 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package gwt.client.org.labkey.plate.designer.client; - -import gwt.client.org.labkey.plate.designer.client.model.GWTWellGroup; - -/** - * User: brittp - * Date: Feb 7, 2007 - * Time: 4:17:33 PM - */ -public interface GroupChangeListener -{ - void groupAdded(GWTWellGroup group); - - void groupRemoved(GWTWellGroup group); - - void activeGroupChanged(GWTWellGroup previouslyActive, GWTWellGroup currentlyActive); - - void activeGroupTypeChanged(String type); -} diff --git a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/GroupChangeListenerAdapter.java b/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/GroupChangeListenerAdapter.java deleted file mode 100644 index a6cb185bea0..00000000000 --- a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/GroupChangeListenerAdapter.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2010 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package gwt.client.org.labkey.plate.designer.client; - -import gwt.client.org.labkey.plate.designer.client.model.GWTWellGroup; - -/** - * User: brittp - * Date: Feb 9, 2007 - * Time: 12:28:27 PM - */ -public abstract class GroupChangeListenerAdapter implements GroupChangeListener -{ - @Override - public void activeGroupChanged(GWTWellGroup previouslyActive, GWTWellGroup currentlyActive) - { - } - - @Override - public void groupAdded(GWTWellGroup group) - { - } - - @Override - public void groupRemoved(GWTWellGroup group) - { - } - - @Override - public void activeGroupTypeChanged(String type) - { - } -} diff --git a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/GroupTypePanel.java b/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/GroupTypePanel.java deleted file mode 100644 index 54c7c43509f..00000000000 --- a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/GroupTypePanel.java +++ /dev/null @@ -1,314 +0,0 @@ -/* - * Copyright (c) 2010-2018 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package gwt.client.org.labkey.plate.designer.client; - -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; -import com.google.gwt.event.dom.client.KeyCodes; -import com.google.gwt.event.dom.client.KeyDownEvent; -import com.google.gwt.event.dom.client.KeyDownHandler; -import com.google.gwt.event.dom.client.KeyUpEvent; -import com.google.gwt.event.dom.client.KeyUpHandler; -import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.DeferredCommand; -import com.google.gwt.user.client.IncrementalCommand; -import com.google.gwt.user.client.Window; -import com.google.gwt.user.client.ui.DialogBox; -import com.google.gwt.user.client.ui.FlexTable; -import com.google.gwt.user.client.ui.HorizontalPanel; -import com.google.gwt.user.client.ui.Label; -import com.google.gwt.user.client.ui.ListBox; -import com.google.gwt.user.client.ui.ScrollPanel; -import com.google.gwt.user.client.ui.TextBox; -import com.google.gwt.user.client.ui.Widget; -import gwt.client.org.labkey.plate.designer.client.model.GWTWellGroup; -import org.labkey.api.gwt.client.ui.BoundTextBox; -import org.labkey.api.gwt.client.ui.ImageButton; -import org.labkey.api.gwt.client.util.StringProperty; - -import java.util.List; -import java.util.Map; - -public class GroupTypePanel extends ScrollPanel implements GroupChangeListener -{ - private final TemplateView _view; - private final String _type; - - private String _newGroupFieldValue; - private ImageButton _createButton; - private ImageButton _multiCreateButton; - private boolean _allowNewGroups; - - public GroupTypePanel(TemplateView view, String type) - { - _type = type; - _view = view; - _view.addGroupListener(this); - redraw(); - } - - public void redraw() - { - clear(); - List wellgroups = _view.getPlate().getTypeToGroupsMap().get(_type); - FlexTable groupList = new FlexTable(); - groupList.setCellPadding(5); - if (wellgroups != null) - { - int i=0; - _allowNewGroups = wellgroups.isEmpty(); - for (GWTWellGroup group : wellgroups) - { - if (!_allowNewGroups && group.isAllowNewGroups()) - _allowNewGroups = true; - - GroupTypePanelRow row = new GroupTypePanelRow(_view, group); - row.attach(groupList, i++); - } - } - else - { - _allowNewGroups = true; - groupList.setWidget(0, 1, new Label("No groups defined.")); - } - add(groupList); - - KeyDownHandler fieldKeyDownListener = new KeyDownHandler() - { - @Override - public void onKeyDown(KeyDownEvent event) - { - if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) - { - // we might want to remove this capability (create wellgroup using keyboard ENTER), the later - // versions of GWT don't allow access to the raw value and the current behavior is components - // don't update their value until a blur event - _view.createWellGroup(_newGroupFieldValue, _type); - } - } - }; - - KeyUpHandler fieldKeyUpListener = new KeyUpHandler() - { - @Override - public void onKeyUp(KeyUpEvent event) - { - _createButton.setEnabled(true); - _multiCreateButton.setEnabled(true); - } - }; - - _createButton = new ImageButton("Create"); - _createButton.setEnabled(false); - _createButton.addClickHandler(new ClickHandler() - { - @Override - public void onClick(ClickEvent event) - { - _view.createWellGroup(_newGroupFieldValue, _type); - } - }); - - _multiCreateButton = new ImageButton("Create multiple..."); - _multiCreateButton.addClickHandler(new ClickHandler() - { - @Override - public void onClick(ClickEvent event) - { - String defaultBaseName = _newGroupFieldValue; - - MultiCreatePopupPanel multiCreatePanel = new MultiCreatePopupPanel(_view, defaultBaseName, _type); - multiCreatePanel.center(); - multiCreatePanel.show(); - } - }); - - // if the group type is furnishing any default group names, populate them into a combo box - // else just use a text field - Map> typeToGroupMap = _view.getPlate().getTypesToDefaultGroups(); - Widget newGroupField; - - if (!typeToGroupMap.containsKey(_type)) - { - final TextBox textField = new TextBox(); - DOM.setElementAttribute(textField.getElement(), "name", "wellGroupName"); - DOM.setElementAttribute(textField.getElement(), "data-type", _type); - - textField.addKeyDownHandler(fieldKeyDownListener); - textField.addKeyUpHandler(fieldKeyUpListener); - textField.addChangeHandler(changeEvent -> { - TextBox source = (TextBox) changeEvent.getSource(); - _newGroupFieldValue = source.getValue(); - }); - - newGroupField = textField; - } - else - { - List defaults = typeToGroupMap.get(_type); - final ListBox selector = new ListBox(); - - selector.addKeyDownHandler(fieldKeyDownListener); - selector.addKeyUpHandler(fieldKeyUpListener); - selector.addChangeHandler(changeEvent -> { - ListBox source = (ListBox)changeEvent.getSource(); - _newGroupFieldValue = source.getSelectedValue(); - - boolean enable = (!_newGroupFieldValue.isEmpty()); - - _createButton.setEnabled(enable); - _multiCreateButton.setEnabled(enable); - }); - - for (String name : defaults) - selector.addItem(name); - - selector.setItemSelected(0, true); - _newGroupFieldValue = defaults.get(0); - _createButton.setEnabled(true); - - newGroupField = selector; - } - - if (_allowNewGroups) - { - groupList.setWidget(groupList.getRowCount(), 0, new Label("New:")); - groupList.setWidget(groupList.getRowCount() - 1, 1, newGroupField); - groupList.setWidget(groupList.getRowCount() - 1, 2, _createButton); - groupList.setWidget(groupList.getRowCount() - 1, 3, _multiCreateButton); - } - } - - private static class MultiCreatePopupPanel extends DialogBox - { - StringProperty _count = new StringProperty("2"); - StringProperty _baseName = new StringProperty(); - public MultiCreatePopupPanel(final TemplateView view, final String baseName, final String type) - { - super(true, false); - _baseName.set(baseName); - setText("Create Multiple Groups"); - int row = 0; - FlexTable options = new FlexTable(); - - ImageButton createButton = new ImageButton("Create"); - createButton.addClickHandler(new ClickHandler() - { - @Override - public void onClick(ClickEvent event) - { - try - { - final int count = Integer.parseInt(_count.getString()); - MultiCreatePopupPanel.this.clear(); - final Label status = new Label("Creating " + _baseName + " 1..."); - MultiCreatePopupPanel.this.add(status); - // Use a deferred command to allow the UI to update after each well group is added: - DeferredCommand.addCommand(new IncrementalCommand() - { - private int _created = 0; - @Override - public boolean execute() - { - String groupName = _baseName + " " + (_created + 1); - view.createWellGroup(groupName, type); - if (++_created < count) - { - // Set the status for the next item. The UI will refresh now, after we return, but before - // the next item is created. The more intuitive approach of setting the status right before - // the call to createWellGroup doesn't work, since the UI won't refresh between the calls. - status.setText("Creating " + _baseName + " " + (_created + 1) + "..."); - return true; - } - else - { - MultiCreatePopupPanel.this.hide(); - return false; - } - } - }); - } - catch (NumberFormatException e) - { - Window.alert("\"" + _count.getString() + "\" is not a valid count."); - } - } - }); - - ImageButton cancelButton = new ImageButton("Cancel"); - cancelButton.addClickHandler(new ClickHandler() - { - @Override - public void onClick(ClickEvent event) - { - MultiCreatePopupPanel.this.hide(); - } - }); - - options.setWidget(row, 0, new Label("Base Name")); - options.setWidget(row++, 1, new BoundTextBox("Base Name", "baseName", _baseName)); - - options.setWidget(row, 0, new Label("Count")); - options.setWidget(row++, 1, new BoundTextBox("Count", "createCount", _count) - { - @Override - protected String validateValue(String text) - { - try - { - int count = Integer.parseInt(text); - return super.validateValue(text); - } - catch (NumberFormatException e) - { - return "\"" + text + "\" is not a valid count."; - } - } - }); - - HorizontalPanel buttonBar = new HorizontalPanel(); - buttonBar.add(cancelButton); - buttonBar.add(createButton); - options.setWidget(row++, 1, buttonBar); - add(options); - } - - } - - - @Override - public void activeGroupChanged(GWTWellGroup previouslyActive, GWTWellGroup currentlyActive) - { - } - - @Override - public void activeGroupTypeChanged(String type) - { - } - - @Override - public void groupAdded(GWTWellGroup group) - { - redraw(); - } - - @Override - public void groupRemoved(GWTWellGroup group) - { - redraw(); - } -} diff --git a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/GroupTypePanelRow.java b/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/GroupTypePanelRow.java deleted file mode 100644 index 2701dc33343..00000000000 --- a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/GroupTypePanelRow.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (c) 2010 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package gwt.client.org.labkey.plate.designer.client; - -import com.google.gwt.user.client.ui.*; -import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.Window; -import com.google.gwt.user.client.Element; -import gwt.client.org.labkey.plate.designer.client.model.GWTWellGroup; -import org.labkey.api.gwt.client.ui.ImageButton; -import org.labkey.api.gwt.client.ui.TextBoxDialogBox; - -/** - * User: brittp - * Date: Feb 7, 2007 - * Time: 3:28:08 PM - */ -public class GroupTypePanelRow extends GroupChangeListenerAdapter -{ - private final TemplateView _view; - private final GWTWellGroup _group; - private FocusPanel _colorPanel; - private Element _tableRowElement; - private RadioButton _radioButton; - private ImageButton _deleteButton; - private ImageButton _renameButton; - - public GroupTypePanelRow(TemplateView view, GWTWellGroup group) - { - _view = view; - _group = group; - } - - public void attach(FlexTable parent, int row) - { - int col = 0; - - _view.addGroupListener(this); - _colorPanel = new FocusPanel(); - DOM.setStyleAttribute(_colorPanel.getElement(), "border", "1px solid white"); - DOM.setStyleAttribute(_colorPanel.getElement(), "backgroundColor", "#" + _view.getColor(_group)); - _colorPanel.setSize("35px", "25px"); - parent.setWidget(row, col++, _colorPanel); - - MouseListener hoverListener = new MouseListenerAdapter() - { - @Override - public void onMouseEnter(Widget sender) - { - DOM.setStyleAttribute(_colorPanel.getElement(), "border", "1px solid black"); - _view.setHighlightGroup(_group, true); - } - - @Override - public void onMouseLeave(Widget sender) - { - DOM.setStyleAttribute(_colorPanel.getElement(), "border", "1px solid white"); - _view.setHighlightGroup(_group, false); - } - }; - - ClickListener clickListener = new ClickListener() - { - @Override - public void onClick(Widget sender) - { - _view.setActiveGroup(_group); - } - }; - - _colorPanel.addClickListener(clickListener); - - _radioButton = new RadioButton("wellGroup", _group.getName()); - FocusPanel radioButtonFocusPanel = new FocusPanel(); - radioButtonFocusPanel.addMouseListener(hoverListener); - radioButtonFocusPanel.add(_radioButton); - parent.setWidget(row, col++, radioButtonFocusPanel); - _radioButton.addClickListener(clickListener); - - _colorPanel.addMouseListener(hoverListener); - - _deleteButton = new ImageButton("Delete"); - _deleteButton.setVisible(false); - _deleteButton.addClickListener(new ClickListener() - { - @Override - public void onClick(Widget sender) - { - if (Window.confirm("Delete well group \"" + _group.getName() + "\"?")) - _view.deleteWellGroup(_group); - } - }); - parent.setWidget(row, col++, _deleteButton); - - _renameButton = new ImageButton("Rename"); - _renameButton.setVisible(false); - _renameButton.addClickListener(new ClickListener() - { - @Override - public void onClick(Widget sender) - { - TextBoxDialogBox dialog = new TextBoxDialogBox("Rename Well Group", "Name") - { - @Override - protected boolean commit(String value) - { - if (value.isEmpty()) - { - Window.alert("You must specify a well group name."); - return false; - } - _group.setName(value); - _radioButton.setText(value); - _view.markAsDirty(); - return true; - } - }; - dialog.show(_group.getName()); - } - }); - parent.setWidget(row, col++, _renameButton); - - _tableRowElement = parent.getRowFormatter().getElement(row); - } - - @Override - public void activeGroupChanged(GWTWellGroup previouslyActive, GWTWellGroup currentlyActive) - { - if (_group == currentlyActive) - { - _radioButton.setChecked(true); - // if this group is effectively not editable never show delete and rename buttons - if (_group.isAllowNewGroups()) - { - _deleteButton.setVisible(true); - _renameButton.setVisible(true); - } - DOM.setStyleAttribute(_tableRowElement, "backgroundColor", "#DDDDDD"); - DOM.setStyleAttribute(_tableRowElement, "border", "1px solid black"); - } - else if (_group == previouslyActive) - { - _radioButton.setChecked(false); - _deleteButton.setVisible(false); - _renameButton.setVisible(false); - DOM.setStyleAttribute(_tableRowElement, "backgroundColor", "#FFFFFF"); - DOM.setStyleAttribute(_tableRowElement, "border", "1px solid white"); - } - } -} diff --git a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/GroupTypesTabPanel.java b/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/GroupTypesTabPanel.java deleted file mode 100644 index 23365ed08c4..00000000000 --- a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/GroupTypesTabPanel.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (c) 2010-2016 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package gwt.client.org.labkey.plate.designer.client; - -import com.google.gwt.event.dom.client.MouseDownEvent; -import com.google.gwt.event.dom.client.MouseDownHandler; -import com.google.gwt.event.dom.client.MouseMoveEvent; -import com.google.gwt.event.dom.client.MouseMoveHandler; -import com.google.gwt.event.dom.client.MouseUpEvent; -import com.google.gwt.event.dom.client.MouseUpHandler; -import com.google.gwt.user.client.ui.FocusPanel; -import com.google.gwt.user.client.ui.HasHorizontalAlignment; -import com.google.gwt.user.client.ui.HorizontalPanel; -import com.google.gwt.user.client.ui.TabPanel; -import com.google.gwt.user.client.ui.TabListener; -import com.google.gwt.user.client.ui.SourcesTabEvents; -import com.google.gwt.user.client.ui.Grid; - -import java.util.List; - -/** - * User: brittp - * Date: Feb 7, 2007 - * Time: 11:14:32 AM - */ -public class GroupTypesTabPanel extends TabPanel -{ - private final TemplateView _view; - private final List _types; - private int _gridTab = -1; - - public GroupTypesTabPanel(TemplateView view) - { - setHeight("100%"); - _view = view; - _types = view.getPlate().getGroupTypes(); - for (String type : _types) - { - Grid tabPanelGrid = new Grid(2, 1); - HorizontalPanel lowerPane = new HorizontalPanel(); - lowerPane.setWidth("100%"); - lowerPane.add(new GroupTypePanel(view, type)); - ShiftPanel shifter = new ShiftPanel(view); - lowerPane.add(shifter); - lowerPane.setCellHorizontalAlignment(shifter, HasHorizontalAlignment.ALIGN_RIGHT); - tabPanelGrid.setWidget(1, 0, lowerPane); - add(tabPanelGrid, type); - } - selectTab(0); - addTabListener(new TabListener() - { - @Override - public boolean onBeforeTabSelected(SourcesTabEvents sender, int tabIndex) - { - return true; - } - - @Override - public void onTabSelected(SourcesTabEvents sender, int tabIndex) - { - _view.setActiveType(_types.get(tabIndex)); - moveGrid(tabIndex); - } - }); - } - - @Override - public void selectTab(int index) - { - super.selectTab(index); - moveGrid(index); - } - - private void moveGrid(int selectedTab) - { - if (_gridTab >= 0) - { - Grid prevPanel = (Grid) getDeckPanel().getWidget(_gridTab); - prevPanel.remove(_view.getGrid()); - } - Grid currentPanel = (Grid) getDeckPanel().getWidget(selectedTab); - - TemplateGrid wellGrid = _view.getGrid(); - // Use a focus panel to prevent mouse events within the grid from being propagated to the browser. - // This is necessary to enable click and drag functionality that doesn't perform browser-provided text selection. - FocusPanel focusPanel = new FocusPanel(wellGrid); - focusPanel.addMouseDownHandler(new MouseDownHandler() - { - @Override - public void onMouseDown(MouseDownEvent event) - { - event.preventDefault(); - } - }); - focusPanel.addMouseUpHandler(new MouseUpHandler() - { - @Override - public void onMouseUp(MouseUpEvent event) - { - event.preventDefault(); - } - }); - focusPanel.addMouseMoveHandler(new MouseMoveHandler() - { - @Override - public void onMouseMove(MouseMoveEvent event) - { - event.preventDefault(); - } - }); - - currentPanel.setWidget(0, 0, focusPanel); - _gridTab = selectedTab; - } - - public void redraw() - { - Grid panel = (Grid) getWidget(getTabBar().getSelectedTab()); - GroupTypePanel typesPanel = (GroupTypePanel) panel.getWidget(1, 0); - typesPanel.redraw(); - } -} diff --git a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/PlateDataService.java b/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/PlateDataService.java deleted file mode 100644 index a94e4956645..00000000000 --- a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/PlateDataService.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2010-2015 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package gwt.client.org.labkey.plate.designer.client; - -import com.google.gwt.user.client.rpc.RemoteService; -import com.google.gwt.user.client.rpc.SerializableException; -import gwt.client.org.labkey.plate.designer.client.model.GWTPlate; - -/** - * User: brittp -* Date: Jan 31, 2007 -* Time: 2:37:12 PM -*/ -public interface PlateDataService extends RemoteService -{ - GWTPlate getTemplateDefinition(String templateName, int plateId, String assayTypeName, String templateTypeName, int rowCount, int columnCount, boolean copyTemplate) throws SerializableException, Exception; - - long saveChanges(GWTPlate plate, boolean replaceIfExisting) throws SerializableException, Exception; - -} diff --git a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/PlateDataServiceAsync.java b/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/PlateDataServiceAsync.java deleted file mode 100644 index 34e0431f2d0..00000000000 --- a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/PlateDataServiceAsync.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2010-2015 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package gwt.client.org.labkey.plate.designer.client; - -import com.google.gwt.user.client.rpc.AsyncCallback; -import gwt.client.org.labkey.plate.designer.client.model.GWTPlate; - -/** - * User: brittp - * Date: Jan 31, 2007 - * Time: 2:37:25 PM - */ -public interface PlateDataServiceAsync -{ - void getTemplateDefinition(String templateName, int plateId, String assayTypeName, String templateTypeName, int rowCount, int columnCount, boolean copyTemplate, AsyncCallback async); - - void saveChanges(GWTPlate plate, boolean replaceIfExisting, AsyncCallback async); -} diff --git a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/PlatePropertyPanel.java b/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/PlatePropertyPanel.java deleted file mode 100644 index 28dc45a9fd2..00000000000 --- a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/PlatePropertyPanel.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2010 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package gwt.client.org.labkey.plate.designer.client; - -/** - * User: jeckels - * Date: Apr 19, 2007 - */ -public class PlatePropertyPanel extends PropertyPanel -{ - public PlatePropertyPanel(TemplateView templateView) - { - super(templateView); - redraw(templateView.getPlate().getPlateProperties()); - } -} diff --git a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/PropertyCreationDialog.java b/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/PropertyCreationDialog.java deleted file mode 100644 index be63aad1b90..00000000000 --- a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/PropertyCreationDialog.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2010 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package gwt.client.org.labkey.plate.designer.client; - -import com.google.gwt.user.client.Window; -import org.labkey.api.gwt.client.ui.TextBoxDialogBox; - -/** - * User: jeckels - * Date: Apr 20, 2007 - */ -public class PropertyCreationDialog extends TextBoxDialogBox -{ - private final PropertyPanel _panel; - - public PropertyCreationDialog(PropertyPanel panel) - { - super("Add Property", "Name"); - _panel = panel; - } - - @Override - protected boolean commit(String propName) - { - if (propName.isEmpty()) - { - Window.alert("You must specify a property name."); - return false; - } - return _panel.addProperty(propName); - } -} diff --git a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/PropertyPanel.java b/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/PropertyPanel.java deleted file mode 100644 index 283feb3f454..00000000000 --- a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/PropertyPanel.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Copyright (c) 2010-2011 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package gwt.client.org.labkey.plate.designer.client; - -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; -import com.google.gwt.user.client.ui.*; -import com.google.gwt.user.client.Window; -import com.google.gwt.user.client.DOM; - -import java.util.*; - -import org.labkey.api.gwt.client.ui.ImageButton; -import org.labkey.api.gwt.client.util.PropertyUtil; - -/** - * User: brittp - * Date: Feb 8, 2007 - * Time: 1:23:51 PM - */ -@SuppressWarnings("Convert2Diamond") -public abstract class PropertyPanel extends DockPanel -{ - private final TemplateView _view; - private final FlexTable _propertyTable; - private Map _propertyTextBoxes; - - private final ChangeListener _changeListener = new ChangeListener() - { - @Override - public void onChange(Widget sender) - { - _view.markAsDirty(); - } - }; - - private final KeyboardListener _keyboardListener = new KeyboardListenerAdapter() - { - @Override - public void onKeyPress(Widget sender, char keyCode, int modifiers) - { - _view.markAsDirty(); - } - }; - - private final MouseListenerAdapter _tooltipListener = new MouseListenerAdapter() - { - private final PopupPanel _tooltip = new PopupPanel(true); - { - _tooltip.add(new Label("Delete")); - _tooltip.setStyleName("labkey-form-label"); - } - - @Override - public void onMouseEnter(Widget sender) - { - _tooltip.show(); - int width = _tooltip.getOffsetWidth(); - _tooltip.setPopupPosition(sender.getAbsoluteLeft() - width - 10, sender.getAbsoluteTop()); - } - - @Override - public void onMouseLeave(Widget sender) - { - _tooltip.hide(); - } - }; - private final ImageButton _addPropertyButton; - - public PropertyPanel(TemplateView view) - { - _view = view; - _propertyTable = new FlexTable(); - add(_propertyTable, CENTER); - - _addPropertyButton = new ImageButton("Add a new property"); - _addPropertyButton.addClickHandler(new ClickHandler() - { - @Override - public void onClick(ClickEvent e) - { - PropertyCreationDialog dialog = new PropertyCreationDialog(PropertyPanel.this); - dialog.show(); - } - }); - } - - public void redraw(String message) - { - _propertyTable.clear(); - _propertyTextBoxes = new HashMap(); - _propertyTable.setWidget(0, 0, new Label(message)); - addNewPropertyButton(1); - _addPropertyButton.setEnabled(false); - } - - public Map getProperties() - { - Map result = new HashMap(); - for (String name : _propertyTextBoxes.keySet()) - result.put(name, ((TextBox) _propertyTextBoxes.get(name)).getText()); - return result; - } - - public void redraw(Map properties) - { - _propertyTable.clear(); - while (_propertyTable.getRowCount() > 0) - { - _propertyTable.removeRow(0); - } - _propertyTextBoxes = new HashMap(); - int row = 0; - if (properties != null) - { - List names = new ArrayList(properties.keySet()); - Collections.sort(names, String.CASE_INSENSITIVE_ORDER); - for (String name : names) - { - Object value = properties.get(name); - insertPropertyRow(row, name, value); - row++; - } - } - addNewPropertyButton(row); - _addPropertyButton.setEnabled(true); - } - - private void addNewPropertyButton(int row) - { - _propertyTable.setWidget(row, 0, _addPropertyButton); - _propertyTable.getFlexCellFormatter().setColSpan(row, 0, 3); - } - - private void insertPropertyRow(int row, final String name, Object value) - { - _propertyTable.setWidget(row, 0, new Label(name)); - _propertyTable.getFlexCellFormatter().setStyleName(row, 0, "labkey-form-label"); - TextBox textBox = new TextBox(); - DOM.setElementAttribute(textBox.getElement(), "id", "property-" + name); - textBox.addChangeListener(_changeListener); - textBox.addKeyboardListener(_keyboardListener); - if (value != null) - { - textBox.setText(value.toString()); - } - _propertyTable.setWidget(row, 1, textBox); - final Image image = new Image(PropertyUtil.getContextPath() + "/_images/partdelete.gif"); - image.addMouseListener(_tooltipListener); - image.addClickHandler(new ClickHandler() - { - @Override - public void onClick(ClickEvent e) - { - deleteProperty(name); - } - }); - _propertyTable.setWidget(row, 2, image); - _propertyTextBoxes.put(name, textBox); - } - - private void deleteProperty(String name) - { - for (int i = 0; i < _propertyTable.getRowCount(); i++) - { - Widget widget = _propertyTable.getWidget(i, 0); - if (widget instanceof Label && ((Label)widget).getText().equals(name)) - { - _propertyTextBoxes.remove(name); - _propertyTable.removeRow(i); - _view.markAsDirty(); - return; - } - } - } - - public boolean addProperty(String propName) - { - if (getProperties().containsKey(propName)) - { - Window.alert("There is already a property with that name."); - return false; - } - - int rowIndex = _propertyTable.insertRow(_propertyTable.getRowCount() - 1); - insertPropertyRow(rowIndex, propName, ""); - _view.markAsDirty(); - return true; - } -} diff --git a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/ShiftPanel.java b/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/ShiftPanel.java deleted file mode 100644 index a5fbe9896c5..00000000000 --- a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/ShiftPanel.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2010-2012 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package gwt.client.org.labkey.plate.designer.client; - -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; -import com.google.gwt.user.client.ui.FlexTable; -import com.google.gwt.user.client.ui.HasHorizontalAlignment; -import com.google.gwt.user.client.ui.Label; -import com.google.gwt.user.client.ui.Widget; -import gwt.client.org.labkey.plate.designer.client.model.GWTPosition; -import gwt.client.org.labkey.plate.designer.client.model.GWTWellGroup; -import org.labkey.api.gwt.client.ui.ImageButton; - -/** - * User: brittp - * Date: Aug 9, 2010 5:56:35 PM - */ -public class ShiftPanel extends FlexTable -{ - private final TemplateView _view; - - private class ShiftButton extends ImageButton - { - public ShiftButton(String text, final int vertical, final int horizontal) - { - super(text); - addClickHandler(new ClickHandler() - { - @Override - public void onClick(ClickEvent event) - { - shift(vertical, horizontal); - } - }); - } - } - - public ShiftPanel(TemplateView view) - { - _view = view; - addCenteredWidget(0, 1, new ShiftButton("Up", 1, 0)); - addCenteredWidget(2, 1, new ShiftButton("Down", -1, 0)); - addCenteredWidget(1, 2, new ShiftButton("Right", 0, -1)); - addCenteredWidget(1, 0, new ShiftButton("Left", 0, 1)); - Label shiftLabel = new Label("Shift"); - shiftLabel .setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); - addCenteredWidget(1, 1,shiftLabel); - } - - private void addCenteredWidget(int row, int column, Widget widget) - { - setWidget(row, column, widget); - getFlexCellFormatter().setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_CENTER); - } - - private void shift(int verticalShift, int horizontalShift) - { - TemplateGrid grid = _view.getGrid(); - GWTWellGroup[][] snapshot = new GWTWellGroup[grid.getTemplateGridRowCount()][grid.getTemplateGridColumnCount()]; - for (int row = 0; row < snapshot.length; row++) - { - for (int col = 0; col < snapshot[row].length; col++) - { - snapshot[row][col] = grid.getTemplateGridCell(new GWTPosition(row, col)).getActiveGroup(); - } - } - - for (int row = 0; row < snapshot.length; row++) - { - for (int col = 0; col < snapshot[row].length; col++) - { - int sourceRow = (row + verticalShift) % grid.getTemplateGridRowCount(); - if (sourceRow < 0) - sourceRow += grid.getTemplateGridRowCount(); - int sourceCol = (col + horizontalShift) % grid.getTemplateGridColumnCount(); - if (sourceCol < 0) - sourceCol += grid.getTemplateGridColumnCount(); - GWTWellGroup newGroup = snapshot[sourceRow][sourceCol]; - grid.getTemplateGridCell(new GWTPosition(row, col)).replaceActiveGroup(newGroup); - } - } - _view.refreshWarningsAsync(); - } -} diff --git a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/StatusBar.java b/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/StatusBar.java deleted file mode 100644 index 45ba5191c79..00000000000 --- a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/StatusBar.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (c) 2010-2012 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package gwt.client.org.labkey.plate.designer.client; - -import com.google.gwt.user.client.Timer; -import com.google.gwt.user.client.ui.HorizontalPanel; -import com.google.gwt.user.client.ui.Label; -import com.google.gwt.user.client.ui.SimplePanel; -import org.labkey.api.gwt.client.ui.SaveButtonBar; -import org.labkey.api.gwt.client.ui.Saveable; -import org.labkey.api.gwt.client.ui.WindowUtil; -import org.labkey.api.gwt.client.util.ErrorDialogAsyncCallback; -import org.labkey.api.gwt.client.util.PropertyUtil; - -/** - * User: brittp - * Date: Feb 8, 2007 - * Time: 3:35:16 PM - */ -public class StatusBar extends HorizontalPanel implements Saveable -{ - private final String _doneLink; - private final SaveButtonBar _saveButtonBar; - - private final TemplateView _view; - private final Label _statusLabel; - private final Timer _clearTimer; - private boolean _dirty; - - public StatusBar(TemplateView view, final String doneLink) - { - _doneLink = doneLink; - - _view = view; - - _saveButtonBar = new SaveButtonBar(this); - add(_saveButtonBar); - - _statusLabel = new Label(); - SimplePanel spacer = new SimplePanel(); - spacer.setWidth("10px"); - add(spacer); - - add(_statusLabel); - setCellVerticalAlignment(_statusLabel, ALIGN_MIDDLE); - _clearTimer = new Timer() - { - @Override - public void run() - { - _statusLabel.setText(""); - } - }; - setDirty(false); - } - - @Override - public void cancel() - { - // We're already listening for navigation if the dirty bit is set, - // so no extra handling is needed. - String loc = PropertyUtil.getContextPath() + "/Project" + PropertyUtil.getContainerPath() + "/begin.view"; - WindowUtil.setLocation(loc); - } - - @Override - public void save(final SaveListener listener) - { - _view.saveChanges(new ErrorDialogAsyncCallback() - { - @Override - public void onSuccess(Long result) - { - setDirty(false); - if (listener != null) - listener.saveSuccessful(listener, PropertyUtil.getCurrentURL()); - } - }); - - } - - @Override - public void finish() - { - save(new SaveListener() - { - @Override - public void saveSuccessful(Object result, String designerUrl) - { - if (_doneLink != null && !_doneLink.isEmpty()) - WindowUtil.setLocation(_doneLink); - else - cancel(); - } - }); - } - - @Override - public String getCurrentURL() - { - return PropertyUtil.getCurrentURL(); - } - - @Override - public void save() - { - save(null); - } - - public void setDirty(boolean dirty) - { - _dirty = dirty; - _saveButtonBar.setAllowSave(dirty); - } - - @Override - public boolean isDirty() - { - return _dirty; - } - - public void setStatus(String status) - { - setStatus(status, 5); - } - - public void setStatus(String status, int secondsToDisplay) - { - _statusLabel.setText(status); - if (secondsToDisplay > 0) - _clearTimer.schedule(secondsToDisplay * 1000); - } -} diff --git a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/TemplateDesigner.java b/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/TemplateDesigner.java deleted file mode 100644 index 2ec383eb78b..00000000000 --- a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/TemplateDesigner.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2010-2015 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package gwt.client.org.labkey.plate.designer.client; - -import com.google.gwt.core.client.EntryPoint; -import com.google.gwt.user.client.ui.RootPanel; -import gwt.client.org.labkey.assay.AssayApplication; -import org.labkey.api.gwt.client.util.PropertyUtil; - -/** - * User: brittp - * Date: Jan 30, 2007 - * Time: 1:59:01 PM - */ -public class TemplateDesigner implements EntryPoint -{ - private int getIntProperty(String name, int defaultValue) - { - try - { - return Integer.parseInt(PropertyUtil.getServerProperty(name)); - } - catch (NumberFormatException e) - { - return defaultValue; - } - } - - @Override - public void onModuleLoad() - { - RootPanel panel = AssayApplication.getRootPanel(); - String templateName = PropertyUtil.getServerProperty("templateName"); - int plateId = PropertyUtil.getServerProperty("plateId") != null ? Integer.parseInt(PropertyUtil.getServerProperty("plateId")) : 0; - String assayTypeName = PropertyUtil.getServerProperty("assayTypeName"); - String templateTypeName = PropertyUtil.getServerProperty("templateTypeName"); - int rowCount = getIntProperty("templateRowCount", 8); - int colCount = getIntProperty("templateColumnCount", 12); - TemplateView view = new TemplateView(panel, plateId, templateName, assayTypeName, templateTypeName, rowCount, colCount); - view.showAsync(); - } -} diff --git a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/TemplateGrid.java b/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/TemplateGrid.java deleted file mode 100644 index ed98de91521..00000000000 --- a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/TemplateGrid.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2010-2012 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package gwt.client.org.labkey.plate.designer.client; - -import com.google.gwt.user.client.ui.*; -import com.google.gwt.user.client.DOM; - -import java.util.Set; -import java.util.List; -import java.util.ArrayList; - -import gwt.client.org.labkey.plate.designer.client.model.GWTPosition; -import gwt.client.org.labkey.plate.designer.client.model.GWTWellGroup; - -/** - * User: brittp - * Date: Feb 6, 2007 - * Time: 3:58:52 PM - */ -@SuppressWarnings("Convert2Diamond") -public class TemplateGrid extends Grid -{ - public static final char[] ALPHABET = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', - 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'}; - - public TemplateGrid(TemplateView view, String activeType) - { - super(view.getPlate().getRows() + 1, view.getPlate().getCols() + 1); - setBorderWidth(0); - setCellPadding(0); - setCellSpacing(3); - // Arbitrary sizes to decide what constitutes a "big" plate (rendered with smaller wells) - boolean bigPlate = view.getPlate().getCols() > 15 || view.getPlate().getRows() > 10; - String cellWidth = bigPlate ? "25px" : "30px"; - String cellHeight = bigPlate ? "20px" : "25px"; - for (int row = 0; row < getRowCount(); row++) - { - Widget cellWidget = null; - for (int col = 0; col < getColumnCount(); col++) - { - if (row == 0 && col > 0) - cellWidget = new Label("" + col); - else if (col == 0 && row > 0) - cellWidget = new Label("" + ALPHABET[row - 1]); - else if (col > 0 && row > 0) - { - GWTPosition position = new GWTPosition(row - 1, col - 1); - Set groups = (Set) view.getPlate().getPositionToGroupsMap().get(position); - cellWidget = new TemplateGridCell(view, position, groups, activeType); - - // add a marker class - DOM.setElementAttribute(cellWidget.getElement(), "class", "Cell-" + ALPHABET[row-1] + col); - } - if (cellWidget != null) - { - cellWidget.setSize(cellWidth, cellHeight); - setWidget(row, col, cellWidget); - DOM.setStyleAttribute(cellWidget.getElement(), "textAlign", "center"); - } - } - } - } - - public void highlightGroup(GWTWellGroup group, boolean on) - { - for (Object o : group.getPositions()) - { - GWTPosition position = (GWTPosition) o; - getTemplateGridCell(position).setHighlight(on); - } - } - - public TemplateGridCell getTemplateGridCell(GWTPosition position) - { - return (TemplateGridCell) getWidget(position.getRow() + 1, position.getCol() + 1); - } - - public int getTemplateGridColumnCount() - { - // The column count of this grid includes the column containing row labels, which we - // don't want to include in our count of well group columns. - return getColumnCount() - 1; - } - - public int getTemplateGridRowCount() - { - // The row count of this grid includes the row containing column labels, which we - // don't want to include in our count of well group rows. - return getRowCount() - 1; - } - - - - public List getAllCells() - { - List cells = new ArrayList(); - for (int row = 0; row < getRowCount(); row++) - { - for (int col = 0; col < getColumnCount(); col++) - { - if (col > 0 && row > 0) - cells.add((TemplateGridCell) getWidget(row, col)); - } - } - return cells; - } -} diff --git a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/TemplateGridCell.java b/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/TemplateGridCell.java deleted file mode 100644 index 5d8a6c995ac..00000000000 --- a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/TemplateGridCell.java +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Copyright (c) 2010 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package gwt.client.org.labkey.plate.designer.client; - -import com.google.gwt.event.dom.client.*; -import com.google.gwt.user.client.ui.*; -import com.google.gwt.user.client.DOM; - -import java.util.*; - -import gwt.client.org.labkey.plate.designer.client.model.GWTWellGroup; -import gwt.client.org.labkey.plate.designer.client.model.GWTPosition; - -/** - * User: brittp - * Date: Feb 6, 2007 - * Time: 7:14:17 PM - */ -public class TemplateGridCell extends FocusPanel -{ - private Set _groups; - private String _activeType; - private final TemplateView _view; - private final GWTPosition _position; - - public TemplateGridCell(TemplateView view, GWTPosition position, Set groups, String activeType) - { - _view = view; - _position = position; - _groups = groups; - _activeType = activeType; - addMouseOverHandler(new MouseOverHandler() - { - @Override - public void onMouseOver(MouseOverEvent event) - { - GWTWellGroup activeGroup = getActiveGroup(); - if (activeGroup != null) - _view.setStatus("Well " + TemplateGrid.ALPHABET[_position.getRow()] + (_position.getCol() + 1) + ": " + activeGroup.getName()); - setHighlight(true); - _view.onMouseOverCell((TemplateGridCell) event.getSource()); - } - }); - - addMouseOutHandler(new MouseOutHandler() - { - @Override - public void onMouseOut(MouseOutEvent event) - { - _view.setStatus(""); - setHighlight(false); - } - }); - - addMouseDownHandler(new MouseDownHandler() - { - @Override - public void onMouseDown(MouseDownEvent event) - { - _view.onMouseDownCell((TemplateGridCell) event.getSource()); - } - }); - - _view.addGroupListener(new GroupChangeListenerAdapter() - { - @Override - public void activeGroupTypeChanged(String type) - { - _activeType = type; - redraw(); - } - - @Override - public void groupRemoved(GWTWellGroup group) - { - if (_groups.contains(group)) - { - getGroups().remove(group); - redraw(); - } - } - }); - - redraw(); - } - - public void setHighlight(boolean on) - { - Widget rowLabel = ((Grid) getParent()).getWidget(_position.getRow() + 1, 0); - Widget colLabel = ((Grid) getParent()).getWidget(0, _position.getCol() + 1); - DOM.setStyleAttribute(rowLabel.getElement(), "backgroundColor", on ? "#DDDDDD" : "#FFFFFF"); - DOM.setStyleAttribute(colLabel.getElement(), "backgroundColor", on ? "#DDDDDD" : "#FFFFFF"); - DOM.setStyleAttribute(getElement(), "border", on ? "1px solid black" : "1px solid gray"); - } - - private Set getGroups() - { - if (_groups == null) - _groups = new HashSet<>(); - return _groups; - } - - private void redraw() - { - String color = null; - for (Iterator it = getGroups().iterator(); it.hasNext() && color == null;) - { - GWTWellGroup group = (GWTWellGroup) it.next(); - if (group.getType().equals(_activeType)) - color = _view.getColor(group); - } - if (color == null) - color = "FFFFFF"; - DOM.setStyleAttribute(getElement(), "backgroundColor", "#" + color); - DOM.setStyleAttribute(getElement(), "border", "1px solid gray"); - } - - public void replaceActiveGroup(GWTWellGroup group) - { - GWTWellGroup activeGroup = getActiveGroup(); - if (activeGroup != null) - { - getGroups().remove(activeGroup); - activeGroup.removePosition(_position); - } - if (group != null) - { - group.addPosition(_position); - getGroups().add(group); - } - redraw(); - } - - public List getWarnings() - { - boolean replicate = false; - boolean specimen = false; - boolean control = false; - for (GWTWellGroup group : getGroups()) - { - if (group.getType().equals("SPECIMEN")) - specimen = true; - else if (group.getType().equals("CONTROL")) - control = true; - else if (group.getType().equals("REPLICATE")) - replicate = true; - } - List warnings = null; - if (replicate && !(specimen || control)) - warnings = addWarning(warnings, "Well is a replicate, but is not part of a specimen or control group."); - if (control && specimen) - warnings = addWarning(warnings, "Well is in both a specimen and a control group."); - return warnings; - } - - private List addWarning(List warnings, String warning) - { - if (warnings == null) - warnings = new ArrayList<>(); - warnings.add(warning); - return warnings; - } - - public GWTWellGroup getActiveGroup() - { - for (GWTWellGroup group : getGroups()) - { - if (group.getType().equals(_activeType)) - return group; - } - return null; - } - - public GWTPosition getPosition() - { - return _position; - } - - public String toString() - { - return TemplateGrid.ALPHABET[getPosition().getRow()] + "" + (getPosition().getCol() + 1); - } -} diff --git a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/TemplateView.java b/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/TemplateView.java deleted file mode 100644 index 722dbbdaedb..00000000000 --- a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/TemplateView.java +++ /dev/null @@ -1,649 +0,0 @@ -/* - * Copyright (c) 2010-2016 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package gwt.client.org.labkey.plate.designer.client; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.event.dom.client.MouseDownEvent; -import com.google.gwt.event.dom.client.MouseDownHandler; -import com.google.gwt.event.dom.client.MouseUpEvent; -import com.google.gwt.event.dom.client.MouseUpHandler; -import com.google.gwt.http.client.UrlBuilder; -import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.Timer; -import com.google.gwt.user.client.Window; -import com.google.gwt.user.client.WindowCloseListener; -import com.google.gwt.user.client.WindowResizeListener; -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.gwt.user.client.ui.ChangeListener; -import com.google.gwt.user.client.ui.FocusPanel; -import com.google.gwt.user.client.ui.HasVerticalAlignment; -import com.google.gwt.user.client.ui.HorizontalPanel; -import com.google.gwt.user.client.ui.KeyboardListenerAdapter; -import com.google.gwt.user.client.ui.Label; -import com.google.gwt.user.client.ui.RootPanel; -import com.google.gwt.user.client.ui.SimplePanel; -import com.google.gwt.user.client.ui.TabPanel; -import com.google.gwt.user.client.ui.TextBox; -import com.google.gwt.user.client.ui.VerticalPanel; -import com.google.gwt.user.client.ui.Widget; -import gwt.client.org.labkey.plate.designer.client.model.GWTPlate; -import gwt.client.org.labkey.plate.designer.client.model.GWTPosition; -import gwt.client.org.labkey.plate.designer.client.model.GWTWellGroup; -import org.labkey.api.gwt.client.util.ColorGenerator; -import org.labkey.api.gwt.client.util.PropertyUtil; -import org.labkey.api.gwt.client.util.ServiceUtil; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * User: brittp - * Date: Feb 6, 2007 - * Time: 3:56:25 PM - */ -@SuppressWarnings("Convert2Diamond") -public class TemplateView extends HorizontalPanel -{ - private final RootPanel _rootPanel; - private final int _plateId; - private final String _templateName; - private TemplateGrid _grid; - private final List _groupListeners = new ArrayList<>(); - private GWTWellGroup _activeGroup; - private StatusBar _statusBar; - private GWTPlate _plate; - private GroupTypesTabPanel _typePanel; - private final ColorGenerator _colorGenerator = new ColorGenerator(); - private final Map _groupToColorMap = new HashMap<>(); - private PlateDataServiceAsync _testService; - private boolean _dirty = false; - private Set _existingTemplateNames; - private String _originalTemplateName; - private TextBox _nameBox; - private boolean _copyMode; - private final Map> _cellWarnings = new HashMap<>(); - private TabPanel _propertyTabPanel; - private boolean _showWarningPanel; - private WarningPanel _warningPanel; - private WellGroupPropertyPanel _wellGroupPropertyPanel; - private PlatePropertyPanel _platePropertyPanel; - private final String _assayTypeName; - private final String _templateTypeName; - private final int _rowCount; - private final int _columnCount; - private boolean _mouseDown = false; - private TemplateGridCell _selectionStartCell; - private TemplateGridCell _prevSelectionEndCell; - private boolean _setSelected; - private GWTWellGroup[][] _assignmentShapshot; - private final List _updatedCellList = new ArrayList<>(); - private final Timer _warningUpdateTimer = new Timer() - { - @Override - public void run() - { - synchronized (_updatedCellList) - { - if (!_updatedCellList.isEmpty()) - refreshWarnings(_updatedCellList); - _updatedCellList.clear(); - } - } - }; - - public TemplateView(RootPanel rootPanel, int plateId, String plateName, String plateTypeName, String templateName, int rowCount, int columnCount) - { - _rootPanel = rootPanel; - _plateId = plateId; - _templateName = plateName; - _assayTypeName = plateTypeName; - _templateTypeName = templateName; - _rowCount = rowCount; - _columnCount = columnCount; - _copyMode = Boolean.valueOf(PropertyUtil.getServerProperty("copyTemplate")).booleanValue(); - } - - public void showAsync() - { - _rootPanel.clear(); - _rootPanel.add(new Label("Loading...")); - getService().getTemplateDefinition(_templateName, _plateId, _assayTypeName, _templateTypeName, _rowCount, _columnCount, _copyMode, new AsyncCallback() - { - @Override - public void onFailure(Throwable throwable) - { - VerticalPanel mainPanel = new VerticalPanel(); - mainPanel.add(new Label("Unable to load plate template: " + throwable.getMessage())); - _rootPanel.add(mainPanel); - } - - @Override - public void onSuccess(GWTPlate plate) - { - _plate = plate; - show(); - } - }); - } - - private PlateDataServiceAsync getService() - { - if (_testService == null) - { - _testService = GWT.create(PlateDataService.class); - ServiceUtil.configureEndpoint(_testService, "designerService"); - } - return _testService; - } - - private void resize(int width, int height) - { - // Set the size of main body scroll panel so that it fills the browser. - int fullWidth = Math.max(width - getAbsoluteLeft() - 20, 0); - int rightPanelWidth = Math.min(fullWidth - _typePanel.getOffsetWidth(), 500); - -// setSize(null, Math.max(height - getAbsoluteTop() - 10, 0) + "px"); - - _propertyTabPanel.setWidth(rightPanelWidth + "px"); - } - - private void show() - { - VerticalPanel mainPanel = new VerticalPanel(); - List groupTypes = _plate.getGroupTypes(); - _originalTemplateName = _plate.getName(); - _showWarningPanel = _plate.isShowWarningPanel(); - - // status bar - _statusBar = new StatusBar(this, PropertyUtil.getRelativeURL("begin")); - mainPanel.add(_statusBar); - mainPanel.setCellHeight(_statusBar, "30px"); - - // plate name textbox: - _nameBox = new TextBox(); - _nameBox.setVisibleLength(40); - DOM.setElementAttribute(_nameBox.getElement(), "id", "templateName"); - String plateName = PropertyUtil.getServerProperty("defaultPlateName"); - if (plateName == null) - { - plateName = ""; - } - _nameBox.setText(plateName); - _plate.setName(plateName); - _nameBox.addKeyboardListener(new KeyboardListenerAdapter() - { - @Override - public void onKeyPress(Widget sender, char keyCode, int modifiers) - { - setDirty(true); - } - }); - - _nameBox.addChangeListener(new ChangeListener() - { - @Override - public void onChange(Widget sender) - { - String newName = _nameBox.getText(); - _plate.setName(newName.trim()); - if (!_nameBox.getText().equals(_plate.getName())) - { - _nameBox.setText(_plate.getName()); - } - } - }); - - HorizontalPanel namePanel = new HorizontalPanel(); - Label templateNameLabel = new Label("Template Name: "); - namePanel.add(templateNameLabel); - SimplePanel spacer = new SimplePanel(); - spacer.setWidth("5px"); - namePanel.add(spacer); - namePanel.add(_nameBox); - mainPanel.add(namePanel); - namePanel.setCellVerticalAlignment(templateNameLabel, HasVerticalAlignment.ALIGN_MIDDLE); - mainPanel.setCellHeight(namePanel, "30px"); - - // well groups and well grid - _grid = new TemplateGrid(this, (String) groupTypes.get(0)); - _typePanel = new GroupTypesTabPanel(this); - HorizontalPanel hpanel = new HorizontalPanel(); - - // Wrap the tabPanel in a focuspanel so we can track mouse events: - FocusPanel focusPanel = new FocusPanel(_typePanel); - focusPanel.addMouseDownHandler(new MouseDownHandler() - { - @Override - public void onMouseDown(MouseDownEvent event) - { - _mouseDown = true; - } - }); - focusPanel.addMouseUpHandler(new MouseUpHandler() - { - @Override - public void onMouseUp(MouseUpEvent event) - { - _mouseDown = false; - } - }); - - hpanel.add(focusPanel); - mainPanel.add(hpanel); - mainPanel.setCellHeight(hpanel, "100%"); - - add(mainPanel); - - _propertyTabPanel = new TabPanel(); - _propertyTabPanel.setWidth("500px"); - - _platePropertyPanel = new PlatePropertyPanel(this); - //_propertyTabPanel.add(_platePropertyPanel, "Plate Properties"); - - _wellGroupPropertyPanel = new WellGroupPropertyPanel(this); - _propertyTabPanel.add(_wellGroupPropertyPanel, "Well Group Properties"); - - if (_showWarningPanel) - { - _warningPanel = new WarningPanel(); - _propertyTabPanel.add(_warningPanel, "Warnings"); - } - _propertyTabPanel.selectTab(0); - - SimplePanel spacer2 = new SimplePanel(); - spacer2.setWidth("5px"); - add(spacer2); - - add(_propertyTabPanel); - - refreshWarnings(_grid.getAllCells()); - _rootPanel.clear(); - _rootPanel.add(this); - resize(Window.getClientWidth(), Window.getClientHeight()); - Window.addWindowResizeListener(new WindowResizeListener() - { - @Override - public void onWindowResized(int width, int height) - { - resize(width, height); - } - - }); - Window.addWindowCloseListener(new WindowCloseListener() - { - @Override - public void onWindowClosed() - { - } - - @Override - public String onWindowClosing() - { - if (_dirty) - return "Changes have not been saved and will be discarded."; - else - return null; - } - }); - - if (_copyMode) - setDirty(true); - } - - private Set getAllTemplateNames() - { - if (_existingTemplateNames == null) - { - String current; - _existingTemplateNames = new HashSet<>(); - int idx = 0; - do - { - current = PropertyUtil.getServerProperty("templateName[" + idx++ + "]"); - if (current != null) - _existingTemplateNames.add(current); - } while (current != null); - } - return _existingTemplateNames; - } - - private void setDirty(boolean dirty) - { - _dirty = dirty; - _statusBar.setDirty(dirty); - } - - public void markAsDirty() - { - setDirty(true); - } - - public void saveChanges(final AsyncCallback callback) - { - String templateName = _nameBox.getText().trim(); - if (templateName == null || templateName.isEmpty()) - { - Window.alert("A plate name must be specified."); - return; - } - if (_copyMode || !templateName.equals(_originalTemplateName)) - { - Set allTemplateNames = getAllTemplateNames(); - if (allTemplateNames.contains(templateName)) - { - Window.alert("A plate template with this name already exists. Please choose another name."); - return; - } - } - _plate.setPlateProperties(_platePropertyPanel.getProperties()); - if (_activeGroup != null) - { - _activeGroup.setProperties(_wellGroupPropertyPanel.getProperties()); - } - setStatus("Saving..."); - getService().saveChanges(_plate, !_copyMode, new AsyncCallback() - { - @Override - public void onFailure(Throwable throwable) - { - setStatus("Save failed: " + throwable.getMessage()); - setDirty(true); - callback.onFailure(throwable); - } - - @Override - public void onSuccess(Long newPlateId) - { - UrlBuilder urlBuilder = Window.Location.createUrlBuilder(); - String oldUrl = urlBuilder.buildString(); - - // remove all parameters (e.g, copy, rows, cols, ...) - for (String param : Window.Location.getParameterMap().keySet()) - { - urlBuilder.removeParameter(param); - } - - // add the necessary parameters for loading the template again if the user refreshes the page - urlBuilder.setParameter("templateName", _plate.getName()); - urlBuilder.setParameter("plateId", String.valueOf(newPlateId)); - - // if the URL has changed, replace it in history - String newUrl = urlBuilder.buildString(); - if (!newUrl.equals(oldUrl)) - { - replaceState(newUrl); - } - - _copyMode = false; - setStatus("Saved."); - setDirty(false); - callback.onSuccess(newPlateId); - } - }); - } - - // https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState - public static native void replaceState(String newURL) /*-{ - $wnd.history.replaceState(null, '', newURL); - }-*/; - - public void setStatus(String status) - { - _statusBar.setStatus(status); - } - - public void onMouseOverCell(TemplateGridCell cell) - { - if (_mouseDown) - { - setStatus("Selection: " + _selectionStartCell + " to " + cell); - // we appear to be doing a drag operation to select multiple cells- snapshot the well group assignments - // now, so we can revert wells as the user drags around: - if (_assignmentShapshot == null) - _assignmentShapshot = snapshotWellAssignments(); - updateSelection(_selectionStartCell, cell, _prevSelectionEndCell, _setSelected); - _prevSelectionEndCell = cell; - } - else - { - _selectionStartCell = null; - _prevSelectionEndCell = null; - _assignmentShapshot = null; - } - } - - private GWTWellGroup[][] snapshotWellAssignments() - { - GWTWellGroup[][] assignments = new GWTWellGroup[_grid.getTemplateGridRowCount()][_grid.getTemplateGridColumnCount()]; - for (int row = 0; row < assignments.length; row++) - { - for (int col = 0; col < assignments[row].length; col++) - assignments[row][col] = _grid.getTemplateGridCell(new GWTPosition(row, col)).getActiveGroup(); - } - return assignments; - } - - public void onMouseDownCell(TemplateGridCell cell) - { - _selectionStartCell = cell; - _setSelected = (cell.getActiveGroup() != _activeGroup); - if (_activeGroup != null) - { - if (cell.getActiveGroup() == _activeGroup) - cell.replaceActiveGroup(null); - else - cell.replaceActiveGroup(_activeGroup); - setDirty(true); - List cellList = new ArrayList(); - cellList.add(cell); - refreshWarnings(cellList); - } - } - - public void refreshWarningsAsync() - { - refreshWarningsAsync(_grid.getAllCells()); - } - - public void refreshWarningsAsync(List updatedCellList) - { - synchronized (_updatedCellList) - { - _updatedCellList.clear(); - _updatedCellList.addAll(updatedCellList); - _warningUpdateTimer.cancel(); - _warningUpdateTimer.schedule(1000); - } - } - - private void updateSelection(TemplateGridCell startCell, TemplateGridCell endCell, TemplateGridCell prevEndCell, boolean setSelected) - { - // First, set the selection state of all cells in the current selection range: - int startCol = Math.min(startCell.getPosition().getCol(), endCell.getPosition().getCol()); - int endCol = Math.max(startCell.getPosition().getCol(), endCell.getPosition().getCol()); - List cellList = new ArrayList(); - for (int col = startCol; col <= endCol; col++) - { - int startRow = Math.min(startCell.getPosition().getRow(), endCell.getPosition().getRow()); - int endRow = Math.max(startCell.getPosition().getRow(), endCell.getPosition().getRow()); - for (int row = startRow; row <= endRow; row++) - { - TemplateGridCell cell = this.getGrid().getTemplateGridCell(new GWTPosition(row, col)); - if (setSelected) - cell.replaceActiveGroup(_activeGroup); - else - cell.replaceActiveGroup(null); - cellList.add(cell); - } - } - refreshWarningsAsync(cellList); - - // Second, de-select any cells that were previously selected in this same drag but which are no longer - // selected. (This can happen if the user drags a few columns/rows in one direction, overshoots, and backs - // off one column/row.) We know that the user has backed off if (and only if) the previous selection end is - // no longer inside the rectangle defined by the current selection. - if (prevEndCell != null && !prevEndCell.getPosition().inside(startCell.getPosition(), endCell.getPosition())) - { - for (int row = 0; row < _grid.getTemplateGridRowCount(); row++) - { - for (int col = 0; col < _grid.getTemplateGridColumnCount(); col++) - { - GWTPosition pos = new GWTPosition(row, col); - // Any cells that were previously included in the selection range but which are now excluded need to be - // reset to their original state: - if (pos.inside(startCell.getPosition(), prevEndCell.getPosition()) && !pos.inside(startCell.getPosition(), endCell.getPosition())) - _grid.getTemplateGridCell(pos).replaceActiveGroup(_assignmentShapshot[row][col]); - } - } - } - } - - private void refreshWarnings(List modifiedCells) - { - boolean warningsChanged = false; - for (TemplateGridCell cell : modifiedCells) - { - List warnings = cell.getWarnings(); - String key = cell.toString(); - if (warnings == null) - { - if (_cellWarnings.containsKey(key)) - { - _cellWarnings.remove(key); - warningsChanged = true; - } - } - else - { - _cellWarnings.put(key, warnings); - warningsChanged = true; - } - } - if (warningsChanged && _showWarningPanel) - { - _warningPanel.update(_cellWarnings); - int currentTab = _propertyTabPanel.getTabBar().getSelectedTab(); - _propertyTabPanel.remove(_warningPanel); - if (_cellWarnings.isEmpty()) - { - _propertyTabPanel.add(_warningPanel, "Warnings"); - } - else - { - _propertyTabPanel.add(_warningPanel, "Warnings (" + _cellWarnings.size() + ")", true); - } - _propertyTabPanel.selectTab(currentTab); - } - } - - public void deleteWellGroup(GWTWellGroup group) - { - setDirty(true); - _plate.removeGroup(group); - List listenersCopy = new ArrayList(_groupListeners); - for (GroupChangeListener listener : listenersCopy) - listener.groupRemoved(group); - _groupToColorMap.remove(group); - setActiveGroup(null); - List cells = new ArrayList(); - for (GWTPosition position : group.getPositions()) - cells.add(_grid.getTemplateGridCell(position)); - refreshWarnings(cells); - } - - public void createWellGroup(String groupName, String type) - { - Map properties = getPropertiesForType(type); - - int wellGroupCount = _plate.getWellGroupCount() + 1; - GWTWellGroup group = new GWTWellGroup(-1 * wellGroupCount, type, groupName, new ArrayList(), properties); - if (_plate.addGroup(group)) - { - setDirty(true); - List listenersCopy = new ArrayList(_groupListeners); - for (GroupChangeListener listener : listenersCopy) - listener.groupAdded(group); - setActiveGroup(group); - } - } - - public void setActiveType(String activeType) - { - setActiveGroup(null); - List listenersCopy = new ArrayList(_groupListeners); - for (GroupChangeListener listener : listenersCopy) - listener.activeGroupTypeChanged(activeType); - } - - public void addGroupListener(GroupChangeListener listener) - { - _groupListeners.add(listener); - } - - public void removeGroupListener(GroupChangeListener listener) - { - _groupListeners.remove(listener); - } - - public void setActiveGroup(GWTWellGroup group) - { - GWTWellGroup previous = _activeGroup; - _activeGroup = group; - List listenersCopy = new ArrayList(_groupListeners); - for (GroupChangeListener listener : listenersCopy) - listener.activeGroupChanged(previous, group); - } - - public GWTPlate getPlate() - { - return _plate; - } - - public String getColor(GWTWellGroup group) - { - String color = _groupToColorMap.get(group); - if (color == null) - { - color = _colorGenerator.next(); - _groupToColorMap.put(group, color); - } - return color; - } - - private Map getPropertiesForType(String type) - { - List groups = _plate.getTypeToGroupsMap().get(type); - if (groups != null && !groups.isEmpty()) - return groups.iterator().next().getProperties(); - else - return new HashMap(); - } - - public TemplateGrid getGrid() - { - return _grid; - } - - public void setHighlightGroup(GWTWellGroup group, boolean on) - { - _grid.highlightGroup(group, on); - } -} diff --git a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/WarningPanel.java b/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/WarningPanel.java deleted file mode 100644 index bd505648a9c..00000000000 --- a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/WarningPanel.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2010 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package gwt.client.org.labkey.plate.designer.client; - -import com.google.gwt.user.client.ui.VerticalPanel; -import com.google.gwt.user.client.ui.Label; -import com.google.gwt.user.client.DOM; - -import java.util.*; - -/** - * User: brittp - * Date: Mar 1, 2007 - * Time: 4:52:29 PM - */ -public class WarningPanel extends VerticalPanel -{ - public WarningPanel() - { - setWidth("100%"); - update(null); - } - - public void update(Map cellToWarnings) - { - clear(); - if (cellToWarnings != null && !cellToWarnings.isEmpty()) - { - List keys = new ArrayList(cellToWarnings.keySet()); - Collections.sort(keys); - for (Iterator cellIt = keys.iterator(); cellIt.hasNext(); ) - { - String cell = (String) cellIt.next(); - List warnings = (List) cellToWarnings.get(cell); - Label cellLabel = new Label("Well " + cell + ":"); - DOM.setStyleAttribute(cellLabel.getElement(), "fontWeight", "bold"); - add(cellLabel); - for (Iterator warnIt = warnings.iterator(); warnIt.hasNext(); ) - { - String warning = (String) warnIt.next(); - Label warningText = new Label(warning); - add(warningText); - DOM.setStyleAttribute(warningText.getElement(), "paddingLeft", "5px"); - } - } - } - else - { - Label header = new Label("No warnings."); - add(header); - } - } -} diff --git a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/WellGroupPropertyPanel.java b/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/WellGroupPropertyPanel.java deleted file mode 100644 index b50141905fa..00000000000 --- a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/WellGroupPropertyPanel.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2010 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package gwt.client.org.labkey.plate.designer.client; - -import gwt.client.org.labkey.plate.designer.client.model.GWTWellGroup; - -/** - * User: jeckels - * Date: Apr 19, 2007 - */ -public class WellGroupPropertyPanel extends PropertyPanel implements GroupChangeListener -{ - public WellGroupPropertyPanel(TemplateView view) - { - super(view); - view.addGroupListener(this); - activeGroupChanged(null, null); - } - - @Override - public void activeGroupChanged(GWTWellGroup previouslyActive, GWTWellGroup currentlyActive) - { - if (previouslyActive != null) - { - previouslyActive.setProperties(getProperties()); - } - if (currentlyActive == null) - { - redraw("No well group selected."); - } - else - { - redraw(currentlyActive.getProperties()); - } - } - - @Override - public void activeGroupTypeChanged(String type) - { - } - - @Override - public void groupAdded(GWTWellGroup group) - { - } - - @Override - public void groupRemoved(GWTWellGroup group) - { - } - -} diff --git a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/model/GWTPlate.java b/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/model/GWTPlate.java deleted file mode 100644 index 02aa209fbae..00000000000 --- a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/model/GWTPlate.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright (c) 2010-2012 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package gwt.client.org.labkey.plate.designer.client.model; - -import com.google.gwt.user.client.Window; -import com.google.gwt.user.client.rpc.IsSerializable; - -import java.util.*; - -@SuppressWarnings("Convert2Diamond") -public class GWTPlate implements IsSerializable -{ - private long _rowId; - private String _name; - private String _type; - private int _rows; - private int _cols; - private Map> _groups = new HashMap>(); - private Set _allGroups = new HashSet<>(); - private boolean _showWarningPanel; - - private List _groupTypes; - private Map _plateProperties = new HashMap(); - private Map> _typesToDefaultGroups = new HashMap>(); - private transient Map> _positionToGroups = null; - - public GWTPlate() - { - } - - public GWTPlate(long rowId, String name, String type, int rows, int cols, List groupTypes, boolean showWarningPanel) - { - _rowId = rowId; - _name = name; - _type = type; - _rows = rows; - _cols = cols; - _groupTypes = groupTypes; - _showWarningPanel = showWarningPanel; - } - - public long getRowId() - { - return _rowId; - } - - public Map getPositionToGroupsMap() - { - if (_positionToGroups == null) - { - _positionToGroups = new HashMap>(); - for (List typeGroups : _groups.values()) - { - for (GWTWellGroup group : typeGroups) - { - for (GWTPosition position : group.getPositions()) - { - Set groupList = _positionToGroups.get(position); - if (groupList == null) - { - groupList = new HashSet(); - _positionToGroups.put(position, groupList); - } - groupList.add(group); - } - } - } - } - return _positionToGroups; - } - - public Map> getTypeToGroupsMap() - { - return Collections.unmodifiableMap(_groups); - } - - public void removeGroup(GWTWellGroup group) - { - if (_groups.containsKey(group.getType())) - { - _groups.get(group.getType()).remove(group); - _positionToGroups = null; - } - _allGroups.remove(group); - } - - public boolean addGroup(GWTWellGroup group) - { - if (!_groups.containsKey(group.getType())) - _groups.put(group.getType(), new ArrayList<>()); - - // verify the group rowId is unique - if (_allGroups.contains(group)) - { - Window.alert("Group '" + group.getName() + "' already exists."); - return false; - } - _allGroups.add(group); - - // verify the group name is unique within the group type - List groups = _groups.get(group.getType()); - for (GWTWellGroup g : groups) - { - if (group.getName() != null && group.getName().equals(g.getName())) - { - Window.alert("Group '" + group.getName() + "' already exists."); - return false; - } - } - groups.add(group); - - _positionToGroups = null; - return true; - } - - public int getCols() - { - return _cols; - } - - public int getWellGroupCount() - { - return _allGroups.size(); - } - - public Set getGroups() - { - return Collections.unmodifiableSet(_allGroups); - } - - public int getRows() - { - return _rows; - } - - public List getGroupTypes() - { - return _groupTypes; - } - - public String getName() - { - return _name; - } - - public void setName(String name) - { - _name = name; - } - - public void setGroups(List groups) - { - for (GWTWellGroup group : groups) - addGroup(group); - } - - public void setPlateProperties(Map plateProperties) - { - _plateProperties = plateProperties; - } - - public Map getPlateProperties() - { - return _plateProperties; - } - - public String getType() - { - return _type; - } - - public Map> getTypesToDefaultGroups() - { - return _typesToDefaultGroups; - } - - public void setTypesToDefaultGroups(Map> typesToDefaultGroups) - { - _typesToDefaultGroups = typesToDefaultGroups; - } - - public boolean isShowWarningPanel() - { - return _showWarningPanel; - } - - public void setShowWarningPanel(boolean showWarningPanel) - { - _showWarningPanel = showWarningPanel; - } -} diff --git a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/model/GWTPosition.java b/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/model/GWTPosition.java deleted file mode 100644 index a7b514ba9d1..00000000000 --- a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/model/GWTPosition.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2010 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package gwt.client.org.labkey.plate.designer.client.model; - -import com.google.gwt.user.client.rpc.IsSerializable; - -/** - * User: brittp - * Date: Feb 2, 2007 - * Time: 3:04:10 PM - */ -public class GWTPosition implements IsSerializable -{ - private int _row; - private int _col; - - public GWTPosition() - { - // empty constructor for serialization - } - - public GWTPosition(int row, int col) - { - _row = row; - _col = col; - } - - public int getCol() - { - return _col; - } - - public int getRow() - { - return _row; - } - - public boolean equals(Object o) - { - if (this == o) return true; - if (!(o instanceof GWTPosition)) - return false; - return ((GWTPosition) o).getRow() == getRow() && - ((GWTPosition) o).getCol() == getCol(); - } - - public int hashCode() - { - int result; - result = _row; - result = 31 * result + _col; - return result; - } - - /** - * Returns a boolean indicating whether this position is inside the grid defined by the two parameter positions. - * Containment is inclusive of the rows/columns occupied by the positions themselves. - * @param first The upper-left or lower-right position of the containment grid. - * @param second The upper-left or lower-right position of the containment grid. - * @return Boolean indicating whether this point is inside the grid defined by the two parameter positions. - */ - public boolean inside(GWTPosition first, GWTPosition second) - { - GWTPosition upperLeft = new GWTPosition(Math.min(first.getRow(), second.getRow()), - Math.min(first.getCol(), second.getCol())); - GWTPosition lowerRight = new GWTPosition(Math.max(first.getRow(), second.getRow()), - Math.max(first.getCol(), second.getCol())); - return upperLeft.getRow() <= getRow() && - lowerRight.getRow() >= getRow() && - upperLeft.getCol() <= getCol() && - lowerRight.getCol() >= getCol(); - } -} diff --git a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/model/GWTWellGroup.java b/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/model/GWTWellGroup.java deleted file mode 100644 index 28c0fd343bd..00000000000 --- a/assay/gwtsrc/gwt/client/org/labkey/plate/designer/client/model/GWTWellGroup.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (c) 2010-2012 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package gwt.client.org.labkey.plate.designer.client.model; - -import com.google.gwt.user.client.rpc.IsSerializable; - -import java.util.List; -import java.util.Map; - -/** - * User: brittp - * Date: Feb 2, 2007 - * Time: 3:16:30 PM - */ -public class GWTWellGroup implements IsSerializable -{ - private int _rowId; - private String _type; - private String _name; - private List _positions; - private boolean _allowNewGroups = true; // issue 47210 : disallow creating/editing of well groups for specific types - - /** - * This field is a Map that must always contain Strings. - */ - private Map _properties; - - public GWTWellGroup() - { - // no-arg constructor for deserialization - } - - public GWTWellGroup(int rowId, String type, String name, List positions, Map properties) - { - _rowId = rowId; - _type = type; - _name = name; - _positions = positions; - _properties = properties; - } - - public int getRowId() - { - return _rowId; - } - - public void removePosition(GWTPosition position) - { - _positions.remove(position); - } - - public void addPosition(GWTPosition position) - { - if (!_positions.contains(position)) - _positions.add(position); - } - - public String getName() - { - return _name; - } - - public void setName(String name) - { - _name = name; - } - - public String getType() - { - return _type; - } - - public List getPositions() - { - return _positions; - } - - public Map getProperties() - { - return _properties; - } - - public void setProperties(Map properties) - { - _properties = properties; - } - - public boolean isAllowNewGroups() - { - return _allowNewGroups; - } - - public void setAllowNewGroups(boolean allowNewGroups) - { - _allowNewGroups = allowNewGroups; - } - - @Override - public int hashCode() - { - return Integer.hashCode(_rowId); - } - - @Override - public boolean equals(Object o) - { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - GWTWellGroup that = (GWTWellGroup) o; - - return this._rowId == that._rowId; - } -} diff --git a/assay/src/org/labkey/assay/PlateController.java b/assay/src/org/labkey/assay/PlateController.java index 9f2f465697c..362c014cc1c 100644 --- a/assay/src/org/labkey/assay/PlateController.java +++ b/assay/src/org/labkey/assay/PlateController.java @@ -22,7 +22,6 @@ import org.labkey.api.action.FormHandlerAction; import org.labkey.api.action.JsonInputLimit; import org.labkey.api.action.FormViewAction; -import org.labkey.api.action.GWTServiceAction; import org.labkey.api.action.Marshal; import org.labkey.api.action.Marshaller; import org.labkey.api.action.MutatingApiAction; @@ -46,7 +45,6 @@ import org.labkey.api.data.ContainerManager; import org.labkey.api.data.TSVWriter; import org.labkey.api.gwt.client.model.GWTPropertyDescriptor; -import org.labkey.api.gwt.server.BaseRemoteService; import org.labkey.api.query.BatchValidationException; import org.labkey.api.query.FieldKey; import org.labkey.api.query.ValidationException; @@ -76,7 +74,6 @@ import org.labkey.api.view.NavTree; import org.labkey.api.view.NotFoundException; import org.labkey.api.writer.ZipFile; -import org.labkey.assay.plate.PlateDataServiceImpl; import org.labkey.assay.plate.PlateImpl; import org.labkey.assay.plate.PlateManager; import org.labkey.assay.plate.PlateSetExport; @@ -85,7 +82,6 @@ import org.labkey.assay.plate.WellGroupImpl; import org.labkey.assay.plate.model.CreatePlateSetOptions; import org.labkey.assay.plate.model.ReformatOptions; -import org.labkey.assay.view.AssayGWTView; import org.springframework.validation.BindException; import org.springframework.validation.Errors; import org.springframework.web.servlet.ModelAndView; @@ -216,17 +212,6 @@ public void addNavTrail(NavTree root) } } - /** Delete soon! */ - @RequiresAnyOf({InsertPermission.class, DesignAssayPermission.class}) - public static class DesignerServiceAction extends GWTServiceAction - { - @Override - protected BaseRemoteService createService() throws IllegalStateException - { - return new PlateDataServiceImpl(getViewContext()); - } - } - public static class RowIdForm { private int _rowId; @@ -608,63 +593,6 @@ public void addNavTrail(NavTree root) } } - /** Delete soon! */ - @RequiresAnyOf({InsertPermission.class, DesignAssayPermission.class}) - public class DesignerGwtAction extends SimpleViewAction - { - @Override - public ModelAndView getView(DesignerForm form, BindException errors) - { - Map properties = new HashMap<>(); - String templateName = null; - Long plateId = null; - - if (form.getTemplateName() != null) - { - plateId = form.getPlateId(); - templateName = form.getTemplateName(); - } - else if (form.getPlateId() != null) - { - Plate plate = PlateManager.get().getPlate(getContainer(), form.getPlateId()); - if (plate != null) - { - plateId = plate.getRowId(); - templateName = plate.getName(); - } - } - - if (templateName != null) - { - properties.put("copyTemplate", Boolean.toString(form.isCopy())); - properties.put("templateName", templateName); - if (plateId != null) - properties.put("plateId", String.valueOf(plateId)); - if (form.isCopy()) - properties.put("defaultPlateName", getUniqueName(getContainer(), templateName)); - else - properties.put("defaultPlateName", templateName); - } - - if (form.getAssayType() != null) - properties.put("assayTypeName", form.getAssayType()); - if (form.getTemplateType() != null) - properties.put("templateTypeName", form.getTemplateType()); - - properties.put("templateRowCount", String.valueOf(form.getRowCount())); - properties.put("templateColumnCount", String.valueOf(form.getColCount())); - - return new AssayGWTView(gwt.client.org.labkey.plate.designer.client.TemplateDesigner.class, properties); - } - - @Override - public void addNavTrail(NavTree root) - { - setHelpTopic("editPlateTemplate"); - root.addChild("Plate Editor (GWT)"); - } - } - @RequiresAnyOf({DeletePermission.class, DesignAssayPermission.class}) public static class DeleteAction extends FormHandlerAction { diff --git a/assay/src/org/labkey/assay/TsvAssayProvider.java b/assay/src/org/labkey/assay/TsvAssayProvider.java index f44a544388c..cfad21024c7 100644 --- a/assay/src/org/labkey/assay/TsvAssayProvider.java +++ b/assay/src/org/labkey/assay/TsvAssayProvider.java @@ -285,7 +285,7 @@ protected Pair> createResultDomain(Container c specimenID.setImportAliasSet(specimenImportAliases); DomainProperty participantID = addProperty(dataDomain, PARTICIPANTID_PROPERTY_NAME, PARTICIPANTID_PROPERTY_CAPTION, PropertyType.STRING, "Used with either " + VISITID_PROPERTY_NAME + " or " + DATE_PROPERTY_NAME + " to identify subject and timepoint for assay."); - participantID.setConceptURI(org.labkey.api.gwt.client.ui.PropertyType.PARTICIPANT_CONCEPT_URI); + participantID.setConceptURI(PropertyType.PARTICIPANT_CONCEPT_URI); participantID.setImportAliasSet(participantImportAliases); DomainProperty visitID = addProperty(dataDomain, VISITID_PROPERTY_NAME, VISITID_PROPERTY_CAPTION, PropertyType.DOUBLE, "Used with " + PARTICIPANTID_PROPERTY_NAME + " to identify subject and timepoint for assay."); diff --git a/assay/src/org/labkey/assay/actions/GetProtocolAction.java b/assay/src/org/labkey/assay/actions/GetProtocolAction.java index 8846544911e..b1a0181459c 100644 --- a/assay/src/org/labkey/assay/actions/GetProtocolAction.java +++ b/assay/src/org/labkey/assay/actions/GetProtocolAction.java @@ -15,7 +15,6 @@ */ package org.labkey.assay.actions; -import com.fasterxml.jackson.databind.ObjectMapper; import org.labkey.api.action.ApiUsageException; import org.labkey.api.action.Marshal; import org.labkey.api.action.Marshaller; @@ -23,13 +22,10 @@ import org.labkey.api.assay.AssayDomainService; import org.labkey.api.exp.api.ExpProtocol; import org.labkey.api.exp.api.ExperimentService; -import org.labkey.api.gwt.client.assay.model.GWTPropertyDescriptorMixin; import org.labkey.api.gwt.client.assay.model.GWTProtocol; -import org.labkey.api.gwt.client.model.GWTPropertyDescriptor; import org.labkey.api.security.RequiresPermission; import org.labkey.api.security.permissions.AssayReadPermission; import org.labkey.api.security.permissions.ReadPermission; -import org.labkey.api.util.JsonUtil; import org.labkey.api.view.NotFoundException; import org.labkey.api.view.UnauthorizedException; import org.labkey.assay.AssayDomainServiceImpl; @@ -54,22 +50,6 @@ public void setCopy(boolean copy) } } - //Keeping both request and response object mappers to avoid serialization/deserialization issues - //as not sure if request object mapper is needed - @Override - protected ObjectMapper createRequestObjectMapper() - { - ObjectMapper mapper = JsonUtil.DEFAULT_MAPPER.copy(); - configureObjectMapper(mapper); - return mapper; - } - - @Override - protected ObjectMapper createResponseObjectMapper() - { - return this.createRequestObjectMapper(); - } - @Override public Object execute(DesignerForm form, BindException errors) throws Exception { @@ -109,7 +89,4 @@ else if (form.getProviderName() != null) } } - static void configureObjectMapper(ObjectMapper om) { - om.addMixIn(GWTPropertyDescriptor.class, GWTPropertyDescriptorMixin.class); - } } diff --git a/assay/src/org/labkey/assay/actions/SaveProtocolAction.java b/assay/src/org/labkey/assay/actions/SaveProtocolAction.java index 4721d83058c..b3a5e3c2581 100644 --- a/assay/src/org/labkey/assay/actions/SaveProtocolAction.java +++ b/assay/src/org/labkey/assay/actions/SaveProtocolAction.java @@ -15,15 +15,18 @@ */ package org.labkey.assay.actions; +import com.fasterxml.jackson.databind.ObjectMapper; import org.labkey.api.action.Marshal; import org.labkey.api.action.Marshaller; import org.labkey.api.action.MutatingApiAction; import org.labkey.api.assay.AssayDomainService; import org.labkey.api.assay.security.DesignAssayPermission; import org.labkey.api.exp.api.ExpProtocol; +import org.labkey.api.exp.property.PropertyService; import org.labkey.api.gwt.client.assay.model.GWTProtocol; import org.labkey.api.security.RequiresPermission; import org.labkey.api.security.permissions.ReadPermission; +import org.labkey.api.util.JsonUtil; import org.labkey.api.view.NotFoundException; import org.labkey.api.view.UnauthorizedException; import org.labkey.assay.AssayDomainServiceImpl; @@ -34,6 +37,14 @@ @RequiresPermission(ReadPermission.class) public class SaveProtocolAction extends MutatingApiAction { + @Override + protected ObjectMapper createRequestObjectMapper() + { + ObjectMapper om = JsonUtil.DEFAULT_MAPPER.copy(); + PropertyService.get().configureObjectMapper(om, null); + return om; + } + @Override public Object execute(GWTProtocol protocol, BindException errors) throws Exception { diff --git a/assay/src/org/labkey/assay/data/generator/AssayDesignGenerator.java b/assay/src/org/labkey/assay/data/generator/AssayDesignGenerator.java index 5b1102e114f..073f5b8f867 100644 --- a/assay/src/org/labkey/assay/data/generator/AssayDesignGenerator.java +++ b/assay/src/org/labkey/assay/data/generator/AssayDesignGenerator.java @@ -4,7 +4,6 @@ import org.labkey.api.data.generator.DataGenerator; import org.labkey.api.exp.query.ExpSchema; import org.labkey.api.exp.query.SamplesSchema; -import org.labkey.api.gwt.client.assay.AssayException; import org.labkey.api.gwt.client.assay.model.GWTProtocol; import org.labkey.api.gwt.client.model.GWTDomain; import org.labkey.api.gwt.client.model.GWTPropertyDescriptor; @@ -18,7 +17,7 @@ import java.util.List; import java.util.Properties; -import static org.labkey.api.gwt.client.ui.PropertyType.SAMPLE_CONCEPT_URI; +import static org.labkey.api.exp.PropertyType.SAMPLE_CONCEPT_URI; public class AssayDesignGenerator extends DataGenerator { @@ -28,7 +27,7 @@ public AssayDesignGenerator(PipelineJob job, Config config) super(job, config); } - public void generateAssayDesigns(String namePrefix) throws ValidationException, AssayException + public void generateAssayDesigns(String namePrefix) throws ValidationException { int numAssayDesigns = _config.getNumAssayDesigns(); if (numAssayDesigns <= 0) @@ -154,7 +153,7 @@ public boolean isAssayDesignPlateSupport() public static class Driver implements DataGenerationDriver { @Override - public List generateData(PipelineJob job, Properties properties) throws ValidationException, AssayException + public List generateData(PipelineJob job, Properties properties) throws ValidationException { AssayDesignGenerator generator = new AssayDesignGenerator(job, new AssayDesignGenerator.Config(properties)); generator.generateAssayDesigns("Assay Design "); diff --git a/assay/src/org/labkey/assay/data/generator/AssayRunDataGenerator.java b/assay/src/org/labkey/assay/data/generator/AssayRunDataGenerator.java index 883445f2c3c..b8fb4901755 100644 --- a/assay/src/org/labkey/assay/data/generator/AssayRunDataGenerator.java +++ b/assay/src/org/labkey/assay/data/generator/AssayRunDataGenerator.java @@ -13,7 +13,6 @@ import org.labkey.api.exp.property.Domain; import org.labkey.api.exp.property.DomainProperty; import org.labkey.api.exp.query.SamplesSchema; -import org.labkey.api.gwt.client.assay.AssayException; import org.labkey.api.pipeline.PipelineJob; import org.labkey.api.query.SchemaKey; import org.labkey.api.query.ValidationException; @@ -28,7 +27,7 @@ import java.util.Properties; import java.util.stream.Collectors; -import static org.labkey.api.gwt.client.ui.PropertyType.SAMPLE_CONCEPT_URI; +import static org.labkey.api.exp.PropertyType.SAMPLE_CONCEPT_URI; public class AssayRunDataGenerator extends DataGenerator { @@ -225,7 +224,7 @@ public void setMaxRowsPerRun(int maxRowsPerRun) public static class Driver implements DataGenerationDriver { @Override - public List generateData(PipelineJob job, Properties properties) throws ValidationException, AssayException, ExperimentException + public List generateData(PipelineJob job, Properties properties) throws ValidationException, ExperimentException { AssayRunDataGenerator generator = new AssayRunDataGenerator(job, new AssayRunDataGenerator.Config(properties)); generator.generateAssayRunData(); diff --git a/assay/src/org/labkey/assay/plate/PlateDataServiceImpl.java b/assay/src/org/labkey/assay/plate/PlateDataServiceImpl.java deleted file mode 100644 index af614c9465f..00000000000 --- a/assay/src/org/labkey/assay/plate/PlateDataServiceImpl.java +++ /dev/null @@ -1,258 +0,0 @@ -/* - * Copyright (c) 2008-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.labkey.assay.plate; - -import gwt.client.org.labkey.plate.designer.client.PlateDataService; -import gwt.client.org.labkey.plate.designer.client.model.GWTPlate; -import gwt.client.org.labkey.plate.designer.client.model.GWTPosition; -import gwt.client.org.labkey.plate.designer.client.model.GWTWellGroup; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.labkey.api.assay.plate.Plate; -import org.labkey.api.assay.plate.PlateLayoutHandler; -import org.labkey.api.assay.plate.PlateService; -import org.labkey.api.assay.plate.PlateType; -import org.labkey.api.assay.plate.Position; -import org.labkey.api.assay.plate.WellGroup; -import org.labkey.api.gwt.server.BaseRemoteService; -import org.labkey.api.query.BatchValidationException; -import org.labkey.api.query.ValidationException; -import org.labkey.api.view.ViewContext; - -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * User: brittp - * Date: Jan 31, 2007 - * Time: 2:38:17 PM - */ -public class PlateDataServiceImpl extends BaseRemoteService implements PlateDataService -{ - private static final Logger LOG = LogManager.getLogger(PlateDataServiceImpl.class); - - public PlateDataServiceImpl(ViewContext context) - { - super(context); - } - - @Override - public GWTPlate getTemplateDefinition(String templateName, int plateId, String assayTypeName, String templateTypeName, int rowCount, int columnCount, boolean copyTemplate) throws Exception - { - try - { - Plate template; - PlateLayoutHandler handler; - - if (templateName != null) - { - // existing template - template = PlateService.get().getPlate(getContainer(), plateId); - if (template == null) - throw new Exception("Plate " + templateName + " does not exist."); - - handler = PlateManager.get().getPlateLayoutHandler(template.getAssayType()); - if (handler == null) - throw new Exception("Plate template type " + template.getAssayType() + " does not exist."); - } - else - { - // new default template - handler = PlateManager.get().getPlateLayoutHandler(assayTypeName); - if (handler == null) - throw new Exception("Plate template type " + assayTypeName + " does not exist."); - - PlateType plateType = PlateService.get().getPlateType(rowCount, columnCount); - if (plateType == null) - throw new Exception("The plate type : (" + rowCount + " x " + columnCount + ") does not exist"); - template = handler.createPlate(templateTypeName, getContainer(), plateType); - } - - // Translate PlateTemplate to GWTPlate - List groups = template.getWellGroups(); - List translated = new ArrayList<>(); - for (int i = 0; i < groups.size(); i++) - { - WellGroup group = groups.get(i); - List positions = new ArrayList<>(group.getPositions().size()); - for (Position position : group.getPositions()) - positions.add(new GWTPosition(position.getRow(), position.getColumn())); - Map groupProperties = new HashMap<>(); - for (String propName : group.getPropertyNames()) - { - groupProperties.put(propName, group.getProperty(propName)); - } - - // NOTE: Use negative rowId for unsaved well groups to support GWTWellGroup.equals() - int wellGroupId = copyTemplate || group.getRowId() == null ? -1 * (i+1) : group.getRowId(); - GWTWellGroup gwtWellGroup = new GWTWellGroup(wellGroupId, group.getType().name(), group.getName(), positions, groupProperties); - gwtWellGroup.setAllowNewGroups(handler.canCreateNewGroups(group.getType())); - translated.add(gwtWellGroup); - } - - long newPlateId = copyTemplate || template.getRowId() == null ? -1 : template.getRowId(); - GWTPlate plate = new GWTPlate(newPlateId, - template.getName(), template.getAssayType(), template.getRows(), - template.getColumns(), getTypeList(template), handler.showEditorWarningPanel()); - plate.setGroups(translated); - plate.setTypesToDefaultGroups(handler.getDefaultGroupsForTypes()); - - Map templateProperties = new HashMap<>(); - for (String propName : template.getPropertyNames()) - { - templateProperties.put(propName, template.getProperty(propName) == null ? null : template.getProperty(propName).toString()); - } - plate.setPlateProperties(templateProperties); - return plate; - } - catch (SQLException e) - { - LOG.error("Error create plate from template", e); - throw new Exception(e); - } - } - - private List getTypeList(Plate template) - { - List wellTypes = Arrays.asList( - WellGroup.Type.CONTROL, WellGroup.Type.SPECIMEN, - WellGroup.Type.REPLICATE, WellGroup.Type.OTHER); - - PlateLayoutHandler handler = PlateManager.get().getPlateLayoutHandler(template.getAssayType()); - if (handler != null) - wellTypes = handler.getWellGroupTypes(); - - List types = new ArrayList<>(); - for (WellGroup.Type type : wellTypes) - types.add(type.name()); - return types; - } - - @Override - public long saveChanges(GWTPlate gwtPlate, boolean replaceIfExisting) throws Exception - { - try - { - boolean updateExisting = false; - Plate plate; - if (gwtPlate.getRowId() > 0) - { - plate = PlateManager.get().getPlate(getContainer(), gwtPlate.getRowId()); - if (plate == null) - throw new Exception("Plate template not found: " + gwtPlate.getRowId()); - - // check another plate of the same name doesn't already exist - if (PlateManager.get().isDuplicatePlateName(getContainer(), getUser(), gwtPlate.getName(), null) && !replaceIfExisting) - throw new Exception("A plate template with name '" + gwtPlate.getName() + "' already exists."); - - if (!plate.getAssayType().equals(gwtPlate.getType())) - throw new Exception("Plate template type '" + plate.getAssayType() + "' cannot be changed for '" + gwtPlate.getName() + "'"); - - if (plate.getRows() != gwtPlate.getRows() || plate.getColumns() != gwtPlate.getCols()) - throw new Exception("Plate template dimensions cannot be changed for '" + gwtPlate.getName() + "'"); - - // TODO: Use a version column to avoid concurrent updates - - updateExisting = true; - } - else - { - // check another plate of the same name doesn't already exist - Plate other = PlateManager.get().getPlateByName(getContainer(), gwtPlate.getName()); - if (other != null) - { - if (!replaceIfExisting) - throw new Exception("A plate template with name '" + gwtPlate.getName() + "' already exists."); - - // delete the existing plate first - PlateService.get().deletePlate(getContainer(), getUser(), other.getRowId()); - } - - PlateType plateType = PlateService.get().getPlateType(gwtPlate.getRows(), gwtPlate.getCols()); - if (plateType == null) - throw new Exception("The plate type : (" + gwtPlate.getRows() + " x " + gwtPlate.getCols() + ") does not exist"); - plate = PlateManager.get().createPlate(getContainer(), gwtPlate.getType(), plateType); - } - - plate.setName(gwtPlate.getName()); - plate.setProperties(gwtPlate.getPlateProperties()); - - // first, mark well groups not submitted for saving as deleted - Set groups = gwtPlate.getGroups(); - List existingWellGroups = plate.getWellGroups(); - for (WellGroup existingWellGroup : existingWellGroups) - { - if (groups.stream().noneMatch(g-> g.getRowId() == existingWellGroup.getRowId())) - ((PlateImpl)plate).markWellGroupForDeletion(existingWellGroup); - } - - // next, update positions on existing well groups or create new well groups - for (GWTWellGroup gwtGroup : groups) - { - WellGroup.Type groupType = WellGroup.Type.valueOf(gwtGroup.getType()); - List positions = new ArrayList<>(); - for (GWTPosition gwtPosition : gwtGroup.getPositions()) - positions.add(plate.getPosition(gwtPosition.getRow(), gwtPosition.getCol())); - - WellGroupImpl group; - if (updateExisting && gwtGroup.getRowId() > 0) - { - group = findExistingWellGroup(existingWellGroups, gwtGroup.getRowId()); - if (group == null) - throw new Exception("Well group " + gwtGroup.getRowId() + " wasn't found"); - if (group.getType() != groupType) - throw new Exception("Well group cannot be changed: " + gwtGroup.getName()); - - group.setName(gwtGroup.getName()); - group.setPositions(positions); - - ((PlateImpl)plate).storeWellGroup(group); - } - else - { - assert gwtGroup.getRowId() <= 0 : "Updating existing well group on a new template"; - group = (WellGroupImpl) plate.addWellGroup(gwtGroup.getName(), groupType, positions); - } - - group.setProperties(gwtGroup.getProperties()); - } - - PlateManager.get().getPlateLayoutHandler(plate.getAssayType()).validatePlate(getContainer(), getUser(), plate); - return PlateService.get().save(getContainer(), getUser(), plate); - } - catch (BatchValidationException | ValidationException e) - { - LOG.error("Error saving plate", e); - throw new Exception(e); - } - } - - private WellGroupImpl findExistingWellGroup(List wellGroups, int rowId) - { - for (WellGroup wellGroup : wellGroups) - { - if (wellGroup.getRowId() != null && wellGroup.getRowId() == rowId) - return (WellGroupImpl) wellGroup; - } - return null; - } -} diff --git a/assay/src/org/labkey/assay/view/AssayGWTView.java b/assay/src/org/labkey/assay/view/AssayGWTView.java deleted file mode 100644 index 822aee9d815..00000000000 --- a/assay/src/org/labkey/assay/view/AssayGWTView.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2010-2013 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.assay.view; - -import com.google.gwt.core.client.EntryPoint; -import gwt.client.org.labkey.assay.AssayApplication; -import org.labkey.api.view.GWTView; - -import java.util.Map; - -/** - * User: matthewb - * Date: Mar 31, 2010 - * Time: 2:21:17 PM - */ -public class AssayGWTView extends GWTView -{ - public AssayGWTView(AssayApplication.GWTModule module, Map properties) - { - super("gwt.AssayApplication", properties); - getModelBean().getProperties().put("GWTModule", module.getClass().getSimpleName()); - } - - public AssayGWTView(Class clss, Map properties) - { - super("gwt.AssayApplication", properties); - for (AssayApplication.GWTModule m : AssayApplication.GWTModule.values()) - { - if (m.className.equals(clss.getName())) - { - getModelBean().getProperties().put("GWTModule", m.getClass().getSimpleName()); - return; - } - } - throw new IllegalArgumentException(clss.getName()); - } -} diff --git a/experiment/src/org/labkey/experiment/api/ExpDataClassDataTestCase.jsp b/experiment/src/org/labkey/experiment/api/ExpDataClassDataTestCase.jsp index 26381bc8d2f..efbcf19c39a 100644 --- a/experiment/src/org/labkey/experiment/api/ExpDataClassDataTestCase.jsp +++ b/experiment/src/org/labkey/experiment/api/ExpDataClassDataTestCase.jsp @@ -107,8 +107,8 @@ <%@ page import="java.util.concurrent.TimeUnit" %> <%@ page import="java.util.stream.Collectors" %> <%@ page import="static org.labkey.api.util.PageFlowUtil.encodeURIComponent" %> -<%@ page import="static org.labkey.api.exp.api.ExperimentService.asInteger" %> -<%@ page import="static org.labkey.api.exp.api.ExperimentService.asLong" %> +<%@ page import="static org.labkey.api.util.IntegerUtils.asInteger" %> +<%@ page import="static org.labkey.api.util.IntegerUtils.asLong" %> <%@ page import="static org.hamcrest.Matchers.containsString" %> <%@ page extends="org.labkey.api.jsp.JspTest.BVT" %> diff --git a/experiment/src/org/labkey/experiment/api/ExpSampleTypeTestCase.jsp b/experiment/src/org/labkey/experiment/api/ExpSampleTypeTestCase.jsp index 10e13d4a0ea..04332ea21c8 100644 --- a/experiment/src/org/labkey/experiment/api/ExpSampleTypeTestCase.jsp +++ b/experiment/src/org/labkey/experiment/api/ExpSampleTypeTestCase.jsp @@ -82,8 +82,8 @@ <%@ page import="java.util.concurrent.TimeUnit" %> <%@ page import="org.jetbrains.annotations.NotNull" %> <%@ page import="org.labkey.api.dataiterator.MapDataIterator" %> -<%@ page import="static org.labkey.api.exp.api.ExperimentService.asInteger" %> -<%@ page import="static org.labkey.api.exp.api.ExperimentService.asLong" %> +<%@ page import="static org.labkey.api.util.IntegerUtils.asInteger" %> +<%@ page import="static org.labkey.api.util.IntegerUtils.asLong" %> <%@ page import="static java.util.Collections.emptyList" %> <%@ page import="org.jetbrains.annotations.Nullable" %> <%@ page import="org.labkey.api.view.ActionURL" %> diff --git a/experiment/src/org/labkey/experiment/api/ExperimentServiceImpl.java b/experiment/src/org/labkey/experiment/api/ExperimentServiceImpl.java index 383e42b212d..843bd1e491a 100644 --- a/experiment/src/org/labkey/experiment/api/ExperimentServiceImpl.java +++ b/experiment/src/org/labkey/experiment/api/ExperimentServiceImpl.java @@ -24,8 +24,9 @@ import org.apache.commons.collections4.multimap.ArrayListValuedHashMap; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Strings; import org.apache.commons.lang3.math.NumberUtils; -import org.apache.commons.lang3.mutable.MutableInt; +import org.apache.commons.lang3.mutable.MutableLong; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.fhcrc.cpas.exp.xml.SimpleTypeNames; @@ -327,14 +328,14 @@ public class ExperimentServiceImpl implements ExperimentService, ObjectReference private static final Logger LOG = LogHelper.getLogger(ExperimentServiceImpl.class, "Experiment infrastructure including maintaining runs and lineage"); private final Cache PROTOCOL_ROW_ID_CACHE = DatabaseCache.get(getExpSchema().getScope(), CacheManager.UNLIMITED, CacheManager.HOUR, "Protocol by RowId", - (key, argument) -> getExpProtocol(new SimpleFilter(FieldKey.fromParts("RowId"), key))); + (key, _) -> getExpProtocol(new SimpleFilter(FieldKey.fromParts("RowId"), key))); private final Cache PROTOCOL_LSID_CACHE = DatabaseCache.get(getExpSchema().getScope(), CacheManager.UNLIMITED, CacheManager.HOUR, "Protocol by LSID", - (key, argument) -> getExpProtocol(new SimpleFilter(FieldKey.fromParts("LSID"), key))); + (key, _) -> getExpProtocol(new SimpleFilter(FieldKey.fromParts("LSID"), key))); private final Cache EXPERIMENT_RUN_CACHE = DatabaseCache.get(getExpSchema().getScope(), getTinfoExperimentRun().getCacheSize(), "Experiment Run by LSID", new ExperimentRunCacheLoader()); - private final Cache> dataClassCache = CacheManager.getBlockingStringKeyCache(CacheManager.UNLIMITED, CacheManager.DAY, "Data classes", (containerId, argument) -> + private final Cache> dataClassCache = CacheManager.getBlockingStringKeyCache(CacheManager.UNLIMITED, CacheManager.DAY, "Data classes", (containerId, _) -> { Container c = ContainerManager.getForId(containerId); if (c == null) @@ -536,7 +537,7 @@ public ExperimentRunType getExperimentRunType(@NotNull String description, @Null @Override public List getExpRuns(Container container, @Nullable ExpProtocol parentProtocol, @Nullable ExpProtocol childProtocol) { - return getExpRuns(container, parentProtocol, childProtocol, run -> true); + return getExpRuns(container, parentProtocol, childProtocol, _ -> true); } @Override @@ -921,7 +922,7 @@ public List getExpMaterialsByName(@NotNull Collection n return null; if (materials.size() > 1) throw new IllegalArgumentException("Expected 0 or 1 samples, got: " + materials.size()); - return materials.get(0); + return materials.getFirst(); } public List findIdsNotPermittedForOperation(List candidates, SampleTypeService.SampleOperations operation) @@ -1019,7 +1020,7 @@ public List getExpMaterialsByObjectId(ContainerFilter container @Override public void enumerateDocuments(SearchService.TaskIndexingQueue queue, final Date modifiedSince) { - queue.addRunnable((a) -> { + queue.addRunnable((_) -> { for (ExpSampleTypeImpl sampleType : getIndexableSampleTypes(queue.getContainer(), modifiedSince)) { sampleType.index(queue, null); @@ -1075,20 +1076,20 @@ private void indexMaterials(final @NotNull SearchService.TaskIndexingQueue queue sql = getSchema().getSqlDialect().limitRows(sql, INDEXING_LIMIT); SqlSelector selector = new SqlSelector(getSchema(), sql); selector.setJdbcCaching(false); - MutableInt maxRowIdProcessed = new MutableInt(minRowId); + MutableLong maxRowIdProcessed = new MutableLong(minRowId); // Work in modest block sizes and fetch as a list so we don't keep the ResultSet open, which could lock the tables List materials = selector.getArrayList(Material.class); materials.forEach(m -> { ExpMaterialImpl expMaterial = new ExpMaterialImpl(m); expMaterial.index(queue, null); - maxRowIdProcessed.setValue(Math.max(maxRowIdProcessed.getValue(), expMaterial.getRowId())); + maxRowIdProcessed.setValue(Math.max(maxRowIdProcessed.longValue(), expMaterial.getRowId())); }); if (materials.size() == INDEXING_LIMIT) { // Requeue for the next batch. This avoids overwhelming the indexer's queue with documents - queue.addRunnable((q) -> indexMaterials(q, modifiedSince, maxRowIdProcessed.getValue())); + queue.addRunnable((q) -> indexMaterials(q, modifiedSince, maxRowIdProcessed.longValue())); } } @@ -1113,20 +1114,20 @@ public void indexData(final @NotNull SearchService.TaskIndexingQueue queue, fina sql = getSchema().getSqlDialect().limitRows(sql, INDEXING_LIMIT); SqlSelector selector = new SqlSelector(getSchema(), sql); selector.setJdbcCaching(false); - MutableInt maxRowIdProcessed = new MutableInt(minRowId); + MutableLong maxRowIdProcessed = new MutableLong(minRowId); // Work in modest block sizes and fetch as a list so we don't keep the ResultSet open, which could lock the tables List data = selector.getArrayList(Data.class); data.forEach(d -> { ExpDataImpl expData = new ExpDataImpl(d); expData.index(queue, null); - maxRowIdProcessed.setValue(Math.max(maxRowIdProcessed.getValue(), expData.getRowId())); + maxRowIdProcessed.setValue(Math.max(maxRowIdProcessed.longValue(), expData.getRowId())); }); if (data.size() == INDEXING_LIMIT) { // Requeue for the next batch. This avoids overwhelming the indexer's queue with documents - queue.addRunnable((q) -> indexData(q, modifiedSince, maxRowIdProcessed.getValue())); + queue.addRunnable((q) -> indexData(q, modifiedSince, maxRowIdProcessed.longValue())); } } @@ -1298,7 +1299,7 @@ private void indexDataClassData(ExpDataClassImpl dataClass, SearchService.TaskIn .add(dataClass.getModified()); var scope = table.getSchema().getScope(); - scope.executeWithRetryReadOnly(tx -> + scope.executeWithRetryReadOnly(_ -> new SqlSelector(scope, sql).forEachBatch(Data.class, 1000, batch -> queue.addRunnable((q) -> batch.forEach(data -> new ExpDataImpl(data).index(q, null)) @@ -1387,7 +1388,7 @@ public ExpProtocolImpl getExpProtocol(String lsid) if (protocols.isEmpty()) return null; - return protocols.get(0); + return protocols.getFirst(); } private void uncacheProtocol(Protocol p) @@ -1945,7 +1946,7 @@ public ExpData findExpData( { Long rowId = asLong(cache.remap(ExpSchema.SCHEMA_EXP_DATA, dataClassName, user, c, getContainerFilterTypeForFind(c), dataName)); if (rowId != null) - return dataCache.computeIfAbsent(rowId, (x) -> getExpData(dataClass, rowId)); + return dataCache.computeIfAbsent(rowId, (_) -> getExpData(dataClass, rowId)); } catch (ConversionException e2) { @@ -1960,7 +1961,7 @@ public ExpData findExpData( Long rowId = ConvertHelper.convert(dataName, Long.class); // now attempt to resolve by rowId - return dataCache.computeIfAbsent(rowId, (x) -> getExpData(dataClass, rowId)); + return dataCache.computeIfAbsent(rowId, (_) -> getExpData(dataClass, rowId)); } catch (ConversionException e1) { @@ -2083,7 +2084,7 @@ public ExpExperiment createHiddenRunGroup(Container container, User user, ExpRun // We don't care which one we use. It's possible to have multiple matches if a run was deleted that was // already part of a hidden run group. - return new ExpExperimentImpl(exp.get(0)); + return new ExpExperimentImpl(exp.getFirst()); } else { @@ -2168,7 +2169,7 @@ public Set getMaterialInputRoles(Container container, User user, ExpProt return getInputRoles(container, ContainerFilter.current(container, user), getTinfoMaterialInput(), types); } - private Set getInputRoles(Container container, ContainerFilter filter, TableInfo table, ExpProtocol.ApplicationType... types) + private Set getInputRoles(Container ignoredContainer, ContainerFilter filter, TableInfo table, ExpProtocol.ApplicationType... types) { SQLFragment sql = new SQLFragment("SELECT role FROM "); sql.append(table, "t"); @@ -2491,7 +2492,7 @@ else if (parent instanceof ExpMaterial materialParent) type = sampleType.getName(); } - parentByType.computeIfAbsent(type, k -> new ArrayList<>()); + parentByType.computeIfAbsent(type, _ -> new ArrayList<>()); String parentName = parent.getName(); if (parentName.contains(",")) parentName = "\"" + parentName + "\""; @@ -2698,7 +2699,7 @@ private Pair getRunGraphCommonTableExpressions(SQLFragment ret, S String parentsInnerToken = ret.addCommonTableExpression(dialect, parentsInnerSelect, "org_lk_exp_PARENTS_INNER", parentsInnerSelectFrag, recursive); String parentsSelect = map.get("$PARENTS$"); - parentsSelect = StringUtils.replace(parentsSelect, "$PARENTS_INNER$", parentsInnerToken); + parentsSelect = Strings.CS.replace(parentsSelect, "$PARENTS_INNER$", parentsInnerToken); // don't use parentsSelect as key, it may not consolidate correctly because of parentsInnerToken parentsToken = ret.addCommonTableExpression(dialect, "$PARENTS$/" + Objects.toString(options.getExpTypeValue(), "ALL") + "/" + parentsInnerSelect, "org_lk_exp_PARENTS", SQLFragment.unsafe(parentsSelect), recursive); } @@ -2707,13 +2708,13 @@ private Pair getRunGraphCommonTableExpressions(SQLFragment ret, S if (options.isChildren()) { String childrenInnerSelect = map.get("$CHILDREN_INNER$"); - childrenInnerSelect = StringUtils.replace(childrenInnerSelect, "$EDGES$", edgesToken); + childrenInnerSelect = Strings.CS.replace(childrenInnerSelect, "$EDGES$", edgesToken); SQLFragment childrenInnerSelectFrag = SQLFragment.unsafe(childrenInnerSelect); childrenInnerSelectFrag.addAll(lsidsFrag.getParams()); String childrenInnerToken = ret.addCommonTableExpression(dialect, childrenInnerSelect, "org_lk_exp_CHILDREN_INNER", childrenInnerSelectFrag, recursive); String childrenSelect = map.get("$CHILDREN$"); - childrenSelect = StringUtils.replace(childrenSelect, "$CHILDREN_INNER$", childrenInnerToken); + childrenSelect = Strings.CS.replace(childrenSelect, "$CHILDREN_INNER$", childrenInnerToken); // don't use childrenSelect as key, it may not consolidate correctly because of childrenInnerToken childrenToken = ret.addCommonTableExpression(dialect, "$CHILDREN$/" + Objects.toString(options.getExpTypeValue(), "ALL") + "/" + childrenInnerSelect, "org_lk_exp_CHILDREN", SQLFragment.unsafe(childrenSelect), recursive); } @@ -2985,7 +2986,7 @@ private Long ensureOwnerObject(@Nullable String cpasType, @NotNull Map { + return cpasTypeToObjectId.computeIfAbsent(cpasType, (_) -> { // NOTE: We can't use OntologyManager.ensureObject() here (which caches) because we don't know what container the SampleType is defined in OntologyObject oo = OntologyManager.getOntologyObject(null, cpasType); @@ -3302,7 +3303,7 @@ SyncRunEdges doIncrementalClosureInvalidation(boolean i) void sync(@Nullable Map cpasTypeToObjectId) { DbScope expScope = getExpSchema().getScope(); - expScope.executeWithRetry((DbScope.RetryFn) tx -> { + expScope.executeWithRetry((DbScope.RetryFn) _ -> { syncInner(cpasTypeToObjectId); return null; }); @@ -3664,7 +3665,7 @@ public ProtocolApplication getStartingProtocolApplication(long runId) if (!protocolApplications.isEmpty()) { - protocolApplication = protocolApplications.get(0); + protocolApplication = protocolApplications.getFirst(); } return protocolApplication; } @@ -4110,7 +4111,7 @@ private Map> getRunInputMaterial(Map[] ma for (Map map : maps) { String runLSID = (String) map.get("RunLSID"); - List list = outputMap.computeIfAbsent(runLSID, k -> new ArrayList<>()); + List list = outputMap.computeIfAbsent(runLSID, _ -> new ArrayList<>()); Material m = f.fromMap(map); list.add(m); } @@ -4221,7 +4222,7 @@ public ExpDataImpl getExpDataByURL(String url, @Nullable Container c) if (data.isEmpty()) return null; - return new ExpDataImpl(data.get(0)); + return new ExpDataImpl(data.getFirst()); } public Lsid getDataClassLsid(Container container) @@ -4438,7 +4439,6 @@ private Collection getRelatedProtocolIds(Collection selectedProtocol while (!idsToCheck.isEmpty()) { String idsString = StringUtils.join(idsToCheck.iterator(), ", "); - idsToCheck = new HashSet<>(); StringBuilder sb = new StringBuilder(); sb.append("SELECT ParentProtocolId FROM exp.ProtocolAction WHERE ChildProtocolId IN ("); @@ -4446,7 +4446,7 @@ private Collection getRelatedProtocolIds(Collection selectedProtocol sb.append(")"); Long[] newIds = new SqlSelector(getExpSchema(), sb.toString()).getArray(Long.class); - idsToCheck.addAll(Arrays.asList(newIds)); + idsToCheck = new HashSet<>(Arrays.asList(newIds)); sb = new StringBuilder(); sb.append("SELECT ChildProtocolId FROM exp.ProtocolAction WHERE ParentProtocolId IN ("); @@ -4516,7 +4516,7 @@ public void deleteProtocolByRowIds(Container c, User user, @Nullable String audi List expProtocols = Arrays.stream(protocols).map(ExpProtocolImpl::new).collect(toList()); if (!c.hasPermission(user, AdminPermission.class) && !runs.isEmpty()) - throw new UnauthorizedException("You do not have sufficient permissions to delete '" + (expProtocols.size() == 1 ? expProtocols.get(0).getName() : "the protocols") + "'."); + throw new UnauthorizedException("You do not have sufficient permissions to delete '" + (expProtocols.size() == 1 ? expProtocols.getFirst().getName() : "the protocols") + "'."); AssayService assayService = AssayService.get(); @@ -4709,7 +4709,7 @@ public static ArrayList> includeLinkedToStudyText(List new HashSet<>()) + sampleTypeAliquotRoots.computeIfAbsent(sampleType, (_) -> new HashSet<>()) .add(material.getRootMaterialRowId()); } } @@ -5346,7 +5346,7 @@ public void deleteDataByRowIds(User user, Container container, Collection if (data.getClassId() != null) { - List byClass = rowIdsByClass.computeIfAbsent(data.getClassId(), k -> new ArrayList<>(10)); + List byClass = rowIdsByClass.computeIfAbsent(data.getClassId(), _ -> new ArrayList<>(10)); byClass.add(data.getRowId()); } allLsids.add(data.getLSID()); @@ -5631,7 +5631,7 @@ public void beforeDeleteData(User user, Container container, List d for (ExpData data : datas) { ExperimentDataHandler handler = data.findDataHandler(); - List list = handlers.computeIfAbsent(handler, k -> new ArrayList<>()); + List list = handlers.computeIfAbsent(handler, _ -> new ArrayList<>()); list.add(data); } for (Map.Entry> entry : handlers.entrySet()) @@ -6852,7 +6852,7 @@ public ExpRun saveSimpleExperimentRun( { throw new IllegalArgumentException("Protocol has the wrong number of steps for a simple protocol; it should have three."); } - ExpProtocolActionImpl action1 = actions.get(0); + ExpProtocolActionImpl action1 = actions.getFirst(); assert action1.getActionSequence() == SIMPLE_PROTOCOL_FIRST_STEP_SEQUENCE; assert action1.getChildProtocol().getRowId() == parentProtocol.getRowId(); @@ -7107,7 +7107,7 @@ private void _prepareRun(DeriveSamplesBulkHelper helper, ExpRunImpl run, SimpleR { throw new IllegalArgumentException("Protocol has the wrong number of steps for a simple protocol; it should have three."); } - ExpProtocolActionImpl action1 = actions.get(0); + ExpProtocolActionImpl action1 = actions.getFirst(); assert action1.getActionSequence() == SIMPLE_PROTOCOL_FIRST_STEP_SEQUENCE; assert action1.getChildProtocol().getRowId() == parentProtocol.getRowId(); @@ -7318,7 +7318,7 @@ private Map saveExpRunsBatch(Container c, List> p { // insert into exp.object List> expObjectParams = params.stream().map( - runParams -> List.of(/* LSID */ runParams.get(0), c.getId()) + runParams -> List.of(/* LSID */ runParams.getFirst(), c.getId()) ).collect(toList()); String expObjectSql = "INSERT INTO " + OntologyManager.getTinfoObject() + " (ObjectUri, Container) VALUES (?, ?)"; @@ -7331,7 +7331,7 @@ private Map saveExpRunsBatch(Container c, List> p Table.batchExecute(getExpSchema(), sql, params); - List runLsids = params.stream().map(p -> (String) p.get(0)).toList(); + List runLsids = params.stream().map(p -> (String) p.getFirst()).toList(); SimpleFilter filter = new SimpleFilter(FieldKey.fromParts(ExpExperimentTable.Column.LSID.name()), runLsids, IN); Map ret = new CaseInsensitiveHashMap<>(); getExperimentRuns(filter).forEach(er -> ret.put(er.getLSID(), er)); @@ -8191,7 +8191,7 @@ public void validateDataClassName(@NotNull Container c, @NotNull User u, String throw new ApiUsageException(reservedError); } - private void validateDataClassOptions(@NotNull Container c, @NotNull User u, @Nullable DataClassDomainKindProperties options) + private void validateDataClassOptions(@NotNull Container c, @NotNull User ignoredU, @Nullable DataClassDomainKindProperties options) { if (options == null) return; @@ -8474,7 +8474,7 @@ private void insertProtocolSteps(Protocol baseProtocol, @Nullable List getNameExpressionMetrics() return metrics; } - public @NotNull Pair, Set> getDataTypesWithRequiredLineage(Integer parentDataTypeRowId, boolean isSampleParent, Container container, User user) + public @NotNull Pair, Set> getDataTypesWithRequiredLineage(Integer parentDataTypeRowId, boolean isSampleParent, Container container, User ignoredUser) { Set sampleTypes = new HashSet<>(); Set dataClasses = new HashSet<>(); @@ -9529,7 +9529,7 @@ public boolean hasMissingRequiredParent(String parentCpasType, String childCpasT return totalCount > withParentCount; } - public String getInvalidRequiredImportAliasUpdate(String dataTypeLsid, boolean isSampleType, Map> newAliases, Set existingRequiredInputs, Container c, User u) + public String getInvalidRequiredImportAliasUpdate(String dataTypeLsid, boolean isSampleType, Map> newAliases, Set existingRequiredInputs, Container c, User ignoredU) { for (Map.Entry> newEntry : newAliases.entrySet()) { @@ -9589,7 +9589,7 @@ public Pair getCurrentAndCrossFolderDataCount(Collection .add(container.getId()) .append("\nAND RowId "); dialect.appendInClauseSql(currentFolderCountSql, rowIds); - int currentFolderSelectionCount = new SqlSelector(expSchema, currentFolderCountSql).getArrayList(Integer.class).get(0); + int currentFolderSelectionCount = new SqlSelector(expSchema, currentFolderCountSql).getArrayList(Integer.class).getFirst(); SQLFragment crossFolderCountSql = new SQLFragment() .append(" SELECT COUNT(*) FROM ") @@ -9598,7 +9598,7 @@ public Pair getCurrentAndCrossFolderDataCount(Collection .add(container.getId()) .append("\nAND RowId "); dialect.appendInClauseSql(crossFolderCountSql, rowIds); - int crossFolderSelectionCount = new SqlSelector(expSchema, crossFolderCountSql).getArrayList(Integer.class).get(0); + int crossFolderSelectionCount = new SqlSelector(expSchema, crossFolderCountSql).getArrayList(Integer.class).getFirst(); return new Pair<>(currentFolderSelectionCount, crossFolderSelectionCount); } @@ -9703,7 +9703,7 @@ public Map moveDataClassObjects( // move audit events associated with the sources that are moving int auditEventCount = QueryService.get().moveAuditEvents(targetContainer, dataIds, "exp.data", dataClassTable.getName()); - updateCounts.compute("sourceAuditEvents", (k, c) -> c == null ? auditEventCount : c + auditEventCount); + updateCounts.compute("sourceAuditEvents", (_, c) -> c == null ? auditEventCount : c + auditEventCount); // create summary audit entries for the source container only. The message is pretty generic, so having it // in both source and target doesn't help much. @@ -9776,7 +9776,7 @@ private Map moveDerivationRuns(Collection da Map> runIdData = new LongHashMap<>(); dataObjects.forEach(dataObject -> { if (dataObject.getRunId() != null) - runIdData.computeIfAbsent(dataObject.getRunId(), t -> new HashSet<>()).add(dataObject); + runIdData.computeIfAbsent(dataObject.getRunId(), _ -> new HashSet<>()).add(dataObject); }); // find the set of runs associated with data objects that are moving List toUpdate = new ArrayList<>(); @@ -9899,7 +9899,7 @@ public Map moveAssayRuns(@NotNull List assayR Map> protocolMap = new HashMap<>(); assayRuns.forEach(run -> - protocolMap.computeIfAbsent(run.getProtocol(), t -> new ArrayList<>()).add(run)); + protocolMap.computeIfAbsent(run.getProtocol(), _ -> new ArrayList<>()).add(run)); List runLsids = assayRuns.stream().map(ExpRun::getLSID).toList(); @@ -10416,7 +10416,7 @@ public void testRunInputProperties() throws Exception List materialRunInputs = pa.getMaterialInputs(); assertEquals(1, materialRunInputs.size()); - ExpMaterialRunInputImpl materialRunInput = (ExpMaterialRunInputImpl)materialRunInputs.get(0); + ExpMaterialRunInputImpl materialRunInput = (ExpMaterialRunInputImpl)materialRunInputs.getFirst(); assertEquals(sampleIn, materialRunInput.getMaterial()); assertEquals("Sample Goo", materialRunInput.getRole()); assertEquals(MaterialInput.NAMESPACE, materialRunInput.getLSIDNamespacePrefix()); diff --git a/experiment/src/org/labkey/experiment/api/property/GWTDomainMixin.java b/experiment/src/org/labkey/experiment/api/property/GWTDomainMixin.java index 7aba30e2013..0b4747b61a6 100644 --- a/experiment/src/org/labkey/experiment/api/property/GWTDomainMixin.java +++ b/experiment/src/org/labkey/experiment/api/property/GWTDomainMixin.java @@ -19,10 +19,11 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; /** - * Configures the fields that are not returned when serializing a GWTDomain. - * Ideally we would just add the @JsonIgnore annotations to GWTDomain directly, - * but the GWT compiler would need to have jackson on the classpath which isn't - * necessary. + * Scopes Jackson annotations to the ObjectMapper used by the listDomains action. + * The @JsonIgnoreProperties fields are excluded from list responses to reduce payload + * size, but are still needed by other callers (e.g. getDomainDetails for the domain + * designer). The @JsonFilter must also remain scoped here because only this ObjectMapper + * registers the "listDomainsActionFilter" filter. */ @JsonIgnoreProperties({ "_Ts", @@ -31,8 +32,7 @@ "excludeFromExportFieldNames", "phiNotAllowedFieldNames", "defaultValuesURL", - "provisioned", - "domainException" + "provisioned" }) @JsonFilter("listDomainsActionFilter") diff --git a/experiment/src/org/labkey/experiment/api/property/PropertyServiceImpl.java b/experiment/src/org/labkey/experiment/api/property/PropertyServiceImpl.java index 0ea06467b31..d9bbe8f368e 100644 --- a/experiment/src/org/labkey/experiment/api/property/PropertyServiceImpl.java +++ b/experiment/src/org/labkey/experiment/api/property/PropertyServiceImpl.java @@ -22,7 +22,6 @@ import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; import org.apache.commons.beanutils.ConversionException; -import org.apache.commons.beanutils.ConvertUtils; import org.apache.commons.lang3.StringUtils; import org.fhcrc.cpas.exp.xml.DefaultType; import org.fhcrc.cpas.exp.xml.DomainDescriptorType; @@ -73,9 +72,7 @@ import org.labkey.api.exp.query.ExpSchema; import org.labkey.api.exp.xar.LsidUtils; import org.labkey.api.gwt.client.DefaultValueType; -import org.labkey.api.gwt.client.assay.model.GWTPropertyDescriptorMixin; import org.labkey.api.gwt.client.model.GWTDomain; -import org.labkey.api.gwt.client.model.GWTPropertyDescriptor; import org.labkey.api.ontology.OntologyService; import org.labkey.api.query.FieldKey; import org.labkey.api.query.QueryService; @@ -491,7 +488,6 @@ public void configureObjectMapper(ObjectMapper om, @Nullable SimpleBeanPropertyF .addFilter("listDomainsActionFilter", gwtDomainPropertiesFilter); om.setFilterProvider(gwtDomainFilterProvider); om.addMixIn(GWTDomain.class, GWTDomainMixin.class); - om.addMixIn(GWTPropertyDescriptor.class, GWTPropertyDescriptorMixin.class); om.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true); } @@ -684,7 +680,7 @@ public Set findVocabularyProperties(Container container, Set getUsageMetrics() DbSchema schema = ExperimentService.get().getSchema(); String lengthFn = schema.getSqlDialect().getVarcharLengthFunction(); - TableInfo t = new ExpSchema(User.getAdminServiceUser(), ContainerManager.getRoot()).getTable(ExpSchema.TableType.Fields.name(), ContainerFilter.getUnsafeEverythingFilter()); + TableInfo t = new ExpSchema(User.getAdminServiceUser(), ContainerManager.getRoot()).getTableOrThrow(ExpSchema.TableType.Fields.name(), ContainerFilter.getUnsafeEverythingFilter()); long storageColumnNameMismatches = new TableSelector(t, new SimpleFilter(FieldKey.fromParts("StorageColumnNameMatch"), false), null).getRowCount(); return Map.of( @@ -752,7 +748,7 @@ private Map stripUriPrefixes(@NotNull Map value key = key.split("#")[1]; } key = key.replace("xsd:", ""); - result.compute(key, (k, v) -> v == null ? value : v.intValue() + value); + result.compute(key, (_, v) -> v == null ? value : v.intValue() + value); } return result; } diff --git a/query/src/org/labkey/query/MetadataTableJSON.java b/query/src/org/labkey/query/MetadataTableJSON.java index 934c621caa6..8e795f33b5a 100644 --- a/query/src/org/labkey/query/MetadataTableJSON.java +++ b/query/src/org/labkey/query/MetadataTableJSON.java @@ -69,7 +69,7 @@ import java.util.Objects; import java.util.Set; -import static org.labkey.api.gwt.client.ui.PropertyType.CALCULATED_CONCEPT_URI; +import static org.labkey.api.exp.PropertyType.CALCULATED_CONCEPT_URI; /** * User: jeckels @@ -83,12 +83,6 @@ public class MetadataTableJSON extends GWTDomain private static final Logger log = LogHelper.getLogger(MetadataTableJSON.class, "Visual editor support for table/query metadata"); - @Override - public boolean isEditable(MetadataColumnJSON field) - { - return true; - } - public boolean isUserDefinedQuery() { return _userDefinedQuery; @@ -129,7 +123,7 @@ private static TableInfo getRawTableInfo(UserSchema schema, String tableName, @N ArrayList errors = new ArrayList<>(); TablesDocument doc = moduleQueryDef.getParsedMetadata().getTablesDocument(errors); if (!errors.isEmpty()) - throw UnexpectedException.wrap(errors.get(0)); + throw UnexpectedException.wrap(errors.getFirst()); if (doc != null) { @@ -139,7 +133,7 @@ private static TableInfo getRawTableInfo(UserSchema schema, String tableName, @N List tableTypes = Collections.singletonList(tables.getTableArray(0)); tableInfo.overlayMetadata(tableTypes, schema, errors); if (!errors.isEmpty()) - throw UnexpectedException.wrap(errors.get(0)); + throw UnexpectedException.wrap(errors.getFirst()); } } } @@ -484,7 +478,7 @@ else if (xmlColumn.isSetImportAliases()) fk.setFkColumnName(rawLookupColumnName); // Issue 48973: don't overwrite existing target FK columns that were set via source else if (fk.getFkColumnName() == null) - fk.setFkColumnName(pkCols.get(0)); + fk.setFkColumnName(pkCols.getFirst()); if (targetContainer != null) fk.setFkFolderPath(targetContainer.getPath()); @@ -751,7 +745,7 @@ else if (columnInfo.getValueExpression() != null) if (queryDefs != null && !queryDefs.isEmpty()) { // Use the last QueryDef's metadata -- this should be the user's metadata override in the database if it exists - QueryDef queryDef = queryDefs.get(queryDefs.size()-1); + QueryDef queryDef = queryDefs.getLast(); if (!container.getId().equals(queryDef.getContainerId())) { diff --git a/query/src/org/labkey/query/MultiValueTest.jsp b/query/src/org/labkey/query/MultiValueTest.jsp index c2f90629e65..ebe587b1f4c 100644 --- a/query/src/org/labkey/query/MultiValueTest.jsp +++ b/query/src/org/labkey/query/MultiValueTest.jsp @@ -33,8 +33,8 @@ <%@ page import="java.util.Map" %> <%@ page import="java.util.Set" %> <%@ page import="org.labkey.api.util.JsonUtil" %> -<%@ page import="static org.labkey.api.exp.api.ExperimentService.asInteger" %> -<%@ page import="static org.labkey.api.exp.api.ExperimentService.asLong" %> +<%@ page import="static org.labkey.api.util.IntegerUtils.asInteger" %> +<%@ page import="static org.labkey.api.util.IntegerUtils.asLong" %> <%@ page extends="org.labkey.api.jsp.JspTest.DRT" %> <%! final String aliasPrefix = "MultiValueTest-"; diff --git a/query/src/org/labkey/query/controllers/QueryController.java b/query/src/org/labkey/query/controllers/QueryController.java index 14b4cfa9bce..f482caa62f4 100644 --- a/query/src/org/labkey/query/controllers/QueryController.java +++ b/query/src/org/labkey/query/controllers/QueryController.java @@ -291,7 +291,6 @@ import org.labkey.query.TableXML; import org.labkey.query.audit.QueryExportAuditProvider; import org.labkey.query.audit.QueryUpdateAuditProvider; -import org.labkey.query.model.MetadataTableJSONMixin; import org.labkey.query.persist.AbstractExternalSchemaDef; import org.labkey.query.persist.CstmView; import org.labkey.query.persist.ExternalSchemaDef; @@ -7903,9 +7902,7 @@ protected ObjectMapper createRequestObjectMapper() PropertyService propertyService = PropertyService.get(); if (null != propertyService) { - ObjectMapper mapper = JsonUtil.DEFAULT_MAPPER.copy(); - mapper.addMixIn(GWTPropertyDescriptor.class, MetadataTableJSONMixin.class); - return mapper; + return JsonUtil.DEFAULT_MAPPER.copy(); } else { diff --git a/query/src/org/labkey/query/model/MetadataTableJSONMixin.java b/query/src/org/labkey/query/model/MetadataTableJSONMixin.java deleted file mode 100644 index 426541613fb..00000000000 --- a/query/src/org/labkey/query/model/MetadataTableJSONMixin.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.labkey.query.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import org.labkey.api.gwt.client.util.StringProperty; - -public abstract class MetadataTableJSONMixin -{ - MetadataTableJSONMixin(@JsonProperty("URL") StringProperty url) - { } - - @JsonProperty("URL") - abstract void setURL(String url); // rename property on deserialize -} diff --git a/study/src/org/labkey/study/assay/AssayPublishConfirmAction.java b/study/src/org/labkey/study/assay/AssayPublishConfirmAction.java index 54b73e1db2d..53c177ee588 100644 --- a/study/src/org/labkey/study/assay/AssayPublishConfirmAction.java +++ b/study/src/org/labkey/study/assay/AssayPublishConfirmAction.java @@ -10,10 +10,10 @@ import org.labkey.api.data.ColumnInfo; import org.labkey.api.data.Container; import org.labkey.api.data.JdbcType; +import org.labkey.api.exp.PropertyType; import org.labkey.api.exp.api.ExpProtocol; import org.labkey.api.exp.api.ExperimentService; import org.labkey.api.exp.property.DomainProperty; -import org.labkey.api.gwt.client.ui.PropertyType; import org.labkey.api.query.FieldKey; import org.labkey.api.query.QuerySettings; import org.labkey.api.query.QueryView; diff --git a/study/src/org/labkey/study/assay/StudyPublishManager.java b/study/src/org/labkey/study/assay/StudyPublishManager.java index f0a74f4cbf0..119b7ef05db 100644 --- a/study/src/org/labkey/study/assay/StudyPublishManager.java +++ b/study/src/org/labkey/study/assay/StudyPublishManager.java @@ -1356,7 +1356,7 @@ public ActionURL autoLinkResults(ExpProtocol protocol, AssayProvider provider, E for (ColumnInfo c : resultTable.getColumns()) { // Check for a column with the PTID concept URI instead - if (org.labkey.api.gwt.client.ui.PropertyType.PARTICIPANT_CONCEPT_URI.equals(c.getConceptURI())) + if (PropertyType.PARTICIPANT_CONCEPT_URI.equals(c.getConceptURI())) { ptidFK = c.getFieldKey(); } @@ -1717,7 +1717,7 @@ public Map getSamplePublishFieldKeys(User user, Conta if (col != null) { - if (org.labkey.api.gwt.client.ui.PropertyType.VISIT_CONCEPT_URI.equalsIgnoreCase(col.getConceptURI())) + if (PropertyType.VISIT_CONCEPT_URI.equalsIgnoreCase(col.getConceptURI())) { if (!fieldKeyMap.containsKey(LinkToStudyKeys.VisitId) && col.getJdbcType().isReal()) fieldKeyMap.put(LinkToStudyKeys.VisitId, ci.getFieldKey()); @@ -1727,7 +1727,7 @@ public Map getSamplePublishFieldKeys(User user, Conta fieldKeyMap.put(LinkToStudyKeys.VisitLabel, ci.getFieldKey()); } - if (!fieldKeyMap.containsKey(LinkToStudyKeys.ParticipantId) && org.labkey.api.gwt.client.ui.PropertyType.PARTICIPANT_CONCEPT_URI.equalsIgnoreCase(col.getConceptURI())) + if (!fieldKeyMap.containsKey(LinkToStudyKeys.ParticipantId) && PropertyType.PARTICIPANT_CONCEPT_URI.equalsIgnoreCase(col.getConceptURI())) { fieldKeyMap.put(LinkToStudyKeys.ParticipantId, ci.getFieldKey()); } diff --git a/study/src/org/labkey/study/controllers/CohortController.java b/study/src/org/labkey/study/controllers/CohortController.java index fc2463fa34d..a62e09f6bec 100644 --- a/study/src/org/labkey/study/controllers/CohortController.java +++ b/study/src/org/labkey/study/controllers/CohortController.java @@ -26,7 +26,6 @@ import org.labkey.api.data.DataRegion; import org.labkey.api.data.DbScope; import org.labkey.api.data.TableInfo; -import org.labkey.api.gwt.client.util.PropertyUtil; import org.labkey.api.query.QueryUpdateForm; import org.labkey.api.query.ValidationError; import org.labkey.api.query.ValidationException; @@ -60,6 +59,7 @@ import java.util.Collection; import java.util.HashMap; import java.util.Map; +import java.util.Objects; import static org.labkey.api.util.IntegerUtils.asInteger; @@ -427,10 +427,11 @@ public boolean handlePost(EditCohortForm form, BindException errors) boolean labelChanged = (newLabel != null && !cohort.getLabel().equals(newLabel)); boolean enrolledChanged = cohort.isEnrolled() != newEnrolled; - boolean subjectCountChanged = !PropertyUtil.nullSafeEquals(cohort.getSubjectCount(), newSubjectCount); - boolean desciprtionChanged = !Strings.CS.equals(cohort.getDescription(), newDescription); + Object o1 = cohort.getSubjectCount(); + boolean subjectCountChanged = !Objects.equals(o1, newSubjectCount); + boolean descriptionChanged = !Strings.CS.equals(cohort.getDescription(), newDescription); - if (labelChanged || enrolledChanged || subjectCountChanged || desciprtionChanged) + if (labelChanged || enrolledChanged || subjectCountChanged || descriptionChanged) { cohort = cohort.createMutable(); diff --git a/study/src/org/labkey/study/query/CohortUpdateService.java b/study/src/org/labkey/study/query/CohortUpdateService.java index 9f5b04136e2..42a623f4e94 100644 --- a/study/src/org/labkey/study/query/CohortUpdateService.java +++ b/study/src/org/labkey/study/query/CohortUpdateService.java @@ -15,15 +15,14 @@ */ package org.labkey.study.query; +import com.google.api.client.util.Objects; import org.apache.commons.beanutils.converters.IntegerConverter; -import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.Strings; import org.jetbrains.annotations.Nullable; import org.labkey.api.data.Container; import org.labkey.api.data.DbScope; import org.labkey.api.data.TableInfo; import org.labkey.api.data.TableSelector; -import org.labkey.api.gwt.client.util.PropertyUtil; import org.labkey.api.query.AbstractQueryUpdateService; import org.labkey.api.query.InvalidKeyException; import org.labkey.api.query.ValidationException; @@ -138,8 +137,9 @@ protected Map updateRow(User user, Container container, Map updateRow(User user, Container container, Map <%@ page import="static org.labkey.api.util.PageFlowUtil.jsString" %> <%@ page import="java.util.Objects" %> -<%@ page import="static org.labkey.api.exp.api.ExperimentService.asInteger" %> -<%@ page import="static org.labkey.api.exp.api.ExperimentService.asLong" %> +<%@ page import="static org.labkey.api.util.IntegerUtils.asInteger" %> +<%@ page import="static org.labkey.api.util.IntegerUtils.asLong" %> <%@ page import="org.labkey.api.collections.LongHashMap" %> <%@ page extends="org.labkey.api.jsp.JspBase" %> <%@ taglib prefix="labkey" uri="http://www.labkey.org/taglib" %> diff --git a/study/test/src/org/labkey/test/pages/AssayQueryConfig.java b/study/test/src/org/labkey/test/pages/AssayQueryConfig.java deleted file mode 100644 index 3afa3aac71a..00000000000 --- a/study/test/src/org/labkey/test/pages/AssayQueryConfig.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2017 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.test.pages; - -import org.labkey.test.Locator; -import org.labkey.test.util.Ext4Helper; -import org.openqa.selenium.WebDriver; - -public class AssayQueryConfig extends LabKeyPage -{ - public AssayQueryConfig(WebDriver driver, int index) - { - super(driver); - click(getEditLink(index)); - } - - private Locator getEditLink(int index) - { - return Locators.self.append(Locator.tagWithAttribute("span", "dataindex", String.valueOf(index))); - } - - public void setFolderName(String name) - { - setFormElement(Locators.folderName, name); - } - - public void setSchemaName(String name) - { - _ext4Helper.selectComboBoxItem("Schema name:", name); - waitForElementToDisappear(Ext4Helper.Locators.mask().index(1)); - } - - public void setQueryName(String name) - { - _ext4Helper.selectComboBoxItem("Query name:", name); - waitForElementToDisappear(Ext4Helper.Locators.mask().index(1)); - } - - public void save() - { - clickButton("Submit", 0); - } - - public static class Locators - { - public static Locator.XPathLocator self = Locator.xpath("//table[contains(@class, 'assay-summary')]"); - public static Locator.XPathLocator dialog = Locator.xpath("//div[contains(@class, 'labkey-assay-config')]"); - public static Locator.XPathLocator folderName = dialog.append(Locator.input("Folder")); - public static Locator.XPathLocator schemaName = dialog.append(Locator.input("Schema")); - public static Locator.XPathLocator queryName = dialog.append(Locator.input("listTable")); - } -} diff --git a/study/test/src/org/labkey/test/pages/DesignerController/DesignerTester.java b/study/test/src/org/labkey/test/pages/DesignerController/DesignerTester.java deleted file mode 100644 index f1194a73440..00000000000 --- a/study/test/src/org/labkey/test/pages/DesignerController/DesignerTester.java +++ /dev/null @@ -1,302 +0,0 @@ -/* - * Copyright (c) 2014 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.test.pages.DesignerController; - -import org.jetbrains.annotations.Nullable; -import org.junit.Assert; -import org.labkey.test.BaseWebDriverTest; -import org.labkey.test.Locator; -import org.openqa.selenium.WebElement; - -import java.util.List; - -/** - * org.labkey.study.controllers.designer.DesignerController#DesignerAction - */ -public class DesignerTester -{ - private final BaseWebDriverTest _test; - - public DesignerTester(BaseWebDriverTest test) - { - _test = test; - - _test.waitForElement(Locator.css("input.gwt-TextBox")); - } - - public void editDesign() - { - _test.clickButton("Edit"); - waitForEditReady(); - } - - private void waitForEditReady() - { - _test.waitForTextToDisappear("Loading", BaseWebDriverTest.WAIT_FOR_JAVASCRIPT); - _test.waitForElement(Locator.gwtTextBoxByLabel("Protocol Name"), BaseWebDriverTest.WAIT_FOR_PAGE); - } - - public void saveDesign() - { - _test.waitForElementToDisappear(Locator.tag("a").withText("Save").withClass("labkey-disabled-button")); - - int revisions = _test.getElementCount(Locator.gwtListBoxByLabel("Revision").append("/option")); - - _test.clickButton("Save", 0); - Locator successText = Locator.tagWithClass("div", "gwt-Label").withText("Revision " + (revisions + 1) + " saved successfully."); - if (!_test.waitForElement(successText, 1000, false)) - { - _test.clickButton("Save", 0); // GWT retry - } - _test.waitForElement(successText); - _test.waitForElement(Locator.tag("a").withText("Save").withClass("labkey-disabled-button")); - } - - public void finishEditing() - { - _test.clickButton("Finished"); - } - - public void setName(String name) - { - _test.setFormElement(Locator.gwtTextBoxByLabel("Protocol Name"), name); - } - - public void setInvestigator(String investigator) - { - _test.setFormElement(Locator.gwtTextBoxByLabel("Investigator"), investigator); - } - - public void setGrant(String grant) - { - _test.setFormElement(Locator.gwtTextBoxByLabel("Grant"), grant); - } - - public void setSpecies(String species) - { - _test.setFormElement(Locator.gwtTextBoxByLabel("Species"), species); - } - - public void setDescription(String description) - { - _test.fireEvent(Locator.xpath("//div[contains(text(), 'Click to edit description')]"), BaseWebDriverTest.SeleniumEvent.focus); - _test.setFormElement(Locator.name("protocolDescription"), description); - } - - public void addImmunogen(String name, String type, String doseAndUnits, String route) - { - int newRowNumber = _test.getElementCount(Locators.immunogenGridRow()); - - setImmunogenName(newRowNumber, name); - setImmunogenType(newRowNumber, type); - setImmunogenDoseAndUnits(newRowNumber, doseAndUnits); - setImmunogenRoute(newRowNumber, route); - } - - public void setImmunogenName(int immunogenRowNumber, String name) - { - Locator immunogenNameField = Locators.immunogenGridRow().index(immunogenRowNumber - 1).append("/td[2]/input"); - _test.setFormElement(immunogenNameField, name); - _test.fireEvent(immunogenNameField, BaseWebDriverTest.SeleniumEvent.change); - } - - public void setImmunogenType(int immunogenRowNumber, String type) - { - Locator immunogenTypeField = Locators.immunogenGridRow().index(immunogenRowNumber - 1).append("/td[3]/select"); - _test.selectOptionByText(immunogenTypeField, type); - } - - public void setImmunogenDoseAndUnits(int immunogenRowNumber, String doseAndUnits) - { - Locator immunogenRouteField = Locators.immunogenGridRow().index(immunogenRowNumber - 1).append("/td[4]/input"); - _test.setFormElement(immunogenRouteField, doseAndUnits); - _test.fireEvent(immunogenRouteField, BaseWebDriverTest.SeleniumEvent.change); - } - - public void setImmunogenRoute(int immunogenRowNumber, String route) - { - Locator immunogenRouteField = Locators.immunogenGridRow().index(immunogenRowNumber - 1).append("/td[5]/select"); - _test.selectOptionByText(immunogenRouteField, route); - } - - public void addAntigen(String immunogenName, String gene, String subType) - { - throw new RuntimeException("Not yet implemented"); - } - - public void addAdjuvant(String name, @Nullable String doseAndUnits, @Nullable String route) - { - int newRowNumber = _test.getElementCount(Locators.adjuvantGridRow()); - - setAdjuvantName(newRowNumber, name); - if (null != doseAndUnits) - setAdjuvantDoseAndUnits(newRowNumber, doseAndUnits); - if (null != route) - setAdjuvantRoute(newRowNumber, route); - } - - public void setAdjuvantName(int adjuvantRowNumber, String name) - { - Locator adjuvantNameField = Locators.adjuvantGridRow().index(adjuvantRowNumber - 1).append("/td[2]/input"); - _test.setFormElement(adjuvantNameField, name); - _test.fireEvent(adjuvantNameField, BaseWebDriverTest.SeleniumEvent.change); - } - - public void setAdjuvantDoseAndUnits(int adjuvantRowNumber, String doseAndUnits) - { - Locator adjuvantRouteField = Locators.adjuvantGridRow().index(adjuvantRowNumber - 1).append("/td[3]/input"); - _test.setFormElement(adjuvantRouteField, doseAndUnits); - _test.fireEvent(adjuvantRouteField, BaseWebDriverTest.SeleniumEvent.change); - } - - public void setAdjuvantRoute(int adjuvantRowNumber, String route) - { - Locator adjuvantRouteField = Locators.adjuvantGridRow().index(adjuvantRowNumber - 1).append("/td[4]/select"); - _test.selectOptionByText(adjuvantRouteField, route); - } - - public void addImmunizationGroup(String name, @Nullable String count) - { - int newRowNumber = _test.getElementCount(Locators.immunizationGridRow()); - - _test.click(Locator.tagWithText("div", "Add New")); - if (!_test.waitForElement(Locator.id("DefineGroupDialog"), 1000, false)) - { - _test.click(Locator.tagWithText("div", "Add New")); - } - _test.waitForElement(Locator.id("DefineGroupDialog")); - _test.setFormElement(Locator.name("newName"), name); - _test.clickButton("OK", 0); - _test.waitForElementToDisappear(Locator.id("DefineGroupDialog"), BaseWebDriverTest.WAIT_FOR_JAVASCRIPT); - _test.waitForElement(Locators.immunizationGridRow().index(newRowNumber - 1)); - - if (null != count) - { - setImmunizationGroupCount(newRowNumber, count); - } - } - - public void setImmunizationGroupCount(int groupRowNumber, String count) - { - Locator immunizationGroupCountField = Locators.immunizationGridRow().index(groupRowNumber - 1).append("/td[3]/input"); - _test.setFormElementJS(immunizationGroupCountField, count); - _test.fireEvent(immunizationGroupCountField, BaseWebDriverTest.SeleniumEvent.change); - } - - public void addImmunizationTimepoint(String timepoint) - { - addImmunizationTimepoint(null, timepoint, null); - } - - public void addImmunizationTimepoint(@Nullable String name, String timepoint, @Nullable String unit) - { - _test.click(Locator.xpath("//table[@id='ImmunizationGrid']//div[contains(text(), 'Add Timepoint')]")); - if (null != name) _test.setFormElement(Locator.name("timepointName"), name); - _test.setFormElement(Locator.name("timepointCount"), timepoint); - if (null != unit) _test.selectOptionByText(Locator.name("timepointUnit"), unit); - _test.click(Locator.tagWithText("button", "OK")); - } - - public void defineFirstUndefinedImmunization(List immunogensAndAdjuvants) - { - _test.click(Locator.xpath("//div[contains(text(), '(none)')]")); - _test.waitForElement(Locator.css("div.gwt-DialogBox")); - - for (String immunogenOrAdjuvant : immunogensAndAdjuvants) - { - _test.checkCheckbox(Locator.xpath(String.format("//label[text()='%s']/../input", immunogenOrAdjuvant))); - } - - _test.click(Locator.tagWithText("button", "Done")); - _test.waitForElementToDisappear(Locator.css("div.gwt-DialogBox")); - } - - public void setAssayPlan(String description) - { - _test.fireEvent(Locator.xpath("//div[contains(text(), 'Click to type assay plan here')]"), BaseWebDriverTest.SeleniumEvent.focus); - _test.setFormElement(Locator.name("assayPlan"), description); - } - - public void addAssay(String assay, String lab) - { - int newRowNumber = _test.getElementCount(Locators.assayGridRow()); - - Locator assayNameField = Locators.assayGridRow().index(newRowNumber - 1).append("/td[2]/select"); - _test.selectOptionByText(assayNameField, assay); - - setAssayLab(newRowNumber, lab); - } - - public void setAssayLab(int assayRowNumber, String lab) - { - Locator assayLabField = Locators.assayGridRow().index(assayRowNumber - 1).append("/td[3]/select"); - _test.selectOptionByText(assayLabField, lab); - } - - public void addAssayTimepoint(@Nullable String name, String timepoint, @Nullable String unit) - { - _test.click(Locator.xpath("//table[@id='AssayGrid']//div[contains(text(), 'Add Timepoint')]")); - if (null != name) _test.setFormElement(Locator.name("timepointName"), name); - _test.setFormElement(Locator.name("timepointCount"), timepoint); - if (null != unit) _test.selectOptionByText(Locator.name("timepointUnit"), unit); - _test.click(Locator.tagWithText("button", "OK")); - } - - public void setAssayRequiredForTimepoint(String assayName, String timepointSubstring) - { - Locator.XPathLocator assayGridRow = Locators.assayGridRow().withDescendant(Locator.tagWithText("td", assayName)); - Locator.XPathLocator timepointColumnHeader = Locator.id("AssayGrid").append(Locator.tagWithAttribute("div", "title", "Click to modify or delete this timepoint.")); - int timepointIndex = -1; - - List timepointColumnHeaders = timepointColumnHeader.findElements(_test.getDriver()); - for (int i = 0; i < timepointColumnHeaders.size(); i++) - { - String timepointLabel = timepointColumnHeaders.get(i).getText(); - if (timepointLabel.contains(timepointSubstring)) - { - timepointIndex = i; - break; - } - } - - Assert.assertFalse("Could not find Assay timepoint: " + timepointSubstring, timepointIndex < 0); - - _test.checkCheckbox(assayGridRow.append(Locator.tagWithAttribute("input", "type", "checkbox")).index(timepointIndex)); - } - - public static class Locators - { - public static Locator.XPathLocator immunogenGridRow() - { - return Locator.xpath("//table[@id='ImmunogenGrid']/tbody/tr[./td[1][contains(@class, 'row-header')]]"); - } - - public static Locator.XPathLocator adjuvantGridRow() - { - return Locator.xpath("//table[@id='AdjuvantGrid']/tbody/tr[./td[1][contains(@class, 'row-header')]]"); - } - - public static Locator.XPathLocator immunizationGridRow() - { - return Locator.xpath("//table[@id='ImmunizationGrid']/tbody/tr[./td[1][contains(@class, 'row-header')]]"); - } - - public static Locator.XPathLocator assayGridRow() - { - return Locator.xpath("//table[@id='AssayGrid']/tbody/tr[./td[1][contains(@class, 'row-header')]]"); - } - } -}