use of com.jsql.view.swing.text.JPopupTextArea in project jsql-injection by ron190.
the class MenuActionNewValue method actionPerformed.
@Override
public void actionPerformed(ActionEvent arg0) {
JPanel panel = new JPanel(new BorderLayout());
final JTextArea textarea = new JPopupTextArea(new JTextArea()).getProxy();
JLabel labelAddValue = new JLabel(I18n.valueByKey("LIST_ADD_VALUE_LABEL") + ":");
panel.add(labelAddValue, BorderLayout.NORTH);
I18nView.addComponentForKey("LIST_ADD_VALUE_LABEL", labelAddValue);
panel.add(new LightScrollPane(1, 1, 1, 1, textarea));
panel.setPreferredSize(new Dimension(600, 400));
panel.setMinimumSize(new Dimension(600, 400));
textarea.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
super.mousePressed(e);
textarea.requestFocusInWindow();
}
});
int result = JOptionPane.showOptionDialog(this.myList.getTopLevelAncestor(), panel, I18n.valueByKey("LIST_ADD_VALUE_TITLE"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { I18n.valueByKey("LIST_ADD_VALUE_OK"), I18n.valueByKey("LIST_ADD_VALUE_CANCEL") }, I18n.valueByKey("LIST_ADD_VALUE_CANCEL"));
if (!"".equals(textarea.getText()) && result == JOptionPane.YES_OPTION) {
int lastIndex = 0;
if (this.myList.getSelectedIndex() > 0) {
lastIndex = this.myList.getSelectedIndex();
}
int firstIndex = lastIndex;
if ("scan".equals(this.myList.getName())) {
List<ItemListScan> listParsedItems = ListTransfertHandlerScan.parse(textarea.getText().replace("\\", "/"));
for (ItemListScan item : listParsedItems) {
((DefaultListModel<ItemList>) this.myList.getModel()).add(lastIndex++, item);
}
} else {
for (String newItem : textarea.getText().split("\\n")) {
if (!"".equals(newItem)) {
((DefaultListModel<ItemList>) this.myList.getModel()).add(lastIndex++, new ItemList(newItem.replace("\\", "/")));
}
}
}
this.myList.setSelectionInterval(firstIndex, lastIndex - 1);
this.myList.scrollRectToVisible(this.myList.getCellBounds(this.myList.getMinSelectionIndex(), this.myList.getMaxSelectionIndex()));
textarea.setText(null);
}
}
use of com.jsql.view.swing.text.JPopupTextArea in project jsql-injection by ron190.
the class CreateFileTab method execute.
@Override
public void execute() {
if (MediatorGui.tabResults() == null) {
LOGGER.error("Unexpected unregistered MediatorGui.tabResults() in " + this.getClass());
}
JTextArea fileText = new JPopupTextArea().getProxy();
fileText.setText(this.content);
fileText.setFont(new Font(HelperUi.FONT_NAME_UBUNTU_MONO, Font.PLAIN, 14));
LightScrollPane scroller = new LightScrollPane(1, 0, 0, 0, fileText);
fileText.setCaretPosition(0);
MediatorGui.tabResults().addTab(this.name + " ", scroller);
// Focus on the new tab
MediatorGui.tabResults().setSelectedComponent(scroller);
// Create a custom tab header with close button
TabHeader header = new TabHeader(this.name, HelperUi.ICON_FILE_SERVER);
MediatorGui.tabResults().setToolTipTextAt(MediatorGui.tabResults().indexOfComponent(scroller), this.path);
// Apply the custom header to the tab
MediatorGui.tabResults().setTabComponentAt(MediatorGui.tabResults().indexOfComponent(scroller), header);
// Add the path String to the list of files only if there is no same StringObject value already
MediatorGui.managerWebshell().addToList(this.path.replace(this.name, ""));
MediatorGui.managerUpload().addToList(this.path.replace(this.name, ""));
MediatorGui.managerSqlshell().addToList(this.path.replace(this.name, ""));
}
Aggregations