I've got a jFrame Form with an action handler that instantiates a new form and switches over to it using setVisible(true). That much works.
When I try to setVisible(false) on the current form, however, I get an error:
cannot find symbol
symbol: method setVisible(boolean)
location: class foo.bar
----
My action handler looks like this:
public void Login() {
//#TODO Log in code
setVisible(false); // <-- Error here
mainPage.mainScreen ms = new mainPage.mainScreen();
ms.setVisible(true);
}
I was trying to hide the "main" view, so to speak, and netbeans won't allow this. I can instantiate a different view, show it, and it can show and hide itself all day long.
Related
I am trying to use Unity3D's UIToolkit with Visual Scripting Graph...
Typically, I can Query for the proper element, and then add the necessary function to the callback... However, as I am new to Visual Scripting, I am not sure how to get to this point. I've got the 'clickable' object of the button isolated, but I'm not sure how to assign the follow-up execution in the graph.
Usually in the code, I would do something like
clickable.clicked += ExampleFunction();
What I am messing up in the graph, is how to access the '.clicked' part. I can get the proper button element, and I can isolate it's clickable property, but I can't figure out how to assign some kind of functionality to react to the button getting clicked.
I could use a custom node to make this work, but I am looking for a way to do this with built-in nodes, if possible.
Alright... I had to write a custom node, but I figured this out. Here is the graph for the solution.
You have to grab the UIDocument from whichever GameObject it is attached to... You then need to get the Root Visual Element, do NOT clone or instantiate it. You then need to Query for the desired button, using the name you gave it in the UI Builder. It is easier if you use the U Query Extensions nodes... After that, I just made a custom node to subscribe the functionality. I am not familiar of any nodes that do this.
Here is the 'Subscribe Start Result' node code:
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.UIElements;
public class SubscribeStartResult : Unit
{
[DoNotSerialize]
[PortLabelHidden]
public ControlInput inputTrigger;
[DoNotSerialize]
[PortLabelHidden]
public ValueInput element;
protected override void Definition()
{
element = ValueInput<Button>("element");
inputTrigger = ControlInput("inputTrigger", (flow) =>
{
flow.GetValue<Button>(element).clicked += () =>
{
Debug.Log("Button clicked");
};
return null;
});
}
}
With this setup, clicking the 'Start Button' in play-mode will log "Button clicked" in the Console.
The 'return null;' line is an artifact of the lambda. It is required to continue the control flow in the event this node has a follow-up... Otherwise, this combination of nodes and code allow you to assign callbacks for the UI Builder elements, using the Visual Scripting Graph.
In TYPO3 own extension validation of form inputs is done before control is handed over to the controller action. How can I get to work on the validation errors before being handed over to view?
Usually there should be no reason to do this. However, what you could do is to override the errorAction() method (which is inherited from AbstractActionController) in your controller. There, you can get the validationResults like this:
$validationResults = $this->arguments->getValidationResults()
Then you can fiddle with them before they are bound to the current request object:
$originalRequest = clone $this->request;
$this->request->setOriginalRequest($originalRequest);
$this->request->setOriginalRequestMappingResults($validationResults);
I am creating my own GEF based graphical editor. It creates error markers when validation fails and the editor has a gotoMarker method to find and active the marker. This all works.
Only problem is that I get a RuntimeException when double clicking on the marker (when clicking 'GoTo' from the context menu there is no problem)
The message is as follows:
java.lang.RuntimeException: WARNING: Prevented recursive attempt to activate part org.eclipse.ui.views.ProblemView while still in the middle of activating part namespace.myEditorID`
Part of the corresponding stacktrace shows:
at org.eclipse.ui.internal.WorkbenchPage.setActivePart(WorkbenchPage.java:3586)
...
at org.eclipse.swt.widgets.Display.eventProc(Display.java:1245)
at org.eclipse.swt.internal.gtk.OS._gtk_enumerate_printers(Native Method)
at org.eclipse.swt.internal.gtk.OS.gtk_enumerate_printers(OS.java:9296)
at org.eclipse.swt.printing.Printer.getPrinterList(Printer.java:98)
at org.eclipse.gef.ui.actions.PrintAction.calculateEnabled(PrintAction.java:45)
at org.eclipse.gef.ui.actions.WorkbenchPartAction.isEnabled(WorkbenchPartAction.java:123)
...
The complete stacktrace is a bit long, so it is available at pastebin.
This gave me the idea to disable the printing action in ActionBarContributor.declareGlobalActionKeys by removing:
addGlobalActionKey(ActionFactory.PRINT.getId());
This solves the RuntimeException...?!
I do not see the relation between the Printing action and going to the corresponding object after clicking on a marker. Leaving the Printing action disabled, of course, is not a solution.
So what can I do to keep the Printing action available and prevent these RuntimeExceptions?
As a test ,I refer to the url:https://bugs.eclipse.org/bugs/show_bug.cgi?id=154112
and I overrid my EditorPart's setFocus method like:
#Override
public void setFocus() {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().setFocus();
}
and then it works well.
I want to create a jface wizard and collect credentials as I go along - password and username on page 1 and then on page 2 I want to display a list I get from an oracle database.
I am using eclipse, and have all the controls in the places I want. On page 2 I put the oracle connection details and sql statement in the createControl method of wizardpage. This seems to fail with a class not found (ojdbc6.jar included in my build path) which I can't decide whether this is an eclipse issue or my code (my code works when it is standalone, not in a wizard)
The failure happens when I start the wizardpage, which it probably will do as I havent got the correct credentials at that point. I couldn't find a method in the wizardpage documentation for running stuff when you enter that wizardpage. Is there a method that runs on entry?
I want to connect to the database to pull down a list to populate a table.
Cheers
David
The createControl method gets called on all pages when the Wizard is opened. You should use createControl only to layout SWT or JFace objects.
You probably want to initialize the JDBC connection when the second page becomes visible. At that point you would then load your list on the page. To do that, override the setVisible method on the second page as follows:
/* (non-Javadoc)
* #see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)
*/
#Override
public void setVisible(boolean visible) {
super.setVisible(visible);
if(visible){
// initialize the jdbc connection here - use a data access object
// use the connection or the DAO to populate your list
}
}
This way the connection will be initialized when the second page becomes visible. Another useful thing to do from the setVisible method is to assign the focus to the right control by calling forceFocus() on the relevant control.
Well, imagine that we have a register form of a class Customer and we only ask three fields (name,surname,email) and after, when this user logged first time we want to complete this information.
First, we have in lib/form/doctrine a file called 'CustomerForm.class.php' wich is generated automatic on command line. In this file we 'setup' only 3 fields and validators and if we wanna use we do something like that:
$this->form = CustomerForm();
Second, we create manual another form named 'CustomerFormStep1.class.php' where we can setup for validate the other fields. But when we do..
$this->form = CustomerFormStep1();
it returns error: Fatal error: Class 'CustomerFormStep1' not found
What is wrong?
Thanks.
Assuming you have the form defined as:
class CustomerFormStep1 extends sfForm
or similar (sfFormDoctrine etc), and named correctly like you say (CustomerFormStep1.class.php) and in lib/form, then Symfony should just pick the definition up fine. Did you clear the cache after creating and placing it in the right place? (symfony cc).
Create the new CustomerFormStep1 class as #richsage instructed. Then, in your actions you can write something like:
public function executeLogin(){
//before login
$this->form = new CustomerForm();
}
public function executeLoggedIn(){
$this->form = new CustomerFormStep1();
//other steps
}
Haven't you read the tutorial? Extending forms is perfectly described in context with reh admin generator and can of course be applied to any case.