Skip to content
Snippets Groups Projects
Commit ad7ec88d authored by srosse's avatar srosse
Browse files

FXOLAT-358: remove clipboard service

parent 690b1b5f
No related branches found
No related tags found
No related merge requests found
Showing
with 0 additions and 574 deletions
/**
* OLAT - Online Learning and Training<br>
* http://www.olat.org
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Copyright (c) 1999-2006 at Multimedia- & E-Learning Services (MELS),<br>
* University of Zurich, Switzerland.
* <p>
*/
package org.olat.core.commons.services.clipboard;
import org.olat.core.gui.control.creator.ControllerCreator;
/**
* @author Felix Jost, http://www.goodsolutions.ch
*
*/
public interface ClipboardEntry {
public boolean acceptsFlavor (Class flavorInterfaceName);
/**
*
*/
public ControllerCreator createTrayUI();
//public Object getHandler(Class flavorInterfaceName);
//TODO: public ControllerCreator createTrayView();
// or is String as return type enough?
}
/**
* OLAT - Online Learning and Training<br>
* http://www.olat.org
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Copyright (c) 1999-2006 at Multimedia- & E-Learning Services (MELS),<br>
* University of Zurich, Switzerland.
* <p>
*/
package org.olat.core.commons.services.clipboard;
/**
* @author Felix Jost, http://www.goodsolutions.ch
*
*/
public interface ClipboardEntryCreator {
public ClipboardEntry createClipboardEntry();
}
/**
* OLAT - Online Learning and Training<br>
* http://www.olat.org
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Copyright (c) 1999-2006 at Multimedia- & E-Learning Services (MELS),<br>
* University of Zurich, Switzerland.
* <p>
*/
package org.olat.core.commons.services.clipboard;
import org.olat.core.gui.control.creator.ControllerCreator;
import org.olat.core.gui.control.Event;
/**
* @author Felix Jost, http://www.goodsolutions.ch
*
* this is a service instance for handling a clipboard (a la gui copy and paste).
* it is normally attached to one user, but this is up to the caller of the service.
*/
public interface ClipboardService {
public ControllerCreator createCopyToUIService(ClipboardEntryCreator cbec);
public ControllerCreator createPasteFromUIService(Class[] acceptedFlavorInterfaces);
public ClipboardEntry getClipboardEntryFrom(Event clipboardEvent);
/**
*
* @return (once only allowed) the UI representing the clipboard content (should be presented at some place like e.g. top right of the screen or similar, a place where it is always accessible)
*/
public ControllerCreator onceGetClipboardUI();
}
/**
* OLAT - Online Learning and Training<br>
* http://www.olat.org
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Copyright (c) 1999-2006 at Multimedia- & E-Learning Services (MELS),<br>
* University of Zurich, Switzerland.
* <p>
*/
package org.olat.core.commons.services.clipboard.impl;
import org.olat.core.commons.services.clipboard.ClipboardEntry;
import org.olat.core.gui.control.Event;
/**
* @author Felix Jost, http://www.goodsolutions.ch
*
*/
public class ClipboardEvent extends Event {
private final ClipboardEntry cbe;
/**
* @param command
*/
public ClipboardEvent(ClipboardEntry cbe) {
super("clipboardevent");
this.cbe = cbe;
}
/**
* @return the clipboardentry (never null)
*/
public ClipboardEntry getClipboardEntry() {
return cbe;
}
}
/**
* OLAT - Online Learning and Training<br>
* http://www.olat.org
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Copyright (c) 1999-2006 at Multimedia- & E-Learning Services (MELS),<br>
* University of Zurich, Switzerland.
* <p>
*/
package org.olat.core.commons.services.clipboard.impl;
import org.olat.core.commons.services.clipboard.ClipboardEntry;
import org.olat.core.commons.services.clipboard.ClipboardEntryCreator;
import org.olat.core.commons.services.clipboard.ClipboardService;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.Event;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.control.creator.ControllerCreator;
import org.springframework.stereotype.Service;
/**
* @author Felix Jost, http://www.goodsolutions.ch
*
*/
@Service
public class ClipboardServiceImpl implements ClipboardService {
private ClipboardEntry clipboardEntry;
/* (non-Javadoc)
* @see org.olat.core.commons.services.clipboard.ClipboardService#createCopyToUIService()
*/
public ControllerCreator createCopyToUIService(final ClipboardEntryCreator cbec) {
return new ControllerCreator() {
public Controller createController(UserRequest ureq, WindowControl wControl) {
return new CopyToClipboardController(ureq, wControl, ClipboardServiceImpl.this, cbec);
}};
}
public ControllerCreator createPasteFromUIService(final Class[] acceptedFlavorInterfaces) {
return new ControllerCreator() {
public Controller createController(UserRequest ureq, WindowControl wControl) {
return new PasteFromClipboardController(ureq, wControl, ClipboardServiceImpl.this, acceptedFlavorInterfaces);
}};
}
public ClipboardEntry getClipboardEntryFrom(Event event) {
ClipboardEvent cbe = (ClipboardEvent)event;
return cbe.getClipboardEntry();
}
ClipboardEntry getClipboardEntry() {
return clipboardEntry;
}
void setClipboardEntry(ClipboardEntry clipboardEntry) {
this.clipboardEntry = clipboardEntry;
}
/* (non-Javadoc)
* @see org.olat.core.commons.services.clipboard.ClipboardService#onceGetClipboardUI()
*/
public ControllerCreator onceGetClipboardUI() {
return new ControllerCreator(){
public Controller createController(UserRequest ureq, WindowControl wControl) {
return new ClipboardTrayController(ureq, wControl, ClipboardServiceImpl.this);
}};
}
}
/**
* OLAT - Online Learning and Training<br>
* http://www.olat.org
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS,
* <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Copyright (c) 1999-2006 at Multimedia- & E-Learning Services (MELS),<br>
* University of Zurich, Switzerland.
* <p>
*/
package org.olat.core.commons.services.clipboard.impl;
import org.olat.core.commons.services.clipboard.ClipboardEntry;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.Component;
import org.olat.core.gui.components.link.Link;
import org.olat.core.gui.components.link.LinkFactory;
import org.olat.core.gui.components.panel.Panel;
import org.olat.core.gui.components.util.ComponentUtil;
import org.olat.core.gui.components.velocity.VelocityContainer;
import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.Event;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.control.controller.BasicController;
import org.olat.core.gui.control.floatingresizabledialog.FloatingResizableDialogController;
/**
* @author Felix Jost, http://www.goodsolutions.ch
*/
public class ClipboardTrayController extends BasicController {
private final ClipboardServiceImpl cbs;
private Link openDetail;
private VelocityContainer mainVc;
private Controller trayContentC;
private Panel expandedP;
private ClipboardEntry latestCB;
private Component detail;
private FloatingResizableDialogController frdC;
/**
* @param ureq
* @param wControl
*/
ClipboardTrayController(UserRequest ureq, WindowControl wControl, ClipboardServiceImpl cbs) {
super(ureq, wControl);
this.cbs = cbs;
expandedP = new Panel("trayExpanded");
mainVc = createVelocityContainer("tray");
ComponentUtil.registerForValidateEvents(mainVc, this);
openDetail = LinkFactory.createLink("opendetail", mainVc, this);
mainVc.put("expanded", expandedP);
putInitialPanel(mainVc);
}
@Override
public void event(UserRequest ureq, Component source, Event event) {
if (event == ComponentUtil.VALIDATE_EVENT) {
// before rendering, check if we can still or newly offer the paste
// button. this is the case when the clipboard contains an entry which
// matches the desired dataflavor
ClipboardEntry cbe = cbs.getClipboardEntry();
if (cbe == null) {
expandedP.setContent(null);
if (trayContentC != null) trayContentC.dispose();
} else {
if (cbe != latestCB) {
latestCB = cbe;
trayContentC = cbe.createTrayUI().createController(ureq, getWindowControl());
frdC = new FloatingResizableDialogController(ureq, getWindowControl(), trayContentC.getInitialComponent(), "clipboard tray");
frdC.addControllerListener(this);
detail = frdC.getInitialComponent();
expandedP.setContent(detail);
}
}
} else if (source == openDetail) {
if (detail == null) {
getWindowControl().setInfo("clipboard is empty");
} else {
expandedP.setContent(detail);
}
}
}
public void event(UserRequest ureq, Controller source, Event event) {
if (source == frdC) {
if (event == Event.DONE_EVENT) {
// close button was clicked -> hide
expandedP.setContent(null);
}
}
}
@Override
protected void doDispose() {
if (trayContentC != null) trayContentC.dispose();
if (frdC != null) frdC.dispose();
}
}
/**
* OLAT - Online Learning and Training<br>
* http://www.olat.org
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Copyright (c) 1999-2006 at Multimedia- & E-Learning Services (MELS),<br>
* University of Zurich, Switzerland.
* <p>
*/
package org.olat.core.commons.services.clipboard.impl;
import org.olat.core.commons.services.clipboard.ClipboardEntry;
import org.olat.core.commons.services.clipboard.ClipboardEntryCreator;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.Component;
import org.olat.core.gui.components.link.Link;
import org.olat.core.gui.components.link.LinkFactory;
import org.olat.core.gui.components.velocity.VelocityContainer;
import org.olat.core.gui.control.Event;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.control.controller.BasicController;
/**
* @author Felix Jost, http://www.goodsolutions.ch
*
*/
public class CopyToClipboardController extends BasicController {
private final ClipboardServiceImpl cbs;
private final ClipboardEntryCreator cbCreator;
private Link copyTo;
/**
* @param ureq
* @param wControl
*/
CopyToClipboardController(UserRequest ureq, WindowControl wControl, ClipboardServiceImpl cbs, ClipboardEntryCreator cbCreator) {
super(ureq, wControl);
this.cbs = cbs;
this.cbCreator = cbCreator;
VelocityContainer mainVc = createVelocityContainer("to");
copyTo = LinkFactory.createButton("copyTo", mainVc, this);
putInitialPanel(mainVc);
}
@Override
public void event(UserRequest ureq, Component source, Event event) {
if (source == copyTo) {
ClipboardEntry cbe = cbCreator.createClipboardEntry();
cbs.setClipboardEntry(cbe);
}
}
@Override
protected void doDispose() {
// nothing to do
}
}
/**
* OLAT - Online Learning and Training<br>
* http://www.olat.org
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS,
* <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Copyright (c) 1999-2006 at Multimedia- & E-Learning Services (MELS),<br>
* University of Zurich, Switzerland.
* <p>
*/
package org.olat.core.commons.services.clipboard.impl;
import org.olat.core.commons.services.clipboard.ClipboardEntry;
import org.olat.core.commons.services.clipboard.ClipboardEntryCreator;
import org.olat.core.commons.services.clipboard.impl.ClipboardServiceImpl;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.Component;
import org.olat.core.gui.components.link.Link;
import org.olat.core.gui.components.link.LinkFactory;
import org.olat.core.gui.components.panel.Panel;
import org.olat.core.gui.components.util.ComponentUtil;
import org.olat.core.gui.components.velocity.VelocityContainer;
import org.olat.core.gui.control.Event;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.control.controller.BasicController;
/**
* @author Felix Jost, http://www.goodsolutions.ch
*/
public class PasteFromClipboardController extends BasicController {
private final ClipboardServiceImpl cbs;
private Link pasteFrom;
private VelocityContainer mainVc;
private final Class[] acceptedFlavorInterfaces;
/**
* @param ureq
* @param wControl
*/
PasteFromClipboardController(UserRequest ureq, WindowControl wControl, ClipboardServiceImpl cbs, Class[] acceptedFlavorInterfaces) {
super(ureq, wControl);
this.cbs = cbs;
this.acceptedFlavorInterfaces = acceptedFlavorInterfaces;
mainVc = createVelocityContainer("from");
ComponentUtil.registerForValidateEvents(mainVc, this);
pasteFrom = LinkFactory.createButton("pasteFrom", mainVc, this);
putInitialPanel(mainVc);
}
@Override
public void event(UserRequest ureq, Component source, Event event) {
if (event == ComponentUtil.VALIDATE_EVENT) {
// before rendering, check if we can still or newly offer the paste
// button.
// this is the case when the clipboard contains an entry which matches
// the desired dataflavor
ClipboardEntry cbe = cbs.getClipboardEntry();
if (cbe == null) {
// or do a setVisible?
pasteFrom.setEnabled(false);
} else {
// there is an entry in the clipboard, check if we can make use of it.
// TODO: Improve this handling
boolean accepted = false;
for (int i = 0; !accepted && i < acceptedFlavorInterfaces.length; i++) {
Class aclass = acceptedFlavorInterfaces[i];
if (aclass.equals(cbe.getClass())) {
pasteFrom.setEnabled(true);
accepted = true;
}
}
}
} else if (source == pasteFrom) {
fireEvent(ureq, new ClipboardEvent(cbs.getClipboardEntry()));
}
}
@Override
protected void doDispose() {
// nothing to do
}
}
$r.render("pasteFrom")
$r.render("copyTo")
$r.render("opendetail")
$r.render("expanded")
#Tue Feb 09 15:17:21 CET 2010
copyTo=\u0646\u0633\u062E
opendetail=\u0627\u0644\u062D\u0627\u0641\u0638\u0629
pasteFrom=\u0644\u0635\u0642
#Thu May 21 20:15:23 CEST 2009
copyTo=\u041A\u043E\u043F\u0438\u0440\u0430\u0439\u0442\u0435
opendetail=\u041C\u0435\u0436\u0434\u0438\u043D\u0435\u043D \u0431\u0443\u0444\u0435\u0440
pasteFrom=\u0417\u0430\u043B\u0435\u043F\u0435\u0442\u0435
#Mon Mar 02 09:54:13 CET 2009
copyTo=Kop\u00EDrovat
opendetail=Schr\u00E1nka
pasteFrom=Vlo\u017Eit
#Mon Mar 02 09:54:04 CET 2009
copyTo=Kopieren
opendetail=Zwischenablage
pasteFrom=Einf\u00FCgen
#Mon Mar 02 09:54:15 CET 2009
copyTo=\u0391\u03BD\u03C4\u03B9\u03B3\u03C1\u03B1\u03C6\u03AE
opendetail=\u03A0\u03AF\u03BD\u03B1\u03BA\u03B1\u03C2 (Clipboard)
pasteFrom=\u0395\u03C0\u03B9\u03BA\u03CC\u03BB\u03BB\u03B7\u03C3\u03B7
#Fri Jan 22 19:08:42 CET 2010
copyTo=Copy
opendetail=Clipboard
pasteFrom=Paste
#Mon Mar 02 09:54:20 CET 2009
copyTo=Copiar
opendetail=Portapapeles
pasteFrom=Pegar
#Mon Mar 02 09:54:07 CET 2009
copyTo=Copier
opendetail=Presse-papiers
pasteFrom=Coller
#Fri Sep 03 14:17:40 CEST 2010
copyTo=Copiare
opendetail=Clipboard
pasteFrom=Incollare
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment