Minor Change default first hint text Reformat and rearrange code
authorValentina Kiryushkina <valentina.kiryushkina@jetbrains.com>
Mon, 25 Jul 2016 09:38:36 +0000 (12:38 +0300)
committerValentina Kiryushkina <valentina.kiryushkina@jetbrains.com>
Mon, 25 Jul 2016 16:25:34 +0000 (19:25 +0300)
python/educational-core/course-creator/src/com/jetbrains/edu/coursecreator/ui/CCCreateAnswerPlaceholderPanel.java

index 469f7162123ace5c971d411dd19b86b2f34e6842..3f4f902e6ac9831375d53dac17d0a147c431cb8b 100644 (file)
@@ -18,19 +18,19 @@ import java.util.ArrayList;
 import java.util.List;
 
 public class CCCreateAnswerPlaceholderPanel extends JPanel {
-
+  private static String ourFirstHintText = "Type here to add hint";
+  
   private JPanel myPanel;
   private JTextArea myHintTextField;
   private JTextField myAnswerPlaceholderText;
   private JBLabel myHintLabel;
   private JPanel actionsPanel;
   private JPanel myHintsPanel;
+  private int myShownHintNumber = 0;
 
   private List<String> myHints = new ArrayList<String>() {{
-    add(ourDefaultHintText);
+    add(ourFirstHintText);
   }};
-  private int myShownHintNumber = 0;
-  private static String ourDefaultHintText = "To add hint type text here";
 
   public CCCreateAnswerPlaceholderPanel() {
     super(new BorderLayout());
@@ -40,23 +40,23 @@ public class CCCreateAnswerPlaceholderPanel extends JPanel {
     myHintTextField.setWrapStyleWord(true);
     myHintTextField.setBorder(BorderFactory.createLineBorder(JBColor.border()));
     myHintTextField.setFont(myAnswerPlaceholderText.getFont());
-    if (myHints.get(myShownHintNumber).equals(ourDefaultHintText)) {
+    if (myHints.get(myShownHintNumber).equals(ourFirstHintText)) {
       myHintTextField.setForeground(UIUtil.getInactiveTextColor());
     }
     myHintTextField.setText(myHints.get(myShownHintNumber));
     myHintTextField.addFocusListener(new FocusAdapter() {
       @Override
       public void focusGained(FocusEvent e) {
-        if (myHintTextField.getText().equals(ourDefaultHintText)) {
+        if (myHintTextField.getText().equals(ourFirstHintText)) {
           myHintTextField.setForeground(UIUtil.getActiveTextColor());
           myHintTextField.setText("");
         }
       }
     });
-    
+
     myAnswerPlaceholderText.grabFocus();
     updateHintNumberLabel();
-    
+
     ((GridLayoutManager)myHintsPanel.getLayout()).setHGap(1);
 
     final DefaultActionGroup addRemoveGroup = new DefaultActionGroup();
@@ -89,13 +89,13 @@ public class CCCreateAnswerPlaceholderPanel extends JPanel {
 
   public List<String> getHints() {
     final String hintText = myHintTextField.getText();
-    if (myShownHintNumber == 0 && hintText.equals(ourDefaultHintText)) {
+    if (myShownHintNumber == 0 && hintText.equals(ourFirstHintText)) {
       myHints.set(myShownHintNumber, "");
     }
     else {
       myHints.set(myShownHintNumber, hintText);
     }
-    
+
     return myHints;
   }