I want to disable moving events from Vaadin Calendar
All of these handlers are automatically set when creating a new Calendar. If you wish to disable some of the default functionality, you can simply set the corresponding handler to null. This will prevent the functionality from ever appearing on the user interface. For example, if you set the EventMoveHandler to null, the user will be unable to move events in the browser. --> Book of Vaadin
I tried:
calendar.setHandler(null);
calendar.setHandler((EventMoveHandler) null);
calendar.setHandler((BaseEventMoveHandler) null);
EventMoveHandler handler = null;
calendar.setHandler(handler);
BaseEventMoveHandler baseHandler = null;
calendar.setHandler(baseHandler );
But nothing is working. Any suggestion....?
It really works for me with Vaadin 7.4.5:
calendar.setHandler((EventMoveHandler)null);
calendar.setHandler((EventResizeHandler)null);
If you want to disable all handlers and make the calendar completely read-only, this worked for me.
calendar.setReadOnly(true);
EDIT1:
This approach however doesn't disable resize pointers for the events. Thus, the best solution I see is to use it together with asmellado's answer :
calendar.setReadOnly(true);
calendar.setHandler((EventMoveHandler)null);
calendar.setHandler((EventResizeHandler)null);
Also, if I did not use the setReadOnly method, I was running in some strage client-side exceptions when I tried to move the event.
Related
I use GraphStream in my application and to show graphs I use a FXViewer for every graph.
Initially I want to show the different graphs, without setting positions of nodes, so I use the enableAutoLayout() method:
ArrayList<FxViewer> viewers = new ArrayList<>();
foreach(Graph graph : graphList) {
FxViewer viewer = new FxViewer(graph, FxViewer.ThreadingModel.GRAPH_IN_GUI_THREAD);
viewer.addView(graph.getId(), new FxGraphRenderer());
viewer.enableAutoLayout();
viewers.add(viewer);
}
Next, I want to show the same graphs but with fixed positions setted manually and so, for every graph, I disable the autoLayout to the related FXViewer.
viewers.forEach(Viewer::disableAutoLayout);
But, for every time I disable the autoLayout to a FXViewer in my console appears this message:
org.graphstream.ui.layout.LayoutRunner run
INFO: Layout 'SpringBox' process stopped.
Is it a problem? Should I do something or I can just ignore this message?
For anyone who might have the same question, here is the answer from the team of GraphStream:
That message is emitted by the LayoutRunner that handles the graph layout in a different thread. That thread is stopped when you disable the auto layout. And as the log category says, it's just info, so nothing to worry about.
I am working on an application where I need to put object using ARCore. And then I need to save the frames as an image.
So is there any way to set auto focus for ARCore camera?
As of ARCore 1.4, you can enable or disable autofocus through your ARCore Session's Config:
Session session = new Session(context);
Config config = new Config(session);
if (enableAutoFocus) {
config.setFocusMode(Config.FocusMode.AUTO);
} else {
config.setFocusMode(Config.FocusMode.FIXED);
}
session.configure(config);
https://developers.google.com/ar/reference/java/com/google/ar/core/Config.html#setFocusMode(com.google.ar.core.Config.FocusMode)
Here's what Google ARCore engineers say about Config.FocusMode:
public static final enum Config.FocusMode
Config.FocusMode enum selects the desired behaviour of the camera focus subsystem. Currently, the default focus mode is FIXED, but this default might change in the future. Note, on devices where ARCore does not support Auto Focus due to the use of a fixed focus camera, setting AUTO will be ignored. See the ARCore Supported Devices page for a list of affected devices.
For optimal AR tracking performance, use the focus mode provided by the default session config. While capturing pictures or video, use AUTO. For optimal AR tracking, revert to the default focus mode once auto focus behavior is no longer needed. If your app requires fixed focus camera, call setFocusMode(Config.FocusMode)(FIXED) before enabling the AR session. This will ensure that your app always uses fixed focus, even if the default camera config focus mode changes in a future release.
There are two values:
public static final Config.FocusMode AUTO
public static final Config.FocusMode FIXED
So, in Java code:
Config ar_session_config = session.getConfig();
ar_session_config.setFocusMode(Config.FocusMode.AUTO);
session.configure(ar_session_config);
Hope this helps.
Old question, but I thought I'd update the answer with implementation in Sceneform. Sceneform SDK 1.4 added the ability to setup autofocus. I use an extension function to enable it.
Declare the relevant fields globally.
//The AR Core session
private var arSession: Session? = null
private var arConfig: Config? = null
and the extension function definition :
private fun Session.setupAutofocus() {
//Create the config
arConfig = Config(this)
//Check if the configuration is set to fixed
if (arConfig?.focusMode == Config.FocusMode.FIXED)
arConfig?.focusMode = Config.FocusMode.AUTO
//Sceneform requires that the ARCore session is configured to the UpdateMode LATEST_CAMERA_IMAGE.
//This is probably not required for just auto focus. I was updating the camera configuration as well
arConfig?.updateMode = Config.UpdateMode.LATEST_CAMERA_IMAGE
//Reconfigure the session
configure(arConfig)
//Setup the session with ARSceneView
fragment.arSceneView.setupSession(this)
//log out if the camera is in auto focus mode
ARApplication.log("The camera is current in focus mode : ${config.focusMode.name}")
}
and a good place to call this is your activity's onResume
override fun onResume() {
super.onResume()
//Check if ARSession is null. If it is, instantiate it
if(arSession == null) {
arSession = Session(this#EdgeActivity)
arSession?.setupAutofocus()
}
}
If the problem is in a Unity project, then change the CameraFocusMode parameter to Auto instead of Fixed.
I have problem with modal window. I call this two methods setIsModal(true) and setShowModalMask(true) but why my window isn't modal ?
Here is the Code :
Window summaryWindow = new Window();
summaryWindow.setWidth(950);
summaryWindow.setHeight(620);
summaryWindow.centerInPage();
summaryWindow.setCanDragReposition(false);
summaryWindow.setIsModal(true);
summaryWindow.setShowModalMask(true);
summaryWindow.setShowMinimizeButton(false);
summaryWindow.setTitle("Example");
summaryWindow.addItem(new Button("Example");
summaryWindow.show();
The exception you're getting is valid. In any GWT related technology, you'll find many API functionalities to set properties of GWT widget. For example, for a Window widget you have, setWidth, setHeight, centerInPage etc...
Now some of these properties MUST be applied before the widget is rendered in DOM of the browser & some of them MUST be applied after the widget is rendered in DOM of the browser.
ShowModalMask() is a property that you can set only before the widget is rendered.
centerInPage() is a property that renders Window in DOM of browser & that is the reason you're getting the exception.
Apply properties in a proper order (centerInPage() after ShowModalMask() in your case) to avoid this kind of exception.
I'm using smartgwt 2.4 : if I try your code with a button calling it enclosed in a method I get an error which indicated I cannot modify it with setModalMask (IllegalStateException - this property cannot be changed after the component has been created) .
After moving this call just after the instanciation it's working:
Window summaryWindow = new Window();
summaryWindow.setShowModalMask(true);
I don't really understand, but let me know if it's also working for you
I need some help. Is it possible to simulate a drag & drop without registering a component?
E.g. I click the mousekey anywhere on the window and hold the mousekey down, at this moment, I want to create or simulate a DragSourceEvent programmatically with Java.
Is this possible?
Update:
Regarding Bob's reply, at least I got it, I can create a listener for the drag & drop:
DragSource dragSource = new DragSource();
DragGestureListener listener = new DragGestureListener() {
public void dragGestureRecognized(DragGestureEvent event) {
event.startDrag (null, strSel) ;
...
}
}
listener.dragGestureRecognized(new DragGestureEvent(
new DragGestureRecognizer(dragSource, component) {
}, DnDConstants.ACTION_COPY, new Point(0,0), events ));
but unfortunately i get this exception:
java.lang.IllegalArgumentException:
source actions at
java.awt.dnd.DragSourceContext.(DragSourceContext.java:169)
at
java.awt.dnd.DragSource.createDragSourceContext(DragSource.java:454)
at
java.awt.dnd.DragSource.startDrag(DragSource.java:293)
at
java.awt.dnd.DragSource.startDrag(DragSource.java:403)
at
java.awt.dnd.DragGestureEvent.startDrag(DragGestureEvent.java:203)
any suggestions?
The question you asked:
I haven't tried it, but in theory you should be able to create the Event object and get a handle on the Swing Event Queue from one of the system classes. However without having a valid component, there may be problems when methods try to work with the event.
What you probably meant:
Registering events for a standard window -- you should be able to set up drag and drop support for an empty JPanel or JFrame, but it'll take some hacking. Drag & Drop is a pain to work with at this level when not built in -- I suggest using something like an invisible component or something instead.
Im writing some java code and im hitting a wall, with FileUpload, i am trying to get a alternate button to activate the filebrowser from the FileUpload.
I tried to dispatch the event from one to another, tried to extend FileUpload to have a button that triggers some action but no luck.
Fileupload upload = new FileUpload();
Button b = new Button("Browse",new ClickHandler() {
// trigger upload Browser
});
Something like this.
You cannot do this due to security restrictions. The restriction is that untrusted code cannot trigger the File Browse dialog to open because it could then do so without user input, possibly tricking the user into thinking the dialog is from a different webapp or entirely different application.
Actually it is possible on IE6 and maybe IE7, all other prohibit this action.
Read my question and answer: gwt fileupload
You might give a shot to SWFUpload in combination with swfupload-gwt.