public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new RowLayout()); Text text = new Text(shell, SWT.MULTI | SWT.BORDER); String modifier = SWT.MOD1 == SWT.CTRL ? "Ctrl" : "Command"; text.setText("Hit " + modifier + "+Return\nto see\nthe default button\nrun"); text.addTraverseListener( e -> { switch (e.detail) { case SWT.TRAVERSE_RETURN: if ((e.stateMask & SWT.MOD1) != 0) e.doit = true; } }); Button button = new Button(shell, SWT.PUSH); button.pack(); button.setText("OK"); button.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { System.out.println("OK selected"); } }); shell.setDefaultButton(button); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
/** * Creates a new button with the given id. * * <p>The <code>Dialog</code> implementation of this framework method creates a standard push * button, registers for selection events including button presses and registers default buttons * with its shell. The button id is stored as the buttons client data. Note that the parent's * layout is assumed to be a GridLayout and the number of columns in this layout is incremented. * Subclasses may override. * * @param parent the parent composite * @param id the id of the button (see <code>IDialogConstants.*_ID</code> constants for standard * dialog button ids) * @param label the label from the button * @param defaultButton <code>true</code> if the button is to be the default button, and <code> * false</code> otherwise */ private Button createButton( final Composite parent, final int id, final String label, final boolean defaultButton) { // increment the number of columns in the button bar ((GridLayout) parent.getLayout()).numColumns++; final Button button = new Button(parent, SWT.PUSH); button.setFont(parent.getFont()); final GridData buttonData = new GridData(GridData.FILL_HORIZONTAL); button.setLayoutData(buttonData); button.setData(Integer.valueOf(id)); button.setText(label); button.setFont(parent.getFont()); if (defaultButton) { final Shell shell = parent.getShell(); if (shell != null) { shell.setDefaultButton(button); } button.setFocus(); } button.setFont(parent.getFont()); setButtonLayoutData(button); return button; }
public void init(Shell parentShell) { shell = ShellFactory.createShell(parentShell, SWT.BORDER | SWT.TITLE | SWT.CLOSE | SWT.RESIZE); Utils.setShellIcon(shell); if (Constants.isOSX) monospace = new Font(shell.getDisplay(), "Courier", 12, SWT.NORMAL); else monospace = new Font(shell.getDisplay(), "Courier New", 8, SWT.NORMAL); shell.setText( MessageText.getString("window.welcome.title", new String[] {Constants.AZUREUS_VERSION})); display = shell.getDisplay(); GridLayout layout = new GridLayout(); shell.setLayout(layout); GridData data; cWhatsNew = new Composite(shell, SWT.BORDER); data = new GridData(GridData.FILL_BOTH); cWhatsNew.setLayoutData(data); cWhatsNew.setLayout(new FillLayout()); Button bClose = new Button(shell, SWT.PUSH); bClose.setText(MessageText.getString("Button.close")); data = new GridData(); data.widthHint = 70; data.horizontalAlignment = Constants.isOSX ? SWT.CENTER : SWT.RIGHT; bClose.setLayoutData(data); Listener closeListener = new Listener() { public void handleEvent(Event event) { close(); } }; bClose.addListener(SWT.Selection, closeListener); shell.addListener(SWT.Close, closeListener); shell.setDefaultButton(bClose); shell.addListener( SWT.Traverse, new Listener() { public void handleEvent(Event e) { if (e.character == SWT.ESC) { close(); } } }); shell.setSize(750, 500); Utils.centreWindow(shell); shell.layout(); shell.open(); pullWhatsNew(cWhatsNew); }
/** This method initializes main controls of the main window */ private void initControlsArea( final Composite controlsArea, final Combo feederSelectionCombo, final Button startStopButton, final StartStopScanningAction startStopScanningAction, final ToolsActions.Preferences preferencesListener, final ToolsActions.ChooseFetchers chooseFetchersListsner) { controlsArea.setLayoutData( LayoutHelper.formData( new FormAttachment(feederArea), new FormAttachment(100), new FormAttachment(0), new FormAttachment(feederArea, 0, SWT.BOTTOM))); controlsArea.setLayout(LayoutHelper.formLayout(7, 3, 3)); // steal the height from the second child of the FeederGUI - this must be the first edit box. // this results in better visual alignment with FeederGUIs Control secondControl = feederRegistry.current().getChildren()[1]; // initialize global standard button height buttonHeight = secondControl.getSize().y + 2; // feeder selection combobox this.feederSelectionCombo = feederSelectionCombo; feederSelectionCombo.pack(); IPFeederSelectionListener feederSelectionListener = new IPFeederSelectionListener(); feederSelectionCombo.addSelectionListener(feederSelectionListener); // initialize the selected feeder GUI feederSelectionCombo.select(guiConfig.activeFeeder); feederSelectionCombo.setToolTipText(Labels.getLabel("combobox.feeder.tooltip")); // start/stop button this.startStopButton = startStopButton; shell.setDefaultButton(startStopButton); startStopButton.addSelectionListener(startStopScanningAction); // traverse the button before the combo (and don't traverse other buttons at all) controlsArea.setTabList(new Control[] {startStopButton, feederSelectionCombo}); prefsButton = new ToolBar(controlsArea, SWT.FLAT); prefsButton.setCursor(prefsButton.getDisplay().getSystemCursor(SWT.CURSOR_HAND)); ToolItem item = new ToolItem(prefsButton, SWT.PUSH); item.setImage(new Image(null, Labels.getInstance().getImageAsStream("button.preferences.img"))); item.setToolTipText(Labels.getLabel("title.preferences")); item.addListener(SWT.Selection, preferencesListener); fetchersButton = new ToolBar(controlsArea, SWT.FLAT); fetchersButton.setCursor(fetchersButton.getDisplay().getSystemCursor(SWT.CURSOR_HAND)); item = new ToolItem(fetchersButton, SWT.PUSH); item.setImage(new Image(null, Labels.getInstance().getImageAsStream("button.fetchers.img"))); item.setToolTipText(Labels.getLabel("title.fetchers.select")); item.addListener(SWT.Selection, chooseFetchersListsner); feederSelectionListener.widgetSelected(null); }
private void createContents(final Shell shell) { shell.setText("Choose one"); RowLayout rl1 = new RowLayout(); rl1.type = SWT.VERTICAL; shell.setLayout(rl1); final Composite composite = new Composite(shell, getStyle()); RowLayout rl2 = new RowLayout(); rl2.type = SWT.VERTICAL; composite.setLayout(rl2); for (String choice : choices) { Button radio = new Button(composite, SWT.RADIO); radio.setText(choice); } Composite buttons = new Composite(shell, getStyle()); buttons.setLayout(new RowLayout()); Button ok = new Button(buttons, SWT.PUSH); ok.setText("OK"); // ok.setLayoutData(data); ok.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { choiceMade = -1; int index = 0; for (Control child : composite.getChildren()) { if (child instanceof Button) { if (((Button) child).getSelection()) { choiceMade = index; break; } } index++; } log.log(Level.INFO, "User clicked on OK and selected option {0}", index); shell.close(); } }); Button cancel = new Button(buttons, SWT.PUSH); cancel.setText("Cancel"); cancel.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { log.info("User clicked on Cancel"); shell.close(); } }); shell.setDefaultButton(ok); }
/** * Creates the dialog's contents * * @param shell the dialog window */ private void createContents(final Shell shell) { shell.setLayout(new GridLayout(2, true)); // Show the message Label label = new Label(shell, SWT.NONE); label.setText(message); GridData data = new GridData(); data.horizontalSpan = 2; label.setLayoutData(data); // Display the input box final Text text = new Text(shell, SWT.BORDER); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 2; text.setLayoutData(data); // Create the OK button and add a handler // so that pressing it will set input // to the entered value Button ok = new Button(shell, SWT.PUSH); ok.setText("OK"); data = new GridData(GridData.FILL_HORIZONTAL); ok.setLayoutData(data); ok.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { input = text.getText(); shell.close(); } }); // Create the cancel button and add a handler // so that pressing it will set input to null Button cancel = new Button(shell, SWT.PUSH); cancel.setText("Cancel"); data = new GridData(GridData.FILL_HORIZONTAL); cancel.setLayoutData(data); cancel.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { input = null; shell.close(); } }); // Set the OK button as the default, so // user can type input and press Enter // to dismiss shell.setDefaultButton(ok); }
/** This method initializes composite2 */ private void createComposite2() { RowLayout rowLayout1 = new RowLayout(); rowLayout1.type = org.eclipse.swt.SWT.VERTICAL; rowLayout1.marginHeight = 10; rowLayout1.marginWidth = 10; rowLayout1.fill = true; composite2 = new Composite(sShell, SWT.NONE); FormData formData = new FormData(); formData.left = new FormAttachment(composite1); formData.right = new FormAttachment(100); composite2.setLayoutData(formData); composite2.setLayout(rowLayout1); showButton = new Button(composite2, SWT.NONE); showButton.setText("Show location"); showButton.addSelectionListener(defaultSelectionAdapter); showButton.addSelectionListener( new org.eclipse.swt.events.SelectionAdapter() { public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { buttonPressed = 1; saveResultAndClose(); } }); gotoButton = new Button(composite2, SWT.NONE); gotoButton.setText("Go to location"); gotoButton.addSelectionListener(defaultSelectionAdapter); gotoButton.addSelectionListener( new org.eclipse.swt.events.SelectionAdapter() { public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { buttonPressed = 2; saveResultAndClose(); } }); closeButton = new Button(composite2, SWT.NONE); closeButton.setText("Close"); closeButton.addSelectionListener( new org.eclipse.swt.events.SelectionAdapter() { public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { sShell.close(); } }); sShell.setDefaultButton(showButton); }
protected void createButtonArea(final Shell parent) { Composite container = new Composite(parent, SWT.NONE); container.setLayout(new GridLayout(3, false)); GridData gdLabel = new GridData(); gdLabel.widthHint = 240; fErrorLabel = new Label(container, SWT.NONE); fErrorLabel.setLayoutData(gdLabel); fErrorLabel.setForeground(new Color(null, new RGB(255, 0, 0))); fErrorLabel.setText(Messages.getString("FilterDialog_PatternValidationError")); fErrorLabel.setVisible(false); GridData gdButton = new GridData(); gdButton.widthHint = 75; fAddButton = new Button(container, SWT.PUSH); fAddButton.setText(Messages.getString("Common_AddButton")); fAddButton.setLayoutData(gdButton); fAddButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { try { fErrorLabel.setVisible(false); Pattern.compile(fAddText.getText()); setChosenFilter(fAddText.getText()); parent.dispose(); } catch (PatternSyntaxException ex) { fErrorLabel.setVisible(true); } } }); fCancelButton = new Button(container, SWT.PUSH); fCancelButton.setText(Messages.getString("Common_CancelButton")); fCancelButton.setLayoutData(gdButton); fCancelButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { parent.dispose(); } }); parent.setDefaultButton(fAddButton); }
private Button createButton(Composite parent, int id, String label, boolean defaultButton) { Button button = new Button(parent, SWT.PUSH); button.setText(label); button.setData(new Integer(id)); // button.setLayoutData(data); button.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { buttonPressed(((Integer) event.widget.getData()).intValue()); } }); if (defaultButton) { Shell shell = parent.getShell(); if (shell != null) { shell.setDefaultButton(button); } } return button; }
/* * (non-Javadoc) * * @see * org.eclipse.ui.splash.AbstractSplashHandler#init(org.eclipse.swt.widgets * .Shell) */ public void init(final Shell splash) { // Store the shell super.init(splash); // Configure the shell layout configureUISplash(); // Create UI createUI(); // Create UI listeners createUIListeners(); // Force the splash screen to layout splash.layout(true); splash.setDefaultButton(this.fButtonOK); // Keep the splash screen visible and prevent the RCP application from // loading until the close button is clicked. doEventLoop(); }
private Button createButton(Composite parent, int id, String label, boolean defaultButton) { Button button = new Button(parent, SWT.PUSH); GridData buttonData = new GridData(GridData.FILL_HORIZONTAL); button.setLayoutData(buttonData); button.setData(Integer.valueOf(id)); button.setText(label); button.setFont(parent.getFont()); if (defaultButton) { Shell shell = parent.getShell(); if (shell != null) { shell.setDefaultButton(button); } button.setFocus(); } button.setFont(parent.getFont()); setButtonLayoutData(button); return button; }
private void create(Shell parent, boolean readOnly) { shell.setText("Segmentation"); if (parent != null) UIUtil.inheritIcon(shell, parent); GridLayout layTmp = new GridLayout(); layTmp.marginBottom = 0; layTmp.verticalSpacing = 0; shell.setLayout(layTmp); createComposite(shell); // --- Dialog-level buttons SelectionAdapter OKCancelActions = new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { result = false; if (e.widget.getData().equals("h")) { if (help != null) help.showWiki("Segmentation Step"); return; } if (e.widget.getData().equals("o")) saveData(); shell.close(); }; }; pnlActions = new OKCancelPanel(shell, SWT.NONE, OKCancelActions, true); pnlActions.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); pnlActions.btOK.setEnabled(!readOnly); if (!readOnly) { shell.setDefaultButton(pnlActions.btOK); } shell.pack(); shell.setMinimumSize(shell.getSize()); Point startSize = shell.getMinimumSize(); if (startSize.x < 600) startSize.x = 600; shell.setSize(startSize); setData(); Dialogs.centerWindow(shell, parent); }
private void step2() { builder.serverInfo.name = serverNameT.getText(); builder.serverInfo.blockSize = optionsInt[blockSizeC.getSelectionIndex()]; builder.virtualDiskBlocks = Integer.parseInt(diskBlocksT.getText()); builder.serverInfo.minimumBlocks = Integer.parseInt(minBlocksT.getText()); builder.serverInfo.maximumBlocks = Integer.parseInt(diskBlocksT.getText()); builder.port = Integer.parseInt(portT.getText()); builder.serverInfo.checkInTime = Integer.parseInt(checkInTimeT.getText()); builder.threadPoolOptions = ThreadPoolOptions.fromString(threadPoolT.getText()); builder.databaseUrl = databaseUrlT.getText(); builder.databaseUser = databaseUserT.getText(); builder.databasePassword = databasePasswordT.getText(); builder.firstRun = true; if (builder.threadPoolOptions == null) { MsgBox.warning(shell, "The thread pool options are invalid."); return; } stackLayout.topControl = p2; shell.setDefaultButton(doneB); shell.layout(); }
private Shell setDialogLayout(int serverId) { final Shell dialog = new Shell(display, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE); dialog.setText("Add Description"); dialog.setLayout(UIUtil.formLayout(5, 5)); Label iconLbl = new Label(dialog, SWT.NONE); iconLbl.setImage(Images.COMMENT); iconLbl.setLayoutData(UIUtil.formData(0, 10, 0, 10, null, -1, null, -1)); Label descLbl = new Label(dialog, SWT.WRAP); descLbl.setText("Add description to " + targetLocation.getName()); descLbl.setLayoutData(UIUtil.formData(iconLbl, 10, 0, 10, 100, -10, null, -1)); descTxt = new Text(dialog, SWT.BORDER); descTxt.setLayoutData(UIUtil.formData(0, 30, descLbl, 10, 100, -30, null, -1)); Button confirmBtn = new Button(dialog, SWT.PUSH); confirmBtn.setLayoutData(UIUtil.formData(null, -1, descTxt, 10, 100, -30, null, -1, 150)); confirmBtn.setText("Confirm"); confirmBtn.addSelectionListener( new SelectionListener() { public void widgetSelected(SelectionEvent e) { String description = descTxt.getText(); if (description != null && !"".equals(description)) { requestDescription(description); } } public void widgetDefaultSelected(SelectionEvent e) {} }); dialog.setDefaultButton(confirmBtn); return dialog; }
/** * Creates a new button with the given id. * * <p>The <code>Dialog</code> implementation of this framework method creates a standard push * button, registers for selection events including button presses and registers default buttons * with its shell. The button id is stored as the buttons client data. Note that the parent's * layout is assumed to be a GridLayout and the number of columns in this layout is incremented. * Subclasses may override. * * @param parent the parent composite * @param id the id of the button (see <code>IDialogConstants.*_ID</code> constants for standard * dialog button ids) * @param label the label from the button * @param defaultButton <code>true</code> if the button is to be the default button, and <code> * false</code> otherwise */ protected Button createButton(Composite parent, int id, String label, boolean defaultButton) { // increment the number of columns in the button bar ((GridLayout) parent.getLayout()).numColumns++; Button button = new Button(parent, SWT.PUSH); GridData buttonData = new GridData(GridData.FILL_HORIZONTAL); button.setLayoutData(buttonData); button.setData(new Integer(id)); button.setText(label); button.setFont(parent.getFont()); if (defaultButton) { Shell shell = parent.getShell(); if (shell != null) { shell.setDefaultButton(button); } button.setFocus(); } button.setFont(parent.getFont()); setButtonLayoutData(button); return button; }
/** * Creates a new AboutDialog object. The icon displayed in this dialog box is provided by the * parent shell. It should be either a unique image (Shell.getImage()), or the second image of a * list of (Shell.getImages()[1]). * * @param parent The parent shell (also carry the icon to display). * @param caption Caption text. * @param description Text for the application description line. * @param version Text for the application version line. */ public AboutDialog(Shell parent, String caption, String description, String version) { // Take the opportunity to do some clean up if possible Runtime rt = Runtime.getRuntime(); rt.runFinalization(); rt.gc(); shell = new Shell(parent, SWT.CLOSE | SWT.TITLE | SWT.RESIZE | SWT.APPLICATION_MODAL); shell.setText(caption); UIUtil.inheritIcon(shell, parent); shell.setLayout(new GridLayout()); Composite cmpTmp = new Composite(shell, SWT.BORDER); cmpTmp.setLayoutData(new GridData(GridData.FILL_BOTH)); GridLayout layTmp = new GridLayout(2, false); cmpTmp.setLayout(layTmp); // Application icon Label appIcon = new Label(cmpTmp, SWT.NONE); GridData gdTmp = new GridData(); gdTmp.verticalSpan = 2; appIcon.setLayoutData(gdTmp); Image[] list = parent.getImages(); // Gets the single icon if ((list == null) || (list.length < 2)) { appIcon.setImage(parent.getImage()); } else { // Or the second one if there are more than one. appIcon.setImage(list[1]); } Label label = new Label(cmpTmp, SWT.NONE); label.setText(description == null ? "TBD" : description); // $NON-NLS-1$ gdTmp = new GridData( GridData.HORIZONTAL_ALIGN_CENTER | GridData.GRAB_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER | GridData.GRAB_VERTICAL); label.setLayoutData(gdTmp); label = new Label(cmpTmp, SWT.NONE); label.setText( String.format( Res.getString("AboutDialog.versionLabel"), version == null ? "TBD" : version)); // $NON-NLS-1$ gdTmp = new GridData( GridData.HORIZONTAL_ALIGN_CENTER | GridData.GRAB_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER | GridData.GRAB_VERTICAL); label.setLayoutData(gdTmp); // Info cmpTmp = new Composite(shell, SWT.BORDER); cmpTmp.setLayoutData(new GridData(GridData.FILL_BOTH)); layTmp = new GridLayout(2, false); cmpTmp.setLayout(layTmp); label = new Label(cmpTmp, SWT.NONE); label.setText(Res.getString("AboutDialog.jvmVersion")); // $NON-NLS-1$ label = new Label(cmpTmp, SWT.NONE); label.setText(System.getProperty("java.version")); // $NON-NLS-1$ label = new Label(cmpTmp, SWT.NONE); label.setText(Res.getString("AboutDialog.platform")); // $NON-NLS-1$ label = new Label(cmpTmp, SWT.NONE); label.setText( String.format( "%s, %s, %s", //$NON-NLS-1$ System.getProperty("os.name"), // $NON-NLS-1$ System.getProperty("os.arch"), // $NON-NLS-1$ System.getProperty("os.version"))); // $NON-NLS-1$ label = new Label(cmpTmp, SWT.NONE); label.setText(Res.getString("AboutDialog.memoryLabel")); // $NON-NLS-1$ label = new Label(cmpTmp, SWT.NONE); NumberFormat nf = NumberFormat.getInstance(); label.setText( String.format( Res.getString("AboutDialog.memory"), // $NON-NLS-1$ nf.format(rt.freeMemory() / 1024), nf.format(rt.totalMemory() / 1024))); // --- Dialog-level buttons SelectionAdapter CloseActions = new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { shell.close(); }; }; ClosePanel pnlActions = new ClosePanel(shell, SWT.NONE, CloseActions, false); pnlActions.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); shell.setDefaultButton(pnlActions.btClose); shell.pack(); shell.setMinimumSize(shell.getSize()); Point startSize = shell.getMinimumSize(); if (startSize.x < 350) startSize.x = 350; shell.setSize(startSize); Dialogs.centerWindow(shell, parent); }
private void createExchange(final Shell parent) { final Shell shell = ViewUtility.createModalDialogShell(parent, "Create Exchange"); Composite nameComposite = _toolkit.createComposite(shell, SWT.NONE); nameComposite.setBackground(shell.getBackground()); nameComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); nameComposite.setLayout(new GridLayout(2, false)); _toolkit.createLabel(nameComposite, "Name:").setBackground(shell.getBackground()); final Text nameText = new Text(nameComposite, SWT.BORDER); nameText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); Composite typeComposite = _toolkit.createComposite(shell, SWT.NONE); typeComposite.setBackground(shell.getBackground()); typeComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); typeComposite.setLayout(new GridLayout(2, false)); String[] exchangeTypes; if (_ApiVersion.greaterThanOrEqualTo(1, 3)) // if the server supports Qpid JMX API 1.3 { // request the current exchange types from the broker try { exchangeTypes = _vhmb.getExchangeTypes(); } catch (IOException e1) { exchangeTypes = DEFAULT_EXCHANGE_TYPE_VALUES.toArray(new String[DEFAULT_EXCHANGE_TYPE_VALUES.size()]); } } else // use the fallback defaults. { exchangeTypes = DEFAULT_EXCHANGE_TYPE_VALUES.toArray(new String[DEFAULT_EXCHANGE_TYPE_VALUES.size()]); } _toolkit.createLabel(typeComposite, "Type:").setBackground(shell.getBackground()); final org.eclipse.swt.widgets.List typeList = new org.eclipse.swt.widgets.List(typeComposite, SWT.SINGLE | SWT.BORDER); typeList.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); typeList.setItems(exchangeTypes); Composite durableComposite = _toolkit.createComposite(shell, SWT.NONE); durableComposite.setBackground(shell.getBackground()); GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false); gridData.minimumWidth = 220; durableComposite.setLayoutData(gridData); durableComposite.setLayout(new GridLayout(2, false)); _toolkit.createLabel(durableComposite, "Durable:").setBackground(shell.getBackground()); final Button durableButton = new Button(durableComposite, SWT.CHECK); durableButton.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, false)); Composite okCancelButtonsComp = _toolkit.createComposite(shell); okCancelButtonsComp.setBackground(shell.getBackground()); okCancelButtonsComp.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, true, true)); okCancelButtonsComp.setLayout(new GridLayout(2, false)); Button okButton = _toolkit.createButton(okCancelButtonsComp, "OK", SWT.PUSH); okButton.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false)); Button cancelButton = _toolkit.createButton(okCancelButtonsComp, "Cancel", SWT.PUSH); cancelButton.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false)); okButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { String name = nameText.getText(); if (name == null || name.length() == 0) { ViewUtility.popupErrorMessage("Create Exchange", "Please enter a valid name"); return; } int selectedTypeIndex = typeList.getSelectionIndex(); if (selectedTypeIndex == -1) { ViewUtility.popupErrorMessage("Create Exchange", "Please select an Exchange type"); return; } String type = typeList.getItem(selectedTypeIndex); boolean durable = durableButton.getSelection(); shell.dispose(); try { _vhmb.createNewExchange(name, type, durable); ViewUtility.operationResultFeedback(null, "Created Exchange", null); try { // delay to allow mbean registration notification processing Thread.sleep(250); } catch (InterruptedException ie) { // ignore } } catch (Exception e5) { ViewUtility.operationFailedStatusBarMessage("Error creating Exchange"); MBeanUtility.handleException(_mbean, e5); } refresh(_mbean); } }); cancelButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { shell.dispose(); } }); shell.setDefaultButton(okButton); shell.pack(); ViewUtility.centerChildInParentShell(parent, shell); shell.open(); }
public static PrintStyles open(Shell shell) { final PrintStyles styles = new PrintStyles(); final Shell dialog = DialogUtils.newDialog(shell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); dialog.setLayout(new GridLayout()); dialog.setText(TuxGuitar.getProperty("options")); // ------------------TRACK SELECTION------------------ Group track = new Group(dialog, SWT.SHADOW_ETCHED_IN); track.setLayout(new GridLayout(2, false)); track.setLayoutData(getGroupData()); track.setText(TuxGuitar.getProperty("track")); Label trackLabel = new Label(track, SWT.NULL); trackLabel.setText(TuxGuitar.getProperty("track")); final Combo tracks = new Combo(track, SWT.DROP_DOWN | SWT.READ_ONLY); tracks.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); for (int number = 1; number <= TuxGuitar.instance().getSongManager().getSong().countTracks(); number++) { tracks.add(TuxGuitar.instance().getSongManager().getTrack(number).getName()); } tracks.select( TuxGuitar.instance().getTablatureEditor().getTablature().getCaret().getTrack().getNumber() - 1); // ------------------MEASURE RANGE------------------ Group range = new Group(dialog, SWT.SHADOW_ETCHED_IN); range.setLayout(new GridLayout(2, false)); range.setLayoutData(getGroupData()); range.setText(TuxGuitar.getProperty("print.range")); final int minSelection = 1; final int maxSelection = TuxGuitar.instance().getSongManager().getSong().countMeasureHeaders(); Label fromLabel = new Label(range, SWT.NULL); fromLabel.setText(TuxGuitar.getProperty("edit.from")); final Spinner fromSpinner = new Spinner(range, SWT.BORDER); fromSpinner.setLayoutData(getSpinnerData()); fromSpinner.setMaximum(maxSelection); fromSpinner.setMinimum(minSelection); fromSpinner.setSelection(minSelection); Label toLabel = new Label(range, SWT.NULL); toLabel.setText(TuxGuitar.getProperty("edit.to")); final Spinner toSpinner = new Spinner(range, SWT.BORDER); toSpinner.setLayoutData(getSpinnerData()); toSpinner.setMinimum(minSelection); toSpinner.setMaximum(maxSelection); toSpinner.setSelection(maxSelection); fromSpinner.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { int fromSelection = fromSpinner.getSelection(); int toSelection = toSpinner.getSelection(); if (fromSelection < minSelection) { fromSpinner.setSelection(minSelection); } else if (fromSelection > toSelection) { fromSpinner.setSelection(toSelection); } } }); toSpinner.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { int toSelection = toSpinner.getSelection(); int fromSelection = fromSpinner.getSelection(); if (toSelection < fromSelection) { toSpinner.setSelection(fromSelection); } else if (toSelection > maxSelection) { toSpinner.setSelection(maxSelection); } } }); // ------------------CHECK OPTIONS-------------------- Group options = new Group(dialog, SWT.SHADOW_ETCHED_IN); options.setLayout(new GridLayout()); options.setLayoutData(getGroupData()); options.setText(TuxGuitar.getProperty("options")); final Button tablatureEnabled = new Button(options, SWT.CHECK); tablatureEnabled.setText(TuxGuitar.getProperty("export.tablature-enabled")); tablatureEnabled.setSelection(true); final Button scoreEnabled = new Button(options, SWT.CHECK); scoreEnabled.setText(TuxGuitar.getProperty("export.score-enabled")); scoreEnabled.setSelection(true); final Button chordNameEnabled = new Button(options, SWT.CHECK); chordNameEnabled.setText(TuxGuitar.getProperty("export.chord-name-enabled")); chordNameEnabled.setSelection(true); final Button chordDiagramEnabled = new Button(options, SWT.CHECK); chordDiagramEnabled.setText(TuxGuitar.getProperty("export.chord-diagram-enabled")); chordDiagramEnabled.setSelection(true); final Button blackAndWhite = new Button(options, SWT.CHECK); blackAndWhite.setText(TuxGuitar.getProperty("export.black-and-white")); blackAndWhite.setSelection(true); tablatureEnabled.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { if (!tablatureEnabled.getSelection()) { scoreEnabled.setSelection(true); } } }); scoreEnabled.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { if (!scoreEnabled.getSelection()) { tablatureEnabled.setSelection(true); } } }); // ------------------BUTTONS-------------------------- Composite buttons = new Composite(dialog, SWT.NONE); buttons.setLayout(new GridLayout(2, false)); buttons.setLayoutData(new GridData(SWT.END, SWT.FILL, true, true)); final Button buttonOK = new Button(buttons, SWT.PUSH); buttonOK.setText(TuxGuitar.getProperty("ok")); buttonOK.setLayoutData(getButtonData()); buttonOK.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { int style = 0; style |= (scoreEnabled.getSelection() ? ViewLayout.DISPLAY_SCORE : 0); style |= (tablatureEnabled.getSelection() ? ViewLayout.DISPLAY_TABLATURE : 0); style |= (chordNameEnabled.getSelection() ? ViewLayout.DISPLAY_CHORD_NAME : 0); style |= (chordDiagramEnabled.getSelection() ? ViewLayout.DISPLAY_CHORD_DIAGRAM : 0); styles.setTrackNumber(tracks.getSelectionIndex() + 1); styles.setFromMeasure(fromSpinner.getSelection()); styles.setToMeasure(toSpinner.getSelection()); styles.setBlackAndWhite(blackAndWhite.getSelection()); styles.setStyle(style); dialog.dispose(); } }); Button buttonCancel = new Button(buttons, SWT.PUSH); buttonCancel.setText(TuxGuitar.getProperty("cancel")); buttonCancel.setLayoutData(getButtonData()); buttonCancel.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { dialog.dispose(); } }); dialog.setDefaultButton(buttonOK); DialogUtils.openDialog( dialog, DialogUtils.OPEN_STYLE_CENTER | DialogUtils.OPEN_STYLE_PACK | DialogUtils.OPEN_STYLE_WAIT); return ((styles.getTrackNumber() > 0) ? styles : null); }
public void openSettingsDialog(final TGSongStreamContext context, final Runnable callback) { final TGSong song = context.getAttribute(TGDocumentContextAttributes.ATTRIBUTE_SONG); final PrintStyles styles = createDefaultStyles(song); final Shell dialog = DialogUtils.newDialog( TuxGuitar.getInstance().getShell(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); dialog.setLayout(new GridLayout()); dialog.setText(TuxGuitar.getProperty("options")); // ------------------FORMAT SELECTION------------------ Group formatGroup = new Group(dialog, SWT.SHADOW_ETCHED_IN); formatGroup.setLayout(new GridLayout(2, false)); formatGroup.setLayoutData(getGroupData()); formatGroup.setText(TuxGuitar.getProperty("tuxguitar-image.format")); Label formatLabel = new Label(formatGroup, SWT.NULL); formatLabel.setText(TuxGuitar.getProperty("tuxguitar-image.format")); final Combo formatCombo = new Combo(formatGroup, SWT.DROP_DOWN | SWT.READ_ONLY); formatCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); for (int i = 0; i < ImageFormat.IMAGE_FORMATS.length; i++) { formatCombo.add(ImageFormat.IMAGE_FORMATS[i].getName()); } formatCombo.select(0); // ------------------TRACK SELECTION------------------ Group track = new Group(dialog, SWT.SHADOW_ETCHED_IN); track.setLayout(new GridLayout(2, false)); track.setLayoutData(getGroupData()); track.setText(TuxGuitar.getProperty("track")); Label trackLabel = new Label(track, SWT.NULL); trackLabel.setText(TuxGuitar.getProperty("track")); final Combo tracks = new Combo(track, SWT.DROP_DOWN | SWT.READ_ONLY); tracks.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); for (int number = 1; number <= song.countTracks(); number++) { tracks.add(TuxGuitar.getInstance().getSongManager().getTrack(song, number).getName()); } tracks.select( TuxGuitar.getInstance() .getTablatureEditor() .getTablature() .getCaret() .getTrack() .getNumber() - 1); // ------------------MEASURE RANGE------------------ Group range = new Group(dialog, SWT.SHADOW_ETCHED_IN); range.setLayout(new GridLayout(2, false)); range.setLayoutData(getGroupData()); range.setText(TuxGuitar.getProperty("print.range")); final int minSelection = 1; final int maxSelection = song.countMeasureHeaders(); Label fromLabel = new Label(range, SWT.NULL); fromLabel.setText(TuxGuitar.getProperty("edit.from")); final Spinner fromSpinner = new Spinner(range, SWT.BORDER); fromSpinner.setLayoutData(getSpinnerData()); fromSpinner.setMaximum(maxSelection); fromSpinner.setMinimum(minSelection); fromSpinner.setSelection(minSelection); Label toLabel = new Label(range, SWT.NULL); toLabel.setText(TuxGuitar.getProperty("edit.to")); final Spinner toSpinner = new Spinner(range, SWT.BORDER); toSpinner.setLayoutData(getSpinnerData()); toSpinner.setMinimum(minSelection); toSpinner.setMaximum(maxSelection); toSpinner.setSelection(maxSelection); fromSpinner.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { int fromSelection = fromSpinner.getSelection(); int toSelection = toSpinner.getSelection(); if (fromSelection < minSelection) { fromSpinner.setSelection(minSelection); } else if (fromSelection > toSelection) { fromSpinner.setSelection(toSelection); } } }); toSpinner.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { int toSelection = toSpinner.getSelection(); int fromSelection = fromSpinner.getSelection(); if (toSelection < fromSelection) { toSpinner.setSelection(fromSelection); } else if (toSelection > maxSelection) { toSpinner.setSelection(maxSelection); } } }); // ------------------CHECK OPTIONS-------------------- Group options = new Group(dialog, SWT.SHADOW_ETCHED_IN); options.setLayout(new GridLayout()); options.setLayoutData(getGroupData()); options.setText(TuxGuitar.getProperty("options")); final Button tablatureEnabled = new Button(options, SWT.CHECK); tablatureEnabled.setText(TuxGuitar.getProperty("export.tablature-enabled")); tablatureEnabled.setSelection(true); final Button scoreEnabled = new Button(options, SWT.CHECK); scoreEnabled.setText(TuxGuitar.getProperty("export.score-enabled")); scoreEnabled.setSelection(true); final Button chordNameEnabled = new Button(options, SWT.CHECK); chordNameEnabled.setText(TuxGuitar.getProperty("export.chord-name-enabled")); chordNameEnabled.setSelection(true); final Button chordDiagramEnabled = new Button(options, SWT.CHECK); chordDiagramEnabled.setText(TuxGuitar.getProperty("export.chord-diagram-enabled")); chordDiagramEnabled.setSelection(true); final Button blackAndWhite = new Button(options, SWT.CHECK); blackAndWhite.setText(TuxGuitar.getProperty("export.black-and-white")); blackAndWhite.setSelection(true); tablatureEnabled.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { if (!tablatureEnabled.getSelection()) { scoreEnabled.setSelection(true); } } }); scoreEnabled.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { if (!scoreEnabled.getSelection()) { tablatureEnabled.setSelection(true); } } }); // ------------------BUTTONS-------------------------- Composite buttons = new Composite(dialog, SWT.NONE); buttons.setLayout(new GridLayout(2, false)); buttons.setLayoutData(new GridData(SWT.END, SWT.FILL, true, true)); final Button buttonOK = new Button(buttons, SWT.PUSH); buttonOK.setText(TuxGuitar.getProperty("ok")); buttonOK.setLayoutData(getButtonData()); buttonOK.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { int format = formatCombo.getSelectionIndex(); if (format < 0 || format >= ImageFormat.IMAGE_FORMATS.length) { format = 0; } int style = 0; style |= (scoreEnabled.getSelection() ? TGLayout.DISPLAY_SCORE : 0); style |= (tablatureEnabled.getSelection() ? TGLayout.DISPLAY_TABLATURE : 0); style |= (chordNameEnabled.getSelection() ? TGLayout.DISPLAY_CHORD_NAME : 0); style |= (chordDiagramEnabled.getSelection() ? TGLayout.DISPLAY_CHORD_DIAGRAM : 0); style |= (blackAndWhite.getSelection() ? TGLayout.DISPLAY_MODE_BLACK_WHITE : 0); styles.setTrackNumber(tracks.getSelectionIndex() + 1); styles.setFromMeasure(fromSpinner.getSelection()); styles.setToMeasure(toSpinner.getSelection()); styles.setStyle(style); dialog.dispose(); ImageExporterSettings settings = new ImageExporterSettings(); settings.setStyles(styles); settings.setFormat(ImageFormat.IMAGE_FORMATS[format]); openDirectoryDialog(settings, context, callback); } }); Button buttonCancel = new Button(buttons, SWT.PUSH); buttonCancel.setText(TuxGuitar.getProperty("cancel")); buttonCancel.setLayoutData(getButtonData()); buttonCancel.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { dialog.dispose(); } }); dialog.setDefaultButton(buttonOK); DialogUtils.openDialog(dialog, DialogUtils.OPEN_STYLE_CENTER | DialogUtils.OPEN_STYLE_PACK); }
private void create(Shell parent, final SymitarFile file) { FormLayout layout = new FormLayout(); layout.marginTop = 5; layout.marginBottom = 5; layout.marginLeft = 5; layout.marginRight = 5; layout.spacing = 5; shell = new Shell(parent, SWT.APPLICATION_MODAL | SWT.DIALOG_TRIM); shell.setText("Line Printer Options"); shell.setLayout(layout); Label queueLabel = new Label(shell, SWT.NONE); queueLabel.setText("LPT Queue"); Label overrideLabel = new Label(shell, SWT.NONE); overrideLabel.setText("Forms Override"); Label lengthLabel = new Label(shell, SWT.NONE); lengthLabel.setText("Form Length"); Label startLabel = new Label(shell, SWT.NONE); startLabel.setText("Start Page"); Label endLabel = new Label(shell, SWT.NONE); endLabel.setText("End Page"); Label copiesLabel = new Label(shell, SWT.NONE); copiesLabel.setText("Copies"); Label landscapeLabel = new Label(shell, SWT.NONE); landscapeLabel.setText("Landscape"); Label duplexLabel = new Label(shell, SWT.NONE); duplexLabel.setText("Duplex"); Label priorityLabel = new Label(shell, SWT.NONE); priorityLabel.setText("Queue Priority"); // Select All when tabbing through FocusListener selectAllFocuser = new FocusListener() { public void focusGained(FocusEvent e) { if (e.widget instanceof Text) ((Text) e.widget).selectAll(); } public void focusLost(FocusEvent e) {} }; MouseListener mouseFocuser = new MouseAdapter() { public void mouseDown(MouseEvent e) { if (e.widget instanceof Text) ((Text) e.widget).selectAll(); } }; final Text queueText = new Text(shell, SWT.BORDER); queueText.setText("0"); queueText.selectAll(); queueText.addFocusListener(selectAllFocuser); queueText.addMouseListener(mouseFocuser); final Combo overrideCombo = new Combo(shell, SWT.READ_ONLY); overrideCombo.add("No"); overrideCombo.add("Yes"); overrideCombo.select(0); final Text lengthText = new Text(shell, SWT.BORDER); lengthText.setText("0"); lengthText.addFocusListener(selectAllFocuser); lengthText.addMouseListener(mouseFocuser); final Text startText = new Text(shell, SWT.BORDER); startText.setText("0"); startText.addFocusListener(selectAllFocuser); startText.addMouseListener(mouseFocuser); final Text endText = new Text(shell, SWT.BORDER); endText.setText("0"); endText.addFocusListener(selectAllFocuser); endText.addMouseListener(mouseFocuser); final Text copiesText = new Text(shell, SWT.BORDER); copiesText.setText("1"); copiesText.addFocusListener(selectAllFocuser); copiesText.addMouseListener(mouseFocuser); final Combo landscapeCombo = new Combo(shell, SWT.READ_ONLY); landscapeCombo.add("No"); landscapeCombo.add("Yes"); landscapeCombo.select(0); final Combo duplexCombo = new Combo(shell, SWT.READ_ONLY); duplexCombo.add("No"); duplexCombo.add("Yes"); duplexCombo.select(0); final Text priorityText = new Text(shell, SWT.BORDER); priorityText.setText("4"); priorityText.addFocusListener(selectAllFocuser); priorityText.addMouseListener(mouseFocuser); Button okButton = new Button(shell, SWT.PUSH); okButton.setText("Print"); Button cancelButton = new Button(shell, SWT.PUSH); cancelButton.setText("Cancel"); shell.setDefaultButton(okButton); queueText.setFocus(); FormData data = new FormData(); data.left = new FormAttachment(0); data.top = new FormAttachment(0); data.width = 120; queueLabel.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(overrideLabel); data.top = new FormAttachment(0); data.right = new FormAttachment(100); data.width = 80; queueText.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(0); data.top = new FormAttachment(queueText); data.width = 120; overrideLabel.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(overrideLabel); data.top = new FormAttachment(queueText); data.right = new FormAttachment(100); data.width = 80; overrideCombo.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(0); data.top = new FormAttachment(overrideCombo); data.width = 120; lengthLabel.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(lengthLabel); data.top = new FormAttachment(overrideCombo); data.right = new FormAttachment(100); data.width = 80; lengthText.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(0); data.top = new FormAttachment(lengthText); data.width = 120; startLabel.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(startLabel); data.top = new FormAttachment(lengthText); data.right = new FormAttachment(100); data.width = 80; startText.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(0); data.top = new FormAttachment(startText); data.width = 120; endLabel.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(endLabel); data.top = new FormAttachment(startText); data.right = new FormAttachment(100); data.width = 80; endText.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(0); data.top = new FormAttachment(endText); data.width = 120; copiesLabel.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(copiesLabel); data.top = new FormAttachment(endText); data.right = new FormAttachment(100); data.width = 80; copiesText.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(0); data.top = new FormAttachment(copiesText); data.width = 120; landscapeLabel.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(landscapeLabel); data.top = new FormAttachment(copiesText); data.right = new FormAttachment(100); data.width = 80; landscapeCombo.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(0); data.top = new FormAttachment(landscapeCombo); data.width = 120; duplexLabel.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(duplexLabel); data.top = new FormAttachment(landscapeCombo); data.right = new FormAttachment(100); data.width = 80; duplexCombo.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(0); data.top = new FormAttachment(duplexCombo); data.width = 120; priorityLabel.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(priorityLabel); data.top = new FormAttachment(duplexCombo); data.right = new FormAttachment(100); data.width = 80; priorityText.setLayoutData(data); data = new FormData(); data.top = new FormAttachment(priorityText); data.right = new FormAttachment(100); cancelButton.setLayoutData(data); cancelButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { result = false; shell.dispose(); } }); data = new FormData(); data.right = new FormAttachment(cancelButton); data.top = new FormAttachment(priorityText); okButton.setLayoutData(data); okButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { result = true; SessionError result = SessionError.INPUT_ERROR; try { result = RepDevMain.SYMITAR_SESSIONS .get(file.getSym()) .printFileLPT( file, Integer.parseInt(queueText.getText()), false, 0, Integer.parseInt(startText.getText()), Integer.parseInt(endText.getText()), Integer.parseInt(copiesText.getText()), landscapeCombo.getSelectionIndex() == 1, duplexCombo.getSelectionIndex() == 1, Integer.parseInt(priorityText.getText())); } catch (NumberFormatException e1) { } if (result != SessionError.NONE) { MessageBox dialog = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR); dialog.setText("Print Error"); dialog.setMessage(result.toString()); dialog.open(); } shell.dispose(); } }); shell.pack(); shell.open(); }
private void createContents(final Shell shell) { shell.setLayout(new GridLayout(2, true)); Label labelMaze = new Label(shell, SWT.NONE); labelMaze.setText("Maze Name:"); GridData data = new GridData(); data.horizontalSpan = 1; labelMaze.setLayoutData(data); final Text mazeText = new Text(shell, SWT.BORDER); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 1; mazeText.setLayoutData(data); Label labelX = new Label(shell, SWT.NONE); labelX.setText("X Axis Size:"); final Text xText = new Text(shell, SWT.BORDER); xText.setLayoutData(data); Label labelY = new Label(shell, SWT.NONE); labelY.setText("Y Axis Size:"); final Text yText = new Text(shell, SWT.BORDER); yText.setLayoutData(data); Label labelZ = new Label(shell, SWT.NONE); labelZ.setText("Y Axis Size:"); final Text zText = new Text(shell, SWT.BORDER); zText.setLayoutData(data); Button ok = new Button(shell, SWT.PUSH); ok.setText("OK"); data = new GridData(GridData.FILL_HORIZONTAL); ok.setLayoutData(data); ok.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { name = mazeText.getText(); x = xText.getText(); y = yText.getText(); z = zText.getText(); shell.close(); } }); Button cancel = new Button(shell, SWT.PUSH); cancel.setText("Cancel"); data = new GridData(GridData.FILL_HORIZONTAL); cancel.setLayoutData(data); cancel.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { name = null; x = null; y = null; x = null; shell.close(); } }); shell.setDefaultButton(ok); }
public RenameDialog(Shell parent, SourcesHandler handler, CopySource copy) { dialog = new Shell(parent, SWT.DIALOG_TRIM | SWT.CLOSE | SWT.APPLICATION_MODAL); FormLayout formLayout = new FormLayout(); formLayout.marginWidth = 10; formLayout.marginHeight = 10; formLayout.spacing = 10; dialog.setLayout(formLayout); this.copySource = copy; this.handler = handler; ApplicationFactory factory = new ApplicationFactory(dialog, "Creator", getClass().getName()); Label label = factory.createLabel("name"); // new Label (dialog, SWT.NONE); FormData data = new FormData(); label.setLayoutData(data); Button cancel = factory.createButton("cancel"); data = new FormData(); data.width = 60; data.right = new FormAttachment(100, 0); data.bottom = new FormAttachment(100, 0); cancel.setLayoutData(data); cancel.addSelectionListener( new SelectionAdapter() { @SuppressWarnings("unused") public void widgetSelected(SelectionEvent e) { dialog.close(); } }); final Text text = new Text(dialog, SWT.BORDER); text.setText(copySource.getSrcNames()[0]); data = new FormData(); data.width = 200; data.left = new FormAttachment(label, 0, SWT.DEFAULT); data.right = new FormAttachment(100, 0); data.top = new FormAttachment(label, 0, SWT.CENTER); data.bottom = new FormAttachment(cancel, 0, SWT.DEFAULT); text.setLayoutData(data); Button ok = new Button(factory.getComposite(), SWT.PUSH); ; ok.setText("Ok"); data = new FormData(); data.width = 60; data.right = new FormAttachment(cancel, 0, SWT.DEFAULT); data.bottom = new FormAttachment(100, 0); ok.setLayoutData(data); ok.addSelectionListener( new SelectionAdapter() { @SuppressWarnings("unused") public void widgetSelected(SelectionEvent e) { rename(text.getText()); } }); Rectangle displayRect = UIDATA.DISPLAY.getBounds(); int x = (displayRect.width - 350) / 2; int y = (displayRect.height - 300) / 2; dialog.setImage(parent.getImage()); dialog.setLocation(x, y); dialog.setDefaultButton(ok); dialog.pack(); // XPWindowTheme.setWin32Theme(dialog); dialog.open(); }
private void deleteQueuesOrExchanges(Shell parent, final VhostOperations op) { Table table; String windowTitle; String dialogueMessage; final String feedBackMessage; final String failureFeedBackMessage; if (op.equals(VhostOperations.DELETE_QUEUE)) { table = _queueTable; windowTitle = "Delete Queue(s)"; dialogueMessage = "Delete Queue(s): "; feedBackMessage = "Queue(s) deleted"; failureFeedBackMessage = "Error deleting Queue(s)"; } else { table = _exchangeTable; windowTitle = "Delete Exchange(s)"; dialogueMessage = "Delete Exchange(s): "; feedBackMessage = "Exchange(s) deleted"; failureFeedBackMessage = "Error deleting Exchange(s)"; } int selectionIndex = table.getSelectionIndex(); if (selectionIndex == -1) { return; } int[] selectedIndices = table.getSelectionIndices(); final ArrayList<ManagedBean> selectedMBeans = new ArrayList<ManagedBean>(); for (int index = 0; index < selectedIndices.length; index++) { ManagedBean selectedMBean = (ManagedBean) table.getItem(selectedIndices[index]).getData(); selectedMBeans.add(selectedMBean); } final Shell shell = ViewUtility.createModalDialogShell(parent, windowTitle); _toolkit.createLabel(shell, dialogueMessage).setBackground(shell.getBackground()); final Text headerText = new Text(shell, SWT.WRAP | SWT.V_SCROLL | SWT.BORDER); headerText.setEditable(false); GridData data = new GridData(SWT.FILL, SWT.FILL, false, false); data.minimumHeight = 150; data.heightHint = 150; data.minimumWidth = 400; data.widthHint = 400; headerText.setLayoutData(data); String lineSeperator = System.getProperty("line.separator"); for (ManagedBean mbean : selectedMBeans) { headerText.append(mbean.getName() + lineSeperator); } headerText.setSelection(0); Composite okCancelButtonsComp = _toolkit.createComposite(shell); okCancelButtonsComp.setBackground(shell.getBackground()); okCancelButtonsComp.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, true, true)); okCancelButtonsComp.setLayout(new GridLayout(2, false)); Button okButton = _toolkit.createButton(okCancelButtonsComp, "OK", SWT.PUSH); okButton.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false)); Button cancelButton = _toolkit.createButton(okCancelButtonsComp, "Cancel", SWT.PUSH); cancelButton.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false)); okButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { shell.dispose(); try { // perform the deletes for (ManagedBean mbean : selectedMBeans) { switch (op) { case DELETE_QUEUE: _vhmb.deleteQueue(mbean.getName()); _serverRegistry.removeManagedObject(mbean); break; case DELETE_EXCHANGE: _vhmb.unregisterExchange(mbean.getName()); break; } // remove the mbean from the server registry now instead of // waiting for an mbean Unregistration Notification to do it _serverRegistry.removeManagedObject(mbean); } ViewUtility.operationResultFeedback(null, feedBackMessage, null); } catch (Exception e1) { ViewUtility.operationFailedStatusBarMessage(failureFeedBackMessage); MBeanUtility.handleException(_mbean, e1); } refresh(_mbean); ; } }); cancelButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { shell.dispose(); } }); shell.setDefaultButton(okButton); shell.pack(); ViewUtility.centerChildInParentShell(parent, shell); shell.open(); }
private void create(Shell parent, boolean readOnly) { shell.setText(Res.getString("EditorCaption")); if (parent != null) shell.setImage(parent.getImage()); GridLayout layTmp = new GridLayout(); layTmp.marginBottom = 0; layTmp.verticalSpacing = 0; shell.setLayout(layTmp); TabFolder tfTmp = new TabFolder(shell, SWT.NONE); GridData gdTmp = new GridData(GridData.FILL_BOTH); tfTmp.setLayoutData(gdTmp); // --- Options tab Composite cmpTmp = new Composite(tfTmp, SWT.NONE); layTmp = new GridLayout(); cmpTmp.setLayout(layTmp); Group grpTmp = new Group(cmpTmp, SWT.NONE); layTmp = new GridLayout(); grpTmp.setLayout(layTmp); grpTmp.setText(Res.getString("grpStandaloneStrings")); gdTmp = new GridData(GridData.FILL_HORIZONTAL); grpTmp.setLayoutData(gdTmp); chkExtractStandalone = new Button(grpTmp, SWT.CHECK); chkExtractStandalone.setText(Res.getString("chkExtractStandalone")); grpTmp = new Group(cmpTmp, SWT.NONE); grpTmp.setLayout(new GridLayout()); grpTmp.setText(Res.getString("grpKeyValuePairs")); gdTmp = new GridData(GridData.FILL_HORIZONTAL); grpTmp.setLayoutData(gdTmp); rdExtractAllPairs = new Button(grpTmp, SWT.RADIO); rdExtractAllPairs.setText(Res.getString("rdExtractAllPairs")); rdDontExtractPairs = new Button(grpTmp, SWT.RADIO); rdDontExtractPairs.setText(Res.getString("rdDontExtractPairs")); Label label = new Label(grpTmp, SWT.NONE); label.setText(Res.getString("stExceptions")); edExceptions = new Text(grpTmp, SWT.BORDER); gdTmp = new GridData(GridData.FILL_HORIZONTAL); edExceptions.setLayoutData(gdTmp); TabItem tiTmp = new TabItem(tfTmp, SWT.NONE); tiTmp.setText(Res.getString("tabOptions")); tiTmp.setControl(cmpTmp); // --- Inline tab cmpTmp = new Composite(tfTmp, SWT.NONE); layTmp = new GridLayout(); cmpTmp.setLayout(layTmp); chkUseCodeFinder = new Button(cmpTmp, SWT.CHECK); chkUseCodeFinder.setText("Has inline codes as defined below:"); chkUseCodeFinder.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateInlineCodes(); }; }); pnlCodeFinder = new InlineCodeFinderPanel(cmpTmp, SWT.NONE); pnlCodeFinder.setLayoutData(new GridData(GridData.FILL_BOTH)); tiTmp = new TabItem(tfTmp, SWT.NONE); tiTmp.setText("Inline Codes"); tiTmp.setControl(cmpTmp); // --- Output tab /*cmpTmp = new Composite(tfTmp, SWT.NONE); layTmp = new GridLayout(); cmpTmp.setLayout(layTmp); grpTmp = new Group(cmpTmp, SWT.NONE); layTmp = new GridLayout(); grpTmp.setLayout(layTmp); grpTmp.setText(Res.getString("grpExtendedChars")); gdTmp = new GridData(GridData.FILL_HORIZONTAL); grpTmp.setLayoutData(gdTmp); chkEscapeExtendedChars = new Button(grpTmp, SWT.CHECK); chkEscapeExtendedChars.setText(Res.getString("chkEscapeExtendedChars")); tiTmp = new TabItem(tfTmp, SWT.NONE); tiTmp.setText(Res.getString("tabOutput")); tiTmp.setControl(cmpTmp);*/ // --- Dialog-level buttons SelectionAdapter OKCancelActions = new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { result = false; if (e.widget.getData().equals("h")) { if (help != null) help.showWiki("JSON Filter"); return; } if (e.widget.getData().equals("o")) { if (!saveData()) return; result = true; } shell.close(); }; }; pnlActions = new OKCancelPanel(shell, SWT.NONE, OKCancelActions, true); gdTmp = new GridData(GridData.FILL_HORIZONTAL); pnlActions.setLayoutData(gdTmp); pnlActions.btOK.setEnabled(!readOnly); if (!readOnly) { shell.setDefaultButton(pnlActions.btOK); } shell.pack(); Rectangle Rect = shell.getBounds(); shell.setMinimumSize(Rect.width, Rect.height); Dialogs.centerWindow(shell, parent); setData(); }
protected void open(Shell shell) { this.accepted = false; final Shell dialog = DialogUtils.newDialog(shell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); dialog.setLayout(new GridLayout()); dialog.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); dialog.setImage(TuxGuitar.instance().getIconManager().getAppIcon()); dialog.setText(TuxGuitar.getProperty("tuxguitar-community.share-dialog.title")); Group group = new Group(dialog, SWT.SHADOW_ETCHED_IN); group.setLayout(makeGroupLayout(5)); group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); group.setText(TuxGuitar.getProperty("tuxguitar-community.share-dialog.details")); // -------USERNAME--------------------------------- Label usernameLabel = new Label(group, SWT.NULL); usernameLabel.setLayoutData(makeLabelData()); usernameLabel.setText( TuxGuitar.getProperty("tuxguitar-community.share-dialog.details.user") + ":"); final Text usernameText = new Text(group, SWT.BORDER | SWT.READ_ONLY); usernameText.setLayoutData(makeUsernameTextData()); usernameText.setText(TGCommunitySingleton.getInstance().getAuth().getUsername()); final Button usernameChooser = new Button(group, SWT.PUSH); usernameChooser.setText("..."); usernameChooser.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { TGCommunityAuthDialog authDialog = new TGCommunityAuthDialog(); authDialog.open(dialog); if (authDialog.isAccepted()) { TGCommunitySingleton.getInstance().getAuth().update(); usernameText.setText(TGCommunitySingleton.getInstance().getAuth().getUsername()); } } }); // -------TITLE------------------------------------ Label titleLabel = new Label(group, SWT.NULL); titleLabel.setLayoutData(makeLabelData()); titleLabel.setText( TuxGuitar.getProperty("tuxguitar-community.share-dialog.details.title") + ":"); final Text titleText = new Text(group, SWT.BORDER); titleText.setLayoutData(makeTextData()); titleText.setText(this.file.getTitle()); // -------TAGKEYS------------------------------------ Label tagkeysLabel = new Label(group, SWT.NULL); tagkeysLabel.setLayoutData(makeLabelData()); tagkeysLabel.setText( TuxGuitar.getProperty("tuxguitar-community.share-dialog.details.tagkeys") + ":"); final Text tagkeysText = new Text(group, SWT.BORDER); tagkeysText.setLayoutData(makeTextData()); tagkeysText.setText(this.file.getTagkeys()); // -------DESCRIPTION------------------------------------ Label descriptionLabel = new Label(group, SWT.NULL); descriptionLabel.setLayoutData(makeLabelData()); descriptionLabel.setText( TuxGuitar.getProperty("tuxguitar-community.share-dialog.details.description") + ":"); final Text descriptionText = new Text(group, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL); descriptionText.setLayoutData(makeTextAreaData()); descriptionText.setText(this.file.getDescription()); // ------------------BUTTONS-------------------------- Composite buttons = new Composite(dialog, SWT.NONE); buttons.setLayout(new GridLayout(2, false)); buttons.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, true, true)); final Button buttonOK = new Button(buttons, SWT.PUSH); buttonOK.setText(TuxGuitar.getProperty("ok")); buttonOK.setLayoutData(getButtonData()); buttonOK.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { update(titleText.getText(), tagkeysText.getText(), descriptionText.getText()); dialog.dispose(); } }); Button buttonCancel = new Button(buttons, SWT.PUSH); buttonCancel.setText(TuxGuitar.getProperty("cancel")); buttonCancel.setLayoutData(getButtonData()); buttonCancel.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { dialog.dispose(); } }); dialog.setDefaultButton(buttonOK); if (this.errors != null) { MessageDialog.errorMessage(dialog, this.errors); } DialogUtils.openDialog( dialog, DialogUtils.OPEN_STYLE_CENTER | DialogUtils.OPEN_STYLE_PACK | DialogUtils.OPEN_STYLE_WAIT); }
public ConfigMaker(File configFile) { builder = new Builder(configFile); display = new Display(); shell = new Shell(display); shell.setText("Negura Server"); shell.setSize(760, 620); stackLayout = new StackLayout(); shell.setLayout(stackLayout); // Page one positioning. /////////////////////////////////////////////// p1 = new Composite(shell, SWT.NONE); p1.setLayout(new MigLayout("insets 10", "[right][200!][max][100::, fill]")); Label newConfigL = Swt.newLabel(p1, "span, align left, wrap 30px", "New configuration"); Swt.newLabel(p1, null, "Server name:"); serverNameT = Swt.newText(p1, "w max, wrap", "Negura Server Name"); Swt.newLabel(p1, null, "Block size:"); blockSizeC = Swt.newCombo(p1, "w max, wrap 25px", optionsStr, 2); Swt.newLabel(p1, null, "Virtual disk blocks:"); diskBlocksT = Swt.newText(p1, "w max", null); Scale diskBlocksS = Swt.newHScale(p1, "span, w max, wrap", 128, 1024, 64); Swt.newLabel(p1, null, "Virtual disk space:"); Label diskSpaceL = Swt.newLabel(p1, "w max, wrap 25px", null); Swt.newLabel(p1, null, "Minimum user blocks:"); minBlocksT = Swt.newText(p1, "w max", null); Scale minBlocksS = Swt.newHScale(p1, "span, w max, wrap", 128, 1024, 64); Swt.newLabel(p1, null, "Minimum user space:"); Label minSpaceL = Swt.newLabel(p1, "w max, wrap 25px", null); Swt.newLabel(p1, null, "Port:"); portT = Swt.newText(p1, "w max, wrap", "5000"); Swt.newLabel(p1, null, "Check-in time:"); checkInTimeT = Swt.newText(p1, "w max", "300"); Swt.newLabel(p1, "wrap", "seconds"); Swt.newLabel(p1, null, "Thread pool options:"); threadPoolT = Swt.newText(p1, "span, w max, wrap 25px", new ThreadPoolOptions(2, 20, 30000).toString()); Swt.newLabel(p1, null, "Database URL:"); databaseUrlT = Swt.newText(p1, "span, w max", "jdbc:postgresql://127.0.0.1:5432/neguradb"); Swt.newLabel(p1, null, "Database user:"******"w max, wrap", "p"); Swt.newLabel(p1, null, "Database password:"******"w max, wrap push", "password"); Button continueB = Swt.newButton(p1, "skip 3", "Continue"); // Page one options. /////////////////////////////////////////////////// titleFont = Swt.getFontWithDifferentHeight(display, newConfigL.getFont(), 16); Swt.connectDisposal(shell, titleFont); newConfigL.setFont(titleFont); Swt.Mod tripleConnector = new Swt.Mod() { public void modify(Widget to, Widget... from) { Label label = (Label) to; Combo combo = (Combo) from[0]; Text text = (Text) from[1]; int blockSize = optionsInt[combo.getSelectionIndex()]; long numberOfBlocks = Util.parseLongOrZero(text.getText()); label.setText(Util.bytesWithUnit(numberOfBlocks * blockSize, 2)); } }; diskBlocksT.addVerifyListener(Swt.INTEGER_VERIFIER); Swt.connectTo(Swt.TEXT_FROM_SCALE, diskBlocksT, diskBlocksS); Swt.connectTo(Swt.SCALE_FROM_TEXT, diskBlocksS, diskBlocksT); Swt.connectTo(tripleConnector, diskSpaceL, blockSizeC, diskBlocksT); diskBlocksT.setText("768"); minBlocksT.addVerifyListener(Swt.INTEGER_VERIFIER); Swt.connectTo(Swt.TEXT_FROM_SCALE, minBlocksT, minBlocksS); Swt.connectTo(Swt.SCALE_FROM_TEXT, minBlocksS, minBlocksT); Swt.connectTo(tripleConnector, minSpaceL, blockSizeC, minBlocksT); minBlocksT.setText("350"); portT.addVerifyListener(Swt.INTEGER_VERIFIER); checkInTimeT.addVerifyListener(Swt.INTEGER_VERIFIER); continueB.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { step2(); } }); // Page two positioning. /////////////////////////////////////////////// p2 = new Composite(shell, SWT.NONE); p2.setLayout(new MigLayout("insets 10", "[right][grow][100::, fill]")); Label newConfig2L = Swt.newLabel(p2, "span, align left, wrap 30px", "New configuration"); Swt.newLabel(p2, null, "Server key pair:"); final Text key1T = Swt.newText(p2, "w max", null); Button load1B = Swt.newButton(p2, "wrap", "Load"); Swt.newLabel(p2, null, "Admin key pair:"); final Text key2T = Swt.newText(p2, "w max", null); Button load2B = Swt.newButton(p2, "wrap push", "Load"); Button genB = Swt.newButton(p2, "align left", "Key pair generator"); doneB = Swt.newButton(p2, "skip 1", "Done"); // Page two options. /////////////////////////////////////////////////// newConfig2L.setFont(titleFont); key1T.setEditable(false); key2T.setEditable(false); load1B.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { loadKeyPair(key1T, 0); } }); load2B.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { loadKeyPair(key2T, 1); } }); genB.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { openKeyGeneratorWindow(); } }); doneB.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { step3(); } }); stackLayout.topControl = p1; shell.layout(); shell.setDefaultButton(continueB); Swt.centerShell(shell); shell.open(); }
public LoginPanel(Shell page, Composite parent) { super(parent, SWT.NONE); this.shell = page; setLayout(new GridLayout()); // ´´½¨µÇ¼ÇøÓòµÄÓû§±êÇ© Óû§ÃûÊäÈë¿ò ÃÜÂë±êÇ© ÃÜÂëÊäÈë¿ò µÇ¼°´Å¥ Composite panelTop = new Composite(this, SWT.NONE); panelTop.setBackgroundMode(SWT.INHERIT_DEFAULT); RowLayout layout = new RowLayout(); layout.spacing = 40; layout.marginBottom = 0; layout.marginRight = 10; layout.marginTop = 0; layout.wrap = false; layout.pack = true; layout.center = true; panelTop.setLayout(layout); userText = new Text(panelTop, SWT.BORDER); RowData rd = new RowData(); rd.width = 240; userText.setMessage("Õʺš¢Óû§Ãû»òÕßemail"); userText.setLayoutData(rd); userText.setData(RWT.CUSTOM_VARIANT, "loginInput"); userText.setFocus(); passwordText = new Text(panelTop, SWT.BORDER | SWT.PASSWORD); rd = new RowData(); rd.width = 220; passwordText.setMessage("ÊäÈëµÇ¼ÃÜÂë"); passwordText.setLayoutData(rd); passwordText.setData(RWT.CUSTOM_VARIANT, "loginInput"); okButton = new Button(panelTop, SWT.PUSH); okButton.setData(RWT.CUSTOM_VARIANT, "loginInput"); rd = new RowData(); rd.width = 50; rd.height = 50; okButton.setLayoutData(rd); page.setDefaultButton(okButton); okButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { buttonPressed(); } }); // ´´½¨±£´æÃÜÂë¹´Ñ¡¿òºÍ±£´æÓû§Ãû¹´Ñ¡¿ò Composite panelBottom = new Composite(this, SWT.NONE); layout = new RowLayout(); layout.spacing = 4; layout.marginBottom = 0; layout.marginRight = 10; layout.marginTop = 0; layout.wrap = false; layout.pack = true; panelBottom.setLayout(layout); saveIdButton = new Button(panelBottom, SWT.CHECK); saveIdButton.setText("±£´æµÇ¼ÕʺÅ"); saveIdButton.setData(RWT.CUSTOM_VARIANT, "loginCheck"); savePassButton = new Button(panelBottom, SWT.CHECK); savePassButton.setText("±£´æµÇ¼ÃÜÂë"); savePassButton.setData(RWT.CUSTOM_VARIANT, "loginCheck"); // cookie save String uid = RWT.getSettingStore().getAttribute(COOKIE_UI_USERID); if (uid != null && uid.length() > 0) { userText.setText(uid); saveIdButton.setSelection(true); } // cookie save String psd = RWT.getSettingStore().getAttribute(COOKIE_UI_PASSWORD); if (psd != null && psd.length() > 0) { passwordText.setText(psd); savePassButton.setSelection(true); } panelTop.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, true, false)); panelBottom.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, false, false)); createTooltips(); }
/** * Init with listener * * @param azureus_core * @param parent * @param linkURL * @param referrer * @param listener */ public OpenUrlWindow( final Shell parent, String linkURL, boolean default_magnet, final String referrer, final TorrentDownloaderCallBackInterface listener) { final Shell shell = ShellFactory.createShell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE); shell.setText(MessageText.getString("openUrl.title")); Utils.setShellIcon(shell); GridData gridData; GridLayout layout = new GridLayout(); layout.numColumns = 3; shell.setLayout(layout); // URL field Label label = new Label(shell, SWT.NULL); label.setText(MessageText.getString("openUrl.url")); gridData = new GridData(); label.setLayoutData(gridData); final Text url = new Text(shell, SWT.BORDER); gridData = new GridData(GridData.FILL_HORIZONTAL); gridData.widthHint = 400; gridData.horizontalSpan = 2; url.setLayoutData(gridData); if (linkURL == null) Utils.setTextLinkFromClipboard(shell, url, true, default_magnet); else url.setText(linkURL); url.setSelection(url.getText().length()); // help field Label help_label = new Label(shell, SWT.NULL); help_label.setText(MessageText.getString("openUrl.url.info")); gridData = new GridData(); gridData.horizontalSpan = 3; help_label.setLayoutData(gridData); Label space = new Label(shell, SWT.NULL); gridData = new GridData(); gridData.horizontalSpan = 3; space.setLayoutData(gridData); // referrer field Label referrer_label = new Label(shell, SWT.NULL); referrer_label.setText(MessageText.getString("openUrl.referrer")); gridData = new GridData(); referrer_label.setLayoutData(gridData); final Combo referrer_combo = new Combo(shell, SWT.BORDER); gridData = new GridData(GridData.FILL_HORIZONTAL); gridData.widthHint = 150; gridData.grabExcessHorizontalSpace = true; referrer_combo.setLayoutData(gridData); final StringList referrers = COConfigurationManager.getStringListParameter("url_open_referrers"); StringIterator iter = referrers.iterator(); while (iter.hasNext()) { referrer_combo.add(iter.next()); } if (referrer != null && referrer.length() > 0) { referrer_combo.setText(referrer); } else if (last_referrer != null) { referrer_combo.setText(last_referrer); } Label referrer_info = new Label(shell, SWT.NULL); referrer_info.setText(MessageText.getString("openUrl.referrer.info")); // line Label labelSeparator = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_END); gridData.horizontalSpan = 3; labelSeparator.setLayoutData(gridData); // buttons Composite panel = new Composite(shell, SWT.NULL); layout = new GridLayout(); layout.numColumns = 3; panel.setLayout(layout); gridData = new GridData( GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_END); gridData.horizontalSpan = 3; gridData.grabExcessHorizontalSpace = true; panel.setLayoutData(gridData); new Label(panel, SWT.NULL); Button ok = new Button(panel, SWT.PUSH); gridData = new GridData( GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_END); gridData.widthHint = 70; gridData.grabExcessHorizontalSpace = true; ok.setLayoutData(gridData); ok.setText(MessageText.getString("Button.ok")); ok.addListener( SWT.Selection, new Listener() { public void handleEvent(Event e) { last_referrer = referrer_combo.getText().trim(); if (!referrers.contains(last_referrer)) { referrers.add(last_referrer); COConfigurationManager.setParameter("url_open_referrers", referrers); COConfigurationManager.save(); } COConfigurationManager.setParameter(CONFIG_REFERRER_DEFAULT, last_referrer); COConfigurationManager.save(); String url_str = url.getText(); url_str = UrlUtils.parseTextForURL(url_str, true); if (url_str == null) { url_str = UrlUtils.parseTextForMagnets(url.getText()); } if (url_str == null) { url_str = url.getText(); } new FileDownloadWindow(parent, url_str, last_referrer, null, null, listener); shell.dispose(); } }); shell.setDefaultButton(ok); Button cancel = new Button(panel, SWT.PUSH); gridData = new GridData(GridData.HORIZONTAL_ALIGN_END); gridData.grabExcessHorizontalSpace = false; gridData.widthHint = 70; cancel.setLayoutData(gridData); cancel.setText(MessageText.getString("Button.cancel")); cancel.addListener( SWT.Selection, new Listener() { public void handleEvent(Event e) { shell.dispose(); } }); shell.addListener( SWT.Traverse, new Listener() { public void handleEvent(Event e) { if (e.character == SWT.ESC) { shell.dispose(); } } }); Point p = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT); if (p.x > 800) { p.x = 800; } shell.setSize(p); Utils.createURLDropTarget(shell, url); Utils.centreWindow(shell); shell.open(); }
private void showInputBox() { Display display = Display.getDefault(); final Shell dialog = new Shell(display, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); dialog.setText("Add a row"); dialog.setLocation( shlTypeDocument.getBounds().x / 2 + shlTypeDocument.getBounds().width / 2, shlTypeDocument.getBounds().y / 2 + shlTypeDocument.getBounds().height / 2); FormLayout formLayout = new FormLayout(); formLayout.marginWidth = 10; formLayout.marginHeight = 10; formLayout.spacing = 10; dialog.setLayout(formLayout); Label label = new Label(dialog, SWT.NONE); label.setText("Type an identifier:"); FormData data = new FormData(); label.setLayoutData(data); Button cancel = new Button(dialog, SWT.PUSH); cancel.setText("Cancel"); data = new FormData(); data.width = 60; data.right = new FormAttachment(100, 0); data.bottom = new FormAttachment(100, 0); cancel.setLayoutData(data); cancel.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { dialog.close(); } }); final Text text = new Text(dialog, SWT.BORDER); data = new FormData(); data.width = 200; data.left = new FormAttachment(label, 0, SWT.DEFAULT); data.right = new FormAttachment(100, 0); data.top = new FormAttachment(label, 0, SWT.CENTER); data.bottom = new FormAttachment(cancel, 0, SWT.DEFAULT); text.setLayoutData(data); Button ok = new Button(dialog, SWT.PUSH); ok.setText("OK"); data = new FormData(); data.width = 60; data.right = new FormAttachment(cancel, 0, SWT.DEFAULT); data.bottom = new FormAttachment(100, 0); ok.setLayoutData(data); ok.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { identifier = text.getText(); dialog.close(); } }); dialog.setDefaultButton(ok); dialog.pack(); dialog.open(); while (!dialog.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } }
public void showDialog(Shell shell) { TGMeasureImpl measure = getEditor().getTablature().getCaret().getMeasure(); if (measure != null) { final Shell dialog = DialogUtils.newDialog(shell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); dialog.setLayout(new GridLayout()); dialog.setText(TuxGuitar.getProperty("composition.tripletfeel")); dialog.setMinimumSize(300, 0); // -------------TIME SIGNATURE----------------------------------------------- Group tripletFeel = new Group(dialog, SWT.SHADOW_ETCHED_IN); tripletFeel.setLayout(new GridLayout()); tripletFeel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); tripletFeel.setText(TuxGuitar.getProperty("composition.tripletfeel")); // none final Button tripletFeelNone = new Button(tripletFeel, SWT.RADIO); tripletFeelNone.setText(TuxGuitar.getProperty("composition.tripletfeel.none")); tripletFeelNone.setSelection(measure.getTripletFeel() == TGMeasureHeader.TRIPLET_FEEL_NONE); final Button tripletFeelEighth = new Button(tripletFeel, SWT.RADIO); tripletFeelEighth.setText(TuxGuitar.getProperty("composition.tripletfeel.eighth")); tripletFeelEighth.setSelection( measure.getTripletFeel() == TGMeasureHeader.TRIPLET_FEEL_EIGHTH); final Button tripletFeelSixteenth = new Button(tripletFeel, SWT.RADIO); tripletFeelSixteenth.setText(TuxGuitar.getProperty("composition.tripletfeel.sixteenth")); tripletFeelSixteenth.setSelection( measure.getTripletFeel() == TGMeasureHeader.TRIPLET_FEEL_SIXTEENTH); // --------------------To End Checkbox------------------------------- Group check = new Group(dialog, SWT.SHADOW_ETCHED_IN); check.setLayout(new GridLayout()); check.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); check.setText(TuxGuitar.getProperty("options")); final Button toEnd = new Button(check, SWT.CHECK); toEnd.setText(TuxGuitar.getProperty("composition.tripletfeel.to-the-end")); toEnd.setSelection(true); // ------------------BUTTONS-------------------------- Composite buttons = new Composite(dialog, SWT.NONE); buttons.setLayout(new GridLayout(2, false)); buttons.setLayoutData(new GridData(SWT.END, SWT.FILL, true, true)); final Button buttonOk = new Button(buttons, SWT.PUSH); buttonOk.setText(TuxGuitar.getProperty("ok")); buttonOk.setLayoutData(getButtonData()); buttonOk.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { final boolean toEndValue = toEnd.getSelection(); final int tripletFeel = getSelectedTripletFeel(tripletFeelNone, tripletFeelEighth, tripletFeelSixteenth); dialog.dispose(); try { TGSynchronizer.instance() .runLater( new TGSynchronizer.TGRunnable() { public void run() throws Throwable { ActionLock.lock(); TuxGuitar.instance().loadCursor(SWT.CURSOR_WAIT); setTripletFeel(tripletFeel, toEndValue); TuxGuitar.instance().updateCache(true); TuxGuitar.instance().loadCursor(SWT.CURSOR_ARROW); ActionLock.unlock(); } }); } catch (Throwable throwable) { MessageDialog.errorMessage(throwable); } } }); Button buttonCancel = new Button(buttons, SWT.PUSH); buttonCancel.setLayoutData(getButtonData()); buttonCancel.setText(TuxGuitar.getProperty("cancel")); buttonCancel.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { dialog.dispose(); } }); dialog.setDefaultButton(buttonOk); DialogUtils.openDialog( dialog, DialogUtils.OPEN_STYLE_CENTER | DialogUtils.OPEN_STYLE_PACK | DialogUtils.OPEN_STYLE_WAIT); } }