Dear users, Please note that, from Monday, August 16, 2019, RSA keys shorter than 2048bit will no longer be accepted for security reasons. Please update your keys as needed before this date. If you need assistance with regard to this process, please contact sia@list.lu

Thank you for your understanding.

Commit 0abfd332 authored by Nico Mack's avatar Nico Mack

Began implementation of interaction events

parent 8f72fe47
UNDEFINED=undefined
ON_DROP=onDrop
ON_TRANSLATE_BEGIN=onTranslateBegin
ON_TRANSLATE_END=onTranslateEnd
ON_ROTATE_BEGIN=onRotateBegin
ON_ROTATE_END=onRotateEnd
ON_LIFT=onLift
ON_TOUCHED=onTouched
ON_DRAG_BEGIN=onDragBegin
ON_DRAG_END=onDragEnd
ON_RELEASED=onReleased
ON_TETHER_ESTABLISHED=onTetherEstablished
ON_TETHER_TORN_DOWN=onTetherTornDown
\ No newline at end of file
/**
* Copyright Luxembourg Institute of Science and Technology, 2018. All rights reserved.
*
* This file is part of TULIP.
*
* TULIP is free software: you can redistribute it and/or modify it under the terms of the GNU
* Lesser General Public License as published by the Free Software Foundation, version 3 of the
* License.
*
* TULIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with TULIP. If
* not, see <http://www.gnu.org/licenses/lgpl-3.0.html>.
*/
package lu.list.itis.dkd.tui.event.interaction;
/**
* @author Nico Mack [nico.mack@list.lu]
* @since 2.5
* @version 1.5.0
*/
public interface Handler extends Comparable<Handler> {
/**
* @param action
*/
boolean handle(Interaction action);
}
/**
* Copyright Luxembourg Institute of Science and Technology, 2018. All rights reserved.
*
* This file is part of TULIP.
*
* TULIP is free software: you can redistribute it and/or modify it under the terms of the GNU
* Lesser General Public License as published by the Free Software Foundation, version 3 of the
* License.
*
* TULIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with TULIP. If
* not, see <http://www.gnu.org/licenses/lgpl-3.0.html>.
*/
package lu.list.itis.dkd.tui.event.interaction;
/**
* @author Nico Mack [nico.mack@list.lu]
* @since 2.5
* @version 1.5.0
*/
public class Interaction {
private String signature;
// ***************************************************************************
// * Constants *
// ***************************************************************************
public static final Interaction ON_DROP = new Interaction(Signature.ON_DROP);
public static final Interaction ON_TRANSLATE_BEGIN = new Interaction(Signature.ON_TRANSLATE_BEGIN);
public static final Interaction ON_TRANSLATE_END = new Interaction(Signature.ON_TRANSLATE_END);
public static final Interaction ON_ROTATE_BEGIN = new Interaction(Signature.ON_ROTATE_BEGIN);
public static final Interaction ON_ROTATE_END = new Interaction(Signature.ON_ROTATE_END);
public static final Interaction ON_LIFT = new Interaction(Signature.ON_LIFT);
public static final Interaction ON_TOUCHED = new Interaction(Signature.ON_TOUCHED);
public static final Interaction ON_DRAG_BEGIN = new Interaction(Signature.ON_DRAG_BEGIN);
public static final Interaction ON_DRAG_END = new Interaction(Signature.ON_DRAG_END);
public static final Interaction ON_RELEASED = new Interaction(Signature.ON_RELEASED);
public static final Interaction ON_TETHER_ESTABLISHED = new Interaction(Signature.ON_TETHER_ESTABLISHED);
public static final Interaction ON_TETHER_TORN_DOWN = new Interaction(Signature.ON_TETHER_TORN_DOWN);
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Constructor(s) *
// ***************************************************************************
// ---------------------------------------------------------------------------
/**
*
*/
// ---------------------------------------------------------------------------
public Interaction() {
this.signature = Signature.UNDEFINED;
}
// ---------------------------------------------------------------------------
/**
* @param signature
*/
// ---------------------------------------------------------------------------
public Interaction(String signature) {
this.signature = signature;
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Class Body *
// ***************************************************************************
// ---------------------------------------------------------------------------
/**
* @return the unique signature for this interaction
*/
// ---------------------------------------------------------------------------
public String getSignature() {
return this.signature;
}
}
/**
* Copyright Luxembourg Institute of Science and Technology, 2018. All rights reserved.
*
* This file is part of TULIP.
*
* TULIP is free software: you can redistribute it and/or modify it under the terms of the GNU
* Lesser General Public License as published by the Free Software Foundation, version 3 of the
* License.
*
* TULIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with TULIP. If
* not, see <http://www.gnu.org/licenses/lgpl-3.0.html>.
*/
package lu.list.itis.dkd.tui.event.interaction;
import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps;
import com.google.common.collect.TreeMultimap;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map.Entry;
/**
* @author Nico Mack [nico.mack@list.lu]
* @since 2.5
* @version 1.0.0
*/
// ***************************************************************************
// * Class Definition and Members *
// ***************************************************************************
public class InteractionManager implements Interactive {
private Multimap<String, Handler> handlers;
// ***************************************************************************
// * Constants *
// ***************************************************************************
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Constructor(s) *
// ***************************************************************************
// ---------------------------------------------------------------------------
/**
*
*/
// ---------------------------------------------------------------------------
public InteractionManager() {
handlers = Multimaps.synchronizedSortedSetMultimap(TreeMultimap.create());
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Primitives *
// ***************************************************************************
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Class Body *
// ***************************************************************************
// ---------------------------------------------------------------------------
/**
* @param handler
* @param action
*/
// ---------------------------------------------------------------------------
@Override
public void registerHandlerFor(Handler handler, Interaction action) {
if (handlers.containsKey(action.getSignature())) {
Collection<Handler> actionHandlers = handlers.get(action.getSignature());
if ((actionHandlers != null) && actionHandlers.contains(handler)) {
return;
}
}
handlers.put(action.getSignature(), handler);
}
// ---------------------------------------------------------------------------
/**
* @param handler
* @param action
*/
// ---------------------------------------------------------------------------
@Override
public void unregisterHandlerFor(Handler handler, Interaction action) {
if (action != null) {
handlers.remove(action.getSignature(), handler);
} else {
List<String> signatures = new ArrayList<>();
for (Entry<String, Handler> entry : handlers.entries()) {
if (entry.getValue().equals(handler)) {
signatures.add(entry.getKey());
}
}
for (String signature : signatures) {
handlers.remove(signature, handler);
}
}
}
// ---------------------------------------------------------------------------
/**
* @param action
*/
// ---------------------------------------------------------------------------
@Override
public boolean respondTo(Interaction action) {
boolean handled = false;
if (handlers.containsKey(action.getSignature())) {
Collection<Handler> actionHandlers = handlers.get(action.getSignature());
for (Handler handler : actionHandlers) {
handled |= handler.handle(action);
}
}
return handled;
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * End of Class *
// ***************************************************************************
// ---------------------------------------------------------------------------
}
/**
* Copyright Luxembourg Institute of Science and Technology, 2018. All rights reserved.
*
* This file is part of TULIP.
*
* TULIP is free software: you can redistribute it and/or modify it under the terms of the GNU
* Lesser General Public License as published by the Free Software Foundation, version 3 of the
* License.
*
* TULIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with TULIP. If
* not, see <http://www.gnu.org/licenses/lgpl-3.0.html>.
*/
package lu.list.itis.dkd.tui.event.interaction;
/**
* @author Nico Mack [nico.mack@list.lu]
* @since 2.5
* @version 1.5.0
*/
public interface Interactive {
/**
* @param handler
* specifies the handler to be registered
* @param action
* specifies the action to register the handler for.
*/
public void registerHandlerFor(Handler handler, Interaction action);
/**
* @param handler
* specifies the previously registered handler to be unregistered
* @param action
* specifies the action to remove the handler for.
*/
public void unregisterHandlerFor(Handler handler, Interaction action);
/**
* @param action
* @return <code>true</code>if action was handled, <code>false</code> otherwise
*/
public boolean respondTo(Interaction action);
}
/**
* Copyright Luxembourg Institute of Science and Technology, 2016.
*
* This file is part of TULIP.
*
* TULIP is licensed under a dual-licensing scheme. For non-commercial purposes, the LGPL version 3,
* as stated below, is applicable. For all commercial purposes TULIP is licensed under a LIST
* proprietary license. Please contact LIST at tto@list.lu to obtain a commercial license.
*
* For all non-commercial purposes, TULIP is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, version 3 of the License.
*
* TULIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with TULIP. If
* not, see <http://www.gnu.org/licenses/lgpl-3.0.html>.
*/
package lu.list.itis.dkd.tui.event.interaction;
import org.eclipse.osgi.util.NLS;
/**
* Auto-generated class for string externalization to be used to bundle all node names.
*
* @author Eric Tobias [eric.tobias@list.lu]
* @since 2.2
* @version 2.5.0
*/
@SuppressWarnings({"javadoc", "squid:S3008"})
public class Signature extends NLS {
private static final String BUNDLE_NAME = "signature"; //$NON-NLS-1$
public static String UNDEFINED;
public static String ON_DROP;
public static String ON_TRANSLATE_BEGIN;
public static String ON_TRANSLATE_END;
public static String ON_ROTATE_BEGIN;
public static String ON_ROTATE_END;
public static String ON_LIFT;
public static String ON_TOUCHED;
public static String ON_DRAG_BEGIN;
public static String ON_DRAG_END;
public static String ON_RELEASED;
public static String ON_TETHER_ESTABLISHED;
public static String ON_TETHER_TORN_DOWN;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Signature.class);
}
private Signature() {}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment