source: trunk/autoquest-ui-swt/src/main/java/de/ugoe/cs/autoquest/ui/swt/SWTHelpers.java @ 1275

Last change on this file since 1275 was 1275, checked in by pharms, 11 years ago
  • added some Java Docs
  • Property svn:mime-type set to text/plain
File size: 2.4 KB
RevLine 
[927]1//   Copyright 2012 Georg-August-Universität Göttingen, Germany
2//
3//   Licensed under the Apache License, Version 2.0 (the "License");
4//   you may not use this file except in compliance with the License.
5//   You may obtain a copy of the License at
6//
7//       http://www.apache.org/licenses/LICENSE-2.0
8//
9//   Unless required by applicable law or agreed to in writing, software
10//   distributed under the License is distributed on an "AS IS" BASIS,
11//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//   See the License for the specific language governing permissions and
13//   limitations under the License.
14
[922]15package de.ugoe.cs.autoquest.ui.swt;
[526]16
17import org.eclipse.swt.SWT;
18import org.eclipse.swt.widgets.List;
19import org.eclipse.swt.widgets.MessageBox;
20import org.eclipse.swt.widgets.Shell;
21
22import de.ugoe.cs.util.console.CommandExecuter;
23
[1094]24/**
[1275]25 * <p>
26 * class containing convenience methods for the SWT UI
27 * </p>
[1094]28 *
29 * @author Steffen Herbold, Patrick Harms
30 */
[526]31public class SWTHelpers {
32
[1094]33    /**
[1275]34     * deletes the objects selected in the provided list from the data store
[1094]35     */
[570]36    public static boolean deleteSelectedFromStorage(final List list) {
37        String[] selectedStrings = list.getSelection();
38        if (selectedStrings.length == 0) {
39            return false;
40        }
41        else {
42            for (String selected : selectedStrings) {
43                String command = "deleteObject " + selected;
44                CommandExecuter.getInstance().exec(command);
45            }
46            return true;
47        }
48    }
49
[1094]50    /**
[1275]51     * alerts, that no object is selected but a selection is required
[1094]52     */
[570]53    public static void noSelectionError(final Shell shell) {
54        MessageBox messageBox = new MessageBox(shell, SWT.ERROR);
[1094]55        messageBox.setMessage
56            ("No objects selected! Please select at least one object to execute this function");
[570]57        messageBox.setText("Error");
58        messageBox.open();
59    }
60
[1094]61    /**
[1275]62     * alerts, that too many objects are selected but a selection of only one is required
[1094]63     */
64    public static void moreThanOneSelectedError(final Shell shell) {
65        MessageBox messageBox = new MessageBox(shell, SWT.ERROR);
66        messageBox.setMessage("Too many objects selected for this function! Select only one!");
67        messageBox.setText("Error");
68        messageBox.open();
69    }
70
[526]71}
Note: See TracBrowser for help on using the repository browser.