List of usage examples for org.eclipse.jface.dialogs IDialogConstants OK_ID
int OK_ID
To view the source code for org.eclipse.jface.dialogs IDialogConstants OK_ID.
Click Source Link
From source file:com.amalto.workbench.dialogs.SimpleXpathInputDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { // Should not really be here but well,.... parent.getShell().setText(this.title); Composite composite = (Composite) super.createDialogArea(parent); GridLayout layout = (GridLayout) composite.getLayout(); layout.numColumns = 2;//from w w w. ja va 2s . co m Label dialogMessageLbl = new Label(composite, SWT.NULL); dialogMessageLbl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); dialogMessageLbl.setText(dialogMessage); final Text textControl = new Text(composite, SWT.BORDER | SWT.SINGLE); textControl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); ((GridData) textControl.getLayoutData()).minimumWidth = 300; final ControlDecoration deco = new ControlDecoration(textControl, SWT.TOP | SWT.LEFT); Image image = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_ERROR) .getImage(); deco.setImage(image); deco.hide(); textControl.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { SimpleXpathInputDialog.this.xpath = textControl.getText(); btnSep.setEnabled(xpath != null && xpath.length() > 0); boolean validXpath = pkXPaths.contains(xpath); if (getButton(IDialogConstants.OK_ID) != null) { getButton(IDialogConstants.OK_ID).setEnabled(validXpath); } if (validXpath) { deco.hide(); } else { deco.show(); deco.setDescriptionText(Messages.InvalidXpathForFK); } } }); Button xpathButton = new Button(composite, SWT.PUSH | SWT.CENTER); xpathButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1)); xpathButton.setImage(ImageCache.getCreatedImage(EImage.DOTS_BUTTON.getPath())); xpathButton.setToolTipText(Messages.SchematronExpressBuilder_selectXPath); xpathButton.addSelectionListener(new SelectionAdapter() { private IXPathSelectionFilter xpathSelectionFilter; @Override public void widgetSelected(SelectionEvent e) { XpathSelectDialog dlg = getNewXpathSelectDialog(parentPage, dataModelName); // new XpathSelectDialog(parentPage.getSite().getShell(), parentPage.getXObject() // .getParent(), "Select Xpath", parentPage.getSite(), false, dataModelName); dlg.setSelectionFilter(getXPathSelectionFilter()); dlg.setLock(lock); dlg.setBlockOnOpen(true); dlg.open(); if (dlg.getReturnCode() == Window.OK) { textControl.setText(dlg.getXpath()); dlg.close(); } } private IXPathSelectionFilter getXPathSelectionFilter() { if (xpathSelectionFilter == null) { xpathSelectionFilter = new SimpleXPathSelectionFilter(); } return xpathSelectionFilter; } }); textControl.forceFocus(); btnSep = new Button(composite, SWT.CHECK); btnSep.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1)); btnSep.setText(Messages.SimpleXpathInputDialog_sepFkTabPanel); btnSep.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { sepFk = btnSep.getSelection(); } }); // init value textControl.setText(initialValue == null ? "" : initialValue);//$NON-NLS-1$ btnSep.setSelection(sepFk); return composite; }
From source file:com.amalto.workbench.dialogs.SimpleXpathInputDialog.java
License:Open Source License
@Override protected void createButtonsForButtonBar(Composite parent) { super.createButtonsForButtonBar(parent); getButton(IDialogConstants.OK_ID).addSelectionListener(this.caller); getButton(IDialogConstants.CANCEL_ID).addSelectionListener(this.caller); getButton(IDialogConstants.OK_ID).setEnabled(false); }
From source file:com.amalto.workbench.dialogs.SimpleXpathInputDialog.java
License:Open Source License
@Override protected void okPressed() { setReturnCode(OK);/*from w w w. ja v a 2 s .c om*/ getButton(IDialogConstants.OK_ID).setData("dialog", SimpleXpathInputDialog.this);//$NON-NLS-1$ // no close let Action Handler handle it }
From source file:com.amalto.workbench.dialogs.VariableDefinitionDialog.java
License:Open Source License
protected Control createDialogArea(Composite parent) { parent.getShell().setText(title);/*w ww . j av a 2s . c om*/ Composite composite = (Composite) super.createDialogArea(parent); GridLayout layout = (GridLayout) composite.getLayout(); layout.numColumns = 2; descriptionsViewer = new TableViewer(composite, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION); descriptionsViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); ((GridData) descriptionsViewer.getControl().getLayoutData()).heightHint = 100; // Set up the underlying table Table table = descriptionsViewer.getTable(); final String columnTitle = Messages.VariableDefinitionDialog_AvailableVariables; new TableColumn(table, SWT.CENTER).setText(columnTitle); table.getColumn(0).setWidth(350); table.setHeaderVisible(true); table.setLinesVisible(true); CellEditor[] editors = new CellEditor[1]; editors[0] = new TextCellEditor(table); descriptionsViewer.setCellEditors(editors); descriptionsViewer.setContentProvider(new IStructuredContentProvider() { public void dispose() { } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } public Object[] getElements(Object inputElement) { ArrayList<String> descs = (ArrayList<String>) inputElement; return descs.toArray(); } }); // set the label provider descriptionsViewer.setLabelProvider(new ITableLabelProvider() { public boolean isLabelProperty(Object element, String property) { return false; } public void dispose() { } public void addListener(ILabelProviderListener listener) { } public void removeListener(ILabelProviderListener listener) { } public String getColumnText(Object element, int columnIndex) { // return element.toString().toLowerCase(); return element.toString(); } public Image getColumnImage(Object element, int columnIndex) { return null; } }); descriptionsViewer.setColumnProperties(new String[] { columnTitle }); descriptionsViewer.setCellModifier(new ICellModifier() { public boolean canModify(Object element, String property) { return false; } public void modify(Object element, String property, Object value) { } public Object getValue(Object element, String property) { return element.toString(); } }); descriptionsViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); outPut = (String) selection.getFirstElement(); getButton(IDialogConstants.OK_ID).setEnabled(true); } }); descriptionsViewer.setInput(inputList); descriptionsViewer.refresh(); return composite; }
From source file:com.amalto.workbench.dialogs.VariableDefinitionDialog.java
License:Open Source License
protected void createButtonsForButtonBar(Composite parent) { super.createButtonsForButtonBar(parent); getButton(IDialogConstants.OK_ID).setEnabled(false); }
From source file:com.amalto.workbench.dialogs.ViewInputDialog.java
License:Open Source License
@Override protected void createButtonsForButtonBar(Composite parent) { // create OK and Cancel buttons by default okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); // do this here because setting the text will set enablement on the ok // button/*w w w . ja va 2 s.c o m*/ okButton.setEnabled(false); }
From source file:com.amalto.workbench.dialogs.ViewInputDialog.java
License:Open Source License
public void setErrorMessage(String errorMessage) { this.errorMessage = errorMessage; if (errorMessageText != null && !errorMessageText.isDisposed()) { errorMessageText.setText(errorMessage == null ? " \n " : errorMessage);//$NON-NLS-1$ boolean hasError = errorMessage != null && (StringConverter.removeWhiteSpaces(errorMessage)).length() > 0; errorMessageText.setEnabled(hasError); errorMessageText.setVisible(hasError); errorMessageText.getParent().update(); Control button = getButton(IDialogConstants.OK_ID); if (button != null) { button.setEnabled(errorMessage == null); }// ww w .ja v a2s . com } }
From source file:com.amalto.workbench.dialogs.XpathSelectDialog.java
License:Open Source License
protected void provideViwerContent(XSDSchema xsdSchema, String filter) { drillDownAdapter = new DrillDownAdapter(domViewer); domViewer.setLabelProvider(new XSDTreeLabelProvider(selectionFilter)); XPathTreeContentProvider provider = new XPathTreeContentProvider(this.site, xsdSchema, parent, filter); // filter the entity with the filter text but not the concept name. // provider.setConceptName(this.conceptName); domViewer.setContentProvider(provider); domViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent e) { StructuredSelection sel = (StructuredSelection) e.getSelection(); xpath = getXpath(sel);/*from w w w . java 2s .c o m*/ xpathText.setText(xpath); boolean enable = false; if (selectionFilter == null) { enable = xpath.length() > 0; } else { enable = xpath.length() > 0 && (selectionFilter.check(sel.getFirstElement()) == FilterResult.ENABLE); } getButton(IDialogConstants.OK_ID).setEnabled(enable); } }); domViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true)); domViewer.setSorter(new ViewerSorter() { @Override public int category(Object element) { // we want facets before Base TypeDefinitions in // SimpleTypeDefinition if (element instanceof XSDFacet) { return 100; } // unique keys after element declarations and before other keys if (element instanceof XSDIdentityConstraintDefinition) { XSDIdentityConstraintDefinition icd = (XSDIdentityConstraintDefinition) element; if (icd.getIdentityConstraintCategory().equals(XSDIdentityConstraintCategory.UNIQUE_LITERAL)) { return 300; } else if (icd.getIdentityConstraintCategory() .equals(XSDIdentityConstraintCategory.KEY_LITERAL)) { return 301; } else { return 302; } } return 200; } @Override public int compare(Viewer theViewer, Object e1, Object e2) { int cat1 = category(e1); int cat2 = category(e2); return cat1 - cat2; } }); domViewer.setInput(site); }
From source file:com.amalto.workbench.dialogs.XpathSelectDialog.java
License:Open Source License
@Override protected Control createButtonBar(Composite parent) { Control btnBar = super.createButtonBar(parent); getButton(IDialogConstants.OK_ID).setText(Messages._Add); return btnBar; }
From source file:com.amalto.workbench.editors.dialog.ConfirmFireEventWithInputDialog.java
License:Open Source License
@Override protected void buttonPressed(int buttonId) { if (buttonId == IDialogConstants.OK_ID) { isFireDeletingEvent = fireEventComp.isFireEvent(); source = fireEventComp.getSource(); isInvokeBeforeDelting = fireEventComp.isInvokeBeforeProcess(); }/* www . j a v a2 s . c o m*/ super.buttonPressed(buttonId); }