Search in sources :

Example 1 with JTextComponent

use of javax.swing.text.JTextComponent in project screenbird by adamhub.

the class RecorderPanel method showUploadMessage.

/*
     * Upload methods 
     */
/**
     * Displays a message on the upload form, formatted with a text color.
     * @param message
     * @param type 
     */
public void showUploadMessage(String message, Color type) {
    int start = 0;
    int end = 0;
    Component focusedComponent = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
    if (focusedComponent instanceof JTextComponent) {
        end = ((JTextComponent) focusedComponent).getSelectionEnd();
        start = ((JTextComponent) focusedComponent).getSelectionStart();
    }
    Dimension size = new Dimension(160, 14);
    this.lblUploadMessage.setPreferredSize(size);
    this.lblUploadMessage.setMinimumSize(size);
    this.lblUploadMessage.setMaximumSize(size);
    this.lblUploadMessage.setSize(size);
    this.pbEncoding.setVisible(true);
    this.pbEncoding.setForeground(type);
    this.lblUploadMessage.validate();
    this.lblUploadMessage.setText(message);
    this.lblUploadMessage.setVisible(true);
    this.lblUploadMessage.setForeground(type);
    ((JFrame) this.getParent().getParent().getParent().getParent()).pack();
    this.redrawWindow();
    if (focusedComponent instanceof JTextComponent) {
        ((JTextComponent) focusedComponent).grabFocus();
        ((JTextComponent) focusedComponent).setSelectionStart(start);
        ((JTextComponent) focusedComponent).setSelectionEnd(end);
    }
}
Also used : JFrame(javax.swing.JFrame) JTextComponent(javax.swing.text.JTextComponent) Dimension(java.awt.Dimension) Component(java.awt.Component) JTextComponent(javax.swing.text.JTextComponent)

Example 2 with JTextComponent

use of javax.swing.text.JTextComponent in project SKMCLauncher by SKCraft.

the class TextFieldPopupMenu method show.

@Override
public void show(Component invoker, int x, int y) {
    JTextComponent textComponent = (JTextComponent) invoker;
    boolean editable = textComponent.isEditable() && textComponent.isEnabled();
    cutItem.setVisible(editable);
    pasteItem.setVisible(editable);
    deleteItem.setVisible(editable);
    super.show(invoker, x, y);
}
Also used : JTextComponent(javax.swing.text.JTextComponent)

Example 3 with JTextComponent

use of javax.swing.text.JTextComponent in project intellij-community by JetBrains.

the class ConfigureProxiesOptionsPanel method setStringProperties.

public void setStringProperties(final Map<String, String> properties) {
    for (Map.Entry<String, String> entry : properties.entrySet()) {
        final JComponent component = myKey2Component.get(entry.getKey());
        if (component != null) {
            JTextComponent textComponent = null;
            if (component instanceof JTextComponent) {
                textComponent = (JTextComponent) component;
            } else if (component instanceof TextFieldWithBrowseButton) {
                textComponent = ((TextFieldWithBrowseButton) component).getTextField();
            }
            if (textComponent != null) {
                textComponent.setText(entry.getValue());
                textComponent.selectAll();
            }
            component.setToolTipText(entry.getKey());
        }
    }
    myTrustDefaultCAsCheckBox.setSelected(booleanPropertySelected(properties.get(myComponent2Key.get(myTrustDefaultCAsCheckBox))));
    repositoryUrlsRecalculation();
}
Also used : TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) JTextComponent(javax.swing.text.JTextComponent) HashMap(java.util.HashMap) Map(java.util.Map)

Example 4 with JTextComponent

use of javax.swing.text.JTextComponent in project intellij-community by JetBrains.

the class SetBackgroundImageDialog method setupComponents.

private void setupComponents() {
    myAdjusting = true;
    myPreviewPanel.setLayout(new CardLayout());
    myPreviewPanel.add(myEditorPreview.getPanel(), "editor");
    myPreviewPanel.add(myIdePreview, "ide");
    ((CardLayout) myPreviewPanel.getLayout()).show(myPreviewPanel, "editor");
    myPathField.getComboBox().setEditable(true);
    FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, false, false, true, false).withFileFilter(file -> ImageFileTypeManager.getInstance().isImage(file));
    myPathField.addBrowseFolderListener(null, null, null, descriptor, TextComponentAccessor.STRING_COMBOBOX_WHOLE_TEXT);
    JTextComponent textComponent = getComboEditor();
    textComponent.getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            if (myAdjusting)
                return;
            imagePathChanged();
        }
    });
    for (Enumeration<AbstractButton> e = getTargetRbGroup().getElements(); e.hasMoreElements(); ) {
        AbstractButton button = e.nextElement();
        button.setActionCommand(button.getText());
        button.addItemListener(this::targetChanged);
    }
    for (Enumeration<AbstractButton> e = getFillRbGroup().getElements(); e.hasMoreElements(); ) {
        AbstractButton button = e.nextElement();
        button.setActionCommand(button.getText());
        button.addItemListener(this::fillOrPlaceChanged);
    }
    for (Enumeration<AbstractButton> e = getPlaceRbGroup().getElements(); e.hasMoreElements(); ) {
        AbstractButton button = e.nextElement();
        button.setActionCommand(button.getText());
        button.addItemListener(this::fillOrPlaceChanged);
    }
    ChangeListener opacitySync = new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            if (myAdjusting)
                return;
            myAdjusting = true;
            boolean b = e.getSource() == myOpacitySpinner;
            if (b) {
                int value = (Integer) myOpacitySpinner.getValue();
                myOpacitySpinner.setValue(Math.min(Math.max(0, value), 100));
                myOpacitySlider.setValue(value);
            } else {
                myOpacitySpinner.setValue(myOpacitySlider.getValue());
            }
            myAdjusting = false;
            opacityChanged();
        }
    };
    myOpacitySpinner.addChangeListener(opacitySync);
    myOpacitySlider.addChangeListener(opacitySync);
    myOpacitySlider.setValue(15);
    myOpacitySpinner.setValue(15);
    myScaleRb.setSelected(true);
    myCenterRb.setSelected(true);
    myEditorRb.setSelected(true);
    boolean perProject = !Comparing.equal(getBackgroundSpec(myProject, getSystemProp(true)), getBackgroundSpec(null, getSystemProp(true)));
    myThisProjectOnlyCb.setSelected(perProject);
    myAdjusting = false;
}
Also used : FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) DocumentAdapter(com.intellij.ui.DocumentAdapter) JTextComponent(javax.swing.text.JTextComponent) DocumentEvent(javax.swing.event.DocumentEvent) ChangeEvent(javax.swing.event.ChangeEvent) ChangeListener(javax.swing.event.ChangeListener)

Example 5 with JTextComponent

use of javax.swing.text.JTextComponent in project intellij-community by JetBrains.

the class DeleteAction method update.

@Override
public void update(AnActionEvent e) {
    Presentation presentation = e.getPresentation();
    if (ActionPlaces.PROJECT_VIEW_POPUP.equals(e.getPlace()) || ActionPlaces.COMMANDER_POPUP.equals(e.getPlace())) {
        presentation.setText(IdeBundle.message("action.delete.ellipsis"));
    } else {
        presentation.setText(IdeBundle.message("action.delete"));
    }
    if (e.getProject() == null) {
        presentation.setEnabled(false);
        return;
    }
    DataContext dataContext = e.getDataContext();
    DeleteProvider provider = getDeleteProvider(dataContext);
    if (e.getInputEvent() instanceof KeyEvent) {
        KeyEvent keyEvent = (KeyEvent) e.getInputEvent();
        Object component = PlatformDataKeys.CONTEXT_COMPONENT.getData(dataContext);
        // Do not override text deletion
        if (component instanceof JTextComponent)
            provider = null;
        if (keyEvent.getKeyCode() == KeyEvent.VK_BACK_SPACE) {
            // Do not override text deletion in speed search
            if (component instanceof JComponent) {
                SpeedSearchSupply searchSupply = SpeedSearchSupply.getSupply((JComponent) component);
                if (searchSupply != null)
                    provider = null;
            }
            String activeSpeedSearchFilter = SpeedSearchSupply.SPEED_SEARCH_CURRENT_QUERY.getData(dataContext);
            if (!StringUtil.isEmpty(activeSpeedSearchFilter)) {
                provider = null;
            }
        }
    }
    if (provider instanceof TitledHandler) {
        presentation.setText(((TitledHandler) provider).getActionTitle());
    }
    boolean canDelete = provider != null && provider.canDeleteElement(dataContext);
    if (ActionPlaces.isPopupPlace(e.getPlace())) {
        presentation.setVisible(canDelete);
    } else {
        presentation.setEnabled(canDelete);
    }
}
Also used : DeleteProvider(com.intellij.ide.DeleteProvider) KeyEvent(java.awt.event.KeyEvent) SpeedSearchSupply(com.intellij.ui.speedSearch.SpeedSearchSupply) JTextComponent(javax.swing.text.JTextComponent) TitledHandler(com.intellij.ide.TitledHandler)

Aggregations

JTextComponent (javax.swing.text.JTextComponent)183 Component (java.awt.Component)28 JComponent (javax.swing.JComponent)18 BadLocationException (javax.swing.text.BadLocationException)13 NotNull (org.jetbrains.annotations.NotNull)13 DocumentEvent (javax.swing.event.DocumentEvent)11 DocumentAdapter (com.intellij.ui.DocumentAdapter)8 Caret (javax.swing.text.Caret)8 Document (javax.swing.text.Document)8 Point (java.awt.Point)7 ActionEvent (java.awt.event.ActionEvent)7 ActionListener (java.awt.event.ActionListener)7 ArrayList (java.util.ArrayList)7 ComboBoxEditor (javax.swing.ComboBoxEditor)7 FocusEvent (java.awt.event.FocusEvent)6 JCheckBox (javax.swing.JCheckBox)6 Color (java.awt.Color)5 KeyEvent (java.awt.event.KeyEvent)5 MouseEvent (java.awt.event.MouseEvent)5 JButton (javax.swing.JButton)5