Skip to content

Commit

Permalink
Feature #3990
Browse files Browse the repository at this point in the history
In the clipboard.jsp web page template, replace the programmatic
construction of the array pane by its declarative approach with the
corresponding taglibs. For doing SilverpeasKeyData has been modified in
order to have all the properties required for the array pane content
rendering; the SilverpeasKeyData object is then used instead of the
IndexEntry object (SilverpeasKeyData is for the clipboard's item whereas
IndexEntry is for the indexation).
  • Loading branch information
mmoqui committed Jan 7, 2025
1 parent 226ad9c commit f21a85b
Show file tree
Hide file tree
Showing 15 changed files with 278 additions and 339 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
node = /util/icons/topic.gif
publi = /util/icons/mini_publi.gif
component = /util/icons/component/peas.gif
publication = /util/icons/mini_publi.gif
component = /util/icons/component/peas.gif
group = /util/icons/groups.png
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.silverpeas.core.clipboard.SilverpeasKeyData;
import org.silverpeas.core.index.indexing.model.IndexEntry;
import org.silverpeas.core.index.indexing.model.IndexEntryKey;
import org.silverpeas.core.util.URLUtil;

import javax.annotation.Nonnull;
import java.awt.datatransfer.DataFlavor;
Expand All @@ -36,8 +37,8 @@
public class ComponentSelection extends ClipboardSelection implements Serializable {

private static final long serialVersionUID = 4750709802063183409L;
public static final DataFlavor ComponentDetailFlavor = new DataFlavor(ComponentInst.class,
"Component");
private static final String TYPE = "Component";
public static final DataFlavor ComponentDetailFlavor = new DataFlavor(ComponentInst.class, TYPE);
private final ComponentInst componentInst;

/**
Expand Down Expand Up @@ -79,8 +80,7 @@ public synchronized Object getTransferData(DataFlavor parFlavor)
@Override
public IndexEntry getIndexEntry() {
IndexEntry indexEntry =
new IndexEntry(new IndexEntryKey(componentInst.getId(), "Component",
componentInst.getId()));
new IndexEntry(new IndexEntryKey(componentInst.getId(), TYPE, componentInst.getId()));
indexEntry.setTitle(componentInst.getLabel());
return indexEntry;
}
Expand All @@ -90,11 +90,13 @@ public IndexEntry getIndexEntry() {
*/
@Override
public SilverpeasKeyData getKeyData() {
SilverpeasKeyData keyData = new SilverpeasKeyData();
SilverpeasKeyData keyData = new SilverpeasKeyData(componentInst.getId(), componentInst.getId());
keyData.setTitle(componentInst.getName());
keyData.setAuthor(componentInst.getCreatorUserId());
keyData.setCreationDate(componentInst.getCreationDate());
keyData.setDesc(componentInst.getDescription());
keyData.setType(TYPE);
keyData.setLink(URLUtil.getSimpleURL(URLUtil.URL_COMPONENT, componentInst.getId()));
return keyData;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.silverpeas.core.clipboard.SilverpeasKeyData;
import org.silverpeas.core.index.indexing.model.IndexEntry;
import org.silverpeas.core.index.indexing.model.IndexEntryKey;
import org.silverpeas.core.util.URLUtil;

import javax.annotation.Nonnull;
import java.awt.datatransfer.DataFlavor;
Expand All @@ -36,8 +37,9 @@
public class SpaceSelection extends ClipboardSelection implements Serializable {

private static final long serialVersionUID = -1717229458481172945L;
private static final String TYPE = "Space";
public static final DataFlavor SpaceFlavor = new DataFlavor(SpaceInst.class,
"Space");
TYPE);
private final SpaceInst spaceInst;

/**
Expand Down Expand Up @@ -79,7 +81,7 @@ public synchronized Object getTransferData(DataFlavor parFlavor)
@Override
public IndexEntry getIndexEntry() {
IndexEntry indexEntry =
new IndexEntry(new IndexEntryKey(spaceInst.getId(), "Space", spaceInst.getId()));
new IndexEntry(new IndexEntryKey(spaceInst.getId(), TYPE, spaceInst.getId()));
indexEntry.setTitle(spaceInst.getName());
return indexEntry;
}
Expand All @@ -89,11 +91,13 @@ public IndexEntry getIndexEntry() {
*/
@Override
public SilverpeasKeyData getKeyData() {
SilverpeasKeyData keyData = new SilverpeasKeyData();
SilverpeasKeyData keyData = new SilverpeasKeyData(spaceInst.getId());
keyData.setTitle(spaceInst.getName());
keyData.setAuthor(spaceInst.getCreatorUserId());
keyData.setCreationDate(spaceInst.getCreationDate());
keyData.setDesc(spaceInst.getDescription());
keyData.setType(TYPE);
keyData.setLink(URLUtil.getSimpleURL(URLUtil.URL_SPACE, spaceInst.getId()));
return keyData;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
*/
public class GroupSelection extends ClipboardSelection implements Serializable {

public static final DataFlavor GROUP_FLAVOR = new DataFlavor(Group.class, "Group");
private static final String TYPE = "Group";
public static final DataFlavor GROUP_FLAVOR = new DataFlavor(Group.class, TYPE);

private final Group group;

Expand Down Expand Up @@ -82,7 +83,7 @@ public synchronized Object getTransferData(DataFlavor parFlavor)
@Override
public IndexEntry getIndexEntry() {
IndexEntry indexEntry =
new IndexEntry(new IndexEntryKey("Groups", "GroupRow", group.getId()));
new IndexEntry(new IndexEntryKey("Groups", TYPE, group.getId()));
indexEntry.setTitle(group.getName());
indexEntry.setPreview(group.getDescription());
return indexEntry;
Expand All @@ -93,10 +94,11 @@ public IndexEntry getIndexEntry() {
*/
@Override
public SilverpeasKeyData getKeyData() {
SilverpeasKeyData keyData = new SilverpeasKeyData();
SilverpeasKeyData keyData = new SilverpeasKeyData(group.getId());
keyData.setTitle(group.getName());
keyData.setCreationDate(group.getCreationDate());
keyData.setDesc(group.getDescription());
keyData.setType(TYPE);
return keyData;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
package org.silverpeas.core.clipboard;

import org.silverpeas.core.index.indexing.model.IndexEntry;
import org.silverpeas.kernel.annotation.NonNull;

import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.ClipboardOwner;
Expand All @@ -34,41 +35,37 @@
import java.util.ArrayList;

/**
* Class declaration
* @author
* A clipboard selection represents a contribution or a resource in Silverpeas that has been
* copied or cut; in other words, an element that has been put into the clipboard.
*/
public abstract class ClipboardSelection implements Serializable, ClipboardOwner, Transferable {

private static final long serialVersionUID = 7296607705319157979L;
final static public DataFlavor IndexFlavor = new DataFlavor("silverpeas/index",
public static final DataFlavor IndexFlavor = new DataFlavor("silverpeas/index",
"Silverpeas index");
final static public DataFlavor SilverpeasKeyDataFlavor = new DataFlavor(
public static final DataFlavor SilverpeasKeyDataFlavor = new DataFlavor(
"silverpeas/keydata", "Silverpeas keydata");
protected ArrayList<DataFlavor> supportedFlavorsList = new ArrayList<DataFlavor>();
protected ArrayList<DataFlavor> supportedFlavorsList = new ArrayList<>();
protected boolean selected = true;
private boolean isCutted = false;
private boolean isCut = false;

/**
* --------------------------------------------------------------------------
* ------------------------------
*/
public ClipboardSelection() {
protected ClipboardSelection() {
supportedFlavorsList.add(IndexFlavor);
supportedFlavorsList.add(SilverpeasKeyDataFlavor);
}

/**
* Add a new DataFlavor to the list of supported DataFlavors.
* @param parFlavor
* @param parFlavor the data flavor to support
*/
protected void addFlavor(DataFlavor parFlavor) {
supportedFlavorsList.add(parFlavor);
}

/**
* Indicates if a DataFlavor is in the list of supported DataFlavors.
* @param parFlavor
* @return true if the dataflavor is supported, false otherwise.
* @param parFlavor the data flavor to check.
* @return true if the data flavor is supported, false otherwise.
*/
@Override
public boolean isDataFlavorSupported(DataFlavor parFlavor) {
Expand All @@ -78,22 +75,22 @@ public boolean isDataFlavorSupported(DataFlavor parFlavor) {
return supportedFlavorsList.contains(parFlavor);
}

/**
* --------------------------------------------------------------------------
* ------------------------------
*/
@Override
public synchronized DataFlavor[] getTransferDataFlavors() {
return supportedFlavorsList
.toArray(new DataFlavor[supportedFlavorsList.size()]);
.toArray(new DataFlavor[0]);
}

/**
* Return the data stored into the DataFlavor.
* @param parFlavor
* @return
* Gets the data stored into the specified DataFlavor.
* @param parFlavor the data stored in the specified data flavor.
* @return the data in the given data flavor: it is either an {@link IndexEntry} instance for
* an {@link ClipboardSelection#IndexFlavor} or a {@link SilverpeasKeyData} object for a
* {@link ClipboardSelection#SilverpeasKeyDataFlavor}.
* @throws UnsupportedFlavorException if the specified data flavor isn't supported.
*/
@Override
@NonNull
public synchronized Object getTransferData(DataFlavor parFlavor)
throws UnsupportedFlavorException {
if (IndexFlavor.equals(parFlavor)) {
Expand All @@ -105,53 +102,28 @@ public synchronized Object getTransferData(DataFlavor parFlavor)
}
}

/**
* --------------------------------------------------------------------------
* ------------------------------
* @return
*/
public boolean isSelected() {
return selected;
}

/**
* --------------------------------------------------------------------------
* ------------------------------
* @param setIt
*/
public void setSelected(boolean setIt) {
selected = setIt;
}

/**
* Does nothing.
* @param parClipboard
* @param parTransferable
*/
@Override
public void lostOwnership(Clipboard parClipboard, Transferable parTransferable) {
}

/**
* --------------------------------------------------------------------------
* ------------------------------
* @return
*/
abstract protected IndexEntry getIndexEntry();
protected abstract IndexEntry getIndexEntry();

/**
* --------------------------------------------------------------------------
* ------------------------------
* @return
*/
abstract protected SilverpeasKeyData getKeyData();
protected abstract SilverpeasKeyData getKeyData();

public boolean isCutted() {
return isCutted;
public boolean isCut() {
return isCut;
}

public void setCutted(boolean isCutted) {
this.isCutted = isCutted;
public void setCut(boolean isCut) {
this.isCut = isCut;
}

}
Loading

0 comments on commit f21a85b

Please sign in to comment.