private JPanel createPanel() { getModifiableRootModel(); // initialize model if needed getModifiableRootModelProxy(); myGenericSettingsPanel = new ModuleEditorPanel(); createEditors(getModule()); final JComponent component = createCenterPanel(); myGenericSettingsPanel.add(component, BorderLayout.CENTER); myEditorsInitialized = true; return myGenericSettingsPanel; }
@NotNull private static JPanel createLayerConfigurationPanel(@NotNull final ModuleEditor moduleEditor) { BorderLayoutPanel panel = JBUI.Panels.simplePanel(); ModifiableRootModel moduleRootModel = moduleEditor.getModifiableRootModelProxy(); final MutableCollectionComboBoxModel<String> model = new MutableCollectionComboBoxModel<String>( new ArrayList<String>(moduleRootModel.getLayers().keySet()), moduleRootModel.getCurrentLayerName()); final ComboBox comboBox = new ComboBox(model); comboBox.setEnabled(model.getSize() > 1); moduleEditor.addChangeListener( new ModuleEditor.ChangeListener() { @Override public void moduleStateChanged(ModifiableRootModel moduleRootModel) { model.update(new ArrayList<String>(moduleRootModel.getLayers().keySet())); model.setSelectedItem(moduleRootModel.getCurrentLayerName()); model.update(); comboBox.setEnabled(comboBox.getItemCount() > 1); } }); comboBox.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { moduleEditor .getModifiableRootModelProxy() .setCurrentLayer((String) comboBox.getSelectedItem()); } } }); DefaultActionGroup group = new DefaultActionGroup(); group.add(new NewLayerAction(moduleEditor, false)); group.add(new DeleteLayerAction(moduleEditor)); group.add(new NewLayerAction(moduleEditor, true)); ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true); JComponent toolbarComponent = actionToolbar.getComponent(); toolbarComponent.setBorder(JBUI.Borders.empty()); panel.addToLeft(LabeledComponent.left(comboBox, "Layer")).addToRight(toolbarComponent); return panel; }
private JPanel createPanel() { getModifiableRootModel(); // initialize model if needed getModifiableRootModelProxy(); myGenericSettingsPanel = new ModuleEditorPanel(); createEditors(getModule()); JPanel northPanel = new JPanel(new GridBagLayout()); myGenericSettingsPanel.add(northPanel, BorderLayout.NORTH); final JComponent component = createCenterPanel(); myGenericSettingsPanel.add(component, BorderLayout.CENTER); return myGenericSettingsPanel; }
private boolean doRemoveModule(@NotNull ModuleEditor selectedEditor) { String question; if (myModuleEditors.size() == 1) { question = ProjectBundle.message("module.remove.last.confirmation"); } else { question = ProjectBundle.message("module.remove.confirmation", selectedEditor.getModule().getName()); } int result = Messages.showYesNoDialog( myProject, question, ProjectBundle.message("module.remove.confirmation.title"), Messages.getQuestionIcon()); if (result != Messages.YES) { return false; } // do remove myModuleEditors.remove(selectedEditor.getModule()); // destroyProcess removed module final Module moduleToRemove = selectedEditor.getModule(); // remove all dependencies on the module that is about to be removed List<ModifiableRootModel> modifiableRootModels = new ArrayList<ModifiableRootModel>(); for (final ModuleEditor moduleEditor : myModuleEditors.values()) { final ModifiableRootModel modifiableRootModel = moduleEditor.getModifiableRootModelProxy(); modifiableRootModels.add(modifiableRootModel); } // destroyProcess editor ModuleDeleteProvider.removeModule(moduleToRemove, null, modifiableRootModels, myModuleModel); processModuleCountChanged(); Disposer.dispose(selectedEditor); return true; }