public SortDialog(Project project) { super(project); cbSpace = new JCheckBox("Add space around delimiter", null, true); cbSplit = new JCheckBox("Split in Groups", null, true); cbRearrangeAll = new JCheckBox("Rearrange intention over all", null, false); cbRearrangeGroup = new JCheckBox("Rearrange intention in groups", null, true); setTitle("Sort Properties"); JPanel panel = new JPanel(); panel.setBounds(61, 11, 81, 140); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.add(cbSpace); panel.add(cbSplit); panel.add(cbRearrangeAll); panel.add(cbRearrangeGroup); component = LabeledComponent.create(panel, "Sort Options"); init(); }
@Override protected JComponent createCenterPanel() { final JPanel panel = new JPanel(new GridBagLayout()); final GridBagConstraints gc = new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 0), 0, 0); final PsiType type = getRootType(); final String typeText = type != null ? type.getPresentableText() : "<unknown>"; panel.add(new JLabel("Migrate " + getElementPresentation(myRoot) + " \"" + typeText + "\" to"), gc); panel.add(myToTypeEditor, gc); LabeledComponent<ScopeChooserCombo> scopeChooserComponent = new LabeledComponent<ScopeChooserCombo>(); scopeChooserComponent.setComponent(myScopeChooserCombo); scopeChooserComponent.setText("Choose scope where change signature may occur"); panel.add(scopeChooserComponent, gc); return panel; }
public RawCommandLineEditor(final Function<String, List<String>> lineParser, final Function<List<String>, String> lineJoiner) { super(new BorderLayout()); myTextField = new TextFieldWithBrowseButton(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (myDialogCaption == null) { Container parent = getParent(); if (parent instanceof LabeledComponent) { parent = parent.getParent(); } LOG.error("Did not call RawCommandLineEditor.setDialogCaption() in " + parent); myDialogCaption = "Parameters"; } Messages.showTextAreaDialog(myTextField.getTextField(), myDialogCaption, "EditParametersPopupWindow", lineParser, lineJoiner); } }); myTextField.setButtonIcon(AllIcons.Actions.ShowViewer); add(myTextField, BorderLayout.CENTER); setDescriptor(null); }
public List<String> getCommandLine() { if (myCurrentCard.equals(CARD_COMMAND_LINE)) { return StringUtil.split(myCommandLineField.getText(), " "); } List<String> result = new ArrayList<String>(); for (Map.Entry<SetupTask.Option, JComponent> entry : myOptionComponents.entrySet()) { final SetupTask.Option option = entry.getKey(); if (option.checkbox) { JCheckBox checkBox = (JCheckBox)entry.getValue(); if (checkBox.isSelected() != option.negative) { result.add(option.name); } } else { LabeledComponent<JTextField> textField = (LabeledComponent<JTextField>)entry.getValue(); String text = textField.getComponent().getText(); if (text.length() > 0) { result.add("--" + option.name + text); } } } return result; }
@Nullable public JComponent createOptionsPanel() { final LabeledComponent<JTextField> definedGroups = new LabeledComponent<JTextField>(); definedGroups.setText("&Defined Groups"); final JTextField textField = new JTextField(StringUtil.join(ArrayUtil.toStringArray(groups), ",")); textField.getDocument().addDocumentListener(new DocumentAdapter() { protected void textChanged(final DocumentEvent e) { groups.clear(); final String[] groupsFromString = textField.getText().split("[, ]"); ContainerUtil.addAll(groups, groupsFromString); } }); definedGroups.setComponent(textField); final JPanel optionsPanel = new JPanel(new BorderLayout()); optionsPanel.add(definedGroups, BorderLayout.NORTH); return optionsPanel; }
private void createUIComponents() { mavenHomeField = new TextFieldWithHistory(); mavenHomeField.setHistorySize(-1); final ArrayList<String> foundMavenHomes = new ArrayList<String>(); foundMavenHomes.add(MavenServerManager.BUNDLED_MAVEN_2); foundMavenHomes.add(MavenServerManager.BUNDLED_MAVEN_3); final File mavenHomeDirectory = MavenUtil.resolveMavenHomeDirectory(null); if (mavenHomeDirectory != null) { foundMavenHomes.add(FileUtil.toSystemIndependentName(mavenHomeDirectory.getPath())); } mavenHomeField.setHistory(foundMavenHomes); mavenHomeComponent = LabeledComponent.create( new ComponentWithBrowseButton<TextFieldWithHistory>(mavenHomeField, null), "Maven &home directory"); final JBLabel versionLabel = new JBLabel(); versionLabel.setOpaque(true); versionLabel.setVerticalAlignment(SwingConstants.TOP); versionLabel.setVerticalTextPosition(SwingConstants.TOP); mavenVersionLabelComponent = LabeledComponent.create(versionLabel, ""); }
public JComponent getMainComponent() { final LabeledComponent<JComboBox> component = new LabeledComponent<JComboBox>(); component.setText("Default &project copyright:"); component.setLabelLocation(BorderLayout.WEST); component.setComponent(myProfilesComboBox); ElementProducer<ScopeSetting> producer = new ElementProducer<ScopeSetting>() { @Override public ScopeSetting createElement() { return new ScopeSetting(DefaultScopesProvider.getAllScope(), myProfilesModel.getAllProfiles().values().iterator().next()); } @Override public boolean canCreateElement() { return !myProfilesModel.getAllProfiles().isEmpty(); } }; ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myScopeMappingTable, producer); return JBUI.Panels.simplePanel(0, 10) .addToTop(component) .addToCenter(decorator.createPanel()) .addToBottom(myScopesLink); }
@Override protected void addComponents() { interpreterNameField = new TextFieldWithBrowseButton(); interpreterNameField.addBrowseFolderListener("Choose interpreter...", "", getProject(), FileChooserDescriptorFactory.createSingleLocalFileDescriptor()); LabeledComponent<JComponent> interpreterNameComponent = LabeledComponent.create(createComponentWithMacroBrowse(interpreterNameField), "Interpreter:"); interpreterNameComponent.setLabelLocation(BorderLayout.WEST); add(interpreterNameComponent); interpreterOptionsComponent = LabeledComponent.create(new RawCommandLineEditor(), "Interpreter options"); interpreterOptionsComponent.setLabelLocation(BorderLayout.WEST); add(interpreterOptionsComponent); programNameField = new TextFieldWithBrowseButton(); programNameField.addBrowseFolderListener("Choose script...", "", getProject(), FileChooserDescriptorFactory.createSingleLocalFileDescriptor()); LabeledComponent<JComponent> programNameComponent = LabeledComponent.create(createComponentWithMacroBrowse(programNameField), "Script:"); programNameComponent.setLabelLocation(BorderLayout.WEST); add(programNameComponent); programParametersComponent = LabeledComponent.create(new RawCommandLineEditor(), "Script parameters:"); programParametersComponent.setLabelLocation(BorderLayout.WEST); add(programParametersComponent); }
private JPanel generateTestPanel() { JPanel testPanel = new JPanel(new GridLayout(2, 1, GRID_LAYOUT_GAP, GRID_LAYOUT_GAP)); input = generateSavingTextArea(); JPanel inputPanel = LabeledComponent.create(new JBScrollPane(input), "Input"); output = generateSavingTextArea(); outputPanel = LabeledComponent.create(new JBScrollPane(output), "Output"); knowAnswer = new JCheckBox("Know answer?"); knowAnswer.addActionListener(e -> saveCurrentTest()); JPanel outputAndCheckBoxPanel = new JPanel(new BorderLayout()); outputAndCheckBoxPanel.add(knowAnswer, BorderLayout.NORTH); outputAndCheckBoxPanel.add(outputPanel, BorderLayout.CENTER); testPanel.add(inputPanel); testPanel.add(outputAndCheckBoxPanel); return testPanel; }
@Override protected void initComponents() { myModuleBox = new ComboBox(); myModuleBox.setRenderer(new ModuleListCellRenderer()); myVmParametersComponent = LabeledComponent.create(new RawCommandLineEditor(), "VM arguments"); myVmParametersComponent.setLabelLocation(BorderLayout.WEST); copyDialogCaption(myVmParametersComponent); myUseAlternativeBundleCheckBox = new JCheckBox("Use alternative bundle: "); ProjectSdksModel projectSdksModel = new ProjectSdksModel(); projectSdksModel.reset(); myAlternativeBundleComboBox = new SdkComboBox(projectSdksModel, Conditions.<SdkTypeId>is(NodeJSBundleType.getInstance()), true); myAlternativeBundleComboBox.setEnabled(false); myUseAlternativeBundleCheckBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { myAlternativeBundleComboBox.setEnabled(myUseAlternativeBundleCheckBox.isSelected()); } }); super.initComponents(); }
public RawCommandLineEditor(final Function<String, List<String>> lineParser, final Function<List<String>, String> lineJoiner) { super(new BorderLayout()); myTextField = new TextFieldWithBrowseButton(new ActionListener() { public void actionPerformed(ActionEvent e) { if (myDialogCaption == null) { Container parent = getParent(); if (parent instanceof LabeledComponent) { parent = parent.getParent(); } LOG.error("Did not call RawCommandLineEditor.setDialogCaption() in " + parent); myDialogCaption = "Parameters"; } Messages.showTextAreaDialog(myTextField.getTextField(), myDialogCaption, "EditParametersPopupWindow", lineParser, lineJoiner); } }); myTextField.setButtonIcon(AllIcons.Actions.ShowViewer); add(myTextField, BorderLayout.CENTER); setDescriptor(null); }
public JComponent getMainComponent() { final JPanel panel = new JPanel(new BorderLayout(0, 10)); final LabeledComponent<JComboBox> component = new LabeledComponent<JComboBox>(); component.setText("Default &project copyright:"); component.setLabelLocation(BorderLayout.WEST); component.setComponent(myProfilesComboBox); panel.add(component, BorderLayout.NORTH); ElementProducer<ScopeSetting> producer = new ElementProducer<ScopeSetting>() { @Override public ScopeSetting createElement() { return new ScopeSetting(DefaultScopesProvider.getAllScope(), myProfilesModel.getAllProfiles().values().iterator().next()); } @Override public boolean canCreateElement() { return !myProfilesModel.getAllProfiles().isEmpty(); } }; ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myScopeMappingTable, producer); panel.add(decorator.createPanel(), BorderLayout.CENTER); panel.add(myScopesLink, BorderLayout.SOUTH); return panel; }
@NotNull @Override protected JComponent createEditor() { JPanel verticalLayout = new JPanel(new VerticalFlowLayout(0, 0)); ProjectSdksModel model = new ProjectSdksModel(); model.reset(); myBundleBox = new SdkComboBox(model, Conditions.equalTo(myBundleType), true); verticalLayout.add(LabeledComponent.left(myBundleBox, J2EEBundle.message("label.run.configuration.properties.application.server"))); JPanel openBrowserPanel = new JPanel(); openBrowserPanel.setBorder(IdeBorderFactory.createTitledBorder("Open browser")); verticalLayout.add(openBrowserPanel); if(myBundleType.isJreCustomizable()) { AlternativeJREPanel panel = new AlternativeJREPanel(); verticalLayout.add(panel); } verticalLayout.add(mySettingsWrapper); return verticalLayout; }
public DotNetCoverageConfigurationEditor() { myPanel.add(myEnabledCheckBox); myPanel.add(LabeledComponent.left(myRunnersBox, "Runner")); myRunnersBox.setRenderer(new ColoredListCellRendererWrapper<Object>() { @Override protected void doCustomize(JList list, Object value, int index, boolean selected, boolean hasFocus) { if(value == null) { append("<none>"); } else if(value instanceof String) { append((String) value, SimpleTextAttributes.ERROR_ATTRIBUTES); } else if(value instanceof CoverageRunner) { append(((CoverageRunner) value).getPresentableName()); } } }); }
public RawCommandLineEditor(final Function<String, List<String>> lineParser, final Function<List<String>, String> lineJoiner) { super(new BorderLayout()); myTextField = new TextFieldWithBrowseButton(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (StringUtil.isEmpty(myDialogCaption)) { Container parent = getParent(); if (parent instanceof LabeledComponent) { parent = parent.getParent(); } LOG.error("Did not call RawCommandLineEditor.setDialogCaption() in " + parent); myDialogCaption = "Parameters"; } Messages.showTextAreaDialog(myTextField.getTextField(), myDialogCaption, "EditParametersPopupWindow", lineParser, lineJoiner); } }); myTextField.setButtonIcon(AllIcons.Actions.ShowViewer); add(myTextField, BorderLayout.CENTER); setDescriptor(null); }
@Override protected JComponent createTopRightComponent(final JTextField nameField) { final ComboBox artifactTypeBox = new ComboBox(); for (ArtifactType type : ArtifactType.EP_NAME.getExtensions()) { artifactTypeBox.addItem(type); } artifactTypeBox.setRenderer(new ArtifactTypeCellRenderer(artifactTypeBox.getRenderer())); artifactTypeBox.setSelectedItem(getArtifact().getArtifactType()); artifactTypeBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final ArtifactType selected = (ArtifactType)artifactTypeBox.getSelectedItem(); if (selected != null && !Comparing.equal(selected, getArtifact().getArtifactType())) { getEditor().setArtifactType(selected); } } }); return LabeledComponent.left(artifactTypeBox, "Type"); }
protected void initComponents() { myProgramParametersComponent = LabeledComponent.create(new RawCommandLineEditor(), ExecutionBundle.message("run.configuration.program.parameters")); FileChooserDescriptor fileChooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); //noinspection DialogTitleCapitalization fileChooserDescriptor.setTitle(ExecutionBundle.message("select.working.directory.message")); myWorkingDirectoryComboBox = new MacroComboBoxWithBrowseButton(fileChooserDescriptor, getProject()); myWorkingDirectoryComponent = LabeledComponent.create(myWorkingDirectoryComboBox, ExecutionBundle.message("run.configuration.working.directory.label")); myEnvVariablesComponent = new EnvironmentVariablesComponent(); myEnvVariablesComponent.setLabelLocation(BorderLayout.WEST); myProgramParametersComponent.setLabelLocation(BorderLayout.WEST); myWorkingDirectoryComponent.setLabelLocation(BorderLayout.WEST); addComponents(); setPreferredSize(new Dimension(10, 10)); copyDialogCaption(myProgramParametersComponent); }
private void showFolderField(final ConfigurationType type, final DefaultMutableTreeNode node, final String folderName) { myRightPanel.removeAll(); JPanel panel = new JPanel(new VerticalFlowLayout(0, 0)); final JTextField textField = new JTextField(folderName); textField.getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(DocumentEvent e) { node.setUserObject(textField.getText()); myTreeModel.reload(node); } }); panel.add(LabeledComponent.left(textField, "Folder name")); panel.add(new JLabel(ExecutionBundle.message("run.configuration.rename.folder.disclaimer"))); myRightPanel.add(panel); myRightPanel.revalidate(); myRightPanel.repaint(); if (isFolderCreating) { textField.selectAll(); IdeFocusManager.getGlobalInstance().doForceFocusWhenFocusSettlesDown(textField); } }
protected GenerateDialog(final PsiClass psiClass) { super(psiClass.getProject()); setTitle("Select Fields for Parcelable Generation"); fieldsCollection = new CollectionListModel<PsiField>(); final JBList fieldList = new JBList(fieldsCollection); fieldList.setCellRenderer(new DefaultPsiElementCellRenderer()); final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(fieldList).disableAddAction(); final JPanel panel = decorator.createPanel(); fieldsComponent = LabeledComponent.create(panel, "Fields to include in Parcelable"); includeSubclasses = new JBCheckBox("Include fields from base classes"); setupCheckboxClickAction(psiClass); showCheckbox = psiClass.getFields().length != psiClass.getAllFields().length; updateFieldsDisplay(psiClass); init(); }
@Nullable @Override public LabeledComponent<JComponent> getLanguageSettingsComponent(@NotNull Course selectedCourse) { final Project project = ProjectManager.getInstance().getDefaultProject(); PyConfigurableInterpreterList instance = PyConfigurableInterpreterList.getInstance(project); if (instance == null) { return null; } final List<Sdk> sdks = instance.getAllPythonSdks(); VirtualEnvProjectFilter.removeAllAssociated(sdks); // by default we create new virtual env in project, we need to add this non-existing sdk to sdk list ProjectJdkImpl fakeSdk = createFakeSdk(selectedCourse); if (fakeSdk != null) { sdks.add(0, fakeSdk); } PythonSdkChooserCombo combo = new PythonSdkChooserCombo(project, sdks, sdk -> true); if (fakeSdk != null) { patchRenderer(fakeSdk, combo); combo.getComboBox().setSelectedItem(fakeSdk); } if (SystemInfo.isMac && !UIUtil.isUnderDarcula()) { combo.putClientProperty("JButton.buttonType", null); } combo.setButtonIcon(PythonIcons.Python.InterpreterGear); combo.addChangedListener(e -> { Sdk selectedSdk = (Sdk)combo.getComboBox().getSelectedItem(); mySettings.setSdk(selectedSdk == fakeSdk ? null : selectedSdk); }); return LabeledComponent.create(combo, "Interpreter", BorderLayout.WEST); }
@Nullable @Override public LabeledComponent<JComponent> getLanguageSettingsComponent(@NotNull Course selectedCourse) { myModel = ProjectStructureConfigurable.getInstance(ProjectManager.getInstance().getDefaultProject()).getProjectJdksModel(); myJdkComboBox = new JdkComboBox(myModel, sdkTypeId -> sdkTypeId instanceof JavaSdkType && !((JavaSdkType)sdkTypeId).isDependent(), sdk -> true, sdkTypeId -> sdkTypeId instanceof JavaSdkType && !((JavaSdkType)sdkTypeId).isDependent(), true); ComboboxWithBrowseButton comboboxWithBrowseButton = new ComboboxWithBrowseButton(myJdkComboBox); FixedSizeButton setupButton = comboboxWithBrowseButton.getButton(); myJdkComboBox.setSetupButton(setupButton, null, myModel, (JdkComboBox.JdkComboBoxItem) myJdkComboBox.getModel().getSelectedItem(), null, false); return LabeledComponent.create(comboboxWithBrowseButton, "Jdk", BorderLayout.WEST); }
private void createUIComponents() { myMainClass = new LabeledComponent<>(); myMainClass.setComponent(new EditorTextFieldWithBrowseButton(myProject, true, (declaration, place) -> { if (declaration instanceof PsiClass) { final PsiClass aClass = (PsiClass) declaration; if (ConfigurationUtil.MAIN_CLASS.value(aClass) && PsiMethodUtil.findMainMethod(aClass) != null) { return JavaCodeFragment.VisibilityChecker.Visibility.VISIBLE; } } return JavaCodeFragment.VisibilityChecker.Visibility.NOT_VISIBLE; } )); }
private void initializePanel(boolean isDp) { controlPanel = new JPanel(); addInitialFields(isDp); layout = new GroupLayout(controlPanel); controlPanel.setLayout(layout); layout.setAutoCreateGaps(true); layout.setAutoCreateContainerGaps(true); setLayoutConstraints(); component = LabeledComponent.create(controlPanel, ""); }
private void initializePanel() { controlPanel = new JPanel(); addInitialFields(); layout = new GroupLayout(controlPanel); controlPanel.setLayout(layout); layout.setAutoCreateGaps(true); layout.setAutoCreateContainerGaps(true); setLayoutConstraints(); component = LabeledComponent.create(controlPanel, ""); }
private void createUIComponents() { myJarPathComponent = new LabeledComponent<TextFieldWithBrowseButton>(); TextFieldWithBrowseButton textFieldWithBrowseButton = new TextFieldWithBrowseButton(); textFieldWithBrowseButton.addBrowseFolderListener("Choose JAR File", null, myProject, new FileChooserDescriptor(false, false, true, true, false, false)); myJarPathComponent.setComponent(textFieldWithBrowseButton); }
private void createUIComponents() { myMainClass = new LabeledComponent<EditorTextFieldWithBrowseButton>(); myMainClass.setComponent(new EditorTextFieldWithBrowseButton(myProject, true, new JavaCodeFragment.VisibilityChecker() { @Override public Visibility isDeclarationVisible(PsiElement declaration, PsiElement place) { if (declaration instanceof PsiClass) { final PsiClass aClass = (PsiClass)declaration; if (ConfigurationUtil.MAIN_CLASS.value(aClass) && PsiMethodUtil.findMainMethod(aClass) != null || place.getParent() != null && myModuleSelector.findClass(((PsiClass)declaration).getQualifiedName()) != null) { return Visibility.VISIBLE; } } return Visibility.NOT_VISIBLE; } })); }
@Override protected void addComponents() { myVMParametersComponent = LabeledComponent.create(new RawCommandLineEditor(), ExecutionBundle.message("run.configuration.java.vm.parameters.label")); copyDialogCaption(myVMParametersComponent); myVMParametersComponent.setLabelLocation(BorderLayout.WEST); add(myVMParametersComponent); super.addComponents(); }
@Override protected JPanel createReplaceFieldsWithGettersPanel() { final LabeledComponent<JComboBox> component = new LabeledComponent<JComboBox>(); myReplaceFieldsCb = new JComboBox(new Integer[]{IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL, IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE}); myReplaceFieldsCb.setRenderer(new ListCellRendererWrapper<Integer>() { @Override public void customize(JList list, Integer value, int index, boolean selected, boolean hasFocus) { switch (value) { case IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE: setText(UIUtil.removeMnemonic(RefactoringBundle.message("do.not.replace"))); break; case IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE: setText(UIUtil.removeMnemonic(RefactoringBundle.message("replace.fields.inaccessible.in.usage.context"))); break; default: setText(UIUtil.removeMnemonic(RefactoringBundle.message("replace.all.fields"))); } } }); myReplaceFieldsCb.setSelectedItem(JavaRefactoringSettings.getInstance().INTRODUCE_PARAMETER_REPLACE_FIELDS_WITH_GETTERS); KeyboardComboSwitcher.setupActions(myReplaceFieldsCb, myProject); component.setComponent(myReplaceFieldsCb); component.setText(RefactoringBundle.message("replace.fields.used.in.expressions.with.their.getters")); component.getLabel().setDisplayedMnemonic('u'); component.setLabelLocation(BorderLayout.NORTH); component.setBorder(IdeBorderFactory.createEmptyBorder(3, 3, 2, 2)); return component; }
public void testEditJUnitConfiguration() throws ConfigurationException { if (PlatformTestUtil.COVERAGE_ENABLED_BUILD) return; PsiClass testA = findTestA(getModule2()); JUnitConfiguration configuration = createConfiguration(testA); JUnitConfigurable editor = new JUnitConfigurable(myProject); try { Configurable configurable = new RunConfigurationConfigurableAdapter(editor, configuration); configurable.reset(); final EditorTextFieldWithBrowseButton component = ((LabeledComponent<EditorTextFieldWithBrowseButton>)editor.getTestLocation(JUnitConfigurationModel.CLASS)).getComponent(); assertEquals(testA.getQualifiedName(), component.getText()); PsiClass otherTest = findClass(getModule2(), "test2.Test2"); component.setText(otherTest.getQualifiedName()); configurable.apply(); assertEquals(otherTest.getName(), configuration.getName()); String specialName = "My name"; configuration.setName(specialName); configuration.setNameChangedByUser(true); configurable.reset(); component.setText(testA.getQualifiedName()); configurable.apply(); assertEquals(specialName, configuration.getName()); } finally { Disposer.dispose(editor); } }
public MergePanel2(DialogBuilder builder, @NotNull Disposable parent) { ArrayList<EditorPlace> editorPlaces = new ArrayList<EditorPlace>(); EditorPlace.EditorListener placeListener = new EditorPlace.EditorListener() { public void onEditorCreated(EditorPlace place) { if (myDuringCreation) return; disposeMergeList(); myDuringCreation = true; try { tryInitView(); } finally { myDuringCreation = false; } } public void onEditorReleased(Editor releasedEditor) { LOG.assertTrue(!myDuringCreation); disposeMergeList(); } }; for (int i = 0; i < EDITORS_COUNT; i++) { EditorPlace editorPlace = new EditorPlace(new DiffEditorState(i), indexToColumn(i), this); Disposer.register(parent, editorPlace); editorPlaces.add(editorPlace); editorPlace.addListener(placeListener); myEditorsPanels[i] = new LabeledComponent(); myEditorsPanels[i].setLabelLocation(BorderLayout.NORTH); myEditorsPanels[i].setComponent(editorPlace); } FontSizeSynchronizer.attachTo(editorPlaces); myPanel = new DiffPanelOuterComponent(TextDiffType.MERGE_TYPES, createToolbar()); myPanel.insertDiffComponent(new ThreePanels(myEditorsPanels, myDividers), new MyScrollingPanel()); myProvider = new MyDataProvider(); myPanel.setDataProvider(myProvider); myBuilder = builder; }
@NotNull private Collection<EditorPlace> getEditorPlaces() { Collection<EditorPlace> editorPlaces = new ArrayList<EditorPlace>(3); for (LabeledComponent editorsPanel : myEditorsPanels) { editorPlaces.add((EditorPlace) editorsPanel.getComponent()); } return editorPlaces; }
public void setDiffRequest(DiffRequest data) { setTitle(data.getWindowTitle()); disposeMergeList(); for (int i = 0; i < EDITORS_COUNT; i++) { getEditorPlace(i).setDocument(null); } LOG.assertTrue(!myDuringCreation); myDuringCreation = true; myProvider.putData(data.getGenericData()); try { myData = data; String[] titles = myData.getContentTitles(); for (int i = 0; i < myEditorsPanels.length; i++) { LabeledComponent editorsPanel = myEditorsPanels[i]; editorsPanel.getLabel().setText(titles[i].isEmpty() ? " " : titles[i]); } createMergeList(); data.customizeToolbar(myPanel.resetToolbar()); myPanel.registerToolbarActions(); if ( data instanceof MergeRequestImpl && myBuilder != null){ Convertor<DialogWrapper, Boolean> preOkHook = new Convertor<DialogWrapper, Boolean>() { @Override public Boolean convert(DialogWrapper dialog) { ChangeCounter counter = ChangeCounter.getOrCreate(myMergeList); int changes = counter.getChangeCounter(); int conflicts = counter.getConflictCounter(); if (changes == 0 && conflicts == 0) return true; return Messages.showYesNoDialog(dialog.getRootPane(), DiffBundle.message("merge.dialog.apply.partially.resolved.changes.confirmation.message", changes, conflicts), DiffBundle.message("apply.partially.resolved.merge.dialog.title"), Messages.getQuestionIcon()) == Messages.YES; } }; ((MergeRequestImpl)data).setActions(myBuilder, this, preOkHook); } } finally { myDuringCreation = false; } }
public static LabeledComponent<TextFieldWithBrowseButton> assignLabel(TextFieldWithBrowseButton targetDirectoryField, Project project) { LabeledComponent<TextFieldWithBrowseButton> labeledComponent = new LabeledComponent<TextFieldWithBrowseButton>(); labeledComponent.setText(CodeEditorBundle.message("export.to.html.output.directory.label")); targetDirectoryField.addBrowseFolderListener(CodeEditorBundle.message("export.to.html.select.output.directory.title"), CodeEditorBundle.message("export.to.html.select.output.directory.description"), project, FileChooserDescriptorFactory.createSingleFolderDescriptor()); labeledComponent.setComponent(targetDirectoryField); return labeledComponent; }
protected void initComponents() { myProgramParametersComponent = LabeledComponent.create(new RawCommandLineEditor(), ExecutionBundle.message("run.configuration.program.parameters")); FileChooserDescriptor fileChooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); //noinspection DialogTitleCapitalization fileChooserDescriptor.setTitle(ExecutionBundle.message("select.working.directory.message")); myWorkingDirectoryField = new TextFieldWithBrowseButton(); myWorkingDirectoryField.addBrowseFolderListener(new MacroAwareTextBrowseFolderListener(fileChooserDescriptor, getProject()) { @Override public void actionPerformed(ActionEvent e) { myFileChooserDescriptor.putUserData(LangDataKeys.MODULE_CONTEXT, myModuleContext); setProject(getProject()); super.actionPerformed(e); } }); myWorkingDirectoryComponent = LabeledComponent.create(createComponentWithMacroBrowse(myWorkingDirectoryField), ExecutionBundle.message("run.configuration.working.directory.label")); myEnvVariablesComponent = new EnvironmentVariablesComponent(); myEnvVariablesComponent.setLabelLocation(BorderLayout.WEST); myProgramParametersComponent.setLabelLocation(BorderLayout.WEST); myWorkingDirectoryComponent.setLabelLocation(BorderLayout.WEST); addComponents(); setPreferredSize(new Dimension(10, 10)); setAnchor(myEnvVariablesComponent.getLabel()); }
@Override public JComponent getPreferredFocusedComponent() { if (myCurrentCard.equals(CARD_OPTIONS)) { if (myOptionComponents.size() > 0) { final JComponent component = myOptionComponents.values().iterator().next(); return component instanceof LabeledComponent ? ((LabeledComponent)component).getComponent() : component; } return super.getPreferredFocusedComponent(); } return myCommandLineField; }
@Override protected JPanel createBasePanel() { final JPanel panel = super.createBasePanel(); final Project project = ProjectManager.getInstance().getDefaultProject(); final List<Sdk> sdks = PyConfigurableInterpreterList.getInstance(project).getAllPythonSdks(); VirtualEnvProjectFilter.removeAllAssociated(sdks); Sdk compatibleSdk = sdks.isEmpty() ? null : sdks.iterator().next(); DirectoryProjectGenerator generator = getProjectGenerator(); if (generator instanceof PyFrameworkProjectGenerator && !((PyFrameworkProjectGenerator)generator).supportsPython3()) { if (compatibleSdk != null && PythonSdkType.getLanguageLevelForSdk(compatibleSdk).isPy3K()) { Sdk python2Sdk = PythonSdkType.findPython2Sdk(sdks); if (python2Sdk != null) { compatibleSdk = python2Sdk; } } } final Sdk preferred = compatibleSdk; mySdkCombo = new PythonSdkChooserCombo(project, sdks, new Condition<Sdk>() { @Override public boolean value(Sdk sdk) { return sdk == preferred; } }); mySdkCombo.setButtonIcon(PythonIcons.Python.InterpreterGear); final LabeledComponent<PythonSdkChooserCombo> labeled = LabeledComponent.create(mySdkCombo, "Interpreter"); labeled.setLabelLocation(BorderLayout.WEST); UIUtil.mergeComponentsWithAnchor(labeled, (PanelWithAnchor)panel.getComponent(0)); panel.add(labeled); final JPanel basePanelExtension = extendBasePanel(); if (basePanelExtension != null) { panel.add(basePanelExtension); } return panel; }
private AppEngineSupportConfigurable(FrameworkSupportModel model) { myFrameworkSupportModel = model; mySdkEditor = new AppEngineSdkEditor(model.getProject()); mySdkPanel.add(LabeledComponent.create(mySdkEditor.getMainComponent(), "Google App Engine SDK:"), BorderLayout.CENTER); PersistenceApiComboboxUtil.setComboboxModel(myPersistenceApiComboBox, true); if (model.isFrameworkSelected(JPA_FRAMEWORK_ID)) { myPersistenceApiComboBox.setSelectedItem(PersistenceApi.JPA.getDisplayName()); } model.addFrameworkListener(this); myErrorLabel = new HyperlinkLabel(); myErrorLabel.setIcon(AllIcons.RunConfigurations.ConfigurationWarning); myErrorLabel.setVisible(false); myErrorLabel.setHyperlinkTarget(AppEngineSdkUtil.APP_ENGINE_DOWNLOAD_URL); myErrorPanel.add(BorderLayout.CENTER, myErrorLabel); final Component component = mySdkEditor.getComboBox().getEditor().getEditorComponent(); if (component instanceof JTextComponent) { ((JTextComponent)component).getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(DocumentEvent e) { checkSdk(); } }); } checkSdk(); }
public PathOverrider(final LabeledComponent<TextFieldWithBrowseButton> component, final JCheckBox checkBox, DocumentListener docListener, PathProvider pathProvider) { this.component = component.getComponent(); this.component.getTextField().getDocument().addDocumentListener(docListener); this.checkBox = checkBox; this.pathProvider = pathProvider; checkBox.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { update(); } }); }