@Override public boolean checkFieldsValue() { checkConnectionBtn.setEnabled(false); if (enableGroup) { if (!validText(userNameText.getText())) { updateStatus(IStatus.ERROR, Messages.getString("OozieForm.nameInvalid")); // $NON-NLS-1$ return false; } } if (validText(userNameText.getText()) && !HadoopParameterValidator.isValidUserName(userNameText.getText())) { updateStatus( IStatus.ERROR, Messages.getString("OozieForm.nameInvalid.invalid")); // $NON-NLS-1$ return false; } if (!validText(endPonitText.getText())) { updateStatus(IStatus.ERROR, Messages.getString("OozieForm.endPointInvalid")); // $NON-NLS-1$ return false; } if (!HadoopParameterValidator.isValidOozieEndPoint(endPonitText.getText())) { updateStatus( IStatus.ERROR, Messages.getString("OozieForm.endPointInvalid.invalid")); // $NON-NLS-1$ return false; } checkConnectionBtn.setEnabled(true); updateStatus(IStatus.OK, null); return true; }
/** * addButtonControls. * * @param cancelButton */ @Override protected void addUtilsButtonListeners() { // Event guessButton guessButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { // changed by hqzhang for TDI-13613, old code is strange, maybe caused by duplicated // addUtilsButtonListeners() in addFields() method if (connectionItem.getConnection().isContextMode()) { connectionItem.getConnection().setContextName(null); } initGuessSchema(); LdifFileConnection originalValueConnection = getOriginalValueConnection(); // if no file, the process don't be executed if (originalValueConnection.getFilePath() == null || originalValueConnection.getFilePath().equals("")) { // $NON-NLS-1$ informationLabel.setText( " " + Messages.getString("FileStep3.filepathAlert") // $NON-NLS-1$ //$NON-NLS-2$ + " "); //$NON-NLS-1$ return; } if (!new File(originalValueConnection.getFilePath()).exists()) { String msg = Messages.getString("FileStep3.fileNotExist"); // $NON-NLS-1$ informationLabel.setText( MessageFormat.format(msg, originalValueConnection.getFilePath())); return; } if (tableEditorView.getMetadataEditor().getBeanCount() > 0) { if (MessageDialog.openConfirm( getShell(), Messages.getString("FileStep3.guessConfirmation"), Messages //$NON-NLS-1$ .getString("FileStep3.guessConfirmationMessage"))) { // $NON-NLS-1$ runShadowProcess(); } return; } runShadowProcess(); } }); if (cancelButton != null) { // Event CancelButton cancelButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { getShell().close(); } }); } }
@Override protected void addFields() { // Header Fields Composite mainComposite = Form.startNewDimensionnedGridLayout(this, 2, WIDTH_GRIDDATA_PIXEL, 60); metadataNameText = new LabelledText( mainComposite, Messages.getString("FileStep3.metadataName")); // $NON-NLS-1$ metadataCommentText = new LabelledText( mainComposite, Messages.getString("FileStep3.metadataComment")); // $NON-NLS-1$ // Group MetaData Group groupMetaData = Form.createGroup( this, 1, Messages.getString("FileStep3.groupMetadata"), 280); // $NON-NLS-1$ Composite compositeMetaData = Form.startNewGridLayout(groupMetaData, 1); // Composite Guess Composite compositeGuessButton = Form.startNewDimensionnedGridLayout(compositeMetaData, 2, WIDTH_GRIDDATA_PIXEL, 40); informationLabel = new Label(compositeGuessButton, SWT.NONE); informationLabel.setText( Messages.getString("FileStep3.informationLabel") + " "); //$NON-NLS-1$ //$NON-NLS-2$ informationLabel.setSize(500, HEIGHT_BUTTON_PIXEL); guessButton = new UtilsButton( compositeGuessButton, Messages.getString("FileStep3.guess"), WIDTH_BUTTON_PIXEL, //$NON-NLS-1$ HEIGHT_BUTTON_PIXEL); guessButton.setToolTipText(Messages.getString("FileStep3.guessTip")); // $NON-NLS-1$ // Composite MetadataTableEditorView Composite compositeTable = Form.startNewDimensionnedGridLayout(compositeMetaData, 1, WIDTH_GRIDDATA_PIXEL, 200); compositeTable.setLayout(new FillLayout()); metadataEditor = new MetadataEmfTableEditor( Messages.getString("FileStep3.metadataDescription")); // $NON-NLS-1$ tableEditorView = new MetadataEmfTableEditorView(compositeTable, SWT.NONE); if (!isInWizard()) { // Bottom Button Composite compositeBottomButton = Form.startNewGridLayout(this, 2, false, SWT.CENTER, SWT.CENTER); // Button Cancel cancelButton = new UtilsButton( compositeBottomButton, Messages.getString("CommonWizard.cancel"), WIDTH_BUTTON_PIXEL, //$NON-NLS-1$ HEIGHT_BUTTON_PIXEL); } // addUtilsButtonListeners(); changed by hqzhang, need not call here, has been called in // setupForm() }
@Override protected void addUtilsButtonListeners() { checkConnectionBtn.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { checkConnection(); } }); }
/** DOC ocarbone Comment method "adaptFormToReadOnly". */ @Override protected void adaptFormToReadOnly() { readOnly = isReadOnly(); guessButton.setEnabled(!isReadOnly()); metadataNameText.setReadOnly(isReadOnly()); metadataCommentText.setReadOnly(isReadOnly()); tableEditorView.setReadOnly(isReadOnly()); // if (getParent().getChildren().length == 1) { // open the table // guessButton.setEnabled(false); // informationLabel.setVisible(false); // } }
private void addCheckFields() { Composite checkGroup = new Composite(this, SWT.NONE); GridLayout checkGridLayout = new GridLayout(1, false); checkGroup.setLayout(checkGridLayout); GridData checkGridData = new GridData(GridData.FILL_HORIZONTAL); checkGridData.minimumHeight = 5; checkGroup.setLayoutData(checkGridData); Composite checkButtonComposite = Form.startNewGridLayout(checkGroup, 1, false, SWT.CENTER, SWT.BOTTOM); GridLayout checkButtonLayout = (GridLayout) checkButtonComposite.getLayout(); checkButtonLayout.marginHeight = 0; checkButtonLayout.marginTop = 0; checkButtonLayout.marginBottom = 0; checkButtonLayout.marginLeft = 0; checkButtonLayout.marginRight = 0; checkButtonLayout.marginWidth = 0; checkConnectionBtn = new UtilsButton( checkButtonComposite, Messages.getString("OozieForm.check"), WIDTH_BUTTON_PIXEL, HEIGHT_BUTTON_PIXEL); //$NON-NLS-1$ checkConnectionBtn.setEnabled(false); }
/** * addButtonControls. * * @param cancelButton */ @Override protected void addUtilsButtonListeners() { // Event guessButton guessButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { if (tableEditorView.getMetadataEditor().getBeanCount() > 0) { if (!guessButton.getEnabled()) { guessButton.setEnabled(true); if (MessageDialog.openConfirm( getShell(), Messages.getString("FileStep3.guessConfirmation"), Messages //$NON-NLS-1$ .getString("FileStep3.guessConfirmationMessage"))) { // $NON-NLS-1$ runShadowProcess(); } } else { guessButton.setEnabled(false); } } else { if (!guessButton.getEnabled()) { guessButton.setEnabled(true); runShadowProcess(); } else { guessButton.setEnabled(false); } } } }); // Event addTable Button addTableButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { if (!addTableButton.getEnabled()) { addTableButton.setEnabled(true); addMetadataTable(); } else { addTableButton.setEnabled(false); } } }); removeTableButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (!removeTableButton.getEnabled()) { removeTableButton.setEnabled(true); TableItem[] selection = tableNavigator.getSelection(); if (selection != null && selection.length > 0) { boolean openConfirm = MessageDialog.openConfirm( getShell(), "Confirm", "Are you sure to delete this schema ?"); if (openConfirm) { for (TableItem item : selection) { if (tableNavigator.indexOf(item) != -1) { EList<SalesforceModuleUnit> modules = temConnection.getModules(); for (int i = 0; i < modules.size(); i++) { if (modules.get(i).getModuleName().equals(moduleName)) { for (int j = 0; j < modules.get(i).getTables().size(); j++) { if (item.getText() .equals(modules.get(i).getTables().get(j).getLabel())) { modules.get(i).getTables().remove(j); } } } } tableNavigator.remove(tableNavigator.indexOf(item)); if (tableNavigator.getItemCount() > 1) { tableNavigator.setSelection( tableNavigator.getItem(tableNavigator.getItemCount() - 1)); } } } initTreeNavigatorNodes(); } } } else { removeTableButton.setEnabled(false); } } }); if (cancelButton != null) { // Event CancelButton cancelButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { getShell().close(); } }); } }
@Override protected void addFields() { int leftCompositeWidth = 125; int rightCompositeWidth = WIDTH_GRIDDATA_PIXEL - leftCompositeWidth; int headerCompositeHeight = 80; int tableSettingsCompositeHeight = 15; int tableCompositeHeight = 200; int height = headerCompositeHeight + tableSettingsCompositeHeight + tableCompositeHeight; // Header Fields Composite mainComposite = Form.startNewDimensionnedGridLayout(this, 2, WIDTH_GRIDDATA_PIXEL, 60); SashForm sash = new SashForm(mainComposite, SWT.HORIZONTAL); GridData sashData = new GridData(GridData.FILL_BOTH); sash.setLayoutData(sashData); Composite leftComposite = Form.startNewDimensionnedGridLayout(sash, 1, leftCompositeWidth, height); Composite rightComposite = Form.startNewDimensionnedGridLayout(sash, 1, rightCompositeWidth, height); sash.setWeights(new int[] {1, 5}); addTreeNavigator(leftComposite, leftCompositeWidth, height); metadataNameText = new LabelledText( rightComposite, Messages.getString("FileStep3.metadataName")); // $NON-NLS-1$ metadataCommentText = new LabelledText( rightComposite, Messages.getString("FileStep3.metadataComment")); // $NON-NLS-1$ // Group MetaData Group groupMetaData = Form.createGroup( rightComposite, 1, Messages.getString("FileStep3.groupMetadata"), 280); // $NON-NLS-1$ Composite compositeMetaData = Form.startNewGridLayout(groupMetaData, 1); // Composite Guess Composite compositeGuessButton = Form.startNewDimensionnedGridLayout(compositeMetaData, 2, WIDTH_GRIDDATA_PIXEL, 40); informationLabel = new Label(compositeGuessButton, SWT.NONE); informationLabel.setText( Messages.getString("FileStep3.informationLabel") + " "); //$NON-NLS-1$ //$NON-NLS-2$ informationLabel.setSize(500, HEIGHT_BUTTON_PIXEL); guessButton = new UtilsButton( compositeGuessButton, Messages.getString("FileStep3.guess"), WIDTH_BUTTON_PIXEL, //$NON-NLS-1$ HEIGHT_BUTTON_PIXEL); guessButton.setToolTipText(Messages.getString("FileStep3.guessTip")); // $NON-NLS-1$ // Composite MetadataTableEditorView Composite compositeTable = Form.startNewDimensionnedGridLayout(compositeMetaData, 1, WIDTH_GRIDDATA_PIXEL, 200); compositeTable.setLayout(new FillLayout()); metadataEditor = new MetadataEmfTableEditor( Messages.getString("FileStep3.metadataDescription")); // $NON-NLS-1$ tableEditorView = new MetadataEmfTableEditorView(compositeTable, SWT.NONE); if (!isInWizard()) { // Bottom Button Composite compositeBottomButton = Form.startNewGridLayout(this, 2, false, SWT.CENTER, SWT.CENTER); // Button Cancel cancelButton = new UtilsButton( compositeBottomButton, Messages.getString("CommonWizard.cancel"), WIDTH_BUTTON_PIXEL, //$NON-NLS-1$ HEIGHT_BUTTON_PIXEL); } addUtilsButtonListeners(); }