diff --git a/designer/src/com/fr/design/mainframe/FormatBrushAction.java b/designer/src/com/fr/design/mainframe/FormatBrushAction.java index ddc9e29dc..f77bda9eb 100644 --- a/designer/src/com/fr/design/mainframe/FormatBrushAction.java +++ b/designer/src/com/fr/design/mainframe/FormatBrushAction.java @@ -50,7 +50,7 @@ public class FormatBrushAction extends ElementCaseAction { //判断是不是连续区域 //荣国是连续区域,那么这些长方形的长加起来应该等于 if (!isContinueArea()) { - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("Can_not_use_FormatBursh")); + JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("FR-Designer_Can_not_use_FormatBursh")); ePane.setFormatState(DesignerContext.FORMAT_STATE_NULL); ePane.getFormatBrush().setSelected(false); return false; diff --git a/designer_base/src/com/fr/design/gui/autocomplete/AutoCompletePopupWindow.java b/designer_base/src/com/fr/design/gui/autocomplete/AutoCompletePopupWindow.java index c5efadc5c..40b3d7ca2 100644 --- a/designer_base/src/com/fr/design/gui/autocomplete/AutoCompletePopupWindow.java +++ b/designer_base/src/com/fr/design/gui/autocomplete/AutoCompletePopupWindow.java @@ -179,7 +179,7 @@ class AutoCompletePopupWindow extends JWindow implements CaretListener, } else { doAutocomplete(); } - } else if (AutoCompletion.getDebug()) { + } else if (AutoCompletion.isDebug()) { Thread.dumpStack(); } } @@ -300,7 +300,7 @@ class AutoCompletePopupWindow extends JWindow implements CaretListener, */ private void installKeyBindings() { - if (AutoCompletion.getDebug()) { + if (AutoCompletion.isDebug()) { System.out.println("PopupWindow: Installing keybindings"); } @@ -313,7 +313,7 @@ class AutoCompletePopupWindow extends JWindow implements CaretListener, ActionMap am = comp.getActionMap(); replaceAction(im, am, KeyEvent.VK_ESCAPE, escapeKap, oldEscape); - if (AutoCompletion.getDebug() && oldEscape.action == escapeKap.action) { + if (AutoCompletion.isDebug() && oldEscape.action == escapeKap.action) { Thread.dumpStack(); } replaceAction(im, am, KeyEvent.VK_UP, upKap, oldUp); @@ -371,7 +371,7 @@ class AutoCompletePopupWindow extends JWindow implements CaretListener, */ private void positionDescWindow() { - boolean showDescWindow = descWindow != null && ac.getShowDescWindow(); + boolean showDescWindow = descWindow != null && ac.isShowDescWindow(); if (!showDescWindow) { return; } @@ -604,7 +604,7 @@ class AutoCompletePopupWindow extends JWindow implements CaretListener, Rectangle screenBounds = Util.getScreenBoundsForPoint(r.x, r.y); //Dimension screenSize = getToolkit().getScreenSize(); - boolean showDescWindow = descWindow != null && ac.getShowDescWindow(); + boolean showDescWindow = descWindow != null && ac.isShowDescWindow(); int totalH = getHeight(); if (showDescWindow) { totalH = Math.max(totalH, descWindow.getHeight()); @@ -655,7 +655,7 @@ class AutoCompletePopupWindow extends JWindow implements CaretListener, installKeyBindings(); lastLine = ac.getLineOfCaret(); selectFirstItem(); - if (descWindow == null && ac.getShowDescWindow()) { + if (descWindow == null && ac.isShowDescWindow()) { descWindow = createDescriptionWindow(); positionDescWindow(); } @@ -693,7 +693,7 @@ class AutoCompletePopupWindow extends JWindow implements CaretListener, // because of the way child JWindows' visibility is handled - in // some ways it's dependent on the parent, in other ways it's not. if (descWindow != null) { - descWindow.setVisible(visible && ac.getShowDescWindow()); + descWindow.setVisible(visible && ac.isShowDescWindow()); } } @@ -708,7 +708,7 @@ class AutoCompletePopupWindow extends JWindow implements CaretListener, */ private void uninstallKeyBindings() { - if (AutoCompletion.getDebug()) { + if (AutoCompletion.isDebug()) { System.out.println("PopupWindow: Removing keybindings"); } diff --git a/designer_base/src/com/fr/design/gui/autocomplete/AutoCompletion.java b/designer_base/src/com/fr/design/gui/autocomplete/AutoCompletion.java index 122beb1e6..d5447880b 100644 --- a/designer_base/src/com/fr/design/gui/autocomplete/AutoCompletion.java +++ b/designer_base/src/com/fr/design/gui/autocomplete/AutoCompletion.java @@ -8,17 +8,17 @@ */ package com.fr.design.gui.autocomplete; -import java.awt.*; -import java.awt.event.*; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.util.List; import javax.swing.*; import javax.swing.event.CaretEvent; import javax.swing.event.CaretListener; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.text.*; +import java.awt.*; +import java.awt.event.*; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.List; import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; @@ -26,20 +26,20 @@ import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_M /** * Adds auto-completion to a text component. Provides a popup window with a * list of auto-complete choices on a given keystroke, such as Crtrl+Space.
- * + *
* Depending on the {@link CompletionProvider} installed, the following * auto-completion features may be enabled: - * + *
*
null
, then a default renderer is used.
- */
- private ListCellRenderer renderer;
-
- /**
- * The handler to use when an external URL is clicked in the help
- * documentation.
- */
- private ExternalURLHandler externalURLHandler;
-
- /**
- * An optional redirector that converts URL's to some other location before
- * being handed over to externalURLHandler
.
- */
- private static LinkRedirector linkRedirector;
-
- /**
- * Whether the description window should be displayed along with the
- * completion choice window.
- */
- private boolean showDescWindow;
-
- /**
- * Whether auto-complete is enabled.
- */
- private boolean autoCompleteEnabled;
-
- /**
- * Whether the auto-activation of auto-complete (after a delay, after the
- * user types an appropriate character) is enabled.
- */
- private boolean autoActivationEnabled;
-
- /**
- * Whether or not, when there is only a single auto-complete option
- * that matches the text at the current text position, that text should
- * be auto-inserted, instead of the completion window displaying.
- */
- private boolean autoCompleteSingleChoices;
-
- /**
- * Whether parameter assistance is enabled.
- */
- private boolean parameterAssistanceEnabled;
-
- /**
- * A renderer used for {@link Completion}s in the optional parameter
- * choices popup window (displayed when a {@link ParameterizedCompletion}
- * is code-completed). If this isn't set, a default renderer is used.
- */
- private ListCellRenderer paramChoicesRenderer;
-
- /**
- * The keystroke that triggers the completion window.
- */
- private KeyStroke trigger;
-
- /**
- * The previous key in the text component's InputMap
for the
- * trigger key.
- */
- private Object oldTriggerKey;
-
- /**
- * The action previously assigned to {@link #trigger}, so we can reset it
- * if the user disables auto-completion.
- */
- private Action oldTriggerAction;
-
- /**
- * The previous key in the text component's InputMap
for the
- * parameter completion trigger key.
- */
- private Object oldParenKey;
-
- /**
- * The action previously assigned to the parameter completion key, so we
- * can reset it when we uninstall.
- */
- private Action oldParenAction;
-
- /**
- * Listens for events in the parent window that affect the visibility of
- * the popup windows.
- */
- private ParentWindowListener parentWindowListener;
-
- /**
- * Listens for events from the text component that affect the visibility
- * of the popup windows.
- */
- private TextComponentListener textComponentListener;
-
- /**
- * Listens for events in the text component that cause the popup windows
- * to automatically activate.
- */
- private AutoActivationListener autoActivationListener;
-
- /**
- * Listens for LAF changes so the auto-complete windows automatically
- * update themselves accordingly.
- */
- private LookAndFeelChangeListener lafListener;
-
- /**
- * The key used in the input map for the AutoComplete action.
- */
- private static final String PARAM_TRIGGER_KEY = "AutoComplete";
-
- /**
- * Key used in the input map for the parameter completion action.
- */
- private static final String PARAM_COMPLETE_KEY = "AutoCompletion.FunctionStart";
-
- /**
- * Stores how to render auto-completion-specific highlights in text
- * components.
- */
- private static final AutoCompletionStyleContext styleContext =
- new AutoCompletionStyleContext();
-
- /**
- * Whether debug messages should be printed to stdout as AutoCompletion
- * runs.
- */
- private static final boolean DEBUG = initDebug();
-
-
- /**
- * Constructor.
- *
- * @param provider The completion provider. This cannot be
- * null
.
- */
- public AutoCompletion(CompletionProvider provider) {
-
- setChoicesWindowSize(350, 200);
- setDescriptionWindowSize(350, 250);
-
- setCompletionProvider(provider);
- setTriggerKey(getDefaultTriggerKey());
- setAutoCompleteEnabled(true);
- setAutoCompleteSingleChoices(true);
- setAutoActivationEnabled(false);
- setShowDescWindow(false);
- parentWindowListener = new ParentWindowListener();
- textComponentListener = new TextComponentListener();
- autoActivationListener = new AutoActivationListener();
- lafListener = new LookAndFeelChangeListener();
-
- }
-
-
- /**
- * Displays the popup window. Hosting applications can call this method
- * to programmatically begin an auto-completion operation.
- */
- public void doCompletion() {
- refreshPopupWindow();
- }
-
-
- /**
- * Returns the delay between when the user types a character and when the
- * code completion popup should automatically appear (if applicable).
- *
- * @return The delay, in milliseconds.
- * @see #setAutoActivationDelay(int)
- */
- public int getAutoActivationDelay() {
- return autoActivationListener.timer.getDelay();
- }
-
-
- /**
- * Returns whether, if a single auto-complete choice is available, it
- * should be automatically inserted, without displaying the popup menu.
- *
- * @return Whether to auto-complete single choices.
- * @see #setAutoCompleteSingleChoices(boolean)
- */
- public boolean getAutoCompleteSingleChoices() {
- return autoCompleteSingleChoices;
- }
-
-
- /**
- * Returns the completion provider.
- *
- * @return The completion provider.
- */
- public CompletionProvider getCompletionProvider() {
- return provider;
- }
-
-
- /**
- * Returns whether debug is enabled for AutoCompletion.
- *
- * @return Whether debug is enabled.
- */
- static boolean getDebug() {
- return DEBUG;
- }
-
-
- /**
- * Returns the default auto-complete "trigger key" for this OS. For
- * Windows, for example, it is Ctrl+Space.
- *
- * @return The default auto-complete trigger key.
- */
- public static KeyStroke getDefaultTriggerKey() {
- // Default to CTRL, even on Mac, since Ctrl+Space activates Spotlight
- return KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, DEFAULT_MODIFIER);
- }
-
-
- /**
- * Returns the handler to use when an external URL is clicked in the
- * description window.
- *
- * @return The handler.
- * @see #setExternalURLHandler(ExternalURLHandler)
- * @see #getLinkRedirector()
- */
- public ExternalURLHandler getExternalURLHandler() {
- return externalURLHandler;
- }
-
-
- int getLineOfCaret() {
- Document doc = textComponent.getDocument();
- Element root = doc.getDefaultRootElement();
- return root.getElementIndex(textComponent.getCaretPosition());
- }
-
-
- /**
- * Returns the link redirector, if any.
- *
- * @return The link redirector, or null
if none.
- * @see #setLinkRedirector(LinkRedirector)
- */
- public static LinkRedirector getLinkRedirector() {
- return linkRedirector;
- }
-
-
- /**
- * Returns the default list cell renderer used when a completion provider
- * does not supply its own.
- *
- * @return The default list cell renderer.
- * @see #setListCellRenderer(ListCellRenderer)
- */
- public ListCellRenderer getListCellRenderer() {
- return renderer;
- }
-
-
- /**
- * Returns the renderer to use for {@link Completion}s in the optional
- * parameter choices popup window (displayed when a
- * {@link ParameterizedCompletion} is code-completed). If this returns
- * null
, a default renderer is used.
- *
- * @return The renderer to use.
- * @see #setParamChoicesRenderer(ListCellRenderer)
- * @see #isParameterAssistanceEnabled()
- */
- public ListCellRenderer getParamChoicesRenderer() {
- return paramChoicesRenderer;
- }
-
-
- /**
- * Returns the text to replace with in the document. This is a
- * "last-chance" hook for subclasses to make special modifications to the
- * completion text inserted. The default implementation simply returns
- * c.getReplacementText(). You usually will not need to modify
- * this method.
- *
- * @param c The completion being inserted.
- * @param doc The document being modified.
- * @param start The start of the text being replaced.
- * @param len The length of the text being replaced.
- * @return The text to replace with.
- */
- protected String getReplacementText(Completion c, Document doc, int start,
- int len) {
- return c.getReplacementText();
- }
-
-
- /**
- * Returns whether the "description window" should be shown alongside
- * the completion window.
- *
- * @return Whether the description window should be shown.
- * @see #setShowDescWindow(boolean)
- */
- public boolean getShowDescWindow() {
- return showDescWindow;
- }
-
-
- /**
- * Returns the style context describing how auto-completion related
- * highlights in the editor are rendered.
- *
- * @return The style context.
- */
- public static AutoCompletionStyleContext getStyleContext() {
- return styleContext;
- }
-
-
- /**
- * Returns the text component for which auto-completion is enabled.
- *
- * @return The text component, or null
if this
- * {@link AutoCompletion} is not installed on any text component.
- * @see #install(JTextComponent)
- */
- public JTextComponent getTextComponent() {
- return textComponent;
- }
-
-
- /**
- * Returns the orientation of the text component we're installed to.
- *
- * @return The orientation of the text component, or null
if
- * we are not installed on one.
- */
- ComponentOrientation getTextComponentOrientation() {
- return textComponent==null ? null :
- textComponent.getComponentOrientation();
- }
-
-
- /**
- * Returns the "trigger key" used for auto-complete.
- *
- * @return The trigger key.
- * @see #setTriggerKey(KeyStroke)
- */
- public KeyStroke getTriggerKey() {
- return trigger;
- }
-
-
- /**
- * Hides any child windows being displayed by the auto-completion system.
- *
- * @return Whether any windows were visible.
- */
- public boolean hideChildWindows() {
- //return hidePopupWindow() || hideToolTipWindow();
- boolean res = hidePopupWindow();
- res |= hideParameterCompletionPopups();
- return res;
- }
-
-
- /**
- * Hides and disposes of any parameter completion-related popups.
- *
- * @return Whether any such windows were visible (and thus hidden).
- */
- private boolean hideParameterCompletionPopups() {
- if (pcc!=null) {
- pcc.deactivate();
- pcc = null;
- return true;
- }
- return false;
- }
-
-
- /**
- * Hides the popup window, if it is visible.
- *
- * @return Whether the popup window was visible.
- */
- private boolean hidePopupWindow() {
- if (popupWindow!=null) {
- if (popupWindow.isVisible()) {
- popupWindow.setVisible(false);
- return true;
- }
- }
- return false;
- }
-
-
- /**
- * Determines whether debug should be enabled for the AutoCompletion
- * library. This method checks a system property, but takes care of
- * {@link SecurityException}s in case we're in an applet or WebStart.
- *
- * @return Whether debug should be enabled.
- */
- private static final boolean initDebug() {
- boolean debug = false;
- try {
- debug = Boolean.getBoolean("AutoCompletion.debug");
- } catch (SecurityException se) { // We're in an applet or WebStart.
- debug = false;
- }
- return debug;
- }
-
-
- /**
- * Inserts a completion. Any time a code completion event occurs, the
- * actual text insertion happens through this method.
- *
- * @param c A completion to insert. This cannot be null
.
- */
- protected final void insertCompletion(Completion c) {
- insertCompletion(c, false);
- }
-
-
- /**
- * Inserts a completion. Any time a code completion event occurs, the
- * actual text insertion happens through this method.
- *
- * @param c A completion to insert. This cannot be null
.
- * @param typedParamListStartChar Whether the parameterized completion
- * start character was typed (typically '('
).
- */
- protected void insertCompletion(Completion c,
- boolean typedParamListStartChar) {
-
- JTextComponent textComp = getTextComponent();
- String alreadyEntered = c.getAlreadyEntered(textComp);
- hidePopupWindow();
- Caret caret = textComp.getCaret();
-
- int dot = caret.getDot();
- int len = alreadyEntered.length();
- int start = dot-len;
- String replacement = getReplacementText(c, textComp.getDocument(),
- start, len);
-
- caret.setDot(start);
- caret.moveDot(dot);
- textComp.replaceSelection(replacement);
-
- if (isParameterAssistanceEnabled() &&
- (c instanceof ParameterizedCompletion)) {
- ParameterizedCompletion pc = (ParameterizedCompletion)c;
- startParameterizedCompletionAssistance(pc, typedParamListStartChar);
- }
-
- }
-
-
- /**
- * Installs this auto-completion on a text component. If this
- * {@link AutoCompletion} is already installed on another text component,
- * it is uninstalled first.
- *
- * @param c The text component.
- * @see #uninstall()
- */
- public void install(JTextComponent c) {
-
- if (textComponent!=null) {
- uninstall();
- }
-
- this.textComponent = c;
- installTriggerKey(getTriggerKey());
-
- // Install the function completion key, if there is one.
- // NOTE: We cannot do this if the start char is ' ' (e.g. just a space
- // between the function name and parameters) because it overrides
- // RSTA's special space action. It seems KeyStorke.getKeyStroke(' ')
- // hoses ctrl+space, shift+space, etc., even though I think it
- // shouldn't...
- char start = provider.getParameterListStart();
- if (start!=0 && start!=' ') {
- InputMap im = c.getInputMap();
- ActionMap am = c.getActionMap();
- KeyStroke ks = KeyStroke.getKeyStroke(start);
- oldParenKey = im.get(ks);
- im.put(ks, PARAM_COMPLETE_KEY);
- oldParenAction = am.get(PARAM_COMPLETE_KEY);
- am.put(PARAM_COMPLETE_KEY,
- new ParameterizedCompletionStartAction(start));
- }
-
- textComponentListener.addTo(this.textComponent);
- // In case textComponent is already in a window...
- textComponentListener.hierarchyChanged(null);
-
- if (isAutoActivationEnabled()) {
- autoActivationListener.addTo(this.textComponent);
- }
-
- UIManager.addPropertyChangeListener(lafListener);
- updateUI(); // In case there have been changes since we uninstalled
-
- }
-
-
- /**
- * Installs a "trigger key" action onto the current text component.
- *
- * @param ks The keystroke that should trigger the action.
- * @see #uninstallTriggerKey()
- */
- private void installTriggerKey(KeyStroke ks) {
- InputMap im = textComponent.getInputMap();
- oldTriggerKey = im.get(ks);
- im.put(ks, PARAM_TRIGGER_KEY);
- ActionMap am = textComponent.getActionMap();
- oldTriggerAction = am.get(PARAM_TRIGGER_KEY);
- am.put(PARAM_TRIGGER_KEY, new AutoCompleteAction());
- }
-
-
- /**
- * Returns whether auto-activation is enabled (that is, whether the
- * completion popup will automatically appear after a delay when the user
- * types an appropriate character). Note that this parameter will be
- * ignored if auto-completion is disabled.
- *
- * @return Whether auto-activation is enabled.
- * @see #setAutoActivationEnabled(boolean)
- * @see #getAutoActivationDelay()
- * @see #isAutoCompleteEnabled()
- */
- public boolean isAutoActivationEnabled() {
- return autoActivationEnabled;
- }
-
-
- /**
- * Returns whether auto-completion is enabled.
- *
- * @return Whether auto-completion is enabled.
- * @see #setAutoCompleteEnabled(boolean)
- */
- public boolean isAutoCompleteEnabled() {
- return autoCompleteEnabled;
- }
-
-
- /**
- * Returns whether parameter assistance is enabled.
- *
- * @return Whether parameter assistance is enabled.
- * @see #setParameterAssistanceEnabled(boolean)
- */
- public boolean isParameterAssistanceEnabled() {
- return parameterAssistanceEnabled;
- }
-
-
- /**
- * Returns whether the completion popup window is visible.
- *
- * @return Whether the completion popup window is visible.
- */
- public boolean isPopupVisible() {
- return popupWindow!=null && popupWindow.isVisible();
- }
-
-
- /**
- * Refreshes the popup window. First, this method gets the possible
- * completions for the current caret position. If there are none, and the
- * popup is visible, it is hidden. If there are some completions and the
- * popup is hidden, it is made visible and made to display the completions.
- * If there are some completions and the popup is visible, its list is
- * updated to the current set of completions.
- *
- * @return The current line number of the caret.
- */
- protected int refreshPopupWindow() {
-
- // A return value of null => don't suggest completions
- String text = provider.getAlreadyEnteredText(textComponent);
- if (text==null && !isPopupVisible()) {
- return getLineOfCaret();
- }
-
- // If the popup is currently visible, and they type a space (or any
- // character that resets the completion list to "all completions"),
- // the popup window should be hidden instead of being reset to show
- // everything.
- int textLen = text==null ? 0 : text.length();
- if (textLen==0) {
- if (isPopupVisible()) {
- hidePopupWindow();
- return getLineOfCaret();
- }
- }
-
- final Listnull
.
- * @throws IllegalArgumentException If provider
is
- * null
.
- */
- public void setCompletionProvider(CompletionProvider provider) {
- if (provider==null) {
- throw new IllegalArgumentException("provider cannot be null");
- }
- this.provider = provider;
- hidePopupWindow(); // In case new choices should be displayed.
- }
-
-
- /**
- * Sets the size of the completion choices window.
- *
- * @param w The new width.
- * @param h The new height.
- * @see #setDescriptionWindowSize(int, int)
- */
- public void setChoicesWindowSize(int w, int h) {
- preferredChoicesWindowSize = new Dimension(w, h);
- if (popupWindow!=null) {
- popupWindow.setSize(preferredChoicesWindowSize);
- }
- }
-
-
- /**
- * Sets the size of the description window.
- *
- * @param w The new width.
- * @param h The new height.
- * @see #setChoicesWindowSize(int, int)
- */
- public void setDescriptionWindowSize(int w, int h) {
- preferredDescWindowSize = new Dimension(w, h);
- if (popupWindow!=null) {
- popupWindow.setDescriptionWindowSize(preferredDescWindowSize);
- }
- }
-
-
- /**
- * Sets the handler to use when an external URL is clicked in the
- * description window. This handler can perform some action, such as
- * open the URL in a web browser. The default implementation will open
- * the URL in a browser, but only if running in Java 6. If you want
- * browser support for Java 5 and below, or otherwise want to respond to
- * hyperlink clicks, you will have to install your own handler to do so.
- *
- * @param handler The new handler.
- * @see #getExternalURLHandler()
- */
- public void setExternalURLHandler(ExternalURLHandler handler) {
- this.externalURLHandler = handler;
- }
-
-
- /**
- * Sets the redirector for external URL's found in code completion
- * documentation. When a non-local link in completion popups is clicked,
- * this redirector is given the chance to modify the URL fetched and
- * displayed.
- *
- * @param linkRedirector The link redirector, or null
for
- * none.
- * @see #getLinkRedirector()
- */
- public static void setLinkRedirector(LinkRedirector linkRedirector) {
- AutoCompletion.linkRedirector = linkRedirector;
- }
-
-
- /**
- * Sets the default list cell renderer to use when a completion provider
- * does not supply its own.
- *
- * @param renderer The renderer to use. If this is null
,
- * a default renderer is used.
- * @see #getListCellRenderer()
- */
- public void setListCellRenderer(ListCellRenderer renderer) {
- this.renderer = renderer;
- if (popupWindow!=null) {
- popupWindow.setListCellRenderer(renderer);
- hidePopupWindow();
- }
- }
-
-
- /**
- * Sets the renderer to use for {@link Completion}s in the optional
- * parameter choices popup window (displayed when a
- * {@link ParameterizedCompletion} is code-completed). If this isn't set,
- * a default renderer is used.
- *
- * @param r The renderer to use.
- * @see #getParamChoicesRenderer()
- * @see #setParameterAssistanceEnabled(boolean)
- */
- public void setParamChoicesRenderer(ListCellRenderer r) {
- paramChoicesRenderer = r;
- }
-
-
- /**
- * Sets whether parameter assistance is enabled. If parameter assistance
- * is enabled, and a "parameterized" completion (such as a function or
- * method) is inserted, the user will get "assistance" in inserting the
- * parameters in the form of a popup window with documentation and easy
- * tabbing through the arguments (as seen in Eclipse and NetBeans).
- *
- * @param enabled Whether parameter assistance should be enabled.
- * @see #isParameterAssistanceEnabled()
- */
- public void setParameterAssistanceEnabled(boolean enabled) {
- parameterAssistanceEnabled = enabled;
- }
-
-
- /**
- * Sets whether the "description window" should be shown beside the
- * completion window.
- *
- * @param show Whether to show the description window.
- * @see #getShowDescWindow()
- */
- public void setShowDescWindow(boolean show) {
- hidePopupWindow(); // Needed to force it to take effect
- showDescWindow = show;
- }
-
-
- /**
- * Sets the keystroke that should be used to trigger the auto-complete
- * popup window.
- *
- * @param ks The keystroke.
- * @throws IllegalArgumentException If ks
is null
.
- * @see #getTriggerKey()
- */
- public void setTriggerKey(KeyStroke ks) {
- if (ks==null) {
- throw new IllegalArgumentException("trigger key cannot be null");
- }
- if (!ks.equals(trigger)) {
- if (textComponent!=null) {
- // Put old trigger action back.
- uninstallTriggerKey();
- // Grab current action for new trigger and replace it.
- installTriggerKey(ks);
- }
- trigger = ks;
- }
- }
-
-
- /**
- * Displays a "tool tip" detailing the inputs to the function just entered.
- *
- * @param pc The completion.
- * @param typedParamListStartChar Whether the parameterized completion list
- * starting character was typed.
- */
- private void startParameterizedCompletionAssistance(
- ParameterizedCompletion pc, boolean typedParamListStartChar) {
-
- // Get rid of the previous tool tip window, if there is one.
- hideParameterCompletionPopups();
-
- // Don't bother with a tool tip if there are no parameters, but if
- // they typed e.g. the opening '(', make them overtype the ')'.
- if (pc.getParamCount()==0 && !(pc instanceof TemplateCompletion)) {
- CompletionProvider p = pc.getProvider();
- char end = p.getParameterListEnd(); // Might be '\0'
- String text = end=='\0' ? "" : Character.toString(end);
- if (typedParamListStartChar) {
- String template = "${}" + text + "${cursor}";
- textComponent.replaceSelection(Character.toString(p.getParameterListStart()));
- TemplateCompletion tc = new TemplateCompletion(p, null, null, template);
- pc = tc;
- }
- else {
- text = p.getParameterListStart() + text;
- textComponent.replaceSelection(text);
- return;
- }
- }
-
- pcc = new ParameterizedCompletionContext(parentWindow, this, pc);
- pcc.activate();
-
- }
-
-
- /**
- * Uninstalls this auto-completion from its text component. If it is not
- * installed on any text component, nothing happens.
- *
- * @see #install(JTextComponent)
- */
- public void uninstall() {
-
- if (textComponent!=null) {
-
- hidePopupWindow(); // Unregisters listeners, actions, etc.
-
- uninstallTriggerKey();
-
- // Uninstall the function completion key.
- char start = provider.getParameterListStart();
- if (start!=0) {
- KeyStroke ks = KeyStroke.getKeyStroke(start);
- InputMap im = textComponent.getInputMap();
- im.put(ks, oldParenKey);
- ActionMap am = textComponent.getActionMap();
- am.put(PARAM_COMPLETE_KEY, oldParenAction);
- }
-
- textComponentListener.removeFrom(textComponent);
- if (parentWindow!=null) {
- parentWindowListener.removeFrom(parentWindow);
- }
-
- if (isAutoActivationEnabled()) {
- autoActivationListener.removeFrom(textComponent);
- }
-
- UIManager.removePropertyChangeListener(lafListener);
-
- textComponent = null;
- popupWindow = null;
-
- }
-
- }
-
-
- /**
- * Replaces the "trigger key" action with the one that was there
- * before auto-completion was installed.
- *
- * @see #installTriggerKey(KeyStroke)
- */
- private void uninstallTriggerKey() {
- InputMap im = textComponent.getInputMap();
- im.put(trigger, oldTriggerKey);
- ActionMap am = textComponent.getActionMap();
- am.put(PARAM_TRIGGER_KEY, oldTriggerAction);
- }
-
-
- /**
- * Updates the LookAndFeel of the popup window. Applications can call
- * this method as appropriate if they support changing the LookAndFeel
- * at runtime.
- */
- private void updateUI() {
- if (popupWindow!=null) {
- popupWindow.updateUI();
- }
- if (pcc!=null) {
- pcc.updateUI();
- }
- // Will practically always be a JComponent (a JLabel)
- if (paramChoicesRenderer instanceof JComponent) {
- ((JComponent)paramChoicesRenderer).updateUI();
- }
- }
-
-
- /**
- * Listens for events in the text component to auto-activate the code
- * completion popup.
- */
- private class AutoActivationListener extends FocusAdapter
- implements DocumentListener, CaretListener, ActionListener {
-
- private Timer timer;
- private boolean justInserted;
-
- public AutoActivationListener() {
- timer = new Timer(200, this);
- timer.setRepeats(false);
- }
-
- public void actionPerformed(ActionEvent e) {
- doCompletion();
- }
-
- public void addTo(JTextComponent tc) {
- tc.addFocusListener(this);
- tc.getDocument().addDocumentListener(this);
- tc.addCaretListener(this);
- }
-
- public void caretUpdate(CaretEvent e) {
- if (justInserted) {
- justInserted = false;
- }
- else {
- timer.stop();
- }
- }
-
- public void changedUpdate(DocumentEvent e) {
- // Ignore
- }
-
- @Override
- public void focusLost(FocusEvent e) {
- timer.stop();
- //hideChildWindows(); Other listener will do this
- }
-
- public void insertUpdate(DocumentEvent e) {
- justInserted = false;
- if (isAutoCompleteEnabled() && isAutoActivationEnabled() &&
- e.getLength()==1) {
- if (provider.isAutoActivateOkay(textComponent)) {
- timer.restart();
- justInserted = true;
- }
- else {
- timer.stop();
- }
- }
- else {
- timer.stop();
- }
- }
-
- public void removeFrom(JTextComponent tc) {
- tc.removeFocusListener(this);
- tc.getDocument().removeDocumentListener(this);
- tc.removeCaretListener(this);
- timer.stop();
- justInserted = false;
- }
-
- public void removeUpdate(DocumentEvent e) {
- timer.stop();
- }
-
- }
-
-
- /**
- * The Action
that displays the popup window if
- * auto-completion is enabled.
- */
- private class AutoCompleteAction extends AbstractAction {
-
- public void actionPerformed(ActionEvent e) {
- if (isAutoCompleteEnabled()) {
- refreshPopupWindow();
- }
- else if (oldTriggerAction!=null) {
- oldTriggerAction.actionPerformed(e);
- }
- }
-
- }
-
-
- /**
- * Listens for LookAndFeel changes and updates the various popup windows
- * involved in auto-completion accordingly.
- */
- private class LookAndFeelChangeListener implements PropertyChangeListener {
-
- public void propertyChange(PropertyChangeEvent e) {
- String name = e.getPropertyName();
- if ("lookAndFeel".equals(name)) {
- updateUI();
- }
- }
-
- }
-
-
- /**
- * Action that starts a parameterized completion, e.g. after '(' is
- * typed.
- */
- private class ParameterizedCompletionStartAction extends AbstractAction {
-
- private String start;
-
- public ParameterizedCompletionStartAction(char ch) {
- this.start = Character.toString(ch);
- }
-
- public void actionPerformed(ActionEvent e) {
-
- // Prevents keystrokes from messing up
- boolean wasVisible = hidePopupWindow();
-
- // Only proceed if they were selecting a completion
- if (!wasVisible || !isParameterAssistanceEnabled()) {
- textComponent.replaceSelection(start);
- return;
- }
-
- Completion c = popupWindow.getSelection();
- if (c instanceof ParameterizedCompletion) { // Should always be true
- // Fixes capitalization of the entered text.
- insertCompletion(c, true);
- }
-
- }
-
- }
-
-
- /**
- * Listens for events in the parent window of the text component with
- * auto-completion enabled.
- */
- private class ParentWindowListener extends ComponentAdapter
- implements WindowFocusListener {
-
- public void addTo(Window w) {
- w.addComponentListener(this);
- w.addWindowFocusListener(this);
- }
-
- @Override
- public void componentHidden(ComponentEvent e) {
- hideChildWindows();
- }
-
- @Override
- public void componentMoved(ComponentEvent e) {
- hideChildWindows();
- }
-
- @Override
- public void componentResized(ComponentEvent e) {
- hideChildWindows();
- }
-
- public void removeFrom(Window w) {
- w.removeComponentListener(this);
- w.removeWindowFocusListener(this);
- }
-
- public void windowGainedFocus(WindowEvent e) {
- }
-
- public void windowLostFocus(WindowEvent e) {
- hideChildWindows();
- }
-
- }
-
-
- /**
- * Listens for events from the text component we're installed on.
- */
- private class TextComponentListener extends FocusAdapter
- implements HierarchyListener {
-
- void addTo(JTextComponent tc) {
- tc.addFocusListener(this);
- tc.addHierarchyListener(this);
- }
-
- /**
- * Hide the auto-completion windows when the text component loses
- * focus.
- */
- @Override
- public void focusLost(FocusEvent e) {
- hideChildWindows();
- }
-
- /**
- * Called when the component hierarchy for our text component changes.
- * When the text component is added to a new {@link Window}, this
- * method registers listeners on that Window
.
- *
- * @param e The event.
- */
- public void hierarchyChanged(HierarchyEvent e) {
-
- // NOTE: e many be null as we call this method at other times.
- //System.out.println("Hierarchy changed! " + e);
-
- Window oldParentWindow = parentWindow;
- parentWindow = SwingUtilities.getWindowAncestor(textComponent);
- if (parentWindow!=oldParentWindow) {
- if (oldParentWindow!=null) {
- parentWindowListener.removeFrom(oldParentWindow);
- }
- if (parentWindow!=null) {
- parentWindowListener.addTo(parentWindow);
- }
- }
-
- }
-
- public void removeFrom(JTextComponent tc) {
- tc.removeFocusListener(this);
- tc.removeHierarchyListener(this);
- }
-
- }
+ /**
+ * The text component we're providing completion for.
+ */
+ private JTextComponent textComponent;
+
+ /**
+ * The parent window of {@link #textComponent}.
+ */
+ private Window parentWindow;
+
+ /**
+ * The popup window containing completion choices.
+ */
+ private AutoCompletePopupWindow popupWindow;
+
+ /**
+ * The preferred size of the completion choices window. This field exists
+ * because the user will likely set the preferred size of the window
+ * before it is actually created.
+ */
+ private Dimension preferredChoicesWindowSize;
+
+ /**
+ * The preferred size of the optional description window. This field
+ * only exists because the user may (and usually will) set the size of
+ * the description window before it exists (it must be parented to a
+ * Window).
+ */
+ private Dimension preferredDescWindowSize;
+
+ /**
+ * Manages any parameterized completions that are inserted.
+ */
+ private ParameterizedCompletionContext pcc;
+
+ /**
+ * Provides the completion options relevant to the current caret position.
+ */
+ private CompletionProvider provider;
+
+ /**
+ * The renderer to use for the completion choices. If this is
+ * null
, then a default renderer is used.
+ */
+ private ListCellRenderer renderer;
+
+ /**
+ * The handler to use when an external URL is clicked in the help
+ * documentation.
+ */
+ private ExternalURLHandler externalURLHandler;
+
+ /**
+ * An optional redirector that converts URL's to some other location before
+ * being handed over to externalURLHandler
.
+ */
+ private static LinkRedirector linkRedirector;
+
+ /**
+ * Whether the description window should be displayed along with the
+ * completion choice window.
+ */
+ private boolean showDescWindow;
+
+ /**
+ * Whether auto-complete is enabled.
+ */
+ private boolean autoCompleteEnabled;
+
+ /**
+ * Whether the auto-activation of auto-complete (after a delay, after the
+ * user types an appropriate character) is enabled.
+ */
+ private boolean autoActivationEnabled;
+
+ /**
+ * Whether or not, when there is only a single auto-complete option
+ * that matches the text at the current text position, that text should
+ * be auto-inserted, instead of the completion window displaying.
+ */
+ private boolean autoCompleteSingleChoices;
+
+ /**
+ * Whether parameter assistance is enabled.
+ */
+ private boolean parameterAssistanceEnabled;
+
+ /**
+ * A renderer used for {@link Completion}s in the optional parameter
+ * choices popup window (displayed when a {@link ParameterizedCompletion}
+ * is code-completed). If this isn't set, a default renderer is used.
+ */
+ private ListCellRenderer paramChoicesRenderer;
+
+ /**
+ * The keystroke that triggers the completion window.
+ */
+ private KeyStroke trigger;
+
+ /**
+ * The previous key in the text component's InputMap
for the
+ * trigger key.
+ */
+ private Object oldTriggerKey;
+
+ /**
+ * The action previously assigned to {@link #trigger}, so we can reset it
+ * if the user disables auto-completion.
+ */
+ private Action oldTriggerAction;
+
+ /**
+ * The previous key in the text component's InputMap
for the
+ * parameter completion trigger key.
+ */
+ private Object oldParenKey;
+
+ /**
+ * The action previously assigned to the parameter completion key, so we
+ * can reset it when we uninstall.
+ */
+ private Action oldParenAction;
+
+ /**
+ * Listens for events in the parent window that affect the visibility of
+ * the popup windows.
+ */
+ private ParentWindowListener parentWindowListener;
+
+ /**
+ * Listens for events from the text component that affect the visibility
+ * of the popup windows.
+ */
+ private TextComponentListener textComponentListener;
+
+ /**
+ * Listens for events in the text component that cause the popup windows
+ * to automatically activate.
+ */
+ private AutoActivationListener autoActivationListener;
+
+ /**
+ * Listens for LAF changes so the auto-complete windows automatically
+ * update themselves accordingly.
+ */
+ private LookAndFeelChangeListener lafListener;
+
+ /**
+ * The key used in the input map for the AutoComplete action.
+ */
+ private static final String PARAM_TRIGGER_KEY = "AutoComplete";
+
+ /**
+ * Key used in the input map for the parameter completion action.
+ */
+ private static final String PARAM_COMPLETE_KEY = "AutoCompletion.FunctionStart";
+
+ /**
+ * Stores how to render auto-completion-specific highlights in text
+ * components.
+ */
+ private static final AutoCompletionStyleContext STYLE_CONTEXT =
+ new AutoCompletionStyleContext();
+
+ /**
+ * Whether debug messages should be printed to stdout as AutoCompletion
+ * runs.
+ */
+ private static final boolean DEBUG = initDebug();
+
+
+ /**
+ * Constructor.
+ *
+ * @param provider The completion provider. This cannot be
+ * null
.
+ */
+ public AutoCompletion(CompletionProvider provider) {
+
+ setChoicesWindowSize(350, 200);
+ setDescriptionWindowSize(350, 250);
+
+ setCompletionProvider(provider);
+ setTriggerKey(getDefaultTriggerKey());
+ setAutoCompleteEnabled(true);
+ setAutoCompleteSingleChoices(true);
+ setAutoActivationEnabled(false);
+ setShowDescWindow(false);
+ parentWindowListener = new ParentWindowListener();
+ textComponentListener = new TextComponentListener();
+ autoActivationListener = new AutoActivationListener();
+ lafListener = new LookAndFeelChangeListener();
+
+ }
+
+
+ /**
+ * Displays the popup window. Hosting applications can call this method
+ * to programmatically begin an auto-completion operation.
+ */
+ public void doCompletion() {
+ refreshPopupWindow();
+ }
+
+
+ /**
+ * Returns the delay between when the user types a character and when the
+ * code completion popup should automatically appear (if applicable).
+ *
+ * @return The delay, in milliseconds.
+ * @see #setAutoActivationDelay(int)
+ */
+ public int getAutoActivationDelay() {
+ return autoActivationListener.timer.getDelay();
+ }
+
+
+ /**
+ * Returns whether, if a single auto-complete choice is available, it
+ * should be automatically inserted, without displaying the popup menu.
+ *
+ * @return Whether to auto-complete single choices.
+ * @see #setAutoCompleteSingleChoices(boolean)
+ */
+ public boolean getAutoCompleteSingleChoices() {
+ return autoCompleteSingleChoices;
+ }
+
+
+ /**
+ * Returns the completion provider.
+ *
+ * @return The completion provider.
+ */
+ public CompletionProvider getCompletionProvider() {
+ return provider;
+ }
+
+
+ /**
+ * Returns whether debug is enabled for AutoCompletion.
+ *
+ * @return Whether debug is enabled.
+ */
+ static boolean isDebug() {
+ return DEBUG;
+ }
+
+
+ /**
+ * Returns the default auto-complete "trigger key" for this OS. For
+ * Windows, for example, it is Ctrl+Space.
+ *
+ * @return The default auto-complete trigger key.
+ */
+ public static KeyStroke getDefaultTriggerKey() {
+ // Default to CTRL, even on Mac, since Ctrl+Space activates Spotlight
+ return KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, DEFAULT_MODIFIER);
+ }
+
+
+ /**
+ * Returns the handler to use when an external URL is clicked in the
+ * description window.
+ *
+ * @return The handler.
+ * @see #setExternalURLHandler(ExternalURLHandler)
+ * @see #getLinkRedirector()
+ */
+ public ExternalURLHandler getExternalURLHandler() {
+ return externalURLHandler;
+ }
+
+
+ int getLineOfCaret() {
+ Document doc = textComponent.getDocument();
+ Element root = doc.getDefaultRootElement();
+ return root.getElementIndex(textComponent.getCaretPosition());
+ }
+
+
+ /**
+ * Returns the link redirector, if any.
+ *
+ * @return The link redirector, or null
if none.
+ * @see #setLinkRedirector(LinkRedirector)
+ */
+ public static LinkRedirector getLinkRedirector() {
+ return linkRedirector;
+ }
+
+
+ /**
+ * Returns the default list cell renderer used when a completion provider
+ * does not supply its own.
+ *
+ * @return The default list cell renderer.
+ * @see #setListCellRenderer(ListCellRenderer)
+ */
+ public ListCellRenderer getListCellRenderer() {
+ return renderer;
+ }
+
+
+ /**
+ * Returns the renderer to use for {@link Completion}s in the optional
+ * parameter choices popup window (displayed when a
+ * {@link ParameterizedCompletion} is code-completed). If this returns
+ * null
, a default renderer is used.
+ *
+ * @return The renderer to use.
+ * @see #setParamChoicesRenderer(ListCellRenderer)
+ * @see #isParameterAssistanceEnabled()
+ */
+ public ListCellRenderer getParamChoicesRenderer() {
+ return paramChoicesRenderer;
+ }
+
+
+ /**
+ * Returns the text to replace with in the document. This is a
+ * "last-chance" hook for subclasses to make special modifications to the
+ * completion text inserted. The default implementation simply returns
+ * c.getReplacementText(). You usually will not need to modify
+ * this method.
+ *
+ * @param c The completion being inserted.
+ * @param doc The document being modified.
+ * @param start The start of the text being replaced.
+ * @param len The length of the text being replaced.
+ * @return The text to replace with.
+ */
+ protected String getReplacementText(Completion c, Document doc, int start,
+ int len) {
+ return c.getReplacementText();
+ }
+
+
+ /**
+ * Returns whether the "description window" should be shown alongside
+ * the completion window.
+ *
+ * @return Whether the description window should be shown.
+ * @see #setShowDescWindow(boolean)
+ */
+ public boolean isShowDescWindow() {
+ return showDescWindow;
+ }
+
+
+ /**
+ * Returns the style context describing how auto-completion related
+ * highlights in the editor are rendered.
+ *
+ * @return The style context.
+ */
+ public static AutoCompletionStyleContext getStyleContext() {
+ return STYLE_CONTEXT;
+ }
+
+
+ /**
+ * Returns the text component for which auto-completion is enabled.
+ *
+ * @return The text component, or null
if this
+ * {@link AutoCompletion} is not installed on any text component.
+ * @see #install(JTextComponent)
+ */
+ public JTextComponent getTextComponent() {
+ return textComponent;
+ }
+
+
+ /**
+ * Returns the orientation of the text component we're installed to.
+ *
+ * @return The orientation of the text component, or null
if
+ * we are not installed on one.
+ */
+ ComponentOrientation getTextComponentOrientation() {
+ return textComponent == null ? null :
+ textComponent.getComponentOrientation();
+ }
+
+
+ /**
+ * Returns the "trigger key" used for auto-complete.
+ *
+ * @return The trigger key.
+ * @see #setTriggerKey(KeyStroke)
+ */
+ public KeyStroke getTriggerKey() {
+ return trigger;
+ }
+
+
+ /**
+ * Hides any child windows being displayed by the auto-completion system.
+ *
+ * @return Whether any windows were visible.
+ */
+ public boolean hideChildWindows() {
+ //return hidePopupWindow() || hideToolTipWindow();
+ boolean res = hidePopupWindow();
+ res |= hideParameterCompletionPopups();
+ return res;
+ }
+
+
+ /**
+ * Hides and disposes of any parameter completion-related popups.
+ *
+ * @return Whether any such windows were visible (and thus hidden).
+ */
+ private boolean hideParameterCompletionPopups() {
+ if (pcc != null) {
+ pcc.deactivate();
+ pcc = null;
+ return true;
+ }
+ return false;
+ }
+
+
+ /**
+ * Hides the popup window, if it is visible.
+ *
+ * @return Whether the popup window was visible.
+ */
+ private boolean hidePopupWindow() {
+ if (popupWindow != null) {
+ if (popupWindow.isVisible()) {
+ popupWindow.setVisible(false);
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ * Determines whether debug should be enabled for the AutoCompletion
+ * library. This method checks a system property, but takes care of
+ * {@link SecurityException}s in case we're in an applet or WebStart.
+ *
+ * @return Whether debug should be enabled.
+ */
+ private static final boolean initDebug() {
+ boolean debug = false;
+ try {
+ debug = Boolean.getBoolean("AutoCompletion.debug");
+ } catch (SecurityException se) { // We're in an applet or WebStart.
+ debug = false;
+ }
+ return debug;
+ }
+
+
+ /**
+ * Inserts a completion. Any time a code completion event occurs, the
+ * actual text insertion happens through this method.
+ *
+ * @param c A completion to insert. This cannot be null
.
+ */
+ protected final void insertCompletion(Completion c) {
+ insertCompletion(c, false);
+ }
+
+
+ /**
+ * Inserts a completion. Any time a code completion event occurs, the
+ * actual text insertion happens through this method.
+ *
+ * @param c A completion to insert. This cannot be null
.
+ * @param typedParamListStartChar Whether the parameterized completion
+ * start character was typed (typically '('
).
+ */
+ protected void insertCompletion(Completion c,
+ boolean typedParamListStartChar) {
+
+ JTextComponent textComp = getTextComponent();
+ String alreadyEntered = c.getAlreadyEntered(textComp);
+ hidePopupWindow();
+ Caret caret = textComp.getCaret();
+
+ int dot = caret.getDot();
+ int len = alreadyEntered.length();
+ int start = dot - len;
+ String replacement = getReplacementText(c, textComp.getDocument(),
+ start, len);
+
+ caret.setDot(start);
+ caret.moveDot(dot);
+ textComp.replaceSelection(replacement);
+
+ if (isParameterAssistanceEnabled() &&
+ (c instanceof ParameterizedCompletion)) {
+ ParameterizedCompletion pc = (ParameterizedCompletion) c;
+ startParameterizedCompletionAssistance(pc, typedParamListStartChar);
+ }
+
+ }
+
+
+ /**
+ * Installs this auto-completion on a text component. If this
+ * {@link AutoCompletion} is already installed on another text component,
+ * it is uninstalled first.
+ *
+ * @param c The text component.
+ * @see #uninstall()
+ */
+ public void install(JTextComponent c) {
+
+ if (textComponent != null) {
+ uninstall();
+ }
+
+ this.textComponent = c;
+ installTriggerKey(getTriggerKey());
+
+ // Install the function completion key, if there is one.
+ // NOTE: We cannot do this if the start char is ' ' (e.g. just a space
+ // between the function name and parameters) because it overrides
+ // RSTA's special space action. It seems KeyStorke.getKeyStroke(' ')
+ // hoses ctrl+space, shift+space, etc., even though I think it
+ // shouldn't...
+ char start = provider.getParameterListStart();
+ if (start != 0 && start != ' ') {
+ InputMap im = c.getInputMap();
+ ActionMap am = c.getActionMap();
+ KeyStroke ks = KeyStroke.getKeyStroke(start);
+ oldParenKey = im.get(ks);
+ im.put(ks, PARAM_COMPLETE_KEY);
+ oldParenAction = am.get(PARAM_COMPLETE_KEY);
+ am.put(PARAM_COMPLETE_KEY,
+ new ParameterizedCompletionStartAction(start));
+ }
+
+ textComponentListener.addTo(this.textComponent);
+ // In case textComponent is already in a window...
+ textComponentListener.hierarchyChanged(null);
+
+ if (isAutoActivationEnabled()) {
+ autoActivationListener.addTo(this.textComponent);
+ }
+
+ UIManager.addPropertyChangeListener(lafListener);
+ updateUI(); // In case there have been changes since we uninstalled
+
+ }
+
+
+ /**
+ * Installs a "trigger key" action onto the current text component.
+ *
+ * @param ks The keystroke that should trigger the action.
+ * @see #uninstallTriggerKey()
+ */
+ private void installTriggerKey(KeyStroke ks) {
+ InputMap im = textComponent.getInputMap();
+ oldTriggerKey = im.get(ks);
+ im.put(ks, PARAM_TRIGGER_KEY);
+ ActionMap am = textComponent.getActionMap();
+ oldTriggerAction = am.get(PARAM_TRIGGER_KEY);
+ am.put(PARAM_TRIGGER_KEY, new AutoCompleteAction());
+ }
+
+
+ /**
+ * Returns whether auto-activation is enabled (that is, whether the
+ * completion popup will automatically appear after a delay when the user
+ * types an appropriate character). Note that this parameter will be
+ * ignored if auto-completion is disabled.
+ *
+ * @return Whether auto-activation is enabled.
+ * @see #setAutoActivationEnabled(boolean)
+ * @see #getAutoActivationDelay()
+ * @see #isAutoCompleteEnabled()
+ */
+ public boolean isAutoActivationEnabled() {
+ return autoActivationEnabled;
+ }
+
+
+ /**
+ * Returns whether auto-completion is enabled.
+ *
+ * @return Whether auto-completion is enabled.
+ * @see #setAutoCompleteEnabled(boolean)
+ */
+ public boolean isAutoCompleteEnabled() {
+ return autoCompleteEnabled;
+ }
+
+
+ /**
+ * Returns whether parameter assistance is enabled.
+ *
+ * @return Whether parameter assistance is enabled.
+ * @see #setParameterAssistanceEnabled(boolean)
+ */
+ public boolean isParameterAssistanceEnabled() {
+ return parameterAssistanceEnabled;
+ }
+
+
+ /**
+ * Returns whether the completion popup window is visible.
+ *
+ * @return Whether the completion popup window is visible.
+ */
+ public boolean isPopupVisible() {
+ return popupWindow != null && popupWindow.isVisible();
+ }
+
+
+ /**
+ * Refreshes the popup window. First, this method gets the possible
+ * completions for the current caret position. If there are none, and the
+ * popup is visible, it is hidden. If there are some completions and the
+ * popup is hidden, it is made visible and made to display the completions.
+ * If there are some completions and the popup is visible, its list is
+ * updated to the current set of completions.
+ *
+ * @return The current line number of the caret.
+ */
+ protected int refreshPopupWindow() {
+ // A return value of null => don't suggest completions
+ String text = provider.getAlreadyEnteredText(textComponent);
+ if (text == null && !isPopupVisible()) {
+ return getLineOfCaret();
+ }
+ // If the popup is currently visible, and they type a space (or any
+ // character that resets the completion list to "all completions"),
+ // the popup window should be hidden instead of being reset to show
+ // everything.
+ int textLen = text == null ? 0 : text.length();
+ if (textLen == 0 && isPopupVisible()) {
+ hidePopupWindow();
+ return getLineOfCaret();
+ }
+ final Listnull
.
+ * @throws IllegalArgumentException If provider
is
+ * null
.
+ */
+ public void setCompletionProvider(CompletionProvider provider) {
+ if (provider == null) {
+ throw new IllegalArgumentException("provider cannot be null");
+ }
+ this.provider = provider;
+ hidePopupWindow(); // In case new choices should be displayed.
+ }
+
+
+ /**
+ * Sets the size of the completion choices window.
+ *
+ * @param w The new width.
+ * @param h The new height.
+ * @see #setDescriptionWindowSize(int, int)
+ */
+ public void setChoicesWindowSize(int w, int h) {
+ preferredChoicesWindowSize = new Dimension(w, h);
+ if (popupWindow != null) {
+ popupWindow.setSize(preferredChoicesWindowSize);
+ }
+ }
+
+
+ /**
+ * Sets the size of the description window.
+ *
+ * @param w The new width.
+ * @param h The new height.
+ * @see #setChoicesWindowSize(int, int)
+ */
+ public void setDescriptionWindowSize(int w, int h) {
+ preferredDescWindowSize = new Dimension(w, h);
+ if (popupWindow != null) {
+ popupWindow.setDescriptionWindowSize(preferredDescWindowSize);
+ }
+ }
+
+
+ /**
+ * Sets the handler to use when an external URL is clicked in the
+ * description window. This handler can perform some action, such as
+ * open the URL in a web browser. The default implementation will open
+ * the URL in a browser, but only if running in Java 6. If you want
+ * browser support for Java 5 and below, or otherwise want to respond to
+ * hyperlink clicks, you will have to install your own handler to do so.
+ *
+ * @param handler The new handler.
+ * @see #getExternalURLHandler()
+ */
+ public void setExternalURLHandler(ExternalURLHandler handler) {
+ this.externalURLHandler = handler;
+ }
+
+
+ /**
+ * Sets the redirector for external URL's found in code completion
+ * documentation. When a non-local link in completion popups is clicked,
+ * this redirector is given the chance to modify the URL fetched and
+ * displayed.
+ *
+ * @param linkRedirector The link redirector, or null
for
+ * none.
+ * @see #getLinkRedirector()
+ */
+ public static void setLinkRedirector(LinkRedirector linkRedirector) {
+ AutoCompletion.linkRedirector = linkRedirector;
+ }
+
+
+ /**
+ * Sets the default list cell renderer to use when a completion provider
+ * does not supply its own.
+ *
+ * @param renderer The renderer to use. If this is null
,
+ * a default renderer is used.
+ * @see #getListCellRenderer()
+ */
+ public void setListCellRenderer(ListCellRenderer renderer) {
+ this.renderer = renderer;
+ if (popupWindow != null) {
+ popupWindow.setListCellRenderer(renderer);
+ hidePopupWindow();
+ }
+ }
+
+
+ /**
+ * Sets the renderer to use for {@link Completion}s in the optional
+ * parameter choices popup window (displayed when a
+ * {@link ParameterizedCompletion} is code-completed). If this isn't set,
+ * a default renderer is used.
+ *
+ * @param r The renderer to use.
+ * @see #getParamChoicesRenderer()
+ * @see #setParameterAssistanceEnabled(boolean)
+ */
+ public void setParamChoicesRenderer(ListCellRenderer r) {
+ paramChoicesRenderer = r;
+ }
+
+
+ /**
+ * Sets whether parameter assistance is enabled. If parameter assistance
+ * is enabled, and a "parameterized" completion (such as a function or
+ * method) is inserted, the user will get "assistance" in inserting the
+ * parameters in the form of a popup window with documentation and easy
+ * tabbing through the arguments (as seen in Eclipse and NetBeans).
+ *
+ * @param enabled Whether parameter assistance should be enabled.
+ * @see #isParameterAssistanceEnabled()
+ */
+ public void setParameterAssistanceEnabled(boolean enabled) {
+ parameterAssistanceEnabled = enabled;
+ }
+
+
+ /**
+ * Sets whether the "description window" should be shown beside the
+ * completion window.
+ *
+ * @param show Whether to show the description window.
+ * @see #isShowDescWindow()
+ */
+ public void setShowDescWindow(boolean show) {
+ hidePopupWindow(); // Needed to force it to take effect
+ showDescWindow = show;
+ }
+
+
+ /**
+ * Sets the keystroke that should be used to trigger the auto-complete
+ * popup window.
+ *
+ * @param ks The keystroke.
+ * @throws IllegalArgumentException If ks
is null
.
+ * @see #getTriggerKey()
+ */
+ public void setTriggerKey(KeyStroke ks) {
+ if (ks == null) {
+ throw new IllegalArgumentException("trigger key cannot be null");
+ }
+ if (!ks.equals(trigger)) {
+ if (textComponent != null) {
+ // Put old trigger action back.
+ uninstallTriggerKey();
+ // Grab current action for new trigger and replace it.
+ installTriggerKey(ks);
+ }
+ trigger = ks;
+ }
+ }
+
+
+ /**
+ * Displays a "tool tip" detailing the inputs to the function just entered.
+ *
+ * @param pc The completion.
+ * @param typedParamListStartChar Whether the parameterized completion list
+ * starting character was typed.
+ */
+ private void startParameterizedCompletionAssistance(
+ ParameterizedCompletion pc, boolean typedParamListStartChar) {
+
+ // Get rid of the previous tool tip window, if there is one.
+ hideParameterCompletionPopups();
+
+ // Don't bother with a tool tip if there are no parameters, but if
+ // they typed e.g. the opening '(', make them overtype the ')'.
+ if (pc.getParamCount() == 0 && !(pc instanceof TemplateCompletion)) {
+ CompletionProvider p = pc.getProvider();
+ char end = p.getParameterListEnd(); // Might be '\0'
+ String text = end == '\0' ? "" : Character.toString(end);
+ if (typedParamListStartChar) {
+ String template = "${}" + text + "${cursor}";
+ textComponent.replaceSelection(Character.toString(p.getParameterListStart()));
+ TemplateCompletion tc = new TemplateCompletion(p, null, null, template);
+ pc = tc;
+ } else {
+ text = p.getParameterListStart() + text;
+ textComponent.replaceSelection(text);
+ return;
+ }
+ }
+
+ pcc = new ParameterizedCompletionContext(parentWindow, this, pc);
+ pcc.activate();
+
+ }
+
+
+ /**
+ * Uninstalls this auto-completion from its text component. If it is not
+ * installed on any text component, nothing happens.
+ *
+ * @see #install(JTextComponent)
+ */
+ public void uninstall() {
+
+ if (textComponent != null) {
+
+ hidePopupWindow(); // Unregisters listeners, actions, etc.
+
+ uninstallTriggerKey();
+
+ // Uninstall the function completion key.
+ char start = provider.getParameterListStart();
+ if (start != 0) {
+ KeyStroke ks = KeyStroke.getKeyStroke(start);
+ InputMap im = textComponent.getInputMap();
+ im.put(ks, oldParenKey);
+ ActionMap am = textComponent.getActionMap();
+ am.put(PARAM_COMPLETE_KEY, oldParenAction);
+ }
+
+ textComponentListener.removeFrom(textComponent);
+ if (parentWindow != null) {
+ parentWindowListener.removeFrom(parentWindow);
+ }
+
+ if (isAutoActivationEnabled()) {
+ autoActivationListener.removeFrom(textComponent);
+ }
+
+ UIManager.removePropertyChangeListener(lafListener);
+
+ textComponent = null;
+ popupWindow = null;
+
+ }
+
+ }
+
+
+ /**
+ * Replaces the "trigger key" action with the one that was there
+ * before auto-completion was installed.
+ *
+ * @see #installTriggerKey(KeyStroke)
+ */
+ private void uninstallTriggerKey() {
+ InputMap im = textComponent.getInputMap();
+ im.put(trigger, oldTriggerKey);
+ ActionMap am = textComponent.getActionMap();
+ am.put(PARAM_TRIGGER_KEY, oldTriggerAction);
+ }
+
+
+ /**
+ * Updates the LookAndFeel of the popup window. Applications can call
+ * this method as appropriate if they support changing the LookAndFeel
+ * at runtime.
+ */
+ private void updateUI() {
+ if (popupWindow != null) {
+ popupWindow.updateUI();
+ }
+ if (pcc != null) {
+ pcc.updateUI();
+ }
+ // Will practically always be a JComponent (a JLabel)
+ if (paramChoicesRenderer instanceof JComponent) {
+ ((JComponent) paramChoicesRenderer).updateUI();
+ }
+ }
+
+
+ /**
+ * Listens for events in the text component to auto-activate the code
+ * completion popup.
+ */
+ private class AutoActivationListener extends FocusAdapter
+ implements DocumentListener, CaretListener, ActionListener {
+
+ private Timer timer;
+ private boolean justInserted;
+
+ public AutoActivationListener() {
+ timer = new Timer(200, this);
+ timer.setRepeats(false);
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ doCompletion();
+ }
+
+ public void addTo(JTextComponent tc) {
+ tc.addFocusListener(this);
+ tc.getDocument().addDocumentListener(this);
+ tc.addCaretListener(this);
+ }
+
+ public void caretUpdate(CaretEvent e) {
+ if (justInserted) {
+ justInserted = false;
+ } else {
+ timer.stop();
+ }
+ }
+
+ public void changedUpdate(DocumentEvent e) {
+ // Ignore
+ }
+
+ @Override
+ public void focusLost(FocusEvent e) {
+ timer.stop();
+ //hideChildWindows(); Other listener will do this
+ }
+
+ public void insertUpdate(DocumentEvent e) {
+ justInserted = false;
+ if (isAutoCompleteEnabled() && isAutoActivationEnabled() &&
+ e.getLength() == 1) {
+ if (provider.isAutoActivateOkay(textComponent)) {
+ timer.restart();
+ justInserted = true;
+ } else {
+ timer.stop();
+ }
+ } else {
+ timer.stop();
+ }
+ }
+
+ public void removeFrom(JTextComponent tc) {
+ tc.removeFocusListener(this);
+ tc.getDocument().removeDocumentListener(this);
+ tc.removeCaretListener(this);
+ timer.stop();
+ justInserted = false;
+ }
+
+ public void removeUpdate(DocumentEvent e) {
+ timer.stop();
+ }
+
+ }
+
+
+ /**
+ * The Action
that displays the popup window if
+ * auto-completion is enabled.
+ */
+ private class AutoCompleteAction extends AbstractAction {
+
+ public void actionPerformed(ActionEvent e) {
+ if (isAutoCompleteEnabled()) {
+ refreshPopupWindow();
+ } else if (oldTriggerAction != null) {
+ oldTriggerAction.actionPerformed(e);
+ }
+ }
+
+ }
+
+
+ /**
+ * Listens for LookAndFeel changes and updates the various popup windows
+ * involved in auto-completion accordingly.
+ */
+ private class LookAndFeelChangeListener implements PropertyChangeListener {
+
+ public void propertyChange(PropertyChangeEvent e) {
+ String name = e.getPropertyName();
+ if ("lookAndFeel".equals(name)) {
+ updateUI();
+ }
+ }
+
+ }
+
+
+ /**
+ * Action that starts a parameterized completion, e.g. after '(' is
+ * typed.
+ */
+ private class ParameterizedCompletionStartAction extends AbstractAction {
+
+ private String start;
+
+ public ParameterizedCompletionStartAction(char ch) {
+ this.start = Character.toString(ch);
+ }
+
+ public void actionPerformed(ActionEvent e) {
+
+ // Prevents keystrokes from messing up
+ boolean wasVisible = hidePopupWindow();
+
+ // Only proceed if they were selecting a completion
+ if (!wasVisible || !isParameterAssistanceEnabled()) {
+ textComponent.replaceSelection(start);
+ return;
+ }
+
+ Completion c = popupWindow.getSelection();
+ if (c instanceof ParameterizedCompletion) { // Should always be true
+ // Fixes capitalization of the entered text.
+ insertCompletion(c, true);
+ }
+
+ }
+
+ }
+
+
+ /**
+ * Listens for events in the parent window of the text component with
+ * auto-completion enabled.
+ */
+ private class ParentWindowListener extends ComponentAdapter
+ implements WindowFocusListener {
+
+ public void addTo(Window w) {
+ w.addComponentListener(this);
+ w.addWindowFocusListener(this);
+ }
+
+ @Override
+ public void componentHidden(ComponentEvent e) {
+ hideChildWindows();
+ }
+
+ @Override
+ public void componentMoved(ComponentEvent e) {
+ hideChildWindows();
+ }
+
+ @Override
+ public void componentResized(ComponentEvent e) {
+ hideChildWindows();
+ }
+
+ public void removeFrom(Window w) {
+ w.removeComponentListener(this);
+ w.removeWindowFocusListener(this);
+ }
+
+ public void windowGainedFocus(WindowEvent e) {
+ }
+
+ public void windowLostFocus(WindowEvent e) {
+ hideChildWindows();
+ }
+
+ }
+
+
+ /**
+ * Listens for events from the text component we're installed on.
+ */
+ private class TextComponentListener extends FocusAdapter
+ implements HierarchyListener {
+
+ void addTo(JTextComponent tc) {
+ tc.addFocusListener(this);
+ tc.addHierarchyListener(this);
+ }
+
+ /**
+ * Hide the auto-completion windows when the text component loses
+ * focus.
+ */
+ @Override
+ public void focusLost(FocusEvent e) {
+ hideChildWindows();
+ }
+
+ /**
+ * Called when the component hierarchy for our text component changes.
+ * When the text component is added to a new {@link Window}, this
+ * method registers listeners on that Window
.
+ *
+ * @param e The event.
+ */
+ public void hierarchyChanged(HierarchyEvent e) {
+
+ // NOTE: e many be null as we call this method at other times.
+ //System.out.println("Hierarchy changed! " + e);
+
+ Window oldParentWindow = parentWindow;
+ parentWindow = SwingUtilities.getWindowAncestor(textComponent);
+ if (parentWindow != oldParentWindow) {
+ if (oldParentWindow != null) {
+ parentWindowListener.removeFrom(oldParentWindow);
+ }
+ if (parentWindow != null) {
+ parentWindowListener.addTo(parentWindow);
+ }
+ }
+
+ }
+
+ public void removeFrom(JTextComponent tc) {
+ tc.removeFocusListener(this);
+ tc.removeHierarchyListener(this);
+ }
+
+ }
}
\ No newline at end of file
diff --git a/designer_base/src/com/fr/design/gui/autocomplete/ParameterizedCompletionContext.java b/designer_base/src/com/fr/design/gui/autocomplete/ParameterizedCompletionContext.java
index 62c68dc98..966035b89 100644
--- a/designer_base/src/com/fr/design/gui/autocomplete/ParameterizedCompletionContext.java
+++ b/designer_base/src/com/fr/design/gui/autocomplete/ParameterizedCompletionContext.java
@@ -439,7 +439,7 @@ class ParameterizedCompletionContext {
*/
private void installKeyBindings() {
- if (AutoCompletion.getDebug()) {
+ if (AutoCompletion.isDebug()) {
System.out.println("CompletionContext: Installing keybindings");
}
@@ -733,7 +733,7 @@ class ParameterizedCompletionContext {
*/
private void uninstallKeyBindings() {
- if (AutoCompletion.getDebug()) {
+ if (AutoCompletion.isDebug()) {
System.out.println("CompletionContext Uninstalling keybindings");
}
diff --git a/designer_base/src/com/fr/design/gui/itabpane/UITabsHeaderIconPane.java b/designer_base/src/com/fr/design/gui/itabpane/UITabsHeaderIconPane.java
index 1ec189cc1..ba7752352 100644
--- a/designer_base/src/com/fr/design/gui/itabpane/UITabsHeaderIconPane.java
+++ b/designer_base/src/com/fr/design/gui/itabpane/UITabsHeaderIconPane.java
@@ -160,12 +160,14 @@ public class UITabsHeaderIconPane extends JPanel implements UITabComponent {
public void run() {
int height = centerPane.getHeight();
int width = centerPane.getWidth();
+ int step = 30;
+ int x = 0;
int y = -height;
- for (int i = 0; i <= height; i += 30) {
+ for (int i = 0; i <= height; i += step) {
// 设置面板位置
- currentPanel.setBounds(0, i, width, height);
- panel.setBounds(0, y, width, height);
- y += 30;
+ currentPanel.setBounds(x, i, width, height);
+ panel.setBounds(x, y, width, height);
+ y += step;
try {
Thread.sleep(3);
} catch (InterruptedException e) {
diff --git a/designer_base/src/com/fr/design/gui/itree/checkboxtree/CheckBoxTree.java b/designer_base/src/com/fr/design/gui/itree/checkboxtree/CheckBoxTree.java
index 941fd962a..b81ea7c38 100644
--- a/designer_base/src/com/fr/design/gui/itree/checkboxtree/CheckBoxTree.java
+++ b/designer_base/src/com/fr/design/gui/itree/checkboxtree/CheckBoxTree.java
@@ -236,8 +236,9 @@ public class CheckBoxTree extends JTree {
}
TreePath path = _tree.getPathForLocation(e.getX(), e.getY());
- if (path == null)
+ if (path == null) {
return null;
+ }
if (clicksInCheckBox(e, path)) {
return path;
@@ -308,8 +309,9 @@ public class CheckBoxTree extends JTree {
return;
}
- if (e.getModifiers() == 0 && e.getKeyChar() == KeyEvent.VK_SPACE)
+ if (e.getModifiers() == 0 && e.getKeyChar() == KeyEvent.VK_SPACE) {
toggleSelections();
+ }
}
public void keyTyped(KeyEvent e) {
diff --git a/designer_base/src/com/fr/design/locale/designer.properties b/designer_base/src/com/fr/design/locale/designer.properties
index ac49629e1..739f519e3 100644
--- a/designer_base/src/com/fr/design/locale/designer.properties
+++ b/designer_base/src/com/fr/design/locale/designer.properties
@@ -1137,7 +1137,7 @@ FRFont-bold=bold
FR-Designer_Set_Submit_Condition=
Form-Change_Widget_Name=Change Widget Name
ReportColumns-Report_Columns=Report Columns
-Can_not_use_FormatBursh=
+FR-Designer_Can_not_use_FormatBursh=
CellElement-Property_Table=CellElement Property Table
Dictionary-Dynamic_SQL=Dynamic SQL
FR-Designer_Form-CheckBoxGroup=CheckBoxGroup
diff --git a/designer_base/src/com/fr/design/locale/designer_en_US.properties b/designer_base/src/com/fr/design/locale/designer_en_US.properties
index 8413c0596..fe1ed74f0 100644
--- a/designer_base/src/com/fr/design/locale/designer_en_US.properties
+++ b/designer_base/src/com/fr/design/locale/designer_en_US.properties
@@ -1138,7 +1138,7 @@ FRFont-bold=Bold
FR-Designer_Set_Submit_Condition=Submit Condition
Form-Change_Widget_Name=Change Control Name
ReportColumns-Report_Columns=Multi-columns/lines display
-Can_not_use_FormatBursh=Can't use format painter in multiple selections
+FR-Designer_Can_not_use_FormatBursh=Can't use format painter in multiple selections
CellElement-Property_Table=Cell Attribute Table
Dictionary-Dynamic_SQL=Dynamic SQL
FR-Designer_Form-CheckBoxGroup=CheckBoxGroup
diff --git a/designer_base/src/com/fr/design/locale/designer_ja_JP.properties b/designer_base/src/com/fr/design/locale/designer_ja_JP.properties
index 5d8a311f7..eafc9e4fe 100644
--- a/designer_base/src/com/fr/design/locale/designer_ja_JP.properties
+++ b/designer_base/src/com/fr/design/locale/designer_ja_JP.properties
@@ -1133,7 +1133,7 @@ FRFont-bold=\u592A\u5B57
FR-Designer_Set_Submit_Condition=\u63D0\u51FA\u6761\u4EF6\u3092\u8A2D\u5B9A
Form-Change_Widget_Name=\u30B3\u30F3\u30C8\u30ED\u30FC\u30EB\u540D\u5909\u66F4
ReportColumns-Report_Columns=\u5E33\u7968\u30B3\u30E9\u30E0
-Can_not_use_FormatBursh=\u8907\u6570\u9078\u629E\u3057\u305F\u30A8\u30EA\u30A2\u3067\u306F\u66F8\u5F0F\u30D6\u30E9\u30B7\u3092\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093\!
+FR-Designer_Can_not_use_FormatBursh=\u8907\u6570\u9078\u629E\u3057\u305F\u30A8\u30EA\u30A2\u3067\u306F\u66F8\u5F0F\u30D6\u30E9\u30B7\u3092\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093\!
CellElement-Property_Table=\u30BB\u30EB\u306E\u30D7\u30ED\u30D1\u30C6\u30A3\u00B7\u30B7\u30FC\u30C8
Dictionary-Dynamic_SQL=\u52D5\u614BSQL
FR-Designer_Form-CheckBoxGroup=\u30D5\u30EC\u30FC\u30E0\u30BB\u30C3\u30C8\u3092\u8907\u6570\u9078\u629E
diff --git a/designer_base/src/com/fr/design/locale/designer_ko_KR.properties b/designer_base/src/com/fr/design/locale/designer_ko_KR.properties
index dbf4da3a0..1953cee19 100644
--- a/designer_base/src/com/fr/design/locale/designer_ko_KR.properties
+++ b/designer_base/src/com/fr/design/locale/designer_ko_KR.properties
@@ -1134,7 +1134,7 @@ FRFont-bold=\uAD75\uAC8C
FR-Designer_Set_Submit_Condition=\uC81C\uCD9C\uC870\uAC74\uC124\uC815
Form-Change_Widget_Name=\uC18C\uD504\uD2B8\uC6E8\uC5B4\uC81C\uC5B4\uC774\uB984\uBCC0\uACBD
ReportColumns-Report_Columns=\uBB38\uC11C\uC140\uB098\uB204\uAE30
-Can_not_use_FormatBursh=\uC911\uBCF5\uC120\uD0DD\uB41C\uC601\uC5ED\uC5D0\uC11C\uC2DD\uC744\uC774\uC6A9\uD558\uC5EC\uC778\uC1C4\uD560\uC218\uC5C6\uC2B5\uB2C8\uB2E4.\!
+FR-Designer_Can_not_use_FormatBursh=\uC911\uBCF5\uC120\uD0DD\uB41C\uC601\uC5ED\uC5D0\uC11C\uC2DD\uC744\uC774\uC6A9\uD558\uC5EC\uC778\uC1C4\uD560\uC218\uC5C6\uC2B5\uB2C8\uB2E4.\!
CellElement-Property_Table=\uC140\uC18D\uC131\uD45C
Dictionary-Dynamic_SQL=\uB3D9\uC801 SQL
FR-Designer_Form-CheckBoxGroup=\uCCB4\uD06C\uBC15\uC2A4\uADF8\uB8F9
diff --git a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties
index 4f044f84f..e501490e1 100644
--- a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties
+++ b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties
@@ -1133,7 +1133,7 @@ FRFont-bold=\u52A0\u7C97
FR-Designer_Set_Submit_Condition=\u8BBE\u7F6E\u63D0\u4EA4\u6761\u4EF6
Form-Change_Widget_Name=\u66F4\u6539\u63A7\u4EF6\u540D
ReportColumns-Report_Columns=\u62A5\u8868\u5206\u680F
-Can_not_use_FormatBursh=\u4E0D\u80FD\u5BF9\u591A\u91CD\u9009\u5B9A\u533A\u57DF\u4F7F\u7528\u683C\u5F0F\u5237\!
+FR-Designer_Can_not_use_FormatBursh=\u4E0D\u80FD\u5BF9\u591A\u91CD\u9009\u5B9A\u533A\u57DF\u4F7F\u7528\u683C\u5F0F\u5237\!
CellElement-Property_Table=\u5355\u5143\u683C\u5C5E\u6027\u8868
Dictionary-Dynamic_SQL=\u52A8\u6001SQL
FR-Designer_Form-CheckBoxGroup=\u590D\u9009\u6846\u7EC4
diff --git a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties
index 2a156e5c2..7260d8f10 100644
--- a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties
+++ b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties
@@ -1133,7 +1133,7 @@ FRFont-bold=\u7C97\u9AD4
FR-Designer_Set_Submit_Condition=\u8A2D\u5B9A\u63D0\u4EA4\u689D\u4EF6
Form-Change_Widget_Name=\u66F4\u6539\u63A7\u5236\u9805\u540D
ReportColumns-Report_Columns=\u5831\u8868\u5206\u6B04
-Can_not_use_FormatBursh=\u7121\u6CD5\u4F7F\u7528\u8907\u88FD\u683C\u5F0F
+FR-Designer_Can_not_use_FormatBursh=\u7121\u6CD5\u4F7F\u7528\u8907\u88FD\u683C\u5F0F
CellElement-Property_Table=\u5132\u5B58\u683C\u5C6C\u6027\u8868
Dictionary-Dynamic_SQL=\u52D5\u614BSQL
FR-Designer_Form-CheckBoxGroup=\u5FA9\u9078\u6846\u7D44
diff --git a/designer_form/src/com/fr/design/mainframe/widget/editors/DataTableConfigPane.java b/designer_form/src/com/fr/design/mainframe/widget/editors/DataTableConfigPane.java
index 417d761cc..a45d9fa25 100644
--- a/designer_form/src/com/fr/design/mainframe/widget/editors/DataTableConfigPane.java
+++ b/designer_form/src/com/fr/design/mainframe/widget/editors/DataTableConfigPane.java
@@ -25,248 +25,249 @@ import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_M
public class DataTableConfigPane extends JComponent implements PropertyChangeListener {
- private DataEditingTable table;
-
- public DataTableConfigPane() {
- table = new DataEditingTable();
- JScrollPane scrollPane = new JScrollPane(table);
- this.setLayout(new DataTableLayout());
- this.add(scrollPane, BorderLayout.CENTER);
- }
-
- public void populate(DataTableConfig config) {
- table.populate(config);
- }
-
- public DataTableConfig update() {
- return table.update();
- }
-
- class DataTableLayout extends BorderLayout {
- public void layoutContainer(Container target) {
- super.layoutContainer(target);
- table.doLayout();
- }
- }
-
- class DataEditingTable extends JTable {
-
- private DataTableConfig config;
- private BeanTableModel model;
- private TableColumnModelListener modeListener;
-
- public DataEditingTable() {
- this.setBorder(BorderFactory.createLineBorder(new Color(210, 210, 210), 1));
- this.setColumnSelectionAllowed(true);
- this.setRowSelectionAllowed(true);
- MouseAdapterListener l = new MouseAdapterListener(this);
- this.addMouseListener(l);
- this.addMouseMotionListener(l);
- model = new BeanTableModel();
- modeListener = new TableColumnModelListener() {
-
- @Override
- public void columnAdded(TableColumnModelEvent e) {
-
- }
-
- @Override
- public void columnMarginChanged(ChangeEvent e) {
- DataTableConfigPane.this.propertyChange();
- }
-
- @Override
- public void columnMoved(TableColumnModelEvent e) {
- DataTableConfigPane.this.propertyChange();
- }
-
- @Override
- public void columnRemoved(TableColumnModelEvent e) {
-
- }
-
- @Override
- public void columnSelectionChanged(ListSelectionEvent e) {
-
- }
-
- };
- }
-
- public TableCellRenderer getCellRenderer(int row, int column) {
- TableCellRenderer renderer = super.getCellRenderer(row, column);
- if (renderer instanceof UILabel) {
- ((UILabel) renderer).setHorizontalAlignment(UILabel.CENTER);
- }
- return renderer;
- }
-
- public void populate(DataTableConfig config) {
- this.getTableHeader().getColumnModel().removeColumnModelListener(modeListener);
- if (config == null) {
- config = DataTableConfig.DEFAULT_TABLE_DATA_CONFIG;
- }
- this.config = config;
-
- model = new BeanTableModel();
- this.setModel(model);
- this.setRowHeight(0, config.getRowHeight());
- for (int i = 0; i < config.getColumnCount(); i++) {
- this.getColumn(this.getColumnName(i)).setPreferredWidth(config.getColumnWidth(i));
- }
- this.getTableHeader().getColumnModel().addColumnModelListener(modeListener);
- this.doLayout();
- this.repaint();
- }
-
- public DataTableConfig update() {
- config.setRowHeight(this.getRowHeight(0));
- model = new BeanTableModel();
- String[] columns = new String[this.getColumnCount()];
- for (int i = 0; i < this.getColumnCount(); i++) {
- config.setColumnWidth(i, this.getColumn(this.getColumnName(i)).getWidth());
- columns[i] = this.getColumnName(i);
- }
-
- config.setColumns(columns);
- return config;
- }
-
- public class BeanTableModel extends AbstractTableModel {
-
- @Override
- public int getColumnCount() {
- return config.getColumnCount();
- }
-
- @Override
- public int getRowCount() {
- return 1;
- }
-
- @Override
- public String getColumnName(int column) {
- return config.getColumnName(column);
- }
-
- @Override
- public Object getValueAt(int rowIndex, int columnIndex) {
- return config.getTableDataName() + "." + config.getColumnName(columnIndex);
- }
-
- }
-
- class MouseAdapterListener extends MouseAdapter {
- private JTable table;
- int oldY = 0;
- int newY = 0;
- int row = 0;
- int oldHeight = 0;
- boolean drag = false;
- int increase = 0;
- JPopupMenu popupMenu;
-
- public MouseAdapterListener(JTable table) {
- this.table = table;
- popupMenu = new JPopupMenu();
-
- popupMenu.add(new CutAction());
- popupMenu.add(new CutAction());
- popupMenu.add(new CutAction());
- popupMenu.add(new CutAction());
- }
-
- class CutAction extends UpdateAction {
-
- /**
- * Constructor
- */
- public CutAction() {
- this.setName(Inter.getLocText("M_Edit-Cut"));
- this.setMnemonic('T');
- this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/cut.png"));
- this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER));
- }
-
- @Override
- public void actionPerformed(ActionEvent e) {
- int row = table.getSelectedRow();
- int column = table.getSelectedColumn();
- table.getColumnModel().removeColumn(table.getColumn(table.getColumnName(column)));
- DataTableConfigPane.this.propertyChange();
- }
- }
-
- public void mouseMoved(MouseEvent e) {
- int onRow = table.rowAtPoint(e.getPoint());
-
- int height = 0;
- for (int i = 0; i <= onRow; i++) {
- height = height + table.getRowHeight(i);
- }
-
- if (height - e.getY() < 3) {
- drag = true;
- table.setCursor(new Cursor(Cursor.N_RESIZE_CURSOR));
- } else {
- drag = false;
- table.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
- }
-
- }
-
- private void trigger_popup(MouseEvent e) {
-
- popupMenu.show(table, e.getX(), e.getY());
- }
-
- public void mouseDragged(MouseEvent e) {
- if (drag) {
- int value = oldHeight + e.getY() - oldY;
- if (value < 30)
- table.setRowHeight(row, 30);
- else
- table.setRowHeight(row, oldHeight + e.getY() - oldY);
- DataTableConfigPane.this.propertyChange();
- }
- }
-
- public void mousePressed(MouseEvent e) {
- oldY = e.getY();
- row = table.rowAtPoint(e.getPoint());
- oldHeight = table.getRowHeight(row);
- if (e.getButton() == MouseEvent.BUTTON3) {
- trigger_popup(e);
- }
- }
-
- public void mouseReleased(MouseEvent e) {
- newY = e.getY();
- table.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
- }
- }
- }
-
- private ArrayList