Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
hmiguim committed Nov 17, 2023
1 parent 1200d25 commit f500d8e
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
/**
* @author Rui Castro
* @author Luis Faria <[email protected]>
* @author Miguel Guimarães <[email protected]>
*/
public class PluginParameter implements Serializable {
private static final long serialVersionUID = -431821437136556726L;
Expand Down Expand Up @@ -401,7 +402,12 @@ public enum PluginParameterType {
/**
* Interface to users profiles
*/
USER_PROFILE;
USER_PROFILE,

/**
* Interface to conversion plugins
*/
CONVERSION
}

public static class PluginParameterBuilder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class ActionLogCleanerPlugin extends AbstractPlugin<Void> {
.withDefaultValue("90").isMandatory(false).isReadOnly(false)
.withDescription("The plugin will delete all logs older than the specified number of days.").build());

pluginParameters.put("test", new PluginParameter.PluginParameterBuilder("test", "dropdown test", PluginParameterType.DROPDOWN).build());
pluginParameters.put("test", new PluginParameter.PluginParameterBuilder("test", "rep or diss test", PluginParameterType.CONVERSION).build());
}

private int deleteOlderThanXDays = 90;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ private void update() {
layout.clear();

if (pluginInfo != null) {

for (PluginParameter parameter : pluginInfo.getParameters()) {
PluginParameterPanel panel = new PluginParameterPanel(parameter);
panels.add(panel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@
import org.roda.core.data.v2.jobs.PluginType;
import org.roda.core.data.v2.risks.IndexedRisk;
import org.roda.core.data.v2.risks.SeverityLevel;
import org.roda.core.data.v2.user.User;
import org.roda.wui.client.browse.BrowserService;
import org.roda.wui.client.browse.bundle.RepresentationInformationFilterBundle;
import org.roda.wui.client.common.IncrementalAssociativeList;
import org.roda.wui.client.common.dialogs.SelectAipDialog;
import org.roda.wui.client.common.utils.PluginUtils;
import org.roda.wui.client.ingest.process.model.DisseminationParameter;
import org.roda.wui.client.ingest.process.model.RepresentationParameter;
import org.roda.wui.common.client.ClientLogger;
import org.roda.wui.common.client.tools.DescriptionLevelUtils;
import org.roda.wui.common.client.tools.StringUtils;
Expand Down Expand Up @@ -76,6 +77,12 @@ public class PluginParameterPanel extends Composite {
private String value;
private String aipTitle;

private final RepresentationParameter representationParameter = new RepresentationParameter();

private DisseminationParameter disseminationParameter;

private boolean conversionPanel = false;

public PluginParameterPanel(PluginParameter parameter) {
super();
this.parameter = parameter;
Expand Down Expand Up @@ -117,15 +124,73 @@ private void updateLayout() {
createPermissionTypesLayout();
} else if (PluginParameterType.DROPDOWN.equals(parameter.getType())) {
createDropdownLayout();
} else if (PluginParameterType.USER_PROFILE.equals(parameter.getType())) {
} else if (PluginParameterType.USER_PROFILE.equals(parameter.getType())) {
createUserProfileLayout();
} else if (PluginParameterType.CONVERSION.equals(parameter.getType())) {
createConversionLayout();
} else {
LOGGER
.warn("Unsupported plugin parameter type: " + parameter.getType() + ". Reverting to default parameter editor.");
createStringLayout();
}
}

private void createConversionLayout() {
conversionPanel = true;
Label parameterName = new Label(parameter.getName());
final ListBox dropdown = new ListBox();
dropdown.addStyleName("form-selectbox");
dropdown.addStyleName("form-textbox-small");

dropdown.addItem("Representation", "rep");
dropdown.addItem("Dissemination", "dip");

value = dropdown.getSelectedValue();
FlowPanel innerPanel = new FlowPanel();
dropdown.addChangeHandler(event -> {
value = dropdown.getSelectedValue();
if (value.equals("rep")) {
innerPanel.clear();
// Clean layout
// Add fields
Label label = new Label(parameter.getName());
TextBox parameterBox = new TextBox();
if (parameter.getDefaultValue() != null) {
parameterBox.setText(parameter.getDefaultValue());
value = parameter.getDefaultValue();
}

parameterBox.setEnabled(!parameter.isReadonly());
parameterBox.setTitle("parameter box");

label.addStyleName("form-label");
parameterBox.addStyleName("form-textbox");

// binding change
parameterBox.addValueChangeHandler(new ValueChangeHandler<String>() {

@Override
public void onValueChange(ValueChangeEvent<String> event) {
representationParameter.setValue(event.getValue());
}
});

innerPanel.add(label);
innerPanel.add(parameterBox);
} else {
innerPanel.clear();
// Clean layout
// Add fields
}
});

dropdown.setTitle("object box");
layout.add(parameterName);
layout.add(dropdown);
layout.add(innerPanel);
addHelp();
}

private void createRepresentationTypeLayout() {
Label parameterName = new Label(parameter.getName());

Expand Down Expand Up @@ -157,7 +222,7 @@ public void onSuccess(Pair<Boolean, List<String>> result) {
selectBox.addItem(option);
}

if (!result.getFirst()) {
if (Boolean.FALSE.equals(result.getFirst())) {
selectBox.addItem(messages.entityTypeAddNew(), ADD_TYPE);
}

Expand Down Expand Up @@ -383,7 +448,6 @@ public void onChange(ChangeEvent event) {
}

private void createDropdownLayout() {
GWT.log("HERE!!!!!!");
Label parameterName = new Label(parameter.getName());
final ListBox dropdown = new ListBox();
dropdown.addStyleName("form-selectbox");
Expand All @@ -399,7 +463,6 @@ public void onFailure(Throwable caught) {

@Override
public void onSuccess(Set<Pair<String, String>> result) {
GWT.log("HERE!");
Set<Pair<String, String>> treeSet = new TreeSet<>(
(p1, p2) -> p1.getFirst().compareToIgnoreCase(p2.getFirst()));

Expand All @@ -419,6 +482,7 @@ public void onSuccess(Set<Pair<String, String>> result) {
layout.add(dropdown);
addHelp();
}

private void createUserProfileLayout() {
Set<UserProfile> treeSet = new HashSet<>();
Label parameterName = new Label(parameter.getName());
Expand Down Expand Up @@ -470,6 +534,7 @@ public void onSuccess(Set<UserProfile> result) {

addHelp();
}

private void createPluginObjectFieldsLayout(final String className) {
List<String> defaultValues = Arrays.asList(parameter.getDefaultValue().split(","));

Expand Down Expand Up @@ -621,7 +686,7 @@ public void onSuccess(List<PluginInfo> pluginsInfo) {

@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
if (event.getValue()) {
if (Boolean.TRUE.equals(event.getValue())) {
value = pluginInfo.getId();
}
}
Expand Down Expand Up @@ -704,14 +769,14 @@ private void createBooleanLayout() {
checkBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
value = event.getValue() ? "true" : "false";
value = Boolean.TRUE.equals(event.getValue()) ? "true" : "false";
}
});
}

private void addHelp() {
String pDescription = parameter.getDescription();
if (pDescription != null && pDescription.length() > 0) {
if (pDescription != null && !pDescription.isEmpty()) {
Label pHelp = new Label(pDescription);
layout.add(pHelp);
pHelp.addStyleName("form-help");
Expand All @@ -722,6 +787,18 @@ public String getValue() {
return value;
}

public boolean isConversionPanel() {
return conversionPanel;
}

public RepresentationParameter getRepresentationParameter() {
return representationParameter;
}

public DisseminationParameter getDisseminationParameter() {
return disseminationParameter;
}

public String getAipTitle() {
return aipTitle;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.roda.wui.client.ingest.process.model;

public class DisseminationParameter {

public DisseminationParameter() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.roda.wui.client.ingest.process.model;

public class RepresentationParameter {

private String value;

public RepresentationParameter() {
}

public RepresentationParameter(String value) {
this.value = value;
}

public String getValue() {
return value;
}

public void setValue(String value) {
this.value = value;
}
}

0 comments on commit f500d8e

Please sign in to comment.