new project wizard: fixing layout problems

This commit is contained in:
Dmitry Avdeev
2013-09-18 16:41:15 +04:00
parent 6e39762756
commit 3b277d22d0
3 changed files with 5 additions and 110 deletions
@@ -1,92 +0,0 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.ide.projectWizard;
import com.intellij.framework.addSupport.FrameworkSupportInModuleConfigurable;
import com.intellij.framework.addSupport.FrameworkSupportInModuleProvider;
import com.intellij.ide.util.newProjectWizard.FrameworkSupportOptionsComponent;
import com.intellij.ide.util.newProjectWizard.impl.FrameworkSupportModelBase;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.ui.components.JBCheckBox;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* @author Dmitry Avdeev
* Date: 09.09.13
*/
class FrameworkPanel extends JPanel {
private final FrameworkSupportInModuleProvider myFramework;
private final FrameworkSupportModelBase myModel;
private JComponent myComponent;
public FrameworkPanel(final FrameworkSupportInModuleProvider framework, FrameworkSupportModelBase model, boolean header) {
super(new BorderLayout());
myFramework = framework;
myModel = model;
if (header) {
addComponent(true);
}
else {
String title = framework.getPresentableName();
final JBCheckBox checkBox = new JBCheckBox(title);
checkBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
selectFramework(checkBox.isSelected());
}
});
add(checkBox, BorderLayout.NORTH);
}
}
private void selectFramework(boolean selected) {
if (selected) {
addComponent(false);
}
else {
removeComponent();
}
revalidate();
repaint();
}
private void removeComponent() {
if (myComponent != null) {
remove(myComponent);
}
}
protected void addComponent(boolean header) {
myComponent = createComponent();
if (myComponent != null) {
myComponent.setBorder(IdeBorderFactory.createEmptyBorder(0, header ? 0 : 20, 0, 0));
add(myComponent, BorderLayout.CENTER);
}
}
private JPanel createComponent() {
FrameworkSupportInModuleConfigurable configurable = myFramework.createConfigurable(myModel);
configurable.onFrameworkSelectionChanged(true);
FrameworkSupportOptionsComponent component =
new FrameworkSupportOptionsComponent(myModel, myModel.getLibrariesContainer(), configurable, myFramework, configurable, true);
return component.getMainPanel();
}
}
@@ -78,7 +78,7 @@ public class AddSupportForFrameworksPanel implements Disposable {
myLibrariesContainer = model.getLibrariesContainer();
myLabel.setVisible(!vertical);
final Splitter splitter = new Splitter(vertical, 0.3f, 0.1f, 0.7f);
final Splitter splitter = vertical ? new Splitter(vertical, 0.3f, 0.1f, 0.7f) : new Splitter(vertical, 0.3f, 0.1f, 0.7f);
myFrameworksTree = new FrameworksTree() {
@Override
protected void onNodeStateChanged(CheckedTreeNode node) {
@@ -57,32 +57,19 @@ public class FrameworkSupportOptionsComponent {
Disposable parentDisposable,
FrameworkSupportInModuleProvider provider,
final FrameworkSupportInModuleConfigurable configurable) {
this(model, container, parentDisposable, provider, configurable, false);
}
public FrameworkSupportOptionsComponent(FrameworkSupportModelBase model,
LibrariesContainer container,
Disposable parentDisposable,
FrameworkSupportInModuleProvider provider,
final FrameworkSupportInModuleConfigurable configurable,
boolean inline) {
myModel = model;
myConfigurable = configurable;
LayoutManager layout = inline ? new BorderLayout() : new VerticalFlowLayout(false, true);
VerticalFlowLayout layout = new VerticalFlowLayout();
layout.setVerticalFill(true);
myMainPanel = new JPanel(layout);
myModel.registerOptionsComponent(provider, this);
List<FrameworkVersion> versions = provider.getFrameworkType().getVersions();
if (!versions.isEmpty()) {
myFrameworkVersionComponent = new FrameworkVersionComponent(model, provider.getFrameworkType().getId(), versions, provider.getVersionLabel());
if (inline) {
myMainPanel.add(myFrameworkVersionComponent.getMainPanel(), BorderLayout.WEST);
}
else {
myMainPanel.add(myFrameworkVersionComponent.getMainPanel());
}
myMainPanel.add(myFrameworkVersionComponent.getMainPanel());
}
final JComponent component = myConfigurable.createComponent(inline);
final JComponent component = myConfigurable.createComponent(false);
if (component != null) {
myMainPanel.add(component);
}