diff options
| author | Simon Rettberg | 2015-07-29 15:14:08 +0200 |
|---|---|---|
| committer | Simon Rettberg | 2015-07-29 15:14:08 +0200 |
| commit | e0ca8b7a3fd299505ad964a1d20d1631920c2a8f (patch) | |
| tree | 1975709d3e7954ed694a90813ae5a15e263d6846 /dozentenmodul/src/main/java | |
| parent | [client] Add JTable helper class ListTable (diff) | |
| download | tutor-module-e0ca8b7a3fd299505ad964a1d20d1631920c2a8f.tar.gz tutor-module-e0ca8b7a3fd299505ad964a1d20d1631920c2a8f.tar.xz tutor-module-e0ca8b7a3fd299505ad964a1d20d1631920c2a8f.zip | |
[client] ImageListWindow ported to Swing
Diffstat (limited to 'dozentenmodul/src/main/java')
6 files changed, 201 insertions, 169 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/Gui.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/Gui.java index 73585797..34c1074f 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/Gui.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/Gui.java @@ -212,6 +212,10 @@ public class Gui { * @param task Task to run */ public static void asyncExec(final Runnable task) { + if (SwingUtilities.isEventDispatchThread()) { + task.run(); + return; + } SwingUtilities.invokeLater(task); } @@ -249,8 +253,8 @@ public class Gui { * @param exception Exception related to this message. Can be null. * @return true if OK or YES was clicked, false for CANCEL/NO/(X) */ - public static boolean showMessageBox(Component parent, String message, MessageType messageType, Logger logger, - Throwable exception) { + public static boolean showMessageBox(Component parent, String message, MessageType messageType, + Logger logger, Throwable exception) { if (logger != null) logger.log(messageType.logPriority, message, exception); if (exception != null) @@ -260,8 +264,7 @@ public class Gui { JOptionPane.showMessageDialog(parent, message, messageType.title, messageType.optionPaneId); return true; } - int ret = JOptionPane.showConfirmDialog(parent, message, messageType.title, messageType.buttons - , + int ret = JOptionPane.showConfirmDialog(parent, message, messageType.title, messageType.buttons, messageType.optionPaneId); return ret == JOptionPane.OK_OPTION || ret == JOptionPane.YES_OPTION; } diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java index 496c1e25..035cea60 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java @@ -27,6 +27,7 @@ import org.openslx.dozmod.gui.Gui.GuiCallable; import org.openslx.dozmod.gui.helper.CompositePage; import org.openslx.dozmod.gui.helper.MessageType; import org.openslx.dozmod.gui.window.DisclaimerWindow; +import org.openslx.dozmod.gui.window.LectureListWindow; import org.openslx.dozmod.gui.window.LoginWindow; import org.openslx.dozmod.gui.window.MainMenuWindow; import org.openslx.dozmod.gui.window.VirtualizerNoticeWindow; @@ -39,7 +40,7 @@ public abstract class MainWindow { private final static Logger LOGGER = Logger.getLogger(MainWindow.class); - private static final JFrame mainWindow = new JFrame("bwLehrstuhl"); + private static final JFrame mainWindow; private static final JPanel mainContainer = new JPanel(); private static CompositePage currentPage; @@ -79,6 +80,16 @@ public abstract class MainWindow { Gui.centerShellOverShell(mainWindow, shell); } + static { + JFrame ret = Gui.syncExec(new GuiCallable<JFrame>() { + @Override + public JFrame run() { + return new JFrame("bwLehrstuhl"); + } + }); + mainWindow = ret; + } + /** * Initializes the GUI by creating the main window, adding the menu and * creating the login mask as the first content window. @@ -151,7 +162,7 @@ public abstract class MainWindow { // register all pages of the main window registerPage(new MainMenuWindow()); //registerPage(new ImageListWindow()); - //registerPage(new LectureListWindow()); + registerPage(new LectureListWindow()); // center the window on the primary monitor mainWindow.getContentPane().add(mainContainer, BorderLayout.CENTER); @@ -159,7 +170,7 @@ public abstract class MainWindow { Gui.centerShell(mainWindow); Gui.limitShellSize(mainWindow); - + // here we can check for Session information if (Session.getSatelliteToken() != null) { // Wait for proxy server init @@ -172,7 +183,7 @@ public abstract class MainWindow { // User did not login, show the login mask LoginWindow.open(mainWindow); } - + // Show main menu by default showPage(MainMenuWindow.class); } @@ -185,7 +196,6 @@ public abstract class MainWindow { // TODO: Only ask if an upload or download is running,, wizard is open etc.. if (Gui.showMessageBox(mainWindow, "Are you sure you want to quit?", MessageType.QUESTION_YESNO, null, null)) { - QuickTimer.cancel(); Gui.exit(0); } } diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/helper/GridPos.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/helper/GridPos.java new file mode 100644 index 00000000..6cb5bfe0 --- /dev/null +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/helper/GridPos.java @@ -0,0 +1,39 @@ +package org.openslx.dozmod.gui.helper; + +import java.awt.GridBagConstraints; +import java.awt.Insets; + +public class GridPos { + + private static final Insets inset = new Insets(0, 0, 0, 0); + + public static GridBagConstraints get(int cellX, int cellY, int spanX, int spanY, boolean fillX, + boolean fillY) { + int fill = 0, wx = 0, wy = 0; + if (fillX && fillY) { + fill = GridBagConstraints.BOTH; + wx = wy = 1; + } else if (fillX) { + fill = GridBagConstraints.HORIZONTAL; + wx = 1; + } else if (fillY) { + fill = GridBagConstraints.VERTICAL; + wy = 1; + } + return new GridBagConstraints(cellX, cellY, spanX, spanY, wx, wy, + GridBagConstraints.FIRST_LINE_START, fill, inset, 0, 0); + } + + public static GridBagConstraints get(int cellX, int cellY, int spanX, int spanY) { + return get(cellX, cellY, spanX, spanY, false, false); + } + + public static GridBagConstraints get(int cellX, int cellY, boolean fillX, boolean fillY) { + return get(cellX, cellY, 1, 1, fillX, fillY); + } + + public static GridBagConstraints get(int cellX, int cellY) { + return get(cellX, cellY, 1, 1); + } + +} diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java index f7fdff4c..66a1a321 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java @@ -1,12 +1,9 @@ package org.openslx.dozmod.gui.window; +import java.awt.Window; import java.util.List; import org.apache.log4j.Logger; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.widgets.Shell; import org.openslx.bwlp.thrift.iface.ImageDetailsRead; import org.openslx.bwlp.thrift.iface.OperatingSystem; import org.openslx.bwlp.thrift.iface.Virtualizer; @@ -32,7 +29,7 @@ public class ImageDetailsWindow extends ImageDetailsWindowLayout { private ImageDetailsRead image = null; - public ImageDetailsWindow(Shell parent) { + public ImageDetailsWindow(Window parent) { super(parent); // Close button closes window diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureListWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureListWindow.java index e45d9055..ccb12ad4 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureListWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureListWindow.java @@ -1,28 +1,27 @@ package org.openslx.dozmod.gui.window; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; import java.util.List; +import javax.swing.JTextField; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; + import org.apache.log4j.Logger; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.swt.events.KeyAdapter; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; import org.openslx.bwlp.thrift.iface.LectureSummary; +import org.openslx.dozmod.gui.Gui; import org.openslx.dozmod.gui.MainWindow; -import org.openslx.dozmod.gui.helper.LectureListComparator; -import org.openslx.dozmod.gui.helper.LectureListFilter; -import org.openslx.dozmod.gui.helper.TableHelper; import org.openslx.dozmod.gui.window.layout.LectureListWindowLayout; -import org.openslx.dozmod.gui.wizard.LectureWizard; import org.openslx.dozmod.thrift.LectureCache; import org.openslx.dozmod.thrift.UserCache; import org.openslx.dozmod.util.FormatHelper; +import org.openslx.util.QuickTimer; +import org.openslx.util.QuickTimer.Task; public class LectureListWindow extends LectureListWindowLayout { @@ -33,30 +32,28 @@ public class LectureListWindow extends LectureListWindowLayout { public LectureListWindow() { super(); - // Comparator for column sorting - LectureListComparator comparator = new LectureListComparator(); - tableViewer.setComparator(comparator); - // creating the columns with sorting functionality through comparator - TableHelper.createLectureTableColumns(tableViewer); - // filter the objects in the table depending on the search field - searchTextField.addKeyListener(new KeyAdapter() { - public void keyReleased(KeyEvent ke) { - filter.setSearchText(searchTextField.getText()); - tableViewer.refresh(); + searchTextField.getDocument().addDocumentListener(new DocumentListener() { + @Override + public void removeUpdate(DocumentEvent e) { + changedUpdate(e); } - }); - // apply object filtering - filter = new LectureListFilter(); - tableViewer.addFilter(filter); + @Override + public void insertUpdate(DocumentEvent e) { + changedUpdate(e); + } - // the listeners to set the detailed info of the selected lecture - tableViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override - public void selectionChanged(SelectionChangedEvent event) { - IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection(); - LectureSummary lecture = (LectureSummary) selection.getFirstElement(); + public void changedUpdate(DocumentEvent e) { + // TODO: Set filter + } + }); + + lectureTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { + @Override + public void valueChanged(ListSelectionEvent e) { + final LectureSummary lecture = lectureTable.getSelectedItem(); if (lecture == null) return; // Fill detail information fields @@ -74,9 +71,11 @@ public class LectureListWindow extends LectureListWindowLayout { startTime.setText(FormatHelper.longDate(lecture.getStartTime())); // set the end time of the lecture endTime.setText(FormatHelper.longDate(lecture.getEndTime())); + me.invalidate(); + me.validate(); } - private void setFieldText(Text control, String content) { + private void setFieldText(JTextField control, String content) { if (content == null) { control.setText("<null>"); } else { @@ -84,39 +83,66 @@ public class LectureListWindow extends LectureListWindowLayout { } } }); - - newButton.addSelectionListener(new SelectionAdapter() { + lectureTable.addMouseListener(new MouseAdapter() { @Override - public void widgetSelected(SelectionEvent e) { - new WizardDialog(mainShell, new LectureWizard(false)).open(); + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() == 2) { + final LectureSummary lecture = lectureTable.getSelectedItem(); + if (lecture == null) + return; + /* TODO for lecture + ImageDetailsWindow popup = new ImageDetailsWindow(SwingUtilities.windowForComponent(me)); + if (popup != null) + popup.setImage(image.getImageBaseId()); + */ + } } }); - editButton.addSelectionListener(new SelectionAdapter() { + newButton.addActionListener(new ActionListener() { @Override - public void widgetSelected(SelectionEvent e) { + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + } + }); + editButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub } }); // delete lecture - deleteButton.addSelectionListener(new SelectionAdapter() { + deleteButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + } }); // return to mainMenu - backButton.addSelectionListener(new SelectionAdapter() { + backButton.addActionListener(new ActionListener() { @Override - public void widgetSelected(SelectionEvent e) { + public void actionPerformed(ActionEvent e) { MainWindow.showPage(MainMenuWindow.class); } }); } - private boolean refreshList() { - List<LectureSummary> lectureList = LectureCache.get(false); - tableViewer.setInput(lectureList); - tableViewer.refresh(); - return true; + private void refreshList() { + QuickTimer.scheduleOnce(new Task() { + @Override + public void fire() { + final List<LectureSummary> lectureList = LectureCache.get(false); + Gui.asyncExec(new Runnable() { + @Override + public void run() { + lectureTable.setData(lectureList); + } + }); + } + }); } @Override diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureListWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureListWindowLayout.java index 14708376..d7e9782a 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureListWindowLayout.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureListWindowLayout.java @@ -1,34 +1,32 @@ package org.openslx.dozmod.gui.window.layout; -import java.awt.Button; -import java.awt.Composite; +import java.awt.Dimension; import java.awt.Font; import java.awt.GridBagLayout; -import java.awt.GridLayout; -import java.awt.Label; -import java.security.acl.Group; import javax.swing.BoxLayout; import javax.swing.JButton; +import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.JScrollPane; import javax.swing.JTextField; import javax.swing.border.TitledBorder; -import org.openslx.dozmod.gui.Gui; import org.openslx.dozmod.gui.control.table.LectureTable; import org.openslx.dozmod.gui.helper.CompositePage; +import org.openslx.dozmod.gui.helper.GridPos; import org.openslx.dozmod.gui.helper.LectureListFilter; public abstract class LectureListWindowLayout extends CompositePage { - protected String infoTitleString = "Übersicht Veranstaltungen"; - protected String newButtonLabel = "Neu"; - protected String editButtonLabel = "Bearbeiten"; - protected String deleteButtonLabel = "Löschen"; - protected String backButtonLabel = "Zurück"; - protected String tableGroupLabel = "Veranstaltungen"; - protected String vmInfoGroupLabel = "Detailinformationen"; - protected String filterGroupLabel = "Filter"; + private static final String infoTitleString = "Übersicht Veranstaltungen"; + private static final String newButtonLabel = "Neu"; + private static final String editButtonLabel = "Bearbeiten"; + private static final String deleteButtonLabel = "Löschen"; + private static final String backButtonLabel = "Zurück"; + private static final String tableGroupLabel = "Veranstaltungen"; + private static final String vmInfoGroupLabel = "Detailinformationen"; + private static final String infoTextString = "Hier können Sie Veranstaltungen anlegen, bearbeiten und löschen."; // buttons protected JButton newButton; @@ -51,123 +49,82 @@ public abstract class LectureListWindowLayout extends CompositePage { protected final LectureTable lectureTable; protected LectureListFilter filter; - protected String infoTextString = "Hier können Sie Veranstaltungen anlegen, bearbeiten und löschen."; - public LectureListWindowLayout() { super(new GridBagLayout()); // -- info group with title and text -- JPanel infoComposite = new JPanel(); infoComposite.setLayout(new BoxLayout(infoComposite, BoxLayout.PAGE_AXIS)); - infoComposite.setBorder(new TitledBorder(infoTitleString)); - - infoComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1)); - // layout for the items of the group - infoComposite.setLayout(new GridLayout(1, false)); - // title of the info group in bold - Label infoTitle = new Label(infoComposite, SWT.NONE); - infoTitle.setText(infoTitleString); - // set the fond - FontData fontData = infoTitle.getFont().getFontData()[0]; - final Font titleFont = new Font(Gui.display, new FontData(fontData.getName(), fontData.getHeight(), - SWT.BOLD)); - infoTitle.setFont(titleFont); + JLabel infoTitle = new JLabel(infoTitleString); + infoTitle.setFont(infoTitle.getFont().deriveFont(Font.BOLD)); // the infotext - Label infoText = new Label(infoComposite, SWT.NONE); - infoText.setText(infoTextString); + JLabel infoText = new JLabel(infoTextString); + infoComposite.add(infoTitle); + infoComposite.add(infoText); // -- end group of title -- // -- group for the table -- - Group tableGroup = new Group(this, SWT.BORDER); - tableGroup.setText(tableGroupLabel); - GridData tgLayoutData = new GridData(SWT.FILL, SWT.FILL, true, true); - tgLayoutData.minimumWidth = 400; - tgLayoutData.widthHint = 800; - tableGroup.setLayoutData(tgLayoutData); - tableGroup.setLayout(new GridLayout()); - - // -- group for the filter -- - Group filterGroup = new Group(tableGroup, SWT.BORDER); - filterGroup.setText(filterGroupLabel); - GridData fgGridData = new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1); - fgGridData.minimumWidth = 400; - fgGridData.widthHint = 800; - filterGroup.setLayoutData(fgGridData); - filterGroup.setLayout(new GridLayout()); - + JPanel tableGroup = new JPanel(); + tableGroup.setBorder(new TitledBorder(tableGroupLabel)); + tableGroup.setLayout(new GridBagLayout()); + tableGroup.setMinimumSize(new Dimension(800, 600)); + tableGroup.setPreferredSize(tableGroup.getMinimumSize()); // filter text field - searchTextField = new Text(filterGroup, SWT.BORDER); - searchTextField.setMessage("Name, Verantwortlicher"); - // -- end group of filter -- - + searchTextField = new JTextField(); + tableGroup.add(searchTextField, GridPos.get(0, 0, true, false)); // table - Table vmTable = new Table(tableGroup, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); - GridData tableGridData = new GridData(SWT.FILL, SWT.FILL, true, true); - vmTable.setLayoutData(tableGridData); - vmTable.setHeaderVisible(true); - vmTable.setLinesVisible(true); - - // TableViewer on the table - tableViewer = new TableViewer(vmTable); - tableViewer.setContentProvider(ArrayContentProvider.getInstance()); + lectureTable = new LectureTable(); + tableGroup.add(new JScrollPane(lectureTable), GridPos.get(0, 1, true, true)); // create, modify and delete buttons - Composite buttonComposite = new Composite(tableGroup, SWT.NONE); - GridData buttonCompositeGridData = new GridData(SWT.FILL, SWT.FILL, true, false); - buttonCompositeGridData.minimumWidth = 200; - buttonComposite.setLayoutData(buttonCompositeGridData); - buttonComposite.setLayout(new RowLayout()); - - newButton = new Button(buttonComposite, SWT.PUSH); - newButton.setText(newButtonLabel); - - editButton = new Button(buttonComposite, SWT.PUSH); - editButton.setText(editButtonLabel); - - deleteButton = new Button(buttonComposite, SWT.PUSH); - deleteButton.setText(deleteButtonLabel); - - backButton = new Button(buttonComposite, SWT.PUSH); - backButton.setText(backButtonLabel); + JPanel buttonComposite = new JPanel(); + buttonComposite.setLayout(new BoxLayout(buttonComposite, BoxLayout.LINE_AXIS)); + tableGroup.add(buttonComposite, GridPos.get(0, 2, true, false)); + + newButton = new JButton(newButtonLabel); + buttonComposite.add(newButton); + editButton = new JButton(editButtonLabel); + buttonComposite.add(editButton); + deleteButton = new JButton(deleteButtonLabel); + buttonComposite.add(deleteButton); + backButton = new JButton(backButtonLabel); + buttonComposite.add(backButton); // -- end group for table -- // -- group for details of selected lecture -- - final Group vmInfoGroup = new Group(this, SWT.BORDER); - vmInfoGroup.setText(vmInfoGroupLabel); - final GridData igGridData = new GridData(SWT.FILL, SWT.FILL, true, false); - igGridData.widthHint = 300; - vmInfoGroup.setLayoutData(igGridData); - vmInfoGroup.setLayout(new GridLayout(2, false)); - + final JPanel vmInfoGroup = new JPanel(); + vmInfoGroup.setLayout(new GridBagLayout()); + vmInfoGroup.setBorder(new TitledBorder(vmInfoGroupLabel)); + vmInfoGroup.setMaximumSize(new Dimension(400, Integer.MAX_VALUE)); + vmInfoGroup.setMinimumSize(new Dimension(350, 0)); + vmInfoGroup.setPreferredSize(vmInfoGroup.getMinimumSize()); // image name info - lectureName = createCaptionAndTextfield("Name:", vmInfoGroup); - idInfo = createCaptionAndTextfield("Id:", vmInfoGroup); - imageBaseId = createCaptionAndTextfield("Image Id:", vmInfoGroup); - lastusedInfo = createCaptionAndTextfield("Zuletzt genutzt:", vmInfoGroup); - permissionInfo = createCaptionAndTextfield("Berechtigungen:", vmInfoGroup); - startTime = createCaptionAndTextfield("Startzeit:", vmInfoGroup); - endTime = createCaptionAndTextfield("Endzeit:", vmInfoGroup); - ownerInfo = createCaptionAndTextfield("Besitzer:", vmInfoGroup); + int row = 0; + lectureName = createCaptionAndTextfield("Name", vmInfoGroup, row++); + idInfo = createCaptionAndTextfield("UUID", vmInfoGroup, row++); + imageBaseId = createCaptionAndTextfield("Image", vmInfoGroup, row++); + lastusedInfo = createCaptionAndTextfield("Zuletzt genutzt", vmInfoGroup, row++); + permissionInfo = createCaptionAndTextfield("Berechtigungen", vmInfoGroup, row++); + startTime = createCaptionAndTextfield("Startzeit", vmInfoGroup, row++); + endTime = createCaptionAndTextfield("Endzeit", vmInfoGroup, row++); + ownerInfo = createCaptionAndTextfield("Besitzer", vmInfoGroup, row++); + // For some reason without this the controls above are centered vertically + vmInfoGroup.add(new JPanel(), GridPos.get(0, row++, 2, 1, true, true)); // -- end group of details -- - // Dispose of stuff we allocated - this.addDisposeListener(new DisposeListener() { - @Override - public void widgetDisposed(DisposeEvent e) { - titleFont.dispose(); - } - }); + add(infoComposite, GridPos.get(0, 0, 2, 1, true, false)); + add(tableGroup, GridPos.get(0, 1, true, true)); + add(vmInfoGroup, GridPos.get(1, 1, false, true)); } - public Text createCaptionAndTextfield(String captionString, Group group) { - Label caption = new Label(group, SWT.NONE); - Text textField = new Text(group, SWT.READ_ONLY); + public JTextField createCaptionAndTextfield(String captionString, JPanel group, int row) { + JLabel caption = new JLabel(captionString); + JTextField textField = new JTextField(); + textField.setEditable(false); caption.setText(captionString); - caption.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); - GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false); - gridData.minimumWidth = 180; - textField.setLayoutData(gridData); + group.add(caption, GridPos.get(0, row)); + group.add(textField, GridPos.get(1, row, true, false)); return textField; } |
