Commit aca4c2a4 authored by Philipp Spohr's avatar Philipp Spohr
Browse files

Added scroll bar to option panels to guarantee that run button is always visible

parent e5764cff
......@@ -33,6 +33,7 @@ import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Arrays;
import javax.swing.BorderFactory;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.Icon;
......@@ -42,7 +43,9 @@ import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.LayoutStyle;
import javax.swing.ScrollPaneConstants;
import org.cytoscape.application.swing.CytoPanelComponent;
import org.cytoscape.application.swing.CytoPanelName;
......@@ -69,6 +72,7 @@ public class MainPanel extends JPanel implements CytoPanelComponent {
//SWING COMPONENTS
private final YoshikoHeader header;
private final JButton about;
......@@ -76,6 +80,8 @@ public class MainPanel extends JPanel implements CytoPanelComponent {
private final JCheckBox showAdvancedOptions;
private final ArrayList<JComponent> advancedOptions;
private final JScrollPane scrollPane;
private final JPanel scrollableContent;
//Those two work with factories whysoever
private final BasicCollapsiblePanel langPanel;
private final BasicCollapsiblePanel libraryPanel;
......@@ -91,6 +97,8 @@ public class MainPanel extends JPanel implements CytoPanelComponent {
private final BasicCollapsiblePanel opWrapper;
private final OperationModePanel opModePanel;
private final JButton runButton;
/**
* Main constructor, creates a new Panel and initializes subcomponents
*/
......@@ -112,6 +120,11 @@ public class MainPanel extends JPanel implements CytoPanelComponent {
showAdvancedOptions = new JCheckBox(LocalizationManager.get("showAdvanced"));
showAdvancedOptions.addActionListener(toggleAdvancedOptionsListener);
scrollableContent = new JPanel();
scrollPane = new JScrollPane(scrollableContent);
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
scrollPane.setBorder(BorderFactory.createEmptyBorder());
langPanel = LanguageSwitcherPanelFactory.createLanguageSwitcherPanel();
libraryPanel = LibraryPanelFactory.createLibraryPanel();
......@@ -133,19 +146,23 @@ public class MainPanel extends JPanel implements CytoPanelComponent {
reductionRulesChooser = new ReductionRulesChooser();
reductionWrapper.add(reductionRulesChooser);
JButton runButton = new JButton(LocalizationManager.get("run"));
runButton = new JButton(LocalizationManager.get("run"));
runButton.addActionListener(buttonListener);
//Add components to main panel
SwingUtil.addAll(this,
header,
about,
showAdvancedOptions,
SwingUtil.addAll(scrollableContent,
langPanel,
libraryPanel,
ecPanelWrapper,
reductionWrapper,
opWrapper,
opWrapper
);
SwingUtil.addAll(this,
header,
about,
showAdvancedOptions,
scrollPane,
runButton
);
......@@ -160,12 +177,20 @@ public class MainPanel extends JPanel implements CytoPanelComponent {
showAdvancedOptions(false);
applyLayout();
}
private void applyLayout() {
//Layout
GroupLayout layout = new GroupLayout(this);
GroupLayout scrollLayout = new GroupLayout(scrollableContent);
layout.setAutoCreateGaps(true);
layout.setAutoCreateContainerGaps(true);
scrollLayout.setAutoCreateGaps(true);
scrollLayout.setAutoCreateContainerGaps(true);
layout.setHorizontalGroup(layout.createParallelGroup(Alignment.LEADING,true)
.addGroup(layout.createSequentialGroup()
.addComponent(header,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE)
......@@ -175,12 +200,16 @@ public class MainPanel extends JPanel implements CytoPanelComponent {
)
.addGap(4)
.addComponent(showAdvancedOptions,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE)
.addComponent(scrollPane,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE)
.addComponent(runButton,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE)
);
scrollLayout.setHorizontalGroup(scrollLayout.createParallelGroup(Alignment.LEADING,true)
.addComponent(langPanel,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE)
.addComponent(libraryPanel,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE)
.addComponent(ecPanelWrapper,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE)
.addComponent(reductionWrapper,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE)
.addComponent(opWrapper,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE)
.addComponent(runButton,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE)
);
layout.setVerticalGroup(layout.createSequentialGroup()
......@@ -190,16 +219,20 @@ public class MainPanel extends JPanel implements CytoPanelComponent {
)
.addGap(4)
.addComponent(showAdvancedOptions,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE)
.addComponent(scrollPane,DEFAULT_SIZE,DEFAULT_SIZE,DEFAULT_SIZE)
.addComponent(runButton,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE)
);
scrollLayout.setVerticalGroup(scrollLayout.createSequentialGroup()
.addComponent(langPanel,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE)
.addComponent(libraryPanel,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE)
.addComponent(ecPanelWrapper,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE)
.addComponent(reductionWrapper,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE)
.addComponent(opWrapper,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE)
.addComponent(runButton,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE)
);
this.setLayout(layout);
scrollableContent.setLayout(scrollLayout);
}
private ActionListener toggleAdvancedOptionsListener = new ActionListener() {
......@@ -293,10 +326,6 @@ public class MainPanel extends JPanel implements CytoPanelComponent {
//GETTER / SETTER
public ColumnMapper getColumnMapper() {
return ecPanel.getColumnMapper();
}
public Component getComponent() {
return this;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment