TS 68 JavaFX Hints

(Difference between revisions)
(Created page with ''''Author:''' <br> '''Version:''' 1.1 <br> '''Last update:''' 23 November 2009 <br> '''Introduction:''' <br> '''Comments:''' <br> __TOC__ == Implement all abstract methods …')
(Static Hints)
 
(15 intermediate revisions not shown)
Line 1: Line 1:
-
'''Author:''' <br>
+
'''Author:'''   [mailto:sunflower@netbeans.org Alexandr Scherbatiy] <br>  
-
'''Version:''' 1.1 <br>
+
'''Version:''' 1.2 <br>
-
'''Last update:''' 23 November 2009 <br>
+
'''Last update:''' 26 February 2010 <br>
'''Introduction:'''  <br>
'''Introduction:'''  <br>
'''Comments:'''  <br>
'''Comments:'''  <br>
Line 7: Line 7:
__TOC__
__TOC__
 +
 +
== Semantic ==
 +
   
 +
=== {{testcase|Unused variables }} ===
 +
*  Copy the code to the editor:
 +
<code> <pre>       
 +
var a = 10;
 +
var b = 20;
 +
var c = a + 30;
 +
</pre> </code> 
 +
* {{result|EXPECTED RESULT:  The 'b' variable is indicated as unused  }}
 +
 +
=== {{testcase|Unused attributes}} ===
 +
*  Copy the code to the editor:
 +
<code> <pre>       
 +
class A{
 +
    public var a;
 +
}</pre> </code> 
 +
* {{result|EXPECTED RESULT:  The 'a' attribute is indicated as unused  }}
 +
 +
=== {{testcase|Unused functions}} ===
 +
*  Copy the code to the editor:
 +
<code> <pre> 
 +
class A{
 +
    public function f(){}
 +
}
 +
</pre> </code> 
 +
* {{result|EXPECTED RESULT:  The 'f' function is indicated as unused  }}
 +
 +
== Dynamic Hints  ==
 +
   
 +
=== {{testcase|Remove unused imports }} ===
 +
*  Copy the code to the editor:
 +
<code> <pre> 
 +
import javafx.scene.shape.Circle;
 +
import javafx.scene.shape.Rectangle;
 +
 +
Circle{}
 +
</pre> </code> 
 +
* Click on the hint
 +
* Select Remove unused import...
 +
* {{result|EXPECTED RESULT:  The unused import is deleted  }}
 +
 +
 +
=== {{testcase|Generate variable }} ===
 +
*  Copy the code to the editor:
 +
<code> <pre> 
 +
public class A {
 +
    function f() {
 +
          value;
 +
    }
 +
}
 +
 +
</pre> </code> 
 +
* Click on the hint
 +
* Select Create variable value in the javafxapplication.Main.A
 +
* {{result|EXPECTED RESULT:  The 'var value;' attribute is generated  }}
 +
<code> <pre> 
 +
public class A {
 +
    var value;
 +
 +
    function f() {
 +
          value;
 +
    }
 +
}
 +
</pre> </code>
 +
 +
=== {{testcase|Generate local variable }} ===
 +
*  Copy the code to the editor:
 +
<code> <pre> 
 +
public class A {
 +
    function f() {
 +
          value;
 +
    }
 +
}
 +
 +
</pre> </code> 
 +
* Click on the hint
 +
* Select Create local variable value in the javafxapplication.Main.A
 +
* {{result|EXPECTED RESULT:  The 'var value;' local variable is generated  }}
 +
<code> <pre> 
 +
public class A {
 +
    function f() {
 +
 +
          var value;
 +
          value;
 +
    }
 +
}
 +
</pre> </code>
 +
 +
=== {{testcase|Generate class}} ===
 +
*  Copy the code to the editor:
 +
<code> <pre> 
 +
var a = A{};
 +
</pre> </code> 
 +
* Click on the hint
 +
* Select Create A Class in the javafxapplication
 +
* {{result|EXPECTED RESULT:  The 'A' class is generated  under the javafxapplication package}}
 +
 +
 +
=== {{testcase|Generate class in a file}} ===
 +
*  Copy the code to the editor:
 +
<code> <pre> 
 +
var a = A{};
 +
</pre> </code> 
 +
* Click on the hint
 +
* Select Create A Class in the javafxapplication.Main
 +
* {{result|EXPECTED RESULT:  The 'A' class is generated  in the Main file}}
 +
<code> <pre> 
 +
var a = A{};
 +
 +
class A {
 +
    //TODO Not implemented yet.
 +
}
 +
</pre> </code>
 +
 +
 +
== Static Hints  ==
 +
   
 +
=== {{testcase|Surround with try-catch  }} ===
 +
*  Copy the code to the editor:
 +
<code> <pre> 
 +
import javafx.scene.shape.Circle;
 +
 +
Circle{}
 +
</pre> </code> 
 +
* Select the ''Circle{}'' line
 +
* Click on the Hint
 +
* Select Surround with try{...
 +
* {{result|EXPECTED RESULT:  The try-catch block is added }}
 +
<code> <pre> 
 +
try{
 +
    Circle{}
 +
}catch(e){
 +
   
 +
}
 +
</pre> </code>
 +
 +
 +
=== {{testcase|Surround with if-else }} ===
 +
*  Copy the code to the editor:
 +
<code> <pre> 
 +
value
 +
</pre> </code> 
 +
* Select the ''value'' line
 +
* Click on the Hint
 +
* Select for if (exp) {...|} else {...} 
 +
* {{result|EXPECTED RESULT:  The if block is added }}
 +
<code> <pre> 
 +
if (exp) {
 +
 +
}else {
 +
}</pre> </code>
 +
 +
=== {{testcase|Surround with for (idx in arr){... }} ===
 +
*  Copy the code to the editor:
 +
<code> <pre> 
 +
value
 +
</pre> </code> 
 +
* Select the ''value'' line
 +
* Click on the Hint
 +
* Select for (idx in arr){...
 +
* {{result|EXPECTED RESULT:  The for block is added }}
 +
<code> <pre> 
 +
for (idx in arr) {
 +
}
 +
</pre> </code>
 +
 +
 +
=== {{testcase|Surround with while (exp) {...  }} ===
 +
*  Copy the code to the editor:
 +
<code> <pre> 
 +
value
 +
</pre> </code> 
 +
* Select the ''value'' line
 +
* Click on the Hint
 +
* Select for while (exp) {... 
 +
* {{result|EXPECTED RESULT:  The while block is added }}
 +
<code> <pre> 
 +
while (exp) {
 +
 +
}
 +
</pre> </code>
== Implement all abstract methods ==
== Implement all abstract methods ==
      
      
 +
=== {{testcase|Argument with Sequence type }} ===
 +
*  Copy the code to the editor:
 +
<code> <pre>       
 +
abstract class A{
 +
    abstract function f (seq:Boolean[]);
 +
}
 +
 +
class B extends A{
 +
 +
}
 +
</pre> </code> 
 +
*  Implement all abstract methods .
 +
** {{result|EXPECTED RESULT:  Implementation of the abstract methods should be added  }}
 +
<code> <pre> 
 +
import java.lang.UnsupportedOperationException;
 +
 +
abstract class A{
 +
    abstract function f (seq:Boolean[]);
 +
}
 +
 +
class B extends A{
 +
    override function f (seq : Boolean[]) : Object {
 +
        throw new UnsupportedOperationException('Not implemented yet');
 +
    }
 +
}
 +
</pre> </code>
 +
 +
=== {{testcase|Generic interface}} ===
=== {{testcase|Generic interface}} ===
*  Copy the code to the editor:
*  Copy the code to the editor:

Current revision as of 13:50, 26 February 2010

Author: Alexandr Scherbatiy
Version: 1.2
Last update: 26 February 2010
Introduction:
Comments:


Contents


Semantic

Unused variables

  • Copy the code to the editor:
         
var a = 10;
var b = 20;
var c = a + 30;
  • EXPECTED RESULT: The 'b' variable is indicated as unused

Unused attributes

  • Copy the code to the editor:
         
class A{
    public var a;
}
  • EXPECTED RESULT: The 'a' attribute is indicated as unused

Unused functions

  • Copy the code to the editor:
  
class A{
    public function f(){}
}
  • EXPECTED RESULT: The 'f' function is indicated as unused

Dynamic Hints

Remove unused imports

  • Copy the code to the editor:
  
import javafx.scene.shape.Circle;
import javafx.scene.shape.Rectangle;

Circle{}
  • Click on the hint
  • Select Remove unused import...
  • EXPECTED RESULT: The unused import is deleted


Generate variable

  • Copy the code to the editor:
  
public class A {
    function f() {
          value;
    }
}

  • Click on the hint
  • Select Create variable value in the javafxapplication.Main.A
  • EXPECTED RESULT: The 'var value;' attribute is generated
  
public class A {
    var value;

    function f() {
          value;
    }
}

Generate local variable

  • Copy the code to the editor:
  
public class A {
    function f() {
          value;
    }
}

  • Click on the hint
  • Select Create local variable value in the javafxapplication.Main.A
  • EXPECTED RESULT: The 'var value;' local variable is generated
  
public class A {
    function f() {

          var value;
          value;
    }
}

Generate class

  • Copy the code to the editor:
  
var a = A{};
  • Click on the hint
  • Select Create A Class in the javafxapplication
  • EXPECTED RESULT: The 'A' class is generated under the javafxapplication package


Generate class in a file

  • Copy the code to the editor:
  
var a = A{};
  • Click on the hint
  • Select Create A Class in the javafxapplication.Main
  • EXPECTED RESULT: The 'A' class is generated in the Main file
  
var a = A{};

class A {
    //TODO Not implemented yet.
}


Static Hints

Surround with try-catch

  • Copy the code to the editor:
  
import javafx.scene.shape.Circle;

Circle{}
  • Select the Circle{} line
  • Click on the Hint
  • Select Surround with try{...
  • EXPECTED RESULT: The try-catch block is added
  
try{
    Circle{}
}catch(e){
    
}


Surround with if-else

  • Copy the code to the editor:
  
value
  • Select the value line
  • Click on the Hint
  • Select for if (exp) {...|} else {...}
  • EXPECTED RESULT: The if block is added
  
if (exp) {
 
}else {
}

Surround with for (idx in arr){...

  • Copy the code to the editor:
  
value
  • Select the value line
  • Click on the Hint
  • Select for (idx in arr){...
  • EXPECTED RESULT: The for block is added
  
for (idx in arr) {
}


Surround with while (exp) {...

  • Copy the code to the editor:
  
value
  • Select the value line
  • Click on the Hint
  • Select for while (exp) {...
  • EXPECTED RESULT: The while block is added
  
while (exp) {

}

Implement all abstract methods

Argument with Sequence type

  • Copy the code to the editor:
         
abstract class A{
    abstract function f (seq:Boolean[]);
}

class B extends A{

}
  • Implement all abstract methods .
    • EXPECTED RESULT: Implementation of the abstract methods should be added
  
import java.lang.UnsupportedOperationException;

abstract class A{
    abstract function f (seq:Boolean[]);
}

class B extends A{
    override function f (seq : Boolean[]) : Object { 
        throw new UnsupportedOperationException('Not implemented yet');
    }
}


Generic interface

  • Copy the code to the editor:
         
import java.lang.Comparable;

class Vector extends Comparable {
}
  • Implement all abstract methods .
    • EXPECTED RESULT: Implementation of the abstract methods should be added
import java.lang.Comparable;
import java.lang.UnsupportedOperationException;

class Vector extends Comparable {
    override public function compareTo (arg) : Integer {
        throw new UnsupportedOperationException('Not implemented yet');
    }
}
Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo