Search in sources :

Example 1 with TextAccessor

use of com.intellij.ui.TextAccessor in project intellij-community by JetBrains.

the class ProjectSpecificSettingsStep method configureMappingField.

/**
   * Enables or disables "remote path" based on interpreter.
   */
private void configureMappingField(@NotNull final PythonRemoteInterpreterManager remoteInterpreterManager) {
    if (myRemotePathField == null) {
        return;
    }
    final JPanel mainPanel = myRemotePathField.getMainPanel();
    final PyProjectSynchronizer synchronizer = getSynchronizer(remoteInterpreterManager);
    if (synchronizer != null) {
        final String defaultRemotePath = synchronizer.getDefaultRemotePath();
        final boolean mappingRequired = defaultRemotePath != null;
        mainPanel.setVisible(mappingRequired);
        final TextAccessor textField = myRemotePathField.getTextField();
        if (mappingRequired && StringUtil.isEmpty(textField.getText())) {
            textField.setText(defaultRemotePath);
        }
        myRemotePathRequired = mappingRequired;
    } else {
        mainPanel.setVisible(false);
        myRemotePathRequired = false;
    }
}
Also used : PyProjectSynchronizer(com.jetbrains.python.remote.PyProjectSynchronizer) TextAccessor(com.intellij.ui.TextAccessor)

Example 2 with TextAccessor

use of com.intellij.ui.TextAccessor in project android by JetBrains.

the class FileChooserActionListener method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    if (myFilePathProperty == null) {
        return;
    }
    final FileChooserDescriptor descriptor = MockupFileHelper.getFileChooserDescriptor();
    VirtualFile selectedFile = myFilePathProperty.getValue() != null ? VfsUtil.findFileByIoFile(new File(FileUtil.toSystemIndependentName(myFilePathProperty.getValue())), false) : ourLastOpenedFile;
    FileChooser.chooseFile(descriptor, null, null, selectedFile, (virtualFile) -> {
        ourLastOpenedFile = virtualFile;
        if (myComponent != null && myComponent.isRoot()) {
            openDeviceChoiceDialog(virtualFile, myFilePathProperty, myCropProperty);
        } else {
            saveMockupFile(virtualFile, myFilePathProperty, myCropProperty);
            if (e == null) {
                return;
            }
            final TextAccessor textAccessor = e.getSource() instanceof TextAccessor ? ((TextAccessor) e.getSource()) : null;
            if (textAccessor != null) {
                textAccessor.setText(virtualFile.getPath());
            }
        }
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) TextAccessor(com.intellij.ui.TextAccessor) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Aggregations

TextAccessor (com.intellij.ui.TextAccessor)2 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PyProjectSynchronizer (com.jetbrains.python.remote.PyProjectSynchronizer)1 File (java.io.File)1