Search in sources :

Example 1 with JPopupTextArea

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);
    }
}
Also used : JPanel(javax.swing.JPanel) JTextArea(javax.swing.JTextArea) MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) LightScrollPane(com.jsql.view.swing.scrollpane.LightScrollPane) DefaultListModel(javax.swing.DefaultListModel) Dimension(java.awt.Dimension) BorderLayout(java.awt.BorderLayout) JPopupTextArea(com.jsql.view.swing.text.JPopupTextArea)

Example 2 with JPopupTextArea

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, ""));
}
Also used : TabHeader(com.jsql.view.swing.tab.TabHeader) JTextArea(javax.swing.JTextArea) JPopupTextArea(com.jsql.view.swing.text.JPopupTextArea) LightScrollPane(com.jsql.view.swing.scrollpane.LightScrollPane) Font(java.awt.Font)

Aggregations

LightScrollPane (com.jsql.view.swing.scrollpane.LightScrollPane)2 JPopupTextArea (com.jsql.view.swing.text.JPopupTextArea)2 JTextArea (javax.swing.JTextArea)2 TabHeader (com.jsql.view.swing.tab.TabHeader)1 BorderLayout (java.awt.BorderLayout)1 Dimension (java.awt.Dimension)1 Font (java.awt.Font)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 DefaultListModel (javax.swing.DefaultListModel)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1