Search in sources :

Example 1 with KtModifierKeywordToken

use of org.jetbrains.kotlin.lexer.KtModifierKeywordToken in project kotlin by JetBrains.

the class KotlinIntroduceTypeAliasDialog method init.

@Override
protected void init() {
    super.init();
    //noinspection unchecked
    visibilityBox.setModel(new DefaultComboBoxModel(getApplicableVisibilities().toArray()));
    //noinspection unchecked
    visibilityBox.setRenderer(new DefaultListCellRenderer() {

        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            String tokenValue = value != null ? ((KtModifierKeywordToken) value).getValue() : null;
            return super.getListCellRendererComponent(list, tokenValue, index, isSelected, cellHasFocus);
        }
    });
    aliasNameField = new NameSuggestionsField(new String[] { originalDescriptor.getName() }, project, KotlinFileType.INSTANCE);
    aliasNameField.addDataChangedListener(new NameSuggestionsField.DataChanged() {

        @Override
        public void dataChanged() {
            update();
        }
    });
    aliasNamePanel.add(aliasNameField, BorderLayout.CENTER);
    aliasNameLabel.setLabelFor(aliasNameField);
    boolean enableVisibility = isVisibilitySectionAvailable();
    visibilityBox.setEnabled(enableVisibility);
    if (enableVisibility) {
        KtModifierKeywordToken defaultVisibility = originalDescriptor.getVisibility();
        if (defaultVisibility == null) {
            defaultVisibility = KtTokens.PUBLIC_KEYWORD;
        }
        visibilityBox.setSelectedItem(defaultVisibility);
    }
    visibilityBox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(@NotNull ItemEvent e) {
            update();
        }
    });
    if (!originalDescriptor.getTypeParameters().isEmpty()) {
        parameterTablePanel = new IntroduceTypeAliasParameterTablePanel() {

            @Override
            protected void updateSignature() {
                KotlinIntroduceTypeAliasDialog.this.update();
            }

            @Override
            protected void onEnterAction() {
                doOKAction();
            }

            @Override
            protected void onCancelAction() {
                doCancelAction();
            }
        };
        parameterTablePanel.init(originalDescriptor.getTypeParameters());
        inputParametersPanel.setText("Type &Parameters");
        inputParametersPanel.setLabelFor(parameterTablePanel.getTable());
        inputParametersPanel.add(parameterTablePanel);
    } else {
        inputParametersPanel.setVisible(false);
    }
}
Also used : ItemEvent(java.awt.event.ItemEvent) KtModifierKeywordToken(org.jetbrains.kotlin.lexer.KtModifierKeywordToken) ItemListener(java.awt.event.ItemListener) KotlinSignatureComponent(org.jetbrains.kotlin.idea.refactoring.introduce.ui.KotlinSignatureComponent) NameSuggestionsField(com.intellij.refactoring.ui.NameSuggestionsField)

Aggregations

NameSuggestionsField (com.intellij.refactoring.ui.NameSuggestionsField)1 ItemEvent (java.awt.event.ItemEvent)1 ItemListener (java.awt.event.ItemListener)1 KotlinSignatureComponent (org.jetbrains.kotlin.idea.refactoring.introduce.ui.KotlinSignatureComponent)1 KtModifierKeywordToken (org.jetbrains.kotlin.lexer.KtModifierKeywordToken)1