-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3915 from inception-project/feature/3914-Allow-pi…
…nning-label-groups-to-the-annotation-sidebar #3914 - Allow pinning label groups to the annotation sidebar
- Loading branch information
Showing
20 changed files
with
536 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...va/de/tudarmstadt/ukp/inception/diam/sidebar/preferences/DiamSidebarManagerPrefPanel.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<!DOCTYPE html> | ||
<!-- | ||
Licensed to the Technische Universität Darmstadt under one | ||
or more contributor license agreements. See the NOTICE file | ||
distributed with this work for additional information | ||
regarding copyright ownership. The Technische Universität Darmstadt | ||
licenses this file to you under the Apache License, Version 2.0 (the | ||
"License"); you may not use this file except in compliance | ||
with the License. | ||
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. | ||
--> | ||
<html xmlns:wicket="http://wicket.apache.org"> | ||
<body> | ||
<wicket:panel> | ||
<form wicket:id="form" class="card"> | ||
<div class="card-header"> | ||
<wicket:message key="title"/> | ||
</div> | ||
<div class="card-body"> | ||
<div class="row form-row"> | ||
<label class="col-sm-4 col-form-label"> | ||
<wicket:message key="pinnedGroups"/> | ||
</label> | ||
<div class="col-sm-8"> | ||
<div wicket:id="pinnedGroups"/> | ||
</div> | ||
</div> | ||
</div> | ||
</form> | ||
</wicket:panel> | ||
</body> | ||
</html> |
79 changes: 79 additions & 0 deletions
79
...va/de/tudarmstadt/ukp/inception/diam/sidebar/preferences/DiamSidebarManagerPrefPanel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* Licensed to the Technische Universität Darmstadt under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The Technische Universität Darmstadt | ||
* licenses this file to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. | ||
* | ||
* 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 de.tudarmstadt.ukp.inception.diam.sidebar.preferences; | ||
|
||
import static de.tudarmstadt.ukp.inception.diam.sidebar.preferences.DiamSidebarManagerPrefs.KEY_DIAM_SIDEBAR_MANAGER_PREFS; | ||
|
||
import org.apache.wicket.ajax.AjaxRequestTarget; | ||
import org.apache.wicket.markup.html.form.Form; | ||
import org.apache.wicket.markup.html.panel.Panel; | ||
import org.apache.wicket.model.CompoundPropertyModel; | ||
import org.apache.wicket.model.IModel; | ||
import org.apache.wicket.spring.injection.annot.SpringBean; | ||
|
||
import de.tudarmstadt.ukp.clarin.webanno.api.ProjectService; | ||
import de.tudarmstadt.ukp.clarin.webanno.model.Project; | ||
import de.tudarmstadt.ukp.clarin.webanno.support.lambda.LambdaForm; | ||
import de.tudarmstadt.ukp.inception.editor.AnnotationEditorRegistry; | ||
import de.tudarmstadt.ukp.inception.preferences.PreferencesService; | ||
|
||
public class DiamSidebarManagerPrefPanel | ||
extends Panel | ||
{ | ||
private static final long serialVersionUID = 3635729182772294488L; | ||
|
||
private @SpringBean AnnotationEditorRegistry annotationEditorRegistry; | ||
private @SpringBean PreferencesService preferencesService; | ||
private @SpringBean ProjectService projectService; | ||
|
||
private CompoundPropertyModel<DiamSidebarManagerPrefs> sidebarPreferences; | ||
|
||
public DiamSidebarManagerPrefPanel(String aId, IModel<Project> aProjectModel) | ||
{ | ||
super(aId, aProjectModel); | ||
setOutputMarkupPlaceholderTag(true); | ||
|
||
sidebarPreferences = CompoundPropertyModel.of(actionLoad()); | ||
|
||
LambdaForm<DiamSidebarManagerPrefs> form = new LambdaForm<>("form", sidebarPreferences); | ||
|
||
form.add(new PinnedGroupsPanel("pinnedGroups", sidebarPreferences.bind("pinnedGroups"))); | ||
|
||
form.onSubmit(this::actionSave); | ||
|
||
add(form); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public IModel<Project> getModel() | ||
{ | ||
return (IModel<Project>) getDefaultModel(); | ||
} | ||
|
||
private DiamSidebarManagerPrefs actionLoad() | ||
{ | ||
return preferencesService.loadDefaultTraitsForProject(KEY_DIAM_SIDEBAR_MANAGER_PREFS, | ||
getModel().getObject()); | ||
} | ||
|
||
private void actionSave(AjaxRequestTarget aTarget, Form<DiamSidebarManagerPrefs> aForm) | ||
{ | ||
preferencesService.saveDefaultTraitsForProject(KEY_DIAM_SIDEBAR_MANAGER_PREFS, | ||
getModel().getObject(), aForm.getModelObject()); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...tudarmstadt/ukp/inception/diam/sidebar/preferences/DiamSidebarManagerPrefPanel.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Licensed to the Technische Universität Darmstadt under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The Technische Universität Darmstadt | ||
# licenses this file to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. | ||
# | ||
# 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. | ||
|
||
title=Annotation sidebar | ||
pinnedGroups=Pinned groups |
50 changes: 50 additions & 0 deletions
50
...n/java/de/tudarmstadt/ukp/inception/diam/sidebar/preferences/DiamSidebarManagerPrefs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Licensed to the Technische Universität Darmstadt under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The Technische Universität Darmstadt | ||
* licenses this file to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. | ||
* | ||
* 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 de.tudarmstadt.ukp.inception.diam.sidebar.preferences; | ||
|
||
import java.io.Serializable; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import de.tudarmstadt.ukp.inception.preferences.Key; | ||
|
||
public class DiamSidebarManagerPrefs | ||
implements Serializable | ||
{ | ||
private static final long serialVersionUID = 8420554954400084375L; | ||
|
||
public static final Key<DiamSidebarManagerPrefs> KEY_DIAM_SIDEBAR_MANAGER_PREFS = new Key<>( | ||
DiamSidebarManagerPrefs.class, "annotation/editor/annotation-sidebar/manager"); | ||
|
||
private final List<String> pinnedGroups = new ArrayList<>(); | ||
|
||
public List<String> getPinnedGroups() | ||
{ | ||
System.out.println("[" + hashCode() + "] GET " + String.join(",", pinnedGroups)); | ||
return pinnedGroups; | ||
} | ||
|
||
public void setPinnedGroups(List<String> aPinnedGroups) | ||
{ | ||
pinnedGroups.clear(); | ||
if (aPinnedGroups != null) { | ||
pinnedGroups.addAll(aPinnedGroups); | ||
} | ||
System.out.println("[" + hashCode() + "] SET " + String.join(",", aPinnedGroups)); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
...rc/main/java/de/tudarmstadt/ukp/inception/diam/sidebar/preferences/PinnedGroupsPanel.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<!DOCTYPE html> | ||
<!-- | ||
Licensed to the Technische Universität Darmstadt under one | ||
or more contributor license agreements. See the NOTICE file | ||
distributed with this work for additional information | ||
regarding copyright ownership. The Technische Universität Darmstadt | ||
licenses this file to you under the Apache License, Version 2.0 (the | ||
"License"); you may not use this file except in compliance | ||
with the License. | ||
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. | ||
--> | ||
|
||
<html xmlns:wicket="http://wicket.apache.org"> | ||
<wicket:panel> | ||
<div class="list-group"> | ||
<div class="list-group-item"> | ||
<div class="input-group"> | ||
<input type="text" wicket:id="newItemName" class="form-control"/> | ||
<span class="input-group-btn"> | ||
<a wicket:id="addItem" class="btn btn-primary"> | ||
<i class="fas fa-plus" aria-hidden="true"></i> | ||
</a> | ||
</span> | ||
</div> | ||
</div> | ||
<div wicket:id=items class="list-group-item"> | ||
<form wicket:id="itemForm"> | ||
<div class="input-group"> | ||
<a wicket:id="moveUp" class="btn btn-outline-secondary"> | ||
<i class="fas fa-arrow-up" aria-hidden="true"></i> | ||
</a> | ||
<a wicket:id="moveDown" class="btn btn-outline-secondary"> | ||
<i class="fas fa-arrow-down" aria-hidden="true"></i> | ||
</a> | ||
<input type="text" wicket:id="textField" class="form-control"/> | ||
<a wicket:id="removeItem" class="btn btn-outline-danger"> | ||
<i class="fas fa-trash" aria-hidden="true"></i> | ||
</a> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</wicket:panel> | ||
</html> |
Oops, something went wrong.