List of usage examples for org.eclipse.swt.widgets Label Label
public Label(Composite parent, int style)
From source file:org.eclipse.swt.examples.controlexample.MenuTab.java
/** * Creates the "Control" widget children. *//*from ww w.j av a 2s . com*/ @Override void createControlWidgets() { /* Create the menu style buttons */ barButton = new Button(styleGroup, SWT.CHECK); barButton.setText("SWT.BAR"); dropDownButton = new Button(styleGroup, SWT.CHECK); dropDownButton.setText("SWT.DROP_DOWN"); popUpButton = new Button(styleGroup, SWT.CHECK); popUpButton.setText("SWT.POP_UP"); noRadioGroupButton = new Button(styleGroup, SWT.CHECK); noRadioGroupButton.setText("SWT.NO_RADIO_GROUP"); leftToRightButton = new Button(styleGroup, SWT.RADIO); leftToRightButton.setText("SWT.LEFT_TO_RIGHT"); leftToRightButton.setSelection(true); rightToLeftButton = new Button(styleGroup, SWT.RADIO); rightToLeftButton.setText("SWT.RIGHT_TO_LEFT"); /* Create the menu item style buttons */ cascadeButton = new Button(menuItemStyleGroup, SWT.CHECK); cascadeButton.setText("SWT.CASCADE"); checkButton = new Button(menuItemStyleGroup, SWT.CHECK); checkButton.setText("SWT.CHECK"); pushButton = new Button(menuItemStyleGroup, SWT.CHECK); pushButton.setText("SWT.PUSH"); radioButton = new Button(menuItemStyleGroup, SWT.CHECK); radioButton.setText("SWT.RADIO"); separatorButton = new Button(menuItemStyleGroup, SWT.CHECK); separatorButton.setText("SWT.SEPARATOR"); /* Create the 'other' buttons */ enabledButton = new Button(otherGroup, SWT.CHECK); enabledButton.setText(ControlExample.getResourceString("Enabled")); enabledButton.setSelection(true); imagesButton = new Button(otherGroup, SWT.CHECK); imagesButton.setText(ControlExample.getResourceString("Images")); acceleratorsButton = new Button(otherGroup, SWT.CHECK); acceleratorsButton.setText(ControlExample.getResourceString("Accelerators")); mnemonicsButton = new Button(otherGroup, SWT.CHECK); mnemonicsButton.setText(ControlExample.getResourceString("Mnemonics")); subMenuButton = new Button(otherGroup, SWT.CHECK); subMenuButton.setText(ControlExample.getResourceString("SubMenu")); subSubMenuButton = new Button(otherGroup, SWT.CHECK); subSubMenuButton.setText(ControlExample.getResourceString("SubSubMenu")); tooltipButton = new Button(otherGroup, SWT.CHECK); tooltipButton.setText(ControlExample.getResourceString("Show_Tooltip")); /* Create the "create" and "closeAll" buttons (and a 'filler' label to place them) */ new Label(controlGroup, SWT.NONE); createButton = new Button(controlGroup, SWT.NONE); createButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); createButton.setText(ControlExample.getResourceString("Create_Shell")); closeAllButton = new Button(controlGroup, SWT.NONE); closeAllButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); closeAllButton.setText(ControlExample.getResourceString("Close_All_Shells")); /* Add the listeners */ createButton.addSelectionListener(widgetSelectedAdapter(e -> createButtonSelected(e))); closeAllButton.addSelectionListener(widgetSelectedAdapter(e -> closeAllShells())); subMenuButton.addSelectionListener( widgetSelectedAdapter(e -> subSubMenuButton.setEnabled(subMenuButton.getSelection()))); /* Set the default state */ barButton.setSelection(true); dropDownButton.setSelection(true); popUpButton.setSelection(true); cascadeButton.setSelection(true); checkButton.setSelection(true); pushButton.setSelection(true); radioButton.setSelection(true); separatorButton.setSelection(true); subSubMenuButton.setEnabled(subMenuButton.getSelection()); }
From source file:SWTTextEditor.java
public void open() { Shell parent = getParent();// w ww.j a v a 2 s . c om final Shell dialog = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); dialog.setSize(200, 100); dialog.setText("About"); final Label l = new Label(dialog, SWT.NONE); l.setText("An SWT Text Editor"); l.setBounds(43, 20, 100, 20); Button b = new Button(dialog, SWT.PUSH | SWT.BORDER); b.setText("OK"); b.setBounds(80, 45, 40, 25); b.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { dialog.dispose(); } }); dialog.open(); Display display = parent.getDisplay(); while (!dialog.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } }
From source file:org.eclipse.swt.examples.browserexample.BrowserExample.java
void show(boolean owned, Point location, Point size, boolean addressBar, boolean menuBar, boolean statusBar, boolean toolBar) { final Shell shell = browser.getShell(); if (owned) {/*from w ww .j av a 2 s. c o m*/ if (location != null) shell.setLocation(location); if (size != null) shell.setSize(shell.computeSize(size.x, size.y)); } FormData data = null; if (toolBar) { toolbar = new ToolBar(parent, SWT.NONE); data = new FormData(); data.top = new FormAttachment(0, 5); toolbar.setLayoutData(data); itemBack = new ToolItem(toolbar, SWT.PUSH); itemBack.setText(getResourceString("Back")); itemForward = new ToolItem(toolbar, SWT.PUSH); itemForward.setText(getResourceString("Forward")); final ToolItem itemStop = new ToolItem(toolbar, SWT.PUSH); itemStop.setText(getResourceString("Stop")); final ToolItem itemRefresh = new ToolItem(toolbar, SWT.PUSH); itemRefresh.setText(getResourceString("Refresh")); final ToolItem itemGo = new ToolItem(toolbar, SWT.PUSH); itemGo.setText(getResourceString("Go")); itemBack.setEnabled(browser.isBackEnabled()); itemForward.setEnabled(browser.isForwardEnabled()); Listener listener = event -> { ToolItem item = (ToolItem) event.widget; if (item == itemBack) browser.back(); else if (item == itemForward) browser.forward(); else if (item == itemStop) browser.stop(); else if (item == itemRefresh) browser.refresh(); else if (item == itemGo) browser.setUrl(locationBar.getText()); }; itemBack.addListener(SWT.Selection, listener); itemForward.addListener(SWT.Selection, listener); itemStop.addListener(SWT.Selection, listener); itemRefresh.addListener(SWT.Selection, listener); itemGo.addListener(SWT.Selection, listener); canvas = new Canvas(parent, SWT.NO_BACKGROUND); data = new FormData(); data.width = 24; data.height = 24; data.top = new FormAttachment(0, 5); data.right = new FormAttachment(100, -5); canvas.setLayoutData(data); final Rectangle rect = images[0].getBounds(); canvas.addListener(SWT.Paint, e -> { Point pt = ((Canvas) e.widget).getSize(); e.gc.drawImage(images[index], 0, 0, rect.width, rect.height, 0, 0, pt.x, pt.y); }); canvas.addListener(SWT.MouseDown, e -> browser.setUrl(getResourceString("Startup"))); final Display display = parent.getDisplay(); display.asyncExec(new Runnable() { @Override public void run() { if (canvas.isDisposed()) return; if (busy) { index++; if (index == images.length) index = 0; canvas.redraw(); } display.timerExec(150, this); } }); } if (addressBar) { locationBar = new Text(parent, SWT.BORDER); data = new FormData(); if (toolbar != null) { data.top = new FormAttachment(toolbar, 0, SWT.TOP); data.left = new FormAttachment(toolbar, 5, SWT.RIGHT); data.right = new FormAttachment(canvas, -5, SWT.DEFAULT); } else { data.top = new FormAttachment(0, 0); data.left = new FormAttachment(0, 0); data.right = new FormAttachment(100, 0); } locationBar.setLayoutData(data); locationBar.addListener(SWT.DefaultSelection, e -> browser.setUrl(locationBar.getText())); } if (statusBar) { status = new Label(parent, SWT.NONE); progressBar = new ProgressBar(parent, SWT.NONE); data = new FormData(); data.left = new FormAttachment(0, 5); data.right = new FormAttachment(progressBar, 0, SWT.DEFAULT); data.bottom = new FormAttachment(100, -5); status.setLayoutData(data); data = new FormData(); data.right = new FormAttachment(100, -5); data.bottom = new FormAttachment(100, -5); progressBar.setLayoutData(data); browser.addStatusTextListener(event -> status.setText(event.text)); } parent.setLayout(new FormLayout()); Control aboveBrowser = toolBar ? (Control) canvas : (addressBar ? (Control) locationBar : null); data = new FormData(); data.left = new FormAttachment(0, 0); data.top = aboveBrowser != null ? new FormAttachment(aboveBrowser, 5, SWT.DEFAULT) : new FormAttachment(0, 0); data.right = new FormAttachment(100, 0); data.bottom = status != null ? new FormAttachment(status, -5, SWT.DEFAULT) : new FormAttachment(100, 0); browser.setLayoutData(data); if (statusBar || toolBar) { browser.addProgressListener(new ProgressListener() { @Override public void changed(ProgressEvent event) { if (event.total == 0) return; int ratio = event.current * 100 / event.total; if (progressBar != null) progressBar.setSelection(ratio); busy = event.current != event.total; if (!busy) { index = 0; if (canvas != null) canvas.redraw(); } } @Override public void completed(ProgressEvent event) { if (progressBar != null) progressBar.setSelection(0); busy = false; index = 0; if (canvas != null) { itemBack.setEnabled(browser.isBackEnabled()); itemForward.setEnabled(browser.isForwardEnabled()); canvas.redraw(); } } }); } if (addressBar || statusBar || toolBar) { browser.addLocationListener(LocationListener.changedAdapter(event -> { busy = true; if (event.top && locationBar != null) locationBar.setText(event.location); })); } if (title) { browser.addTitleListener( event -> shell.setText(event.title + " - " + getResourceString("window.title"))); } parent.layout(true); if (owned) shell.open(); }
From source file:AddressBook.java
/** * Creates the page contents/* w w w . j a va 2s.c om*/ * * @param parent * the parent composite */ public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new FillLayout(SWT.VERTICAL)); new Label(composite, SWT.CENTER).setText("Welcome to the Address Book Entry Wizard!"); new Label(composite, SWT.LEFT).setText("This wizard guides you through creating an Address Book entry."); new Label(composite, SWT.LEFT).setText("Click Next to continue."); setControl(composite); }
From source file:SWTBrowserDemo.java
void show(boolean owned, Point location, Point size, boolean addressBar, boolean menuBar, boolean statusBar, boolean toolBar) { final Shell shell = browser.getShell(); if (owned) {/*from w ww. j a va 2 s. c o m*/ if (location != null) shell.setLocation(location); if (size != null) shell.setSize(shell.computeSize(size.x, size.y)); } FormData data = null; if (toolBar) { toolbar = new ToolBar(parent, SWT.NONE); data = new FormData(); data.top = new FormAttachment(0, 5); toolbar.setLayoutData(data); itemBack = new ToolItem(toolbar, SWT.PUSH); itemBack.setText(getResourceString("Back")); itemForward = new ToolItem(toolbar, SWT.PUSH); itemForward.setText(getResourceString("Forward")); final ToolItem itemStop = new ToolItem(toolbar, SWT.PUSH); itemStop.setText(getResourceString("Stop")); final ToolItem itemRefresh = new ToolItem(toolbar, SWT.PUSH); itemRefresh.setText(getResourceString("Refresh")); final ToolItem itemGo = new ToolItem(toolbar, SWT.PUSH); itemGo.setText(getResourceString("Go")); itemBack.setEnabled(browser.isBackEnabled()); itemForward.setEnabled(browser.isForwardEnabled()); Listener listener = new Listener() { public void handleEvent(Event event) { ToolItem item = (ToolItem) event.widget; if (item == itemBack) browser.back(); else if (item == itemForward) browser.forward(); else if (item == itemStop) browser.stop(); else if (item == itemRefresh) browser.refresh(); else if (item == itemGo) browser.setUrl(locationBar.getText()); } }; itemBack.addListener(SWT.Selection, listener); itemForward.addListener(SWT.Selection, listener); itemStop.addListener(SWT.Selection, listener); itemRefresh.addListener(SWT.Selection, listener); itemGo.addListener(SWT.Selection, listener); canvas = new Canvas(parent, SWT.NO_BACKGROUND); data = new FormData(); data.width = 24; data.height = 24; data.top = new FormAttachment(0, 5); data.right = new FormAttachment(100, -5); canvas.setLayoutData(data); final Rectangle rect = images[0].getBounds(); canvas.addListener(SWT.Paint, new Listener() { public void handleEvent(Event e) { Point pt = ((Canvas) e.widget).getSize(); e.gc.drawImage(images[index], 0, 0, rect.width, rect.height, 0, 0, pt.x, pt.y); } }); canvas.addListener(SWT.MouseDown, new Listener() { public void handleEvent(Event e) { browser.setUrl(getResourceString("Startup")); } }); final Display display = parent.getDisplay(); display.asyncExec(new Runnable() { public void run() { if (canvas.isDisposed()) return; if (busy) { index++; if (index == images.length) index = 0; canvas.redraw(); } display.timerExec(150, this); } }); } if (addressBar) { locationBar = new Text(parent, SWT.BORDER); data = new FormData(); if (toolbar != null) { data.top = new FormAttachment(toolbar, 0, SWT.TOP); data.left = new FormAttachment(toolbar, 5, SWT.RIGHT); data.right = new FormAttachment(canvas, -5, SWT.DEFAULT); } else { data.top = new FormAttachment(0, 0); data.left = new FormAttachment(0, 0); data.right = new FormAttachment(100, 0); } locationBar.setLayoutData(data); locationBar.addListener(SWT.DefaultSelection, new Listener() { public void handleEvent(Event e) { browser.setUrl(locationBar.getText()); } }); } if (statusBar) { status = new Label(parent, SWT.NONE); progressBar = new ProgressBar(parent, SWT.NONE); data = new FormData(); data.left = new FormAttachment(0, 5); data.right = new FormAttachment(progressBar, 0, SWT.DEFAULT); data.bottom = new FormAttachment(100, -5); status.setLayoutData(data); data = new FormData(); data.right = new FormAttachment(100, -5); data.bottom = new FormAttachment(100, -5); progressBar.setLayoutData(data); browser.addStatusTextListener(new StatusTextListener() { public void changed(StatusTextEvent event) { status.setText(event.text); } }); } parent.setLayout(new FormLayout()); Control aboveBrowser = toolBar ? (Control) canvas : (addressBar ? (Control) locationBar : null); data = new FormData(); data.left = new FormAttachment(0, 0); data.top = aboveBrowser != null ? new FormAttachment(aboveBrowser, 5, SWT.DEFAULT) : new FormAttachment(0, 0); data.right = new FormAttachment(100, 0); data.bottom = status != null ? new FormAttachment(status, -5, SWT.DEFAULT) : new FormAttachment(100, 0); browser.setLayoutData(data); if (statusBar || toolBar) { browser.addProgressListener(new ProgressListener() { public void changed(ProgressEvent event) { if (event.total == 0) return; int ratio = event.current * 100 / event.total; if (progressBar != null) progressBar.setSelection(ratio); busy = event.current != event.total; if (!busy) { index = 0; if (canvas != null) canvas.redraw(); } } public void completed(ProgressEvent event) { if (progressBar != null) progressBar.setSelection(0); busy = false; index = 0; if (canvas != null) { itemBack.setEnabled(browser.isBackEnabled()); itemForward.setEnabled(browser.isForwardEnabled()); canvas.redraw(); } } }); } if (addressBar || statusBar || toolBar) { browser.addLocationListener(new LocationListener() { public void changed(LocationEvent event) { busy = true; if (event.top && locationBar != null) locationBar.setText(event.location); } public void changing(LocationEvent event) { } }); } if (title) { browser.addTitleListener(new TitleListener() { public void changed(TitleEvent event) { shell.setText(event.title + " - " + getResourceString("window.title")); } }); } parent.layout(true); if (owned) shell.open(); }
From source file:ReservationData.java
public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.NULL); composite.setLayout(new GridLayout(2, false)); new Label(composite, SWT.NULL).setText("Full name: "); textName = new Text(composite, SWT.SINGLE | SWT.BORDER); textName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); new Label(composite, SWT.NULL).setText("Phone Number: "); textPhone = new Text(composite, SWT.SINGLE | SWT.BORDER); textPhone.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); new Label(composite, SWT.NULL).setText("Email address: "); textEmail = new Text(composite, SWT.SINGLE | SWT.BORDER); textEmail.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); new Label(composite, SWT.NULL).setText("Address: "); textAddress = new Text(composite, SWT.MULTI | SWT.BORDER); textAddress.setText("\r\n\r\n\r\n"); textAddress.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Listener listener = new Listener() { public void handleEvent(Event event) { if (event.widget == null || !(event.widget instanceof Text)) return; String string = ((Text) event.widget).getText(); if (event.widget == textName) { ((ReservationWizard) getWizard()).data.customerName = string; } else if (event.widget == textPhone) { ((ReservationWizard) getWizard()).data.customerPhone = string; } else if (event.widget == textEmail) { if (string.indexOf('@') < 0) { setErrorMessage("Invalid email address: " + string); ((ReservationWizard) getWizard()).data.customerEmail = null; } else { setErrorMessage(null); ((ReservationWizard) getWizard()).data.customerEmail = string; }/*w w w . ja va 2 s . com*/ } else if (event.widget == textAddress) { ((ReservationWizard) getWizard()).data.customerAddress = string; } ReservationData data = ((ReservationWizard) getWizard()).data; if (data.customerName != null && data.customerPhone != null && data.customerEmail != null && data.customerAddress != null) { setPageComplete(true); } else { setPageComplete(false); } } }; textName.addListener(SWT.Modify, listener); textPhone.addListener(SWT.Modify, listener); textEmail.addListener(SWT.Modify, listener); textAddress.addListener(SWT.Modify, listener); if (getDialogSettings() != null && validDialogSettings()) { textName.setText(getDialogSettings().get(ReservationWizard.KEY_CUSTOMER_NAME)); textPhone.setText(getDialogSettings().get(ReservationWizard.KEY_CUSTOMER_PHONE)); textEmail.setText(getDialogSettings().get(ReservationWizard.KEY_CUSTOMER_EMAIL)); textAddress.setText(getDialogSettings().get(ReservationWizard.KEY_CUSTOMER_ADDRESS)); } setControl(composite); }
From source file:org.eclipse.swt.examples.ole.win32.OleBrowserView.java
/** * Creates Web browser control.// w ww. j a va 2 s .c o m */ private void createBrowserControl() { try { // Create an Automation object for access to extended capabilities webControlSite = new OleControlSite(webFrame, SWT.NONE, "Shell.Explorer"); Variant download = new Variant(DLCTL_NO_SCRIPTS); webControlSite.setSiteProperty(DISPID_AMBIENT_DLCONTROL, download); OleAutomation oleAutomation = new OleAutomation(webControlSite); webBrowser = new OleWebBrowser(oleAutomation); } catch (SWTException ex) { // Creation may have failed because control is not installed on machine Label label = new Label(webFrame, SWT.BORDER); OlePlugin.logError(OlePlugin.getResourceString("error.CouldNotCreateBrowserControl"), ex); label.setText(OlePlugin.getResourceString("error.CouldNotCreateBrowserControl")); return; } // Respond to ProgressChange events by updating the Progress bar webControlSite.addEventListener(OleWebBrowser.ProgressChange, event -> { Variant progress = event.arguments[0]; Variant maxProgress = event.arguments[1]; if (progress == null || maxProgress == null) return; webProgress.setMaximum(maxProgress.getInt()); webProgress.setSelection(progress.getInt()); }); // Respond to StatusTextChange events by updating the Status Text label webControlSite.addEventListener(OleWebBrowser.StatusTextChange, event -> { Variant statusText = event.arguments[0]; if (statusText == null) return; String text = statusText.getString(); if (text != null) webStatus.setText(text); }); // Listen for changes to the ready state and print out the current state webControlSite.addPropertyListener(OleWebBrowser.DISPID_READYSTATE, event -> { if (event.detail == OLE.PROPERTY_CHANGING) return; int state = webBrowser.getReadyState(); switch (state) { case OleWebBrowser.READYSTATE_UNINITIALIZED: webStatus.setText(OlePlugin.getResourceString("browser.State.Uninitialized.text")); webCommandBackward.setEnabled(false); webCommandForward.setEnabled(false); webCommandHome.setEnabled(false); webCommandRefresh.setEnabled(false); webCommandStop.setEnabled(false); webCommandSearch.setEnabled(false); break; case OleWebBrowser.READYSTATE_LOADING: webStatus.setText(OlePlugin.getResourceString("browser.State.Loading.text")); webCommandHome.setEnabled(true); webCommandRefresh.setEnabled(true); webCommandStop.setEnabled(true); webCommandSearch.setEnabled(true); break; case OleWebBrowser.READYSTATE_LOADED: webStatus.setText(OlePlugin.getResourceString("browser.State.Loaded.text")); webCommandStop.setEnabled(true); break; case OleWebBrowser.READYSTATE_INTERACTIVE: webStatus.setText(OlePlugin.getResourceString("browser.State.Interactive.text")); webCommandStop.setEnabled(true); break; case OleWebBrowser.READYSTATE_COMPLETE: webStatus.setText(OlePlugin.getResourceString("browser.State.Complete.text")); webCommandStop.setEnabled(false); break; } }); // Listen for changes to the active command states webControlSite.addEventListener(OleWebBrowser.CommandStateChange, event -> { if (event.type != OleWebBrowser.CommandStateChange) return; final int commandID = (event.arguments[0] != null) ? event.arguments[0].getInt() : 0; final boolean commandEnabled = (event.arguments[1] != null) ? event.arguments[1].getBoolean() : false; switch (commandID) { case OleWebBrowser.CSC_NAVIGATEBACK: webCommandBackward.setEnabled(commandEnabled); break; case OleWebBrowser.CSC_NAVIGATEFORWARD: webCommandForward.setEnabled(commandEnabled); break; } }); // in place activate the ActiveX control activated = (webControlSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE) == OLE.S_OK); if (activated) webBrowser.GoHome(); }
From source file:SWTFileViewerDemo.java
/** * Construct the UI/* w w w. j ava 2s . c om*/ * * @param container * the ShellContainer managing the Shell we are rendering inside */ private void createShellContents() { shell.setText(getResourceString("Title", new Object[] { "" })); shell.setImage(iconCache.stockImages[iconCache.shellIcon]); Menu bar = new Menu(shell, SWT.BAR); shell.setMenuBar(bar); createFileMenu(bar); createHelpMenu(bar); GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 3; gridLayout.marginHeight = gridLayout.marginWidth = 0; shell.setLayout(gridLayout); GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gridData.widthHint = 185; createComboView(shell, gridData); gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gridData.horizontalSpan = 2; createToolBar(shell, gridData); SashForm sashForm = new SashForm(shell, SWT.NONE); sashForm.setOrientation(SWT.HORIZONTAL); gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL); gridData.horizontalSpan = 3; sashForm.setLayoutData(gridData); createTreeView(sashForm); createTableView(sashForm); sashForm.setWeights(new int[] { 2, 5 }); numObjectsLabel = new Label(shell, SWT.BORDER); gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL); gridData.widthHint = 185; numObjectsLabel.setLayoutData(gridData); diskSpaceLabel = new Label(shell, SWT.BORDER); gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL); gridData.horizontalSpan = 2; diskSpaceLabel.setLayoutData(gridData); }
From source file:at.ac.tuwien.inso.subcat.ui.widgets.TrendView.java
public void addConfiguration(TrendChartConfigData config) { assert (config != null); LinkedList<Combo> combos = new LinkedList<Combo>(); // Title Row: Label lblGrpTitle = new Label(optionComposite, SWT.NONE); lblGrpTitle.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); Helper.setLabelStyle(lblGrpTitle, SWT.BOLD); lblGrpTitle.setText(config.getName()); Composite topOptions = new Composite(optionComposite, SWT.NONE); topOptions.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); topOptions.setLayout(new GridLayout(config.getDropDowns().size(), true)); for (DropDownData dropData : config.getDropDowns()) { Combo comboDropDown = new Combo(topOptions, SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY); comboDropDown.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1)); comboDropDown.setData(dropData); combos.add(comboDropDown);/* w w w. j ava 2s. c o m*/ for (DropDownData.Pair data : dropData.getData()) { comboDropDown.add(data.name); } comboDropDown.select(0); comboDropDown.addSelectionListener(this.comboListener); } // Separator: Helper.separator(optionComposite, 3); // Left Option Labels: new Label(optionComposite, SWT.NONE); Composite leftOptions = new Composite(optionComposite, SWT.NONE); leftOptions.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); leftOptions.setLayout(new GridLayout(1, true)); for (OptionListConfigData.Pair pair : config.getOptionList().getData()) { Label lblOpt = new Label(leftOptions, SWT.NONE); lblOpt.setText(pair.name); } // Check Boxes: Composite selectionComposite = new Composite(optionComposite, SWT.NONE); selectionComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); selectionComposite.setLayout(new GridLayout(combos.size(), true)); OptionListConfig leftConfig = config.getOptionList().getConfig(); int x = 0; for (Combo combo : combos) { TrendChartPlotConfig topConfig = (TrendChartPlotConfig) config.getDropDowns().get(x).getConfig(); for (OptionListConfigData.Pair pair : config.getOptionList().getData()) { Button button = new Button(selectionComposite, SWT.CHECK); button.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1)); button.setData(new ChartIdentifier(topConfig, combo, leftConfig, pair.id, boxWeight++)); button.addSelectionListener(boxListener); } x++; } // Scrolling area size update: scrolledComposite.setMinSize(optionComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT)); }
From source file:at.ac.tuwien.inso.subcat.ui.widgets.TrendChart.java
public void addConfiguration(TrendChartConfigData config, List<String> flags) { assert (config != null); ArrayList<Combo> combos = new ArrayList<Combo>(); // Title Row: Label lblGrpTitle = new Label(optionComposite, SWT.NONE); lblGrpTitle.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); Helper.setLabelStyle(lblGrpTitle, SWT.BOLD); lblGrpTitle.setText(config.getName()); Composite topOptions = new Composite(optionComposite, SWT.NONE); topOptions.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); topOptions.setLayout(new GridLayout(config.getDropDowns().size(), true)); for (DropDownData dropData : config.getDropDowns()) { if (dropData.getConfig().show(flags)) { Combo comboDropDown = new Combo(topOptions, SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY); comboDropDown.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1)); comboDropDown.setData(dropData); combos.add(comboDropDown);//w ww. j av a 2 s .c om for (DropDownData.Pair data : dropData.getData()) { comboDropDown.add(data.name); } comboDropDown.select(0); comboDropDown.addSelectionListener(this.comboListener); } } // Separator: Helper.separator(optionComposite, 3); // Left Option Labels: new Label(optionComposite, SWT.NONE); Composite leftOptions = new Composite(optionComposite, SWT.NONE); leftOptions.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); leftOptions.setLayout(new GridLayout(1, true)); for (OptionListConfigData.Pair pair : config.getOptionList().getData()) { Label lblOpt = new Label(leftOptions, SWT.NONE); lblOpt.setText(pair.name); } // Check Boxes: Composite selectionComposite = new Composite(optionComposite, SWT.NONE); selectionComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); selectionComposite.setLayout(new GridLayout(combos.size(), true)); OptionListConfig leftConfig = config.getOptionList().getConfig(); for (OptionListConfigData.Pair pair : config.getOptionList().getData()) { int x = 0; for (Combo combo : combos) { TrendChartPlotConfig topConfig = (TrendChartPlotConfig) config.getDropDowns().get(x).getConfig(); Button button = new Button(selectionComposite, SWT.CHECK); button.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1)); button.setData(new ChartIdentifier(topConfig, combo, leftConfig, pair.id, boxWeight++)); button.addSelectionListener(boxListener); x++; } } // Scrolling area size update: scrolledComposite.setMinSize(optionComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT)); }