summaryrefslogtreecommitdiff
path: root/java/src/IceGridGUI/EditorBase.java
blob: 1a3bc7d82456471952cb12074f99997bc57079e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// **********************************************************************
//
// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************

package IceGridGUI;

import java.awt.BorderLayout;

import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JToolBar;

import com.jgoodies.forms.builder.DefaultFormBuilder;
import com.jgoodies.forms.factories.Borders;
import com.jgoodies.forms.layout.FormLayout;
import com.jgoodies.forms.util.LayoutStyle;

import IceGrid.*;

//
// Base class for all editors
//
public abstract class EditorBase
{
    public JComponent getProperties()
    {
        if(_propertiesPanel == null)
        {
            buildPropertiesPanel();
        }
        return _propertiesPanel;
    }

    public JToolBar getToolBar()
    {
        return null;
    }

    protected abstract void appendProperties(DefaultFormBuilder builder);

    protected void buildPropertiesPanel()
    {
        FormLayout layout = new FormLayout("right:pref, 3dlu, fill:pref:grow, 3dlu, pref", "");

        DefaultFormBuilder builder = new DefaultFormBuilder(layout);
        builder.setBorder(Borders.DLU2_BORDER);
        builder.setRowGroupingEnabled(true);
        builder.setLineGapSize(LayoutStyle.getCurrent().getLinePad());

        appendProperties(builder);

        JScrollPane scrollPane =
            new JScrollPane(builder.getPanel(),
                            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

        scrollPane.setBorder(Borders.DIALOG_BORDER);

        _propertiesPanel = new JPanel(new BorderLayout());
        _propertiesPanel.add(scrollPane, BorderLayout.CENTER);
        _propertiesPanel.setBorder(Borders.EMPTY_BORDER);
    }

    protected JPanel _propertiesPanel;
}