List of usage examples for org.eclipse.jface.dialogs IDialogConstants OK_LABEL
String OK_LABEL
To view the source code for org.eclipse.jface.dialogs IDialogConstants OK_LABEL.
Click Source Link
From source file:net.sf.eclipsecs.ui.config.RuleConfigurationEditDialog.java
License:Open Source License
protected void createButtonsForButtonBar(Composite parent) { Button defautlt = createButton(parent, IDialogConstants.BACK_ID, Messages.RuleConfigurationEditDialog_btnDefaul, false); defautlt.setEnabled(!mReadonly);// w w w. ja v a2 s . c om // create OK and Cancel buttons by default createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); }
From source file:net.sf.eclipsecs.ui.stats.views.internal.CheckstyleMarkerFilterDialog.java
License:Open Source License
/** * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) *///from w w w. j a v a2 s . co m protected void createButtonsForButtonBar(Composite parent) { mBtnDefault = createButton(parent, IDialogConstants.BACK_ID, Messages.CheckstyleMarkerFilterDialog_btnRestoreDefault, false); mBtnDefault.addSelectionListener(mController); // create OK and Cancel buttons by default createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); }
From source file:net.sf.eclipsensis.dialogs.NSISAboutDialog.java
License:Open Source License
/** * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(Composite) */// w ww . j a v a 2 s. c o m @Override protected void createButtonsForButtonBar(Composite parent) { // create OK button createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); }
From source file:net.sf.eclipsensis.dialogs.NSISAssociatedHeadersPropertyPage.java
License:Open Source License
@Override public Control createControl(final Composite parent) { mOriginalHeaders = mHeaderAssociationManager .getAssociatedHeaders((IFile) ((NSISProperties) mSettings).getResource()); mHeaders = new HashSet<IFile>(); initHeaders();/* w ww . ja v a 2 s. c om*/ final IFilter filter = new IFilter() { public boolean select(Object toTest) { if (toTest instanceof IFile) { String ext = ((IFile) toTest).getFileExtension(); if (ext != null && ext.equalsIgnoreCase(INSISConstants.NSH_EXTENSION)) { return mHeaders != null && !mHeaders.contains(toTest); } } return false; } }; Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(2, false); composite.setLayout(layout); Label l = new Label(composite, SWT.NONE); l.setText(EclipseNSISPlugin.getResourceString("associated.headers.title")); //$NON-NLS-1$ GridData data = new GridData(SWT.FILL, SWT.FILL, true, false); data.horizontalSpan = 2; l.setLayoutData(data); Table table = new Table(composite, SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.BORDER); table.setHeaderVisible(true); table.setLinesVisible(true); TableColumn column = new TableColumn(table, SWT.LEFT, 0); column.setText(EclipseNSISPlugin.getResourceString("associated.headers.column.label")); //$NON-NLS-1$ table.addControlListener(new TableResizer()); mViewer = new TableViewer(table); mViewer.setContentProvider(new CollectionContentProvider()); mViewer.setLabelProvider(new CollectionLabelProvider() { @Override public String getColumnText(Object element, int columnIndex) { if (element instanceof IFile) { return ((IFile) element).getFullPath().toString(); } return null; } }); mViewer.setComparator(new ViewerComparator() { @Override public int compare(Viewer viewer, Object e1, Object e2) { if (e1 instanceof IFile && e2 instanceof IFile) { return ((IFile) e1).getFullPath().toString().compareTo(((IFile) e2).getFullPath().toString()); } return super.compare(viewer, e1, e2); } }); data = new GridData(SWT.FILL, SWT.FILL, true, true); data.verticalSpan = 2; table.setLayoutData(data); Button addButton = new Button(composite, SWT.PUSH); addButton.setImage(CommonImages.ADD_ICON); addButton.setToolTipText(EclipseNSISPlugin.getResourceString("add.associated.header.toolip")); //$NON-NLS-1$ addButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent arg0) { FileSelectionDialog dialog = new FileSelectionDialog(parent.getShell(), ((NSISProperties) mSettings).getResource().getParent(), filter); dialog.setDialogMessage(EclipseNSISPlugin.getResourceString("nsis.script.prompt")); //$NON-NLS-1$ dialog.setHelpAvailable(false); if (dialog.open() == Window.OK) { IFile file = dialog.getFile(); IFile script = mHeaderAssociationManager.getAssociatedScript(file); if (script != null && !script.equals(((NSISProperties) mSettings).getResource()) && mReassociateHeaderWarning.getSelection()) { MessageDialogWithToggle dlg = new MessageDialogWithToggle(parent.getShell(), EclipseNSISPlugin.getResourceString("confirm.title"), //$NON-NLS-1$ EclipseNSISPlugin.getShellImage(), EclipseNSISPlugin.getFormattedString("associated.header.warning", //$NON-NLS-1$ new String[] { file.getFullPath().toString(), script.getFullPath().toString() }), MessageDialog.QUESTION, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0, EclipseNSISPlugin.getResourceString("associated.header.toggle.message"), false); //$NON-NLS-1$ dlg.open(); if (dialog.getReturnCode() == IDialogConstants.OK_ID) { mReassociateHeaderWarning.setSelection(!dlg.getToggleState()); } else { return; } } if (!mHeaders.contains(file)) { mHeaders.add(file); mViewer.refresh(false); } } } }); addButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false)); final Button removeButton = new Button(composite, SWT.PUSH); removeButton.setImage(CommonImages.DELETE_ICON); removeButton.setToolTipText(EclipseNSISPlugin.getResourceString("remove.associated.header.toolip")); //$NON-NLS-1$ removeButton.setEnabled(false); removeButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent arg0) { IStructuredSelection sel = (IStructuredSelection) mViewer.getSelection(); if (!sel.isEmpty()) { mHeaders.removeAll(sel.toList()); mViewer.refresh(false); } } }); data = new GridData(SWT.FILL, SWT.TOP, false, false); data.verticalSpan = 2; removeButton.setLayoutData(data); Composite c = new Composite(composite, SWT.NONE); data = new GridData(SWT.FILL, SWT.FILL, true, false); c.setLayoutData(data); layout = new GridLayout(2, false); layout.marginWidth = layout.marginHeight = 0; layout.horizontalSpacing = 3; c.setLayout(layout); mReassociateHeaderWarning = new Button(c, SWT.CHECK); mReassociateHeaderWarning.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false)); mReassociateHeaderWarning.setSelection(NSISPreferences.getInstance().getPreferenceStore() .getBoolean(INSISPreferenceConstants.WARN_REASSOCIATE_HEADER)); l = new Label(c, SWT.WRAP); l.setText(EclipseNSISPlugin.getResourceString("show.associated.header.warning.label")); //$NON-NLS-1$ l.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, false)); mViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); removeButton.setEnabled((selection != null && !selection.isEmpty())); } }); mViewer.setInput(mHeaders); PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, INSISConstants.PLUGIN_CONTEXT_PREFIX + "nsis_assochdrproperties_context"); //$NON-NLS-1$ return composite; }
From source file:net.sf.eclipsensis.dialogs.NSISTemplateWizardDialog.java
License:Open Source License
@Override protected void createButtonsForButtonBar(Composite parent) { super.createButtonsForButtonBar(parent); getButton(IDialogConstants.FINISH_ID).setText(IDialogConstants.OK_LABEL); }
From source file:net.sf.eclipsensis.editor.NSISEditor.java
License:Open Source License
@Override protected void installTextDragAndDrop(ISourceViewer viewer) { if (mTextDragAndDropEnabled || viewer == null) { return;//from www . j a va2 s . c o m } if (mTextDragAndDropInstalled) { mTextDragAndDropEnabled = true; return; } final IDragAndDropService dndService = (IDragAndDropService) getSite() .getService(IDragAndDropService.class); if (dndService == null) { return; } mTextDragAndDropEnabled = true; final StyledText st = viewer.getTextWidget(); // Install drag source final ISelectionProvider selectionProvider = viewer.getSelectionProvider(); final DragSource source = new DragSource(st, DND.DROP_COPY | DND.DROP_MOVE); source.setTransfer(new Transfer[] { TextTransfer.getInstance() }); source.addDragListener(new DragSourceAdapter() { String mSelectedText; Point mSelection; @Override public void dragStart(DragSourceEvent event) { mTextDragAndDropToken = null; if (!mTextDragAndDropEnabled) { event.doit = false; event.image = null; return; } try { mSelection = st.getSelection(); int offset = st.getOffsetAtLocation(new Point(event.x, event.y)); Point p = st.getLocationAtOffset(offset); if (p.x > event.x) { offset--; } event.doit = offset > mSelection.x && offset < mSelection.y; ISelection selection = selectionProvider.getSelection(); if (selection instanceof ITextSelection) { mSelectedText = ((ITextSelection) selection).getText(); } else { mSelectedText = st.getSelectionText(); } } catch (IllegalArgumentException ex) { event.doit = false; } } @Override public void dragSetData(DragSourceEvent event) { event.data = mSelectedText; mTextDragAndDropToken = this; // Can be any non-null object } @Override public void dragFinished(DragSourceEvent event) { try { if (event.detail == DND.DROP_MOVE && validateEditorInputState()) { Point newSelection = st.getSelection(); int length = mSelection.y - mSelection.x; int delta = 0; if (newSelection.x < mSelection.x) { delta = length; } st.replaceTextRange(mSelection.x + delta, length, ""); //$NON-NLS-1$ if (mTextDragAndDropToken == null) { // Move in same editor - end compound change IRewriteTarget target = (IRewriteTarget) getAdapter(IRewriteTarget.class); if (target != null) { target.endCompoundChange(); } } } } finally { mTextDragAndDropToken = null; } } }); // Install drag target DropTargetListener dropTargetListener = new DropTargetAdapter() { private Point mSelection; @Override public void dragEnter(DropTargetEvent event) { if (NSISCommandTransfer.INSTANCE.isSupportedType(event.currentDataType) || FileTransfer.getInstance().isSupportedType(event.currentDataType)) { //Don't want default feedback- we will do it ourselves event.feedback = DND.FEEDBACK_NONE; if (event.detail == DND.DROP_DEFAULT) { event.detail = DND.DROP_COPY; } } else { mTextDragAndDropToken = null; mSelection = st.getSelection(); if (!mTextDragAndDropEnabled) { event.detail = DND.DROP_NONE; event.feedback = DND.FEEDBACK_NONE; return; } if (event.detail == DND.DROP_DEFAULT) { event.detail = DND.DROP_MOVE; } } } @Override public void dragOperationChanged(DropTargetEvent event) { if (NSISCommandTransfer.INSTANCE.isSupportedType(event.currentDataType) || FileTransfer.getInstance().isSupportedType(event.currentDataType)) { // Don't want default feedback- we will do it ourselves event.feedback = DND.FEEDBACK_NONE; if (event.detail == DND.DROP_DEFAULT) { event.detail = DND.DROP_COPY; } } else { if (!mTextDragAndDropEnabled) { event.detail = DND.DROP_NONE; event.feedback = DND.FEEDBACK_NONE; return; } if (event.detail == DND.DROP_DEFAULT) { event.detail = DND.DROP_MOVE; } } } @Override public void dragOver(DropTargetEvent event) { if (NSISCommandTransfer.INSTANCE.isSupportedType(event.currentDataType) || FileTransfer.getInstance().isSupportedType(event.currentDataType)) { // Don't want default feedback- we will do it ourselves event.feedback = DND.FEEDBACK_NONE; st.setFocus(); Point location = st.getDisplay().map(null, st, event.x, event.y); location.x = Math.max(0, location.x); location.y = Math.max(0, location.y); int offset; try { offset = st.getOffsetAtLocation(new Point(location.x, location.y)); } catch (IllegalArgumentException ex) { try { offset = st.getOffsetAtLocation(new Point(0, location.y)); } catch (IllegalArgumentException ex2) { offset = st.getCharCount(); Point maxLocation = st.getLocationAtOffset(offset); if (location.y >= maxLocation.y) { if (location.x < maxLocation.x) { offset = st.getOffsetAtLocation(new Point(location.x, maxLocation.y)); } } } } IDocument doc = getDocumentProvider().getDocument(getEditorInput()); offset = getCaretOffsetForInsertCommand(doc, offset); st.setCaretOffset(offset); } else { if (!mTextDragAndDropEnabled) { event.feedback = DND.FEEDBACK_NONE; return; } event.feedback |= DND.FEEDBACK_SCROLL; } } @Override public void drop(DropTargetEvent event) { if (NSISCommandTransfer.INSTANCE.isSupportedType(event.currentDataType)) { insertCommand((NSISCommand) event.data, false); } else if (FileTransfer.getInstance().isSupportedType(event.currentDataType)) { int dropNSISFilesAction = NSISPreferences.getInstance().getPreferenceStore() .getInt(DROP_EXTERNAL_FILES_ACTION); switch (dropNSISFilesAction) { case DROP_EXTERNAL_FILES_ASK: MessageDialog dialog = new MessageDialog(getSite().getShell(), EclipseNSISPlugin.getResourceString("drop.external.files.ask.title"), //$NON-NLS-1$ EclipseNSISPlugin.getShellImage(), EclipseNSISPlugin.getResourceString("drop.external.files.ask.message"), //$NON-NLS-1$ MessageDialog.QUESTION, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0); if (dialog.open() != 0) { break; } //$FALL-THROUGH$ case DROP_EXTERNAL_FILES_OPEN_IN_EDITORS: openFiles((String[]) event.data); return; default: break; } insertFiles((String[]) event.data); } else { try { if (!mTextDragAndDropEnabled) { return; } if (mTextDragAndDropToken != null && event.detail == DND.DROP_MOVE) { // Move in same editor int caretOffset = st.getCaretOffset(); if (mSelection.x <= caretOffset && caretOffset <= mSelection.y) { event.detail = DND.DROP_NONE; return; } // Start compound change IRewriteTarget target = (IRewriteTarget) getAdapter(IRewriteTarget.class); if (target != null) { target.beginCompoundChange(); } } if (!validateEditorInputState()) { event.detail = DND.DROP_NONE; return; } String text = (String) event.data; Point newSelection = st.getSelection(); st.insert(text); st.setSelectionRange(newSelection.x, text.length()); } finally { mTextDragAndDropToken = null; } } } }; dndService.addMergedDropTarget(st, DND.DROP_DEFAULT | DND.DROP_MOVE | DND.DROP_COPY, new Transfer[] { NSISCommandTransfer.INSTANCE, FileTransfer.getInstance(), TextTransfer.getInstance() }, dropTargetListener); mTextDragAndDropInstalled = true; mTextDragAndDropEnabled = true; }
From source file:net.sf.eclipsensis.installoptions.actions.INIFileDeleteControlAction.java
License:Open Source License
@Override protected boolean doRun2(INIFile iniFile, INISection section) { boolean showOnShift = InstallOptionsPlugin.getDefault().getPreferenceStore() .getBoolean(IInstallOptionsConstants.PREFERENCE_DELETE_CONTROL_WARNING); if (!showOnShift || WinAPI.INSTANCE.getKeyState(WinAPI.VK_SHIFT) < 0) { MessageDialogWithToggle dialog = new MessageDialogWithToggle( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), mEditor.getPartName(), InstallOptionsPlugin.getShellImage(), InstallOptionsPlugin.getFormattedString("delete.control.action.warning", //$NON-NLS-1$ new String[] { section.getName() }), MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0, InstallOptionsPlugin.getResourceString("delete.control.warning.toggle.label"), showOnShift); //$NON-NLS-1$ dialog.open();// w w w . j av a 2s .co m if (dialog.getReturnCode() == IDialogConstants.OK_ID) { InstallOptionsPlugin.getDefault().getPreferenceStore().setValue( IInstallOptionsConstants.PREFERENCE_DELETE_CONTROL_WARNING, dialog.getToggleState()); } else { return false; } } iniFile.removeChild(section); iniFile.update(INILine.VALIDATE_FIX_ERRORS); updateDocument(iniFile, section); return true; }
From source file:net.sf.eclipsensis.installoptions.actions.PreviewAction.java
License:Open Source License
@Override public void run() { if (mEditor != null) { Shell shell = mEditor.getSite().getShell(); if (mEditor.isDirty()) { boolean autosaveBeforePreview = mPreferenceStore .getBoolean(IInstallOptionsConstants.PREFERENCE_AUTOSAVE_BEFORE_PREVIEW); boolean shouldSave = autosaveBeforePreview; if (!shouldSave) { MessageDialogWithToggle dialog = new MessageDialogWithToggle(shell, EclipseNSISPlugin.getResourceString("confirm.title"), //$NON-NLS-1$ InstallOptionsPlugin.getShellImage(), InstallOptionsPlugin.getResourceString("save.before.preview.confirm"), //$NON-NLS-1$ MessageDialog.QUESTION, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0, InstallOptionsPlugin.getResourceString("confirm.toggle.message"), false); //$NON-NLS-1$ dialog.open();/*w ww . j a v a 2s .c o m*/ shouldSave = dialog.getReturnCode() == IDialogConstants.OK_ID; if (shouldSave && dialog.getToggleState()) { mPreferenceStore.setValue(IInstallOptionsConstants.PREFERENCE_AUTOSAVE_BEFORE_PREVIEW, true); } } if (shouldSave) { ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell); dialog.open(); IProgressMonitor progressMonitor = dialog.getProgressMonitor(); mEditor.doSave(progressMonitor); dialog.close(); if (progressMonitor.isCanceled()) { return; } } else { return; } } INIFile iniFile = mEditor.getINIFile(); if (iniFile.hasErrors()) { Common.openError(shell, InstallOptionsPlugin.getResourceString("ini.errors.preview.error"), //$NON-NLS-1$ InstallOptionsPlugin.getShellImage()); return; } INISection settings = iniFile.findSections(InstallOptionsModel.SECTION_SETTINGS)[0]; INIKeyValue numFields = settings.findKeyValues(InstallOptionsModel.PROPERTY_NUMFIELDS)[0]; if (Integer.parseInt(numFields.getValue()) <= 0) { Common.openError(shell, InstallOptionsPlugin.getResourceString("ini.numfields.preview.error"), //$NON-NLS-1$ InstallOptionsPlugin.getShellImage()); } else { IPathEditorInput editorInput = NSISEditorUtilities.getPathEditorInput(mEditor); if (editorInput instanceof IFileEditorInput) { IFile file = ((IFileEditorInput) editorInput).getFile(); if (file.exists()) { IPath location = file.getLocation(); if (location != null) { doPreview(iniFile, location.toFile()); } else { Common.openError(shell, EclipseNSISPlugin.getResourceString("local.filesystem.error"), //$NON-NLS-1$ InstallOptionsPlugin.getShellImage()); } } } else if (editorInput != null) { doPreview(iniFile, new File(editorInput.getPath().toOSString())); } } } }
From source file:net.sf.eclipsensis.settings.NSISPreferences.java
License:Open Source License
public void fileChanged(int type, File file) { if (file.equals(mNSISHome == null ? null : mNSISHome.getNSISExe().getFile())) { final String message; switch (type) { case FileMonitor.FILE_MODIFIED: case FileMonitor.FILE_CREATED: message = EclipseNSISPlugin.getResourceString("makensis.modified.message"); //$NON-NLS-1$ break; case FileMonitor.FILE_DELETED: message = EclipseNSISPlugin.getResourceString("makensis.deleted.message"); //$NON-NLS-1$ break; default://from w w w. ja va 2s . co m return; } final String nsisHome = mNSISHome.getLocation().getAbsolutePath(); mNSISHome = null; final boolean silent = !mPreferenceStore.getBoolean(NOTIFY_MAKENSIS_CHANGED); if (silent) { setBestNSISHome(nsisHome); if (mListeners.size() > 0) { new NSISHomeChangedRunnable(null, mNSISHome).run(new NullProgressMonitor()); } Display.getDefault().syncExec(new Runnable() { public void run() { maybeConfigure(); } }); } else { Display.getDefault().asyncExec(new Runnable() { public void run() { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); MessageDialogWithToggle dialog = new MessageDialogWithToggle(shell, EclipseNSISPlugin.getDefault().getName(), EclipseNSISPlugin.getShellImage(), message, MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL }, 0, EclipseNSISPlugin.getResourceString("notify.makensis.changed.toggle"), silent); //$NON-NLS-1$ dialog.open(); mPreferenceStore.setValue(NOTIFY_MAKENSIS_CHANGED, !dialog.getToggleState()); BusyIndicator.showWhile(shell.getDisplay(), new Runnable() { public void run() { setBestNSISHome(nsisHome); fireNSISHomeChanged(null, mNSISHome); } }); maybeConfigure(); } }); } } }
From source file:net.sf.eclipsensis.util.Common.java
License:Open Source License
public static boolean openConfirm(Shell parent, String title, String message, Image icon) { MessageDialog dialog = new MessageDialog(parent, title, icon, message, MessageDialog.QUESTION, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0); return dialog.open() == 0; }