public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new GridLayout(2, true)); final Browser browser; try { browser = new Browser(shell, SWT.NONE); } catch (SWTError e) { System.out.println("Could not instantiate Browser: " + e.getMessage()); display.dispose(); return; } GridData data = new GridData(GridData.FILL_BOTH); data.horizontalSpan = 2; browser.setLayoutData(data); Button headersButton = new Button(shell, SWT.PUSH); headersButton.setText("Send custom headers"); data = new GridData(); data.horizontalAlignment = GridData.FILL; headersButton.setLayoutData(data); headersButton.addListener( SWT.Selection, event -> browser.setUrl( "http://www.ericgiguere.com/tools/http-header-viewer.html", null, new String[] {"User-agent: SWT Browser", "Custom-header: this is just a demo"})); Button postDataButton = new Button(shell, SWT.PUSH); postDataButton.setText("Send post data"); data = new GridData(); data.horizontalAlignment = GridData.FILL; postDataButton.setLayoutData(data); postDataButton.addListener( SWT.Selection, event -> browser.setUrl( "https://bugs.eclipse.org/bugs/buglist.cgi", "emailassigned_to1=1&bug_severity=enhancement&bug_status=NEW&email1=platform-swt-inbox&emailtype1=substring", null)); shell.setBounds(10, 10, 600, 600); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); RowLayout layout = new RowLayout(SWT.HORIZONTAL); layout.wrap = true; layout.fill = false; layout.justify = true; shell.setLayout(layout); Button b = new Button(shell, SWT.PUSH); b.setText("Button 1"); b = new Button(shell, SWT.PUSH); b.setText("Button 2"); b = new Button(shell, SWT.PUSH); b.setText("Button 3"); b = new Button(shell, SWT.PUSH); b.setText("Not shown"); b.setVisible(false); RowData data = new RowData(); data.exclude = true; b.setLayoutData(data); b = new Button(shell, SWT.PUSH); b.setText("Button 200 high"); data = new RowData(); data.height = 200; b.setLayoutData(data); b = new Button(shell, SWT.PUSH); b.setText("Button 200 wide"); data = new RowData(); data.width = 200; b.setLayoutData(data); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
private void createButtonPanel(Composite pageContent) { Composite buttonPanel = new Composite(pageContent, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 1; buttonPanel.setLayout(layout); GridData gridData = new GridData(); gridData.grabExcessHorizontalSpace = false; gridData.grabExcessVerticalSpace = true; gridData.verticalAlignment = GridData.CENTER; gridData.horizontalAlignment = GridData.CENTER; buttonPanel.setLayoutData(gridData); addButton = new Button(buttonPanel, SWT.PUSH); addButton.setText(Messages._UI_ADD_BUTTON); gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.verticalAlignment = GridData.CENTER; addButton.setLayoutData(gridData); addButton.addSelectionListener(new ButtonSelectListener()); addButton.setToolTipText(Messages._UI_ADD_BUTTON_TOOL_TIP); addButton.setEnabled(false); removeButton = new Button(buttonPanel, SWT.PUSH); removeButton.setText(Messages._UI_REMOVE_BUTTON); gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.verticalAlignment = GridData.CENTER; removeButton.setLayoutData(gridData); removeButton.addSelectionListener(new ButtonSelectListener()); removeButton.setToolTipText(Messages._UI_REMOVE_BUTTON_TOOL_TIP); removeButton.setEnabled(false); removeAllButton = new Button(buttonPanel, SWT.PUSH); removeAllButton.setText(Messages._UI_REMOVE_ALL_BUTTON); gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.verticalAlignment = GridData.CENTER; removeAllButton.setLayoutData(gridData); removeAllButton.addSelectionListener(new ButtonSelectListener()); removeAllButton.setToolTipText(Messages._UI_REMOVE_ALL_BUTTON_TOOL_TIP); removeAllButton.setEnabled(false); }
/** Creates a text that controls whether a border radius is set on the registered controls. */ protected void cteateRoundedBorderGroup() { Group group = new Group(styleComp, SWT.NONE); group.setText("Rounded Border"); group.setLayout(new GridLayout(2, false)); new Label(group, SWT.NONE).setText("Width"); final Text textWidth = new Text(group, SWT.SINGLE | SWT.BORDER); textWidth.setLayoutData(new GridData(20, SWT.DEFAULT)); new Label(group, SWT.NONE).setText("Color"); final Button buttonColor = new Button(group, SWT.PUSH); buttonColor.setLayoutData(new GridData(20, 20)); buttonColor.addSelectionListener( new SelectionAdapter() { public void widgetSelected(final SelectionEvent event) { rbIndex = (rbIndex + 1) % bgColors.length; if (bgColors[rbIndex] == null) { buttonColor.setText(""); } else { buttonColor.setText("\u2588"); } buttonColor.setForeground(bgColors[rbIndex]); } }); new Label(group, SWT.NONE).setText("Radius "); Composite radiusGroup = new Composite(group, SWT.NONE); radiusGroup.setLayout(new GridLayout(4, false)); new Label(radiusGroup, SWT.NONE).setText("T-L"); final Text textTopLeft = new Text(radiusGroup, SWT.SINGLE | SWT.BORDER); textTopLeft.setLayoutData(new GridData(20, SWT.DEFAULT)); new Label(radiusGroup, SWT.NONE).setText("T-R"); final Text textTopRight = new Text(radiusGroup, SWT.SINGLE | SWT.BORDER); textTopRight.setLayoutData(new GridData(20, SWT.DEFAULT)); new Label(radiusGroup, SWT.NONE).setText("B-L"); final Text textBottomLeft = new Text(radiusGroup, SWT.SINGLE | SWT.BORDER); textBottomLeft.setLayoutData(new GridData(20, SWT.DEFAULT)); new Label(radiusGroup, SWT.NONE).setText("B-R"); final Text textBottomRight = new Text(radiusGroup, SWT.SINGLE | SWT.BORDER); textBottomRight.setLayoutData(new GridData(20, SWT.DEFAULT)); Button button = new Button(group, SWT.PUSH); button.setText("Set"); button.addSelectionListener( new SelectionAdapter() { public void widgetSelected(final SelectionEvent e) { int width = parseInt(textWidth.getText()); Color color = buttonColor.getBackground(); int topLeft = parseInt(textTopLeft.getText()); int topRight = parseInt(textTopRight.getText()); int bottomRight = parseInt(textBottomRight.getText()); int bottomLeft = parseInt(textBottomLeft.getText()); updateRoundedBorder(width, color, topLeft, topRight, bottomRight, bottomLeft); } }); }
private void createUI() { String newFile = ""; parentShell = ((Spoon) SpoonFactory.getInstance()).getShell(); Display display = parentShell.getDisplay(); comp = new Composite(((Spoon) SpoonFactory.getInstance()).getShell(), SWT.BORDER); comp.setLayout(new GridLayout()); comp.setLayoutData(new GridData(GridData.FILL_BOTH)); lbl = new Label(comp, SWT.CENTER | SWT.TOP); GridData ldata = new GridData(SWT.CENTER, SWT.TOP, true, false); lbl.setLayoutData(ldata); lbl.setText("Preview data returned from HPCC"); Button fileButton = new Button(comp, SWT.PUSH | SWT.SINGLE | SWT.TOP); fileButton.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, false)); fileButton.setText("OPEN FILE"); // Listener for the file open button (fileButton) Listener fileOpenListener = new Listener() { public void handleEvent(Event e) { String newFile = buildFileDialog(); if (newFile != "") { fileName = newFile; // TODO: create new tab for file // openFile(fileName); openResultsXML(fileName); // int len = folder.getChildren().length; int len = folder.getItemCount(); System.out.println("Number of tabs: " + len); folder.setSelection(len - 1); } } }; fileButton.addListener(SWT.Selection, fileOpenListener); folder = new CTabFolder(comp, SWT.CLOSE); folder.setSimple(false); folder.setBorderVisible(true); folder.setLayoutData(new GridData(GridData.FILL_BOTH)); }
void createImportButton(Composite parent) { importButton = new Button(parent, SWT.PUSH); importButton.setText(Messages._UI_IMPORT_BUTTON); GridData gridData = new GridData(); gridData.horizontalAlignment = GridData.CENTER; importButton.setLayoutData(gridData); importButton.addSelectionListener( new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) {} public void widgetSelected(SelectionEvent e) { FileSystemImportWizard importWizard = new FileSystemImportWizard(); importWizard.init(workbench, selection); Shell shell = Display.getCurrent().getActiveShell(); WizardDialog wizardDialog = new WizardDialog(shell, importWizard); wizardDialog.create(); wizardDialog.open(); sourceFileViewer.refresh(); } }); importButton.setToolTipText(Messages._UI_IMPORT_BUTTON_TOOL_TIP); }
private void createLanguagesGroup(Composite parent) { final Group langGroup = NSISWizardDialogUtil.createGroup( parent, 1, "language.support.group.label", null, false); // $NON-NLS-1$ GridData data = (GridData) langGroup.getLayoutData(); data.verticalAlignment = SWT.FILL; data.grabExcessVerticalSpace = true; data.horizontalAlignment = SWT.FILL; data.grabExcessHorizontalSpace = true; NSISWizardSettings settings = mWizard.getSettings(); final Button enableLangSupport = NSISWizardDialogUtil.createCheckBox( langGroup, "enable.language.support.label", settings.isEnableLanguageSupport(), true, null, false); //$NON-NLS-1$ enableLangSupport.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { boolean selection = enableLangSupport.getSelection(); mWizard.getSettings().setEnableLanguageSupport(selection); validateField(LANG_CHECK); } }); final MasterSlaveController m = new MasterSlaveController(enableLangSupport); final Composite listsComposite = new Composite(langGroup, SWT.NONE); data = new GridData(SWT.FILL, SWT.FILL, true, true); listsComposite.setLayoutData(data); GridLayout layout = new GridLayout(2, true); layout.marginHeight = 0; layout.marginWidth = 0; listsComposite.setLayout(layout); java.util.List<NSISLanguage> selectedLanguages = settings.getLanguages(); if (selectedLanguages.isEmpty()) { NSISLanguage defaultLanguage = NSISLanguageManager.getInstance().getDefaultLanguage(); if (defaultLanguage != null) { selectedLanguages.add(defaultLanguage); } } java.util.List<NSISLanguage> availableLanguages = NSISLanguageManager.getInstance().getLanguages(); availableLanguages.removeAll(selectedLanguages); Composite leftComposite = new Composite(listsComposite, SWT.NONE); leftComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); layout = new GridLayout(2, false); layout.marginHeight = 0; layout.marginWidth = 0; leftComposite.setLayout(layout); ((GridData) NSISWizardDialogUtil.createLabel( leftComposite, "available.languages.label", //$NON-NLS-1$ true, m, false) .getLayoutData()) .horizontalSpan = 2; final List availableLangList = new List(leftComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI); data = new GridData(SWT.FILL, SWT.FILL, true, true); Dialog.applyDialogFont(availableLangList); data.heightHint = Common.calculateControlSize(availableLangList, 0, 12).y; availableLangList.setLayoutData(data); m.addSlave(availableLangList); final ListViewer availableLangViewer = new ListViewer(availableLangList); CollectionContentProvider collectionContentProvider = new CollectionContentProvider(); availableLangViewer.setContentProvider(collectionContentProvider); availableLangViewer.setInput(availableLanguages); availableLangViewer.setSorter(new ViewerSorter(cLanguageCollator)); final Composite buttonsComposite1 = new Composite(leftComposite, SWT.NONE); layout = new GridLayout(1, false); layout.marginHeight = 0; layout.marginWidth = 0; buttonsComposite1.setLayout(layout); data = new GridData(SWT.FILL, SWT.CENTER, false, false); buttonsComposite1.setLayoutData(data); final Button allRightButton = new Button(buttonsComposite1, SWT.PUSH); data = new GridData(SWT.FILL, SWT.CENTER, true, false); allRightButton.setLayoutData(data); allRightButton.setImage( EclipseNSISPlugin.getImageManager() .getImage(EclipseNSISPlugin.getResourceString("all.right.icon"))); // $NON-NLS-1$ allRightButton.setToolTipText( EclipseNSISPlugin.getResourceString("all.right.tooltip")); // $NON-NLS-1$ final Button rightButton = new Button(buttonsComposite1, SWT.PUSH); data = new GridData(SWT.FILL, SWT.CENTER, true, false); rightButton.setLayoutData(data); rightButton.setImage( EclipseNSISPlugin.getImageManager() .getImage(EclipseNSISPlugin.getResourceString("right.icon"))); // $NON-NLS-1$ rightButton.setToolTipText(EclipseNSISPlugin.getResourceString("right.tooltip")); // $NON-NLS-1$ final Button leftButton = new Button(buttonsComposite1, SWT.PUSH); data = new GridData(SWT.FILL, SWT.CENTER, true, false); leftButton.setLayoutData(data); leftButton.setImage( EclipseNSISPlugin.getImageManager() .getImage(EclipseNSISPlugin.getResourceString("left.icon"))); // $NON-NLS-1$ leftButton.setToolTipText(EclipseNSISPlugin.getResourceString("left.tooltip")); // $NON-NLS-1$ final Button allLeftButton = new Button(buttonsComposite1, SWT.PUSH); data = new GridData(SWT.FILL, SWT.CENTER, true, false); allLeftButton.setLayoutData(data); allLeftButton.setImage( EclipseNSISPlugin.getImageManager() .getImage(EclipseNSISPlugin.getResourceString("all.left.icon"))); // $NON-NLS-1$ allLeftButton.setToolTipText( EclipseNSISPlugin.getResourceString("all.left.tooltip")); // $NON-NLS-1$ Composite rightComposite = new Composite(listsComposite, SWT.NONE); rightComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); layout = new GridLayout(2, false); layout.marginHeight = 0; layout.marginWidth = 0; rightComposite.setLayout(layout); ((GridData) NSISWizardDialogUtil.createLabel( rightComposite, "selected.languages.label", //$NON-NLS-1$ true, m, isScriptWizard()) .getLayoutData()) .horizontalSpan = 2; final List selectedLangList = new List(rightComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI); data = new GridData(SWT.FILL, SWT.FILL, true, true); Dialog.applyDialogFont(selectedLangList); data.heightHint = Common.calculateControlSize(selectedLangList, 0, 12).y; selectedLangList.setLayoutData(data); m.addSlave(selectedLangList); final ListViewer selectedLangViewer = new ListViewer(selectedLangList); selectedLangViewer.setContentProvider(collectionContentProvider); selectedLangViewer.setInput(selectedLanguages); final ListViewerUpDownMover<java.util.List<NSISLanguage>, NSISLanguage> mover = new ListViewerUpDownMover<java.util.List<NSISLanguage>, NSISLanguage>() { @Override @SuppressWarnings("unchecked") protected java.util.List<NSISLanguage> getAllElements() { return (java.util.List<NSISLanguage>) ((ListViewer) getViewer()).getInput(); } @Override protected void updateStructuredViewerInput( java.util.List<NSISLanguage> input, java.util.List<NSISLanguage> elements, java.util.List<NSISLanguage> move, boolean isDown) { (input).clear(); (input).addAll(elements); } }; mover.setViewer(selectedLangViewer); final Composite buttonsComposite2 = new Composite(rightComposite, SWT.NONE); layout = new GridLayout(1, false); layout.marginHeight = 0; layout.marginWidth = 0; buttonsComposite2.setLayout(layout); data = new GridData(SWT.FILL, SWT.CENTER, false, false); buttonsComposite2.setLayoutData(data); final Button upButton = new Button(buttonsComposite2, SWT.PUSH); data = new GridData(SWT.FILL, SWT.CENTER, true, false); upButton.setLayoutData(data); upButton.setImage( EclipseNSISPlugin.getImageManager() .getImage(EclipseNSISPlugin.getResourceString("up.icon"))); // $NON-NLS-1$ upButton.setToolTipText(EclipseNSISPlugin.getResourceString("up.tooltip")); // $NON-NLS-1$ m.addSlave(upButton); final Button downButton = new Button(buttonsComposite2, SWT.PUSH); data = new GridData(SWT.FILL, SWT.CENTER, true, false); downButton.setLayoutData(data); downButton.setImage( EclipseNSISPlugin.getImageManager() .getImage(EclipseNSISPlugin.getResourceString("down.icon"))); // $NON-NLS-1$ downButton.setToolTipText(EclipseNSISPlugin.getResourceString("down.tooltip")); // $NON-NLS-1$ m.addSlave(downButton); Composite langOptions = langGroup; boolean showSupportedLangOption = NSISPreferences.getInstance().getNSISVersion().compareTo(INSISVersions.VERSION_2_26) >= 0; if (showSupportedLangOption) { langOptions = new Composite(langGroup, SWT.None); layout = new GridLayout(2, false); layout.marginHeight = 0; layout.marginWidth = 0; langOptions.setLayout(layout); data = new GridData(SWT.FILL, SWT.FILL, true, false); langOptions.setLayoutData(data); } final Button selectLang = NSISWizardDialogUtil.createCheckBox( langOptions, "select.language.label", settings.isSelectLanguage(), true, m, false); //$NON-NLS-1$ final Button displaySupported; if (showSupportedLangOption) { ((GridData) selectLang.getLayoutData()).horizontalSpan = 1; displaySupported = NSISWizardDialogUtil.createCheckBox( langOptions, "display.supported.languages.label", settings.isDisplaySupportedLanguages(), // $NON-NLS-1$ true, m, false); ((GridData) displaySupported.getLayoutData()).horizontalSpan = 1; displaySupported.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { mWizard.getSettings().setDisplaySupportedLanguages(displaySupported.getSelection()); } }); } else { displaySupported = null; } final MasterSlaveEnabler mse = new MasterSlaveEnabler() { public void enabled(Control control, boolean flag) {} @SuppressWarnings("unchecked") public boolean canEnable(Control control) { NSISWizardSettings settings = mWizard.getSettings(); if (control == allRightButton) { return settings.isEnableLanguageSupport() && availableLangViewer.getList().getItemCount() > 0; } else if (control == rightButton) { return settings.isEnableLanguageSupport() && !availableLangViewer.getSelection().isEmpty(); } else if (control == allLeftButton) { return settings.isEnableLanguageSupport() && selectedLangViewer.getList().getItemCount() > 0; } else if (control == leftButton) { return settings.isEnableLanguageSupport() && !selectedLangViewer.getSelection().isEmpty(); } else if (control == upButton) { return settings.isEnableLanguageSupport() && mover.canMoveUp(); } else if (control == downButton) { return settings.isEnableLanguageSupport() && mover.canMoveDown(); } else if (control == selectLang) { java.util.List<NSISLanguage> selectedLanguages = (java.util.List<NSISLanguage>) selectedLangViewer.getInput(); return settings.getInstallerType() != INSTALLER_TYPE_SILENT && settings.isEnableLanguageSupport() && selectedLanguages.size() > 1; } else if (control == displaySupported && displaySupported != null) { java.util.List<NSISLanguage> selectedLanguages = (java.util.List<NSISLanguage>) selectedLangViewer.getInput(); return settings.getInstallerType() != INSTALLER_TYPE_SILENT && settings.isEnableLanguageSupport() && selectedLanguages.size() > 1 && selectLang.getSelection(); } else { return true; } } }; m.addSlave(rightButton, mse); m.addSlave(allRightButton, mse); m.addSlave(leftButton, mse); m.addSlave(allLeftButton, mse); m.setEnabler(upButton, mse); m.setEnabler(downButton, mse); m.setEnabler(selectLang, mse); if (displaySupported != null) { m.setEnabler(displaySupported, mse); } selectLang.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { mWizard.getSettings().setSelectLanguage(selectLang.getSelection()); if (displaySupported != null) { displaySupported.setEnabled(mse.canEnable(displaySupported)); } } }); final Runnable langRunnable = new Runnable() { public void run() { availableLangViewer.refresh(false); selectedLangViewer.refresh(false); allRightButton.setEnabled(mse.canEnable(allRightButton)); allLeftButton.setEnabled(mse.canEnable(allLeftButton)); rightButton.setEnabled(mse.canEnable(rightButton)); leftButton.setEnabled(mse.canEnable(leftButton)); upButton.setEnabled(mse.canEnable(upButton)); downButton.setEnabled(mse.canEnable(downButton)); selectLang.setEnabled(mse.canEnable(selectLang)); if (displaySupported != null) { displaySupported.setEnabled(mse.canEnable(displaySupported)); } setPageComplete(validateField(LANG_CHECK)); } }; rightButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent se) { moveAcross( availableLangViewer, selectedLangViewer, Common.makeGenericList( NSISLanguage.class, ((IStructuredSelection) availableLangViewer.getSelection()).toList())); langRunnable.run(); } }); allRightButton.addSelectionListener( new SelectionAdapter() { @Override @SuppressWarnings("unchecked") public void widgetSelected(SelectionEvent se) { moveAcross( availableLangViewer, selectedLangViewer, (java.util.List<NSISLanguage>) availableLangViewer.getInput()); langRunnable.run(); } }); leftButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent se) { moveAcross( selectedLangViewer, availableLangViewer, Common.makeGenericList( NSISLanguage.class, ((IStructuredSelection) selectedLangViewer.getSelection()).toList())); langRunnable.run(); } }); allLeftButton.addSelectionListener( new SelectionAdapter() { @Override @SuppressWarnings("unchecked") public void widgetSelected(SelectionEvent se) { moveAcross( selectedLangViewer, availableLangViewer, (java.util.List<NSISLanguage>) selectedLangViewer.getInput()); langRunnable.run(); } }); upButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent se) { mover.moveUp(); langRunnable.run(); } }); downButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent se) { mover.moveDown(); langRunnable.run(); } }); availableLangViewer.addSelectionChangedListener( new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { rightButton.setEnabled(mse.canEnable(rightButton)); allRightButton.setEnabled(mse.canEnable(allRightButton)); } }); availableLangViewer .getList() .addSelectionListener( new SelectionAdapter() { @Override public void widgetDefaultSelected(SelectionEvent event) { IStructuredSelection sel = (IStructuredSelection) availableLangViewer.getSelection(); if (!sel.isEmpty()) { moveAcross( availableLangViewer, selectedLangViewer, Common.makeGenericList(NSISLanguage.class, sel.toList())); selectedLangViewer.reveal(sel.getFirstElement()); langRunnable.run(); } } }); selectedLangViewer.addSelectionChangedListener( new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { leftButton.setEnabled(mse.canEnable(leftButton)); allLeftButton.setEnabled(mse.canEnable(allLeftButton)); upButton.setEnabled(mse.canEnable(upButton)); downButton.setEnabled(mse.canEnable(downButton)); selectLang.setEnabled(mse.canEnable(selectLang)); if (displaySupported != null) { displaySupported.setEnabled(mse.canEnable(displaySupported)); } } }); selectedLangViewer .getList() .addSelectionListener( new SelectionAdapter() { @Override public void widgetDefaultSelected(SelectionEvent event) { IStructuredSelection sel = (IStructuredSelection) selectedLangViewer.getSelection(); if (!sel.isEmpty()) { moveAcross( selectedLangViewer, availableLangViewer, Common.makeGenericList(NSISLanguage.class, sel.toList())); availableLangViewer.reveal(sel.getFirstElement()); langRunnable.run(); } } }); m.updateSlaves(); listsComposite.addListener( SWT.Resize, new Listener() { boolean init = false; public void handleEvent(Event e) { if (!init) { // Stupid hack so that the height hint doesn't get changed // on the first resize, // i.e., when the page is drawn for the first time. init = true; } else { Point size = listsComposite.getSize(); GridLayout layout = (GridLayout) listsComposite.getLayout(); int heightHint = size.y - 2 * layout.marginHeight; ((GridData) availableLangList.getLayoutData()).heightHint = heightHint; ((GridData) selectedLangList.getLayoutData()).heightHint = heightHint; int totalWidth = size.x - 2 * layout.marginWidth - 3 * layout.horizontalSpacing; int listWidth = (int) (totalWidth * 0.4); int buttonWidth = (int) (0.5 * (totalWidth - 2 * listWidth)); size = availableLangList.computeSize(listWidth, SWT.DEFAULT); int delta = 0; if (size.x > listWidth) { delta = size.x - listWidth; listWidth = listWidth - delta; } ((GridData) availableLangList.getLayoutData()).widthHint = listWidth; ((GridData) buttonsComposite1.getLayoutData()).widthHint = totalWidth - 2 * (listWidth + delta) - buttonWidth; ((GridData) selectedLangList.getLayoutData()).widthHint = listWidth; ((GridData) buttonsComposite2.getLayoutData()).widthHint = buttonWidth; listsComposite.layout(); } } }); addPageChangedRunnable( new Runnable() { public void run() { if (isCurrentPage()) { selectLang.setEnabled(mse.canEnable(selectLang)); if (displaySupported != null) { displaySupported.setEnabled(mse.canEnable(displaySupported)); } } } }); mWizard.addSettingsListener( new INSISWizardSettingsListener() { public void settingsChanged( NSISWizardSettings oldSettings, NSISWizardSettings newSettings) { enableLangSupport.setSelection(newSettings.isEnableLanguageSupport()); m.updateSlaves(); selectLang.setSelection(newSettings.isSelectLanguage()); if (displaySupported != null) { displaySupported.setSelection(newSettings.isDisplaySupportedLanguages()); } java.util.List<NSISLanguage> selectedLanguages = newSettings.getLanguages(); java.util.List<NSISLanguage> availableLanguages = NSISLanguageManager.getInstance().getLanguages(); if (selectedLanguages.isEmpty()) { NSISWizardWelcomePage welcomePage = (NSISWizardWelcomePage) mWizard.getPage(NSISWizardWelcomePage.NAME); if (welcomePage != null) { if (!welcomePage.isCreateFromTemplate()) { NSISLanguage defaultLanguage = NSISLanguageManager.getInstance().getDefaultLanguage(); if (defaultLanguage != null && availableLanguages.contains(defaultLanguage)) { selectedLanguages.add(defaultLanguage); } } } } selectedLangViewer.setInput(selectedLanguages); availableLanguages.removeAll(selectedLanguages); availableLangViewer.setInput(availableLanguages); } }); }
/** Creates the "Control" widget children. */ void createControlWidgets() { /* Create the combo */ String[] strings = { ControlExample.getResourceString("ColorDialog"), ControlExample.getResourceString("DirectoryDialog"), ControlExample.getResourceString("FileDialog"), ControlExample.getResourceString("FontDialog"), ControlExample.getResourceString("PrintDialog"), ControlExample.getResourceString("MessageBox"), }; dialogCombo = new Combo(dialogStyleGroup, SWT.READ_ONLY); dialogCombo.setItems(strings); dialogCombo.setText(strings[0]); dialogCombo.setVisibleItemCount(strings.length); /* Create the create dialog button */ createButton = new Button(dialogStyleGroup, SWT.NONE); createButton.setText(ControlExample.getResourceString("Create_Dialog")); createButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER)); /* Create a group for the various dialog button style controls */ Group buttonStyleGroup = new Group(controlGroup, SWT.NONE); buttonStyleGroup.setLayout(new GridLayout()); buttonStyleGroup.setLayoutData( new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); buttonStyleGroup.setText(ControlExample.getResourceString("Button_Styles")); /* Create the button style buttons */ okButton = new Button(buttonStyleGroup, SWT.CHECK); okButton.setText("SWT.OK"); cancelButton = new Button(buttonStyleGroup, SWT.CHECK); cancelButton.setText("SWT.CANCEL"); yesButton = new Button(buttonStyleGroup, SWT.CHECK); yesButton.setText("SWT.YES"); noButton = new Button(buttonStyleGroup, SWT.CHECK); noButton.setText("SWT.NO"); retryButton = new Button(buttonStyleGroup, SWT.CHECK); retryButton.setText("SWT.RETRY"); abortButton = new Button(buttonStyleGroup, SWT.CHECK); abortButton.setText("SWT.ABORT"); ignoreButton = new Button(buttonStyleGroup, SWT.CHECK); ignoreButton.setText("SWT.IGNORE"); /* Create a group for the icon style controls */ Group iconStyleGroup = new Group(controlGroup, SWT.NONE); iconStyleGroup.setLayout(new GridLayout()); iconStyleGroup.setLayoutData( new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); iconStyleGroup.setText(ControlExample.getResourceString("Icon_Styles")); /* Create the icon style buttons */ iconErrorButton = new Button(iconStyleGroup, SWT.RADIO); iconErrorButton.setText("SWT.ICON_ERROR"); iconInformationButton = new Button(iconStyleGroup, SWT.RADIO); iconInformationButton.setText("SWT.ICON_INFORMATION"); iconQuestionButton = new Button(iconStyleGroup, SWT.RADIO); iconQuestionButton.setText("SWT.ICON_QUESTION"); iconWarningButton = new Button(iconStyleGroup, SWT.RADIO); iconWarningButton.setText("SWT.ICON_WARNING"); iconWorkingButton = new Button(iconStyleGroup, SWT.RADIO); iconWorkingButton.setText("SWT.ICON_WORKING"); noIconButton = new Button(iconStyleGroup, SWT.RADIO); noIconButton.setText(ControlExample.getResourceString("No_Icon")); /* Create a group for the modal style controls */ Group modalStyleGroup = new Group(controlGroup, SWT.NONE); modalStyleGroup.setLayout(new GridLayout()); modalStyleGroup.setLayoutData( new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); modalStyleGroup.setText(ControlExample.getResourceString("Modal_Styles")); /* Create the modal style buttons */ primaryModalButton = new Button(modalStyleGroup, SWT.RADIO); primaryModalButton.setText("SWT.PRIMARY_MODAL"); applicationModalButton = new Button(modalStyleGroup, SWT.RADIO); applicationModalButton.setText("SWT.APPLICATION_MODAL"); systemModalButton = new Button(modalStyleGroup, SWT.RADIO); systemModalButton.setText("SWT.SYSTEM_MODAL"); /* Create a group for the file dialog style controls */ Group fileDialogStyleGroup = new Group(controlGroup, SWT.NONE); fileDialogStyleGroup.setLayout(new GridLayout()); fileDialogStyleGroup.setLayoutData( new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); fileDialogStyleGroup.setText(ControlExample.getResourceString("File_Dialog_Styles")); /* Create the file dialog style buttons */ openButton = new Button(fileDialogStyleGroup, SWT.RADIO); openButton.setText("SWT.OPEN"); saveButton = new Button(fileDialogStyleGroup, SWT.RADIO); saveButton.setText("SWT.SAVE"); multiButton = new Button(fileDialogStyleGroup, SWT.CHECK); multiButton.setText("SWT.MULTI"); /* Create the orientation group */ if (RTL_SUPPORT_ENABLE) { createOrientationGroup(); } /* Add the listeners */ dialogCombo.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { dialogSelected(event); } }); createButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { createButtonSelected(event); } }); SelectionListener buttonStyleListener = new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { buttonStyleSelected(event); } }; okButton.addSelectionListener(buttonStyleListener); cancelButton.addSelectionListener(buttonStyleListener); yesButton.addSelectionListener(buttonStyleListener); noButton.addSelectionListener(buttonStyleListener); retryButton.addSelectionListener(buttonStyleListener); abortButton.addSelectionListener(buttonStyleListener); ignoreButton.addSelectionListener(buttonStyleListener); /* Set default values for style buttons */ okButton.setEnabled(false); cancelButton.setEnabled(false); yesButton.setEnabled(false); noButton.setEnabled(false); retryButton.setEnabled(false); abortButton.setEnabled(false); ignoreButton.setEnabled(false); iconErrorButton.setEnabled(false); iconInformationButton.setEnabled(false); iconQuestionButton.setEnabled(false); iconWarningButton.setEnabled(false); iconWorkingButton.setEnabled(false); noIconButton.setEnabled(false); saveButton.setEnabled(false); openButton.setEnabled(false); openButton.setSelection(true); multiButton.setEnabled(false); noIconButton.setSelection(true); }
/** @see PreferencePage#createContents(Composite) */ protected Control createContents(Composite ancestor) { Composite parent = new Composite(ancestor, SWT.NULL); GridLayout layout = new GridLayout(); layout.numColumns = 2; layout.marginHeight = 0; layout.marginWidth = 0; parent.setLayout(layout); // layout the top table & its buttons Label label = new Label(parent, SWT.LEFT); label.setText(XMLCompareMessages.XMLComparePreference_topTableLabel); GridData data = new GridData(); data.horizontalAlignment = GridData.FILL; data.horizontalSpan = 2; label.setLayoutData(data); fIdMapsTable = new Table(parent, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION); fIdMapsTable.setHeaderVisible(true); data = new GridData(GridData.FILL_BOTH); data.heightHint = fIdMapsTable.getItemHeight() * 4; fIdMapsTable.setLayoutData(data); fIdMapsTable.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { selectionChanged(); } }); String column2Text = XMLCompareMessages.XMLComparePreference_topTableColumn2; String column3Text = XMLCompareMessages.XMLComparePreference_topTableColumn3; ColumnLayoutData columnLayouts[] = { new ColumnWeightData(1), new ColumnPixelData(convertWidthInCharsToPixels(column2Text.length() + 2), true), new ColumnPixelData(convertWidthInCharsToPixels(column3Text.length() + 5), true) }; TableLayout tablelayout = new TableLayout(); fIdMapsTable.setLayout(tablelayout); for (int i = 0; i < 3; i++) tablelayout.addColumnData(columnLayouts[i]); TableColumn column = new TableColumn(fIdMapsTable, SWT.NONE); column.setText(XMLCompareMessages.XMLComparePreference_topTableColumn1); column = new TableColumn(fIdMapsTable, SWT.NONE); column.setText(column2Text); column = new TableColumn(fIdMapsTable, SWT.NONE); column.setText(column3Text); fillIdMapsTable(); Composite buttons = new Composite(parent, SWT.NULL); buttons.setLayout(new GridLayout()); data = new GridData(); data.verticalAlignment = GridData.FILL; data.horizontalAlignment = GridData.FILL; buttons.setLayoutData(data); fAddIdMapButton = new Button(buttons, SWT.PUSH); fAddIdMapButton.setText(XMLCompareMessages.XMLComparePreference_topAdd); fAddIdMapButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { addIdMap(fAddIdMapButton.getShell()); } }); data = new GridData(); data.horizontalAlignment = GridData.FILL; // data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT); int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); data.widthHint = Math.max(widthHint, fAddIdMapButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); fAddIdMapButton.setLayoutData(data); fRenameIdMapButton = new Button(buttons, SWT.PUSH); fRenameIdMapButton.setText(XMLCompareMessages.XMLComparePreference_topRename); fRenameIdMapButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { renameIdMap(fRenameIdMapButton.getShell()); } }); data = new GridData(); data.horizontalAlignment = GridData.FILL; // data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT); widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); data.widthHint = Math.max(widthHint, fAddIdMapButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); fRenameIdMapButton.setLayoutData(data); fRemoveIdMapButton = new Button(buttons, SWT.PUSH); fRemoveIdMapButton.setText(XMLCompareMessages.XMLComparePreference_topRemove); fRemoveIdMapButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { removeIdMap(fRemoveIdMapButton.getShell()); } }); data = new GridData(); data.horizontalAlignment = GridData.FILL; // data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT); widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); data.widthHint = Math.max(widthHint, fRemoveIdMapButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); fRemoveIdMapButton.setLayoutData(data); createSpacer(buttons); fEditIdMapButton = new Button(buttons, SWT.PUSH); fEditIdMapButton.setText(XMLCompareMessages.XMLComparePreference_topEdit); fEditIdMapButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { editIdMap(fEditIdMapButton.getShell()); } }); data = new GridData(); data.horizontalAlignment = GridData.FILL; // data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT); widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); data.widthHint = Math.max(widthHint, fEditIdMapButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); fEditIdMapButton.setLayoutData(data); // Spacer label = new Label(parent, SWT.LEFT); data = new GridData(); data.horizontalAlignment = GridData.FILL; data.horizontalSpan = 2; label.setLayoutData(data); // layout the middle table & its buttons label = new Label(parent, SWT.LEFT); label.setText(XMLCompareMessages.XMLComparePreference_middleTableLabel); data = new GridData(); data.horizontalAlignment = GridData.FILL; data.horizontalSpan = 2; label.setLayoutData(data); fMappingsTable = new Table(parent, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION); fMappingsTable.setHeaderVisible(true); data = new GridData(GridData.FILL_BOTH); data.heightHint = fMappingsTable.getItemHeight() * 4; data.widthHint = convertWidthInCharsToPixels(70); fMappingsTable.setLayoutData(data); column3Text = XMLCompareMessages.XMLComparePreference_middleTableColumn3; String column4Text = XMLCompareMessages.XMLComparePreference_middleTableColumn4; columnLayouts = new ColumnLayoutData[] { new ColumnWeightData(10), new ColumnWeightData(18), new ColumnPixelData(convertWidthInCharsToPixels(column3Text.length() + 1), true), new ColumnPixelData(convertWidthInCharsToPixels(column4Text.length() + 3), true) }; tablelayout = new TableLayout(); fMappingsTable.setLayout(tablelayout); for (int i = 0; i < 4; i++) tablelayout.addColumnData(columnLayouts[i]); column = new TableColumn(fMappingsTable, SWT.NONE); column.setText(XMLCompareMessages.XMLComparePreference_middleTableColumn1); column = new TableColumn(fMappingsTable, SWT.NONE); column.setText(XMLCompareMessages.XMLComparePreference_middleTableColumn2); column = new TableColumn(fMappingsTable, SWT.NONE); column.setText(column3Text); column = new TableColumn(fMappingsTable, SWT.NONE); column.setText(column4Text); buttons = new Composite(parent, SWT.NULL); buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; buttons.setLayout(layout); fNewMappingsButton = new Button(buttons, SWT.PUSH); fNewMappingsButton.setLayoutData(getButtonGridData(fNewMappingsButton)); fNewMappingsButton.setText(XMLCompareMessages.XMLComparePreference_middleNew); fNewMappingsButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { addMapping(fAddIdMapButton.getShell()); } }); fEditMappingsButton = new Button(buttons, SWT.PUSH); fEditMappingsButton.setLayoutData(getButtonGridData(fEditMappingsButton)); fEditMappingsButton.setText(XMLCompareMessages.XMLComparePreference_middleEdit); fEditMappingsButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { editMapping(fEditMappingsButton.getShell()); } }); fRemoveMappingsButton = new Button(buttons, SWT.PUSH); fRemoveMappingsButton.setLayoutData(getButtonGridData(fRemoveMappingsButton)); fRemoveMappingsButton.setText(XMLCompareMessages.XMLComparePreference_middleRemove); fRemoveMappingsButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { removeMapping(fRemoveMappingsButton.getShell()); } }); createSpacer(buttons); // layout the botton table & its buttons label = new Label(parent, SWT.LEFT); label.setText(XMLCompareMessages.XMLComparePreference_bottomTableLabel); data = new GridData(); data.horizontalAlignment = GridData.FILL; data.horizontalSpan = 2; label.setLayoutData(data); fOrderedTable = new Table(parent, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION); fOrderedTable.setHeaderVisible(true); data = new GridData(GridData.FILL_BOTH); data.heightHint = fOrderedTable.getItemHeight() * 2; data.widthHint = convertWidthInCharsToPixels(70); fOrderedTable.setLayoutData(data); columnLayouts = new ColumnLayoutData[] {new ColumnWeightData(1), new ColumnWeightData(1)}; tablelayout = new TableLayout(); fOrderedTable.setLayout(tablelayout); for (int i = 0; i < 2; i++) tablelayout.addColumnData(columnLayouts[i]); column = new TableColumn(fOrderedTable, SWT.NONE); column.setText(XMLCompareMessages.XMLComparePreference_bottomTableColumn1); column = new TableColumn(fOrderedTable, SWT.NONE); column.setText(XMLCompareMessages.XMLComparePreference_bottomTableColumn2); buttons = new Composite(parent, SWT.NULL); buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; buttons.setLayout(layout); fNewOrderedButton = new Button(buttons, SWT.PUSH); fNewOrderedButton.setLayoutData(getButtonGridData(fNewOrderedButton)); fNewOrderedButton.setText(XMLCompareMessages.XMLComparePreference_bottomNew); fNewOrderedButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { addOrdered(fNewOrderedButton.getShell()); } }); fEditOrderedButton = new Button(buttons, SWT.PUSH); fEditOrderedButton.setLayoutData(getButtonGridData(fEditOrderedButton)); fEditOrderedButton.setText(XMLCompareMessages.XMLComparePreference_bottomEdit); fEditOrderedButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { editOrdered(fEditOrderedButton.getShell()); } }); fRemoveOrderedButton = new Button(buttons, SWT.PUSH); fRemoveOrderedButton.setLayoutData(getButtonGridData(fRemoveOrderedButton)); fRemoveOrderedButton.setText(XMLCompareMessages.XMLComparePreference_bottomRemove); fRemoveOrderedButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { removeOrdered(fRemoveOrderedButton.getShell()); } }); createSpacer(buttons); fIdMapsTable.setSelection(0); fIdMapsTable.setFocus(); selectionChanged(); return parent; }
protected authDialog( AESemaphore _sem, Display display, String realm, boolean is_tracker, String target, String details) { sem = _sem; if (display.isDisposed()) { sem.releaseForever(); return; } final String ignore_key = "IgnoreAuth:" + realm + ":" + target + ":" + details; if (RememberedDecisionsManager.getRememberedDecision(ignore_key) == 1) { Debug.out( "Authentication for " + realm + "/" + target + "/" + details + " ignored as told not to ask again"); sem.releaseForever(); return; } shell = ShellFactory.createMainShell(SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); Utils.setShellIcon(shell); Messages.setLanguageText(shell, "authenticator.title"); GridLayout layout = new GridLayout(); layout.numColumns = 3; shell.setLayout(layout); GridData gridData; // realm Label realm_label = new Label(shell, SWT.NULL); Messages.setLanguageText(realm_label, "authenticator.realm"); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; realm_label.setLayoutData(gridData); Label realm_value = new Label(shell, SWT.NULL); realm_value.setText(realm.replaceAll("&", "&&")); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 2; realm_value.setLayoutData(gridData); // target Label target_label = new Label(shell, SWT.NULL); Messages.setLanguageText( target_label, is_tracker ? "authenticator.tracker" : "authenticator.location"); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; target_label.setLayoutData(gridData); Label target_value = new Label(shell, SWT.NULL); target_value.setText(target.replaceAll("&", "&&")); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 2; target_value.setLayoutData(gridData); if (details != null) { Label details_label = new Label(shell, SWT.NULL); Messages.setLanguageText( details_label, is_tracker ? "authenticator.torrent" : "authenticator.details"); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; details_label.setLayoutData(gridData); Label details_value = new Label(shell, SWT.NULL); details_value.setText(details.replaceAll("&", "&&")); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 2; details_value.setLayoutData(gridData); } // user Label user_label = new Label(shell, SWT.NULL); Messages.setLanguageText(user_label, "authenticator.user"); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; user_label.setLayoutData(gridData); final Text user_value = new Text(shell, SWT.BORDER); user_value.setText(""); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 2; user_value.setLayoutData(gridData); user_value.addListener( SWT.Modify, new Listener() { public void handleEvent(Event event) { username = user_value.getText(); } }); // password Label password_label = new Label(shell, SWT.NULL); Messages.setLanguageText(password_label, "authenticator.password"); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; password_label.setLayoutData(gridData); final Text password_value = new Text(shell, SWT.BORDER); password_value.setEchoChar('*'); password_value.setText(""); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 2; password_value.setLayoutData(gridData); password_value.addListener( SWT.Modify, new Listener() { public void handleEvent(Event event) { password = password_value.getText(); } }); // persist Label blank_label = new Label(shell, SWT.NULL); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; blank_label.setLayoutData(gridData); final Button checkBox = new Button(shell, SWT.CHECK); checkBox.setText(MessageText.getString("authenticator.savepassword")); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; checkBox.setLayoutData(gridData); checkBox.addListener( SWT.Selection, new Listener() { public void handleEvent(Event e) { persist = checkBox.getSelection(); } }); final Button dontAsk = new Button(shell, SWT.CHECK); dontAsk.setText(MessageText.getString("general.dont.ask.again")); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; dontAsk.setLayoutData(gridData); dontAsk.addListener( SWT.Selection, new Listener() { public void handleEvent(Event e) { RememberedDecisionsManager.setRemembered(ignore_key, dontAsk.getSelection() ? 1 : 0); } }); // line Label labelSeparator = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); gridData = new GridData(GridData.FILL_HORIZONTAL); gridData.horizontalSpan = 3; labelSeparator.setLayoutData(gridData); // buttons new Label(shell, SWT.NULL); Button bOk = new Button(shell, SWT.PUSH); Messages.setLanguageText(bOk, "Button.ok"); gridData = new GridData( GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END | GridData.HORIZONTAL_ALIGN_FILL); gridData.grabExcessHorizontalSpace = true; gridData.widthHint = 70; bOk.setLayoutData(gridData); bOk.addListener( SWT.Selection, new Listener() { public void handleEvent(Event e) { close(true); } }); Button bCancel = new Button(shell, SWT.PUSH); Messages.setLanguageText(bCancel, "Button.cancel"); gridData = new GridData(GridData.HORIZONTAL_ALIGN_END); gridData.grabExcessHorizontalSpace = false; gridData.widthHint = 70; bCancel.setLayoutData(gridData); bCancel.addListener( SWT.Selection, new Listener() { public void handleEvent(Event e) { close(false); } }); shell.setDefaultButton(bOk); shell.addListener( SWT.Traverse, new Listener() { public void handleEvent(Event e) { if (e.character == SWT.ESC) { close(false); } } }); shell.pack(); Utils.centreWindow(shell); shell.open(); }
/** * Creates the dialog's contents * * @param shell the dialog window */ private void createContents(final Shell shell) { final Config config = controller.getConfig(); // Create the ScrolledComposite to scroll horizontally and vertically ScrolledComposite sc = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL); // Create the parent Composite container for the three child containers Composite container = new Composite(sc, SWT.NONE); GridLayout containerLayout = new GridLayout(1, false); container.setLayout(containerLayout); shell.setLayout(new FillLayout()); GridData data; data = new GridData(GridData.FILL_HORIZONTAL); data.heightHint = 50; data.widthHint = 400; // START TOP COMPONENT Composite topComp = new Composite(container, SWT.NONE); GridLayout layout = new GridLayout(1, false); layout.marginHeight = 0; layout.marginWidth = 0; layout.verticalSpacing = 0; topComp.setLayout(layout); topComp.setLayoutData(data); Label blank = new Label(topComp, SWT.NONE); data = new GridData(GridData.FILL_HORIZONTAL); data.heightHint = 10; blank.setLayoutData(data); blank.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); // Show the message Label label = new Label(topComp, SWT.NONE); label.setText(message); data = new GridData(GridData.FILL_HORIZONTAL); data.heightHint = 30; data.widthHint = 370; Font f = label.getFont(); FontData[] farr = f.getFontData(); FontData fd = farr[0]; fd.setStyle(SWT.BOLD); label.setFont(new Font(Display.getCurrent(), fd)); label.setLayoutData(data); label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); Label labelSeparator = new Label(topComp, SWT.SEPARATOR | SWT.HORIZONTAL); data = new GridData(GridData.FILL_HORIZONTAL); labelSeparator.setLayoutData(data); // END TOP COMPONENT // START MIDDLE COMPONENT Composite restComp = new Composite(container, SWT.NONE); data = new GridData(GridData.FILL_BOTH); restComp.setLayoutData(data); layout = new GridLayout(2, false); layout.verticalSpacing = 10; restComp.setLayout(layout); // Hide welecome screen Label labelHideWelcomeScreen = new Label(restComp, SWT.RIGHT); labelHideWelcomeScreen.setText( Labels.getString("AdvancedSettingsDialog.hideWelcomeScreen")); // $NON-NLS-1$ labelHideWelcomeScreen.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); buttonHideWelcomeScreen = new Button(restComp, SWT.CHECK); buttonHideWelcomeScreen.setSelection(config.getBoolean(Config.HIDE_WELCOME_SCREEN)); // batch size Label labelBatch = new Label(restComp, SWT.RIGHT); labelBatch.setText(Labels.getString("AdvancedSettingsDialog.batchSize")); // $NON-NLS-1$ data = new GridData(GridData.HORIZONTAL_ALIGN_END); labelBatch.setLayoutData(data); textBatch = new Text(restComp, SWT.BORDER); textBatch.setText(config.getString(Config.LOAD_BATCH_SIZE)); textBatch.setTextLimit(8); textBatch.addVerifyListener( new VerifyListener() { @Override public void verifyText(VerifyEvent event) { event.doit = Character.isISOControl(event.character) || Character.isDigit(event.character); } }); data = new GridData(); data.widthHint = 50; textBatch.setLayoutData(data); // insert Nulls Label labelNulls = new Label(restComp, SWT.RIGHT); labelNulls.setText(Labels.getString("AdvancedSettingsDialog.insertNulls")); // $NON-NLS-1$ data = new GridData(GridData.HORIZONTAL_ALIGN_END); labelNulls.setLayoutData(data); buttonNulls = new Button(restComp, SWT.CHECK); buttonNulls.setSelection(config.getBoolean(Config.INSERT_NULLS)); // assignment rules Label labelRule = new Label(restComp, SWT.RIGHT); labelRule.setText(Labels.getString("AdvancedSettingsDialog.assignmentRule")); // $NON-NLS-1$ data = new GridData(GridData.HORIZONTAL_ALIGN_END); labelRule.setLayoutData(data); textRule = new Text(restComp, SWT.BORDER); textRule.setTextLimit(18); data = new GridData(); data.widthHint = 115; textRule.setLayoutData(data); textRule.setText(config.getString(Config.ASSIGNMENT_RULE)); // endpoint Label labelEndpoint = new Label(restComp, SWT.RIGHT); labelEndpoint.setText(Labels.getString("AdvancedSettingsDialog.serverURL")); // $NON-NLS-1$ data = new GridData(GridData.HORIZONTAL_ALIGN_END); labelEndpoint.setLayoutData(data); textEndpoint = new Text(restComp, SWT.BORDER); data = new GridData(); data.widthHint = 250; textEndpoint.setLayoutData(data); String endpoint = config.getString(Config.ENDPOINT); if ("".equals(endpoint)) { // $NON-NLS-1$ endpoint = defaultServer; } textEndpoint.setText(endpoint); // reset url on login Label labelResetUrl = new Label(restComp, SWT.RIGHT); labelResetUrl.setText( Labels.getString("AdvancedSettingsDialog.resetUrlOnLogin")); // $NON-NLS-1$ data = new GridData(GridData.HORIZONTAL_ALIGN_END); labelResetUrl.setLayoutData(data); buttonResetUrl = new Button(restComp, SWT.CHECK); buttonResetUrl.setSelection(config.getBoolean(Config.RESET_URL_ON_LOGIN)); // insert compression Label labelCompression = new Label(restComp, SWT.RIGHT); labelCompression.setText(Labels.getString("AdvancedSettingsDialog.compression")); // $NON-NLS-1$ data = new GridData(GridData.HORIZONTAL_ALIGN_END); labelCompression.setLayoutData(data); buttonCompression = new Button(restComp, SWT.CHECK); buttonCompression.setSelection(config.getBoolean(Config.NO_COMPRESSION)); // timeout size Label labelTimeout = new Label(restComp, SWT.RIGHT); labelTimeout.setText(Labels.getString("AdvancedSettingsDialog.timeout")); // $NON-NLS-1$ data = new GridData(GridData.HORIZONTAL_ALIGN_END); labelTimeout.setLayoutData(data); textTimeout = new Text(restComp, SWT.BORDER); textTimeout.setTextLimit(4); textTimeout.setText(config.getString(Config.TIMEOUT_SECS)); textTimeout.addVerifyListener( new VerifyListener() { @Override public void verifyText(VerifyEvent event) { event.doit = Character.isISOControl(event.character) || Character.isDigit(event.character); } }); data = new GridData(); data.widthHint = 30; textTimeout.setLayoutData(data); // extraction batch size Label labelQueryBatch = new Label(restComp, SWT.RIGHT); labelQueryBatch.setText(Labels.getString("ExtractionInputDialog.querySize")); // $NON-NLS-1$ data = new GridData(GridData.HORIZONTAL_ALIGN_END); labelQueryBatch.setLayoutData(data); textQueryBatch = new Text(restComp, SWT.BORDER); textQueryBatch.setText(config.getString(Config.EXTRACT_REQUEST_SIZE)); textQueryBatch.setTextLimit(4); textQueryBatch.addVerifyListener( new VerifyListener() { @Override public void verifyText(VerifyEvent event) { event.doit = Character.isISOControl(event.character) || Character.isDigit(event.character); } }); data = new GridData(); data.widthHint = 30; textQueryBatch.setLayoutData(data); // enable/disable output of success file for extracts Label labelOutputExtractStatus = new Label(restComp, SWT.RIGHT); labelOutputExtractStatus.setText( Labels.getString("AdvancedSettingsDialog.outputExtractStatus")); // $NON-NLS-1$ data = new GridData(GridData.HORIZONTAL_ALIGN_END); labelOutputExtractStatus.setLayoutData(data); buttonOutputExtractStatus = new Button(restComp, SWT.CHECK); buttonOutputExtractStatus.setSelection(config.getBoolean(Config.ENABLE_EXTRACT_STATUS_OUTPUT)); // utf-8 for loading Label labelReadUTF8 = new Label(restComp, SWT.RIGHT); labelReadUTF8.setText(Labels.getString("AdvancedSettingsDialog.readUTF8")); // $NON-NLS-1$ data = new GridData(GridData.HORIZONTAL_ALIGN_END); labelReadUTF8.setLayoutData(data); buttonReadUtf8 = new Button(restComp, SWT.CHECK); buttonReadUtf8.setSelection(config.getBoolean(Config.READ_UTF8)); // utf-8 for extraction Label labelWriteUTF8 = new Label(restComp, SWT.RIGHT); labelWriteUTF8.setText(Labels.getString("AdvancedSettingsDialog.writeUTF8")); // $NON-NLS-1$ data = new GridData(GridData.HORIZONTAL_ALIGN_END); labelWriteUTF8.setLayoutData(data); buttonWriteUtf8 = new Button(restComp, SWT.CHECK); buttonWriteUtf8.setSelection(config.getBoolean(Config.WRITE_UTF8)); // European Dates Label labelEuropeanDates = new Label(restComp, SWT.RIGHT); labelEuropeanDates.setText( Labels.getString("AdvancedSettingsDialog.useEuropeanDateFormat")); // $NON-NLS-1$ data = new GridData(GridData.HORIZONTAL_ALIGN_END); labelEuropeanDates.setLayoutData(data); buttonEuroDates = new Button(restComp, SWT.CHECK); buttonEuroDates.setSelection(config.getBoolean(Config.EURO_DATES)); // Field truncation Label labelTruncateFields = new Label(restComp, SWT.RIGHT); labelTruncateFields.setText(Labels.getString("AdvancedSettingsDialog.allowFieldTruncation")); data = new GridData(GridData.HORIZONTAL_ALIGN_END); labelTruncateFields.setLayoutData(data); buttonTruncateFields = new Button(restComp, SWT.CHECK); buttonTruncateFields.setSelection(config.getBoolean(Config.TRUNCATE_FIELDS)); Label labelCsvCommand = new Label(restComp, SWT.RIGHT); labelCsvCommand.setText(Labels.getString("AdvancedSettingsDialog.useCommaAsCsvDelimiter")); data = new GridData(GridData.HORIZONTAL_ALIGN_END); labelCsvCommand.setLayoutData(data); buttonCsvComma = new Button(restComp, SWT.CHECK); buttonCsvComma.setSelection(config.getBoolean(Config.CSV_DELIMETER_COMMA)); Label labelTabCommand = new Label(restComp, SWT.RIGHT); labelTabCommand.setText(Labels.getString("AdvancedSettingsDialog.useTabAsCsvDelimiter")); data = new GridData(GridData.HORIZONTAL_ALIGN_END); labelTabCommand.setLayoutData(data); buttonCsvTab = new Button(restComp, SWT.CHECK); buttonCsvTab.setSelection(config.getBoolean(Config.CSV_DELIMETER_TAB)); Label labelOtherCommand = new Label(restComp, SWT.RIGHT); labelOtherCommand.setText(Labels.getString("AdvancedSettingsDialog.useOtherAsCsvDelimiter")); data = new GridData(GridData.HORIZONTAL_ALIGN_END); labelOtherCommand.setLayoutData(data); buttonCsvOther = new Button(restComp, SWT.CHECK); buttonCsvOther.setSelection(config.getBoolean(Config.CSV_DELIMETER_OTHER)); Label labelOtherDelimiterValue = new Label(restComp, SWT.RIGHT); labelOtherDelimiterValue.setText( Labels.getString("AdvancedSettingsDialog.csvOtherDelimiterValue")); data = new GridData(GridData.HORIZONTAL_ALIGN_END); labelOtherDelimiterValue.setLayoutData(data); textSplitterValue = new Text(restComp, SWT.BORDER); textSplitterValue.setText(config.getString(Config.CSV_DELIMETER_OTHER_VALUE)); data = new GridData(); data.widthHint = 25; textSplitterValue.setLayoutData(data); // Enable Bulk API Setting Label labelUseBulkApi = new Label(restComp, SWT.RIGHT); labelUseBulkApi.setText(Labels.getString("AdvancedSettingsDialog.useBulkApi")); // $NON-NLS-1$ data = new GridData(GridData.HORIZONTAL_ALIGN_END); labelUseBulkApi.setLayoutData(data); boolean useBulkAPI = config.getBoolean(Config.BULK_API_ENABLED); buttonUseBulkApi = new Button(restComp, SWT.CHECK); buttonUseBulkApi.setSelection(useBulkAPI); buttonUseBulkApi.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { super.widgetSelected(e); boolean enabled = buttonUseBulkApi.getSelection(); // update batch size when this setting changes int newDefaultBatchSize = controller.getConfig().getDefaultBatchSize(enabled); logger.info("Setting batch size to " + newDefaultBatchSize); textBatch.setText(String.valueOf(newDefaultBatchSize)); // make sure the appropriate check boxes are enabled or disabled initBulkApiSetting(enabled); } }); // Bulk API serial concurrency mode setting Label labelBulkApiSerialMode = new Label(restComp, SWT.RIGHT); labelBulkApiSerialMode.setText( Labels.getString("AdvancedSettingsDialog.bulkApiSerialMode")); // $NON-NLS-1$ labelBulkApiSerialMode.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); buttonBulkApiSerialMode = new Button(restComp, SWT.CHECK); buttonBulkApiSerialMode.setSelection(config.getBoolean(Config.BULK_API_SERIAL_MODE)); buttonBulkApiSerialMode.setEnabled(useBulkAPI); // Bulk API serial concurrency mode setting Label labelBulkApiZipContent = new Label(restComp, SWT.RIGHT); labelBulkApiZipContent.setText( Labels.getString("AdvancedSettingsDialog.bulkApiZipContent")); // $NON-NLS-1$ labelBulkApiZipContent.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); buttonBulkApiZipContent = new Button(restComp, SWT.CHECK); buttonBulkApiZipContent.setSelection(config.getBoolean(Config.BULK_API_SERIAL_MODE)); buttonBulkApiZipContent.setEnabled(useBulkAPI); // timezone textTimezone = createTextInput( restComp, "AdvancedSettingsDialog.timezone", Config.TIMEZONE, TimeZone.getDefault().getID(), 200); // proxy Host Label labelProxyHost = new Label(restComp, SWT.RIGHT); labelProxyHost.setText(Labels.getString("AdvancedSettingsDialog.proxyHost")); // $NON-NLS-1$ data = new GridData(GridData.HORIZONTAL_ALIGN_END); labelProxyHost.setLayoutData(data); textProxyHost = new Text(restComp, SWT.BORDER); textProxyHost.setText(config.getString(Config.PROXY_HOST)); data = new GridData(); data.widthHint = 250; textProxyHost.setLayoutData(data); // Proxy Port Label labelProxyPort = new Label(restComp, SWT.RIGHT); labelProxyPort.setText(Labels.getString("AdvancedSettingsDialog.proxyPort")); // $NON-NLS-1$ data = new GridData(GridData.HORIZONTAL_ALIGN_END); labelProxyPort.setLayoutData(data); textProxyPort = new Text(restComp, SWT.BORDER); textProxyPort.setText(config.getString(Config.PROXY_PORT)); textProxyPort.setTextLimit(4); textProxyPort.addVerifyListener( new VerifyListener() { @Override public void verifyText(VerifyEvent event) { event.doit = Character.isISOControl(event.character) || Character.isDigit(event.character); } }); data = new GridData(); data.widthHint = 25; textProxyPort.setLayoutData(data); // Proxy Username Label labelProxyUsername = new Label(restComp, SWT.RIGHT); labelProxyUsername.setText(Labels.getString("AdvancedSettingsDialog.proxyUser")); // $NON-NLS-1$ data = new GridData(GridData.HORIZONTAL_ALIGN_END); labelProxyUsername.setLayoutData(data); textProxyUsername = new Text(restComp, SWT.BORDER); textProxyUsername.setText(config.getString(Config.PROXY_USERNAME)); data = new GridData(); data.widthHint = 120; textProxyUsername.setLayoutData(data); // Proxy Password Label labelProxyPassword = new Label(restComp, SWT.RIGHT); labelProxyPassword.setText( Labels.getString("AdvancedSettingsDialog.proxyPassword")); // $NON-NLS-1$ data = new GridData(GridData.HORIZONTAL_ALIGN_END); labelProxyPassword.setLayoutData(data); textProxyPassword = new Text(restComp, SWT.BORDER | SWT.PASSWORD); textProxyPassword.setText(config.getString(Config.PROXY_PASSWORD)); data = new GridData(); data.widthHint = 120; textProxyPassword.setLayoutData(data); // proxy NTLM domain Label labelProxyNtlmDomain = new Label(restComp, SWT.RIGHT); labelProxyNtlmDomain.setText( Labels.getString("AdvancedSettingsDialog.proxyNtlmDomain")); // $NON-NLS-1$ data = new GridData(GridData.HORIZONTAL_ALIGN_END); labelProxyNtlmDomain.setLayoutData(data); textProxyNtlmDomain = new Text(restComp, SWT.BORDER); textProxyNtlmDomain.setText(config.getString(Config.PROXY_NTLM_DOMAIN)); data = new GridData(); data.widthHint = 250; textProxyNtlmDomain.setLayoutData(data); ////////////////////////////////////////////////// // Row to start At Label blankAgain = new Label(restComp, SWT.NONE); data = new GridData(); data.horizontalSpan = 2; blankAgain.setLayoutData(data); // Row to start AT Label labelLastRow = new Label(restComp, SWT.NONE); String lastBatch = controller.getConfig().getString(LastRun.LAST_LOAD_BATCH_ROW); if (lastBatch.equals("")) { // $NON-NLS-1$ lastBatch = "0"; // $NON-NLS-1$ } labelLastRow.setText( Labels.getFormattedString("AdvancedSettingsDialog.lastBatch", lastBatch)); // $NON-NLS-1$ data = new GridData(); data.horizontalSpan = 2; labelLastRow.setLayoutData(data); Label labelRowToStart = new Label(restComp, SWT.RIGHT); labelRowToStart.setText(Labels.getString("AdvancedSettingsDialog.startRow")); // $NON-NLS-1$ data = new GridData(GridData.HORIZONTAL_ALIGN_END); labelRowToStart.setLayoutData(data); textRowToStart = new Text(restComp, SWT.BORDER); textRowToStart.setText(config.getString(Config.LOAD_ROW_TO_START_AT)); data = new GridData(); data.widthHint = 75; textRowToStart.setLayoutData(data); textRowToStart.addVerifyListener( new VerifyListener() { @Override public void verifyText(VerifyEvent event) { event.doit = Character.isISOControl(event.character) || Character.isDigit(event.character); } }); // now that we've created all the buttons, make sure that buttons dependent on the bulk api // setting are enabled or disabled appropriately initBulkApiSetting(useBulkAPI); // the bottow separator Label labelSeparatorBottom = new Label(restComp, SWT.SEPARATOR | SWT.HORIZONTAL); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 2; labelSeparatorBottom.setLayoutData(data); // ok cancel buttons new Label(restComp, SWT.NONE); // END MIDDLE COMPONENT // START BOTTOM COMPONENT Composite buttonComp = new Composite(restComp, SWT.NONE); data = new GridData(GridData.HORIZONTAL_ALIGN_END); buttonComp.setLayoutData(data); buttonComp.setLayout(new GridLayout(2, false)); // Create the OK button and add a handler // so that pressing it will set input // to the entered value Button ok = new Button(buttonComp, SWT.PUSH | SWT.FLAT); ok.setText(Labels.getString("UI.ok")); // $NON-NLS-1$ ok.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { Config config = controller.getConfig(); // set the configValues config.setValue(Config.HIDE_WELCOME_SCREEN, buttonHideWelcomeScreen.getSelection()); config.setValue(Config.INSERT_NULLS, buttonNulls.getSelection()); config.setValue(Config.LOAD_BATCH_SIZE, textBatch.getText()); if (!buttonCsvComma.getSelection() && !buttonCsvTab.getSelection() && (!buttonCsvOther.getSelection() || textSplitterValue.getText() == null || textSplitterValue.getText().length() == 0)) { return; } config.setValue(Config.CSV_DELIMETER_OTHER_VALUE, textSplitterValue.getText()); config.setValue(Config.CSV_DELIMETER_COMMA, buttonCsvComma.getSelection()); config.setValue(Config.CSV_DELIMETER_TAB, buttonCsvTab.getSelection()); config.setValue(Config.CSV_DELIMETER_OTHER, buttonCsvOther.getSelection()); config.setValue(Config.EXTRACT_REQUEST_SIZE, textQueryBatch.getText()); config.setValue(Config.ENDPOINT, textEndpoint.getText()); config.setValue(Config.ASSIGNMENT_RULE, textRule.getText()); config.setValue(Config.LOAD_ROW_TO_START_AT, textRowToStart.getText()); config.setValue(Config.RESET_URL_ON_LOGIN, buttonResetUrl.getSelection()); config.setValue(Config.NO_COMPRESSION, buttonCompression.getSelection()); config.setValue(Config.TRUNCATE_FIELDS, buttonTruncateFields.getSelection()); config.setValue(Config.TIMEOUT_SECS, textTimeout.getText()); config.setValue( Config.ENABLE_EXTRACT_STATUS_OUTPUT, buttonOutputExtractStatus.getSelection()); config.setValue(Config.READ_UTF8, buttonReadUtf8.getSelection()); config.setValue(Config.WRITE_UTF8, buttonWriteUtf8.getSelection()); config.setValue(Config.EURO_DATES, buttonEuroDates.getSelection()); config.setValue(Config.TIMEZONE, textTimezone.getText()); config.setValue(Config.PROXY_HOST, textProxyHost.getText()); config.setValue(Config.PROXY_PASSWORD, textProxyPassword.getText()); config.setValue(Config.PROXY_PORT, textProxyPort.getText()); config.setValue(Config.PROXY_USERNAME, textProxyUsername.getText()); config.setValue(Config.PROXY_NTLM_DOMAIN, textProxyNtlmDomain.getText()); config.setValue(Config.BULK_API_ENABLED, buttonUseBulkApi.getSelection()); config.setValue(Config.BULK_API_SERIAL_MODE, buttonBulkApiSerialMode.getSelection()); config.setValue(Config.BULK_API_ZIP_CONTENT, buttonBulkApiZipContent.getSelection()); controller.saveConfig(); controller.logout(); input = Labels.getString("UI.ok"); // $NON-NLS-1$ shell.close(); } }); data = new GridData(); data.widthHint = 75; ok.setLayoutData(data); // Create the cancel button and add a handler // so that pressing it will set input to null Button cancel = new Button(buttonComp, SWT.PUSH | SWT.FLAT); cancel.setText(Labels.getString("UI.cancel")); // $NON-NLS-1$ cancel.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { input = null; shell.close(); } }); // END BOTTOM COMPONENT data = new GridData(); data.widthHint = 75; cancel.setLayoutData(data); // Set the OK button as the default, so // user can type input and press Enter // to dismiss shell.setDefaultButton(ok); // Set the child as the scrolled content of the ScrolledComposite sc.setContent(container); // Set the minimum size sc.setMinSize(768, 1024); // Expand both horizontally and vertically sc.setExpandHorizontal(true); sc.setExpandVertical(true); }
/** * Constructor to create an editor to update/create an ontology entry * * @param display - points back to the display * @param oureditOntEntry - the entry being edited * @param ontParent - the edited item's parent in the hierarchy * @param newItem - true if this is a new item */ public EditOntEntry( Display display, OntEntry oureditOntEntry, OntEntry ontParent, boolean newItem) { super(); shell = new Shell(display, SWT.DIALOG_TRIM | SWT.PRIMARY_MODAL); shell.setText("OntEntry Information"); GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 3; gridLayout.marginHeight = 5; gridLayout.makeColumnsEqualWidth = true; shell.setLayout(gridLayout); ourOntEntry = oureditOntEntry; ourParent = ontParent; if (newItem) { ourOntEntry.setName(""); ourOntEntry.setImportance(Importance.MODERATE); } new Label(shell, SWT.NONE).setText("Name:"); nameField = new Text(shell, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL); nameField.setText(ourOntEntry.getName()); GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING); DisplayUtilities.setTextDimensions(nameField, gridData, 75); gridData.horizontalSpan = 2; nameField.setLayoutData(gridData); new Label(shell, SWT.NONE).setText("Description:"); descArea = new Text(shell, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL); descArea.setText(ourOntEntry.getDescription()); gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); DisplayUtilities.setTextDimensions(descArea, gridData, 75, 5); gridData.horizontalSpan = 2; gridData.heightHint = descArea.getLineHeight() * 3; descArea.setLayoutData(gridData); new Label(shell, SWT.NONE).setText("Importance:"); importanceBox = new Combo(shell, SWT.DROP_DOWN | SWT.READ_ONLY); Enumeration impEnum = Importance.elements(); int l = 0; Importance itype; while (impEnum.hasMoreElements()) { itype = (Importance) impEnum.nextElement(); importanceBox.add(itype.toString()); if (itype.toString().compareTo(ourOntEntry.getImportance().toString()) == 0) { importanceBox.select(l); } l++; } // Error checking: if no such selection is valid, set it to select index 0 if (importanceBox.getSelectionIndex() == -1) { importanceBox.select(0); } importanceBox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); new Label(shell, SWT.NONE).setText(" "); new Label(shell, SWT.NONE).setText(" "); addButton = new Button(shell, SWT.PUSH); gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING); addButton.setLayoutData(gridData); if (newItem) { addButton.setText("Add"); addButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { canceled = false; if (!nameField.getText().trim().equals("")) { ConsistencyChecker checker = new ConsistencyChecker(ourOntEntry.getID(), nameField.getText(), "OntEntries"); if (ourOntEntry.getName() == nameField.getText() || checker.check()) { ourParent.addChild(ourOntEntry); ourOntEntry.setLevel(ourParent.getLevel() + 1); ourOntEntry.setName(nameField.getText()); ourOntEntry.setDescription(descArea.getText()); ourOntEntry.setImportance( Importance.fromString( importanceBox.getItem(importanceBox.getSelectionIndex()))); // comment before this made no sense... ourOntEntry.setID(ourOntEntry.toDatabase(ourParent.getID())); System.out.println("Name of added item = " + ourOntEntry.getName()); shell.close(); shell.dispose(); } } else { MessageBox mbox = new MessageBox(shell, SWT.ICON_ERROR); mbox.setMessage("Need to provide the OntEntry name"); mbox.open(); } } }); } else { addButton.setText("Save"); addButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { canceled = false; ConsistencyChecker checker = new ConsistencyChecker(ourOntEntry.getID(), nameField.getText(), "OntEntries"); if (ourOntEntry.getName() == nameField.getText() || checker.check()) { ourOntEntry.setName(nameField.getText()); ourOntEntry.setDescription(descArea.getText()); ourOntEntry.setImportance( Importance.fromString( importanceBox.getItem(importanceBox.getSelectionIndex()))); // since this is a save, not an add, the type and parent are ignored ourOntEntry.setID(ourOntEntry.toDatabase(0)); // RationaleDB db = RationaleDB.getHandle(); // db.addOntEntry(ourOntEntry); shell.close(); shell.dispose(); } } }); } cancelButton = new Button(shell, SWT.PUSH); cancelButton.setText("Cancel"); gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING); cancelButton.setLayoutData(gridData); cancelButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { canceled = true; shell.close(); shell.dispose(); } }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } }
private void createUI() { String newFile = ""; System.out.println("create saltResults GUI"); // fileName = System.getProperty("fileName"); // fileName = System.getProperties().getProperty("fileName"); // System.out.println("fileName" + fileName); parentShell = ((Spoon) SpoonFactory.getInstance()).getShell(); Display display = parentShell.getDisplay(); // dpt.createContents(parentShell); comp = new Composite(((Spoon) SpoonFactory.getInstance()).getShell(), SWT.BORDER); comp.setLayout(new GridLayout()); comp.setLayoutData(new GridData(GridData.FILL_BOTH)); Composite btnComp = new Composite(comp, SWT.NONE); GridLayout btnLayout = new GridLayout(); btnLayout.numColumns = 2; btnComp.setLayout(btnLayout); lbl = new Label(comp, SWT.CENTER | SWT.TOP); Label lbl = new Label(comp, SWT.CENTER | SWT.TOP); GridData ldata = new GridData(SWT.CENTER, SWT.TOP, true, false); lbl.setLayoutData(ldata); lbl.setText("Preview data returned from SALt"); Button fileButton = new Button(btnComp, SWT.PUSH | SWT.SINGLE | SWT.TOP); fileButton.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, false)); fileButton.setText("OPEN Data Profile FILE"); // Listener for the file open button (fileButton) Listener fileOpenListener = new Listener() { public void handleEvent(Event e) { String newFile = buildFileDialog(); if (newFile != "") { fileName = newFile; // TODO: create new tab for file // openFile(fileName); buildProfileTab(fileName); // int len = folder.getChildren().length; int len = folder.getItemCount(); System.out.println("Number of tabs: " + len); folder.setSelection(len - 1); } } }; fileButton.addListener(SWT.Selection, fileOpenListener); Button fileButtonSummary = new Button(btnComp, SWT.PUSH | SWT.SINGLE | SWT.TOP); fileButtonSummary.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, false)); fileButtonSummary.setText("OPEN Data Summary FILE"); // Listener for the file open button (fileButton) Listener fileSummaryOpenListener = new Listener() { public void handleEvent(Event e) { String newFile = buildFileDialog(); if (newFile != "") { fileName = newFile; // TODO: create new tab for file // openFile(fileName); buildSummaryTab(fileName); // int len = folder.getChildren().length; int len = folder.getItemCount(); System.out.println("Number of tabs: " + len); folder.setSelection(len - 1); } } }; fileButtonSummary.addListener(SWT.Selection, fileSummaryOpenListener); folder = new CTabFolder(comp, SWT.CLOSE); folder.setSimple(false); folder.setBorderVisible(true); folder.setLayoutData(new GridData(GridData.FILL_BOTH)); }
public static void main(String[] args) { final Display display = new Display(); final Clipboard clipboard = new Clipboard(display); final Shell shell = new Shell(display, SWT.SHELL_TRIM); shell.setLayout(new GridLayout()); shell.setText("Clipboard ImageTransfer"); final Button imageButton = new Button(shell, SWT.NONE); GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); gd.minimumHeight = 400; gd.minimumWidth = 600; imageButton.setLayoutData(gd); final Text imageText = new Text(shell, SWT.BORDER); imageText.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false)); Composite buttons = new Composite(shell, SWT.NONE); buttons.setLayout(new GridLayout(4, true)); Button button = new Button(buttons, SWT.PUSH); button.setText("Open"); button.addListener( SWT.Selection, event -> { FileDialog dialog = new FileDialog(shell, SWT.OPEN); dialog.setText("Open an image file or cancel"); String string = dialog.open(); if (string != null) { imageButton.setText(""); Image image = imageButton.getImage(); if (image != null) image.dispose(); image = new Image(display, string); imageButton.setImage(image); imageText.setText(string); } }); button = new Button(buttons, SWT.PUSH); button.setText("Copy"); button.addListener( SWT.Selection, event -> { Image image = imageButton.getImage(); if (image != null) { ImageTransfer imageTransfer = ImageTransfer.getInstance(); TextTransfer textTransfer = TextTransfer.getInstance(); clipboard.setContents( new Object[] {image.getImageData(), imageText.getText()}, new Transfer[] {imageTransfer, textTransfer}); } }); button = new Button(buttons, SWT.PUSH); button.setText("Paste"); button.addListener( SWT.Selection, event -> { ImageData imageData = (ImageData) clipboard.getContents(ImageTransfer.getInstance()); if (imageData != null) { imageButton.setText(""); Image image = imageButton.getImage(); if (image != null) image.dispose(); image = new Image(display, imageData); imageButton.setImage(image); } else { imageButton.setText("No image"); imageButton.setImage(null); } String text = (String) clipboard.getContents(TextTransfer.getInstance()); if (text != null) { imageText.setText(text); } else { imageText.setText(""); } }); button = new Button(buttons, SWT.PUSH); button.setText("Clear"); button.addListener( SWT.Selection, event -> { imageButton.setText(""); Image image = imageButton.getImage(); if (image != null) image.dispose(); imageButton.setImage(null); imageText.setText(""); }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
public Control getFindTabControl(TabFolder tabFolder) { // Find Composite Composite compositeFind = new Composite(tabFolder, SWT.NULL); GridLayout gridLayout = new GridLayout(2, false); compositeFind.setLayout(gridLayout); /* GridData fromTreeGridData = new GridData (GridData.FILL_BOTH); fromTreeGridData.grabExcessHorizontalSpace = true; fromTreeGridData.grabExcessVerticalSpace = true; // fromTreeGridData.widthHint = 300; compositeFind.setLayoutData(fromTreeGridData); */ // First Set up the match combo box final Combo matchCombo = new Combo(compositeFind, SWT.READ_ONLY); matchCombo.add("Starting with"); matchCombo.add("Ending with"); matchCombo.add("Containing"); matchCombo.add("Exact"); // set default category matchCombo.setText("Containing"); match = "Containing"; matchCombo.addSelectionListener( new SelectionListener() { public void widgetSelected(SelectionEvent e) { // Item in list has been selected match = matchCombo.getItem(matchCombo.getSelectionIndex()); } public void widgetDefaultSelected(SelectionEvent e) { // this is not an option (text cant be entered) } }); // Then set up the Find text combo box final Combo findCombo = new Combo(compositeFind, SWT.DROP_DOWN); GridData findComboData = new GridData(GridData.FILL_HORIZONTAL); findComboData.widthHint = 200; findComboData.horizontalSpan = 1; findCombo.setLayoutData(findComboData); findCombo.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { // Text Item has been entered // Does not require 'return' to be entered findText = findCombo.getText(); } }); findCombo.addSelectionListener( new SelectionListener() { public void widgetSelected(SelectionEvent e) {} public void widgetDefaultSelected(SelectionEvent e) { findText = findCombo.getText(); if (findCombo.indexOf(findText) < 0) { findCombo.add(findText); } if (findButton.getText().equals("Find")) { slm.setMessage("Performing search"); slm.update(true); browser.flush(); ModifierComposite.getInstance().disableComposite(); System.setProperty("statusMessage", "Calling WebService"); TreeNode placeholder = new TreeNode(1, "placeholder", "working...", "C-UNDEF"); browser.rootNode.addChild(placeholder); browser.refresh(); browser.getFindData(categoryKey, categories, findText, match).start(); findButton.setText("Cancel"); } else { System.setProperty("statusMessage", "Canceling WebService call"); browser.refresh(); browser.stopRunning = true; findButton.setText("Find"); } } }); // Next include 'Find' Button findButton = new Button(compositeFind, SWT.PUSH); findButton.setText("Find"); GridData findButtonData = new GridData(); if (OS.startsWith("mac")) findButtonData.widthHint = 80; else findButtonData.widthHint = 60; findButton.setLayoutData(findButtonData); findButton.addMouseListener( new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { // Add item to findCombo drop down list if not already there if (findText == null) { return; } if (findCombo.indexOf(findText) < 0) { findCombo.add(findText); } if (findButton.getText().equals("Find")) { ModifierComposite.getInstance().disableComposite(); browser.flush(); System.setProperty("statusMessage", "Calling WebService"); TreeNode placeholder = new TreeNode(1, "placeholder", "working...", "C-UNDEF"); browser.rootNode.addChild(placeholder); browser.refresh(); browser.getFindData(categoryKey, categories, findText, match).start(); findButton.setText("Cancel"); } else { System.setProperty("statusMessage", "Canceling WebService call"); browser.refresh(); browser.stopRunning = true; findButton.setText("Find"); } } }); // Next set up the category combo box final Combo categoryCombo = new Combo(compositeFind, SWT.READ_ONLY); setCategories(categoryCombo); categoryCombo.addSelectionListener( new SelectionListener() { public void widgetSelected(SelectionEvent e) { // Item in list has been selected if (categoryCombo.getSelectionIndex() == 0) categoryKey = "any"; else { ConceptType concept = (ConceptType) categories.get(categoryCombo.getSelectionIndex() - 1); categoryKey = StringUtil.getTableCd(concept.getKey()); } } public void widgetDefaultSelected(SelectionEvent e) { // this is not an option (text cant be entered) } }); ModifierComposite.setInstance(compositeFind); browser = new NodeBrowser(compositeFind, 1, findButton, slm); return compositeFind; }
protected authDialog( AESemaphore _sem, Display display, String realm, String tracker, String torrent_name) { sem = _sem; if (display.isDisposed()) { sem.release(); return; } shell = new Shell(display, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); Utils.setShellIcon(shell); Messages.setLanguageText(shell, "authenticator.title"); GridLayout layout = new GridLayout(); layout.numColumns = 3; shell.setLayout(layout); GridData gridData; // realm Label realm_label = new Label(shell, SWT.NULL); Messages.setLanguageText(realm_label, "authenticator.realm"); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; realm_label.setLayoutData(gridData); Label realm_value = new Label(shell, SWT.NULL); realm_value.setText(realm.replaceAll("&", "&&")); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 2; realm_value.setLayoutData(gridData); // tracker Label tracker_label = new Label(shell, SWT.NULL); Messages.setLanguageText(tracker_label, "authenticator.tracker"); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; tracker_label.setLayoutData(gridData); Label tracker_value = new Label(shell, SWT.NULL); tracker_value.setText(tracker.replaceAll("&", "&&")); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 2; tracker_value.setLayoutData(gridData); if (torrent_name != null) { Label torrent_label = new Label(shell, SWT.NULL); Messages.setLanguageText(torrent_label, "authenticator.torrent"); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; torrent_label.setLayoutData(gridData); Label torrent_value = new Label(shell, SWT.NULL); torrent_value.setText(torrent_name.replaceAll("&", "&&")); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 2; torrent_value.setLayoutData(gridData); } // user Label user_label = new Label(shell, SWT.NULL); Messages.setLanguageText(user_label, "authenticator.user"); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; user_label.setLayoutData(gridData); final Text user_value = new Text(shell, SWT.BORDER); user_value.setText(""); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 2; user_value.setLayoutData(gridData); user_value.addListener( SWT.Modify, new Listener() { public void handleEvent(Event event) { username = user_value.getText(); } }); // password Label password_label = new Label(shell, SWT.NULL); Messages.setLanguageText(password_label, "authenticator.password"); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; password_label.setLayoutData(gridData); final Text password_value = new Text(shell, SWT.BORDER); password_value.setEchoChar('*'); password_value.setText(""); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 2; password_value.setLayoutData(gridData); password_value.addListener( SWT.Modify, new Listener() { public void handleEvent(Event event) { password = password_value.getText(); } }); // persist Label blank_label = new Label(shell, SWT.NULL); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; blank_label.setLayoutData(gridData); final Button checkBox = new Button(shell, SWT.CHECK); checkBox.setText(MessageText.getString("authenticator.savepassword")); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 2; checkBox.setLayoutData(gridData); checkBox.addListener( SWT.Selection, new Listener() { public void handleEvent(Event e) { persist = checkBox.getSelection(); } }); // line Label labelSeparator = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); gridData = new GridData(GridData.FILL_HORIZONTAL); gridData.horizontalSpan = 3; labelSeparator.setLayoutData(gridData); // buttons new Label(shell, SWT.NULL); Button bOk = new Button(shell, SWT.PUSH); Messages.setLanguageText(bOk, "Button.ok"); gridData = new GridData( GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END | GridData.HORIZONTAL_ALIGN_FILL); gridData.grabExcessHorizontalSpace = true; gridData.widthHint = 70; bOk.setLayoutData(gridData); bOk.addListener( SWT.Selection, new Listener() { public void handleEvent(Event e) { close(true); } }); Button bCancel = new Button(shell, SWT.PUSH); Messages.setLanguageText(bCancel, "Button.cancel"); gridData = new GridData(GridData.HORIZONTAL_ALIGN_END); gridData.grabExcessHorizontalSpace = false; gridData.widthHint = 70; bCancel.setLayoutData(gridData); bCancel.addListener( SWT.Selection, new Listener() { public void handleEvent(Event e) { close(false); } }); shell.setDefaultButton(bOk); shell.addListener( SWT.Traverse, new Listener() { public void handleEvent(Event e) { if (e.character == SWT.ESC) { close(false); } } }); shell.pack(); Utils.centreWindow(shell); shell.open(); shell.forceActive(); }