Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
[*.java]
indent_style = tab
indent_size = 4
end_of_line = lf
trim_trailing_whitespace = true
max_line_length = 120

[*.xml]
indent_style = tab
indent_size = 4
trim_trailing_whitespace = true
end_of_line = lf
trim_trailing_whitespace = true
max_line_length = 120
4 changes: 2 additions & 2 deletions RSTAUI/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ base {
dependencies {
api 'com.fifesoft:rsyntaxtextarea:4.0.1'
api 'com.fifesoft:autocomplete:4.0.0'
testImplementation platform('org.junit:junit-bom:6.0.1')
testImplementation platform('org.junit:junit-bom:6.1.1')
testImplementation 'org.junit.jupiter:junit-jupiter'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
testImplementation 'org.mockito:mockito-core:5.21.0'
testImplementation 'org.mockito:mockito-core:5.23.0'
}

ext.isReleaseVersion = !project.version.endsWith('SNAPSHOT')
Expand Down
370 changes: 185 additions & 185 deletions RSTAUI/src/main/java/org/fife/rsta/ui/DecorativeIconPanel.java
Original file line number Diff line number Diff line change
@@ -1,185 +1,185 @@
/*
* 07/30/2011
*
* DecorativeIconPanel.java - Displays a small decorative icon beside some
* other component.
* This library is distributed under a modified BSD license. See the included
* RSTAUI.License.txt file for details.
*/
package org.fife.rsta.ui;
import java.awt.BorderLayout;
import java.awt.Graphics;
import java.awt.event.MouseEvent;
import javax.swing.Icon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.ToolTipManager;
import org.fife.ui.autocomplete.EmptyIcon;
/**
* A panel that displays an 8x8 decorative icon for a component, such as a
* text field or combo box. This can be used to display error icons, warning
* icons, etc.
*
* @author Robert Futrell
* @version 1.1
* @see AssistanceIconPanel
*/
public class DecorativeIconPanel extends JPanel {
/**
* The width of this icon panel, to help align the components we're
* listening to with other combo boxes or text fields without a
* DecorativeIconPanel.
*/
public static final int DEFAULT_WIDTH = 8;
private JLabel iconLabel;
private boolean showIcon;
private String tip;
private EmptyIcon emptyIcon;
/**
* Constructor.
*/
public DecorativeIconPanel() {
this(DEFAULT_WIDTH);
}
/**
* Constructor.
*
* @param iconWidth The with of decorative icons that will be added to
* this panel. This is used to ensure the proper amount of padding
* when no icon is being shown.
*/
public DecorativeIconPanel(int iconWidth) {
setLayout(new BorderLayout());
emptyIcon = new EmptyIcon(iconWidth);
iconLabel = new JLabel(emptyIcon) {
@Override
public String getToolTipText(MouseEvent e) {
return showIcon ? tip : null;
}
};
iconLabel.setVerticalAlignment(SwingConstants.TOP);
ToolTipManager.sharedInstance().registerComponent(iconLabel);
add(iconLabel, BorderLayout.NORTH);
}
/**
* Returns the icon being displayed.
*
* @return The icon.
* @see #setIcon(Icon)
*/
public Icon getIcon() {
return iconLabel.getIcon();
}
/**
* Returns whether the icon (if any) is being rendered.
*
* @return Whether the icon is being rendered.
* @see #setShowIcon(boolean)
*/
public boolean getShowIcon() {
return showIcon;
}
/**
* Returns the tool tip displayed when the mouse hovers over the icon.
* If the icon is not being displayed, this parameter is ignored.
*
* @return The tool tip text.
* @see #setToolTipText(String)
*/
@Override
public String getToolTipText() {
return tip;
}
/**
* Paints any child components. Overridden so the user can explicitly
* hide the icon.
*
* @param g The graphics context.
* @see #setShowIcon(boolean)
*/
@Override
protected void paintChildren(Graphics g) {
if (showIcon) {
super.paintChildren(g);
}
}
/**
* Sets the icon to display.
*
* @param icon The new icon to display.
* @see #getIcon()
*/
public void setIcon(Icon icon) {
if (icon==null) {
icon = emptyIcon;
}
iconLabel.setIcon(icon);
}
/**
* Sets the size of the icon to display. This only needs to be
* called if the icon set being used changes at runtime.
*
* @param iconWidth The new icon size.
*/
public void setIconWidth(int iconWidth) {
if (iconWidth != emptyIcon.getIconWidth()) {
emptyIcon.setSize(iconWidth);
revalidate();
repaint();
}
}
/**
* Toggles whether the icon should be shown.
*
* @param show Whether to show the icon.
* @see #getShowIcon()
*/
public void setShowIcon(boolean show) {
if (show!=showIcon) {
showIcon = show;
repaint();
}
}
/**
* Sets the tool tip text to display when the mouse is over the icon.
* This parameter is ignored if the icon is not being displayed.
*
* @param tip The tool tip text to display.
* @see #getToolTipText()
*/
@Override
public void setToolTipText(String tip) {
this.tip = tip;
}
}
/*
* 07/30/2011
*
* DecorativeIconPanel.java - Displays a small decorative icon beside some
* other component.
* This library is distributed under a modified BSD license. See the included
* RSTAUI.License.txt file for details.
*/
package org.fife.rsta.ui;

import java.awt.BorderLayout;
import java.awt.Graphics;
import java.awt.event.MouseEvent;
import javax.swing.Icon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.ToolTipManager;

import org.fife.ui.autocomplete.EmptyIcon;


/**
* A panel that displays an 8x8 decorative icon for a component, such as a
* text field or combo box. This can be used to display error icons, warning
* icons, etc.
*
* @author Robert Futrell
* @version 1.1
* @see AssistanceIconPanel
*/
public class DecorativeIconPanel extends JPanel {

/**
* The width of this icon panel, to help align the components we're
* listening to with other combo boxes or text fields without a
* DecorativeIconPanel.
*/
public static final int DEFAULT_WIDTH = 8;

private JLabel iconLabel;
private boolean showIcon;
private String tip;
private EmptyIcon emptyIcon;


/**
* Constructor.
*/
public DecorativeIconPanel() {
this(DEFAULT_WIDTH);
}


/**
* Constructor.
*
* @param iconWidth The with of decorative icons that will be added to
* this panel. This is used to ensure the proper amount of padding
* when no icon is being shown.
*/
public DecorativeIconPanel(int iconWidth) {

setLayout(new BorderLayout());
emptyIcon = new EmptyIcon(iconWidth);

iconLabel = new JLabel(emptyIcon) {
@Override
public String getToolTipText(MouseEvent e) {
return showIcon ? tip : null;
}
};
iconLabel.setVerticalAlignment(SwingConstants.TOP);
ToolTipManager.sharedInstance().registerComponent(iconLabel);
add(iconLabel, BorderLayout.NORTH);
}


/**
* Returns the icon being displayed.
*
* @return The icon.
* @see #setIcon(Icon)
*/
public Icon getIcon() {
return iconLabel.getIcon();
}


/**
* Returns whether the icon (if any) is being rendered.
*
* @return Whether the icon is being rendered.
* @see #setShowIcon(boolean)
*/
public boolean getShowIcon() {
return showIcon;
}


/**
* Returns the tool tip displayed when the mouse hovers over the icon.
* If the icon is not being displayed, this parameter is ignored.
*
* @return The tool tip text.
* @see #setToolTipText(String)
*/
@Override
public String getToolTipText() {
return tip;
}


/**
* Paints any child components. Overridden so the user can explicitly
* hide the icon.
*
* @param g The graphics context.
* @see #setShowIcon(boolean)
*/
@Override
protected void paintChildren(Graphics g) {
if (showIcon) {
super.paintChildren(g);
}
}


/**
* Sets the icon to display.
*
* @param icon The new icon to display.
* @see #getIcon()
*/
public void setIcon(Icon icon) {
if (icon==null) {
icon = emptyIcon;
}
iconLabel.setIcon(icon);
}


/**
* Sets the size of the icon to display. This only needs to be
* called if the icon set being used changes at runtime.
*
* @param iconWidth The new icon size.
*/
public void setIconWidth(int iconWidth) {
if (iconWidth != emptyIcon.getIconWidth()) {
emptyIcon.setSize(iconWidth);
revalidate();
repaint();
}
}


/**
* Toggles whether the icon should be shown.
*
* @param show Whether to show the icon.
* @see #getShowIcon()
*/
public void setShowIcon(boolean show) {
if (show!=showIcon) {
showIcon = show;
repaint();
}
}


/**
* Sets the tool tip text to display when the mouse is over the icon.
* This parameter is ignored if the icon is not being displayed.
*
* @param tip The tool tip text to display.
* @see #getToolTipText()
*/
@Override
public void setToolTipText(String tip) {
this.tip = tip;
}


}
Loading
Loading