/** Method for creating Stream Direction Group */ protected void createStreamDirectionGroup( int horizontalSpan, int verticalSpan, boolean isBothButton) { streamDirectionGroup = new Group(shell, SWT.NONE); streamDirectionGroup.setText("Stream direction"); GridData gridData = new GridData(GridData.FILL, GridData.BEGINNING, false, false); gridData.horizontalSpan = horizontalSpan; gridData.verticalSpan = verticalSpan; streamDirectionGroup.setLayoutData(gridData); streamDirectionGroup.setLayout(new GridLayout()); // Downstream Radio Button downstreamButton = new Button(streamDirectionGroup, SWT.RADIO); downstreamButton.setText("Downstream"); gridData = new GridData(GridData.BEGINNING, GridData.CENTER, false, false); downstreamButton.setLayoutData(gridData); // Upstream Radio Button upstreamButton = new Button(streamDirectionGroup, SWT.RADIO); upstreamButton.setText("Upstream"); gridData = new GridData(GridData.BEGINNING, GridData.CENTER, false, false); upstreamButton.setLayoutData(gridData); // Downstream & Upstream Radio Button if (isBothButton) { bothButton = new Button(streamDirectionGroup, SWT.RADIO); bothButton.setText("Both"); gridData = new GridData(GridData.BEGINNING, GridData.CENTER, false, false); bothButton.setLayoutData(gridData); } }
protected void createLimitTypesGroup() { GridData gridData; // Group for lengthLimitButton and shortestPlusKButton Group limitTypeGroup = new Group(shell, SWT.NONE); limitTypeGroup.setText("Stop distance"); gridData = new GridData(GridData.FILL, GridData.BEGINNING, false, false); gridData.horizontalSpan = 2; gridData.verticalSpan = 2; limitTypeGroup.setLayoutData(gridData); limitTypeGroup.setLayout(new GridLayout(2, true)); // Length limit radio button lengthLimitLabel = new Label(limitTypeGroup, SWT.NONE); lengthLimitLabel.setText("Length limit"); gridData = new GridData(GridData.BEGINNING, GridData.CENTER, false, false); lengthLimitLabel.setLayoutData(gridData); // Length limit text lengthLimit = new Text(limitTypeGroup, SWT.BORDER); lengthLimit.addKeyListener(keyAdapter); gridData = new GridData(GridData.FILL, GridData.CENTER, false, false); lengthLimit.setLayoutData(gridData); // Shortest+k radio button shortestPlusKButton = new Button(limitTypeGroup, SWT.CHECK); shortestPlusKButton.setText("Shortest+k"); gridData = new GridData(GridData.BEGINNING, GridData.CENTER, false, false); shortestPlusKButton.setLayoutData(gridData); shortestPlusKButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { shortestPlusK.setEnabled(shortestPlusKButton.getSelection()); } }); // Shortest+k text shortestPlusK = new Text(limitTypeGroup, SWT.BORDER); shortestPlusK.addKeyListener(keyAdapter); gridData = new GridData(GridData.FILL, GridData.CENTER, false, false); shortestPlusK.setLayoutData(gridData); // Strict check box strictButton = new Button(shell, SWT.CHECK | SWT.WRAP); strictButton.setText("Ignore source-source/target-target paths"); gridData = new GridData(GridData.CENTER, GridData.CENTER, false, false); gridData.verticalSpan = 2; gridData.horizontalSpan = 4; strictButton.setLayoutData(gridData); }
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); }
/** Method to create cancel button */ protected void createCancelButton(GridData gridData) { cancelButton.setText("Cancel"); cancelButton.setLayoutData(gridData); cancelButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { shell.close(); } }); }
/** 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); } }); }
/** Method for creating Result View Group */ protected void createResultViewGroup(int horizontalSpan, int verticalSpan) { resultViewGroup = new Group(shell, SWT.NONE); resultViewGroup.setText("Show result in"); GridData gridData = new GridData(GridData.FILL, GridData.BEGINNING, false, false); gridData.horizontalSpan = horizontalSpan; gridData.verticalSpan = verticalSpan; resultViewGroup.setLayoutData(gridData); resultViewGroup.setLayout(new GridLayout()); // Current View Radio Button currentViewButton = new Button(resultViewGroup, SWT.RADIO); currentViewButton.setText("Current view"); gridData = new GridData(GridData.BEGINNING, GridData.CENTER, false, false); currentViewButton.setLayoutData(gridData); // New View Radio Button newViewButton = new Button(resultViewGroup, SWT.RADIO); newViewButton.setText("New view"); gridData = new GridData(GridData.BEGINNING, GridData.CENTER, false, false); newViewButton.setLayoutData(gridData); }
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); }
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(); }
private Composite createButtonArea(Composite parent) { ScrolledComposite comp = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL); GridLayout layout = new GridLayout(); layout.marginWidth = layout.marginHeight = 0; comp.setLayoutData(new GridData(GridData.FILL_VERTICAL)); Composite container = new Composite(comp, SWT.NONE); layout = new GridLayout(); layout.marginWidth = 0; container.setLayout(layout); GridData gd = new GridData(GridData.FILL_VERTICAL); gd.verticalIndent = 15; container.setLayoutData(gd); Button button = new Button(container, SWT.PUSH); button.setText(PDEUIMessages.ImportWizard_DetailedPage_existing); button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); button.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { handleExistingProjects(); } }); SWTUtil.setButtonDimensionHint(button); button = new Button(container, SWT.PUSH); button.setText(PDEUIMessages.ImportWizard_DetailedPage_existingUnshared); button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); button.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { handleExistingUnshared(); } }); SWTUtil.setButtonDimensionHint(button); fAddButton = new Button(container, SWT.PUSH); fAddButton.setText(PDEUIMessages.ImportWizard_DetailedPage_add); fAddButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fAddButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { handleAdd(); } }); SWTUtil.setButtonDimensionHint(fAddButton); fAddAllButton = new Button(container, SWT.PUSH); fAddAllButton.setText(PDEUIMessages.ImportWizard_DetailedPage_addAll); fAddAllButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fAddAllButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { handleAddAll(); } }); SWTUtil.setButtonDimensionHint(fAddAllButton); fRemoveButton = new Button(container, SWT.PUSH); fRemoveButton.setText(PDEUIMessages.ImportWizard_DetailedPage_remove); fRemoveButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fRemoveButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { handleRemove(); } }); SWTUtil.setButtonDimensionHint(fRemoveButton); fRemoveAllButton = new Button(container, SWT.PUSH); fRemoveAllButton.setText(PDEUIMessages.ImportWizard_DetailedPage_removeAll); fRemoveAllButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fRemoveAllButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { handleRemoveAll(); } }); SWTUtil.setButtonDimensionHint(fRemoveAllButton); button = new Button(container, SWT.PUSH); button.setText(PDEUIMessages.ImportWizard_DetailedPage_swap); button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); button.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { handleSwap(); } }); SWTUtil.setButtonDimensionHint(button); fAddRequiredButton = new Button(container, SWT.PUSH); fAddRequiredButton.setText(PDEUIMessages.ImportWizard_DetailedPage_addRequired); fAddRequiredButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fAddRequiredButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { handleAddRequiredPlugins(); } }); SWTUtil.setButtonDimensionHint(fAddRequiredButton); fCountLabel = new Label(container, SWT.NONE); fCountLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER)); comp.setContent(container); comp.setMinHeight(250); comp.setExpandHorizontal(true); comp.setExpandVertical(true); return container; }
/** * 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); }
public void init() { GridLayout lay = new GridLayout(); lay.numColumns = 2; lay.makeColumnsEqualWidth = true; this.setLayout(lay); addedEntities = new ArrayList<EntityHolder>(); entityList = new List(this, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.HORIZONTAL); GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, true); gridData.verticalSpan = 1; gridData.horizontalSpan = 2; entityList.setLayoutData(gridData); // Add Entity Button addButton = new Button(this, SWT.NONE); addButton.setText("Add..."); gridData = new GridData(GridData.END, GridData.BEGINNING, true, false); gridData.minimumWidth = 50; gridData.horizontalIndent = 5; addButton.setLayoutData(gridData); addButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { // new addEntityDialog AddEntityDialog addEntityDialog = new AddEntityDialog(new Shell(), allEntities); // open dialog boolean addPressed = addEntityDialog.open(); // if add button is pressed if (addPressed) { // for each selected entity for (EntityHolder entity : addEntityDialog.getSelectedEntities()) { // check if entity has been added before if (!addedEntities.contains(entity)) { // add entity keyName to List entityList.add(entity.getName()); // add entity to addedEntities ArrayList addedEntities.add(entity); } } } } }); // Remove Entity Button removeButton = new Button(this, SWT.NONE); removeButton.setText("Remove"); gridData = new GridData(GridData.BEGINNING, GridData.BEGINNING, true, false); gridData.horizontalIndent = 5; gridData.minimumWidth = 50; removeButton.setLayoutData(gridData); removeButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { String[] selectionResult = entityList.getSelection(); // for each selected string for (String selected : selectionResult) { // search among all addedEntities for (int j = 0; j < addedEntities.size(); j++) { EntityHolder entity = addedEntities.get(j); // if corresponding entity is found if (selected != null && selected.equals(entity.getName())) { // remove entity from addedEntities ArrayList addedEntities.remove(j); // remove entity keyName from from List entityList.remove(selected); } } } } }); }
/** * This method is called by Spoon when the user opens the settings dialog of the step. It should * open the dialog and return only once the dialog has been closed by the user. * * <p>If the user confirms the dialog, the meta object (passed in the constructor) must be updated * to reflect the new step settings. The changed flag of the meta object must reflect whether the * step configuration was changed by the dialog. * * <p>If the user cancels the dialog, the meta object must not be updated, and its changed flag * must remain unaltered. * * <p>The open() method must return the name of the step after the user has confirmed the dialog, * or null if the user cancelled the dialog. */ public String open() { // store some convenient SWT variables Shell parent = getParent(); Display display = parent.getDisplay(); // SWT code for preparing the dialog shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MIN | SWT.MAX); props.setLook(shell); setShellImage(shell, meta); // Save the value of the changed flag on the meta object. If the user cancels // the dialog, it will be restored to this saved value. // The "changed" variable is inherited from BaseStepDialog changed = meta.hasChanged(); // The ModifyListener used on all controls. It will update the meta object to // indicate that changes are being made. ModifyListener lsMod = new ModifyListener() { public void modifyText(ModifyEvent e) { meta.setChanged(); } }; // ------------------------------------------------------- // // SWT code for building the actual settings dialog // // ------------------------------------------------------- // FormLayout formLayout = new FormLayout(); formLayout.marginWidth = Const.FORM_MARGIN; formLayout.marginHeight = Const.FORM_MARGIN; shell.setLayout(formLayout); shell.setText(BaseMessages.getString(PKG, "UniqueListStep.Shell.Title")); int middle = props.getMiddlePct(); int margin = Const.MARGIN; // Stepname line wlStepname = new Label(shell, SWT.RIGHT); wlStepname.setText(BaseMessages.getString(PKG, "System.Label.StepName")); props.setLook(wlStepname); fdlStepname = new FormData(); fdlStepname.left = new FormAttachment(0, 0); fdlStepname.right = new FormAttachment(middle, -margin); fdlStepname.top = new FormAttachment(0, margin); wlStepname.setLayoutData(fdlStepname); wStepname = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER); wStepname.setText(stepname); props.setLook(wStepname); wStepname.addModifyListener(lsMod); fdStepname = new FormData(); fdStepname.left = new FormAttachment(middle, 0); fdStepname.top = new FormAttachment(0, margin); fdStepname.right = new FormAttachment(100, 0); wStepname.setLayoutData(fdStepname); // Treat Consecutive Delimiters as One // wlRemoveBlanks = new Label(shell, SWT.RIGHT); wlRemoveBlanks.setText("Treat Consecutive Delims as One"); wlRemoveBlanks.setToolTipText( "Multiple delimiters in a row will be condensed. Essentially removes blank spaces"); props.setLook(wlRemoveBlanks); fdlRemoveBlanks = new FormData(); fdlRemoveBlanks.left = new FormAttachment(0, 0); fdlRemoveBlanks.top = new FormAttachment(wStepname, margin); fdlRemoveBlanks.right = new FormAttachment(middle, -margin); wlRemoveBlanks.setLayoutData(fdlRemoveBlanks); wRemoveBlanks = new Button(shell, SWT.CHECK); wRemoveBlanks.setToolTipText( "Multiple delimiters in a row will be condensed. Essentially removes blank spaces"); props.setLook(wRemoveBlanks); wRemoveBlanks.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { meta.setChanged(); } }); fdRemoveBlanks = new FormData(); fdRemoveBlanks.left = new FormAttachment(middle, 0); fdRemoveBlanks.top = new FormAttachment(wStepname, margin); fdRemoveBlanks.right = new FormAttachment(100, 0); wRemoveBlanks.setLayoutData(fdRemoveBlanks); // OK and cancel buttons wOK = new Button(shell, SWT.PUSH); wOK.setText(BaseMessages.getString(PKG, "System.Button.OK")); wGet = new Button(shell, SWT.PUSH); wGet.setText("Get"); wCancel = new Button(shell, SWT.PUSH); wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel")); setButtonPositions(new Button[] {wOK, wGet, wCancel}, margin, null); wlGroup = new Label(shell, SWT.NONE); wlGroup.setText("Fields"); props.setLook(wlGroup); fdlGroup = new FormData(); fdlGroup.left = new FormAttachment(0, 0); fdlGroup.top = new FormAttachment(wlRemoveBlanks, margin); wlGroup.setLayoutData(fdlGroup); // Fields colinf = new ColumnInfo[] { new ColumnInfo("Field Name", ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] {""}, false), new ColumnInfo("Current Delimiter", ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo("Output Field Name (Optional)", ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo("Output Delimiter (Optional)", ColumnInfo.COLUMN_TYPE_TEXT, false) }; int nrRows = (meta.getSourceFields() != null ? meta.getSourceFields().length : 1); wGroup = new TableView( transMeta, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, colinf, nrRows, lsMod, props); fdGroup = new FormData(); fdGroup.left = new FormAttachment(0, 0); fdGroup.top = new FormAttachment(wlGroup, margin); fdGroup.right = new FormAttachment(100, 0); fdGroup.bottom = new FormAttachment(wGet, -margin); wGroup.setLayoutData(fdGroup); final Runnable runnable = new Runnable() { public void run() { StepMeta stepMeta = transMeta.findStep(stepname); if (stepMeta != null) { try { RowMetaInterface row = transMeta.getPrevStepFields(stepMeta); // Remember these fields... for (int i = 0; i < row.size(); i++) { inputFields.put(row.getValueMeta(i).getName(), i); } setComboBoxes(); } catch (KettleException e) { logError(BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message")); } } } }; new Thread(runnable).start(); // Add listeners for cancel and OK lsCancel = new Listener() { public void handleEvent(Event e) { cancel(); } }; lsOK = new Listener() { public void handleEvent(Event e) { ok(); } }; lsGet = new Listener() { public void handleEvent(Event event) { get(); } }; wCancel.addListener(SWT.Selection, lsCancel); wOK.addListener(SWT.Selection, lsOK); wGet.addListener(SWT.Selection, lsGet); // default listener (for hitting "enter") lsDef = new SelectionAdapter() { public void widgetDefaultSelected(SelectionEvent e) { ok(); } }; wStepname.addSelectionListener(lsDef); // Detect X or ALT-F4 or something that kills this window and cancel the dialog properly shell.addShellListener( new ShellAdapter() { public void shellClosed(ShellEvent e) { cancel(); } }); // Set/Restore the dialog size based on last position on screen // The setSize() method is inherited from BaseStepDialog setSize(); // populate the dialog with the values from the meta object populateDialog(); // restore the changed flag to original value, as the modify listeners fire during dialog // population meta.setChanged(changed); // open dialog and enter event loop shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } // at this point the dialog has closed, so either ok() or cancel() have been executed // The "stepname" variable is inherited from BaseStepDialog return stepname; }
@Override public void createControl(Composite composite) { ModifyListener textListener = new ModifyListener() { @Override public void modifyText(ModifyEvent e) { if (activated) { saveAndUpdate(); } } }; settingsGroup = new Composite(composite, SWT.NONE); GridLayout gl = new GridLayout(4, false); gl.marginHeight = 10; gl.marginWidth = 10; settingsGroup.setLayout(gl); GridData gd = new GridData(GridData.FILL_BOTH); settingsGroup.setLayoutData(gd); { Label urlLabel = new Label(settingsGroup, SWT.NONE); urlLabel.setText(GenericMessages.dialog_connection_jdbc_url_); gd = new GridData(GridData.HORIZONTAL_ALIGN_END); urlLabel.setLayoutData(gd); urlText = new Text(settingsGroup, SWT.BORDER); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 3; gd.grabExcessHorizontalSpace = true; // gd.widthHint = 355; urlText.setLayoutData(gd); urlText.addModifyListener( new ModifyListener() { @Override public void modifyText(ModifyEvent e) { site.updateButtons(); } }); addControlToGroup(GROUP_URL, urlLabel); addControlToGroup(GROUP_URL, urlText); } { Label hostLabel = new Label(settingsGroup, SWT.NONE); hostLabel.setText(GenericMessages.dialog_connection_host_label); hostLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); hostText = new Text(settingsGroup, SWT.BORDER); gd = new GridData(GridData.FILL_HORIZONTAL); gd.grabExcessHorizontalSpace = true; hostText.setLayoutData(gd); hostText.addModifyListener(textListener); Label portLabel = new Label(settingsGroup, SWT.NONE); portLabel.setText(GenericMessages.dialog_connection_port_label); portLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); portText = new Text(settingsGroup, SWT.BORDER); gd = new GridData(GridData.CENTER); gd.widthHint = 60; portText.setLayoutData(gd); // portText.addVerifyListener(UIUtils.INTEGER_VERIFY_LISTENER); portText.addModifyListener(textListener); addControlToGroup(GROUP_HOST, hostLabel); addControlToGroup(GROUP_HOST, hostText); addControlToGroup(GROUP_HOST, portLabel); addControlToGroup(GROUP_HOST, portText); } { Label serverLabel = new Label(settingsGroup, SWT.NONE); serverLabel.setText(GenericMessages.dialog_connection_server_label); serverLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); serverText = new Text(settingsGroup, SWT.BORDER); gd = new GridData(GridData.FILL_HORIZONTAL); gd.grabExcessHorizontalSpace = true; // gd.widthHint = 270; serverText.setLayoutData(gd); serverText.addModifyListener(textListener); Control emptyLabel = createEmptyLabel(settingsGroup, 1); addControlToGroup(GROUP_SERVER, serverLabel); addControlToGroup(GROUP_SERVER, serverText); addControlToGroup(GROUP_SERVER, emptyLabel); } { Label dbLabel = new Label(settingsGroup, SWT.NONE); dbLabel.setText(GenericMessages.dialog_connection_database_schema_label); dbLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); dbText = new Text(settingsGroup, SWT.BORDER); gd = new GridData(GridData.FILL_HORIZONTAL); gd.grabExcessHorizontalSpace = true; // gd.widthHint = 270; // gd.horizontalSpan = 3; dbText.setLayoutData(gd); dbText.addModifyListener(textListener); Control emptyLabel = createEmptyLabel(settingsGroup, 1); addControlToGroup(GROUP_DB, dbLabel); addControlToGroup(GROUP_DB, dbText); addControlToGroup(GROUP_DB, emptyLabel); } // Path { Label pathLabel = new Label(settingsGroup, SWT.NONE); pathLabel.setText(GenericMessages.dialog_connection_path_label); pathLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); pathText = new Text(settingsGroup, SWT.BORDER); gd = new GridData(GridData.FILL_HORIZONTAL); // gd.grabExcessHorizontalSpace = true; // gd.widthHint = 200; gd.horizontalSpan = 2; pathText.setLayoutData(gd); pathText.addModifyListener(textListener); pathText.addModifyListener( new ModifyListener() { @Override public void modifyText(ModifyEvent e) { updateCreateButton(site.getDriver()); } }); Composite buttonsPanel = new Composite(settingsGroup, SWT.NONE); gl = new GridLayout(2, true); gl.marginHeight = 0; gl.marginWidth = 0; buttonsPanel.setLayout(gl); gd = new GridData(GridData.HORIZONTAL_ALIGN_END); gd.widthHint = 150; buttonsPanel.setLayoutData(gd); Button browseButton = new Button(buttonsPanel, SWT.PUSH); browseButton.setText(GenericMessages.dialog_connection_browse_button); gd = new GridData(GridData.FILL_HORIZONTAL); browseButton.setLayoutData(gd); browseButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (metaURL.getAvailableProperties().contains(DriverDescriptor.PROP_FILE)) { FileDialog dialog = new FileDialog(getShell(), SWT.OPEN | SWT.SINGLE); dialog.setFileName(pathText.getText()); dialog.setText(GenericMessages.dialog_connection_db_file_chooser_text); String file = dialog.open(); if (file != null) { pathText.setText(file); } } else { DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.NONE); final String curPath = pathText.getText(); File curFolder = new File(curPath); if (curFolder.exists()) { if (curFolder.isDirectory()) { dialog.setFilterPath(curFolder.getAbsolutePath()); } else { dialog.setFilterPath(curFolder.getParentFile().getAbsolutePath()); } } dialog.setText(GenericMessages.dialog_connection_db_folder_chooser_text); dialog.setMessage(GenericMessages.dialog_connection_db_folder_chooser_message); String folder = dialog.open(); if (folder != null) { pathText.setText(folder); } } } }); createButton = new Button(buttonsPanel, SWT.PUSH); createButton.setText("Create"); createButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); createButton.setEnabled(false); createButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { createEmbeddedDatabase(); } }); addControlToGroup(GROUP_PATH, pathLabel); addControlToGroup(GROUP_PATH, pathText); addControlToGroup(GROUP_PATH, buttonsPanel); } { Label userNameLabel = new Label(settingsGroup, SWT.NONE); userNameLabel.setText(GenericMessages.dialog_connection_user_name_label); userNameLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); userNameText = new Text(settingsGroup, SWT.BORDER); gd = new GridData(GridData.FILL_HORIZONTAL); gd.grabExcessHorizontalSpace = true; userNameText.setLayoutData(gd); userNameText.addModifyListener(textListener); Control emptyLabel = createEmptyLabel(settingsGroup, 2); Label passwordLabel = new Label(settingsGroup, SWT.NONE); passwordLabel.setText(GenericMessages.dialog_connection_password_label); passwordLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); passwordText = new Text(settingsGroup, SWT.BORDER | SWT.PASSWORD); gd = new GridData(GridData.FILL_HORIZONTAL); gd.grabExcessHorizontalSpace = true; passwordText.setLayoutData(gd); passwordText.addModifyListener(textListener); addControlToGroup(GROUP_LOGIN, userNameLabel); addControlToGroup(GROUP_LOGIN, userNameText); addControlToGroup(GROUP_LOGIN, emptyLabel); addControlToGroup(GROUP_LOGIN, passwordLabel); addControlToGroup(GROUP_LOGIN, passwordText); } createDriverPanel(settingsGroup); setControl(settingsGroup); }
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(); }
protected void createExeCancDefGroup(final QueryOptionsPack opt, int horizontalSpan) { // Group for execute, cancel and default buttons exeCancelDefaultGroup = new Group(shell, SWT.NONE); GridData gridData = new GridData(GridData.FILL, GridData.CENTER, false, false); gridData.horizontalSpan = horizontalSpan; exeCancelDefaultGroup.setLayoutData(gridData); exeCancelDefaultGroup.setLayout(new GridLayout(4, true)); if (forSIF) { sifTypeButton = new Button(exeCancelDefaultGroup, SWT.NONE); sifTypeButton.setBackground(new Color(null, 255, 255, 255)); gridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, false); sifTypeButton.setLayoutData(gridData); sifTypeButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { ArrayList<SIFType> selection = new ArrayList<SIFType>(selectedTypes); ExportToSIFL3Dialog dialog = new ExportToSIFL3Dialog( main.getShell(), org.gvt.model.sifl3.SIFGraph.getPossibleRuleTypes(), selection); if (dialog.open()) { selectedTypes.clear(); selectedTypes.addAll(selection); updateSIFTypeButtonText(); } } }); if (selectedTypes == null) selectedTypes = new ArrayList<SIFType>(); updateSIFTypeButtonText(); } // Execute Button executeButton = new Button(exeCancelDefaultGroup, SWT.NONE); executeButton.setText("Execute"); gridData = new GridData(GridData.END, GridData.CENTER, true, false); executeButton.setLayoutData(gridData); executeButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { // if no entity is added, show error if ((sourceElg != null && getAddedSourceEntities().isEmpty()) || (sourceST != null && sourceST.getSymbols().isEmpty())) { MessageDialog.openError(main.getShell(), "Error!", "Add Source Molecule!"); return; } if ((targetElg != null && getAddedTargetEntities().isEmpty()) || (targetST != null && targetST.getSymbols().isEmpty())) { MessageDialog.openError(main.getShell(), "Error!", "Add Target Molecule!"); return; } if (forSIF && selectedTypes.isEmpty()) { MessageDialog.openError( main.getShell(), "Error!", "Please select at least one interaction type."); return; } // Check for unknown gene symbols java.util.List<String> unkwn = getUnknownSymbols(); if (!unkwn.isEmpty()) { String s = ""; for (String us : unkwn) s += " " + us; MessageDialog.openError( main.getShell(), "Error!", "Unknown symbol" + (unkwn.size() > 1 ? "s" : "") + ": " + s); return; } // store values in dialog to optionsPack storeValuesToOptionsPack(opt); // execute is selected opt.setCancel(false); shell.close(); } }); // Cancel Button cancelButton = new Button(exeCancelDefaultGroup, SWT.NONE); gridData = new GridData(GridData.CENTER, GridData.CENTER, true, false); createCancelButton(gridData); // Default Button defaultButton = new Button(exeCancelDefaultGroup, SWT.NONE); defaultButton.setText("Default"); gridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, false); defaultButton.setLayoutData(gridData); defaultButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { // set default values of dialog setDefaultQueryDialogOptions(); } }); }
/** * Creates the buttons in this group inside a new composite * * @param parent parent composite * @param toolkit toolkit to give form style or <code>null</code> for dialog style */ private void createButtons(Composite parent, FormToolkit toolkit) { if (toolkit != null) { Composite buttonComp = toolkit.createComposite(parent); GridLayout layout = new GridLayout(); layout.marginWidth = layout.marginHeight = 0; buttonComp.setLayout(layout); buttonComp.setLayoutData(new GridData(GridData.FILL_VERTICAL)); fSelectButton = toolkit.createButton(buttonComp, Messages.IncludedBundlesTree_0, SWT.PUSH); fSelectButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fDeselectButton = toolkit.createButton(buttonComp, Messages.IncludedBundlesTree_1, SWT.PUSH); fDeselectButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Label emptySpace = new Label(buttonComp, SWT.NONE); GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); gd.widthHint = gd.heightHint = 5; emptySpace.setLayoutData(gd); fSelectAllButton = toolkit.createButton(buttonComp, Messages.IncludedBundlesTree_2, SWT.PUSH); fSelectAllButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fDeselectAllButton = toolkit.createButton(buttonComp, Messages.IncludedBundlesTree_3, SWT.PUSH); fDeselectAllButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); emptySpace = new Label(buttonComp, SWT.NONE); gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); gd.widthHint = gd.heightHint = 5; emptySpace.setLayoutData(gd); fSelectRequiredButton = toolkit.createButton(buttonComp, Messages.TargetContentsGroup_4, SWT.PUSH); fSelectRequiredButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Composite filterComp = toolkit.createComposite(buttonComp); layout = new GridLayout(); layout.marginWidth = layout.marginHeight = 0; filterComp.setLayout(layout); filterComp.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, true)); fModeLabel = toolkit.createLabel(filterComp, Messages.TargetContentsGroup_ManageUsing); fPluginModeButton = toolkit.createButton(filterComp, Messages.TargetContentsGroup_PluginMode, SWT.RADIO); fPluginModeButton.setSelection(true); fFeaureModeButton = toolkit.createButton(filterComp, Messages.TargetContentsGroup_FeatureMode, SWT.RADIO); fFeaureModeButton.setSelection(true); emptySpace = new Label(filterComp, SWT.NONE); gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); gd.widthHint = gd.heightHint = 5; emptySpace.setLayoutData(gd); fShowLabel = toolkit.createLabel(filterComp, Messages.BundleContainerTable_9); fShowPluginsButton = toolkit.createButton(filterComp, Messages.BundleContainerTable_14, SWT.CHECK); fShowPluginsButton.setSelection(true); fShowSourceButton = toolkit.createButton(filterComp, Messages.BundleContainerTable_15, SWT.CHECK); fShowSourceButton.setSelection(true); emptySpace = new Label(filterComp, SWT.NONE); gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); gd.widthHint = gd.heightHint = 5; emptySpace.setLayoutData(gd); fGroupLabel = toolkit.createLabel(filterComp, Messages.TargetContentsGroup_0); fGroupComboPart = new ComboPart(); fGroupComboPart.createControl(filterComp, toolkit, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalIndent = 10; fGroupComboPart.getControl().setLayoutData(gd); fGroupComboPart.setItems( new String[] { Messages.TargetContentsGroup_1, Messages.TargetContentsGroup_2, Messages.TargetContentsGroup_3 }); fGroupComboPart.setVisibleItemCount(30); fGroupComboPart.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { handleGroupChange(); } }); fGroupComboPart.select(0); } else { Composite buttonComp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_VERTICAL, 0, 0); fSelectButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_0, null); fDeselectButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_1, null); Label emptySpace = new Label(buttonComp, SWT.NONE); GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); gd.widthHint = gd.heightHint = 5; emptySpace.setLayoutData(gd); fSelectAllButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_2, null); fDeselectAllButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_3, null); emptySpace = new Label(buttonComp, SWT.NONE); gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); gd.widthHint = gd.heightHint = 5; emptySpace.setLayoutData(gd); fSelectRequiredButton = SWTFactory.createPushButton(buttonComp, Messages.TargetContentsGroup_4, null); Composite filterComp = SWTFactory.createComposite(buttonComp, 1, 1, SWT.NONE, 0, 0); filterComp.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, true)); fModeLabel = SWTFactory.createLabel(filterComp, Messages.TargetContentsGroup_ManageUsing, 1); fPluginModeButton = SWTFactory.createRadioButton(filterComp, Messages.TargetContentsGroup_PluginMode); fFeaureModeButton = SWTFactory.createRadioButton(filterComp, Messages.TargetContentsGroup_FeatureMode); emptySpace = new Label(filterComp, SWT.NONE); gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); gd.widthHint = gd.heightHint = 5; emptySpace.setLayoutData(gd); fShowLabel = SWTFactory.createLabel(filterComp, Messages.BundleContainerTable_9, 1); fShowPluginsButton = SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_14, null, true, 1); fShowSourceButton = SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_15, null, true, 1); emptySpace = new Label(filterComp, SWT.NONE); gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); gd.widthHint = gd.heightHint = 5; emptySpace.setLayoutData(gd); fGroupLabel = SWTFactory.createLabel(filterComp, Messages.TargetContentsGroup_0, 1); fGroupCombo = SWTFactory.createCombo( filterComp, SWT.READ_ONLY, 1, new String[] { Messages.TargetContentsGroup_1, Messages.TargetContentsGroup_2, Messages.TargetContentsGroup_3 }); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalIndent = 10; fGroupCombo.setLayoutData(gd); fGroupCombo.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { handleGroupChange(); } }); fGroupCombo.select(0); } fSelectButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (!fTree.getSelection().isEmpty()) { Object[] selected = ((IStructuredSelection) fTree.getSelection()).toArray(); for (int i = 0; i < selected.length; i++) { fTree.setChecked(selected[i], true); } saveIncludedBundleState(); contentChanged(); updateButtons(); fTree.update( fTargetDefinition.getBundleContainers(), new String[] {IBasicPropertyConstants.P_TEXT}); } } }); fDeselectButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (!fTree.getSelection().isEmpty()) { Object[] selected = ((IStructuredSelection) fTree.getSelection()).toArray(); for (int i = 0; i < selected.length; i++) { fTree.setChecked(selected[i], false); } saveIncludedBundleState(); contentChanged(); updateButtons(); fTree.update( fTargetDefinition.getBundleContainers(), new String[] {IBasicPropertyConstants.P_TEXT}); } } }); fSelectAllButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { fTree.setAllChecked(true); saveIncludedBundleState(); contentChanged(); updateButtons(); fTree.update( fTargetDefinition.getBundleContainers(), new String[] {IBasicPropertyConstants.P_TEXT}); } }); fDeselectAllButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { fTree.setAllChecked(false); saveIncludedBundleState(); contentChanged(); updateButtons(); fTree.update( fTargetDefinition.getBundleContainers(), new String[] {IBasicPropertyConstants.P_TEXT}); } }); fSelectRequiredButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Object[] allChecked = fTree.getCheckedLeafElements(); Object[] required = null; if (fFeaureModeButton.getSelection()) { required = getRequiredFeatures(fTargetDefinition.getAllFeatures(), allChecked); } else { required = getRequiredPlugins(fAllBundles, allChecked); } for (int i = 0; i < required.length; i++) { fTree.setChecked(required[i], true); } saveIncludedBundleState(); contentChanged(); updateButtons(); fTree.update( fTargetDefinition.getBundleContainers(), new String[] {IBasicPropertyConstants.P_TEXT}); } }); fPluginModeButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { // Moving from feature based filtering to plug-in based, need to update storage ((TargetDefinition) fTargetDefinition).setUIMode(TargetDefinition.MODE_PLUGIN); contentChanged(); fTargetDefinition.setIncluded(null); fGroupLabel.setEnabled(true); if (fGroupCombo != null) { fGroupCombo.setEnabled(true); } else { fGroupComboPart.getControl().setEnabled(true); } fTree.getControl().setRedraw(false); fTree.refresh(false); fTree.expandAll(); updateCheckState(); updateButtons(); fTree.getControl().setRedraw(true); } }); fPluginModeButton.setSelection(true); GridData gd = new GridData(); gd.horizontalIndent = 10; fPluginModeButton.setLayoutData(gd); fFeaureModeButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { // Moving from plug-in based filtering to feature based, need to update storage ((TargetDefinition) fTargetDefinition).setUIMode(TargetDefinition.MODE_FEATURE); contentChanged(); fTargetDefinition.setIncluded(null); fGroupLabel.setEnabled(false); if (fGroupCombo != null) { fGroupCombo.setEnabled(false); } else { fGroupComboPart.getControl().setEnabled(false); } fTree.getControl().setRedraw(false); fTree.refresh(false); fTree.expandAll(); updateCheckState(); updateButtons(); fTree.getControl().setRedraw(true); } }); fFeaureModeButton.setSelection(false); gd = new GridData(); gd.horizontalIndent = 10; fFeaureModeButton.setLayoutData(gd); fShowPluginsButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (!fShowPluginsButton.getSelection()) { fTree.addFilter(fPluginFilter); } else { fTree.removeFilter(fPluginFilter); fTree.expandAll(); updateCheckState(); } updateButtons(); } }); fShowPluginsButton.setSelection(true); gd = new GridData(); gd.horizontalIndent = 10; fShowPluginsButton.setLayoutData(gd); fShowSourceButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (!fShowSourceButton.getSelection()) { fTree.addFilter(fSourceFilter); } else { fTree.removeFilter(fSourceFilter); fTree.expandAll(); updateCheckState(); } updateButtons(); } }); fShowSourceButton.setSelection(true); gd = new GridData(); gd.horizontalIndent = 10; fShowSourceButton.setLayoutData(gd); }
/** @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; }