Skip to content
Snippets Groups Projects
Commit 225d9cb1 authored by Letitia Li's avatar Letitia Li
Browse files

Fixed some Pragma bugs

parent d7c86bdc
No related branches found
No related tags found
No related merge requests found
...@@ -121,7 +121,7 @@ public class AvatarBDPragma extends TGCScalableWithoutInternalComponent { ...@@ -121,7 +121,7 @@ public class AvatarBDPragma extends TGCScalableWithoutInternalComponent {
removable = true; removable = true;
name = "Proverif Pragma"; name = "Proverif Pragma";
value = "Proverif List of Pragma"; value = "";
myImageIcon = IconManager.imgic6000; myImageIcon = IconManager.imgic6000;
} }
...@@ -160,6 +160,8 @@ public class AvatarBDPragma extends TGCScalableWithoutInternalComponent { ...@@ -160,6 +160,8 @@ public class AvatarBDPragma extends TGCScalableWithoutInternalComponent {
Color c = g.getColor(); Color c = g.getColor();
int desiredWidth = minWidth; int desiredWidth = minWidth;
desiredWidth = Math.max(desiredWidth, g.getFontMetrics().stringWidth("Property Pragma") + marginX);
for(int i=0; i< values.length; i++) { for(int i=0; i< values.length; i++) {
desiredWidth = Math.max(desiredWidth, g.getFontMetrics().stringWidth(values[i]) + marginX); desiredWidth = Math.max(desiredWidth, g.getFontMetrics().stringWidth(values[i]) + marginX);
} }
......
...@@ -88,7 +88,9 @@ public class JDialogPragma extends javax.swing.JDialog implements ActionListener ...@@ -88,7 +88,9 @@ public class JDialogPragma extends javax.swing.JDialog implements ActionListener
popupMenu.setOpaque(false); popupMenu.setOpaque(false);
popupMenu.setBorder(null); popupMenu.setBorder(null);
popupMenu.add(list = createSuggestionList(position, subWord), BorderLayout.CENTER); popupMenu.add(list = createSuggestionList(position, subWord), BorderLayout.CENTER);
if (list.getModel().getSize() >0){
popupMenu.show(textarea, location.x, textarea.getBaseline(0, 0) + location.y); popupMenu.show(textarea, location.x, textarea.getBaseline(0, 0) + location.y);
}
} }
public void hide() { public void hide() {
...@@ -141,7 +143,7 @@ public class JDialogPragma extends javax.swing.JDialog implements ActionListener ...@@ -141,7 +143,7 @@ public class JDialogPragma extends javax.swing.JDialog implements ActionListener
} }
public void moveUp() { public void moveUp() {
int index = Math.min(list.getSelectedIndex() - 1, 0); int index = Math.max(list.getSelectedIndex() - 1, 0);
selectIndex(index); selectIndex(index);
} }
...@@ -196,7 +198,7 @@ public class JDialogPragma extends javax.swing.JDialog implements ActionListener ...@@ -196,7 +198,7 @@ public class JDialogPragma extends javax.swing.JDialog implements ActionListener
return; return;
} }
final String subWord = text.substring(start, position); final String subWord = text.substring(start, position);
if (subWord.length() < 2) { if (subWord.length() < 1) {
return; return;
} }
suggestion = new SuggestionPanel(textarea, position, subWord, location); suggestion = new SuggestionPanel(textarea, position, subWord, location);
...@@ -258,11 +260,12 @@ public class JDialogPragma extends javax.swing.JDialog implements ActionListener ...@@ -258,11 +260,12 @@ public class JDialogPragma extends javax.swing.JDialog implements ActionListener
suggestion.moveDown(); suggestion.moveDown();
} else if (e.getKeyCode() == KeyEvent.VK_UP && suggestion != null) { } else if (e.getKeyCode() == KeyEvent.VK_UP && suggestion != null) {
suggestion.moveUp(); suggestion.moveUp();
} else if (Character.isLetterOrDigit(e.getKeyChar())) {
showSuggestionLater();
} else if (Character.isWhitespace(e.getKeyChar())) { } else if (Character.isWhitespace(e.getKeyChar())) {
hideSuggestion(); hideSuggestion();
} }
else if (Character.isLetter(e.getKeyChar()) || e.getKeyChar()=='#'){
showSuggestionLater();
}
} }
@Override @Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment